diff --git a/CL_server.php b/CL_server.php index 7ecc3822..7a5cd4fd 100644 --- a/CL_server.php +++ b/CL_server.php @@ -449,6 +449,10 @@ function guessPilots($chunkSize=5) { // we pull data from this server } // print_r($samePilots); + echo "
";
+		echo "# ------------------------------------\n";
+		echo "DELETE FROM leonardo_remote_pilots  WHERE remoteServerID=".$this->ID."; \n";
+
 		foreach($samePilots as $remoteUserID=>$arr1) 
 			foreach($arr1 as $remoteUserServerID=>$arr2) 
 				foreach($arr2 as $localUserID=>$arr3)  
@@ -457,13 +461,17 @@ function guessPilots($chunkSize=5) { // we pull data from this server
 						$pilotInfo=getPilotInfo($localUserID,$localUserServerID );
 						
 						$remotePilotInfo=$remotePilotNames[$remoteUserID][$remoteUserServerID];
-						echo "$remoteUserServerID _$remoteUserID  $localUserServerID _$localUserID  = $counts 
"; - echo " [ ".$remotePilotInfo['lName']." ".$remotePilotInfo['fName']." country: ".$remotePilotInfo['country']." sex: ".$remotePilotInfo['sex']." birthdate: ".$remotePilotInfo['birthdate']." CIVL ID: ".$remotePilotInfo['CIVL_ID']." ]
"; - echo " [ ".$pilotInfo['0']." ".$pilotInfo['1']." country: ".$pilotInfo['2']." sex: ".$pilotInfo['3']." birthdate: ".$pilotInfo['4']." CIVL ID: ".$pilotInfo['5']." ]
"; + if ($remoteUserServerID==0) $remoteUserServerID=$this->ID; + echo "# ------------------------------------\n"; + echo "# REMOTE [ ".$remotePilotInfo['lName']." ".$remotePilotInfo['fName']." country: ".$remotePilotInfo['country']." sex: ".$remotePilotInfo['sex']." birthdate: ".$remotePilotInfo['birthdate']." CIVL ID: ".$remotePilotInfo['CIVL_ID']." ] \n"; + echo "# LOCAL [ ".$pilotInfo['0']." ".$pilotInfo['1']." country: ".$pilotInfo['2']." sex: ".$pilotInfo['3']." birthdate: ".$pilotInfo['4']." CIVL ID: ".$pilotInfo['5']." ] \n"; + echo "# $remoteUserServerID"."_$remoteUserID $localUserServerID"."_$localUserID = $counts \n"; + echo "INSERT INTO leonardo_remote_pilots VALUES ( $remoteUserServerID,$remoteUserID,$localUserServerID,$localUserID);\n"; } - echo "
Sync-log replication finished

"; + echo "
"; + echo "
Finished guessing pilots

"; echo "Proccessed $entriesNum flight's hashes out of $item_num
"; } diff --git a/FN_waypoint.php b/FN_waypoint.php index 152ce097..75556a8f 100644 --- a/FN_waypoint.php +++ b/FN_waypoint.php @@ -264,6 +264,11 @@ function selectWaypointLocation($name,$intName,$countryCode,$forceIntl=-1) { return $tname; } +function countryCodeToLanguage($countryCode) { + global $lang2iso; + if ( ($lang=array_search(strtolower($countryCode),$lang2iso)) === NULL ) $lang=''; + return $lang; +} function countryHasLang($countryCode,$language) { global $CONFIG_langsSpoken; diff --git a/GUI_admin.php b/GUI_admin.php index 3647bc37..670b33d4 100644 --- a/GUI_admin.php +++ b/GUI_admin.php @@ -100,6 +100,8 @@ function chmodDir($dir){ echo "
  • Convert waypoints from iso -> UTF8 "; echo "
  • Clean Photos Table (NOT USED !!!) "; echo "
  • Migrate to new Photos table (NOT USED !!!) "; + echo "
    "; + echo "
  • Convert takeoffs from iso to utf8 "; echo ""; echo "

    Sync Log oparations

    "; @@ -131,6 +133,64 @@ function chmodDir($dir){ deleteFiles(dirname(__FILE__)."/flights",0,".json.js"); } else if ($admin_op=="cleanOldJSfiles") { deleteFiles(dirname(__FILE__)."/flights",0,".1.js"); + } else if ($admin_op=="convertTakeoffs") { + $res= $db->sql_query('SET NAMES latin1'); + // $query="SELECT * from $waypointsTable WHERE countryCode='RU'"; + $query="SELECT * from $waypointsTable order By countryCode "; + + //$query=" UPDATE leonardo_waypoints SET name='Schwand', intName='Schwand', lat='47.0142', lon='-8.58312', type='1000', countryCode='CH', location='Brunnen', intLocation='Brunnen', link='http://paragliding.ch/index.php?id=129', description='Startplatz Schwand: 47° 00' 50'' N,8° 35' 05'' O 1250m Bisenstartplatz. In 15 minutigem Fussmarsch zu erreichen ab Bergstation. Gute Soaring Moglichkeiten bei Bise und Nordwind. Flug nach Seewen oder zuruck zur Talstation. Um zur Talstation zu fliegen nach dem Start rechts dem Hang entlang fliegen und vor der Hochspannungsleitung rechts ins Lee fliegen. Das zuruckfliegen im Lee ist bei nicht allzu starkem Wind kein Problem. ', modifyDate='2007-01-24' WHERE ID=9265"; + $res= $db->sql_query($query); +//echo "#$res#"; +//return; + echo "
    ";
    +		while ($row = mysql_fetch_assoc($res)) { 	
    +			$convertInAction=0;
    +			$sqlStr="  UPDATE $waypointsTable SET ";
    +			$orgValues="# UPDATE $waypointsTable SET ";
    +
    +			$enc=$langEncodings[ countryCodeToLanguage($row['countryCode']) ];
    +			if (!$enc) $enc='iso-8859-1';
    +
    +			// $orgValues.=" [$enc] ";
    +			// echo "ecn: $enc 
    "; + foreach($row as $varName=>$varVal ) { + + $varVal=str_replace("\r\n",'',trim($varVal)); + $varVal=str_replace("\n",'',trim($varVal)); + // $varVal=htmlspecialchars($varVal,ENT_QUOTES,"UTF-8"); + //$varVal=str_replace('&','&',$varVal); + // $varVal=str_replace('"','"',$varVal); + //$varVal=str_replace('<','<',$varVal); + //$varVal=str_replace('>','>',$varVal); + // $varVal=prep_for_DB($varVal); + + + $varValUtf8=iconv($enc,'utf8',$varVal); + if ($varValUtf8!=$varVal) $convertInAction=1; + +// $varValUtf8=str_replace("\r\n",'
    ',trim($varValUtf8)); +// $varValUtf8=str_replace("\n",'
    ',trim($varValUtf8)); + + $varValUtf8=htmlspecialchars($varValUtf8,ENT_QUOTES,"UTF-8"); + // $varValUtf8=str_replace('&','&',$varValUtf8); + $varValUtf8=str_replace('"','"',$varValUtf8); + $varValUtf8=str_replace('<','<',$varValUtf8); + $varValUtf8=str_replace('>','>',$varValUtf8); + + if ($varName!='ID') { + $sqlStr.=" $varName='".$varValUtf8."',"; + $orgValues.=" $varName='$varVal',"; + } + } + $sqlStr=substr($sqlStr,0,-1); + $orgValues=substr($orgValues,0,-1); + $sqlStr.=" WHERE ID=".$row['ID']; + $orgValues.=" WHERE ID=".$row['ID']; + //if ($convertInAction || $row['ID']==9265) echo "$orgValues\n$sqlStr;\n#\n"; + if ($convertInAction ) echo "$orgValues\n$sqlStr;\n#\n"; + } + echo "
    "; + } else if ($admin_op=="fixTakeoffNames") { $ar1=array('name'=>'intName','intName'=>'name','location'=>'intLocation','intLocation'=>'location'); foreach ($ar1 as $n1=>$n2){ diff --git a/doc/install/sql/convert_flights_to_utf8.sql b/doc/install/sql/convert_flights_to_utf8.sql new file mode 100644 index 00000000..53a9116d --- /dev/null +++ b/doc/install/sql/convert_flights_to_utf8.sql @@ -0,0 +1,100 @@ +CREATE TABLE leonardo_flights_new ( + ID bigint(20) unsigned NOT NULL auto_increment, + serverID smallint(5) unsigned NOT NULL default '0', + originalURL varchar(255) NOT NULL default '', + originalKML varchar(255) NOT NULL, + original_ID mediumint(8) unsigned NOT NULL default '0', + cat smallint(5) unsigned NOT NULL default '1', + subcat smallint(5) unsigned NOT NULL default '1', + category smallint(5) unsigned NOT NULL default '2', + active smallint(6) NOT NULL default '0', + dateAdded datetime NOT NULL default '0000-00-00 00:00:00', + timesViewed mediumint(9) NOT NULL default '0', + userID mediumint(8) unsigned NOT NULL default '0', + originalUserID mediumint(8) unsigned NOT NULL default '0', + userServerID mediumint(8) unsigned NOT NULL default '0', + filename varchar(200) NOT NULL default '', + place varchar(100) NOT NULL default '', + glider varchar(50) NOT NULL default '', + gliderBrandID smallint(5) unsigned NOT NULL default '0', + comments text NOT NULL, + linkURL varchar(200) NOT NULL default '', + hasPhotos tinyint(3) unsigned NOT NULL default '0', + photo1Filename varchar(150) NOT NULL default '', + photo2Filename varchar(150) NOT NULL default '', + photo3Filename varchar(150) NOT NULL default '', + photo4Filename varchar(150) NOT NULL default '', + photo5Filename varchar(150) NOT NULL default '', + photo6Filename varchar(150) NOT NULL default '', + takeoffID mediumint(9) NOT NULL default '0', + takeoffVinicity float NOT NULL default '0', + landingID mediumint(9) NOT NULL default '0', + landingVinicity float NOT NULL default '0', + `DATE` date NOT NULL default '0000-00-00', + timezone float NOT NULL default '0', + MAX_SPEED float NOT NULL default '0', + MEAN_SPEED float NOT NULL default '0', + MAX_ALT int(11) NOT NULL default '0', + MIN_ALT int(11) NOT NULL default '0', + TAKEOFF_ALT int(11) NOT NULL default '0', + MAX_VARIO float NOT NULL default '0', + MIN_VARIO float NOT NULL default '0', + LINEAR_DISTANCE bigint(20) NOT NULL default '0', + MAX_LINEAR_DISTANCE bigint(20) NOT NULL default '0', + START_TIME mediumint(9) NOT NULL default '0', + END_TIME mediumint(9) NOT NULL default '0', + DURATION mediumint(9) NOT NULL default '0', + BEST_FLIGHT_TYPE varchar(30) NOT NULL default '', + FLIGHT_KM float NOT NULL default '0', + FLIGHT_POINTS float NOT NULL default '0', + autoScore float NOT NULL default '0', + isLive tinyint(3) unsigned NOT NULL default '0', + externalFlightType tinyint(3) unsigned NOT NULL default '0', + forceBounds tinyint(3) unsigned NOT NULL default '0', + firstPointTM int(10) unsigned NOT NULL default '0', + firstLat float NOT NULL, + firstLon float NOT NULL, + lastPointTM int(10) unsigned NOT NULL default '0', + lastLat float NOT NULL, + lastLon float NOT NULL, + FIRST_POINT varchar(50) NOT NULL default '', + LAST_POINT varchar(50) NOT NULL default '', + turnpoint1 varchar(100) NOT NULL default '', + turnpoint2 varchar(100) NOT NULL default '', + turnpoint3 varchar(100) NOT NULL default '', + turnpoint4 varchar(100) NOT NULL default '', + turnpoint5 varchar(100) NOT NULL default '', + olcRefNum varchar(30) NOT NULL default '', + olcFilename varchar(12) NOT NULL default '', + olcDateSubmited datetime NOT NULL default '0000-00-00 00:00:00', + private tinyint(3) unsigned NOT NULL default '0', + gpsTrack tinyint(3) unsigned NOT NULL default '1', + grecord smallint(6) NOT NULL default '0', + validated smallint(6) NOT NULL default '0', + validationMessage text NOT NULL, + airspaceCheck tinyint(4) NOT NULL default '0', + airspaceCheckFinal tinyint(4) NOT NULL default '0', + airspaceCheckMsg text NOT NULL, + checkedBy varchar(100) NOT NULL default '', + NACid int(10) unsigned NOT NULL default '0', + NACclubID bigint(20) NOT NULL default '0', + `hash` varchar(100) NOT NULL default '', + batchOpProcessed tinyint(3) unsigned NOT NULL default '0', + PRIMARY KEY (ID), + KEY userID (userID), + KEY takeoffID (takeoffID), + KEY takeoffID_2 (takeoffID), + KEY NACClubIndex (NACclubID,NACid) +) ENGINE=MyISAM DEFAULT CHARSET=utf8 ; + +INSERT INTO `leonardo_flights_new` +SELECT * +FROM `leonardo_flights` ; + + +ALTER TABLE `leonardo_flights` RENAME `leonardo_flights_iso` ; + +ALTER TABLE `leonardo_flights_new` RENAME `leonardo_flights` ; + + + diff --git a/doc/install/sql/convert_pilots_to_utf8.sql b/doc/install/sql/convert_pilots_to_utf8.sql new file mode 100644 index 00000000..fa19d9fb --- /dev/null +++ b/doc/install/sql/convert_pilots_to_utf8.sql @@ -0,0 +1,68 @@ +CREATE TABLE leonardo_pilots_new ( +`pilotID` bigint( 20 ) NOT NULL default '0', +`serverID` smallint( 5 ) unsigned NOT NULL default '0', +`countryCode` char( 2 ) NOT NULL default '', +`CIVL_ID` mediumint( 8 ) unsigned NOT NULL default '0', +`NACid` int( 10 ) unsigned NOT NULL default '0', +`NACmemberID` bigint( 20 ) unsigned NOT NULL default '0', +`NACclubID` bigint( 20 ) NOT NULL default '0', +`olcBirthDate` varchar( 8 ) NOT NULL default '', +`olcFirstName` varchar( 100 ) NOT NULL default '', +`olcLastName` varchar( 100 ) NOT NULL default '', +`olcCallSign` varchar( 50 ) NOT NULL default '', +`olcFilenameSuffix` varchar( 4 ) NOT NULL default '', +`olcAutoSubmit` tinyint( 4 ) NOT NULL default '0', +`FirstName` varchar( 40 ) NOT NULL default '', +`LastName` varchar( 50 ) NOT NULL default '', +`clubID` mediumint( 8 ) unsigned NOT NULL default '0', +`sponsor` varchar( 255 ) default NULL , +`Sex` varchar( 6 ) NOT NULL default '', +`Birthdate` varchar( 15 ) NOT NULL default '', +`BirthdateHideMask` varchar( 10 ) NOT NULL default 'xx.xx.xxxx', +`Occupation` varchar( 100 ) NOT NULL default '', +`MartialStatus` varchar( 20 ) NOT NULL default '', +`OtherInterests` longtext NOT NULL , +`PersonalWebPage` varchar( 150 ) NOT NULL default '', +`PilotLicence` varchar( 100 ) NOT NULL default '', +`BestMemory` longtext NOT NULL , +`WorstMemory` longtext NOT NULL , +`Training` varchar( 200 ) NOT NULL default '', +`personalDistance` varchar( 150 ) NOT NULL default '', +`personalHeight` varchar( 150 ) NOT NULL default '', +`glider` varchar( 200 ) NOT NULL default '', +`FlyingSince` varchar( 100 ) NOT NULL default '', +`HoursFlown` varchar( 50 ) NOT NULL default '', +`HoursPerYear` varchar( 50 ) NOT NULL default '', +`FavoriteLocation` varchar( 250 ) NOT NULL default '', +`UsualLocation` varchar( 150 ) NOT NULL default '', +`FavoriteBooks` varchar( 150 ) NOT NULL default '', +`FavoriteActors` varchar( 150 ) NOT NULL default '', +`FavoriteSingers` varchar( 150 ) NOT NULL default '', +`FavoriteMovies` varchar( 150 ) NOT NULL default '', +`FavoriteSite` varchar( 150 ) NOT NULL default '', +`Sign` varchar( 40 ) NOT NULL default '', +`Spiral` varchar( 60 ) NOT NULL default '', +`Bline` varchar( 100 ) NOT NULL default '', +`FullStall` varchar( 100 ) NOT NULL default '', +`Sat` varchar( 100 ) NOT NULL default '', +`AsymmetricSpiral` varchar( 100 ) NOT NULL default '', +`Spin` varchar( 100 ) NOT NULL default '', +`OtherAcro` varchar( 150 ) NOT NULL default '', +`camera` varchar( 150 ) NOT NULL default '', +`camcorder` varchar( 150 ) NOT NULL default '', +`Vario` varchar( 60 ) NOT NULL default '', +`GPS` varchar( 60 ) NOT NULL default '', +`Harness` varchar( 60 ) NOT NULL default '', +`Reserve` varchar( 60 ) NOT NULL default '', +`Helmet` varchar( 60 ) NOT NULL default '', +`PilotPhoto` varchar( 30 ) NOT NULL default '', +`FirstOlcYear` int( 10 ) NOT NULL default '0', +PRIMARY KEY ( `pilotID` , `serverID` ) +) ENGINE = MYISAM DEFAULT CHARSET = utf8 ; + +INSERT INTO `leonardo_pilots_new` SELECT * FROM `leonardo_pilots` ; + + +ALTER TABLE `leonardo_pilots` RENAME `leonardo_pilots_iso` ; + +ALTER TABLE `leonardo_pilots_new` RENAME `leonardo_pilots` ; diff --git a/doc/install/sql/convert_waypoints_to_utf8.sql b/doc/install/sql/convert_waypoints_to_utf8.sql new file mode 100644 index 00000000..f3ba605a --- /dev/null +++ b/doc/install/sql/convert_waypoints_to_utf8.sql @@ -0,0 +1,22 @@ +CREATE TABLE `leonardo_waypoints_new` ( +`ID` mediumint( 9 ) NOT NULL AUTO_INCREMENT , +`name` varchar( 100 ) NOT NULL default '', +`intName` varchar( 100 ) NOT NULL default '', +`lat` float NOT NULL default '0', +`lon` float NOT NULL default '0', +`type` int( 11 ) NOT NULL default '0', +`countryCode` varchar( 10 ) NOT NULL default 'GR', +`location` varchar( 100 ) NOT NULL default '', +`intLocation` varchar( 100 ) NOT NULL default '', +`link` varchar( 255 ) NOT NULL default '', +`description` text NOT NULL , +`modifyDate` date NOT NULL default '2005-09-01', +PRIMARY KEY ( `ID` ) , +KEY `lat` ( `lat` , `lon` ) +) ENGINE = MYISAM DEFAULT CHARSET = utf8 ; + +INSERT INTO `leonardo_waypoints_new` SELECT * FROM `leonardo_waypoints` ; + +ALTER TABLE `leonardo_waypoints` RENAME `leonardo_waypoints_iso` ; + +ALTER TABLE `leonardo_waypoints_new` RENAME `leonardo_waypoints` ; diff --git a/index.php b/index.php index c073ffbf..b061363e 100644 --- a/index.php +++ b/index.php @@ -58,7 +58,9 @@ function leo_getmicrotime() { require_once dirname(__FILE__)."/templates/".$PREFS->themeName."/theme.php"; // if we use utf - if ($CONF_use_utf) $db->sql_query("SET NAMES utf8"); +if ($CONF_use_utf) { + $db->sql_query("SET NAMES utf8"); +} $pagetitle = _PAGE_TITLE;