Subversion Repositories eFlore/Applications.cel

Rev

Rev 541 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 541 Rev 582
Line 304... Line 304...
304
					break;
304
					break;
305
				case MILIEU:
305
				case MILIEU:
306
					$info_milieu="000null";
306
					$info_milieu="000null";
307
					break;
307
					break;
308
				case DEPARTEMENT:
308
				case DEPARTEMENT:
-
 
309
		            /*if (!isset ($info_commune['code']) || $info_commune['code']=='') {
309
					$info_commune['code']="000null";
310
					    $info_commune['code']="000null";
-
 
311
                    }*/
310
					break;
312
					break;
311
				case LATITUDE:
313
				case LATITUDE:
312
					$info_latitude="000null";
314
					$info_latitude="000null";
313
					break;
315
					break;
314
				case LONGITUDE:
316
				case LONGITUDE:
Line 322... Line 324...
322
 
324
 
Line 323... Line 325...
323
                $this->dernier_ordre++;
325
                $this->dernier_ordre++;
324
 
326
 
325
                list($jour,$mois,$annee)=split("/",$info_dateobs);
-
 
326
                $info_dateobs=$annee."-".$mois."-".$jour." 0:0:0";
327
                list($jour,$mois,$annee)=split("/",$info_dateobs);
327
 
328
                $info_dateobs=$annee."-".$mois."-".$jour." 0:0:0";
328
                $query  = "INSERT INTO cel_inventory (identifiant,ordre,nom_sel,num_nom_sel,nom_ret,num_nom_ret,num_taxon,famille,location,id_location,date_observation,lieudit,station, milieu, commentaire, date_creation,date_modification,coord_x,coord_y) " .
329
                $query  = "INSERT INTO cel_inventory (identifiant,ordre,nom_sel,num_nom_sel,nom_ret,num_nom_ret,num_taxon,famille,location,id_location,date_observation,lieudit,station, milieu, commentaire, date_creation,date_modification,coord_x,coord_y) " .
329
                    " VALUES('".$DB->escapeSimple($utilisateur)."','".
330
                    " VALUES('".$DB->escapeSimple($utilisateur)."','".
330
                    $DB->escapeSimple($this->dernier_ordre)."','".
331
                    $DB->escapeSimple($this->dernier_ordre)."','".
Line 344... Line 345...
344
                    "now() , now(),'".
345
                    "now() , now(),'".
345
                    $DB->escapeSimple($info_latitude)."','".
346
                    $DB->escapeSimple($info_latitude)."','".
346
                    $DB->escapeSimple($info_longitude)."')";
347
                    $DB->escapeSimple($info_longitude)."')";
347
//		print "\n";
348
//		print "\n";
Line 348... Line -...
348
 
-
 
349
 
349
 
Line 350... Line 350...
350
		   $res =& $DB->query($query);
350
		   $res =& $DB->query($query);
351
 
351
 
352
                if (PEAR::isError($res)) {
352
                if (PEAR::isError($res)) {
Line 419... Line 419...
419
                $query="SELECT DISTINCT name, code  FROM locations WHERE name like '".$DB->escapeSimple($nom_commune)."'";
419
                $query="SELECT DISTINCT name, code  FROM locations WHERE name like '".$DB->escapeSimple($nom_commune)."'";
420
            }
420
            }
421
        }
421
        }
422
	}
422
	}
Line 423... Line -...
423
 
-
 
424
	
423
 
Line 425... Line 424...
425
	$res =& $DB->query($query);
424
	$res =& $DB->query($query);
426
 
425
 
427
        if (DB::isError($res)) {
426
        if (DB::isError($res)) {
Line 436... Line 435...
436
}
435
}
Line 437... Line 436...
437
 
436
 
Line 438... Line 437...
438
function traiterLieudit($lieudit) { // texte libre
437
function traiterLieudit($lieudit) { // texte libre
439
 
-
 
-
 
438
 
440
	//echo "traitement lieudit";
439
	//echo "traitement lieudit";
441
 
440
    $lieudit=fix_latin($lieudit);
Line 442... Line 441...
442
	return utf8_encode(trim($lieudit));
441
	return trim($lieudit);
443
}
442
}
-
 
443
 
444
 
444
function traiterStation($station) { // texte libre
445
function traiterStation($station) { // texte libre
445
//	echo "traitement station";
Line 446... Line 446...
446
//	echo "traitement station";
446
    $station=fix_latin($station);
447
	return utf8_encode(trim($station));
447
	return trim($station);
-
 
448
}
448
}
449
 
449
 
450
function traiterMilieu($milieu) { // texte libre
Line 450... Line 451...
450
function traiterMilieu($milieu) { // texte libre
451
//	echo "traitement milieu";
451
//	echo "traitement milieu";
452
    $milieu=fix_latin($milieu);
452
	return utf8_encode(trim($milieu));
453
	return trim($milieu);
Line 467... Line 468...
467
	return trim($longitude);
468
	return trim($longitude);
468
}
469
}
Line 469... Line 470...
469
 
470
 
