Esempio n. 1
0
                                    }
                                    $i = 0;
                                    $photoStr = '';
                                    $query = "SELECT * FROM {$photosTable} WHERE \n\t\t\t lat>={$south} AND lat<={$north} AND \n\t\t\t lon>=" . $west . " AND lon<=" . $east . " ORDER BY ID";
                                    //echo $query;
                                    $res = $db->sql_query($query);
                                    if ($res <= 0) {
                                        echo "<H3> Error in query! {$query} </H3>\n";
                                        exit;
                                    }
                                    require_once dirname(__FILE__) . '/CL_flightPhotos.php';
                                    require_once dirname(__FILE__) . '/FN_output.php';
                                    $i = 0;
                                    $photoStr = '';
                                    while ($row = mysql_fetch_assoc($res)) {
                                        $imgTarget = $moduleRelPath . '/' . flightPhotos::getPath($row['path']) . '/' . $row['name'];
                                        $imgTarget = "http://" . $_SERVER['SERVER_NAME'] . $baseInstallationPath . "/" . $imgTarget;
                                        $lineColor = "ff0000";
                                        $lineWidth = 2;
                                        $getFlightKML = "http://" . $_SERVER['SERVER_NAME'] . getDownloadLink(array('type' => 'kml_trk', 'flightID' => $row['flightID'])) . "&c={$lineColor}&w={$lineWidth}&an=0";
                                        $photoStr .= "<Placemark>\n\t\t    <name>Photo</name>\n\t\t\t<styleUrl>#marker_photo</styleUrl>\n\t\t\t<Snippet maxLines='0' ></Snippet>\n\t\t\t<description><![CDATA[<a href='{$imgTarget}'><img src='{$imgTarget}' width='" . $CONF['photos']['mid']['max_width'] . "' border='0'>\t\t\t\n\t\t\t</a><BR><BR>\n\t\t\t<strong><a href='{$getFlightKML}'>Load Track of this Photo</a></strong>\n]]></description>\n\t\t\t<Point>\n\t\t\t\t<altitudeMode>{$altitudeMode}</altitudeMode>  \t    \n\t\t\t\t<coordinates>" . $row['lon'] . "," . $row['lat'] . "," . $row['alt'] . "</coordinates>\n\t\t\t</Point>\n\t\t\t</Placemark>";
                                        $i++;
                                    }
                                    $photoNum = $i;
                                    $xml = '<?xml version="1.0" encoding="UTF-8"?>
<kml xmlns="http://www.opengis.net/kml/2.2">
<Folder>  
  <Folder>  
  	' . $styleTrack . '  
    <name>Leonardo Tracks (' . $trackNum . ')</name>
	<Snippet maxLines="0"></Snippet>
			});	
			return marker;
			
	}
	function drawPhoto(lat,lon,num,imgIcon,imgBig,width,height){ 	
			var photoPoint= new GLatLng(lat, lon) ;			
			var photoMarker = createPhotoMarker(photoPoint,num,imgIcon,imgBig,width,height);
			photoMarkers[num] = photoMarker ;	
			map.addOverlay(photoMarker );

	}
