Пример #1
0
 function getScore($file, $useInternal)
 {
     global $OLCScoringServerUseInternal, $OLCScoringServerPath, $scoringServerActive, $OLCScoringServerPassword;
     global $baseInstallationPath, $CONF_allow_olc_files, $CONF;
     if ($useInternal) {
         $path = dirname(__FILE__) . '/server';
         $igcFilename = tempnam($path . "/tmpFiles", "IGC.");
         //urlencode($basename)
         @unlink($igcFilename);
         $lines = file(rawurldecode($file));
         $cont = "";
         foreach ($lines as $line) {
             $cont .= $line;
         }
         if (!($handle = fopen($igcFilename, 'w'))) {
             exit;
         }
         if (!fwrite($handle, $cont)) {
             exit;
         }
         fclose($handle);
         @chmod($path . "/olc", 0755);
         if ($CONF['os'] == 'windows') {
             $olcEXE = 'olc.exe';
         } else {
             $olcEXE = 'olc';
         }
         $cmd = $path . "/{$olcEXE} {$igcFilename}";
         DEBUG('OLC_SCORE', 1, "cmd={$cmd}");
         exec($cmd, $res);
         DEBUG('OLC_SCORE', 1, "result has " . count($res) . " lines<BR>");
         $contents = array();
         foreach ($res as $line) {
             DEBUG('OLC_SCORE', 1, $line . '<BR>');
             if (substr($line, 0, 4) == "OUT ") {
                 // echo substr($line,4)."\n";
                 $contents[] = substr($line, 4);
             }
         }
         @unlink($igcFilename);
     } else {
         $IGCwebPath = urlencode("http://" . $_SERVER['SERVER_NAME'] . $baseInstallationPath . "/") . $file;
         // score saned file
         $fl = $OLCScoringServerPath . "?pass="******"&file=" . $IGCwebPath;
         DEBUG("OLC_SCORE", 1, "Will use URL: {$fl}<BR>");
         //$contents = file($fl);
         $contents = split("\n", fetchURL($fl, 40));
         // if (!$contents) return;
     }
     return $contents;
 }
