Beispiel #1
0
function processDistances($in)
{
    $dirs = explode("\n", $in);
    $routes = array();
    $places = array();
    $patt = "/(.*) to (.*) = ([0-9]*)/";
    foreach ($dirs as $dir) {
        if (!$dir) {
            continue;
        }
        $matches = array();
        preg_match($patt, $dir, $matches);
        $routes = addToRoutes($matches[1], $matches[2], $matches[3], $routes);
        $places[] = $matches[1];
        $places[] = $matches[2];
    }
    $places = array_unique($places);
    $currentLowestDist = -1;
    $currentLowestRoute = array();
    foreach (getAllRoutes($places) as $route) {
        $dist = calcDistance($route, $routes);
        if ($dist > $currentLowestDist) {
            $currentLowestDist = $dist;
            $currentLowestRoute = $route;
        }
    }
    echo "Lowest Distance: " . $currentLowestDist . "\n";
}
Beispiel #2
0
function process_new_cache($notify)
{
    global $debug, $debug_mailto, $rootpath;
    global $mailfrom, $new_cache_subject, $new_oconly_subject;
    //echo "process_new_cache(".$notify['id'].")\n";
    $error = false;
    // mail-template lesen
    switch ($notify['type']) {
        case notify_new_cache:
            // Type: new cache
            $mailbody = read_file($rootpath . 'util/notification/notify_newcache.email');
            $mailsubject = $new_cache_subject;
            break;
        case notify_new_oconly:
            // Type: new OConly flag
            $mailbody = read_file($rootpath . 'util/notification/notify_newoconly.email');
            $mailsubject = $new_oconly_subject;
            break;
        default:
            $error = true;
            break;
    }
    if (!$error) {
        $mailbody = mb_ereg_replace('{username}', $notify['recpname'], $mailbody);
        $mailbody = mb_ereg_replace('{date}', date('d.m.Y', strtotime($notify['date_hidden'])), $mailbody);
        $mailbody = mb_ereg_replace('{cacheid}', $notify['cache_id'], $mailbody);
        $mailbody = mb_ereg_replace('{wp_oc}', $notify['wp_oc'], $mailbody);
        $mailbody = mb_ereg_replace('{user}', $notify['username'], $mailbody);
        $mailbody = mb_ereg_replace('{cachename}', $notify['cachename'], $mailbody);
        $mailbody = mb_ereg_replace('{distance}', round(calcDistance($notify['lat1'], $notify['lon1'], $notify['lat2'], $notify['lon2'], 1), 1), $mailbody);
        $mailbody = mb_ereg_replace('{unit}', 'km', $mailbody);
        $mailbody = mb_ereg_replace('{bearing}', Bearing2Text(calcBearing($notify['lat1'], $notify['lon1'], $notify['lat2'], $notify['lon2'])), $mailbody);
        $mailbody = mb_ereg_replace('{cachetype}', $notify['cachetype'], $mailbody);
        $mailbody = mb_ereg_replace('{cachesize}', $notify['cachesize'], $mailbody);
        $mailbody = mb_ereg_replace('{oconly}', $notify['oconly'] ? 'OConly-' : '', $mailbody);
        $subject = mb_ereg_replace('{cachename}', $notify['cachename'], $mailsubject);
        $subject = mb_ereg_replace('{oconly}', $notify['oconly'] ? 'OConly-' : '', $subject);
        /* begin send out everything that has to be sent */
        $email_headers = 'From: "' . $mailfrom . '" <' . $mailfrom . '>';
        // mail versenden
        if ($debug == true) {
            $mailadr = $debug_mailto;
        } else {
            $mailadr = $notify['email'];
        }
        if (is_existent_maildomain(getToMailDomain($mailadr))) {
            mb_send_mail($mailadr, $subject, $mailbody, $email_headers);
        }
    } else {
        echo "Unbekannter Notification-Typ: " . $notify['type'] . "<br />";
    }
    // logentry($module, $eventid, $userid, $objectid1, $objectid2, $logtext, $details)
    logentry('notify_newcache', 8, $notify['recid'], $notify['cache_id'], 0, 'Sending mail to ' . $mailadr, array());
    return 0;
}
Beispiel #3
0
function calcWinner($in, $seconds)
{
    $reindeerDetails = getReindeerDetails($in);
    $maxDistance = 0;
    foreach ($reindeerDetails as $name => $reindeer) {
        $distance = calcDistance($seconds, $reindeer);
        if ($distance > $maxDistance) {
            $maxDistance = $distance;
        }
    }
    echo "Winning reindeer went {$maxDistance}\n";
}
Beispiel #4
0
function process_new_cache($notify)
{
    global $emailaddr, $octeamEmailsSignature, $absolute_server_URI, $site_name, $dateFormat, $cacheTypes, $cacheSizes, $cacheTypeIcons;
    switch ($notify['type']) {
        case NOTIFY_NEW_CACHES:
            // Type: new cache
            $mailbody = file_get_contents(__DIR__ . '/notifyNewcacheEmail.html');
            break;
        default:
            echo "Unknown Notification Typ: " . $notify['type'] . "<br />";
            return 0;
    }
    $thunderSection = ' (<img src="' . $absolute_server_URI . 'tpl/stdstyle/images/blue/thunder_ico.png" alt="user activity" width="9" height="9" border="0" title="' . tr('viewlog_aktywnosc') . ' [' . $notify['found'] . '+' . $notify['dnf'] . '+' . $notify['hidden'] . ']"/>' . ($notify['hidden'] + $notify['found'] + $notify['dnf']) . ') ';
    $mailbody = mb_ereg_replace('{username}', htmlspecialchars($notify['recpname'], ENT_COMPAT, 'UTF-8'), $mailbody);
    $mailbody = mb_ereg_replace('{date}', date($dateFormat, strtotime($notify['date_hidden'])), $mailbody);
    $mailbody = mb_ereg_replace('{cacheid}', $notify['cache_id'], $mailbody);
    $mailbody = mb_ereg_replace('{wp_oc}', $notify['wp_oc'], $mailbody);
    $mailbody = mb_ereg_replace('{user}', htmlspecialchars($notify['username'], ENT_COMPAT, 'UTF-8'), $mailbody);
    $mailbody = mb_ereg_replace('{cachename}', htmlspecialchars($notify['cachename'], ENT_COMPAT, 'UTF-8'), $mailbody);
    $mailbody = mb_ereg_replace('{distance}', round(calcDistance($notify['lat1'], $notify['lon1'], $notify['lat2'], $notify['lon2'], 1), 1), $mailbody);
    $mailbody = mb_ereg_replace('{unit}', 'km', $mailbody);
    $mailbody = mb_ereg_replace('{bearing}', Bearing2Text(calcBearing($notify['lat1'], $notify['lon1'], $notify['lat2'], $notify['lon2'])), $mailbody);
    $mailbody = mb_ereg_replace('{cachetype}', tr($cacheTypes[$notify['cachetype']]['translation']), $mailbody);
    $mailbody = mb_ereg_replace('{cachesize}', tr($cacheSizes[$notify['cachesize']]['translation']), $mailbody);
    $mailbody = mb_ereg_replace('{server}', $absolute_server_URI, $mailbody);
    $mailbody = mb_ereg_replace('{sitename}', $site_name, $mailbody);
    $mailbody = mb_ereg_replace('{notify_newCache_01}', tr('notify_newCache_01'), $mailbody);
    $mailbody = mb_ereg_replace('{notify_newCache_02}', tr('notify_newCache_02'), $mailbody);
    $mailbody = mb_ereg_replace('{notify_newCache_03}', tr('notify_newCache_03'), $mailbody);
    $mailbody = mb_ereg_replace('{notify_newCache_04}', tr('notify_newCache_04'), $mailbody);
    $mailbody = mb_ereg_replace('{notify_newCache_05}', tr('notify_newCache_05'), $mailbody);
    $mailbody = mb_ereg_replace('{notify_newCache_06}', tr('notify_newCache_06'), $mailbody);
    $mailbody = mb_ereg_replace('{notify_newCache_07}', tr('notify_newCache_07'), $mailbody);
    $mailbody = mb_ereg_replace('{notify_newCache_08}', tr('notify_newCache_08'), $mailbody);
    $mailbody = mb_ereg_replace('{notify_newCache_09}', tr('notify_newCache_09'), $mailbody);
    $mailbody = mb_ereg_replace('{octeamEmailsSignature}', $octeamEmailsSignature, $mailbody);
    $mailbody = mb_ereg_replace('{runwatch04}', tr('runwatch04'), $mailbody);
    $mailbody = mb_ereg_replace('{runwatch08}', tr('runwatch08'), $mailbody);
    $mailbody = mb_ereg_replace('{runwatch09}', tr('runwatch09'), $mailbody);
    $mailbody = mb_ereg_replace('{wp_oc}', $notify['wp_oc'], $mailbody);
    $mailbody = mb_ereg_replace('{cache_owner_id}', $notify['cache_owner_id'], $mailbody);
    $mailbody = mb_ereg_replace('{caheIcon}', $cacheTypeIcons[$notify['cachetype']]['iconSet'][1]['iconSmall'], $mailbody);
    $mailbody = mb_ereg_replace('{thunderSection}', $thunderSection, $mailbody);
    $subject = mb_ereg_replace('{cachename}', $notify['cachename'], tr('notify_newCache_13'));
    /* begin send out everything that has to be sent */
    $email_headers = "Content-Type: text/html; charset=utf-8\r\n";
    $email_headers .= 'From: "' . $emailaddr . '" <' . $emailaddr . '>';
    $mailadr = $notify['email'];
    $status = mb_send_mail($mailadr, $subject, $mailbody, $email_headers);
    Log::logentry('notify_newcache', 5, $notify['recid'], $notify['cache_id'], 0, 'Sending mail to ' . $mailadr, array('status' => $status));
    return 0;
}
function process_new_cache($notify)
{
    global $mailfrom, $mailsubject, $debug, $debug_mailto, $rootpath, $octeamEmailsSignature, $absolute_server_URI, $site_name, $dateFormat, $cacheTypes, $cacheSizes, $cacheTypeIcons;
    $fehler = false;
    switch ($notify['type']) {
        case notify_new_cache:
            // Type: new cache
            //$emailFilePath = 'util.sec/notification/notify_newcache.email';
            $emailFilePath = '/notifyNewcacheEmail.html';
            //$mailbody = read_file($rootpath.$emailFilePath);
            $mailbody = file_get_contents(__DIR__ . $emailFilePath);
            break;
        default:
            $fehler = true;
            break;
    }
    if (!$fehler) {
        $thunderSection = ' (<img src="' . $absolute_server_URI . 'tpl/stdstyle/images/blue/thunder_ico.png" alt="user activity" width="9" height="9" border="0" title="' . tr('viewlog_aktywnosc') . ' [' . $notify['found'] . '+' . $notify['dnf'] . '+' . $notify['hidden'] . ']"/>' . ($notify['hidden'] + $notify['found'] + $notify['dnf']) . ') ';
        $mailbody = mb_ereg_replace('{username}', htmlspecialchars($notify['recpname'], ENT_COMPAT, 'UTF-8'), $mailbody);
        $mailbody = mb_ereg_replace('{date}', date($dateFormat, strtotime($notify['date_hidden'])), $mailbody);
        $mailbody = mb_ereg_replace('{cacheid}', $notify['cache_id'], $mailbody);
        $mailbody = mb_ereg_replace('{wp_oc}', $notify['wp_oc'], $mailbody);
        $mailbody = mb_ereg_replace('{user}', htmlspecialchars($notify['username'], ENT_COMPAT, 'UTF-8'), $mailbody);
        $mailbody = mb_ereg_replace('{cachename}', htmlspecialchars($notify['cachename'], ENT_COMPAT, 'UTF-8'), $mailbody);
        $mailbody = mb_ereg_replace('{distance}', round(calcDistance($notify['lat1'], $notify['lon1'], $notify['lat2'], $notify['lon2'], 1), 1), $mailbody);
        $mailbody = mb_ereg_replace('{unit}', 'km', $mailbody);
        $mailbody = mb_ereg_replace('{bearing}', Bearing2Text(calcBearing($notify['lat1'], $notify['lon1'], $notify['lat2'], $notify['lon2'])), $mailbody);
        $mailbody = mb_ereg_replace('{cachetype}', tr($cacheTypes[$notify['cachetype']]['translation']), $mailbody);
        $mailbody = mb_ereg_replace('{cachesize}', tr($cacheSizes[$notify['cachesize']]['translation']), $mailbody);
        $mailbody = mb_ereg_replace('{server}', $absolute_server_URI, $mailbody);
        $mailbody = mb_ereg_replace('{sitename}', $site_name, $mailbody);
        $mailbody = mb_ereg_replace('{notify_newCache_01}', tr('notify_newCache_01'), $mailbody);
        $mailbody = mb_ereg_replace('{notify_newCache_02}', tr('notify_newCache_02'), $mailbody);
        $mailbody = mb_ereg_replace('{notify_newCache_03}', tr('notify_newCache_03'), $mailbody);
        $mailbody = mb_ereg_replace('{notify_newCache_04}', tr('notify_newCache_04'), $mailbody);
        $mailbody = mb_ereg_replace('{notify_newCache_05}', tr('notify_newCache_05'), $mailbody);
        $mailbody = mb_ereg_replace('{notify_newCache_06}', tr('notify_newCache_06'), $mailbody);
        $mailbody = mb_ereg_replace('{notify_newCache_07}', tr('notify_newCache_07'), $mailbody);
        $mailbody = mb_ereg_replace('{notify_newCache_08}', tr('notify_newCache_08'), $mailbody);
        $mailbody = mb_ereg_replace('{notify_newCache_09}', tr('notify_newCache_09'), $mailbody);
        $mailbody = mb_ereg_replace('{octeamEmailsSignature}', $octeamEmailsSignature, $mailbody);
        $mailbody = mb_ereg_replace('{runwatch04}', tr('runwatch04'), $mailbody);
        $mailbody = mb_ereg_replace('{runwatch08}', tr('runwatch08'), $mailbody);
        $mailbody = mb_ereg_replace('{runwatch09}', tr('runwatch09'), $mailbody);
        $mailbody = mb_ereg_replace('{wp_oc}', $notify['wp_oc'], $mailbody);
        $mailbody = mb_ereg_replace('{cache_owner_id}', $notify['cache_owner_id'], $mailbody);
        $mailbody = mb_ereg_replace('{caheIcon}', $cacheTypeIcons[$notify['cachetype']]['iconSet'][1]['iconSmall'], $mailbody);
        $mailbody = mb_ereg_replace('{thunderSection}', $thunderSection, $mailbody);
        $subject = mb_ereg_replace('{cachename}', $notify['cachename'], $mailsubject);
        /* begin send out everything that has to be sent */
        $email_headers = "Content-Type: text/html; charset=utf-8\r\n";
        $email_headers .= 'From: "' . $mailfrom . '" <' . $mailfrom . '>';
        // mail versenden
        if ($debug == true) {
            $mailadr = $debug_mailto;
        } else {
            $mailadr = $notify['email'];
        }
        //header("Content-Type: text/html; charset=utf-8\r\n");
        //echo $mailbody;
        $status = mb_send_mail($mailadr, $subject, $mailbody, $email_headers);
        // logentry($module, $eventid, $userid, $objectid1, $objectid2, $logtext, $details)
        logentry('notify_newcache', 5, $notify['recid'], $notify['cache_id'], 0, 'Sending mail to ' . $mailadr, array('status' => $status));
    } else {
        echo "Unbekannter Notification-Typ: " . $notify['type'] . "<br />";
    }
    return 0;
}
Beispiel #6
0
             // find nearest log after
             $najblizszy_log_pozniej = mysql_fetch_array(mysql_query("\n                                             SELECT\n                                              `id`,\n                                              `date`,\n                                              `user_id`,\n                                              `log_id`,\n                                              `longitude`,\n                                              `latitude`,\n                                              `km`\n                                             FROM  `cache_moved`\n                                             WHERE `cache_id` = '{$cache_id}'\n                                             AND   `date` > '{$log_date}'\n                                             ORDER BY `date` ASC\n                                             LIMIT 1\n                                             "));
             print 'mieszanie z datami<br>';
             print 'data logu: ' . $log_date . '<br><br>ostatnia (najpozniejsza) data logu ($ostatnie_dane_mobilniaka): ' . $ostatnie_dane_mobilniaka['date'] . '<br>data wcześniejszego logu ($najblizszy_log_wczesniej): ' . $najblizszy_log_wczesniej['date'] . '<br>data późniejszego logu ($najblizszy_log_pozniej):' . $najblizszy_log_pozniej['date'];
             // Report all PHP errors
             // wyliczenie zapisac w bazie dystans z obu wierszy modyfikowanych logow
             $najblizszy_log_wczesniej['id'];
             // dla logu przed obecnym
             $najblizszy_log_jeszcze_wczesniej = mysql_fetch_array($najblizszy_log_wczesniej_array);
             $km_logu[$najblizszy_log_wczesniej['id']] = sprintf("%.2f", calcDistance($najblizszy_log_jeszcze_wczesniej['latitude'], $najblizszy_log_jeszcze_wczesniej['longitude'], $najblizszy_log_wczesniej['latitude'], $najblizszy_log_wczesniej['longitude']));
             // dla logu po obecnym
             $km_logu[$najblizszy_log_pozniej['id']] = sprintf("%.2f", calcDistance($wspolrzedneNS, $wspolrzedneWE, $najblizszy_log_pozniej['latitude'], $najblizszy_log_pozniej['longitude']));
             sql("UPDATE `cache_moved` SET `km`='&1' WHERE id = '&2'", $km_logu[$najblizszy_log_pozniej['id']], $najblizszy_log_pozniej['id']);
             sql("UPDATE `cache_moved` SET `km`='&1' WHERE id = '&2'", $km_logu[$najblizszy_log_wczesniej['id']], $najblizszy_log_wczesniej['id']);
             // wyliczenie dystansu dla obecnego logu.
             $dystans = sprintf("%.2f", calcDistance($najblizszy_log_wczesniej['latitude'], $najblizszy_log_wczesniej['longitude'], $wspolrzedneNS, $wspolrzedneWE));
             //print $dystans;
         }
     }
     //
     // insert into table cache_moved
     sql("INSERT INTO `cache_moved`(`id`,\n                                                     `cache_id`,\n                                                     `user_id`,\n                                                     `log_id`,\n                                                     `date`,\n                                                     `longitude`,\n                                                     `latitude`,\n                                                     `km`)\n                                             VALUES ('',\n                                                     '&1',\n                                                     '&2',\n                                                     '&3',\n                                                     '&4',\n                                                     '&5',\n                                                     '&6',\n                                                     '&7'\n                                                    )", sql_escape($cache_id), $usr['userid'], $last_id_4_mobile_moved, $log_date, $wspolrzedneWE, $wspolrzedneNS, $dystans);
     // update main cache coordinates
     sql("UPDATE `caches` SET `longitude` = '&2', `latitude` = '&3'  WHERE `cache_id`='&1'", sql_escape($cache_id), $wspolrzedneWE, $wspolrzedneNS);
     // get new region (names and codes) from coordinates and put it into database.
     $region = new GetRegions();
     $regiony = $region->GetRegion($wspolrzedneNS, $wspolrzedneWE);
     sql("UPDATE `cache_location` SET adm1 = '&2', adm3 = '&3', code1='&4', code3='&5' WHERE cache_id = '&1'", sql_escape($cache_id), $regiony['adm1'], $regiony['adm3'], $regiony['code1'], $regiony['code3']);
 }
 // mobilne by Łza - koniec
 //inc cache stat and "last found"
     // remove cache from print list
     while (onTheList($_SESSION['print_list'], $cache_id) != -1) {
         unset($_SESSION['print_list'][onTheList($_SESSION['print_list'], $cache_id)]);
     }
     $_SESSION['print_list'] = array_values($_SESSION['print_list']);
 }
 $guru = sqlvalue("SELECT `guru` FROM `user` WHERE `user_id` = '" . sql_escape($usr['userid']) . "' LIMIT 1", 0);
 if ($cache_id != 0 && ($cache_record['status'] != 4 && $cache_record['status'] != 5 && $cache_record['status'] != 6 || $usr['userid'] == $cache_record['user_id'] || $usr['admin'] || $cache_record['status'] == 4 && $guru)) {
     //ok, cache is here, let's process
     $owner_id = $cache_record['user_id'];
     // check XY home if OK redirect to myn
     if ($usr == true) {
         $ulat = sqlValue("SELECT `latitude` FROM user WHERE user_id='" . sql_escape($usr['userid']) . "'", 0);
         $ulon = sqlValue("SELECT `longitude` FROM user WHERE user_id='" . sql_escape($usr['userid']) . "'", 0);
         if ($ulon != NULL && $ulat != NULL || $ulon != 0 && $ulat != 0) {
             $distancecache = sprintf("%.2f", calcDistance($ulat, $ulon, $cache_record['latitude'], $cache_record['longitude']));
             tpl_set_var('distance_cache', '<img src="tpl/stdstyle/images/free_icons/car.png" class="icon16" alt="distance" title="" align="middle" />&nbsp;' . tr('distance_to_cache') . ': <b>' . $distancecache . ' km</b><br />');
         } else {
             tpl_set_var('distance_cache', '');
         }
     } else {
         tpl_set_var('distance_cache', '');
     }
     // get cache waypoint
     $cache_wp = '';
     if ($cache_record['wp_oc'] != '') {
         $cache_wp = $cache_record['wp_oc'];
     } else {
         if ($cache_record['wp_gc'] != '') {
             $cache_wp = $cache_record['wp_gc'];
         } else {
Beispiel #8
0
     // remove cache from print list
     while (onTheList($_SESSION['print_list'], $cache_id) != -1) {
         unset($_SESSION['print_list'][onTheList($_SESSION['print_list'], $cache_id)]);
     }
     $_SESSION['print_list'] = array_values($_SESSION['print_list']);
 }
 if ($cache_id != 0 && ($geocache->getStatus() != 4 && $geocache->getStatus() != 5 && $geocache->getStatus() != 6 || $usr['userid'] == $geocache->getOwner()->getUserId() || $usr['admin'] || $cache_record['status'] == 4 && $applicationContainer->getLoggedUser()->getIsGuide())) {
     //ok, cache is here, let's process
     $owner_id = $geocache->getOwner()->getUserId();
     tpl_set_var('owner_id', $owner_id);
     // check XY home if OK redirect to myn
     if ($usr == true) {
         $ulat = $applicationContainer->getLoggedUser()->getHomeCoordinates()->getLatitude();
         $ulon = $applicationContainer->getLoggedUser()->getHomeCoordinates()->getLongitude();
         if ($ulon != NULL && $ulat != NULL || $ulon != 0 && $ulat != 0) {
             $distancecache = sprintf("%.2f", calcDistance($ulat, $ulon, $geocache->getCoordinates()->getLatitude(), $geocache->getCoordinates()->getLongitude()));
             tpl_set_var('distance_cache', '<img src="tpl/stdstyle/images/free_icons/car.png" class="icon16" alt="distance" title="" align="middle" />&nbsp;' . tr('distance_to_cache') . ': <b>' . $distancecache . ' km</b><br />');
         } else {
             tpl_set_var('distance_cache', '');
         }
     } else {
         tpl_set_var('distance_cache', '');
     }
     // check if there is geokret in this cache
     $thatquery = "SELECT gk_item.id, name, distancetravelled as distance FROM gk_item INNER JOIN gk_item_waypoint ON (gk_item.id = gk_item_waypoint.id) WHERE gk_item_waypoint.wp = :v1 AND stateid<>1 AND stateid<>4 AND stateid <>5 AND typeid<>2 AND missing=0";
     $params['v1']['value'] = (string) $geocache->getGeocacheWaypointId();
     $params['v1']['data_type'] = 'string';
     $s = $dbc->paramQuery($thatquery, $params);
     unset($params);
     //clear to avoid overlaping on next paramQuery (if any))
     $geokrety_all_count = $dbc->rowCount($s);