<?php 
// draw the photo positions if any
if ($flight->hasPhotos) {
    require_once dirname(__FILE__) . "/CL_flightPhotos.php";
    $flightPhotos = new flightPhotos($flight->flightID);
    $flightPhotos->getFromDB();
    // get geoinfo
    $flightPhotos->computeGeoInfo();
    $imagesHtml = "";
    foreach ($flightPhotos->photos as $photoNum => $photoInfo) {
        if ($photoInfo['lat'] && $photoInfo['lon']) {
            $imgIconRel = $flightPhotos->getPhotoRelPath($photoNum) . ".icon.jpg";
            $imgBigRel = $flightPhotos->getPhotoRelPath($photoNum);
            $imgIcon = $flightPhotos->getPhotoAbsPath($photoNum) . ".icon.jpg";
            $imgBig = $flightPhotos->getPhotoAbsPath($photoNum);
            if (file_exists($imgBig)) {
                list($width, $height, $type, $attr) = getimagesize($imgBig);
                list($width, $height) = CLimage::getJPG_NewSize($CONF['photos']['mid']['max_width'], $CONF['photos']['mid']['max_height'], $width, $height);
                $imgTarget = $imgBigRel;
            } else {
Esempio n. 3
0
 function changeUser($newUserID, $newUserServerID)
 {
     global $CONF, $CONF_photosPerFlight;
     $pilotDir = $this->getPilotAbsDir();
     if ($newUserServerID) {
         $extra_prefix = $newUserServerID . '_';
     } else {
         $extra_prefix = '';
     }
     $newPilotDir = LEONARDO_ABS_PATH . '/' . str_replace("%PILOTID%", $extra_prefix . $newUserID, $CONF['paths']['pilot']);
     // delete non critical files
     $this->deleteFile($this->getIGCFilename(1));
     $this->deleteFile($this->getIGCFilename(2));
     $this->deleteSecondaryFiles();
     $this->deleteFile($this->getMapFilename());
     for ($metric_system = 1; $metric_system <= 2; $metric_system++) {
         for ($raw = 0; $raw <= 1; $raw++) {
             # martin jursa 28.05.2008: delete using the deleteFile() method to avoid log flooding
             $this->deleteFile($this->getChartFilename("alt", $metric_system, $raw));
             $this->deleteFile($this->getChartFilename("speed", $metric_system, $raw));
             $this->deleteFile($this->getChartFilename("vario", $metric_system, $raw));
             $this->deleteFile($this->getChartFilename("takeoff_distance", $metric_system, $raw));
         }
     }
     $flightYear = $this->getYear();
     $subdirs = array('flights', 'charts', 'maps');
     // create all dirs on the target user as well in case they are missing
     $this->checkDirs($extra_prefix . $newUserID, $flightYear);
     /*
     foreach ($subdirs as $subdir){
     	$sourceDir="$pilotDir/$subdir/$flightYear";
     	$targetDir="$newPilotDir/$subdir/$flightYear";
     
     	if ($handle = opendir($sourceDir)) {
     		while (false !== ($file = readdir($handle))) {
     			if (  substr( $file,0,strlen($this->filename) )==$this->filename  ) {
     				// echo "$file\n";
     				$filesToMove[$sourceDir.'/'.$file]=$targetDir.'/'.$file;
     			}
     		}
     		closedir($handle);
     	}
     }
     
     //	this is old code, does not work nay more!
     for($i=1;$i<=$CONF_photosPerFlight;$i++) {
     	$var_name="photo".$i."Filename";
     	$file=$this->$var_name;
     	if ($file) {
     		$sourceDir="$pilotDir/photos/$flightYear";
     		$targetDir="$newPilotDir/photos/$flightYear";
     		$filesToMove[$sourceDir.'/'.$file]=$targetDir.'/'.$file;
     	}
     }
     
     array_push($subdirs,'photos');
     
     foreach ($subdirs as $subdir){
     	makeDir("$newPilotDir/$subdir");
     }
     
     foreach ($filesToMove as $src=>$target){
     	makeDir($target);
     	@rename($src,$target);
     }
     */
     // Take care of photos!
     if ($this->hasPhotos) {
         $flightPhotos = new flightPhotos($this->flightID);
         $flightPhotos->getFromDB();
         // print_r($flightPhotos->photos );
         foreach ($flightPhotos->photos as $photoNum => $photoInfo) {
             $flightPhotos->changeUser($photoNum, getPilotID($newUserServerID, $newUserID));
         }
         $flightPhotos->putToDB(0);
     }
     // store the original paths of the files
     $igcOrg = $this->getIGCFilename(0);
     // store away the original userID
     $this->originalUserID = $this->userServerID + 0 . '_' . $this->userID;
     $this->userID = $newUserID;
     $this->userServerID = $newUserServerID;
     // now move the igc file (and optionally the olc if it exists
     @rename($igcOrg, $this->getIGCFilename(0));
     @rename($igcOrg . ".olc", $this->getIGCFilename(0) . ".olc");
     //  echo "will put to db $newUserServerID $newUserID<BR>";
     $this->putFlightToDB(1);
     // take care of same flights (hide /unhide)
     $this->hideSameFlights();
     // now also log this action
 }
Esempio n. 4
0
function addFlightFromFile($filename, $calledFromForm, $userIDstr, $argArray = array())
{
    global $CONF_default_cat_add, $CONF_photosPerFlight, $CONF;
    global $CONF_NAC_list, $CONF_use_NAC, $CONF_use_validation, $CONF_airspaceChecks, $CONF_server_id;
    global $userID, $CONF_new_flights_submit_window;
    global $flightsTable;
    set_time_limit(120);
    global $CONF_server_id;
    list($thisServerID, $userIDforFlight) = splitServerPilotStr($userIDstr);
    if (!$thisServerID) {
        $thisServerID = $CONF_server_id;
    }
    require_once dirname(__FILE__) . '/CL_actionLogger.php';
    $log = new Logger();
    $log->userID = $userID + 0;
    // the userId that is logged in , not the one that the flight will be atrributed to
    $log->ItemType = 1;
    // flight;
    $log->ItemID = 0;
    // 0 at start will fill in later if successfull
    $log->ServerItemID = $thisServerID;
    $log->ActionID = 1;
    //1  => add  2  => edit;
    $log->ActionXML = '';
    $log->Modifier = 0;
    $log->ModifierID = 0;
    $log->ServerModifierID = 0;
    $log->Result = 0;
    $log->ResultDescription = "";
    if (!$filename) {
        $log->ResultDescription = getAddFlightErrMsg(ADD_FLIGHT_ERR_YOU_HAVENT_SUPPLIED_A_FLIGHT_FILE, 0);
        if (!$log->put()) {
            echo "Problem in logger<BR>";
        }
        return array(ADD_FLIGHT_ERR_YOU_HAVENT_SUPPLIED_A_FLIGHT_FILE, 0);
    }
    // now is the time to remove bad chars from the filename!
    $newFilename = str_replace("'", " ", $filename);
    $newFilename = toLatin1($newFilename);
    if ($newFilename != $filename) {
        rename($filename, $newFilename);
        $filename = $newFilename;
    }
    if (!is_file($filename)) {
        $log->ResultDescription = getAddFlightErrMsg(ADD_FLIGHT_ERR_NO_SUCH_FILE, 0);
        if (!$log->put()) {
            echo "Problem in logger<BR>";
        }
        return array(ADD_FLIGHT_ERR_NO_SUCH_FILE, 0);
    }
    if (strtolower(substr($filename, -4)) != ".igc") {
        $log->ResultDescription = getAddFlightErrMsg(ADD_FLIGHT_ERR_FILE_DOESNT_END_IN_IGC, 0);
        if (!$log->put()) {
            echo "Problem in logger<BR>";
        }
        return array(ADD_FLIGHT_ERR_FILE_DOESNT_END_IN_IGC, 0);
    }
    $tmpIGCPath = $filename;
    $flight = new flight();
    if ($thisServerID != $CONF_server_id) {
        $flight->userServerID = $thisServerID;
    }
    $flight->userID = $userIDforFlight;
    /*
    	$flight->cat=$gliderCat;
    	$flight->private=$is_private;
    	$flight->category=$category;
    	$flight->comments=$comments;
    	$flight->glider=$glider;
    	$flight->linkURL=$linkURL;
    */
    foreach ($argArray as $varName => $varValue) {
        if ($varName == 'NACclubID' || $varName == 'NACid' || $varName == 'comments') {
            continue;
        }
        $flight->{$varName} = $varValue;
    }
    $comments = $argArray['comments'];
    if ($comments) {
        $flight->commentsNum = 1;
    }
    if (strtolower(substr($flight->linkURL, 0, 7)) == "http://") {
        $flight->linkURL = substr($flight->linkURL, 7);
    }
    if ($flight->cat == -1) {
        $flight->cat = $CONF_default_cat_add;
    }
    # martin jursa 22.06.2008:
    # in case the glider is not given otherwise, try to extract it from the IGC file
    if (empty($flight->glider)) {
        $flight->glider = extractGlider($lines);
    }
    // if no brand was given , try to detect
    $flight->checkGliderBrand();
    //  we must cope with some cases here
    //  1. more flights in the igc
    //  2. garmin saved paths -> zero time difference -> SOLVED!
    if (!$flight->getFlightFromIGC($tmpIGCPath)) {
        $log->ResultDescription = getAddFlightErrMsg(ADD_FLIGHT_ERR_THIS_ISNT_A_VALID_IGC_FILE, 0);
        if (!$log->put()) {
            echo "Problem in logger<BR>";
        }
        return array(ADD_FLIGHT_ERR_THIS_ISNT_A_VALID_IGC_FILE, 0);
    }
    // Compute hash now
    $lines = file($tmpIGCPath);
    $hash = md5(implode('', $lines));
    $flight->hash = $hash;
    unset($lines);
    // check for mac newlines -> NOT USED NOW
    // we now use auto_detect_line_endings=true;
    /*
    	if ( count ($lines)==1) {
    		if ($lines[0]=preg_replace("/\r([^\n])/","\r\n\\1",$lines[0])) {		
    			DEBUG('addFlightFromFile',1,"addFlightFromFile: MAC newlines found<BR>");
    			if (!$handle = fopen($tmpIGCPath, 'w')) { 
    				print "Cannot open file ($filename)"; 
    				exit; 
    			} 
    			if (!fwrite($handle, $lines[0])) { 
    			   print "Cannot write to file ($filename)"; 
    			   exit; 
    			} 
    			fclose($handle); 
    		} 
    	}
    */
    // echo $flight->DATE	." >  ". date("Y-m-d",time()+3600*10) ."<BR>";
    // check for dates in the furure
    if ($flight->DATE > date("Y-m-d", time() + 3600 * 10)) {
        @unlink($flight->getIGCFilename(1));
        @unlink($tmpIGCPath . ".olc");
        @unlink($tmpIGCPath);
        $log->ResultDescription = getAddFlightErrMsg(ADD_FLIGHT_ERR_DATE_IN_THE_FUTURE, 0);
        if (!$log->put()) {
            echo "Problem in logger<BR>";
        }
        return array(ADD_FLIGHT_ERR_DATE_IN_THE_FUTURE, 0);
    }
    // Two week time limit check - P.Wild
    /// Modification martin jursa 08.05.2007 cancel the upload if flight is too old
    if ($CONF_new_flights_submit_window > 0) {
        if (!L_auth::isAdmin($userID)) {
            if ($flight->DATE < date("Y-m-d", time() - $CONF_new_flights_submit_window * 24 * 3600)) {
                @unlink($flight->getIGCFilename(1));
                @unlink($tmpIGCPath . ".olc");
                @unlink($tmpIGCPath);
                $log->ResultDescription = getAddFlightErrMsg(ADD_FLIGHT_ERR_OUTSIDE_SUBMIT_WINDOW, 0);
                if (!$log->put()) {
                    echo "Problem in logger<BR>";
                }
                return array(ADD_FLIGHT_ERR_OUTSIDE_SUBMIT_WINDOW, 0);
            }
        }
    }
    // end martin / peter
    $sameFilenameID = $flight->findSameFilename(basename($filename));
    if ($sameFilenameID > 0) {
        if ($flight->allowDuplicates) {
            while (is_file($flight->getIGCFilename())) {
                $flight->filename = '_' . $flight->filename;
            }
        } else {
            @unlink($flight->getIGCFilename(1));
            @unlink($tmpIGCPath . ".olc");
            @unlink($tmpIGCPath);
            $log->ResultDescription = getAddFlightErrMsg(ADD_FLIGHT_ERR_SAME_FILENAME_FLIGHT, 0);
            if (!$log->put()) {
                echo "Problem in logger<BR>";
            }
            return array(ADD_FLIGHT_ERR_SAME_FILENAME_FLIGHT, $sameFilenameID);
        }
    }
    $sameFlightsArray = $flight->findSameTime();
    if (count($sameFlightsArray) > 0) {
        if ($flight->allowDuplicates) {
            // we allow duplicates if they are from another server
            $dupFound = 0;
            foreach ($sameFlightsArray as $k => $fArr) {
                if ($fArr['serverID'] == $flight->serverID) {
                    // if a same flight from this server is present we dont re-insert
                    $dupFound = 1;
                    break;
                } else {
                    // fill in ids of flights to 'disable'
                    $disableFlightsList[$fArr['ID']]++;
                }
            }
        } else {
            $dupFound = 1;
        }
        if ($dupFound) {
            @unlink($flight->getIGCFilename(1));
            @unlink($tmpIGCPath . ".olc");
            @unlink($tmpIGCPath);
            $log->ResultDescription = getAddFlightErrMsg(ADD_FLIGHT_ERR_SAME_DATE_FLIGHT, 0);
            if (!$log->put()) {
                echo "Problem in logger<BR>";
            }
            //	return  array( ADD_FLIGHT_ERR_SAME_DATE_FLIGHT,$sameFlightsArray[0]['serverID'].'_'. $sameFlightsArray[0]['ID']);
            return array(ADD_FLIGHT_ERR_SAME_DATE_FLIGHT, $sameFlightsArray[0]['ID']);
        } else {
            DEBUG("FLIGHT", 1, "addFlightFromFile: Duplicate DATE/TIME flight will be inserted<br>");
        }
    }
    $sameFlightsArray = $flight->findSameHash($hash);
    if (count($sameFlightsArray) > 0) {
        if ($flight->allowDuplicates) {
            // we allow duplicates if they are from another server
            //echo "searching in dups ";
            //print_r($sameFlightsArray);
            $dupFound = 0;
            $flightPilot = new pilot($flight->userServerID + 0, $flight->userID + 0);
            $flightPilotMapTable = $flightPilot->pilotMapping();
            // print_r($flightPilotMapTable);
            foreach ($sameFlightsArray as $k => $fArr) {
                if ($fArr['serverID'] == $flight->serverID) {
                    // if a same flight from this server is present we dont re-insert
                    $dupFound = 1;
                    break;
                } else {
                    // check that the existing flight belongs to a pilot that is 'mapped' to
                    // $flight->userID + $flight->userServerID
                    if (!$flightPilotMapTable[$fArr['userServerID']][$fArr['userID']]) {
                        DEBUG("FLIGHT", 1, "addFlightFromFile: Same hash from external Server BUT from the pilot was not mapped into local <br>");
                        // We allow the flight to be submitted but then we must check and disable all duplicates but one
                        //$dupFound=1;
                        //break;
                    }
                    // fill in ids of flights to 'disable'
                    $disableFlightsList[$fArr['ID']]++;
                }
            }
        } else {
            // echo "no dups allowesd";
            $dupFound = 1;
        }
        if ($dupFound) {
            @unlink($flight->getIGCFilename(1));
            @unlink($tmpIGCPath . ".olc");
            @unlink($tmpIGCPath);
            $log->ResultDescription = getAddFlightErrMsg(ADD_FLIGHT_ERR_SAME_HASH_FLIGHT, 0);
            if (!$log->put()) {
                echo "Problem in logger<BR>";
            }
            return array(ADD_FLIGHT_ERR_SAME_HASH_FLIGHT, $sameFlightsArray[0]['ID']);
        } else {
            DEBUG("FLIGHT", 1, "addFlightFromFile: Duplicate HASH flight will be inserted<br>");
            // echo "addFlightFromFile: Duplicate HASH flight will be inserted<br>";
        }
    }
    // print_r($disableFlightsList);
    /*
    	if ( ! $flight->allowDuplicates ) {
    		$sameHashIDArray=$flight->findSameHash( $hash );
    		if (count($sameHashIDArray)>0) 	 {
    			@unlink($flight->getIGCFilename(1));
    			@unlink($tmpIGCPath.".olc");
    			@unlink($tmpIGCPath);
    			$log->ResultDescription=getAddFlightErrMsg(ADD_FLIGHT_ERR_SAME_HASH_FLIGHT,0);
    			if (!$log->put()) echo "Problem in logger<BR>";
    			return array(ADD_FLIGHT_ERR_SAME_HASH_FLIGHT,$sameHashIDArray[0]['serverID'].'_'.$sameHashIDArray[0]['ID']);	
    		}
    	}
    */
    //******************************************************
    // PASSED ALL TESTS , NOW DO SOME WORK WITH OUR FLIGHT
    //******************************************************
    // move the flight to corresponding year
    $flight->checkDirs();
    //$yearPath=$flightsAbsPath."/".$userIDstr."/flights/".$flight->getYear();
    //$maps_dir=$flightsAbsPath."/".$userIDstr."/maps/".$flight->getYear();
    //$charts_dir=$flightsAbsPath."/".$userIDstr."/charts/".$flight->getYear();
    //$photos_dir=$flightsAbsPath."/".$userIDstr."/photos/".$flight->getYear();
    //if (!is_dir($yearPath))  	mkdir($yearPath,0755);
    //if (!is_dir($maps_dir))  	mkdir($maps_dir,0755);
    //if (!is_dir($charts_dir))	mkdir($charts_dir,0755);
    //if (!is_dir($photos_dir))	mkdir($photos_dir,0755);
    /**
     * Martin Jursa; to avoid error log flooding
     */
    if (file_exists($tmpIGCPath)) {
        @rename($tmpIGCPath, $flight->getIGCFilename());
    }
    // in case an olc file was created too
    if (file_exists($tmpIGCPath . ".olc")) {
        @rename($tmpIGCPath . ".olc", $flight->getIGCFilename() . ".olc");
    }
    // these commands seem redundant:
    //@unlink($tmpIGCPath.".olc");
    //@unlink($tmpIGCPath);
    /*old:	@rename($tmpIGCPath, $flight->getIGCFilename() );
    	// in case an olc file was created too
    	@rename($tmpIGCPath.".olc", $flight->getIGCFilename().".olc" );
    	@unlink($tmpIGCPath.".olc");
    	@unlink($tmpIGCPath);
    */
    // if we use NACclubs
    // get the NACclubID for userID
    // and see if the flight is in the current year (as defined in the NAclist array
    if ($CONF_use_NAC) {
        require_once dirname(__FILE__) . "/CL_NACclub.php";
        list($pilotNACID, $pilotNACclubID) = NACclub::getPilotClub($userIDforFlight);
        DEBUG("FLIGHT", 1, "addFlightFromFile: pilotNACID:{$pilotNACID}, pilotNACclubID: {$pilotNACclubID}<br>");
        if ($CONF_NAC_list[$pilotNACID]['use_clubs']) {
            DEBUG("FLIGHT", 1, "addFlightFromFile: use_clubs is on<br>");
            if ($argArray['NACclubID'] > 0 && $argArray['NACid'] > 0) {
                $flight->NACclubID = $argArray['NACclubID'];
                $flight->NACid = $argArray['NACid'];
                DEBUG("FLIGHT", 1, "addFlightFromFile: using arguments NACclubID NACid<br>");
            } else {
                DEBUG("FLIGHT", 1, "addFlightFromFile: calculating  NACclubID NACid<br>");
                // check year -> we only put the club for the current season , so that results for previous seasons cannot be affected
                $currSeasonYear = $CONF_NAC_list[$pilotNACID]['current_year'];
                DEBUG("FLIGHT", 1, "addFlightFromFile: currSeasonYear:  {$currSeasonYear}<br>");
                if ($CONF_NAC_list[$pilotNACID]['periodIsNormal']) {
                    $seasonStart = $currSeasonYear - 1 . "-12-31";
                    $seasonEnd = $currSeasonYear . "-12-31";
                } else {
                    $seasonStart = $currSeasonYear - 1 . $CONF_NAC_list[$pilotNACID]['periodStart'];
                    $seasonEnd = $currSeasonYear . $CONF_NAC_list[$pilotNACID]['periodStart'];
                }
                DEBUG("FLIGHT", 1, "addFlightFromFile: seasonStart:{$seasonStart} , seasonEnd:{$seasonEnd}<br>");
                if ($flight->DATE > $seasonStart && $flight->DATE <= $seasonEnd) {
                    DEBUG("FLIGHT", 1, "addFlightFromFile: inside Season !!<br>");
                    $flight->NACclubID = $pilotNACclubID;
                    $flight->NACid = $pilotNACID;
                }
            }
        }
    }
    if ($CONF_use_validation) {
        $ok = $flight->validate(0);
        // dont update DB
    }
    if ($CONF_airspaceChecks) {
        $flight->checkAirspace(0);
        // dont update DB
    }
    $flight->putFlightToDB(0);
    // now do the photos
    if ($calledFromForm) {
        require_once dirname(__FILE__) . "/CL_flightPhotos.php";
        $flightPhotos = new flightPhotos($flight->flightID);
        // $flightPhotos->getFromDB();
        $j = 0;
        for ($i = 0; $i < $CONF_photosPerFlight; $i++) {
            $var_name = "photo" . $i . "Filename";
            $photoName = $_FILES[$var_name]['name'];
            $photoFilename = $_FILES[$var_name]['tmp_name'];
            if ($photoName) {
                if (CLimage::validJPGfilename($photoName) && CLimage::validJPGfile($photoFilename)) {
                    // $newPhotoName=toLatin1($photoName);
                    // Fix for same photo filenames 2009.02.03
                    //global $flightsAbsPath;
                    global $CONF;
                    $newPhotoName = flightPhotos::getSafeName(LEONARDO_ABS_PATH . '/' . str_replace("%PILOTID%", $flight->getPilotID(), str_replace("%YEAR%", $flight->getYear(), $CONF['paths']['photos'])), $photoName);
                    //$flightsAbsPath.'/'.$flight->getPilotID()."/photos/".$flight->getYear() ,
                    //$photoName	) ;
                    $phNum = $flightPhotos->addPhoto($j, $flight->getPilotID() . "/photos/" . $flight->getYear(), $newPhotoName, $description);
                    $photoAbsPath = $flightPhotos->getPhotoAbsPath($j);
                    if (move_uploaded_file($photoFilename, $photoAbsPath)) {
                        CLimage::resizeJPG($CONF['photos']['thumbs']['max_width'], $CONF['photos']['thumbs']['max_height'], $photoAbsPath, $photoAbsPath . ".icon.jpg", $CONF['photos']['compression']);
                        CLimage::resizeJPG($CONF['photos']['normal']['max_width'], $CONF['photos']['normal']['max_height'], $photoAbsPath, $photoAbsPath, $CONF['photos']['compression']);
                        $flight->hasPhotos++;
                        $j++;
                    } else {
                        //upload not successfull
                        $flightPhotos->deletePhoto($j);
                    }
                }
            }
        }
        // also try to get geotag info
        $flightPhotos->computeGeoInfo();
    }
    // took care of photos
    // tkae care of comments
    if ($comments) {
        global $lang2isoGoogle, $currentlang;
        $flightComments = new flightComments($flight->flightID);
        $commentInsertResult = $flightComments->addComment(array('parentID' => 0, 'userID' => $flight->userID + 0, 'userServerID' => $flight->userServerID + 0, 'guestName' => '', 'guestPass' => '', 'guestEmail' => '', 'text' => $comments, 'languageCode' => $lang2isoGoogle[$currentlang]), 0);
    }
    // now is a good time to disable duplicate flights we have found from other servers
    // AND are from the same user (using pilot's mapping table to find that out)
    global $db;
    if (0) {
        foreach ($disableFlightsList as $dFlightID => $num) {
            $query = "UPDATE {$flightsTable} SET private = private | 0x02 WHERE  ID={$dFlightID} ";
            $res = $db->sql_query($query);
            # Error checking
            if ($res <= 0) {
                echo "<H3> Error in query: {$query}</H3>\n";
            }
        }
    }
    //or
    $flight->hideSameFlights();
    set_time_limit(200);
    $flight->computeScore();
    $flight->updateTakeoffLanding();
    //	echo "TakeoffID:".$flight->takeoffID."<BR>";
    if (in_array($flight->takeoffID, $CONF['takeoffs']['private'])) {
        $flight->private = 1;
    }
    $flight->putFlightToDB(1);
    // update
    return array(1, $flight->flightID);
    // ALL OK;
}
Esempio n. 5
0
	    </div>
	  </fieldset>	</td>
    </tr>
    <tr>
      <td colspan="2"><fieldset class="legendBox legend3">
      <legend><? echo _RELEVANT_PAGE ?></legend>
	  <div align="left">
			http://<input name="linkURL" type="text" id="linkURL" size="90" value="<? echo  $flight->linkURL ?>">
	    </div>
	  </fieldset></td>
    </tr>
	<?	
		$photoNum=0;
		if ($flight->hasPhotos) {
			require_once dirname(__FILE__)."/CL_flightPhotos.php";
			$flightPhotos=new flightPhotos($flight->flightID);
			$flightPhotos->getFromDB();

		?>
		<tr>
	      <td valign="top">
		  		<table align="center">
		  			<tr>				 
    	  
	  <?
			foreach ( $flightPhotos->photos as $photoNum=>$photoInfo) {	
				echo '<td valign="top" align=center>'._PHOTO.' #'.($photoNum+1).
						'<BR />'._DELETE_PHOTO.
						'<input type="checkbox" name="photo'.$photoNum.'Delete" value="1">'.
						'<BR><img src="'.$flightPhotos->getPhotoRelPath($photoNum).'.icon.jpg" border=0>'.
						'</td>';
Esempio n. 6
0
        echo _RELEVANT_PAGE;
        ?>
</legend>
	  <div align="left">
			http://<input name="linkURL" type="text" id="linkURL" size="90" value="<?php 
        echo $flight->linkURL;
        ?>
">
	    </div>
	  </fieldset></td>
    </tr>
	<?php 
        $photoNum = 0;
        if ($flight->hasPhotos) {
            require_once dirname(__FILE__) . "/CL_flightPhotos.php";
            $flightPhotos = new flightPhotos($flight->flightID);
            $flightPhotos->getFromDB();
            ?>
		<tr>
	      <td valign="top">
		  		<table align="center">
		  			<tr>				 
    	  
	  <?php 
            foreach ($flightPhotos->photos as $photoNum => $photoInfo) {
                echo '<td valign="top" align=center>' . _PHOTO . ' #' . ($photoNum + 1) . '<BR />' . _DELETE_PHOTO . '<input type="checkbox" name="photo' . $photoNum . 'Delete" value="1">' . '<BR><img src="' . $flightPhotos->getPhotoRelPath($photoNum) . '.icon.jpg" border=0>' . '</td>';
                if (($photoNum + 1) % 5 == 0) {
                    echo "</tr><tr>";
                }
            }
            $photoNum = $flightPhotos->photosNum;