function changeComment($params) { global $db, $commentsTable; $now = gmdate("Y-m-d H:i:s"); $query = "UPDATE {$commentsTable} SET `text`='" . prep_for_DB($params['text']) . "' , dateUpdated ='{$now}' \n\t\t\t\t\t WHERE commentID=" . $params['commentID'] . " "; // echo $query; $res = $db->sql_query($query); if ($res <= 0) { echo "Error putting comment for flight " . $this->flightID . " to DB: {$query}<BR>"; return 0; } return $newID; }
function putAirspaceToDB() { global $db, $AirspaceArea, $airspaceTable; if (count($AirspaceArea) == 0) { return 1; } //$query="TRUNCATE TABLE $airspaceTable "; // set updated =0 so we then delete all areas not present in the new version $query = "UPDATE TABLE {$airspaceTable} set updated=0 "; $res = $db->sql_query($query); //$query="TRUNCATE TABLE $airspaceTable "; // get 'Comments' and 'id' values $query = "SELECT id,Comments,disabled, Name,serial FROM {$airspaceTable} "; $res = $db->sql_query($query); while ($row = mysql_fetch_assoc($res)) { $data[$row['Name']][$row['serial']]['Comments'] = $row['Comments']; $data[$row['Name']][$row['serial']]['disabled'] = $row['disabled']; $data[$row['Name']][$row['serial']]['id'] = $row['id']; } $names = array(); for ($i = 0; $i < count($AirspaceArea); $i++) { $serial = $names[$AirspaceArea[$i]->Name] + 0; $names[$AirspaceArea[$i]->Name]++; $id = $data[$AirspaceArea[$i]->Name][$serial]['id'] + 0; $Comments = prep_for_DB($data[$AirspaceArea[$i]->Name][$serial]['Comments']); $disabled = $data[$AirspaceArea[$i]->Name][$serial]['disabled'] + 0; // print_r($AirspaceArea[$i]->Base); $fields = " id, Name, serial, updated, Type, Shape, Comments, disabled, minx, miny, maxx, maxy , Base , Top, "; $values = " {$id} , '" . prep_for_DB($AirspaceArea[$i]->Name) . "' , {$serial} , 1, '" . $AirspaceArea[$i]->Type . "' , '" . $AirspaceArea[$i]->Shape . "', '" . $Comments . "', {$disabled} ,\n\t\t\t\t\t" . $AirspaceArea[$i]->minx . ", " . $AirspaceArea[$i]->miny . ", " . $AirspaceArea[$i]->maxx . ", " . $AirspaceArea[$i]->maxy . " ,\n\t\t\t\t '" . serialize($AirspaceArea[$i]->Base) . "' ,'" . serialize($AirspaceArea[$i]->Top) . "' , "; if ($AirspaceArea[$i]->Shape == 1) { //area $fields .= " Points"; $values .= " '" . serialize($AirspaceArea[$i]->Points) . "' "; } else { // circle $fields .= "Radius, Latitude, Longitude "; $values .= $AirspaceArea[$i]->Radius . " , " . $AirspaceArea[$i]->Latitude . " , " . $AirspaceArea[$i]->Longitude; } $query = "REPLACE into {$airspaceTable} ({$fields}) VALUES ({$values}) "; $res = $db->sql_query($query); if (!$res) { echo "Error in inserting airspace [{$i}] to DB: {$query} <BR>"; print_r($AirspaceArea[$i]); return 0; } } // now delete areas not updated $query = "DELETE FROM {$airspaceTable} WHERE updated=0 "; $res = $db->sql_query($query); return 1; }
function searchJob($args) { global $CONF, $db, $jobsTable; $query = "SELECT * FROM {$jobsTable} WHERE "; foreach ($args as $nameStr => $valStr) { if (in_array($nameStr, array('userID', 'jobType', 'param1', 'param2'))) { $query .= $nameStr . "="; $query .= "'" . prep_for_DB($valStr) . "' AND "; } } $query = substr($query, 0, -4); //echo $query; $res = $db->sql_query($query); if ($res <= 0) { echo "Error in searchJob: {$query}<BR>"; return 0; } if ($row = $db->sql_fetchrow($res)) { return $row['timeCreated']; } else { return 0; } }
<head> <meta http-equiv="Content-Type" content="text/html; charset=<?php echo $CONF_ENCODING; ?> "> <style type="text/css"> body, p, table,tr,td {font-family:Verdana, Arial, Helvetica, sans-serif; font-size:10px;} body {margin:0px} </style> </head> <?php $area_id = makeSane($_REQUEST['area_id'], 1); // echo $area_id; if ($_POST['updateComment'] == 1) { // CHANGE waypoint $Comments = prep_for_DB($_POST['Comments']); $disabled = makeSane($_POST['disabled'], 1); $query = "UPDATE {$airspaceTable} SET Comments='{$Comments}' , disabled={$disabled} WHERE id={$area_id}"; // echo $query; $res = $db->sql_query($query); # Error checking if ($res > 0) { ?> <script language="javascript"> function refreshParent() { topWinRef=top.location.href; top.window.location.href=topWinRef; } </script> <?php echo "<center>" . _THE_CHANGES_HAVE_BEEN_APPLIED . "<br><br>";
function putToDB($updateFlightsTable=1) { global $db,$photosTable,$flightsTable; // if (!$this->gotValues) $this->getFromDB(); $query="DELETE FROM $photosTable WHERE flightID=".$this->flightID; //echo $query; $res= $db->sql_query( $query); if($res <= 0){ echo "Error deleting photos for flight ".$this->flightID."<BR>"; } //print_r($this->photos); foreach ( $this->photos as $photoNum=>$photoInfo) { $query="INSERT INTO $photosTable (flightID,path,name,lat,lon,alt,tm,description) VALUES (". $this->flightID.",'".prep_for_DB($photoInfo['path'])."','". prep_for_DB($photoInfo['name'])."',". ($photoInfo['lat']+0).",". ($photoInfo['lon']+0).",". ($photoInfo['alt']+0).",". ($photoInfo['tm']+0).",'". prep_for_DB($photoInfo['description'])."' ) "; // echo $query; $res= $db->sql_query($query); if($res <= 0){ echo "Error putting photo for flight ".$this->flightID." to DB: $query<BR>"; return 0; } } if ($updateFlightsTable) { $query="UPDATE $flightsTable SET hasPhotos=".$this->photosNum." WHERE ID=".$this->flightID; $res= $db->sql_query($query ); if($res <= 0){ echo "Error updating hasPhotos for flight ".$this->flightID." : $query<BR>"; } } $this->gotValues=1; return 1; }
function putToDB($update = 0) { global $db, $waypointsTable, $CONF_server_id, $userID; if ($update) { $query = "REPLACE INTO "; $fl_id_1 = "ID, modifyDate,"; $this->modifyDate = date("Y-m-d H:i:s"); $fl_id_2 = $this->waypointID . ", now(), "; } else { $query = "INSERT INTO "; $fl_id_1 = "modifyDate,"; $fl_id_2 = "now(),"; $this->modifyDate = date("Y-m-d H:i:s"); } $query .= " {$waypointsTable} \n\t\t\t\t\t ( {$fl_id_1} name ,intName, lat,lon, type, location ,intLocation ,countryCode , link, description ) \n\t\t\t\tVALUES ( {$fl_id_2} '" . prep_for_DB($this->name) . "', '" . prep_for_DB($this->intName) . "', " . $this->lat . ", " . $this->lon . " , " . $this->type . ", \n\t\t\t\t\t\t'" . prep_for_DB($this->location) . "', '" . prep_for_DB($this->intLocation) . "', '" . prep_for_DB($this->countryCode) . "' , '" . prep_for_DB($this->link) . "' , '" . prep_for_DB($this->description) . "' )"; // echo $query; $res = $db->sql_query($query); if (!$update) { $this->waypointID = $db->sql_nextid(); } $log = new Logger(); $log->userID = $userID; $log->ItemType = 4; // waypoint; $log->ItemID = $this->waypointID; $log->ServerItemID = $CONF_server_id; $log->ActionID = $update ? 2 : 1; //1 => add 2 => edit; $log->ActionXML = $this->exportXML(); $log->Modifier = 0; $log->ModifierID = 0; $log->ServerModifierID = 0; $log->Result = $res <= 0 ? 0 : 1; $log->ResultDescription = ""; if (!$log->put()) { echo "Problem in logger<BR>"; } if ($res <= 0) { echo "Error putting waypoint to DB {$query}<BR>"; return 0; } return 1; }
function putToDB2($update = 0) { global $db, $pilotsInfoTable; if ($update) { $query = "REPLACE INTO "; $fl_id_1 = "pilotID,serverID, "; $fl_id_2 = $this->pilotID . ", " . $this->serverID . ","; } else { $query = "INSERT INTO "; $fl_id_1 = ""; $fl_id_2 = ""; } $query .= " {$pilotsInfoTable} ( "; foreach ($this->valuesArray2 as $valStr) { $query .= $valStr . ","; } $query = substr($query, 0, -1); $query .= " ) VALUES ( "; foreach ($this->valuesArray2 as $valStr) { $query .= "'" . prep_for_DB($this->{$valStr}) . "',"; } $query = substr($query, 0, -1); $query .= " ) "; // echo $query; $res = $db->sql_query($query); if ($res <= 0) { echo "Error putting pilot to DB : {$query}<BR>"; return 0; } $this->gotValues = 1; return 1; }
function putFlightToDB($update = 0) { global $db; global $flightsTable, $CONF_photosPerFlight, $CONF_server_id; if ($update) { $query = "REPLACE INTO "; $fl_id_1 = "ID,dateAdded,"; $fl_id_2 = $this->flightID . ",'" . $this->dateAdded . "',"; $this->active = 1; } else { $query = "INSERT INTO "; $fl_id_1 = "dateAdded,"; $this->active = 0; if (!$this->dateAdded) { $this->dateAdded = gmdate("Y-m-d H:i:s"); } // $fl_id_2="now(),"; $fl_id_2 = " '" . $this->dateAdded . "',"; $this->timesViewed = 0; } $this->dateUpdated = gmdate("Y-m-d H:i:s"); /* for($i=1;$i<=$CONF_photosPerFlight;$i++) { $var_name="photo".$i."Filename"; $p1.="$var_name, "; $p2.="'".$this->$var_name."',"; } */ // we dont store $originalURL $originalKML. for leonardo originated flights... $originalURL = $this->originalURL; $originalKML = $this->originalKML; if ($this->serverID != 0) { global $CONF; if ($CONF['servers']['list'][$this->serverID]['isLeo'] == 1) { $originalURL = ''; $originalKML = ''; } } // make sure it evaluates to something $this->gliderCertCategory += 0; /// Martin Jursa 17.05.2007: adding NACid $query .= " {$flightsTable} (" . $fl_id_1 . "filename,userID, dateUpdated,\n\t\tcat,subcat,category,active, private ,\n\t\tgliderCertCategory, startType,\n\t\tvalidated,grecord,validationMessage,\n\t\thash, serverID, originalURL, originalKML, original_ID,\n\t\toriginalUserID ,userServerID,\n\t\texcludeFrom,\n\n\t\tairspaceCheck,airspaceCheckFinal,airspaceCheckMsg,checkedBy,\n\t\tNACclubID,NACid,\n\t\tcomments, commentsNum, commentsEnabled, glider, gliderBrandID, linkURL, timesViewed,\n\n\t\ttakeoffID, takeoffVinicity, landingID, landingVinicity,\n\t\tDATE,\n\t\ttimezone,\n\t\thasPhotos,\n\t\tMAX_SPEED ,\n\t\tMEAN_SPEED ,\n\t\tMAX_ALT ,\n\t\tMIN_ALT ,\n\t\tTAKEOFF_ALT,\n\t\tMAX_VARIO ,\n\t\tMIN_VARIO ,\n\t\tLINEAR_DISTANCE , " . "MAX_LINEAR_DISTANCE ," . "START_TIME,\n\t\tEND_TIME,\n\t\tDURATION, " . "BEST_FLIGHT_TYPE,\n\t\tFLIGHT_KM,\n\t\tFLIGHT_POINTS," . "autoScore,\n\t\tforceBounds,\n\t\texternalFlightType,\tisLive,\n\t\n\t\tfirstPointTM, firstLat, firstLon,\n\t\tlastPointTM, lastLat, lastLon\n\n\t\t)\n\t\tVALUES (" . $fl_id_2 . "'{$this->filename}',{$this->userID}, '{$this->dateUpdated}',\n\t\t{$this->cat},{$this->subcat},{$this->category},{$this->active}, {$this->private},\n\t\t{$this->gliderCertCategory}, {$this->startType},\n\t\t{$this->validated}, {$this->grecord}, '" . prep_for_DB($this->validationMessage) . "',\n\t\t'{$this->hash}', {$this->serverID}, '{$originalURL}', '{$originalKML}', {$this->original_ID},\n\t\t'{$this->originalUserID}' , {$this->userServerID},\n\t\t{$this->excludeFrom},\n\n\t\t{$this->airspaceCheck}, {$this->airspaceCheckFinal}, '" . prep_for_DB($this->airspaceCheckMsg) . "','" . prep_for_DB($this->checkedBy) . "',\n\t\t{$this->NACclubID}, {$this->NACid},\n\t\t'" . prep_for_DB($this->comments) . "', " . ($this->commentsNum + 0) . ", " . ($this->commentsEnabled + 0) . ", '" . prep_for_DB($this->glider) . "', " . ($this->gliderBrandID + 0) . " , '" . prep_for_DB($this->linkURL) . "', {$this->timesViewed} ,\n\n\t\t'{$this->takeoffID}', {$this->takeoffVinicity}, '{$this->landingID}', {$this->landingVinicity},\n\t\t'{$this->DATE}',\n\t\t{$this->timezone},\n\t\t{$this->hasPhotos},\n\t\t{$this->MAX_SPEED} ,\n\t\t{$this->MEAN_SPEED} ,\n\t\t{$this->MAX_ALT} ,\n\t\t{$this->MIN_ALT} ,\n\t\t{$this->TAKEOFF_ALT},\n\t\t{$this->MAX_VARIO} ,\n\t\t{$this->MIN_VARIO} ,\n\t\t{$this->LINEAR_DISTANCE} , " . ($this->MAX_LINEAR_DISTANCE + 0) . "," . "{$this->START_TIME},\n\t\t{$this->END_TIME},\n\t\t{$this->DURATION}, " . "'{$this->BEST_FLIGHT_TYPE}',\n\t\t" . ($this->FLIGHT_KM + 0) . ",\n\t\t" . ($this->FLIGHT_POINTS + 0) . "," . "{$this->autoScore},\n\t\t{$this->forceBounds},\n\t\t{$this->externalFlightType},\t{$this->isLive},\n\t\t\n\t\t" . ($this->firstPointTM + 0) . ", {$this->firstLat}, {$this->firstLon},\n\t\t" . ($this->lastPointTM + 0) . ", {$this->lastLat}, {$this->lastLon}\n\n\t\t)"; //echo $query; $result = $db->sql_query($query); if (!$result) { echo "Problem in puting flight to DB {$query}<BR>"; } //echo "UPDATE / INSERT RESULT ".$result ; if (!$update) { $this->flightID = $db->sql_nextid(); } require_once dirname(__FILE__) . '/CL_actionLogger.php'; $log = new Logger(); $log->userID = $this->userID; $log->ItemType = 1; // flight; $log->ItemID = $this->serverID && $this->serverID != $CONF_server_id ? $this->original_ID : $this->flightID; // 0 at start will fill in later if successfull $log->ServerItemID = $this->serverID ? $this->serverID : $CONF_server_id; $log->ActionID = $update + 1; //1 => add 2 => edit; $log->ActionXML = $this->toXML(); $log->Modifier = 0; $log->ModifierID = 0; $log->ServerModifierID = 0; $log->Result = $result ? 1 : 0; if (!$log->Result) { $log->ResultDescription = "Problem in puting flight to DB {$query}"; } if (!$log->put()) { echo "Problem in logger<BR>"; } return $result; }
} } $year=substr($row['DATE'],0,4); if ($row['userServerID']) $path=$row['userServerID'].'_'; else $path=''; $path.=$row['userID']."/photos/$year"; $path=prep_for_DB($path); $name=prep_for_DB($name); foreach($photos as $photo) { #martin jursa 22.06.2008 prep_for db also for $photo $photo=prep_for_DB($photo); $query1="INSERT INTO $photosTable (flightID,path,name) values (".$row['ID'].",'$path','$photo') "; $res1= $db->sql_query($query1); if (!$res1) { echo "Problem in inserting photo : $query1<BR>"; } $photoNumTotal++; } if ($hasPhotos) { $query2="UPDATE $flightsTable SET hasPhotos=$hasPhotos WHERE ID=".$row['ID']; $res2= $db->sql_query($query2); if(!$res2 ){ echo "Problem in updating hasPhotos : $query2<BR>"; }
$FirstOlcYear = 0; } $hideDay = $_POST['hideDay'] + 0; $hideMonth = $_POST['hideMonth'] + 0; $hideYear = $_POST['hideYear'] + 0; $hideYearLastDigit = $_POST['hideYearLastDigit'] + 0; $BirthdateHideMask = ($hideDay ? 'xx' : '##') . '.' . ($hideMonth ? 'xx' : '##') . '.' . ($hideYear ? 'xxx' : '###') . ($hideYearLastDigit ? 'x' : '#'); $query = "UPDATE {$pilotsTable} SET\n \t\t`FirstNameEn` = '" . prep_for_DB($_POST['FirstNameEn']) . "',\n\t\t`LastNameEn` = '" . prep_for_DB($_POST['LastNameEn']) . "',\n\t\t`FirstName` = '" . prep_for_DB($_POST['FirstName']) . "',\n\t\t`LastName` = '" . prep_for_DB($_POST['LastName']) . "',\n\t\t`countryCode` = '" . prep_for_DB($_POST['countriesList']) . "',\n\t\t`NACid` = {$NACid},\n\t\t`NACmemberID` = {$NACmemberID},\n\t\t`NACclubID` = {$NACclubID},\t\t\n\t\t`CIVL_ID` = '" . prep_for_DB($_POST['CIVL_ID']) . "',\n\t\t`Birthdate` = '" . prep_for_DB($_POST['Birthdate']) . "',\n\t\t`BirthdateHideMask` = '{$BirthdateHideMask}',\n\t\t`Sex` = '" . prep_for_DB($_POST['Sex']) . "',\n\t\t`PilotPhoto` = '" . $PilotPhoto . "',\n\t\t`FirstOlcYear` = {$FirstOlcYear}\n\n\t\t WHERE `pilotID` = '{$pilotIDview}' AND serverID='{$serverIDview}' "; $res = $db->sql_query($query); if ($res <= 0) { echo "<H3>Error in update query: {$query}</H3>\n"; return; } $res = $db->sql_query("REPLACE INTO {$pilotsInfoTable} (pilotID,serverID) VALUES({$pilotIDview},{$serverIDview})"); $res = $db->sql_query($selQuery); $query = "UPDATE {$pilotsInfoTable} SET\n\t\t`sponsor` = '" . prep_for_DB($_POST['sponsor']) . "',\n\t\t`Occupation` = '" . prep_for_DB($_POST['Occupation']) . "',\n\t\t`MartialStatus` = '" . prep_for_DB($_POST['MartialStatus']) . "',\n\t\t`OtherInterests` = '" . prep_for_DB($_POST['OtherInterests']) . "',\n\t\t`PilotLicence` = '" . prep_for_DB($_POST['PilotLicence']) . "',\n\t\t`BestMemory` = '" . prep_for_DB($_POST['BestMemory']) . "',\n\t\t`WorstMemory` = '" . prep_for_DB($_POST['WorstMemory']) . "',\n\t\t`Training` = '" . prep_for_DB($_POST['Training']) . "',\n\t\t`personalDistance` = '" . prep_for_DB($_POST['personalDistance']) . "',\n\t\t`personalHeight` = '" . prep_for_DB($_POST['personalHeight']) . "',\n\t\t`glider` = '" . prep_for_DB($_POST['glider']) . "',\n\t\t`FlyingSince` = '" . prep_for_DB($_POST['FlyingSince']) . "',\n\t\t`HoursFlown` = '" . prep_for_DB($_POST['HoursFlown']) . "',\n\t\t`HoursPerYear` = '" . prep_for_DB($_POST['HoursPerYear']) . "',\n\t\t`FavoriteLocation` = '" . prep_for_DB($_POST['FavoriteLocation']) . "',\n\t\t`UsualLocation` = '" . prep_for_DB($_POST['UsualLocation']) . "',\n\t\t`FavoriteBooks` = '" . prep_for_DB($_POST['FavoriteBooks']) . "',\n\t\t`FavoriteActors` = '" . prep_for_DB($_POST['FavoriteActors']) . "',\n\t\t`FavoriteSingers` = '" . prep_for_DB($_POST['FavoriteSingers']) . "',\n\t\t`FavoriteMovies` = '" . prep_for_DB($_POST['FavoriteMovies']) . "',\n\t\t`FavoriteSite` = '" . prep_for_DB($_POST['FavoriteSite']) . "',\n\t\t`Sign` = '" . prep_for_DB($_POST['Sign']) . "',\n\t\t`Spiral` = '" . prep_for_DB($_POST['Spiral']) . "',\n\t\t`Bline` = '" . prep_for_DB($_POST['Bline']) . "',\n\t\t`FullStall` = '" . prep_for_DB($_POST['FullStall']) . "',\n\t\t`Sat` = '" . prep_for_DB($_POST['Sat']) . "',\n\t\t`AsymmetricSpiral` = '" . prep_for_DB($_POST['AsymmetricSpiral']) . "',\n\t\t`Spin` = '" . prep_for_DB($_POST['Spin']) . "',\n\t\t`OtherAcro` = '" . prep_for_DB($_POST['OtherAcro']) . "',\n\t\t`camera` = '" . prep_for_DB($_POST['camera']) . "',\n\t\t`camcorder` = '" . prep_for_DB($_POST['camcorder']) . "',\n\t\t`Harness` = '" . prep_for_DB($_POST['Harness']) . "',\n\t\t`Vario` = '" . prep_for_DB($_POST['Vario']) . "',\n\t\t`GPS` = '" . prep_for_DB($_POST['GPS']) . "',\n\t\t`Helmet` = '" . prep_for_DB($_POST['Helmet']) . "',\n\t\t`Reserve` = '" . prep_for_DB($_POST['Reserve']) . "',\n\t\t`commentsEnabled` = " . ($_POST['commentsEnabled'] + 0) . ",\n\t\t`PersonalWebPage` = '" . prep_for_DB($_POST['PersonalWebPage']) . "'\n\n\t\t WHERE `pilotID` = '{$pilotIDview}' AND serverID='{$serverIDview}' "; $res = $db->sql_query($query); if ($res <= 0) { echo "<H3>Error in update query: {$query}</H3>\n"; return; } // echo '<div style="font-weight:bold;margin:10px;">'._Your_profile_has_been_updated.'</div>'; echo "<div style='font-weight:bold;margin:10px;'><span class='ok'>" . _Your_profile_has_been_updated . "\n\t\t\t</span></div>"; } // $query_sel="SELECT * FROM $pilotsTable, ".$CONF['userdb']['users_table']." WHERE pilotID=".$pilotIDview ." AND pilotID=".$CONF['userdb']['user_id_field'] ; $query_sel = " SELECT * FROM {$pilotsTable} LEFT JOIN {$pilotsInfoTable} ON\n\t\t\t\t({$pilotsTable}.pilotID={$pilotsInfoTable}.pilotID AND {$pilotsTable}.serverID={$pilotsInfoTable}.serverID )\n\t\t\tWHERE \n\t\t\t\t{$pilotsTable}.pilotID={$pilotIDview} AND {$pilotsTable}.serverID={$serverIDview}"; $res = $db->sql_query($query_sel); if ($res <= 0) { echo "<H3>Error in pilot query</H3>\n"; return; } else {