Пример #2
0
function getExtrernalServerTakeoffs($serverID, $lat, $lon, $limitKm, $limitNum)
{
    global $xmlSites;
    $takeoffServers = array(1 => array("callUrl" => "http://www.paraglidingearth.com/takeoff_around.php?", "latArg" => "lat", "lonArg" => "lng", "limitKmArg" => "distance", "limitNumArg" => "limit", "XML_name" => "name", "XML_distance" => "distance", "XML_area" => "area", "XML_countryCode" => "countryCode", "XML_url" => "pe_link", "XML_lat" => "lat", "XML_lon" => "lng"), 2 => array("callUrl" => "http://www.paragliding365.com/paragliding_sites_xml.html?type=mini&", "latArg" => "latitude", "lonArg" => "longitude", "limitKmArg" => "radius", "limitNumArg" => "notused", "XML_name" => "name", "XML_distance" => "distance", "XML_area" => "location", "XML_countryCode" => "iso", "XML_url" => "link", "XML_lat" => "lat", "XML_lon" => "lng"));
    $getXMLurl = $takeoffServers[$serverID]["callUrl"] . $takeoffServers[$serverID]["latArg"] . "={$lat}&" . $takeoffServers[$serverID]["lonArg"] . "={$lon}&" . $takeoffServers[$serverID]["limitKmArg"] . "={$limitKm}&" . $takeoffServers[$serverID]["limitNumArg"] . "={$limitNum}";
    //echo 	$getXMLurl;
    $xmlSites = fetchURL($getXMLurl);
    if ($xmlSites) {
        require_once dirname(__FILE__) . '/lib/miniXML/minixml.inc.php';
        $xmlDoc = new MiniXMLDoc();
        $xmlDoc->fromString($xmlSites);
        $xmlArray = $xmlDoc->toArray();
        $takeoffsNum = 0;
        $takoffsList = array();
        // print_r($xmlArray);
        if ($serverID == 1) {
            // paraglidingearth.com
            if (is_array($xmlArray['search'])) {
                if (is_array($xmlArray['search']['takeoff'][0])) {
                    $arrayToUse = $xmlArray['search']['takeoff'];
                } else {
                    $arrayToUse = $xmlArray['search'];
                }
            } else {
                $arrayToUse = 0;
            }
        } else {
            if ($serverID == 2) {
                //paragliding365.com
                if ($xmlArray['root']['flightareas']['flightarea']) {
                    if (is_array($xmlArray['root']['flightareas']['flightarea'][0])) {
                        $arrayToUse = $xmlArray['root']['flightareas']['flightarea'];
                    } else {
                        $arrayToUse = $xmlArray['root']['flightareas'];
                    }
                } else {
                    $arrayToUse = 0;
                }
            } else {
                $arrayToUse = 0;
            }
        }
        $takeoffsList = array();
        $takeoffsNum = 0;
        if ($arrayToUse) {
            //echo "#";
            //print_r($arrayToUse);
            foreach ($arrayToUse as $flightareaNum => $flightarea) {
                $XML_name = $takeoffServers[$serverID]["XML_name"];
                $XML_distance = $takeoffServers[$serverID]["XML_distance"];
                $XML_area = $takeoffServers[$serverID]["XML_area"];
                $XML_countryCode = $takeoffServers[$serverID]["XML_countryCode"];
                $XML_url = $takeoffServers[$serverID]["XML_url"];
                $XML_lat = $takeoffServers[$serverID]["XML_lat"];
                $XML_lon = $takeoffServers[$serverID]["XML_lon"];
                if ($flightareaNum !== "_num" && $flightarea[$XML_name]) {
                    $distance = $flightarea[$XML_distance];
                    if ($distance > $limitKm * 1000) {
                        continue;
                    }
                    $takeoffsList[$takeoffsNum]['distance'] = $flightarea[$XML_distance];
                    $takeoffsList[$takeoffsNum]['name'] = $flightarea[$XML_name];
                    $takeoffsList[$takeoffsNum]['area'] = $flightarea[$XML_area];
                    $takeoffsList[$takeoffsNum]['countryCode'] = $flightarea[$XML_countryCode];
                    $takeoffsList[$takeoffsNum]['url'] = $flightarea[$XML_url];
                    $takeoffsList[$takeoffsNum]['lat'] = $flightarea[$XML_lat];
                    $takeoffsList[$takeoffsNum]['lon'] = $flightarea[$XML_lon];
                    $takeoffsNum++;
                    if ($takeoffsNum == $limitNum) {
                        break;
                    }
                }
            }
        }
        return $takeoffsList;
    }
    // if we have content
    return array();
}
Пример #3
0
function update()
{
    authenticate(1);
    $questionid = sanitize($_POST['id'], "int");
    $title = sanitize($_POST['title'], "string");
    $description = sanitize($_POST['description'], "markdown");
    $link = sanitize($_POST['link'], "url");
    $slug = createSlug($title);
    $kb = 0;
    if (!empty($_POST['answercheck'])) {
        $kb = sanitize($_POST['answercheck'], "int");
    }
    $cache = '';
    if (!empty($link)) {
        $cache = fetchURL($link);
    }
    $sql = "select * from questions where id = '" . escape($questionid) . "'";
    $query = mysql_query($sql);
    $result = mysql_fetch_array($query);
    if ($result['userid'] != $_SESSION['userid']) {
        $basePath = basePath();
        header("Location: {$basePath}/questions/view/{$result['id']}/{$result['slug']}");
    }
    $cacheup = '';
    if ($result['link'] != $link) {
        $cacheup = ",linkcache = '" . escape($cache) . "'";
    }
    if ($result['kb'] == 1 && $kb == 0) {
        score('kb_posted_removed', $questionid);
    } else {
        if ($result['kb'] == 0 && $kb == 1) {
            score('kb_posted', $questionid);
        }
    }
    $sql = "update questions set title = '" . escape($title) . "', kb = '" . escape($kb) . "', description = '" . escape($description) . "' , updated = NOW(), link = '" . escape($link) . "', slug = '" . escape($slug) . "' {$cacheup} where userid = '" . escape($_SESSION['userid']) . "' and id = '" . escape($questionid) . "'";
    $query = mysql_query($sql);
    echo mysql_error();
    $sql = "delete from tags_questions where questionid = '" . escape($questionid) . "'";
    $query = mysql_query($sql);
    if (!empty($_POST['tags'])) {
        foreach ($_POST['tags'] as $tag) {
            $tag = createSlug($tag);
            $sql = "select * from tags where tag = '" . escape($tag) . "'";
            $query = mysql_query($sql);
            $result = mysql_fetch_array($query);
            if ($result['id'] > 0) {
                $sql = "insert into tags_questions (tagid,questionid) values ('" . escape($result['id']) . "','" . escape($questionid) . "')";
                $query = mysql_query($sql);
            } else {
                $sql = "insert into tags (tag) values ('" . escape($tag) . "')";
                $query = mysql_query($sql);
                $tagid = mysql_insert_id();
                $sql = "insert into tags_questions (tagid,questionid) values ('" . escape($tagid) . "','" . escape($questionid) . "')";
                $query = mysql_query($sql);
            }
        }
    }
    $basePath = basePath();
    header("Location: {$basePath}/questions/view/{$questionid}/{$slug}");
}
Пример #4
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
 }
