Ejemplo n.º 1
0
	function movePilotFlights($newServerID,$newUserID){
		$newPilot=new pilot($newServerID,$newUserID);
		if (!$newPilot->pilotExists()) {
			echo "movePilotFlights($newServerID,$newUserID): The target pilot does not exist<BR>";
			return 0;
		}
		
		global $db,$flightsTable;
		// first see if a mapping exists
		
		$query="SELECT ID FROM $flightsTable WHERE userID=".$this->pilotID.
				" AND userServerID=".$this->serverID." ";
		
			
		$res= $db->sql_query($query);		
		if($res <= 0){
			echo("<H3> Error in movePilotFlights query! $query</H3>\n");
			return 0;
		}	
		while (  $row = $db->sql_fetchrow($res) ) {	
			echo "moving flight ".$row['ID'].'<BR>';
			// continue;
			$flight2move=new flight();
			$flight2move->getFlightFromDB($row['ID']);
			$flight2move->changeUser($newUserID,$newServerID);
		}
		
	}
Ejemplo n.º 2
0
 function checkPilot($serverID, $pilotArray)
 {
     global $remotePilotsTable, $db;
     // echo "####"; print_r($pilotArray);
     /*  [pilot] => Array
     			(
     				[userID] => 347
     				[civlid] => 0
     				[userName] => 
     				[pilotFirstName] => �������
     				[pilotLastName] => ����������
     				[pilotCountry] => gr
     				[pilotBirthdate] => 
     				[pilotSex] => 
     			)
     		*/
     // first see if a mapping exists
     $query = "SELECT * FROM {$remotePilotsTable}  \n\t\tWHERE \t\t\n\t\t\t\t( serverID=" . ($serverID + 0) . " AND userID=" . $pilotArray['userID'] . " ) OR \n\t\t\t\t( remoteServerID=" . ($serverID + 0) . " AND remoteUserID=" . $pilotArray['userID'] . " ) ORDER BY serverID ASC";
     $res = $db->sql_query($query);
     if ($res <= 0) {
         echo "<H3> Error in checkPilot query! {$query}</H3>\n";
         return array(0, 0);
     }
     // if a mapping exists return the local user instead
     // we must take care for this case :
     // 1 : 12_101678 <-> 0_2527
     // 2 : 12_101678 <-> 5_3219
     // 3 : 5_3219 <-> 0_2527
     // if we have 12_101678 and we are on server 1 (pgforum) we must map to 0_2527 instead of 5_3219
     // if we have 12_101678 and we are on server 10002 (dhv mirror) we must map to 5_3219 instead of 1_2527
     $map = array();
     while ($row = $db->sql_fetchrow($res)) {
         if ($serverID == $row['serverID'] && $pilotArray['userID'] == $row['userID']) {
             $map[$row['remoteServerID']] = $row['remoteUserID'];
         } else {
             $map[$row['serverID']] = $row['userID'];
         }
     }
     if (count($map)) {
         // print_r($map);
         uksort($map, "pilotServerCmp");
         $ar1 = array_keys($map);
         $ar2 = array_values($map);
         //echo $ar1[0] .", ".$ar2[0] ."<BR>";
         // a mapping is taking place, we must log this somehow when we return from this function!!!
         return array($ar1[0], $ar2[0]);
     }
     /*				 old way 
     		if (  $row = $db->sql_fetchrow($res) ) {
     			if ($row['userID']) 
     				return array($row['serverID'],$row['userID']);		
     		}
     		*/
     // else we insert/update the external pilot
     $update = 1;
     $pilot = new pilot($serverID, $pilotArray['userID']);
     $pilot->createDirs();
     if (!$pilot->pilotExists()) {
         //echo "pilot $serverID ".$pilotArray['userID']." does not exists";
         $update = 0;
     }
     $pilot->pilotID = $pilotArray['userID'];
     $pilot->CIVL_ID = $pilotArray['civlID'];
     //$pilot->FirstName=$pilotArray['userName'];
     $pilot->FirstName = $pilotArray['pilotFirstName'];
     $pilot->LastName = $pilotArray['pilotLastName'];
     $pilot->FirstNameEn = $pilotArray['pilotFirstNameEn'];
     $pilot->LastNameEn = $pilotArray['pilotLastNameEn'];
     $pilot->countryCode = $pilotArray['pilotCountry'];
     $pilot->Birthdate = $pilotArray['pilotBirthdate'];
     $pilot->Sex = $pilotArray['pilotSex'];
     $pilot->putToDB($update);
     return array($serverID, $pilotArray['userID']);
 }