コード例 #1
0
 function run()
 {
     $sql = "delete from CACHE_ACCESS_LOGS where date_sub(now(), INTERVAL 5 DAY) > event_date";
     set_time_limit(360);
     $s = XDb::xSql($sql);
     $total_deleted = XDb::xNumRows($s);
     set_time_limit(60);
     unset($db);
     echo "total_deleted={$total_deleted}\n";
 }
コード例 #2
0
ファイル: news.php プロジェクト: kojoty/opencaching-pl
function find_news($start, $end)
{
    global $tpl;
    $query = "SELECT id,date_posted,content FROM `news` order by id desc limit " . $start . "," . $end;
    $wynik = XDb::xSql($query);
    $ile = XDb::xNumRows($wynik);
    $znalezione = array();
    while ($odp2 = XDb::xFetchArray($wynik)) {
        $odp['date_posted'] = $odp2['date_posted'];
        //$odp['content']=strip_tags($odp2['content'],'<b></b><p></p><a></a><br><br/>');
        $odp['content'] = html2desc($odp2['content']);
        $znalezione[] = $odp;
    }
    $tpl->assign('news', $znalezione);
    return $ile;
}
コード例 #3
0
ファイル: mywatches.php プロジェクト: kojoty/opencaching-pl
 function find_news($start, $end)
 {
     global $lang;
     global $ile;
     global $url;
     global $znalezione;
     $query = "select cache_id from cache_watches where user_id=" . $_SESSION['user_id'] . " limit " . $start . "," . $end;
     $wynik = XDb::xSql($query);
     $ile2 = XDb::xNumRows($wynik);
     if ($ile2 > 0) {
         $znalezione = array();
         while ($rek = XDb::xFetchArray($wynik)) {
             $query = "select status,cache_id,name, score, latitude, longitude, wp_oc, user_id, type from caches where cache_id=" . $rek['cache_id'] . " order by name";
             $wynik2 = XDb::xSql($query);
             while ($rekord = XDb::xFetchArray($wynik2)) {
                 if (isset($_SESSION['user_id'])) {
                     $query2 = "select 1 from cache_logs where user_id = '" . $_SESSION['user_id'] . "' and type = '1' and deleted='0' and cache_id ='" . $rekord['cache_id'] . "';";
                     $wynik2 = XDb::xSql($query2);
                     $if_found = XDb::xFetchArray($wynik2);
                     if ($if_found[0] != '1') {
                         $query2 = "select 2 from cache_logs where user_id = '" . $_SESSION['user_id'] . "' and type = '2' and deleted='0' and cache_id ='" . $rekord['cache_id'] . "';";
                         $wynik2 = XDb::xSql($query2);
                         $if_found = XDb::xFetchArray($wynik2);
                     }
                     $if_found = $if_found[0];
                 }
                 $query = "select username from user where user_id = " . $rekord['user_id'] . ";";
                 $wynik2 = XDb::xSql($query);
                 $wiersz = XDb::xFetchArray($wynik2);
                 $query = "select " . $lang . " from cache_type where id = " . $rekord['type'] . ";";
                 $wynik2 = XDb::xSql($query);
                 $wiersz2 = XDb::xFetchArray($wynik2);
                 $rekord['if_found'] = $if_found;
                 $rekord['username'] = $wiersz['username'];
                 $rekord['N'] = cords($rekord['latitude']);
                 $rekord['E'] = cords($rekord['longitude']);
                 $rekord['typetext'] = $wiersz2[0];
                 $znalezione[] = $rekord;
             }
         }
     }
 }
コード例 #4
0
 function find_news($start, $end)
 {
     global $lang;
     global $ile;
     global $url;
     global $tpl;
     global $znalezione;
     if (isset($_GET['nazwa'])) {
         $nazwa = XDb::xEscape($_GET['nazwa']);
         $query = "select votes,cache_id,name, status, score, latitude, longitude, wp_oc, user_id, type from caches where name like '%" . $nazwa . "%' and caches.status in ('1','2','3') order by name limit " . $start . "," . $end;
         $czykilka = 1;
         $url = "./find.php?nazwa=" . $nazwa;
     }
     if (isset($_GET['wp'])) {
         $wp = XDb::xEscape($_GET['wp']);
         $query = "select votes,cache_id,name, status, score, latitude, longitude, wp_oc, user_id, type from caches where wp_oc = '" . $wp . "' and caches.status in ('1','2','3') order by name limit " . $start . "," . $end;
         $czykilka = 0;
         $url = "./find.php?wp=" . $wp;
     }
     if (isset($_GET['owner'])) {
         $owner = XDb::xEscape($_GET['owner']);
         $query = "select votes,cache_id,name, status, score, latitude, longitude, wp_oc, user_id, type from caches where user_id = (select user_id from user where username ='******') and caches.status in ('1','2','3') order by name limit " . $start . "," . $end;
         $czykilka = 1;
         $url = "./find.php?owner=" . $owner;
     }
     if (isset($_GET['finder'])) {
         $finder = XDb::xEscape($_GET['finder']);
         $query = "select caches.votes,caches.cache_id,name, status, score, latitude, longitude, wp_oc, caches.user_id, caches.type from caches inner join cache_logs on caches.cache_id=cache_logs.cache_id where cache_logs.user_id = (select user.user_id from user where username ='******') and cache_logs.type = '1' and cache_logs.deleted=0 and caches.status in ('1','2','3') order by cache_logs.id desc limit " . $start . "," . $end;
         $czykilka = 1;
         $url = "./find.php?finder=" . $finder;
     }
     $wynik = XDb::xSql($query);
     $ilewyn = XDb::xNumRows($wynik);
     if ($czykilka == 0) {
         if ($ilewyn > 0) {
             global $address;
             $wiersz = XDb::xFetchArray($wynik);
             $adres = "./" . $address . ".php?wp=" . $wiersz['wp_oc'];
             header('Location: ' . $adres);
             exit;
         } else {
             $tpl->assign("error", "1");
         }
     }
     if ($czykilka == 1) {
         $znalezione = array();
         while ($rekord = XDb::xFetchArray($wynik)) {
             if (isset($_SESSION['user_id'])) {
                 $query2 = "select 1 from cache_logs where user_id = '" . $_SESSION['user_id'] . "' and type = '1' and deleted='0' and cache_id ='" . $rekord['cache_id'] . "';";
                 $wynik2 = XDb::xSql($query2);
                 $if_found = XDb::xFetchArray($wynik2);
                 if ($if_found[0] != '1') {
                     $query2 = "select 2 from cache_logs where user_id = '" . $_SESSION['user_id'] . "' and type = '2' and deleted='0' and cache_id ='" . $rekord['cache_id'] . "';";
                     $wynik2 = XDb::xSql($query2);
                     $if_found = XDb::xFetchArray($wynik2);
                 }
                 $if_found = $if_found[0];
             }
             $query = "select username from user where user_id = " . $rekord['user_id'] . ";";
             $wynik2 = XDb::xSql($query);
             $wiersz = XDb::xFetchArray($wynik2);
             $query = "select " . $lang . " from cache_type where id = " . $rekord['type'] . ";";
             $wynik2 = XDb::xSql($query);
             $wiersz2 = XDb::xFetchArray($wynik2);
             if ($rekord['votes'] > 3) {
                 $rekord['score'] = score2ratingnum($rekord['score']);
             } else {
                 $rekord['score'] = 5;
             }
             $rekord['username'] = $wiersz['username'];
             $rekord['if_found'] = $if_found;
             $rekord['N'] = cords($rekord['latitude']);
             $rekord['E'] = cords($rekord['longitude']);
             $rekord['typetext'] = $wiersz2[0];
             $znalezione[] = $rekord;
         }
     }
 }
