Esempio 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);
		}
		
	}
Esempio n. 2
0
# http://www.izzysoft.de/                                                   #
# ------------------------------------------------------------------------- #
# This program is free software; you can redistribute and/or modify it      #
# under the terms of the GNU General Public License (see doc/LICENSE)       #
# ------------------------------------------------------------------------- #
# Show what we have in the Cache                                            #
#############################################################################
# $Id: cache.php 236 2009-10-06 15:23:07Z izzy $
require_once "imdb.class.php";
require_once "pilot.class.php";
echo "<!DOCTYPE HTML PUBLIC '-//W3C//DTD HTML 4.01 Transitional//EN'>\n";
echo "<HTML><HEAD>\n <TITLE>IMDBPHP Cache Contents</TITLE>\n";
echo " <STYLE TYPE='text/css'>body,td,th { font-size:12px; }</STYLE>\n";
echo "</HEAD><BODY>\n";
$imdb = new imdb("0");
$pilot = new pilot("0");
$movies = array();
if ($d = opendir($imdb->cachedir)) {
    while (false !== ($entry = readdir($d))) {
        if (strstr($entry, "Title")) {
            $imdbid = substr($entry, 0, 7);
            if (preg_match('|.pilot$|', $entry)) {
                $movies[$imdbid]['pilot'] = 1;
            } else {
                $movies[$imdbid]['imdb'] = 1;
            }
        }
    }
}
if (!empty($movies)) {
    echo "<TABLE ALIGN='center' BORDER='1' STYLE='border-collapse:collapse;margin-top:20px;'>\n" . " <TR><TH STYLE='background-color:#ffb000'>Movie</TH><TH STYLE='background-color:#ffb000'>IMDB</TH><TH STYLE='background-color:#ffb000'>MoviePilot</TR>\n";
Esempio n. 3
0
//
// This program is free software. You can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License.
//
// $Id: GUI_flight_add.php,v 1.45 2012/01/16 07:21:22 manolis Exp $
//
//************************************************************************
# modification martin jursa 02.06.2009: keep user==-1 from uploading flights and place a message
if (!$userID || $userID == -1) {
    echo _You_are_not_login;
    return;
}
require_once dirname(__FILE__) . "/CL_NACclub.php";
require_once dirname(__FILE__) . "/CL_pilot.php";
$thisPilot = new pilot(0, $userID);
$thisPilot->getFromDB();
/*
	new defines
define("_GLIDER_CERT","Glider Certification");
define("_PLEASE_SELECT_YOUR_GLIDER_CERTIFICATION","Please select the certification of your glider");

AirTime
*/
?>
<style type="text/css">
<!--

.addGlider {
    font-style: italic;
}
Esempio n. 4
0
 function fetchXML()
 {
     // is a player feed - take details from logged in user
     if (user::get('usr_pilot_id')) {
         $plt = new pilot(user::get('usr_pilot_id'));
         $usersname = $plt->getName();
         $this->CharName_ = $usersname;
         // $this->CharName_ is used later for config key value for caching
         $sql = 'select plts.plt_id, plts.plt_externalid from kb3_pilots plts where plts.plt_name = "' . $usersname . '"';
         $qry = DBFactory::getDBQuery();
         $qry->execute($sql);
         $row = $qry->getRow();
         $pilot_id = $row['plt_id'];
         $API_charID = $row['plt_externalid'];
         if ($pilot_id == 0) {
             return "Something went wrong with finiding pilots external ID<br>";
         }
         $newsql = 'SELECT userID , apiKey FROM kb3_api_user WHERE charID = "' . $API_charID . '"';
         $qry->execute($newsql);
         $userrow = $qry->getRow();
         $API_userID = $userrow['userID'];
         $API_apiKey = $userrow['apiKey'];
         $myKeyString = array();
         $myKeyString["userID"] = $API_userID;
         $myKeyString["apiKey"] = $API_apiKey;
         $myKeyString["characterID"] = $API_charID;
         $data = $this->loaddata($myKeyString);
     } else {
         return "You are not logged in.";
     }
     $xml_parser = xml_parser_create();
     xml_set_object($xml_parser, $this);
     xml_set_element_handler($xml_parser, "startElement", "endElement");
     xml_set_character_data_handler($xml_parser, 'characterData');
     if (!xml_parse($xml_parser, $data, true)) {
         return "<i>Error getting XML data from " . API_SERVER . "/CharacterSheet.xml.aspx  </i><br><br>";
     }
     xml_parser_free($xml_parser);
     return $this->html;
 }
Esempio n. 5
0
function listFlights($res, $legend, $queryExtraArray = array(), $sortOrder = "DATE")
{
    global $db, $Theme;
    global $takeoffRadious;
    global $userID, $serverID;
    global $NACclubID;
    global $clubID, $clubFlights, $clubsList, $add_remove_mode;
    global $moduleRelPath;
    global $PREFS, $CONF;
    global $page_num, $pagesNum, $startNum, $itemsNum;
    global $currentlang, $nativeLanguage, $opMode;
    global $CONF_photosPerFlight, $CONF_use_validation, $CONF_airspaceChecks;
    global $CONF_new_flights_days_threshold;
    global $gliderCatList;
    $clubIcon = "<img src='" . $moduleRelPath . "/img/icon_club_small.gif' width=12 height=12 border=0 align='absmiddle' >";
    $removeFromClubIcon = "<img src='" . $moduleRelPath . "/img/icon_club_remove.gif' width=22 height=12 border=0 align='absmiddle' title='Remove flight from this league'>";
    $addToClubIcon = "<img src='" . $moduleRelPath . "/img/icon_club_add.gif' width=12 height=12 border=0 align='absmiddle' title='Add flight to this league'>";
    if ($clubID && (L_auth::isClubAdmin($userID, $clubID) || L_auth::isAdmin($userID))) {
        ?>

<script language="javascript">

function addClubFlight(clubID,flightID) {
	$("#updateDiv").load('<?php 
        echo $moduleRelPath;
        ?>
/EXT_club_functions.php?op=add&clubID='+clubID+'&flightID='+flightID);
	$('#fl_'+flightID).html("<a href=\"#\" onclick=\"removeClubFlight("+clubID+","+flightID+");return false;\"><?php 
        echo $removeFromClubIcon;
        ?>
</a>");
	
}

function removeClubFlight(clubID,flightID) {
	$("#updateDiv").load('<?php 
        echo $moduleRelPath;
        ?>
/EXT_club_functions.php?op=remove&clubID='+clubID+'&flightID='+flightID);
	$('#fl_'+flightID).html("<a href=\"#\" onclick=\"addClubFlight("+clubID+","+flightID+");return false;\"><?php 
        echo $addToClubIcon;
        ?>
</a>");
}
</script>

<?php 
        echo "<div class='tableInfo shadowBox'>You can administer this club ";
        if ($clubsList[$clubID]['addManual']) {
            if ($add_remove_mode) {
                $queryExtraArray['admClub'] = '0';
                echo "<a href='" . getLeonardoLink(array('op' => 'list_flights', 'sortOrder' => $sortOrder) + $queryExtraArray) . "'>Return to normal view</a>";
            } else {
                $queryExtraArray['admClub'] = '1';
                echo "<a href='" . getLeonardoLink(array('op' => 'list_flights', 'sortOrder' => $sortOrder) + $queryExtraArray) . "'>Add / remove flights</a>";
            }
        }
        echo "<div id='updateDiv' style='display:block'></div>";
        echo "</div>";
    }
    ?>
  	<table class='listTable' style='clear:both' width="100%" cellpadding="2" cellspacing="0">
	<tr> 
	  <td class='SortHeader indexCell' width="25"><?php 
    echo _NUM;
    ?>
</td>
		 <?php 
    printHeader(60, $sortOrder, "DATE", _DATE_SORT, $queryExtraArray);
    printHeader(160, $sortOrder, "pilotName", _PILOT, $queryExtraArray);
    printHeader(0, $sortOrder, "takeoffID", _TAKEOFF, $queryExtraArray);
    printHeader(40, $sortOrder, "DURATION", _DURATION_HOURS_MIN, $queryExtraArray);
    if ($CONF['list_flights']['fields']['scoring'][0] == 'LINEAR_DISTANCE') {
        printHeader(60, $sortOrder, "LINEAR_DISTANCE", _LINEAR_DISTANCE, $queryExtraArray);
    } else {
        printHeader(60, $sortOrder, "SCORE_SPEED", _MEAN_SPEED1, $queryExtraArray);
    }
    printHeader(60, $sortOrder, "FLIGHT_KM", _OLC_KM, $queryExtraArray);
    printHeader(65, $sortOrder, "FLIGHT_POINTS", _OLC_SCORE, $queryExtraArray);
    ?>
	  <td width="18" class='SortHeader'>&nbsp;</td>
  	  <td width="50" class='SortHeader'>&nbsp;</td>
	  <td width="70" class='SortHeader displayCell alLeft'><?php 
    echo _SHOW;
    ?>
</td>
  </tr>
<?php 
    $i = 1;
    $currDate = "";
    while ($row = $db->sql_fetchrow($res)) {
        $is_private = $row["private"];
        $flightID = $row['ID'];
        if ($pilotNames[$row["userServerID"] . '_' . $row["userID"]]) {
            $name = $pilotNames[$row["userServerID"] . '_' . $row["userID"]];
        } else {
            $name = getPilotRealName($row["userID"], $row["userServerID"], 1);
            $pilotNames[$row["userServerID"] . '_' . $row["userID"]] = $name;
        }
        $name = prepare_for_js($name);
        if ($takeoffNames[$row["flight_takeoffID"]]) {
            $takeoffName = $takeoffNames[$row["flight_takeoffID"]];
        } else {
            $takeoffName = prepare_for_js(getWaypointName($row["flight_takeoffID"], -1, 0, 20));
            $takeoffNames[$row["flight_takeoffID"]] = $takeoffName;
        }
        $takeoffVinicity = $row["takeoffVinicity"];
        $takeoffNameFrm = formatLocation($takeoffName, $takeoffVinicity, $takeoffRadious);
        $sortRowClass = $i % 2 ? "l_row1" : "l_row2";
        $i++;
        $days_from_submission = floor((mktime() - datetime2UnixTimestamp($row["dateAdded"])) / 86400);
        // 60*60*24 sec per day
        if (!$is_private) {
            $privateIcon = '&nbsp;';
        } else {
            $privateIcon = '';
            if ($is_private & 0x1) {
                $privateIcon .= "<img src='" . $moduleRelPath . "/img/icon_private.gif' align='absmiddle' width='13' height='13'>";
            }
            if ($is_private & 0x2) {
                $privateIcon .= "<img src='" . $moduleRelPath . "/img/icon_disabled.gif' align='absmiddle' width='13' height='13'>";
            }
            if ($is_private & 0x4) {
                $privateIcon .= "<img src='" . $moduleRelPath . "/img/locked.gif' align='absmiddle' width='13' height='13'>";
            }
        }
        if ($row["DATE"] != $currDate || $sortOrder != 'DATE') {
            $currDate = $row["DATE"];
            $dateStr = formatDate($row["DATE"]);
            $rowStr = " newDate ";
        } else {
            $dateStr = "<span class='dateHidden'>" . formatDate($row["DATE"]) . "</span>";
            $rowStr = "";
        }
        $date2row = "";
        if ($days_from_submission <= $CONF_new_flights_days_threshold) {
            $newSubmissionStr = _SUBMIT_FLIGHT . ': ' . $row["dateAdded"] . ' GMT';
            $date2row .= leoHtml::img("icon_new.png", 25, 12, 'absmiddle', $newSubmissionStr, 'icons1');
        }
        if ($row['excludeFrom'] & 0x1) {
            $date2row .= "*";
        }
        //$extLinkImgStr=getExternalLinkIconStr($row["serverID"],$row["originalURL"],3);
        //if ($extLinkImgStr) $extLinkImgStr="<a href='".$row["originalURL"]."' target='_blank'>$extLinkImgStr</a>";
        $date2row .= $extLinkImgStr;
        if ($date2row == '') {
            $date2row .= '&nbsp;';
        }
        echo "\n\n<tr class='{$sortRowClass} {$rowStr}' id='row_{$flightID}'>\n";
        $duration = sec2Time($row['DURATION'], 1);
        $linearDistance = formatDistanceOpen($row["LINEAR_DISTANCE"]);
        $olcDistance = formatDistanceOpen($row["FLIGHT_KM"]);
        $olcScore = formatOLCScore($row["FLIGHT_POINTS"]);
        $gliderType = $row["cat"];
        // 1=pg 2=hg flex 4=hg rigid 8=glider
        # Martin Jursa 20.05.2007
        $scoreSpeed = formatSpeed($row["SCORE_SPEED"]);
        // get the OLC score type
        $olcScoreType = $row['BEST_FLIGHT_TYPE'];
        if ($olcScoreType == "FREE_FLIGHT") {
            $olcScoreTypeImg = "icon_turnpoints.gif";
        } else {
            if ($olcScoreType == "FREE_TRIANGLE") {
                $olcScoreTypeImg = "icon_triangle_free.gif";
            } else {
                if ($olcScoreType == "FAI_TRIANGLE") {
                    $olcScoreTypeImg = "icon_triangle_fai.gif";
                } else {
                    $olcScoreTypeImg = "photo_icon_blank.gif";
                }
            }
        }
        $gliderBrandImg = brands::getBrandImg($row["gliderBrandID"], $row['flight_glider'], $gliderType);
        echo "\n<TD {$first_col_back_color} class='indexCell'><div>" . ($i - 1 + $startNum) . "</div>{$privateIcon}</TD>";
        echo "<TD class='dateString' valign='top'><div>{$dateStr}</div>{$date2row}";
        if ((L_auth::isClubAdmin($userID, $clubID) || L_auth::isAdmin($userID)) && $add_remove_mode) {
            // echo "<BR>";
            if (in_array($flightID, $clubFlights)) {
                echo "<div id='fl_{$flightID}' style='display:inline;margin:0px;padding:0px'><a href=\"#\" onclick=\"removeClubFlight({$clubID},{$flightID});return false;\">{$removeFromClubIcon}</a></div>";
            } else {
                echo "<div id='fl_{$flightID}' style='display:inline'><a href=\"#\" onclick=\"addClubFlight({$clubID},{$flightID});return false;\">{$addToClubIcon}</a></div>";
            }
        }
        echo "</TD>";
        echo "<TD  class='pilotTakeoffCell' colspan=2 " . $sortArrayStr["pilotName"] . $sortArrayStr["takeoffID"] . ">" . "<div id='p_{$i}' class='pilotLink'>";
        //echo "<span class='fl sprite-gr'></span>";
        //echo  getNationalityDescription($row["pilotCountryCode"],1,0);
        $thisPilot = new pilot($row["userServerID"], $row["userID"]);
        if ($thisPilot->isPilotLocal() || L_auth::isAdmin($userID)) {
            echo " <a href=\"javascript:pilotTip.newTip('inline', 0, 13, 'p_{$i}', 250, '" . $row["userServerID"] . "_" . $row["userID"] . "','" . addslashes($name) . "' )\"  onmouseout=\"pilotTip.hide()\">{$name}</a>\n";
        } else {
            echo " <a href=\"javascript:pilotTipExt.newTip('inline', 0, 13, 'p_{$i}', 200, '" . $row["userServerID"] . "_" . $row["userID"] . "','" . addslashes($name) . "' )\"  onmouseout=\"pilotTip.hide()\">{$name}</a>\n";
        }
        echo "</div>";
        echo "<div id='at_{$i}' class='takeoffLink'>";
        echo "<a id='t_{$i}' href=\"javascript:takeoffTip.newTip('inline',-25, 13,'t_{$i}', 250, '" . $row["takeoffID"] . "','" . addslashes($takeoffName) . "')\"  onmouseout=\"takeoffTip.hide()\">{$takeoffNameFrm}</a>\n";
        echo "</div></TD>" . "<TD>{$duration}</TD>";
        if ($CONF['list_flights']['fields']['scoring'][0] == 'LINEAR_DISTANCE') {
            echo "<TD class='distance'>{$linearDistance}</TD>";
        } else {
            echo "<TD class='speed'>{$scoreSpeed}</TD>";
        }
        echo "<TD class='distance'>{$olcDistance}</TD>";
        //P. Wild 22.03.2011 - Deutschland Flüge Fett hervorheben, Admin Farbkennzeichnung Luftraum
        $tmpairspaceName = $row['airspaceCheckMsg'];
        if (strrchr($tmpairspaceName, "Punkte")) {
            echo "<TD nowrap class='OLCScore'><b>{$olcScore}</b>&nbsp;" . leoHtml::img($olcScoreTypeImg, 16, 16, 'top', formatOLCScoreType($olcScoreType, 0), 'icons1');
        } else {
            echo "<TD nowrap class='OLCScore'>{$olcScore}&nbsp;" . leoHtml::img($olcScoreTypeImg, 16, 16, 'top', formatOLCScoreType($olcScoreType, 0), 'icons1');
        }
        if ($CONF_use_validation) {
            $isValidated = $row['validated'];
            if ($isValidated == -1) {
                $vImg = "icon_valid_nok.gif";
            } else {
                if ($isValidated == 0) {
                    $vImg = "icon_valid_unknown.gif";
                } else {
                    if ($isValidated == 1) {
                        $vImg = "icon_valid_ok.gif";
                    }
                }
            }
            $valStr = leoHtml::img($vImg, 12, 12, '', '', 'icons1 listIcons');
            echo $valStr;
        }
        echo "</TD>";
        echo "<TD><div class='catInfo'>";
        $gliderTypeDesc = $gliderCatList[$row["cat"]];
        if ($row["category"]) {
            $gliderTypeDesc .= " - " . $CONF['gliderClasses'][$row["cat"]]['classes'][$row["category"]];
            $categoryImg = "<div class='categoryListIconDiv'>" . leoHtml::img("icon_class_" . $row["category"] . ".png", 0, 0, 'top', $gliderTypeDesc, 'icons1', '') . "</div>";
        } else {
            $categoryImg = '';
        }
        echo leoHtml::img("icon_cat_" . $row["cat"] . ".png", 0, 0, 'top', $gliderTypeDesc, 'icons1 catListIcon') . $categoryImg;
        echo "</div></td>\n\t<TD><div align='center'>{$gliderBrandImg}</div></td>";
        if (L_auth::airspaceVisible($userID, $row["userID"], $row["userServerID"])) {
            /*
            		$CONF_airspaceChecks && 
            			( L_auth::isAdmin($userID) || $CONF['airspace']['view']=='public' ||   
            			( $CONF['airspace']['view']=='registered' && $userID >0 ) || 
            			( $CONF['airspace']['view']=='own' && $userID == $row["userID"] && $row["userServerID"]==$serverID )   
            		) 
            		) {*/
            if ($row['airspaceCheckFinal'] == -1) {
                //original: $airspaceProblem=' bgcolor=#F7E5C9 ';
                # peter Wild hack taking into account the deutschlandpokal-hack
                $tmpairspaceName = $row['airspaceCheckMsg'];
                if (strrchr($tmpairspaceName, "Punkte")) {
                    $airspaceProblem = ' bgcolor=#009cff ';
                    //Blue
                    if (strpos($tmpairspaceName, "HorDist")) {
                        $airspaceProblem = ' bgcolor=#FFFF00 ';
                        //Yellow
                    }
                    //mod.31.12.08 different colours for bad infringements. P. Wild
                    if (strpos($tmpairspaceName, 'CLASSC') !== false) {
                        $airspaceProblem = ' bgcolor=#FF0008 ';
                        //Red
                    }
                    if (strpos($tmpairspaceName, 'CLASSD') !== false) {
                        $airspaceProblem = ' bgcolor=#FF0008 ';
                    }
                } else {
                    $airspaceColor = '';
                    foreach ($CONF['aispace']['list']['colors'] as $className => $classColor) {
                        if (strpos($tmpairspaceName, $className) !== false) {
                            $airspaceColor = $classColor;
                            break;
                        }
                    }
                    if (!$airspaceColor) {
                        $airspaceColor = $CONF['aispace']['list']['colors']['ALLOTHER'];
                    }
                    $airspaceProblem = " bgcolor=#{$airspaceColor} ";
                }
                # end hack
            } else {
                $airspaceProblem = '';
            }
        }
        $isExternalFlight = $row['externalFlightType'];
        echo "<TD {$airspaceProblem} align=left valign='top'>";
        echo "<div class='smallInfo'>";
        if ($isExternalFlight == 0 || $isExternalFlight == 2 || $CONF['servers']['list'][$row['serverID']]['treat_flights_as_local']) {
            // add class='betterTip' for tooltip
            $flightLinkUrl = getLeonardoLink(array('op' => 'show_flight', 'flightID' => $row["ID"]));
            global $deletedFlights;
            if ($deletedFlights) {
                $flightLinkUrl .= "&deleted=1";
            }
            echo "<a class='flightLink' id='tpa3_{$flightID}' href='" . $flightLinkUrl . "'>" . leoHtml::img("icon_look.gif", 0, 0, 'top', _SHOW, 'icons1 flightIcon', '', 1) . "</a>";
            echo "<a href='javascript:nop()' onclick=\"geTip.newTip('inline', -315, -5, 'ge_{$i}', 300, '" . $row["ID"] . "' , '{$currentlang}')\"  onmouseout=\"geTip.hide()\">" . leoHtml::img("geicon.gif", 0, 0, 'top', _Navigate_with_Google_Earth, 'icons1 geIcon', 'ge_' . $i) . "</a>";
        } else {
            echo "<a class='flightLink' href='" . getLeonardoLink(array('op' => 'show_flight', 'flightID' => $row["ID"])) . "'>" . leoHtml::img("icon_look.gif", 0, 0, 'top', _SHOW, 'icons1 flightIcon') . "</a>";
            $originalKML = $row["originalKML"];
            global $CONF;
            if ($CONF['servers']['list'][$row["serverID"]]['isLeo'] == 1) {
                if ($row["original_ID"]) {
                    $originalKML = 'http://' . $CONF['servers']['list'][$row["serverID"]]['url_base'] . '/download.php?type=kml_trk&flightID=' . $row["original_ID"];
                }
            }
            if ($originalKML) {
                echo "<a  href='" . $originalKML . "'>" . leoHtml::img("geicon.gif", 0, 0, 'top', _Navigate_with_Google_Earth, 'icons1 geIcon') . "</a>";
            } else {
                echo leoHtml::img("photo_icon_blank.gif", 16, 16, '', '', 'icons1 geIcon');
            }
        }
        $photosNum = $row["hasPhotos"];
        if ($photosNum) {
            echo "<span><a class='betterTip2' id='tpa1_{$flightID}' href='javascript:nop();'>" . leoHtml::img("icon_camera.gif", 0, 0, '', $photosNum . ' ' . _PHOTOS, 'icons1 photoIcon2') . "</a></span>";
        }
        if ($row["commentsNum"] > 0) {
            $hasComments = 1;
            if ($row["commentsNum"] > 1) {
                $commentsImgName = "icon_comments_many.gif";
            } else {
                $commentsImgName = "icon_comments.gif";
            }
        } else {
            $hasComments = 0;
        }
        if ($hasComments) {
            echo "<a class='betterTip' id='tpa2_{$flightID}' href='javascript:nop();'>" . leoHtml::img($commentsImgName, 0, 0, '', $row["commentsNum"] . ' ' . _COMMENTS, 'icons1 commentDiv', '', 1) . "</a>";
        }
        if (1) {
            echo "<span class='preview'><a class='betterTip' id='tpa0_{$flightID}' href='javascript:nop()'>" . leoHtml::img("icon_info.gif", 0, 0, 'top', _SHOW, 'icons1 previewDiv', '', 1) . "</a></span>";
        }
        if ($isExternalFlight && !$CONF['servers']['list'][$row['serverID']]['treat_flights_as_local']) {
            $extServerStr = $CONF['servers']['list'][$row['serverID']]['name'];
            $extServerStrShort = $CONF['servers']['list'][$row['serverID']]['short_name'];
            if ($isExternalFlight == 2) {
                echo leoHtml::img("icon_link_dark.gif", 0, 0, '', _External_Entry . ": {$extServerStr}", 'icons1 extLink');
                echo "<div class='extLinkName'>{$extServerStrShort}</div>";
            } else {
                if ($CONF['servers']['list'][$row['serverID']]['isLeo']) {
                    $url_flight = $CONF['servers']['list'][$row['serverID']]['url_flight'];
                    if ($url_flight) {
                        $extFlightLink = 'http://' . str_replace("%FLIGHT_ID%", $row['original_ID'], $url_flight) . "&lng={$currentlang}";
                    } else {
                        $extFlightLink = 'http://' . $CONF['servers']['list'][$row['serverID']]['url'] . '&op=show_flight&flightID=' . $row['original_ID'] . "&lng={$currentlang}";
                    }
                } else {
                    $extFlightLink = $row['originalURL'];
                }
                echo "<a href='{$extFlightLink}' target='_blank' class='extLinkDiv' title='{$extServerStr}: " . _Ext_text2 . "' >";
                // also put the direct link in the place of the photo
                echo "<img class='extServerLogo' src='" . $moduleRelPath . "/img/servers/" . sprintf("%03d", $row['serverID']) . ".gif' width='16' height='16'  border='0'/>";
                echo leoHtml::img("icon_link_dark.gif", 0, 0, '', '', 'icons1 extLinkIcon');
                echo "<div class='extLinkDescr'>{$extServerStrShort}</div>";
                //echo "<span class='extLinkDescr'>$extServerStrShort</span>";
                echo "</a>";
            }
        }
        # P.Wild, martin jursa: considering $CONF_new_flights_days_threshold
        global $CONF_new_flights_submit_window;
        //P. Wild - edited to submit window (old version false)
        $inWindow = empty($CONF_new_flights_submit_window) ? true : $days_from_submission <= $CONF_new_flights_submit_window;
        if ($row["userID"] == $userID && $inWindow || L_auth::isAdmin($userID)) {
            echo "<div id='ac_{$i}' class='actionLink'>";
            echo "<a href=\"javascript:flightActionTip.newTip('inline', -100, 13, 'ac_{$i}', 120, " . $row["ID"] . " )\"  onmouseout=\"flightActionTip.hide()\">" . leoHtml::img("icon_action_select.gif", 0, 0, 'bottom', '', 'icons1') . "</a>";
            echo "</div>";
        }
        $checkedByStr = '';
        if ($row['checkedBy'] && L_auth::isAdmin($userID)) {
            $checkedByArray = explode(" ", $row['checkedBy']);
            $checkedByStr = "<div class='checkedBy' align=right>" . $checkedByArray[0] . "</div>";
            echo $checkedByStr;
        }
        echo "</div>";
        echo "</TD>\n";
        echo "</TR>";
    }
    echo "</table>\n\n";
    $db->sql_freeresult($res);
}
Esempio n. 6
0
 /** Setup search results
  * @method results
  * @param optional string URL Replace search URL by your own
  * @return array results array of objects (instances of the imdb class)
  */
 public function results($url = "")
 {
     if (empty($this->pilot_apikey)) {
         trigger_error('Please provide a valid api key or contact api@moviepilot.de.', E_USER_WARNING);
         return array();
     }
     // get the result list
     if ($this->page == "") {
         if (empty($url)) {
             $url = $this->mkurl();
         }
         $be = new MDB_Request($url);
         $be->sendrequest();
         $fp = $be->getResponseBody();
         if ($fp == '{"error":"please provide a valid api key or contact api@moviepilot.de"}') {
             $this->debug_scalar('ERROR: invalid API key');
             trigger_error('Please provide a valid api key or contact api@moviepilot.de.', E_USER_WARNING);
             return array();
         }
         $this->page = json_decode($fp);
     }
     // end (page="")
     // parse results
     $i = 0;
     if (!empty($this->page->movies)) {
         foreach ($this->page->movies as $movie) {
             if ($this->maxresults && $i > $this->maxresults) {
                 break;
             }
             ++$i;
             $mid = str_pad($movie->alternative_identifiers->imdb, 7, 0, STR_PAD_LEFT);
             $item = new pilot($mid);
             $item->page['Title'] = $movie;
             $item->setid($mid);
             $this->resu[] = $item;
             if ($this->storecache) {
                 $this->cache_write($mid . '.' . 'Title.pilot', json_encode($movie));
             }
         }
     }
     return $this->resu;
 }
Esempio n. 7
0
 function processEntry($serverID, $e, $sync_mode = SYNC_INSERT_FLIGHT_LINK)
 {
     global $CONF;
     global $DBGcat, $DBGlvl;
     if ($DBGlvl > 0) {
         echo "<PRE>";
         print_r($e);
         echo "</PRE>";
     }
     if (is_array($e['ActionXML'])) {
         $actionData =& $e['ActionXML'];
     } else {
         if (is_array($e['actionData'])) {
             $actionData =& $e['actionData'];
         } else {
             if (is_array($e['flight'])) {
                 $actionData =& $e;
             } else {
                 return array(0, "logReplicator::processEntry : actionData section not found");
             }
         }
     }
     // if this log entry is not for a flight of the specific server
     // then check if we are allowesd to accpet these flights from this server
     if (isset($actionData['flight']['serverID'])) {
         $thisEntryServerID = $actionData['flight']['serverID'];
     } else {
         if (isset($e['serverID'])) {
             $thisEntryServerID = $e['serverID'];
         } else {
             return array(0, "logReplicator::processEntry : ServerID for Log entry could not be determined ");
         }
     }
     if ($thisEntryServerID != $serverID) {
         $wrongServer = 1;
         if (is_array($CONF['servers']['list'][$serverID]['accept_also_servers'])) {
             if (in_array($thisEntryServerID, $CONF['servers']['list'][$serverID]['accept_also_servers'])) {
                 $wrongServer = 0;
             }
         }
         if ($wrongServer) {
             return array(0, "logReplicator::processEntry : We dont accept flights originally from server " . $thisEntryServerID);
         }
     }
     if ($e['type'] == '1') {
         // flight
         if ($e['action'] == 4) {
             // delete
             $flightIDlocal = logReplicator::findFlight($actionData['flight']['serverID'], $actionData['flight']['id']);
             if (!$flightIDlocal) {
                 return array(0, "logReplicator::processEntry : Flight with serverID " . $actionData['flight']['serverID'] . " and original ID : " . $actionData['flight']['id'] . " is not found in the local DB -> Wont delete it");
             }
             // echo "Will delete flight $flightIDlocal<BR>";
             $extFlight = new flight();
             $extFlight->getFlightFromDB($flightIDlocal, 0);
             $extFlight->deleteFlight();
             return array(1, "Flight with local ID: {$flightIDlocal} DELETED");
         }
         if ($e['action'] == 16) {
             // rename tracklog
             $flightIDlocal = logReplicator::findFlight($e['serverID'], $e['id']);
             if (!$flightIDlocal) {
                 return array(0, "logReplicator::processEntry : Flight with serverID " . $e['serverID'] . " and original ID : " . $e['id'] . " is not found in the local DB -> Wont rename tracklog<BR>");
             }
             $extFlight = new flight();
             $extFlight->getFlightFromDB($flightIDlocal, 0);
             $extFlight->renameTracklog($actionData['newFilename'], $actionData['oldFilename']);
             return array(1, "Flight tracklog renamed for local ID {$flightIDlocal}");
         }
         if ($e['action'] == 8) {
             // scoring info
             $flightIDlocal = logReplicator::findFlight($e['serverID'], $e['id']);
             if (!$flightIDlocal) {
                 return array(0, "logReplicator::processEntry : Flight with serverID " . $e['serverID'] . " and original ID : " . $e['id'] . " is not found in the local DB -> Wont update scoring<BR>");
             }
             // echo "Will update scoring  info for flight $flightIDlocal<BR>";
             // no need to pull flight info
             //$extFlight=new flight();
             //$extFlight->getFlightFromDB($flightIDlocal,0);
             require_once dirname(__FILE__) . '/CL_flightScore.php';
             $flightScore = new flightScore($flightIDlocal);
             // we have the score array in $actionData['score']
             $sArr =& $actionData['score'];
             $flightScore->fromSyncArray($sArr);
             //put also in scores table, the flight is sure to be present in flights table
             $flightScore->putToDB(1, 1);
             return array(1, "Flight Score was *pulled* for local ID {$flightIDlocal}");
         }
         // now deal with add/update
         $getValidationData = 1;
         $getScoreData = 1;
         //	check 'alien' pilot  and insert him or update him anyway
         $userServerID = $actionData['flight']['serverID'];
         if ($userServerID == 0) {
             $userServerID = $serverID;
         }
         //  echo "logReplicator::checkPilot";
         list($effectiveServerID, $effectiveUserID) = logReplicator::checkPilot($userServerID, $actionData['flight']['pilot']);
         //echo "effectiveServerID: $effectiveServerID, effectiveUserID: $effectiveUserID
         // userServerID: $userServerID, userID: ".$actionData['flight']['pilot']['userID']."<BR>";
         // check if a maping took place and LOG it!!
         if ($effectiveServerID != $userServerID || $effectiveUserID != $actionData['flight']['pilot']['userID']) {
             $orgUserIDstr = $userServerID + 0 . '_' . $actionData['flight']['pilot']['userID'];
         } else {
             $orgUserIDstr = '';
         }
         // $userIDstr=$userServerID.'_'.$actionData['flight']['pilot']['userID'];
         $userIDstr = $effectiveServerID . '_' . $effectiveUserID;
         list($nearestTakeoffID, $nearestDistance) = logReplicator::checkLocation($userServerID, $actionData['flight']['location'], $actionData['flight']['bounds']);
         list($nearestLandingID, $nearestLandingDistance) = findNearestWaypoint($actionData['flight']['bounds']['lastLat'], $actionData['flight']['bounds']['lastLon']);
         // get only the first 2 bits
         $externalFlightType = $sync_mode & 0x3;
         $addFlightNote = '';
         // if action ==update check to see if the flight exists !
         if ($e['action'] == 2) {
             $flightIDlocal = logReplicator::findFlight($actionData['flight']['serverID'], $actionData['flight']['id']);
             if (!$flightIDlocal) {
                 // we then INSERT IT instead
                 echo " [Not found,will insert] ";
                 $e['action'] = 1;
             }
         } else {
             if ($e['action'] == 1) {
                 // if action == insert we make an extra check to see if the fligh is there, if yes we UPDATE instead
                 $flightIDlocal = logReplicator::findFlight($actionData['flight']['serverID'], $actionData['flight']['id']);
                 if ($flightIDlocal) {
                     // we then UPDATE IT instead
                     echo " [Already here,will update] ";
                     $e['action'] = 2;
                 }
             }
         }
         if ($e['action'] == 1) {
             // add
             $igcFilename = $actionData['flight']['filename'];
             $igcFileURL = $actionData['flight']['linkIGC'];
             $igcZipFileURL = $actionData['flight']['linkIGCzip'];
             $tempFilename = LEONARDO_ABS_PATH . '/' . $CONF['paths']['tmpigc'] . '/' . $igcFilename;
             $hash = $actionData['flight']['validation']['hash'];
             $sameHashIDarray = flight::findSameHash($hash);
             if (count($sameHashIDarray) > 0) {
                 $isFlightDup = 0;
                 $markFlightAsDisabled = 1;
                 $msg = '';
                 if ($CONF['servers']['list'][$actionData['flight']['serverID']]['allow_duplicate_flights']) {
                     foreach ($sameHashIDarray as $sameHashFlightInfo) {
                         if ($sameHashFlightInfo['serverID'] == $actionData['flight']['serverID']) {
                             // from same server
                             $isFlightDup = 1;
                             $msg .= " local flight: " . $sameHashFlightInfo['serverID'] . '_' . $sameHashFlightInfo['ID'] . " , new entry:" . $actionData['flight']['serverID'] . '_' . $actionData['flight']['id'];
                             break;
                         } else {
                             // we have a flight with same hash that is not from this specific server.
                             // HERE we must make the decision whether to mark this flight as DISABLED
                             // WE always mark this new flight as DISABLED because :
                             // the local flight takes precedence anyway.
                             // ONE case
                             // we are DHV mirror , the new flight is from DHV and there is a dup from XContest
                             // we should insert,
                             // SO INSERT TAKES PRECEDENCE OVER LINKED FLIGHTS
                         }
                     }
                 } else {
                     $isFlightDup = 1;
                 }
                 if ($isFlightDup) {
                     return array(-1, "Flight already exists : {$msg}");
                 }
             }
             /*
             if ($CONF['servers']['list'][$actionData['flight']['serverID']]['allow_duplicate_flights']) {
             	$sameHashIDarray=flight::findSameHash( $hash , $actionData['flight']['serverID'] );
             	if (count($sameHashIDarray)>0 )  {
             		return array(-1,"Flight already exists in local with ID: $sameHashID (dups allowed)");
             		continue;
             	} else {
             		// $addFlightNote="*(Duplicate Flight)*";
             	}
             
             } else {
             	$sameHashIDarray=flight::findSameHash( $hash );
             	if (count($sameHashIDarray)>0 ) 	 {
             		return array(-1,"Flight already exists in local with ID: $sameHashID");
             		continue;
             	}
             }
             */
         } else {
             if ($e['action'] == 2) {
                 // update
                 // This is not needed , we have found $flightIDlocal earlier and if it didnt exist we will insert it instead
                 /*
                 $flightIDlocal=logReplicator::findFlight($actionData['flight']['serverID'],$actionData['flight']['id']);
                 if (!$flightIDlocal) {
                 	return array(0,"logReplicator::processEntry : Flight with serverID ".$actionData['flight']['serverID']." and original ID : ".
                 			$actionData['flight']['id']." is not found in the local DB -> Wont update<BR>");
                 }
                 */
                 // echo "Will update flight $flightIDlocal<BR>";
             }
         }
         $thisCat = $actionData['flight']['info']['cat'] + 0;
         // when we get data from leonardo servers, we just ignore these fields
         // since they can be computed on the fly
         $originalURL = htmlDecode($actionData['flight']['linkDisplay']);
         $originalKML = htmlDecode($actionData['flight']['linkGE']);
         if ($actionData['flight']['serverID'] != 0) {
             global $CONF;
             if ($CONF['servers']['list'][$actionData['flight']['serverID']]['isLeo'] == 1) {
                 $originalURL = '';
                 $originalKML = '';
             }
         }
         $argArray = array("private" => $actionData['flight']['info']['private'] + 0, "cat" => $actionData['flight']['info']['gliderCat'] + 0, "linkURL" => $actionData['flight']['info']['linkURL'], "comments" => $actionData['flight']['info']['comments'], "glider" => $actionData['flight']['info']['glider'], "gliderBrandID" => $actionData['flight']['info']['gliderBrandID'] + 0, "category" => $thisCat >= 0 ? $thisCat : 0, "dateAdded" => $actionData['flight']['dateAdded'], "originalURL" => $originalURL, "originalKML" => $originalKML, "original_ID" => $actionData['flight']['id'], "serverID" => $actionData['flight']['serverID'], "userServerID" => $actionData['flight']['serverID'], "originalUserID" => $orgUserIDstr, "externalFlightType" => $externalFlightType, "allowDuplicates" => $CONF['servers']['list'][$actionData['flight']['serverID']]['allow_duplicate_flights'] + 0);
         // print_r($argArray);
         if ($e['action'] == 1 && $sync_mode & SYNC_INSERT_FLIGHT_LOCAL & SYNC_INSERT_FLIGHT_REPROCESS_LOCALLY) {
             if (!($igcFileStr = fetchURL($igcFileURL, 20))) {
                 return array(0, "logReplicator::processEntry() : Cannot Fetch {$igcFileURL}");
             }
             writeFile($tempFilename, $igcFileStr);
             list($res, $flightID) = addFlightFromFile($tempFilename, 0, $userIDstr, $argArray);
             if ($res != 1) {
                 return array(-128, "Problem: " . getAddFlightErrMsg($res, $flightID));
             }
             return array(1, "Flight *pulled* OK with local ID {$flightID}");
         } else {
             // if ( ( $e['action']==1 && $sync_mode & SYNC_INSERT_FLIGHT_LINK  ) || $e['action']==2 ){
             // inserting in LINK / LOCAL mode or updates - NOT reproccess
             if ($e['action'] == 1) {
                 $extFlight = new flight();
                 // get igc if required
                 if ($sync_mode & SYNC_INSERT_FLIGHT_LOCAL) {
                     echo " Geting IGC file : ";
                     if (!$e['tmpDir']) {
                         $e['tmpDir'] = '/tmp';
                     }
                     $igcFileTmp = $e['tmpDir'] . '/' . $actionData['flight']['id'] . '.igc';
                     if (!is_file($igcFileTmp)) {
                         echo "igc file: {$igcFileURL}<BR>\n";
                         echo "tmpfile: {$igcFileTmp}<BR>\n";
                         echo "NOT in zip -> will fetch ...";
                         if (!($igcFileStr = fetchURL($igcFileURL, 20))) {
                             return array(0, "logReplicator::processEntry() : Cannot Fetch {$igcFileURL}");
                         }
                         writeFile($igcFileTmp, $igcFileStr);
                     } else {
                         echo "IN zip -> will use that ...";
                     }
                 }
             } else {
                 $extFlight = new flight();
                 $extFlight->getFlightFromDB($flightIDlocal, 0);
             }
             $igcFilename = $actionData['flight']['filename'];
             $igcFileURL = $actionData['flight']['linkIGC'];
             if ($CONF['servers']['list'][$actionData['flight']['serverID']]['exclude_from_list']) {
                 $extFlight->excludeFrom |= 3;
             }
             if ($CONF['servers']['list'][$actionData['flight']['serverID']]['exclude_from_league']) {
                 $extFlight->excludeFrom |= 2;
             }
             foreach ($argArray as $fieldName => $fieldValue) {
                 // if the flight is already present
                 // we must tkae care to honor ONLY
                 // the 1st bit of 'private' , the others are used locally !!
                 if ($fieldName == 'private') {
                     if ($fieldValue & 0x1) {
                         $fieldValue = $extFlight->private | 0x1;
                     } else {
                         if ($fieldValue & 0x4) {
                             // visible to friends
                             $fieldValue = $extFlight->private | 0x4;
                         } else {
                             $fieldValue = $extFlight->private & 0xfa;
                         }
                     }
                 }
                 $extFlight->{$fieldName} = $fieldValue;
             }
             // echo " gliderBrandID : $extFlight->gliderBrandID #<BR>";
             $extFlight->takeoffID = $nearestTakeoffID;
             $extFlight->takeoffVinicity = $nearestDistance;
             $extFlight->landingID = $nearestLandingID;
             $extFlight->landingVinicity = $nearestLandingDistance;
             // no userid will be assgined to this flight since it will not be inserted locally
             // so userID= userServerID;
             // $extFlight->userID=$extFlight->originalUserID;
             // now we take care of mapping between users
             $extFlight->userID = $effectiveUserID;
             $extFlight->userServerID = $effectiveServerID;
             $extFlight->dateAdded = $actionData['flight']['dateAdded'];
             $extFlight->DATE = $actionData['flight']['time']['date'];
             $extFlight->timezone = $actionData['flight']['time']['Timezone'] + 0;
             $extFlight->START_TIME = $actionData['flight']['time']['StartTime'] + 0;
             $extFlight->DURATION = $actionData['flight']['time']['Duration'] + 0;
             $extFlight->END_TIME = $extFlight->START_TIME + $extFlight->DURATION;
             $extFlight->forceBounds = $actionData['flight']['bounds']['forceBounds'] + 0;
             $extFlight->firstLon = $actionData['flight']['bounds']['firstLon'] + 0;
             $extFlight->firstLat = $actionData['flight']['bounds']['firstLat'] + 0;
             $extFlight->firstPointTM = $actionData['flight']['bounds']['firstTM'] + 0;
             $extFlight->lastLon = $actionData['flight']['bounds']['lastLon'] + 0;
             $extFlight->lastLat = $actionData['flight']['bounds']['lastLat'] + 0;
             $extFlight->lastPointTM = $actionData['flight']['bounds']['lastTM'] + 0;
             $firstPoint = new gpsPoint();
             $firstPoint->setLon($actionData['flight']['bounds']['firstLon']);
             $firstPoint->setLat($actionData['flight']['bounds']['firstLat']);
             $firstPoint->gpsTime = $actionData['flight']['bounds']['firstTM'] % 86400;
             $lastPoint = new gpsPoint();
             $lastPoint->setLon($actionData['flight']['bounds']['lastLon']);
             $lastPoint->setLat($actionData['flight']['bounds']['lastLat']);
             $lastPoint->gpsTime = $actionData['flight']['bounds']['lastTM'] % 86400;
             // $extFlight->FIRST_POINT=$firstPoint->to_IGC_Record();
             // $extFlight->LAST_POINT=$lastPoint->to_IGC_Record();
             // not used!!
             /*
             					if (	is_array($actionData['flight']['turnpoints']) ) {
             						foreach ($actionData['flight']['turnpoints'] as $i=>$tp){
             							$tpNum=$tp['id'];
             							$tpPoint=new gpsPoint();
             							$tpPoint->setLon($tp['lon']);
             							$tpPoint->setLat($tp['lat']);
             							$varname="turnpoint$tpNum" ;
             							$extFlight->$varname = $tpPoint->getLatMin().' '.$tpPoint->getLonMin() ;
             						}					
             					}
             */
             if ($getValidationData) {
                 $extFlight->validated = $actionData['flight']['validation']['validated'];
                 $extFlight->grecord = $actionData['flight']['validation']['grecord'];
                 $extFlight->hash = $actionData['flight']['validation']['hash'];
                 $extFlight->validationMessage = $actionData['flight']['validation']['validationMessage'];
                 $extFlight->airspaceCheck = $actionData['flight']['validation']['airspaceCheck'] + 0;
                 $extFlight->airspaceCheckFinal = $actionData['flight']['validation']['airspaceCheckFinal'] + 0;
                 $extFlight->airspaceCheckMsg = $actionData['flight']['validation']['airspaceCheckMsg'];
             }
             $getScoreDataExtra = 0;
             $getScoreDataExtraMissing = 0;
             if ($getScoreData) {
                 // we should get these from the [score] section  also
                 $extFlight->BEST_FLIGHT_TYPE = $actionData['flight']['stats']['FlightType'];
                 $extFlight->FLIGHT_KM = $actionData['flight']['stats']['XCdistance'];
                 $extFlight->FLIGHT_POINTS = $actionData['flight']['stats']['XCscore'];
                 $extFlight->LINEAR_DISTANCE = $actionData['flight']['stats']['StraightDistance'] + 0;
                 $extFlight->MAX_LINEAR_DISTANCE = $actionData['flight']['stats']['MaxStraightDistance'] + 0;
                 $extFlight->MEAN_SPEED = $actionData['flight']['stats']['MeanGliderSpeed'] + 0;
                 $extFlight->MAX_SPEED = $actionData['flight']['stats']['MaxSpeed'] + 0;
                 $extFlight->MAX_VARIO = $actionData['flight']['stats']['MaxVario'] + 0;
                 $extFlight->MIN_VARIO = $actionData['flight']['stats']['MinVario'] + 0;
                 $extFlight->MAX_ALT = $actionData['flight']['stats']['MaxAltASL'] + 0;
                 $extFlight->MIN_ALT = $actionData['flight']['stats']['MinAltASL'] + 0;
                 $extFlight->TAKEOFF_ALT = $actionData['flight']['stats']['TakeoffAlt'] + 0;
                 if (is_array($actionData['flight']['score']) && count($actionData['flight']['score']) > 0) {
                     require_once dirname(__FILE__) . '/CL_flightScore.php';
                     $flightScore = new flightScore($extFlight->flightID);
                     // we have the score array in $actionData['score']
                     $sArr =& $actionData['flight']['score'];
                     $flightScore->fromSyncArray($sArr);
                     $extFlight->flightScore = $flightScore;
                     $getScoreDataExtra = 1;
                     $extFlight->BEST_FLIGHT_TYPE = $flightScore->bestScoreType;
                     $extFlight->FLIGHT_KM = $flightScore->bestDistance * 1000;
                     $extFlight->FLIGHT_POINTS = $flightScore->bestScore;
                     // check for missing linear distance
                     if ($extFlight->LINEAR_DISTANCE == 0 && $extFlight->MAX_LINEAR_DISTANCE > 0) {
                         // echo "compute MAxtakeoffDistance";
                         $extFlight->LINEAR_DISTANCE = $flightScore->computeMaxTakeoffDistance($firstPoint);
                     }
                     //put also in scores table, the flight is sure to be present in flights table
                     if ($e['action'] == 2) {
                         // update so we already know the flightID
                         $flightScore->putToDB(1, 1);
                     }
                 } else {
                     $getScoreDataExtraMissing = 1;
                 }
             }
             // we also have [gliderBrand] => GRADIENT
             $extFlight->checkGliderBrand($actionData['flight']['info']['gliderBrand']);
             if ($e['action'] == 1) {
                 if ($sync_mode & SYNC_INSERT_FLIGHT_LOCAL) {
                     $tmpPilot = new pilot($effectiveServerID, $effectiveUserID);
                     $tmpPilot->createDirs();
                     $extFlight->filename = $igcFilename;
                     $extFlight->checkDirs();
                     if ($DBGlvl > 0) {
                         echo "Moving file into place: " . $extFlight->getIGCFilename() . "<BR>";
                     }
                     while (is_file($extFlight->getIGCFilename())) {
                         if ($DBGlvl > 0) {
                             echo "Same filename is already present<BR>";
                         }
                         $extFlight->filename = '_' . $extFlight->filename;
                     }
                     @rename($igcFileTmp, $extFlight->getIGCFilename());
                     $opString = '*inserted*';
                 } else {
                     $opString = '*linked*';
                 }
                 // insert flight
                 $extFlight->putFlightToDB(0);
                 // take care of sme flights (hide /unhide)
                 $extFlight->hideSameFlights();
                 if ($getScoreData && $getScoreDataExtra) {
                     $flightScore->flightID = $extFlight->flightID;
                     $flightScore->putToDB(1, 1);
                 } else {
                     if ($getScoreDataExtraMissing && $CONF['servers']['list'][$actionData['flight']['serverID']]['rescore_if_missing'] && $sync_mode & SYNC_INSERT_FLIGHT_LOCAL) {
                         echo " [Re-score] ";
                         $extFlight->computeScore();
                     }
                 }
                 return array(1, "Flight {$opString} OK {$addFlightNote} with local ID {$extFlight->flightID}");
             } else {
                 //update flight
                 $extFlight->putFlightToDB(1);
                 if ($getScoreDataExtraMissing && $CONF['servers']['list'][$actionData['flight']['serverID']]['rescore_if_missing'] && $sync_mode & SYNC_INSERT_FLIGHT_LOCAL) {
                     echo " [Re-score] ";
                     require_once dirname(__FILE__) . '/CL_flightScore.php';
                     $flightScore = new flightScore($extFlight->flightID);
                     $flightScore->getFromDB();
                     if ($flightScore->gotValues) {
                         echo "[not needed] ";
                     } else {
                         $extFlight->computeScore();
                     }
                 }
                 return array(1, "Flight with local ID {$flightIDlocal} UPDATED OK");
             }
         }
         return array(0, "Unknown error, we should have returned by this far...");
     }
     // if type==1
 }
Esempio n. 8
0
# IMDBPHP                              (c) Giorgos Giagas & Itzchak Rehberg #
# written by Giorgos Giagas                                                 #
# extended & maintained by Itzchak Rehberg <izzysoft AT qumran DOT org>     #
# http://www.izzysoft.de/                                                   #
# ------------------------------------------------------------------------- #
# This program is free software; you can redistribute and/or modify it      #
# under the terms of the GNU General Public License (see doc/LICENSE)       #
#############################################################################
/* $Id: movie.php 510 2012-04-15 18:08:14Z izzy $ */
if (isset($_GET["mid"])) {
    $movieid = $_GET["mid"];
    $engine = $_GET["engine"];
    switch ($engine) {
        case "pilot":
            require "pilot.class.php";
            $movie = new pilot($_GET["mid"]);
            $charset = "utf8";
            $source = "<A HREF='?engine=imdb&mid={$movieid}'>IMDB</A> | <B CLASS='active'>MoviePilot</B>";
            if ($movie->get_pilot_imdbfill()) {
                $source .= '<SUP>+i</SUP>';
            }
            break;
        default:
            require "imdb.class.php";
            $movie = new imdb($_GET["mid"]);
            $charset = "iso-8859-1";
            $source = "<B CLASS='active'>IMDB</B> | <A HREF='?engine=pilot&mid={$movieid}'>MoviePilot</A>";
            break;
    }
    $movie->setid($movieid);
    $rows = 2;
        }
    }
    $sql = "INSERT INTO {$pilotsTable} (countryCode,CIVL_ID,CIVL_NAME,FirstName,LastName,Sex,Birthdate,pilotID,serverID)\n\t\t\tVALUES(\n\t\t\t'" . makeSane($_POST['countryCode']) . "',\n\t\t\t'" . makeSane($_POST['CIVL_ID']) . "',\n\t\t\t'" . makeSane($_POST['CIVL_NAME'], 2) . "',\n\t\t\t'" . makeSane($_POST['FirstName'], 2) . "',\n\t\t\t'" . makeSane($_POST['LastName'], 2) . "',\n\t\t\t'" . makeSane($_POST['Sex']) . "',\n\t\t\t'" . makeSane($_POST['Birthdate']) . "', \n\t\t\t{$user_id},0) ";
    if (!$db->sql_query($sql)) {
        echo "Error in query : {$sql}<BR>";
    }
    echo "User Added";
    exit;
} else {
    if ($op == 'del') {
        $user_id = makeSane($_POST['id']);
        $sql = "DELETE FROM " . $CONF['userdb']['users_table'] . " WHERE user_id={$user_id} ";
        if (!$db->sql_query($sql)) {
            echo "Error in query : {$sql}<BR>";
        }
        $pilot = new pilot(0, $user_id);
        $pilot->deletePilot(1, 1);
        exit;
    } else {
        if ($op == 'edit') {
            $user_id = makeSane($_POST['id']);
            $sql = "UPDATE {$pilotsTable} SET \n\t\t\tcountryCode='" . makeSane($_POST['countryCode']) . "',\n\t\t\tCIVL_ID='" . makeSane($_POST['CIVL_ID']) . "',\n\t\t\tCIVL_NAME='" . makeSane($_POST['CIVL_NAME'], 2) . "',\n\t\t\tFirstName='" . makeSane($_POST['FirstName'], 2) . "',\n\t\t\tLastName='" . makeSane($_POST['LastName'], 2) . "',\n\t\t\tSex='" . makeSane($_POST['Sex']) . "',\n\t\t\tBirthdate='" . makeSane($_POST['Birthdate']) . "' \n\t\t\tWHERE pilotID={$user_id} AND serverID=0";
            if (!$db->sql_query($sql)) {
                echo "Error in query : {$sql}<BR>";
            }
            $sql = "UPDATE " . $CONF['userdb']['users_table'] . " SET \n\t\t\tusername='******'username'], 2) . "',\n\t\t\tuser_email='" . makeSane($_POST['user_email'], 2) . "'\t\t\n\t\t\tWHERE user_id={$user_id} ";
            if (!$db->sql_query($sql)) {
                echo "Error in query : {$sql}<BR>";
            }
            // change password ?
            $user_password = makeSane($_POST['user_password'], 2);
Esempio n. 10
0
    $query = "INSERT INTO {$remotePilotsTable} (remoteServerID,remoteUserID,serverID,userID) VALUES \n\t\t  \t\t\t({$serverID1},{$userID1},{$serverID2},{$userID2} )";
    $res = $db->sql_query($query);
    if ($res <= 0) {
        echo "<H3> Error in mapping pilots: {$query}</H3>\n";
    } else {
        echo "Pilot Mapping successfull";
    }
} else {
    if ($op == 'copyRemoteToLocalInfo') {
        $pilotID1 = makeSane($_GET['pilotID1'], 0);
        $pilotID2 = makeSane($_GET['pilotID2'], 0);
        $serverID1 = makeSane($_GET['serverID1'], 0);
        $serverID2 = makeSane($_GET['serverID2'], 0);
        require_once "CL_pilot.php";
        echo "Copying Pilot Info from {$serverID1}  {$pilotID1} -> {$serverID2} {$pilotID2}<br>";
        $pilot1 = new pilot($serverID1, $pilotID1);
        $pilot1->getFromDB();
        $pilot1->pilotID = $pilotID2;
        $pilot1->serverID = $serverID2;
        $res = $pilot1->putToDB1(1);
        echo "Res:{$res}<BR>";
    } else {
        if ($op == 'movePilotFlights') {
            $pilotID1 = makeSane($_GET['pilotID1'], 0);
            $pilotID2 = makeSane($_GET['pilotID2'], 0);
            $serverID1 = makeSane($_GET['serverID1'], 0);
            $serverID2 = makeSane($_GET['serverID2'], 0);
            echo "moving flights from {$serverID1}  {$pilotID1} -> {$serverID2} {$pilotID2} ";
            require_once "CL_pilot.php";
            $pilot = new pilot($serverID1, $pilotID1);
            $res = $pilot->movePilotFlights($serverID2, $pilotID2);
Esempio n. 11
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. 12
0
 function fetchXML()
 {
     $myKeyString = array();
     // is a player feed - take details from logged in user
     if ($this->API_corpID_ != "") {
         $myKeyString["corporationID"] = $this->API_corpID_;
         $this->CharName_ = $this->API_corpID_;
     } elseif (user::get('usr_pilot_id')) {
         $plt = new pilot(user::get('usr_pilot_id'));
         $usersname = $plt->getName();
         $this->CharName_ = $usersname;
         $sql = 'select plts.plt_id, plts.plt_externalid from kb3_pilots plts where plts.plt_name = "' . $usersname . '"';
         $qry = DBFactory::getDBQuery();
         $qry->execute($sql);
         $row = $qry->getRow();
         $pilot_id = $row['plt_id'];
         $API_charID = $row['plt_externalid'];
         if ($pilot_id == 0) {
             return "Something went wrong with finding pilots external ID<br>";
         }
         $newsql = 'SELECT userID , apiKey FROM kb3_api_user WHERE charID = "' . $API_charID . '"';
         $qry->execute($newsql);
         $userrow = $qry->getRow();
         $API_userID = $userrow['userID'];
         $API_apiKey = $userrow['apiKey'];
         $myKeyString["userID"] = $API_userID;
         $myKeyString["apiKey"] = $API_apiKey;
         $myKeyString["characterID"] = $API_charID;
     } else {
         if ($this->API_userID_ != "" && $this->API_apiKey_ != "" && $this->API_charID_ != "") {
             $myKeyString["userID"] = $this->API_userID_;
             $myKeyString["apiKey"] = $this->API_apiKey_;
             $myKeyString["characterID"] = $this->API_charID_;
             $this->CharName_ = $this->API_charID_;
         } else {
             return "You are not logged in and have not set API details.";
         }
     }
     $this->_result = $this->CallAPI("corp", "CorporationSheet", array('corporationID' => $myKeyString['corporationID']), $this->API_userID_, $this->API_apiKey_);
     if ($this->_result == false) {
         return false;
     }
     $this->CurrentTime_ = $this->_result->request_time;
     $this->CachedUntil_ = $this->_result->cached_until;
     return true;
 }
Esempio n. 13
0
 function deleteAllSyncedPilots()
 {
     global $db, $pilotsTable;
     // if (!$this->gotValues) $this->getFromDB();
     $res = $db->sql_query("SELECT * FROM {$pilotsTable} WHERE  serverID={$this->ID} ");
     if ($res <= 0) {
         echo "Error getting server's pilots from local DB<BR>";
         return;
     }
     echo "Deleting all pilots of server " . $this->ID . " from local DB <HR>";
     while ($row = $db->sql_fetchrow($res)) {
         echo "Deleting pilot " . $row['pilotID'] . " : " . $row['FirstName'] . ' ' . $row['LastName'] . "<BR>";
         $pilotToDelete = new pilot($this->ID, $row['pilotID']);
         $pilotToDelete->deletePilot(0, 1);
         // delete dir of pilot
     }
     //	reset the counter
     //$this->lastPullUpdateID=0;
     // $this->putToDB(1);
 }