Пример #5
0
/**
 * fetches content from actual password looking service
 *
 * @param string $hash
 * @param string $type
 * @return string
 */
function getpassbyhash($hash, $type)
{
    return fetchURL('http://anna.allkiri.com/getpassbyhash.php?hash=' . $hash . '&type=' . $type);
}
Пример #6
0
		unset($_GET['op1']);
		unset($_GET['direct']);
		unset($_GET['remote']);

		$url="http://".urldecode($_GET['url']);
		foreach($_GET as $name=>$val ) {
			if ( !in_array($name,array('print','url') )  ){
				$url.="&$name=$val";
			}
		}	
		
		if ($remote) $url.='&remote=1';
		$url.='&print';
		
		if ($direct){
			$res=fetchURL($url,300);
		
			echo "<a href='$url' target='_blank'>Printing URL</a><BR>\n";
			// echo $res;
		
			$lines=split("\n",$res);
			if (!$remote) {
				//$lines=$res;
				$pdfFile=$SERVER_URL.$moduleRelPath.$lines[count($lines)-1];
				$pdfFile=$SERVER_URL.$lines[count($lines)-1];							
			} else {
				require_once dirname(__FILE__)."/CL_pdf.php";
				
				$linesNum=count($lines);
				
				for($k=$linesNum-1;$k>0;$k--) {
Пример #7
0
 function validate($updateFlightInDB = 1)
 {
     global $CONF_validation_server_url, $CONF_use_custom_validation, $DBGlvl;
     global $baseInstallationPath, $CONF_abs_path, $CONF;
     global $alreadyValidatedInPage;
     if ($alreadyValidatedInPage) {
         return;
     }
     $alreadyValidatedInPage = 1;
     set_time_limit(240);
     $customValidationCodeFile = dirname(__FILE__) . "/site/CODE_validate_custom.php";
     if ($CONF_use_custom_validation && file_exists($customValidationCodeFile)) {
         // we expect the result on $ok
         include $customValidationCodeFile;
     } else {
         //standard leoanrdo validation -> the server not yet working
         $IGCwebPath = urlencode("http://" . $_SERVER['SERVER_NAME'] . $baseInstallationPath . "/") . $this->getIGCRelPath(0);
         // validate original file
         $fl = $CONF['validation']['server_url'] . "?file=" . $IGCwebPath;
         if ($DBGlvl) {
             $fl .= "&dbg=1";
         }
         DEBUG("VALIDATE_IGC", 1, "Will use URL: {$fl}<BR>");
         $contents = split("\n", fetchURL($fl, 30));
         if (!$contents) {
             return 0;
         }
         $ok = -1;
         foreach ($contents as $lnum => $line) {
             DEBUG("VALIDATE", 64, "{$line}");
             if (trim($contents[$lnum]) == "VALI:OK") {
                 $ok = 1;
                 $valStr = trim($contents[$lnum + 1]);
             }
             if (trim($contents[$lnum]) == "VALI:NOK") {
                 $ok = -1;
                 $valStr = trim($contents[$lnum + 1]);
             }
             if (trim($contents[$lnum]) == "VALI:NNOK") {
                 $ok = -2;
                 $valStr = trim($contents[$lnum + 1]);
             }
         }
     }
     //	 -1 => invalid 0 => not yet proccessed  1 => valid
     // force ok=1 till we have a validation server ready
     // $ok=1;
     $this->grecord = $ok;
     $this->validated = $ok;
     $this->validationMessage = $valStr;
     if ($updateFlightInDB) {
         $this->putFlightToDB(1);
     }
     return $ok;
 }
Пример #8
0
function flights_submit($args)
{
    global $opMode, $CONF;
    //global $DBGlvl,$DEBUG_OUTPUT; $DBGlvl=255;
    require_once dirname(__FILE__) . "/FN_flight.php";
    $username = $args[0];
    $passwd = $args[1];
    $igcURL = $args[2];
    $igcFilename = $args[3];
    $private = $args[4];
    $cat = $args[5];
    $linkURL = $args[6];
    $comments = $args[7];
    $glider = $args[8];
    $clientID = $args[9];
    $clientPass = $args[10];
    global $db, $CONF;
    $allowUploadWithoutPassword = 0;
    if ($clientID) {
        if (clientCheck($clientID, $clientPass)) {
            if ($CONF['servers']['list'][$clientID]['allowUploadWithoutPassword']) {
                $allowUploadWithoutPassword = 1;
            }
        } else {
            return new IXR_Error(200, "Client {$clientID} authentication failed");
        }
    }
    if ($CONF['userdb']['password_users_table']) {
        $dbTable = $CONF['userdb']['password_users_table'];
    } else {
    }
    $sql = "SELECT " . $CONF['userdb']['user_id_field'] . ", " . $CONF['userdb']['username_field'] . ", " . $CONF['userdb']['password_field'] . " FROM " . $CONF['userdb']['users_table'] . " WHERE LOWER(" . $CONF['userdb']['username_field'] . ") = '" . strtolower($username) . "'";
    if (!($result = $db->sql_query($sql))) {
        return new IXR_Error(200, "Error in obtaining userdata for {$username}");
    }
    $passwordHashed = '';
    if ($CONF['userdb']['password_users_table']) {
        $sql2 = "SELECT  " . $CONF['userdb']['password_username_field'] . ", " . $CONF['userdb']['password_password_field'] . " FROM " . $CONF['userdb']['password_users_table'] . " WHERE LOWER(" . $CONF['userdb']['password_username_field'] . ") = '" . strtolower($username) . "'";
        if (!($result2 = $db->sql_query($sql2))) {
            return new IXR_Error(200, "Error in obtaining userdata2 for {$username}");
        }
        if ($row2 = $db->sql_fetchrow($result2)) {
            $passwordHashed = $row2[$CONF['userdb']['password_password_field']];
        }
    }
    //echo "$passwordHashed %";
    $passwdProblems = 0;
    if ($row = $db->sql_fetchrow($result)) {
        if (!$passwordHashed) {
            $passwordHashed = $row[$CONF['userdb']['password_field']];
        }
        if (function_exists('leonardo_check_password')) {
            // phpbb3 has custom way of hashing passwords
            if (!leonardo_check_password($passwd, $passwordHashed)) {
                $passwdProblems = 1;
            }
        } else {
            if (md5($passwd) != $passwordHashed) {
                $passwdProblems = 1;
            }
        }
    } else {
        return new IXR_Error(200, "Error in obtaining userdata for {$username}");
    }
    //  check if the client is authrorized to by pass passord so that it can mass upload flights
    if ($passwdProblems && !$allowUploadWithoutPassword) {
        return new IXR_Error(201, "Error in password for {$username}");
    }
    $userID = $row['user_id'];
    //$filename = dirname(__FILE__)."/flights/".$igcFilename;
    $filename = LEONARDO_ABS_PATH . '/' . $CONF['paths']['tmpigc'] . '/' . $igcFilename;
    if (!($handle = fopen($filename, 'w'))) {
        return new IXR_Error(202, "Cannot open file ({$filename})");
    }
    // $igcURL=html_entity_decode($igcURL);
    $igcURL = rawurldecode($igcURL);
    // return  new IXR_Error(203, "Cannot get igcURL ($igcURL)");
    $igcStr = fetchURL($igcURL, 10);
    // timeout 10 secs
    if (!$igcStr) {
        return new IXR_Error(203, "Cannot get igcURL ({$igcURL})");
    }
    if (!fwrite($handle, $igcStr)) {
        return new IXR_Error(204, "Cannot write to file ({$filename})");
    }
    @fclose($handle);
    error_reporting(0);
    ob_start();
    list($errCode, $flightID) = addFlightFromFile($filename, 0, $userID, array('private' => $private, 'cat' => $cat, 'category' => 1, 'linkURL' => $linkURL, 'comments' => $comments, 'glider' => $glider));
    $errorBuffer = ob_get_contents();
    ob_end_clean();
    $flightID += 0;
    if ($errCode == 1 && $flightID != 0) {
        // all ok
        // return  new IXR_Error(500,htmlspecialchars("flightID:$flightID^errCode:$errCode^" ));
        return $flightID;
    } else {
        if ($errCode == 1 && $flightID == 0) {
            $errStr = "The IGC file did not contain a valid flight";
            //.urlencode($DEBUG_OUTPUT);
        } else {
            $errStr = htmlspecialchars(getAddFlightErrMsg($errCode, $flightID));
        }
        // $errStr.=htmlspecialchars("#----------\n".$errorBuffer);
        return new IXR_Error(500, $errStr);
    }
}
<?php

require_once 'appshed-extension-api/api/api.php';
require_once 'functions.php';
if (empty($_GET['username']) || empty($_GET['password'])) {
    $apiScreen = new AppBuilderAPIListScreen("Incorrect Login");
    echo AppBuilderAPI::getScreenResponse($apiScreen);
    exit;
}
$file = fetchURL('http://community.computingatschool.org.uk/forums.json', null, false, array('username' => $_GET['username'], 'password' => $_GET['password']));
if (!$file) {
    $apiScreen = new AppBuilderAPIListScreen("Incorrect Login");
    echo AppBuilderAPI::getScreenResponse($apiScreen);
    exit;
}
$data = json_decode($file, true);
$apiScreen = new AppBuilderAPIListScreen("Discussion Forums");
$apiScreen->setBack(false);
$base = base();
foreach ($data['normal'] as $forum) {
    $apiItem = new AppBuilderAPILinkItem($forum['name'], "http://images-resized.appshed.com/10148plain_x2.png");
    $apiItem->setImageSize(array('width' => 40, 'height' => 40));
    $query = http_build_query(array('url' => $forum['json_url'], 'name' => $forum['name'], 'username' => $_GET['username'], 'password' => $_GET['password']));
    $apiItem->setRemoteLink("{$base}/forum.php?{$query}");
    $apiScreen->addChild($apiItem);
}
echo AppBuilderAPI::getScreenResponse($apiScreen);
<?php

require_once 'appshed-extension-api/api/api.php';
require_once 'functions.php';
if (empty($_GET['username']) || empty($_GET['password'])) {
    $apiScreen = new AppBuilderAPIListScreen("Incorrect Login");
    echo AppBuilderAPI::getScreenResponse($apiScreen);
    exit;
}
if (!isset($_GET['url']) || !isset($_GET['name']) || strpos($_GET['url'], 'http://community.computingatschool.org.uk') != 0) {
    exit;
}
$file = fetchURL($_GET['url'], null, false, array('username' => $_GET['username'], 'password' => $_GET['password']));
if (!$file) {
    $apiScreen = new AppBuilderAPIListScreen("Incorrect Login");
    echo AppBuilderAPI::getScreenResponse($apiScreen);
    exit;
}
$data = json_decode($file, true);
$apiScreen = new AppBuilderAPIListScreen($_GET['name']);
foreach ($data as $topic) {
    if (!($countPosts = count($topic['posts']))) {
        continue;
    }
    $createStr = date('j M Y', strtotime($topic['created_at']));
    $apiItem = new AppBuilderAPIThumbItem($topic['name'], "by {$topic['posts'][0]['user']['name']} - {$createStr} - {$countPosts} replies", "http://community.computingatschool.org.uk{$topic['posts'][0]['user']['picture']}");
    $apiItem->setImageSize(array('width' => 24, 'height' => 21));
    $apiItem->setScreenLink(getTopicScreen($topic));
    $apiItem->setHrAfter(false);
    $apiScreen->addChild($apiItem);
    $lastPost = $countPosts - 1;
Пример #11
0
 function sync($chunkSize = 5, $verbose = 1)
 {
     // we pull data from this server
     global $CONF_server_id, $CONF_tmp_path;
     global $DBGlvl;
     $this->getFromDB();
     // we need to take care for protocol version 2,
     // in v21 the StartID is the last TM in UTC , we need to start again from the last TM
     // in case 2 or more actions were preformed on the same second and we only
     // proccessed them partially
     // Problem: the last transaction gets pulled again and again !!!
     // we need to detect if the same transaction ID has been proccessed
     // at least 2 times, then we can move to the next ID without fear of loosing
     // transactions made in the same second.
     // we have enforced RULE #1 on the other server running protocol v2
     // RULE #1
     // we  ensure that no transactions of the same second are split into 2 log batches
     // thats why we get 100 more entries and stop manually
     // so the following is not needed nay more , we always start +1
     /*
     if ( $this->getProtocolVersion() == 2 ) 
     	$startID=$this->lastPullUpdateID;
     else // old version
     	$startID=$this->lastPullUpdateID+1;
     */
     $startID = $this->lastPullUpdateID + 1;
     if ($this->data['isLeo']) {
         $urlToPull = 'http://' . $this->data['url_base'] . '/sync.php?type=1&version=' . $this->getProtocolVersion();
         $urlToPull .= "&c={$chunkSize}&startID={$startID}&format=" . $this->data['sync_format'];
         $urlToPull .= "&clientID={$CONF_server_id}&clientPass="******"&sync_type=" . $this->data['sync_type'] . "&use_zip=" . $this->data['use_zip'];
     } else {
         $urlToPull = 'http://' . $this->data['url_sync'] . "count={$chunkSize}&startID={$startID}";
     }
     if ($verbose) {
         echo "Getting <strong>" . $this->data['sync_format'] . "</strong> sync-log from {$urlToPull} ... ";
     }
     if ($verbose) {
         flush2Browser();
     }
     if ($verbose) {
         flush2Browser();
     }
     $timeout = 60 + floor($chunkSize / 5);
     if ($this->data['sync_type'] & SYNC_INSERT_FLIGHT_LOCAL && $this->data['use_zip']) {
         $timeout *= 5;
     }
     $rssStr = fetchURL($urlToPull, $timeout);
     if (!$rssStr) {
         echo "<div class='error'>Cannot get data from server</div><BR>";
         return array(-1, "Cannot get data from {$urlToPull}");
     }
     if ($verbose) {
         echo " <div class='ok'>DONE</div><br>";
     }
     if ($verbose) {
         flush2Browser();
     }
     if ($this->data['use_zip']) {
         // we have a zip file in $rssStr, unzip it
         if ($verbose) {
             echo "Unziping sync-log ... ";
         }
         $tmpZIPfolder = $CONF_tmp_path . '/' . $this->ID . "_" . time();
         makeDir($tmpZIPfolder);
         $zipFile = "{$tmpZIPfolder}/sync_log.zip";
         writeFile($zipFile, $rssStr);
         require_once dirname(__FILE__) . "/lib/pclzip/pclzip.lib.php";
         $archive = new PclZip($zipFile);
         $list = $archive->extract(PCLZIP_OPT_PATH, $tmpZIPfolder, PCLZIP_OPT_REMOVE_ALL_PATH, PCLZIP_OPT_BY_PREG, "/(\\.igc)|(\\.olc)|(\\.txt)\$/i");
         if ($list) {
             if ($verbose) {
                 echo " <div class='ok'>DONE</div><br>";
             }
             echo "<br><b>List of uploaded igc/olc/txt files</b><BR>";
             $f_num = 1;
             foreach ($list as $fileInZip) {
                 echo "{$f_num}) " . $fileInZip['stored_filename'] . ' (' . floor($fileInZip['size'] / 1024) . 'Kb)<br>';
                 $f_num++;
             }
             if ($verbose) {
                 flush2Browser();
             }
             if (is_file($tmpZIPfolder . '/sync.txt')) {
                 $rssStr = implode('', file($tmpZIPfolder . '/sync.txt'));
             } else {
                 echo "Could not find sync.txt. <div class='error'>Aborting</div>";
                 delDir($tmpZIPfolder);
                 return array(-2, "Could not find sync.txt");
             }
             //delDir($tmpZIPfolder);
             //exit;
         } else {
             echo " <div class='error'>This is not a zip file (" . $archive->errorInfo() . ")</div><br>";
         }
     }
     //
     // getIGC
     // zip
     // for debugging json
     // writeFile(dirname(__FILE__).'/sync.txt',$rssStr);
     //return;
     // echo "<PRE>$rssStr</pre>";
     if ($this->data['sync_format'] == 'XML') {
         require_once dirname(__FILE__) . '/lib/miniXML/minixml.inc.php';
         $xmlDoc = new MiniXMLDoc();
         $xmlDoc->fromString($rssStr);
         $xmlArray = $xmlDoc->toArray();
         //echo "<PRE>";
         //print_r($xmlArray);
         //echo "</PRE>";
         if ($xmlArray['log']['item']['_num']) {
             foreach ($xmlArray['log']['item'] as $i => $logItem) {
                 if (!is_numeric($i)) {
                     continue;
                 }
                 if (!$this->processSyncEntry($this->ID, $logItem)) {
                     // if we got an error break the loop, the admin must solve the error
                     break;
                 }
             }
         } else {
             $this->processSyncEntry($this->ID, $xmlArray['log']['item']);
         }
     } else {
         if ($this->data['sync_format'] == 'JSON') {
             if ($verbose) {
                 echo "Decoding log from JSON format ...";
             }
             if ($verbose) {
                 flush2Browser();
             }
             require_once dirname(__FILE__) . '/lib/json/CL_json.php';
             // is this needed ?
             // $rssStr=str_replace('\\\\"','\"',$rssStr);
             // for testing emply log
             // $rssStr='{ "log": [  ] }';
             // for testing bad log
             // $rssStr='{ "log": [   }';
             $arr = json::decode($rssStr);
             if ($verbose) {
                 echo " <div class='ok'>DONE</div><br>";
             }
             if ($verbose) {
                 flush2Browser();
             }
             if ($DBGlvl > 0) {
                 echo "<PRE>";
                 print_r($arr);
                 echo "</PRE>";
             }
             //exit;
             $entriesNum = 0;
             $entriesNumOK = 0;
             if (count($arr['log'])) {
                 if ($verbose) {
                     echo "Log Entries: <div class='ok'>" . count($arr['log']) . "</div><br>";
                 }
                 if ($verbose) {
                     flush2Browser();
                 }
                 foreach ($arr['log'] as $i => $logItem) {
                     if (!is_numeric($i)) {
                         continue;
                     }
                     echo $entriesNum + 1 . " / {$chunkSize} ";
                     // add path of temp folder into array
                     $logItem['item']['tmpDir'] = $tmpZIPfolder;
                     $entryResult = $this->processSyncEntry($this->ID, $logItem['item'], $verbose);
                     if ($entryResult <= -128) {
                         // if we got an error break the loop, the admin must solve the error
                         echo "<div class'error'>Got fatal Error, will exit</div>";
                         $errorInProccess = 1;
                         break;
                     }
                     if ($entryResult > 0) {
                         $entriesNumOK++;
                     }
                     $entriesNum++;
                 }
             } else {
                 if (is_array($arr['log'])) {
                     // no log entries to proccess
                     delDir($tmpZIPfolder);
                     echo "No new log entries to proccess<br />";
                     return array(0, 0);
                 }
                 if ($verbose) {
                     echo "Sync-log format error:<br />";
                     print_r($arr);
                     echo "<hr><pre>{$rssStr}</pre>";
                 } else {
                     echo "Sync-log format error:<br><pre>{$rssStr}</pre><br>";
                 }
                 delDir($tmpZIPfolder);
                 return array(-4, "Sync-log format error: <pre>{$rssStr}</pre>");
             }
         }
     }
     if ($verbose || $entriesNum > 0) {
         echo "<div class='ok'>Sync-log replication finished</div><br>";
         echo "Proccessed {$entriesNum} log entries ({$entriesNumOK} inserted OK) out of {$chunkSize}<br>";
     }
     // clean up
     delDir($tmpZIPfolder);
     if ($errorInProccess) {
         return array(-3, $entriesNum);
     } else {
         return array(1, $entriesNum);
     }
 }