コード例 #5
0
ファイル: viewprofile.php プロジェクト: kojoty/opencaching-pl
      * but without unset($rsms) query below don't return any results
      */
     unset($rsms);
     $rsms = XDb::xSql("SET @r = 1;\n                    SELECT * FROM\n                    (\n                        SELECT *,@r:=@r+1 row FROM (\n\n                            SELECT cache_id, wp_oc, DATE_FORMAT(date_created,'%d-%m-%Y') data\n                            FROM caches\n                            WHERE user_id= ? AND status <> 4 AND status <> 5 AND status <> 6 AND type <> 6\n                            ORDER BY\n                                YEAR(`date_created`) ASC,\n                                MONTH(`date_created`) ASC,\n                                DAY(`date_created`) ASC,\n                                HOUR(`date_created`) ASC\n\n                        ) B\n                    ) A\n                    WHERE row % {$milestone} =1 ORDER BY row ASC", $user_id);
     $rsms->nextRowset();
     //to switch to second query results :)
     while ($rms = XDb::xFetchArray($rsms)) {
         $content .= '<tr> <td>' . ($rms['row'] - 1) . '</td><td>' . $rms['data'] . '</td><td><a class="links" href="viewcache.php?cacheid=' . $rms['cache_id'] . '">' . $rms['wp_oc'] . '</a></td></tr>';
     }
     $content .= '</table>';
     XDb::xFreeResults($rsms);
 }
 //$total_created_and_owned_caches > 0
 XDb::xFreeResults($rscc2);
 $rs_logs = XDb::xSql("SELECT cache_logs.id, cache_logs.cache_id AS cache_id, cache_logs.type AS log_type,\n                        cache_logs.text AS log_text, DATE_FORMAT(cache_logs.date,'%d-%m-%Y') AS log_date,\n                        caches.name AS cache_name, caches.wp_oc AS wp_name, cache_logs.encrypt AS encrypt,\n                        caches.user_id AS cache_owner, cache_logs.user_id AS luser_id, user.username AS user_name,\n                        user.user_id AS user_id, caches.type AS cache_type, cache_type.icon_small AS cache_icon_small,\n                        log_types.icon_small AS icon_small, IF(ISNULL(`cache_rating`.`cache_id`), 0, 1) AS `recommended`,\n                        COUNT(gk_item.id) AS geokret_in\n                FROM ((cache_logs\n                    INNER JOIN caches ON (caches.cache_id = cache_logs.cache_id)))\n                    INNER JOIN user ON (cache_logs.user_id = user.user_id)\n                    INNER JOIN log_types ON (cache_logs.type = log_types.id)\n                    INNER JOIN cache_type ON (caches.type = cache_type.id)\n                    LEFT JOIN `cache_rating` ON `cache_logs`.`cache_id`=`cache_rating`.`cache_id`\n                        AND `cache_logs`.`user_id`=`cache_rating`.`user_id`\n                    LEFT JOIN gk_item_waypoint ON gk_item_waypoint.wp = caches.wp_oc\n                    LEFT JOIN gk_item ON gk_item.id = gk_item_waypoint.id\n                        AND gk_item.stateid<>1 AND gk_item.stateid<>4 AND gk_item.typeid<>2 AND gk_item.stateid !=5\n                    WHERE (caches.status=1 OR caches.status=2 OR caches.status=3) AND cache_logs.deleted=0 AND `caches`.`user_id`= ?\n                        AND `cache_logs`.`cache_id`=`caches`.`cache_id`\n                        AND `user`.`user_id`=`cache_logs`.`user_id`\n                    GROUP BY cache_logs.id\n                    ORDER BY `cache_logs`.`date_created` DESC\n                    LIMIT 5", $user_id);
 if (XDb::xNumRows($rs_logs) != 0) {
     $content .= '<p>&nbsp;</p><p><span class="content-title-noshade txt-blue08">' . tr('latest_logs_in_caches') . ':</span>&nbsp;&nbsp;<img src="tpl/stdstyle/images/blue/arrow.png" alt="" /> [<a class="links" href="mycaches_logs.php?userid=' . $user_id . '">' . tr('show_all') . '</a>] ';
     if ($user_id == $usr['userid'] || $usr['admin']) {
         $content .= '&nbsp;&nbsp;<a class="links" href="rss/mycaches_logs.xml?userid=' . $user_id . '"><img src=images/rss.gif alt="" /></a>';
     }
     $content .= '</p><br /><div><ul style="margin: -0.9em 0px 0.9em 0px; padding: 0px 0px 0px 10px; list-style-type: none; line-height: 1.6em; font-size: 12px;">';
     while ($record_logs = XDb::xFetchArray($rs_logs)) {
         $tmp_log = $cache_line_my_caches;
         if ($record_logs['geokret_in'] != '0') {
             $tmp_log = mb_ereg_replace('{gkimage}', '<img src="images/gk.png" border="0" alt="" title="GeoKret" />', $tmp_log);
         } else {
             $tmp_log = mb_ereg_replace('{gkimage}', '<img src="images/rating-star-empty.png" border="0" alt=""/>', $tmp_log);
         }
         if ($record_logs['recommended'] == 1 && $record_logs['log_type'] == 1) {
             $tmp_log = mb_ereg_replace('{rateimage}', '<img src="images/rating-star.png" border="0" alt=""/>', $tmp_log);
         } else {
コード例 #6
0
         `PowerTrail`.`image` AS PT_image
      FROM `caches`
         LEFT JOIN `powerTrail_caches` ON `caches`.`cache_id` = `powerTrail_caches`.`cacheId`
         LEFT JOIN `PowerTrail` ON (
             `PowerTrail`.`id` = `powerTrail_caches`.`PowerTrailId`  AND `PowerTrail`.`status` = 1),
             `user`, `cache_type`, `cache_rating`
      WHERE `caches`.`user_id`=`user`.`user_id`
         AND `cache_rating`.`cache_id`=`caches`.`cache_id`
         AND `caches`.`status`=1  AND `caches`.`type` <> 6
         AND `caches`.`type`=`cache_type`.`id`
      GROUP BY `user`.`user_id`, `user`.`username`, `caches`.`cache_id`, `caches`.`name`, `cache_type`.`icon_large`
      ORDER BY `anzahl` DESC, `caches`.`name` ASC
      LIMIT ' . XDb::xEscape($startat) . ',' . XDb::xEscape($perpage));
 $tr_myn_click_to_view_cache = tr('myn_click_to_view_cache');
 $cacheline = '<tr><td>&nbsp;</td><td><span class="content-title-noshade txt-blue08" >{rating_absolute}</span></td><td>{GPicon}</td><td><a class="links" href="viewcache.php?cacheid={cacheid}"><img src="{cacheicon}" class="icon16" alt="' . $tr_myn_click_to_view_cache . '" title="' . $tr_myn_click_to_view_cache . '" /></a></td><td><strong><a class="links" href="viewcache.php?cacheid={cacheid}">{cachename}</a></strong></td><td><strong><a class="links" href="viewprofile.php?userid={userid}">{username}</a></strong></td></tr>';
 if (XDb::xNumRows($rs) == 0) {
     $file_content = '<tr><td colspan="5"><strong>' . tr('recommendation_rating_none') . '</strong></td></tr>';
 } else {
     //powertrail vel geopath variables
     $pt_cache_intro_tr = tr('pt_cache');
     $pt_icon_title_tr = tr('pt139');
     $file_content = '';
     $rows = 0;
     while ($record = XDb::xFetchArray($rs)) {
         $rows++;
         //$cacheicon = 'tpl/stdstyle/images/'.getSmallCacheIcon($record['icon_large']);
         $thisline = $cacheline;
         $thisline = mb_ereg_replace('{cacheid}', urlencode($record['cache_id']), $thisline);
         $thisline = mb_ereg_replace('{cachename}', htmlspecialchars($record['name'], ENT_COMPAT, 'UTF-8'), $thisline);
         // PowerTrail vel GeoPath icon
         if (isset($record['PT_ID'])) {
コード例 #7
0
ファイル: ocxml11.php プロジェクト: kojoty/opencaching-pl
function startXmlSession($sModifiedSince, $bCache, $bCachedesc, $bCachelog, $bUser, $bPicture, $bRemovedObject, $bPictureFromCachelog, $selection)
{
    global $rootpath;
    // session anlegen
    XDb::xSql('INSERT INTO `xmlsession` (`last_use`, `modified_since`, `date_created`)
        VALUES (NOW(), ?, NOW())', date('Y-m-d H:i:s', strtotime($sModifiedSince)));
    $sessionid = XDb::xLastInsertId();
    $recordcount['caches'] = 0;
    $recordcount['cachedescs'] = 0;
    $recordcount['cachelogs'] = 0;
    $recordcount['users'] = 0;
    $recordcount['pictures'] = 0;
    $recordcount['removedobjects'] = 0;
    if ($selection['type'] == 0) {
        // ohne selection
        if ($bCache == 1) {
            $stmt = XDb::xSql("INSERT INTO xmlsession_data (`session_id`, `object_type`, `object_id`)\n                SELECT {$sessionid}, 2, `cache_id` FROM `caches`\n                WHERE `last_modified` >= ? AND `status`!=5 AND `status`!=6 AND `status`!=4", $sModifiedSince);
            $recordcount['caches'] = XDb::xNumRows($stmt);
        }
        if ($bCachedesc == 1) {
            $stmt = XDb::xSql("INSERT INTO `xmlsession_data` (`session_id`, `object_type`, `object_id`)\n                 SELECT {$sessionid}, 3, `cache_desc`.`id`\n                 FROM `cache_desc` INNER JOIN `caches` ON `cache_desc`.`cache_id`=`caches`.`cache_id`\n                 WHERE `cache_desc`.`last_modified` >= ? AND `caches`.`status`!=5\n                    AND `status`!=6 AND `status`!=4", $sModifiedSince);
            $recordcount['cachedescs'] = XDb::xNumRows($stmt);
        }
        if ($bCachelog == 1) {
            $stmt = XDb::xSql("INSERT INTO `xmlsession_data` (`session_id`, `object_type`, `object_id`)\n                 SELECT {$sessionid}, 1, `cache_logs`.`id`\n                 FROM `cache_logs` INNER JOIN `caches` ON `cache_logs`.`cache_id`=`caches`.`cache_id`\n                 WHERE `cache_logs`.`last_modified` >= ? AND `caches`.`status`!=5\n                    AND `status`!=6 AND `status`!=4 AND `cache_logs`.`deleted`=0", $sModifiedSince);
            $recordcount['cachelogs'] = XDb::xNumRows($stmt);
        }
        if ($bUser == 1) {
            $stmt = XDb::xSql("INSERT INTO `xmlsession_data` (`session_id`, `object_type`, `object_id`)\n                 SELECT {$sessionid}, 4, `user_id` FROM `user` WHERE `last_modified` >= ? ", $sModifiedSince);
            $recordcount['users'] = XDb::xNumRows($stmt);
        }
        if ($bPicture == 1) {
            $stmt = XDb::xSql("INSERT INTO `xmlsession_data` (`session_id`, `object_type`, `object_id`)\n                 SELECT {$sessionid}, 6, `pictures`.`id`\n                 FROM `pictures`\n                    INNER JOIN `caches` ON `pictures`.`object_type`=2\n                        AND `pictures`.`object_id`=`caches`.`cache_id`\n                 WHERE `pictures`.`last_modified` >= ?\n                    AND `caches`.`status`!=5 AND `status`!=6 AND `status`!=4\n                 UNION DISTINCT\n                 SELECT {$sessionid}, 6, `pictures`.`id`\n                 FROM `pictures`\n                    INNER JOIN `cache_logs` ON `pictures`.`object_type`=1\n                        AND `pictures`.`object_id`=`cache_logs`.`id`\n                    INNER JOIN `caches` ON `cache_logs`.`cache_id`=`caches`.`cache_id`\n                 WHERE `pictures`.`last_modified` >= ?\n                    AND `caches`.`status`!=5 AND `status`!=6 AND `caches`.`status`!=4\n                    AND `cache_logs`.`deleted`=0", $sModifiedSince, $sModifiedSince);
            $recordcount['pictures'] = XDb::xNumRows($stmt);
        }
        if ($bRemovedObject == 1) {
            $stmt = XDb::xSql("INSERT INTO `xmlsession_data` (`session_id`, `object_type`, `object_id`)\n                 SELECT {$sessionid}, 7, `id` FROM `removed_objects`\n                 WHERE `removed_date` >= ? ", $sModifiedSince);
            $recordcount['removedobjects'] = XDb::xNumRows($stmt);
        }
    } else {
        $qWhere = '';
        $qHaving = '';
        if ($selection['type'] == 1) {
            XDb::xSql("CREATE TEMPORARY TABLE `tmpxmlSesssionCaches` (`cache_id` int(11), PRIMARY KEY (`cache_id`)) ENGINE=MEMORY\n                 SELECT DISTINCT `cache_countries`.`cache_id`\n                 FROM `caches`, `cache_countries`\n                 WHERE `caches`.`cache_id`=`cache_countries`.`cache_id` AND `cache_countries`.`country`= ?\n                    AND `caches`.`status`!=5 AND `status`!=6 AND `status`!=4", $selection['country']);
        } else {
            if ($selection['type'] == 2) {
                require_once $rootpath . 'lib/search.inc.php';
                XDb::xSql('CREATE TEMPORARY TABLE `tmpxmlSesssionCaches` (`cache_id` int(11), `distance` double, KEY (`cache_id`)) ENGINE=MEMORY
                 SELECT `cache_coordinates`.`cache_id`,' . getSqlDistanceFormula($selection['lon'], $selection['lat'], $selection['distance'], 'cache_coordinates') . ' `distance`
                 FROM `caches`, `cache_coordinates`
                 WHERE `cache_coordinates`.`cache_id`=`caches`.`cache_id` AND `caches`.`status`!=5
                     AND `status`!=6 AND `status`!=4
                     AND `cache_coordinates`.`latitude` > ' . getMinLat($selection['lon'], $selection['lat'], $selection['distance']) . '
                     AND `cache_coordinates`.`latitude` < ' . getMaxLat($selection['lon'], $selection['lat'], $selection['distance']) . '
                     AND `cache_coordinates`.`longitude` >' . getMinLon($selection['lon'], $selection['lat'], $selection['distance']) . '
                     AND `cache_coordinates`.`longitude` < ' . getMaxLon($selection['lon'], $selection['lat'], $selection['distance']) . '
                 HAVING `distance` < ' . ($selection['distance'] + 0));
            } else {
                if ($selection['type'] == 3) {
                    XDb::xSql("CREATE TEMPORARY TABLE `tmpxmlSesssionCaches` (`cache_id` int(11), PRIMARY KEY (`cache_id`)) ENGINE=MEMORY\n                 SELECT " . $selection['cacheid'] . " AS cache_id");
                }
            }
        }
        if ($bCache == 1) {
            $stmt = XDb::xSql("INSERT INTO `xmlsession_data` (`session_id`, `object_type`, `object_id`)\n                 SELECT DISTINCT {$sessionid}, 2, `tmpxmlSesssionCaches`.`cache_id`\n                 FROM `tmpxmlSesssionCaches`, `caches`\n                 WHERE `tmpxmlSesssionCaches`.`cache_id`=`caches`.`cache_id`\n                     AND `caches`.`last_modified` >= ? ", $sModifiedSince);
            $recordcount['caches'] = XDb::xNumRows($stmt);
        }
        if ($bCachedesc == 1) {
            $stmt = XDb::xSql("INSERT INTO `xmlsession_data` (`session_id`, `object_type`, `object_id`)\n                 SELECT DISTINCT {$sessionid}, 3, `cache_desc`.`id`\n                 FROM `cache_desc`, `tmpxmlSesssionCaches`\n                 WHERE `cache_desc`.`cache_id`=`tmpxmlSesssionCaches`.`cache_id`\n                     AND `cache_desc`.`last_modified` >= ? ", $sModifiedSince);
            $recordcount['cachedescs'] = XDb::xNumRows($stmt);
        }
        if ($bCachelog == 1) {
            $stmt = XDb::xSql("INSERT INTO `xmlsession_data` (`session_id`, `object_type`, `object_id`)\n                 SELECT DISTINCT {$sessionid}, 1, `cache_logs`.`id`\n                 FROM `cache_logs`, `tmpxmlSesssionCaches`\n                 WHERE `cache_logs`.`deleted`=0\n                     AND `cache_logs`.`cache_id`=`tmpxmlSesssionCaches`.`cache_id`\n                     AND `cache_logs`.`last_modified` >= ? ", $sModifiedSince);
            $recordcount['cachelogs'] = XDb::xNumRows($stmt);
        }
        if ($bPicture == 1) {
            // cachebilder
            $stmt = XDb::xSql("INSERT INTO `xmlsession_data` (`session_id`, `object_type`, `object_id`)\n                 SELECT DISTINCT {$sessionid}, 6, `pictures`.`id`\n                 FROM `pictures`, `tmpxmlSesssionCaches`\n                 WHERE `pictures`.`object_id`=`tmpxmlSesssionCaches`.`cache_id`\n                     AND `pictures`.`object_type`=2\n                     AND `pictures`.`last_modified` >= ? ", $sModifiedSince);
            $recordcount['pictures'] = XDb::xNumRows($stmt);
            // bilder von logs
            if ($bPictureFromCachelog == 1) {
                $stmt = XDb::xSql("INSERT INTO `xmlsession_data` (`session_id`, `object_type`, `object_id`)\n                     SELECT DISTINCT {$sessionid}, 6, `pictures`.id\n                     FROM `pictures` , `cache_logs`, `tmpxmlSesssionCaches`\n                     WHERE `tmpxmlSesssionCaches`.`cache_id`=`cache_logs`.`cache_id`\n                         AND `cache_logs`.`deleted`=0\n                         AND `pictures`.`object_type`=1\n                         AND `pictures`.`object_id`=`cache_logs`.`id`\n                         AND `pictures`.`last_modified` >= ? ", $sModifiedSince);
                $recordcount['pictures'] += XDb::xNumRows($stmt);
            }
        }
        if ($bRemovedObject == 1) {
            $stmt = XDb::xSql("INSERT INTO `xmlsession_data` (`session_id`, `object_type`, `object_id`)\n                 SELECT DISTINCT {$sessionid}, 7, `id`\n                 FROM `removed_objects`\n                 WHERE `removed_date` >= ? ", $sModifiedSince);
            $recordcount['removedobjects'] = XDb::xNumRows($stmt);
        }
    }
    XDb::xSql('UPDATE `xmlsession` SET `caches`= ?, `cachedescs`= ?, `cachelogs`= ?, `users`= ?, `pictures`= ?, `removedobjects`= ?
        WHERE `id`= ? LIMIT 1', $recordcount['caches'], $recordcount['cachedescs'], $recordcount['cachelogs'], $recordcount['users'], $recordcount['pictures'], $recordcount['removedobjects'], $sessionid);
    return $sessionid;
}
コード例 #8
0
     }
     if ($r['topratings'] > 0) {
         $thisextra .= "" . tr('search_gpxgc_06') . ": " . $r['topratings'] . "\n";
     }
     // NPA - nature protection areas
     // Parki Narodowe , Krajobrazowe
     $rsArea = XDb::xSql("SELECT `parkipl`.`id` AS `npaId`, `parkipl`.`name` AS `npaname`,`parkipl`.`link` AS `npalink`,`parkipl`.`logo` AS `npalogo`\n                    FROM `cache_npa_areas`\n                        INNER JOIN `parkipl` ON `cache_npa_areas`.`parki_id`=`parkipl`.`id`\n                    WHERE `cache_npa_areas`.`cache_id`= ? AND `cache_npa_areas`.`parki_id`!='0'", $r['cacheid']);
     if (XDb::xNumRows($rsArea) != 0) {
         $thisextra .= "" . tr('search_gpxgc_07') . ": ";
         while ($npa = XDb::xFetchArray($rsArea)) {
             $thisextra .= $npa['npaname'] . "  ";
         }
     }
     // Natura 2000
     $rsArea = XDb::xSql("SELECT `npa_areas`.`id` AS `npaId`, `npa_areas`.`linkid` AS `linkid`,`npa_areas`.`sitename` AS `npaSitename`, `npa_areas`.`sitecode` AS `npaSitecode`, `npa_areas`.`sitetype` AS `npaSitetype`\n                FROM `cache_npa_areas`\n                INNER JOIN `npa_areas` ON `cache_npa_areas`.`npa_id`=`npa_areas`.`id`\n                WHERE `cache_npa_areas`.`cache_id`= ? AND `cache_npa_areas`.`npa_id`!='0'", $r['cacheid']);
     if (XDb::xNumRows($rsArea) != 0) {
         $thisextra .= "\nNATURA 2000: ";
         while ($npa = XDb::xFetchArray($rsArea)) {
             $thisextra .= " - " . $npa['npaSitename'] . "  " . $npa['npaSitecode'] . " - ";
         }
     }
 }
 $thisline = str_replace('{extra_info}', $thisextra, $thisline);
 // end of extra info
 if ($r['rr_comment'] == '') {
     $thisline = str_replace('{rr_comment}', '', $thisline);
 } else {
     $thisline = str_replace('{rr_comment}', cleanup_text("<br /><br />--------<br />" . $r['rr_comment'] . "<br />"), $thisline);
 }
 $thisline = str_replace('{{images}}', getPictures($r['cacheid'], false, $r['picturescount']), $thisline);
 if (isset($gpxType[$r['type']])) {
コード例 #9
0
use Utils\Database\XDb;
global $lang, $rootpath;
$lang = 'en';
if (!isset($rootpath)) {
    $rootpath = '../';
}
//include template handling
require_once $rootpath . 'lib/common.inc.php';
require_once $rootpath . 'lib/cache_icon.inc.php';
$rs = XDb::xSql(" SELECT latitude, longitude, date_created FROM caches ORDER BY `date_created`");
$im = imagecreatefromjpeg("mapa.jpg");
$blue = imagecolorallocate($im, 0, 0, 255);
$green = imagecolorallocate($im, 0, 255, 0);
$l = 0;
$no_users = XDb::xNumRows($rs);
for ($i = 0; $i < $no_users; $i++) {
    $record = XDb::xFetchArray($rs);
    $long = $record['longitude'];
    $lat = $record['latitude'];
    $pt = latlon_to_pix($lat, $long);
    imagefilledellipse($im, $pt["x"], $pt["y"], 2, 2, $blue);
    // Now mark the point on the map using a red 4 pixel rectangle
    if ($i % 5 == 0) {
        // Write the string at the top left
        imagefilledrectangle($im, 0, 0, 90, 14, $green);
        imagestring($im, 5, 0, 0, substr($record['date_created'], 0, 10), $blue);
        imagejpeg($im, "pics/mapa-new-" . $l . ".jpg", 80);
        $l++;
    }
}
コード例 #10
0
 $searchfor = mb_trim($searchfor);
 $target = mb_strtolower(mb_substr($searchfor, 0, 2));
 if (mb_substr($target, 0, 1) == 'n') {
     $target = 'nc';
 }
 if (mb_ereg_match('([a-f0-9]){4,4}$', mb_strtolower($searchfor))) {
     $target = $ocWP;
     $searchfor = $target . '' . $searchfor;
 }
 if (($target == 'oc' || $target == $ocWP || $target == 'nc' || $target == 'gc') && mb_ereg_match('((' . $ocWP . '|oc)([a-z0-9]){4,4}|gc([a-z0-9]){4,5}|n([a-f0-9]){5,5})$', mb_strtolower($searchfor))) {
     // get cache_id from DB
     if ($target == $ocWP) {
         $target = 'oc';
     }
     $rs = XDb::xSql("SELECT `cache_id`, `latitude`, `longitude` FROM `caches`\n                        WHERE `wp_" . XDb::xEscape($target) . "`= ? ", $searchfor);
     $count = XDb::xNumRows($rs);
     if ($count == 1) {
         $record = XDb::xFetchArray($rs);
         if (isset($_POST['namapie'])) {
             $targeturl = 'cachemap2.php?lat=' . $record['latitude'] . '&lon=' . $record['longitude'] . '&cacheid=' . $record['cache_id'];
         } else {
             $targeturl = 'viewcache.php?cacheid=' . $record['cache_id'];
         }
         unset($record);
     } else {
         if ($count == 0) {
             $tplname = 'searchplugin';
             tpl_set_var('error_msg', mb_ereg_replace('{wp}', $searchfor, $errmsg_no_cache_found));
             tpl_BuildTemplate();
             exit;
         } else {
コード例 #11
0
ファイル: chowner.php プロジェクト: kojoty/opencaching-pl
     }
     tpl_set_var('acceptList', $acceptList);
 }
 //user for adoption is selected
 if (isset($_POST['username'])) {
     $newUserId = doesUserExist($_POST['username']);
     if ($newUserId > 0) {
         // check if selected user not own this cache...
         $ownerId = getCacheOwner($_REQUEST['cacheid']);
         if ($ownerId == $newUserId) {
             tpl_set_var('error_msg', tr('adopt_33') . '<br /><br />');
         } else {
             // uzytkownik istnieje, mozna kontynuowac procedure
             $q = "INSERT INTO chowner (cache_id, user_id) VALUES ( ?, ?)";
             $stmt = XDb::xSql($q, $_REQUEST['cacheid'], $newUserId);
             if (XDb::xNumRows($stmt) > 0) {
                 tpl_set_var('info_msg', ' ' . tr('adopt_24') . ' <br /><br />');
                 $mailContent = tr('adopt_26');
                 $mailContent = str_replace('\\n', "\n", $mailContent);
                 $mailContent = str_replace('{userName}', $usr['username'], $mailContent);
                 $mailContent = str_replace('{cacheName}', getCacheName($_REQUEST['cacheid']), $mailContent);
                 mb_send_mail_2(getUserEmail($newUserId), tr('adopt_25'), $mailContent, emailHeaders());
             } else {
                 tpl_set_var('error_msg', tr('adopt_22') . '<br /><br />');
             }
         }
     } else {
         $message = tr('adopt_23');
         $message = str_replace('{userName}', $_POST['username'], $message);
         tpl_set_var('error_msg', $message . '<br /><br />');
     }
コード例 #12
0
ファイル: printcache.php プロジェクト: kojoty/opencaching-pl
        $showlogs = $_POST['showlogs'];
        $pictures = $_POST['showpictures'];
        $nocrypt = $_POST['nocrypt'];
        $spoiler_only = $_POST['spoiler_only'];
    } else {
        $showlogs = "";
        $pictures = "&pictures=no";
        $nocrypt = "";
        $spoiler_only = "";
    }
}
if (isset($_GET['source']) && $_GET['source'] == 'mywatches') {
    $rs = XDb::xSql("SELECT `cache_watches`.`cache_id` AS `cache_id`\n                         FROM `cache_watches` WHERE `cache_watches`.`user_id`= ? ", $usr['userid']);
    if (XDb::xNumRows($rs) > 0) {
        $caches_list = array();
        for ($i = 0; $i < XDb::xNumRows($rs); $i++) {
            $record = XDb::xFetchArray($rs);
            $caches_list[] = $record['cache_id'];
        }
    }
} else {
    if ($cache_id) {
        $caches_list = array();
        $caches_list[] = $cache_id;
    } else {
        $caches_list = $_SESSION['print_list'];
    }
}
/* $caches_list = array();
      $nr = 0;
      for( $i=1000;$i<2000;$i+=200)
コード例 #13
0
<?php

use Utils\Database\XDb;
//prepare the templates and include all neccessary
require_once './lib/common.inc.php';
//Preprocessing
if ($error == false) {
    $target = isset($_REQUEST['target']) ? $_REQUEST['target'] : 'myignores.php';
    $cache_id = isset($_REQUEST['cacheid']) ? $_REQUEST['cacheid'] : '';
    if ($usr['userid']) {
        //remove watch
        XDb::xSql('DELETE FROM cache_ignore
                   WHERE cache_id=\'' . XDb::xEscape($cache_id) . '\'
                        AND user_id=\'' . XDb::xEscape($usr['userid']) . '\'');
        //remove from caches
        $rs = XDb::xSql('SELECT ignorer_count FROM caches
                         WHERE cache_id=\'' . XDb::xEscape($cache_id) . '\'');
        if (XDb::xNumRows($rs) > 0) {
            $record = XDb::xFetchArray($rs);
            XDb::xSql('UPDATE caches SET ignorer_count=\'' . ($record['ignorer_count'] - 1) . '\'
                       WHERE cache_id=\'' . XDb::xEscape($cache_id) . '\'');
            //remove from user
            $rs = XDb::xSql('SELECT cache_ignores FROM user WHERE user_id=\'' . XDb::xEscape($usr['userid']) . '\'');
            $record = XDb::xFetchArray($rs);
            XDb::xSql('UPDATE user SET cache_ignores=\'' . ($record['cache_ignores'] - 1) . '\'
                       WHERE user_id=\'' . XDb::xEscape($usr['userid']) . '\'');
        }
    }
    tpl_redirect($target);
}
tpl_BuildTemplate();
コード例 #14
0
ファイル: newest.php プロジェクト: kojoty/opencaching-pl
<?php

use Utils\Database\XDb;
require_once "./lib/common.inc.php";
$query = "select date_hidden, name,  latitude, longitude, wp_oc, user_id, type from caches where status='1' and date_hidden<now() order by date_hidden desc limit 10";
$wynik = XDb::xSql($query);
$ile = XDb::xNumRows($wynik);
$tpl->assign("ile", $ile);
$znalezione = array();
$lista = array();
$tpl->assign("address", "viewcache");
while ($rekord = XDb::xFetchArray($wynik)) {
    $query = "select username from user where user_id = " . $rekord['user_id'] . ";";
    $wynik2 = XDb::xSql($query);
    $wiersz = XDb::xFetchArray($wynik2);
    $query = "select " . $lang . " from cache_type where id = " . $rekord['type'] . ";";
    $wynik2 = XDb::xSql($query);
    $wiersz2 = XDb::xFetchArray($wynik2);
    $rekord['username'] = $wiersz['username'];
    $rekord['date_hidden'] = date("d-m-Y", strtotime($rekord['date_hidden']));
    $rekord['N'] = cords($rekord['latitude']);
    $rekord['E'] = cords($rekord['longitude']);
    $rekord['typetext'] = $wiersz2[0];
    $lista[] = $rekord['wp_oc'];
    $znalezione[] = $rekord;
}
$tpl->assign('lista', $lista);
$tpl->assign("max", 1);
$tpl->assign("znalezione", $znalezione);
$tpl->display('./tpl/find2.tpl');
コード例 #15
0
ファイル: editcache.php プロジェクト: kojoty/opencaching-pl
     tpl_set_var('hidemp3_start', '<!--');
     tpl_set_var('hidemp3_end', '-->');
 }
 //Add Waypoint
 if (checkField('waypoint_type', $lang)) {
     $lang_db = $lang;
 } else {
     $lang_db = "en";
 }
 $cache_type = $cache_record['type'];
 if ($cache_type != GeoCache::TYPE_MOVING) {
     tpl_set_var('waypoints_start', '');
     tpl_set_var('waypoints_end', '');
     $eLang = XDb::xEscape($lang);
     $wp_rs = XDb::xSql("SELECT `wp_id`, `type`, `longitude`, `latitude`,  `desc`, `status`, `stage`,\n                                `waypoint_type`.`{$eLang}` wp_type, waypoint_type.icon wp_icon\n                         FROM `waypoints` INNER JOIN waypoint_type ON (waypoints.type = waypoint_type.id)\n                         WHERE `cache_id`=? ORDER BY `stage`,`wp_id`", $cache_id);
     if (XDb::xNumRows($wp_rs) != 0) {
         $waypoints = '<table id="gradient" cellpadding="5" width="97%" border="1" style="border-collapse: collapse; font-size: 11px; line-height: 1.6em; color: #000000; ">';
         $waypoints .= '<tr>';
         if ($cache_type == GeoCache::TYPE_OTHERTYPE || $cache_type == GeoCache::TYPE_MULTICACHE || $cache_type == GeoCache::TYPE_QUIZ) {
             $waypoints .= '<th align="center" valign="middle" width="30"><b>' . tr('stage_wp') . '</b></th>';
         }
         $waypoints .= '<th width="32"><b>' . tr('symbol_wp') . '</b></th><th width="32"><b>' . tr('type_wp') . '</b></th><th width="32"><b>' . tr('coordinates_wp') . '</b></th><th><b>' . tr('describe_wp') . '</b></th><th width="22"><b>' . tr('status_wp') . '</b></th><th width="22"><b>' . tr('edit') . '</b></th><th width="22"><b>' . tr('delete') . '</b></th></tr>';
         while ($wp_record = XDb::xFetchArray($wp_rs)) {
             $tmpline1 = $wpline;
             $coords_lat = mb_ereg_replace(" ", "&nbsp;", htmlspecialchars(help_latToDegreeStr($wp_record['latitude']), ENT_COMPAT, 'UTF-8'));
             $coords_lon = mb_ereg_replace(" ", "&nbsp;", htmlspecialchars(help_lonToDegreeStr($wp_record['longitude']), ENT_COMPAT, 'UTF-8'));
             $tmpline1 = mb_ereg_replace('{wp_icon}', htmlspecialchars($wp_record['wp_icon'], ENT_COMPAT, 'UTF-8'), $tmpline1);
             $tmpline1 = mb_ereg_replace('{type}', htmlspecialchars($wp_record['wp_type'], ENT_COMPAT, 'UTF-8'), $tmpline1);
             $tmpline1 = mb_ereg_replace('{lon}', $coords_lon, $tmpline1);
             $tmpline1 = mb_ereg_replace('{lat}', $coords_lat, $tmpline1);
             $tmpline1 = mb_ereg_replace('{desc}', nl2br($wp_record['desc']), $tmpline1);
コード例 #16
0
ファイル: search.php プロジェクト: kojoty/opencaching-pl
function outputLocidSelectionForm($locSql, $urlparams)
{
    global $tplname, $locline, $stylepath, $bgcolor1, $bgcolor2;
    require_once $stylepath . '/selectlocid.inc.php';
    unset($urlparams['queryid']);
    unset($urlparams['locid']);
    $urlparams['searchto'] = 'search' . $urlparams['searchtype'];
    unset($urlparams['searchtype']);
    $tplname = 'selectlocid';
    // urlparams zusammenbauen
    $urlparamString = '';
    foreach ($urlparams as $name => $param) {
        // workaround for attribs
        if (is_array($param)) {
            $pnew = '';
            foreach ($param as $p) {
                if ($pnew != '') {
                    $pnew .= ';' . $p;
                } else {
                    $pnew .= $p;
                }
            }
            $param = $pnew;
        }
        if ($urlparamString != '') {
            $urlparamString .= '&' . $name . '=' . urlencode($param);
        } else {
            $urlparamString = $name . '=' . urlencode($param);
        }
    }
    $urlparamString .= '&locid={locid}';
    XDb::xSql('CREATE TEMPORARY TABLE `locids` ENGINE=MEMORY ' . $locSql);
    XDb::xSql('ALTER TABLE `locids` ADD PRIMARY KEY (`loc_id`)');
    $rs = XDb::xSql('SELECT `geodb_textdata`.`loc_id` `loc_id`, `geodb_textdata`.`text_val` `text_val` FROM `geodb_textdata`, `locids` WHERE `locids`.`loc_id`=`geodb_textdata`.`loc_id` AND `geodb_textdata`.`text_type`=500100000 ORDER BY `text_val`');
    $nr = 1;
    $locations = '';
    while ($r = XDb::xFetchArray($rs)) {
        $thislocation = $locline;
        // locationsdings zusammenbauen
        $locString = '';
        $land = landFromLocid($r['loc_id']);
        if ($land != '') {
            $locString .= htmlspecialchars($land, ENT_COMPAT, 'UTF-8');
        }
        $rb = regierungsbezirkFromLocid($r['loc_id']);
        if ($rb != '') {
            $locString .= ' &gt; ' . htmlspecialchars($rb, ENT_COMPAT, 'UTF-8');
        }
        $lk = landkreisFromLocid($r['loc_id']);
        if ($lk != '') {
            $locString .= ' &gt; ' . htmlspecialchars($lk, ENT_COMPAT, 'UTF-8');
        }
        $thislocation = mb_ereg_replace('{parentlocations}', $locString, $thislocation);
        // koordinaten ermitteln
        $r['loc_id'] = $r['loc_id'] + 0;
        $rsCoords = XDb::xSql('SELECT `lon`, `lat` FROM `geodb_coordinates` WHERE loc_id=' . $r['loc_id'] . ' LIMIT 1');
        if ($rCoords = XDb::xFetchArray($rsCoords)) {
            $coordString = help_latToDegreeStr($rCoords['lat']) . ' ' . help_lonToDegreeStr($rCoords['lon']);
        } else {
            $coordString = '[keine Koordinaten vorhanden]';
        }
        $thislocation = mb_ereg_replace('{coords}', htmlspecialchars($coordString, ENT_COMPAT, 'UTF-8'), $thislocation);
        $thislocation = mb_ereg_replace('{locationname}', htmlspecialchars($r['text_val'], ENT_COMPAT, 'UTF-8'), $thislocation);
        $thislocation = mb_ereg_replace('{urlparams}', $urlparamString, $thislocation);
        $thislocation = mb_ereg_replace('{locid}', urlencode($r['loc_id']), $thislocation);
        $thislocation = mb_ereg_replace('{nr}', $nr, $thislocation);
        $thislocation = mb_ereg_replace('{secondlocationname}', '', $thislocation);
        if ($nr % 2) {
            $thislocation = mb_ereg_replace('{bgcolor}', $bgcolor1, $thislocation);
        } else {
            $thislocation = mb_ereg_replace('{bgcolor}', $bgcolor2, $thislocation);
        }
        $nr++;
        $locations .= $thislocation . "\n";
    }
    tpl_set_var('locations', $locations);
    tpl_set_var('resultscount', XDb::xNumRows($rs));
    tpl_set_var('pages', $first_img_inactive . ' ' . $prev_img_inactive . ' 1 ' . $next_img_inactive . ' ' . $last_img_inactive);
    tpl_BuildTemplate();
    exit;
}