470
function traiterNotes($notes) { // texte libre
471
function traiterNotes($notes) { // texte libre
-
 
472
//	echo "traitement notes";
471
//	echo "traitement notes";
473
    $notes=remove_accent($notes);
472
	return utf8_encode(trim($notes));
474
	return utf8_encode(trim($notes));
Line 473... Line 475...
473
}
475
}
474
 
476
 
Line 839... Line 841...
839
 
841
 
Line -... Line 842...
-
 
842
 
-
 
843
 
-
 
844
}
-
 
845
 
-
 
846
function init_byte_map(){
-
 
847
    global $byte_map;
-
 
848
    for($x=128;$x<256;++$x){
-
 
849
        $byte_map[chr($x)]=utf8_encode(chr($x));
-
 
850
    }
-
 
851
    $cp1252_map=array(
-
 
852
            "\x80"=>"\xE2\x82\xAC",    // EURO SIGN
-
 
853
            "\x82" => "\xE2\x80\x9A",  // SINGLE LOW-9 QUOTATION MARK
-
 
854
            "\x83" => "\xC6\x92",      // LATIN SMALL LETTER F WITH HOOK
-
 
855
            "\x84" => "\xE2\x80\x9E",  // DOUBLE LOW-9 QUOTATION MARK
-
 
856
            "\x85" => "\xE2\x80\xA6",  // HORIZONTAL ELLIPSIS
-
 
857
            "\x86" => "\xE2\x80\xA0",  // DAGGER
-
 
858
            "\x87" => "\xE2\x80\xA1",  // DOUBLE DAGGER
-
 
859
            "\x88" => "\xCB\x86",      // MODIFIER LETTER CIRCUMFLEX ACCENT
-
 
860
            "\x89" => "\xE2\x80\xB0",  // PER MILLE SIGN
-
 
861
            "\x8A" => "\xC5\xA0",      // LATIN CAPITAL LETTER S WITH CARON
-
 
862
            "\x8B" => "\xE2\x80\xB9",  // SINGLE LEFT-POINTING ANGLE QUOTATION MARK
-
 
863
            "\x8C" => "\xC5\x92",      // LATIN CAPITAL LIGATURE OE
-
 
864
            "\x8E" => "\xC5\xBD",      // LATIN CAPITAL LETTER Z WITH CARON
-
 
865
            "\x91" => "\xE2\x80\x98",  // LEFT SINGLE QUOTATION MARK
-
 
866
            "\x92" => "\xE2\x80\x99",  // RIGHT SINGLE QUOTATION MARK
-
 
867
            "\x93" => "\xE2\x80\x9C",  // LEFT DOUBLE QUOTATION MARK
-
 
868
            "\x94" => "\xE2\x80\x9D",  // RIGHT DOUBLE QUOTATION MARK
-
 
869
            "\x95" => "\xE2\x80\xA2",  // BULLET
-
 
870
            "\x96" => "\xE2\x80\x93",  // EN DASH
-
 
871
            "\x97" => "\xE2\x80\x94",  // EM DASH
-
 
872
            "\x98" => "\xCB\x9C",      // SMALL TILDE
-
 
873
            "\x99" => "\xE2\x84\xA2",  // TRADE MARK SIGN
-
 
874
            "\x9A" => "\xC5\xA1",      // LATIN SMALL LETTER S WITH CARON
-
 
875
            "\x9B" => "\xE2\x80\xBA",  // SINGLE RIGHT-POINTING ANGLE QUOTATION MARK
-
 
876
            "\x9C" => "\xC5\x93",      // LATIN SMALL LIGATURE OE
-
 
877
            "\x9E" => "\xC5\xBE",      // LATIN SMALL LETTER Z WITH CARON
-
 
878
            "\x9F" => "\xC5\xB8"       // LATIN CAPITAL LETTER Y WITH DIAERESIS
-
 
879
                );
-
 
880
    foreach($cp1252_map as $k=>$v){
-
 
881
        $byte_map[$k]=$v;
-
 
882
    }
-
 
883
}
-
 
884
 
-
 
885
function fix_latin($instr){
-
 
886
    if(mb_check_encoding($instr,'UTF-8'))return $instr; // no need for the rest if it's all valid UTF-8 already
-
 
887
    global $nibble_good_chars,$byte_map;
-
 
888
    $outstr='';
-
 
889
    $char='';
-
 
890
    $rest='';
-
 
891
    while((strlen($instr))>0){
-
 
892
        if(1==@preg_match($nibble_good_chars,$input,$match)){
-
 
893
            $char=$match[1];
-
 
894
            $rest=$match[2];
-
 
895
            $outstr.=$char;
-
 
896
        }elseif(1==@preg_match('@^(.)(.*)$@s',$input,$match)){
-
 
897
            $char=$match[1];
-
 
898
            $rest=$match[2];
-
 
899
            $outstr.=$byte_map[$char];
-
 
900
        }
-
 
901
        $instr=$rest;
Line 840... Line 902...
840
 
902
    }
841
 
903
    return $outstr;
842
}
904
}
843
 
905