예제 #1
0
function viewqueries()
{
    global $tplname, $usr;
    global $viewquery_line, $noqueries, $bgcolor1, $bgcolor2;
    $tplname = 'viewqueries';
    $dbc = new dataBase();
    $i = 0;
    $content = '';
    //$rs = sql("SELECT `id`, `name` FROM `queries` WHERE `user_id`='&1' ORDER BY `name` ASC", $usr['userid']);
    $query = "SELECT id, name FROM `queries` WHERE `user_id`=:1 ORDER BY `name` ASC";
    $dbc->multiVariableQuery($query, $usr['userid']);
    if ($dbc->rowCount() != 0) {
        //while ($r = sql_fetch_array($rs))
        while ($r = $dbc->dbResultFetch()) {
            $thisline = $viewquery_line;
            $thisline = mb_ereg_replace('{queryname}', htmlspecialchars($r['name'], ENT_COMPAT, 'UTF-8'), $thisline);
            $thisline = mb_ereg_replace('{queryid}', htmlspecialchars($r['id'], ENT_COMPAT, 'UTF-8'), $thisline);
            if ($i % 2 == 1) {
                $thisline = mb_ereg_replace('{bgcolor}', $bgcolor2, $thisline);
            } else {
                $thisline = mb_ereg_replace('{bgcolor}', $bgcolor1, $thisline);
            }
            $content .= $thisline;
            $i++;
        }
        //mysql_free_result($rs);
    } else {
        $content = $noqueries;
    }
    unset($dbc);
    tpl_set_var('queries', $content);
    tpl_BuildTemplate();
    exit;
}
 function run()
 {
     $db = new dataBase();
     $db->switchDebug(false);
     $sql = "SELECT user_id FROM user where user_id >= 0 ";
     $params = array();
     if (isset($_GET['user_id'])) {
         $sql .= ' and user_id=:user_id';
         $params['user_id']['value'] = intval($_GET['user_id']);
         $params['user_id']['data_type'] = 'integer';
     }
     $db->paramQuery($sql, $params);
     $users = $db->dbResultFetchAll();
     set_time_limit(3600);
     $total_touched = 0;
     foreach ($users as $user) {
         $user_id = $user['user_id'];
         // repair founds
         $founds_count = $db->multiVariableQueryValue("SELECT count(id) FROM cache_logs WHERE deleted=0 AND user_id = :1 AND type=1", 0, $user_id);
         $notfounds_count = $db->multiVariableQueryValue("SELECT count(id) FROM cache_logs WHERE deleted=0 AND user_id = :1 AND type=2", 0, $user_id);
         $log_notes_count = $db->multiVariableQueryValue("SELECT count(id) FROM cache_logs WHERE deleted=0 AND user_id = :1 AND type=3", 0, $user_id);
         $cache_watches = $db->multiVariableQueryValue("SELECT count(id) FROM cache_watches WHERE user_id = :1", 0, $user_id);
         $cache_ignores = $db->multiVariableQueryValue("SELECT count(id) FROM cache_ignore WHERE user_id = :1", 0, $user_id);
         $hidden_count = $db->multiVariableQueryValue("select count(cache_id) from caches where status in (1,2,3) and user_id = :1", 0, $user_id);
         $sql = "\n                UPDATE user\n                SET\n                    hidden_count=:new_hidden_count,\n                    cache_ignores=:new_cache_ignores,\n                    log_notes_count=:new_log_notes_count,\n                    founds_count=:new_founds_count,\n                    notfounds_count=:new_notfounds_count,\n                    cache_watches=:new_cache_watches\n                WHERE\n                    user_id=:user_id\n                    AND (\n                        hidden_count is null\n                        OR cache_ignores is null\n                        OR log_notes_count is null\n                        OR founds_count is null\n                        OR notfounds_count is null\n                        OR cache_watches is null\n                        OR hidden_count!=:new_hidden_count\n                        OR cache_ignores!=:new_cache_ignores\n                        OR log_notes_count!=:new_log_notes_count\n                        OR founds_count!=:new_founds_count\n                        OR notfounds_count!=:new_notfounds_count\n                        OR cache_watches!=:new_cache_watches\n                    )\n            ";
         $params = array();
         $params['new_hidden_count']['value'] = intval($hidden_count);
         $params['new_hidden_count']['data_type'] = 'integer';
         $params['new_cache_ignores']['value'] = intval($cache_ignores);
         $params['new_cache_ignores']['data_type'] = 'integer';
         $params['new_log_notes_count']['value'] = intval($log_notes_count);
         $params['new_log_notes_count']['data_type'] = 'integer';
         $params['new_founds_count']['value'] = intval($founds_count);
         $params['new_founds_count']['data_type'] = 'integer';
         $params['new_notfounds_count']['value'] = intval($notfounds_count);
         $params['new_notfounds_count']['data_type'] = 'integer';
         $params['new_cache_watches']['value'] = intval($cache_watches);
         $params['new_cache_watches']['data_type'] = 'integer';
         $params['user_id']['value'] = intval($user_id);
         $params['user_id']['data_type'] = 'integer';
         $db->paramQuery($sql, $params);
         if ($db->rowCount() > 0) {
             echo "<b>user_id={$user_id}</b><br>";
             echo "hidden_count={$hidden_count}<br>cache_ignores={$cache_ignores}<br>";
             echo "log_notes_count={$log_notes_count}<br>founds_count={$founds_count}<br>";
             echo "notfounds_count={$notfounds_count}<br>cache_watches={$cache_watches}<br>";
             $total_touched++;
         }
         $db->closeCursor();
     }
     set_time_limit(60);
     unset($db);
     echo "-----------------------------------<br>total_touched={$total_touched}<br>";
 }
 function run()
 {
     $db = new dataBase();
     $db->switchDebug(false);
     $sql = "delete from CACHE_ACCESS_LOGS where date_sub(now(), INTERVAL 5 DAY) > event_date";
     set_time_limit(360);
     $db->simpleQuery($sql);
     $total_deleted = $db->rowCount();
     set_time_limit(60);
     unset($db);
     echo "total_deleted={$total_deleted}\n";
 }
예제 #4
0
     tpl_set_var('def_seq', 1);
     //set default sequence to 1 for add picture link (in case there is no picture att all yet))
     tpl_set_var('pictures', $nopictures);
 }
 //MP3 files only for type of cache:
 if ($cache_record['type'] == GeoCache::TYPE_OTHERTYPE || $cache_record['type'] == GeoCache::TYPE_MULTICACHE || $cache_record['type'] == GeoCache::TYPE_QUIZ) {
     if ($cache_record['mp3count'] > 0) {
         $mp3files = '';
         $thatquery = "SELECT `id`, `url`, `title`, `uuid`, `seq` FROM `mp3` WHERE `object_id`=:v1 AND `object_type`=2 ORDER BY seq, date_created";
         $params['v1']['value'] = (int) $cache_id;
         $params['v1']['data_type'] = 'integer';
         if (!isset($dbc)) {
             $dbc = new dataBase();
         }
         $dbc->paramQuery($thatquery, $params);
         $mp3_count = $dbc->rowCount();
         $mp3_all = $dbc->dbResultFetchAll();
         $thatquery = "SELECT `seq` FROM `mp3` WHERE `object_id`=:v1 AND `object_type`=2 ORDER BY `seq` DESC";
         //get highest seq number for this cache
         $dbc->paramQuery($thatquery, $params);
         //params are same as a few lines above
         $max_seq_record = $dbc->dbResultFetch();
         unset($params);
         //clear to avoid overlaping on next paramQuery (if any))
         $max_seq_number = isset($max_seq_record['seq']) ? $max_seq_record['seq'] : 0;
         if ($max_seq_number < $mp3_count) {
             $max_seq_number = $mp3_count;
         }
         tpl_set_var('def_seq_m', $max_seq_number + 1);
         // set default seq for mp3 to be added (if link is click) - this line updated link to newmp3.php)  )
         for ($i = 0; $i < $mp3_count; $i++) {
예제 #5
0
     $username = "******";
     $notop5 = $user_notfound;
 }
 $i = 0;
 $content = '';
 /* $rs = sql("   SELECT `cache_rating`.`cache_id` AS `cache_id`, `caches`.`name` AS `cachename`,
    `user`.`username` AS `ownername`, `user`.`user_id` AS `owner_id`
    FROM `cache_rating`, `caches`, `user`
    WHERE `cache_rating`.`cache_id` = `caches`.`cache_id`
    AND `caches`.`user_id`=`user`.`user_id`
    AND `cache_rating`.`user_id`='&1' ORDER BY `caches`.`name` ASC", $userid); */
 $query = "SELECT `cache_rating`.`cache_id` AS `cache_id`, `caches`.`name` AS `cachename`,\n                `user`.`username` AS `ownername`, `user`.`user_id` AS `owner_id`\n                FROM `cache_rating`, `caches`, `user`\n                WHERE `cache_rating`.`cache_id` = `caches`.`cache_id`\n                  AND `caches`.`user_id`=`user`.`user_id`\n                  AND `cache_rating`.`user_id`= :1 ORDER BY `caches`.`name` ASC";
 $dbc = new dataBase();
 $dbc->multiVariableQuery($query, $userid);
 //if (mysql_num_rows($rs) != 0)
 if ($dbc->rowCount() != 0) {
     //          while ($r = sql_fetch_array($rs))
     while ($r = $dbc->dbResultFetch()) {
         $thisline = $viewtop5_line;
         $thisline = mb_ereg_replace('{cachename}', htmlspecialchars($r['cachename'], ENT_COMPAT, 'UTF-8'), $thisline);
         $thisline = mb_ereg_replace('{cacheid}', htmlspecialchars($r['cache_id'], ENT_COMPAT, 'UTF-8'), $thisline);
         $thisline = mb_ereg_replace('{ownername}', htmlspecialchars($r['ownername'], ENT_COMPAT, 'UTF-8'), $thisline);
         $thisline = mb_ereg_replace('{owner_id}', htmlspecialchars($r['owner_id'], ENT_COMPAT, 'UTF-8'), $thisline);
         if ($i % 2 == 1) {
             $thisline = mb_ereg_replace('{bgcolor}', $bgcolor2, $thisline);
         } else {
             $thisline = mb_ereg_replace('{bgcolor}', $bgcolor1, $thisline);
         }
         $content .= $thisline;
         $i++;
     }
        $log_id = intval($_REQUEST['logid']);
    }
    //user logged in?
    if ($usr == false) {
        tpl_redirect('login.php');
    } else {
        if (!isset($_REQUEST["logid"]) or !isset($_REQUEST["target"]) or !isset($_REQUEST["cacheid"]) or !isset($_REQUEST["posY"])) {
            tpl_redirect("index.php");
        } else {
            $nLogId = $_REQUEST["logid"];
            $sTarget = $_REQUEST["target"];
            $sCacheId = $_REQUEST["cacheid"];
            $nPosY = $_REQUEST["posY"];
            $query = "SELECT 1 FROM log_rating WHERE log_id =:1 and user_id=:2";
            $dbc = new dataBase();
            $dbc->multiVariableQuery($query, $nLogId, $usr["userid"]);
            if ($dbc->rowCount() == 0) {
                //add
                $cDT = new DateTime();
                $currDate = $cDT->format('Y-m-d H:m:s');
                $query = "INSERT INTO log_rating (log_id, user_id, date) VALUES( :1, :2, :3 )";
                $dbc->multiVariableQuery($query, $nLogId, $usr["userid"], $currDate);
            } else {
                $query = "DELETE FROM log_rating WHERE log_id =:1 and user_id=:2";
                $dbc->multiVariableQuery($query, $nLogId, $usr["userid"]);
            }
        }
    }
    $sTarget .= "?cacheid=" . $sCacheId . "&posY=" . $nPosY;
    tpl_redirect($sTarget);
}
예제 #7
0
     if ($page_number == $start) {
         $pages .= "<b>{$i}</b> ";
     } else {
         $pages .= "<a href='newlogs.php?start={$page_number}'>{$i}</a> ";
     }
 }
 if ($total_pages > $PAGES_LISTED) {
     $pages .= '<a href="newlogs.php?start=' . ($start + $LOGS_PER_PAGE) . '">{next_img}</a> ';
     $pages .= '<a href="newlogs.php?start=' . ($i - 1) * $LOGS_PER_PAGE . '">{last_img}</a> ';
 } else {
     $pages .= ' {next_img_inactive} {last_img_inactive}';
 }
 $rsQuery = "SELECT `cache_logs`.`id` FROM `cache_logs` USE INDEX(date_created), `caches`\n            WHERE `cache_logs`.`cache_id`=`caches`.`cache_id`\n            AND `cache_logs`.`deleted`=0\n            AND `caches`.`status` IN (1, 2, 3)\n            ORDER BY  `cache_logs`.`date_created` DESC\n            LIMIT :variable1, :variable2 ";
 $db->paramQuery($rsQuery, array('variable1' => array('value' => intval($start), 'data_type' => 'integer'), 'variable2' => array('value' => intval($LOGS_PER_PAGE), 'data_type' => 'integer')));
 $log_ids = '';
 if ($db->rowCount() == 0) {
     $log_ids = '0';
 }
 //powertrail vel geopath variables
 $pt_cache_intro_tr = tr('pt_cache');
 $pt_icon_title_tr = tr('pt139');
 for ($i = 0; $i < $db->rowCount(); $i++) {
     $record = $db->dbResultFetch();
     if ($i > 0) {
         $log_ids .= ', ' . $record['id'];
     } else {
         $log_ids = $record['id'];
     }
 }
 $rsQuery = "SELECT cache_logs.id, cache_logs.cache_id AS cache_id,\n                  cache_logs.type AS log_type,\n                  cache_logs.date AS log_date,\n                 `cache_logs`.`encrypt` `encrypt`,\n                  cache_logs.user_id AS luser_id,\n                  cache_logs.text AS log_text,\n                  cache_logs.text_html AS text_html,\n                  caches.name AS cache_name,\n                  caches.user_id AS cache_owner,\n                  user.username AS user_name,\n                  caches.user_id AS user_id,\n                  user.user_id AS xuser_id,\n                  caches.wp_oc AS wp_name,\n                  caches.type AS cache_type,\n                  cache_type.icon_small AS cache_icon_small,\n                  log_types.icon_small AS icon_small,\n                  log_types.pl as pl,\n                  IF(ISNULL(`cache_rating`.`cache_id`), 0, 1) AS `recommended`,\n                  COUNT(gk_item.id) AS geokret_in,\n                 `PowerTrail`.`id` AS PT_ID,\n                 `PowerTrail`.`name` AS PT_name,\n                 `PowerTrail`.`type` As PT_type,\n                 `PowerTrail`.`image` AS PT_image\n                  FROM (cache_logs INNER JOIN caches ON (caches.cache_id = cache_logs.cache_id)) INNER JOIN user ON (cache_logs.user_id = user.user_id) INNER JOIN log_types ON (cache_logs.type = log_types.id) INNER JOIN cache_type ON (caches.type = cache_type.id) LEFT JOIN `cache_rating` ON `cache_logs`.`cache_id`=`cache_rating`.`cache_id` 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 AND\n\n                  gk_item.stateid<>1 AND gk_item.stateid<>4 AND gk_item.typeid<>2 AND gk_item.stateid !=5\n                  LEFT JOIN `powerTrail_caches` ON cache_logs.cache_id = `powerTrail_caches`.`cacheId`\n                  LEFT JOIN `PowerTrail` ON `PowerTrail`.`id` = `powerTrail_caches`.`PowerTrailId`  AND `PowerTrail`.`status` = 1\n                  WHERE cache_logs.deleted=0 AND cache_logs.id IN ({$log_ids}) AND cache_logs.cache_id=caches.cache_id AND caches.status<> 4 AND caches.status<> 5 AND caches.status<> 6\n                  GROUP BY cache_logs.id\n                  ORDER BY cache_logs.date_created DESC";
 $file_content = '';
예제 #8
0
     $note_id = $_REQUEST["delete"];
     //remove
     $query = "DELETE FROM `cache_notes` WHERE `note_id`=:1 AND `user_id`=:2";
     $db->multiVariableQuery($query, $note_id, $userid);
 }
 if (isset($_REQUEST["delete_coords"])) {
     $coords_id = $_REQUEST["delete_coords"];
     //remove
     $query = "DELETE FROM `cache_mod_cords` WHERE `id`=:1 AND `user_id`=:2";
     $db->multiVariableQuery($query, $coords_id, $userid);
 }
 //$notes_rs = sql("SELECT `cache_notes`.`cache_id` `cacheid`, `caches`.`name` `cache_name`, `cache_type`.`icon_small` `icon_large` FROM `cache_notes` INNER JOIN caches ON (`caches`.`cache_id` = `cache_notes`.`cache_id`), `cache_type`  WHERE `cache_notes`.`user_id`=&1 AND `cache_type`.`id`=`caches`.`type` GROUP BY `cacheid` ORDER BY `cacheid`,`date` DESC",$userid);
 $query = "\n                            SELECT `cache_notes`.`cache_id` `cacheid`,\n                                `cache_notes`.`desc` `notes_desc`,\n                                `caches`.`name` `cache_name`,\n                                `cache_type`.`icon_small` `icon_large`,\n                                `caches`.`type` `cache_type`,\n                                `caches`.`cache_id` `cache_id`,\n                                `caches`.`user_id` `user_id`,\n                                note_id,\n                                cl.text AS log_text,\n                                cl.type AS log_type,\n                                cl.user_id AS luser_id,\n                                cl.date AS log_date,\n                                cl.deleted AS log_deleted,\n                                log_types.icon_small AS icon_small,\n                                user.username AS user_name,\n                                cache_mod_cords.id as cache_mod_cords_id,\n                                cache_mod_cords.longitude,\n                                cache_mod_cords.latitude\n                            FROM\n                                `cache_notes`\n                                INNER JOIN `caches` ON (`cache_notes`.`cache_id`=`caches`.`cache_id`)\n                                INNER JOIN cache_type ON (caches.type = cache_type.id)\n                                left outer JOIN cache_logs as cl ON (caches.cache_id = cl.cache_id)\n                                left outer JOIN log_types ON (cl.type = log_types.id)\n                                left outer JOIN user ON (cl.user_id = user.user_id)\n                                left outer JOIN cache_mod_cords ON (\n                                        cache_mod_cords.user_id = cache_notes.user_id\n                                        AND cache_mod_cords.cache_id = cache_notes.cache_id\n                                    )\n                            WHERE\n                                `cache_notes`.`user_id`=:1\n                                AND `cache_type`.`id`=`caches`.`type`\n                                AND\n                                    ( cl.id is null or cl.id =\n                                    ( SELECT id\n                                        FROM cache_logs cl_id\n                                        WHERE cl.cache_id = cl_id.cache_id and cl_id.date =\n\n                                            ( SELECT max( cache_logs.date )\n                                                FROM cache_logs\n                                                WHERE cl.cache_id = cache_id\n                                            )\n                                            limit 1\n                                        ))\n                            GROUP BY `cacheid`\n                            UNION\n                            SELECT `cache_mod_cords`.`cache_id` `cacheid`,\n                                `cache_notes`.`desc` `notes_desc`,\n                                `caches`.`name` `cache_name`,\n                                `cache_type`.`icon_small` `icon_large`,\n                                `caches`.`type` `cache_type`,\n                                `caches`.`cache_id` `cache_id`,\n                                `caches`.`user_id` `user_id`,\n                                note_id,\n                                cl.text AS log_text,\n                                cl.type AS log_type,\n                                cl.user_id AS luser_id,\n                                cl.date AS log_date,\n                                cl.deleted AS log_deleted,\n                                log_types.icon_small AS icon_small,\n                                user.username AS user_name,\n                                cache_mod_cords.id as cache_mod_cords_id,\n                                cache_mod_cords.longitude,\n                                cache_mod_cords.latitude\n                            FROM\n                                cache_mod_cords\n                                INNER JOIN `caches` ON (`cache_mod_cords`.`cache_id`=`caches`.`cache_id`)\n                                INNER JOIN cache_type ON (caches.type = cache_type.id)\n                                left outer JOIN cache_logs as cl ON (caches.cache_id = cl.cache_id)\n                                left outer JOIN log_types ON (cl.type = log_types.id)\n                                left outer JOIN user ON (cl.user_id = user.user_id)\n                                left outer JOIN cache_notes ON (\n                                        cache_notes.user_id = cache_mod_cords.user_id\n                                        AND cache_notes.cache_id = cache_mod_cords.cache_id\n                                    )\n                            WHERE\n                                `cache_mod_cords`.`user_id`=:1\n                                AND `cache_type`.`id`=`caches`.`type`\n                                AND\n                                    ( cl.id is null or cl.id =\n                                    ( SELECT id\n                                        FROM cache_logs cl_id\n                                        WHERE cl.cache_id = cl_id.cache_id and cl_id.date =\n\n                                            ( SELECT max( cache_logs.date )\n                                                FROM cache_logs\n                                                WHERE cl.cache_id = cache_id\n                                            )\n                                            limit 1\n                                        ))\n                            GROUP BY `cacheid`\n                            ORDER BY `cache_name`, log_date DESC";
 $db->multiVariableQuery($query, $userid);
 //if (mysql_num_rows($notes_rs) != 0)
 $count = $db->rowCount();
 if ($count != 0) {
     //$notes = '<table border="0" cellspacing="2" cellpadding="1" style="margin-left: 10px; line-height: 1.4em; font-size: 13px;" width="95%">';
     //$notes .= '<tr><td width="22">&nbsp;</td><td><strong>GeoCache</strong></td></tr><tr><td colspan="2"><hr></hr></td></tr>';
     $notes = "";
     $bgcolor1 = '#ffffff';
     $bgcolor2 = '#eeeeee';
     //for ($i = 0; $i < mysql_num_rows($notes_rs); $i++)
     for ($i = 0; $i < $count; $i++) {
         $bgcolor = $i % 2 ? $bgcolor1 : $bgcolor2;
         //$notes_record = sql_fetch_array($notes_rs);
         $notes_record = $db->dbResultFetch();
         $cacheicon = myninc::checkCacheStatusByUser($notes_record, $usr['userid']);
         $user_coords = '&nbsp;';
         if ($notes_record['latitude'] != null && $notes_record['longitude'] != null) {
             $user_coords = mb_ereg_replace(" ", "&nbsp;", htmlspecialchars(help_latToDegreeStr($notes_record['latitude'], 1), ENT_COMPAT, 'UTF-8')) . '&nbsp;' . mb_ereg_replace(" ", "&nbsp;", htmlspecialchars(help_lonToDegreeStr($notes_record['longitude'], 1), ENT_COMPAT, 'UTF-8'));
예제 #9
0
 tpl_set_var('display', $display);
 tpl_set_var('score_note_innitial', tr('log_score_note_innitial'));
 tpl_set_var('score_note_thanks', tr('log_score_note_thanks'));
 tpl_set_var('score_note_encorage', tr('log_score_note_encorage'));
 tpl_set_var('Do_reset_logform', tr('Do_reset_logform'));
 tpl_set_var('log_reset_button', tr('log_reset_button'));
 // check if geokret is in this cache
 if (isGeokretInCache($cache_id)) {
     tpl_set_var('log_geokret', "<br /><img src=\"images/gk.png\" class=\"icon16\" alt=\"\" title=\"GeoKrety\" align=\"middle\" />&nbsp;<b>" . tr('geokret_log') . " <a href='http://geokrety.org/ruchy.php'>geokrety.org</a></b>");
 } else {
     tpl_set_var('log_geokret', "");
 }
 /* GeoKretApi selector for logging Geokrets using GeoKretyApi */
 $dbConWpt = new dataBase();
 $dbConWpt->paramQuery("SELECT `secid` FROM `GeoKretyAPI` WHERE `userID` =:user_id LIMIT 1", array('user_id' => array('value' => $usr['userid'], 'data_type' => 'integer')));
 if ($dbConWpt->rowCount() > 0) {
     tpl_set_var('GeoKretyApiNotConfigured', 'none');
     tpl_set_var('GeoKretyApiConfigured', 'block');
     $databaseResponse = $dbConWpt->dbResultFetch();
     $secid = $databaseResponse['secid'];
     unset($dbConWpt);
     $dbConWpt = new dataBase();
     $dbConWpt->paramQuery("SELECT `wp_oc` FROM `caches` WHERE `cache_id` = :cache_id", array('cache_id' => array('value' => $cache_id, 'data_type' => 'integer')));
     $cwpt = $dbConWpt->dbResultFetch();
     $cache_waypt = $cwpt['wp_oc'];
     unset($dbConWpt);
     $GeoKretSelector = new GeoKretyApi($secid, $cache_waypt);
     $GKSelect = $GeoKretSelector->MakeGeokretSelector($cachename);
     $GKSelect2 = $GeoKretSelector->MakeGeokretInCacheSelector($cachename);
     tpl_set_var('GeoKretApiSelector', $GKSelect);
     tpl_set_var('GeoKretApiSelector2', $GKSelect2);
예제 #10
0
} else {
    tpl_set_var('blogDisplay', 'none');
}
/////////////////////////////////////////////////////
//Titled Caches
///////////////////////////////////////////////////
$usrid = -1;
$TitledCaches = "";
$dbc = new dataBase();
if ($usr != false) {
    $usrid = $usr['userid'];
}
$query = "SELECT caches.cache_id, caches.name cacheName, adm1 cacheCountry, adm3 cacheRegion, caches.type cache_type, \n        caches.user_id, user.username userName, cache_titled.date_alg, cache_logs.text, cache_desc.short_desc,\n        logUser.user_id logUserId, logUser.username logUserName\nFROM cache_titled\nJOIN caches ON cache_titled.cache_id = caches.cache_id\nJOIN cache_desc ON caches.cache_id = cache_desc.cache_id and language=:1\nJOIN cache_location ON caches.cache_id = cache_location.cache_id\nJOIN user ON caches.user_id = user.user_id\n        \nJOIN cache_logs ON cache_logs.id = cache_titled.log_id \nJOIN user logUser ON logUser.user_id = cache_logs.user_id\n               \nORDER BY date_alg DESC \nLIMIT 1";
$dbc->multiVariableQuery($query, $lang);
$pattern = "<span style='font-size:13px'><img src='{cacheIcon}' class='icon16' alt='Cache' title='Cache' />\n        <a href='viewcache.php?cacheid={cacheId}'><b>{cacheName}</b></a></span> \n        \n        <span style='font-size:11px'> " . tr('hidden_by') . "</span>\n        <span style='font-size:13px'><a href='viewprofile.php?userid={userId}'><b>{userName}</b></a></span><br>\n                \n        <span style='font-size:11px;font-style:italic'>{cacheShortDesc}</span><br>\n                \n        <span class='content-title-noshade' style='font-size:11px'>{country} > {region}</span>\n        <br><br>        \n        <table class='CacheTitledLog' >\n                <tr><td>{logText}\n                <br><br><img src='images/rating-star.png'/> Autor: <a href='viewprofile.php?userid={logUserId}'><b>{logUserName}<b></a></td></tr>\n        </table>";
for ($i = 0; $i < $dbc->rowCount(); $i++) {
    $rec = $dbc->dbResultFetch();
    $line = $pattern;
    $line = mb_ereg_replace('{cacheIcon}', myninc::checkCacheStatusByUser($rec, $usrid), $line);
    $line = mb_ereg_replace('{dateAlg}', $rec["date_alg"], $line);
    $line = mb_ereg_replace('{cacheName}', $rec["cacheName"], $line);
    $line = mb_ereg_replace('{userId}', $rec["user_id"], $line);
    $line = mb_ereg_replace('{userName}', $rec["userName"], $line);
    $line = mb_ereg_replace('{cacheId}', $rec["cache_id"], $line);
    $line = mb_ereg_replace('{country}', $rec["cacheCountry"], $line);
    $line = mb_ereg_replace('{region}', $rec["cacheRegion"], $line);
    $line = mb_ereg_replace('{cacheShortDesc}', $rec["short_desc"], $line);
    $line = mb_ereg_replace('{logUserId}', $rec["logUserId"], $line);
    $line = mb_ereg_replace('{logUserName}', $rec["logUserName"], $line);
    $text = mb_ereg_replace('<p>', '', $rec["text"]);
    $text = mb_ereg_replace('</p>', '<br>', $text);
예제 #11
0
                $record_logs = $dbc->dbResultFetch();
                $tmp_cache = $cache_notpublished_line;
                $tmp_cache = mb_ereg_replace('{cacheimage}', icon_cache_status($record_caches['status'], $record_caches['cache_status_text']), $tmp_cache);
                $tmp_cache = mb_ereg_replace('{cachestatus}', htmlspecialchars($record_caches['cache_status_text'], ENT_COMPAT, 'UTF-8'), $tmp_cache);
                $tmp_cache = mb_ereg_replace('{cacheid}', htmlspecialchars(urlencode($record_caches['cache_id']), ENT_COMPAT, 'UTF-8'), $tmp_cache);
                if (is_null($record_caches['date_activate'])) {
                    $tmp_cache = mb_ereg_replace('{date}', $no_time_set, $tmp_cache);
                } else {
                    $tmp_cache = mb_ereg_replace('{date}', strftime($datetimeformat, strtotime($record_caches['date_activate'])), $tmp_cache);
                }
                $tmp_cache = mb_ereg_replace('{cachename}', htmlspecialchars($record_caches['name'], ENT_COMPAT, 'UTF-8'), $tmp_cache);
                $caches .= "\n" . $tmp_cache;
            }
            tpl_set_var('notpublishedcaches', $caches);
        }
        unset($dbc);
        // get number of sent emails
        $dbc = new dataBase();
        $emails_sent = '0';
        $sql = "SELECT COUNT(*) AS `emails_sent` FROM `email_user` WHERE `from_user_id`=:1";
        $dbc->multiVariableQuery($sql, $usr['userid']);
        $row = $dbc->dbResultFetch();
        if ($dbc->rowCount()) {
            $emails_sent = $row['emails_sent'];
        }
        tpl_set_var('emails_sent', $emails_sent);
        unset($dbc);
    }
}
//make the template and send it out
tpl_BuildTemplate();
// test transaction isolation
$db2->beginTransaction();
$db2->simpleQuery("insert into transaction_test (name) values('Asia')");
$db2->simpleQuery("insert into transaction_test (name) values('Kasia')");
$db2->simpleQuery("insert into transaction_test (name) values('Natalia')");
check_database_count($db, 0, __LINE__);
// test commit
$db2->commit();
check_database_count($db, 3, __LINE__);
// test no-transaction
$db2->simpleQuery("insert into transaction_test (name) values('Basia')");
check_database_count($db, 4, __LINE__);
// test rollback
$db2->beginTransaction();
$db2->simpleQuery("delete from transaction_test where name = 'Kasia'");
if ($db2->rowCount() !== 1) {
    echo "Expected 1 row to be deleted!<br>";
    die;
}
check_database_count($db, 4, __LINE__);
check_database_count($db2, 3, __LINE__);
$db2->rollback();
check_database_count($db2, 4, __LINE__);
$db2->simpleQuery("delete from transaction_test;");
$db2->simpleQuery("insert into transaction_test (name) values('Kasia')");
// test transation nesting
$db2->beginTransaction();
$db2->simpleQuery("insert into transaction_test (name) values('Zosia')");
$db2->beginTransaction();
$db2->simpleQuery("insert into transaction_test (name) values('Gosia')");
$db2->simpleQuery("insert into transaction_test (name) values('Marta')");
예제 #13
0
     }
 }
 $tmplog = mb_ereg_replace('{logfunctions}', $logfunctions, $tmplog);
 // pictures
 //START: edit by FelixP - 2013'10
 if ($record['picturescount'] > 0 && ($record['deleted'] == false || $usr['admin'])) {
     // show pictures if (any added) and ((not deleted) or (user is admin))
     //END: edit by FelixP - 2013'10
     $logpicturelines = '';
     $append_atag = '';
     if (!isset($dbc)) {
         $dbc = new dataBase();
     }
     $thatquery = "SELECT `url`, `title`, `uuid`, `user_id`, `spoiler` FROM `pictures` WHERE `object_id`=:1 AND `object_type`=1";
     $dbc->multiVariableQuery($thatquery, $record['log_id']);
     $pic_count = $dbc->rowCount();
     for ($j = 0; $j < $pic_count; $j++) {
         $pic_record = $dbc->dbResultFetch();
         $thisline = $logpictureline;
         if ($disable_spoiler_view && intval($pic_record['spoiler']) == 1) {
             // if hide spoiler (due to user not logged in) option is on prevent viewing pic link and show alert
             $thisline = mb_ereg_replace('{log_picture_onclick}', "alert('" . $spoiler_disable_msg . "'); return false;", $thisline);
             $thisline = mb_ereg_replace('{link}', 'index.php', $thisline);
             $thisline = mb_ereg_replace('{longdesc}', 'index.php', $thisline);
         } else {
             $thisline = mb_ereg_replace('{log_picture_onclick}', "enlarge(this)", $thisline);
             $thisline = mb_ereg_replace('{link}', $pic_record['url'], $thisline);
             $thisline = mb_ereg_replace('{longdesc}', str_replace("images/uploads", "upload", $pic_record['url']), $thisline);
         }
         $thisline = mb_ereg_replace('{imgsrc}', 'thumbs2.php?' . $showspoiler . 'uuid=' . urlencode($pic_record['uuid']), $thisline);
         $thisline = mb_ereg_replace('{title}', htmlspecialchars($pic_record['title'], ENT_COMPAT, 'UTF-8'), $thisline);
예제 #14
0
         $message = tr('adopt_15');
         $message = str_replace('{cacheName}', getCacheName($_GET['cacheid']), $message);
         tpl_set_var('error_msg', $message . '<br /><br />');
         tpl_set_var("error_msg", "");
         $mailContent = tr('adopt_31');
         $mailContent = str_replace('\\n', "\n", $mailContent);
         $mailContent = str_replace('{userName}', $usr['username'], $mailContent);
         $mailContent = str_replace('{cacheName}', getCacheName($_GET['cacheid']), $mailContent);
         mb_send_mail_2(getUserEmail($oldOwnerId), tr('adopt_18'), $mailContent, emailHeaders());
     }
 }
 if (isset($_GET['accept']) && $_GET['accept'] == 0) {
     // odrzucenie zmiany
     $sql = "DELETE FROM chowner WHERE cache_id = :1 AND user_id = :2";
     $db->multiVariableQuery($sql, $_GET['cacheid'], $usr['userid']);
     if ($db->rowCount() > 0) {
         tpl_set_var("info_msg", tr('adopt_27') . '<br /><br />');
         $mailContent = tr('adopt_29');
         $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($oldOwnerId), tr('adopt_28'), $mailContent, emailHeaders());
     } else {
         tpl_set_var("error_msg", tr('adopt_30') . '<br /><br />');
     }
 }
 if (isset($_GET['abort']) && isUserOwner($usr['userid'], $_GET['cacheid'])) {
     // anulowanie procedury przejecia
     $sql = "DELETE FROM chowner WHERE cache_id = :1";
     $db->multiVariableQuery($sql, $_GET['cacheid']);
     if ($db->rowCount() > 0) {
예제 #15
0
 $tmp_list = $i % 2 == 0 ? $list_e : $list_o;
 //modified coords
 if (($record['type'] == '7' || $record['type'] == '1' || $record['type'] == '3') && $usr != false) {
     //check if quiz (7) or other(1) or multi (3) and user is logged
     if (!isset($dbc)) {
         $dbc = new dataBase();
     }
     $mod_coord_sql = 'SELECT cache_id FROM cache_mod_cords
                 WHERE cache_id = :v1 AND user_id =:v2';
     $params['v1']['value'] = (int) $record['cache_id'];
     $params['v1']['data_type'] = 'integer';
     $params['v2']['value'] = (int) $usr['userid'];
     $params['v2']['data_type'] = 'integer';
     $dbc->paramQuery($mod_coord_sql, $params);
     unset($params);
     if ($dbc->rowCount() > 0) {
         $tmp_list = str_replace('{mod_suffix}', '[F]', $tmp_list);
     } else {
         $tmp_list = str_replace('{mod_suffix}', '', $tmp_list);
     }
 } else {
     $tmp_list = str_replace('{mod_suffix}', '', $tmp_list);
 }
 $tmp_list = mb_ereg_replace('{cachename}', htmlspecialchars($record['name'], ENT_COMPAT, 'UTF-8'), $tmp_list);
 if ($record['last_found'] == NULL || $record['last_found'] == '0000-00-00 00:00:00') {
     $tmp_list = mb_ereg_replace('{lastfound}', htmlspecialchars($no_found_date, ENT_COMPAT, 'UTF-8'), $tmp_list);
 } else {
     $tmp_list = mb_ereg_replace('{lastfound}', htmlspecialchars(strftime($dateformat, strtotime($record['last_found'])), ENT_COMPAT, 'UTF-8'), $tmp_list);
 }
 $tmp_list = mb_ereg_replace('{urlencode_cacheid}', htmlspecialchars(urlencode($record['cache_id']), ENT_COMPAT, 'UTF-8'), $tmp_list);
 $tmp_list = mb_ereg_replace('{cacheid}', htmlspecialchars($record['cache_id'], ENT_COMPAT, 'UTF-8'), $tmp_list);
예제 #16
0
function revertLog($log_id, $language, $lang)
{
    // set $debug = true to display debug messages (or false to hide).
    $debug = false;
    global $tplname, $usr, $lang, $stylepath, $oc_nodeid, $error_wrong_node, $removed_message_title, $removed_message_end, $emailheaders, $rootpath, $cacheid, $log_record, $cache_types, $cache_size, $cache_status, $dblink;
    $logRs = new dataBase($debug);
    $logRsQuery = "SELECT   `cache_logs`.`node` AS `node`, `cache_logs`.`uuid` AS `uuid`, `cache_logs`.`cache_id` AS `cache_id`, `caches`.`user_id` AS `cache_owner_id`,\n                            `caches`.`name` AS `cache_name`, `cache_logs`.`text` AS `log_text`, `cache_logs`.`type` AS `log_type`,\n                            `cache_logs`.`user_id` AS `log_user_id`, `cache_logs`.`date` AS `log_date`,\n                            `log_types`.`icon_small` AS `icon_small`,\n                            `log_types_text`.`text_listing` AS `text_listing`,\n                            `user`.`username` as `log_username`\n                     FROM   `log_types`, `log_types_text`, `cache_logs`, `caches`, `user`\n                    WHERE   `cache_logs`.`id`=:log_id\n                      AND   `cache_logs`.`user_id`=`user`.`user_id`\n                      AND   `caches`.`cache_id`=`cache_logs`.`cache_id`\n                      AND   `log_types_text`.`log_types_id`=`log_types`.`id` AND `log_types_text`.`lang`=:lang\n                      AND   `cache_logs`.`deleted` = 1\n                      AND   `log_types`.`id`=`cache_logs`.`type`";
    $logRs->paramQuery($logRsQuery, array('log_id' => array('value' => $log_id, 'data_type' => 'integer'), 'lang' => array('value' => $lang, 'data_type' => 'string')));
    //log exists?
    if ($logRs->rowCount() == 1) {
        $log_record = $logRs->dbResultFetch();
        unset($logRs);
        //  include($stylepath . '/removelog.inc.php');
        if ($log_record['node'] != $oc_nodeid) {
            tpl_errorMsg('removelog', $error_wrong_node);
            exit;
        }
        //cache-owner or log-owner
        if ($log_record['log_user_id'] == $usr['userid'] || $log_record['cache_owner_id'] == $usr['userid'] || $usr['admin']) {
            // revert the log.
            $revert = new dataBase($debug);
            $query = "UPDATE `cache_logs` SET deleted = 0 , `last_modified`=NOW() WHERE `cache_logs`.`id`=:log_id LIMIT 1";
            $revert->paramQuery($query, array('log_id' => array('value' => $log_id, 'data_type' => 'i')));
            unset($revert);
            //user stats update
            $statUpd = new dataBase();
            $query = "SELECT `founds_count`, `notfounds_count`, `log_notes_count` FROM `user` WHERE `user_id`=:user_id";
            $statUpd->paramQuery($query, array('user_id' => array('value' => $log_record['log_user_id'], 'data_type' => 'i')));
            $user_record = $statUpd->dbResultFetch();
            unset($statUpd);
            if ($log_record['log_type'] == 1 || $log_record['log_type'] == 7) {
                $user_record['founds_count']++;
            } elseif ($log_record['log_type'] == 2) {
                $user_record['notfounds_count']++;
            } elseif ($log_record['log_type'] == 3) {
                $user_record['log_notes_count']++;
            }
            $updateUser = new dataBase($debug);
            $query = "UPDATE `user` SET `founds_count`=:var1, `notfounds_count`=:var2, `log_notes_count`=:var3 WHERE `user_id`=:var4";
            $params = array('var1' => array('value' => $user_record['founds_count'], 'data_type' => 'i'), 'var2' => array('value' => $user_record['notfounds_count'], 'data_type' => 'i'), 'var3' => array('value' => $user_record['log_notes_count'], 'data_type' => 'i'), 'var4' => array('value' => $log_record['log_user_id'], 'data_type' => 'i'));
            $updateUser->paramQuery($query, $params);
            unset($updateUser, $params, $user_record);
            //call eventhandler
            require_once $rootpath . 'lib/eventhandler.inc.php';
            event_remove_log($cacheid, $usr['userid'] + 0);
            //update cache-stat if type or log_date changed
            $cachStat = new dataBase($debug);
            $query = "SELECT `founds`, `notfounds`, `notes` FROM `caches` WHERE `cache_id`=:var1";
            $cachStat->paramQuery($query, array('var1' => array('value' => $log_record['cache_id'], 'data_type' => 'i')));
            $cache_record = $cachStat->dbResultFetch();
            unset($cachStat);
            if ($log_record['log_type'] == 1 || $log_record['log_type'] == 7) {
                $cache_record['founds']++;
            } elseif ($log_record['log_type'] == 2 || $log_record['log_type'] == 8) {
                $cache_record['notfounds']++;
            } elseif ($log_record['log_type'] == 3) {
                $cache_record['notes']++;
            }
            //Update last found
            $lastF = new dataBase();
            $query = "SELECT MAX(`cache_logs`.`date`) AS `date` FROM `cache_logs` WHERE ((cache_logs.`type`=1) AND (cache_logs.`cache_id`=:last_tmp))";
            $lastF->paramQuery($query, array('last_tmp' => array('value' => $log_record['cache_id'], 'data_type' => 'i')));
            $lastfound_record = $lastF->dbResultFetch();
            unset($statUpd);
            if ($lastfound_record['date'] === NULL) {
                $lastfound = 'NULL';
            } else {
                $lastfound = $lastfound_record['date'];
            }
            $updateCache = new dataBase();
            $query = "UPDATE `caches` SET `last_found`=:var1, `founds`=:var2, `notfounds`=:var3, `notes`=:var4 WHERE `cache_id`=:var5";
            $params = array('var1' => array('value' => $lastfound, 'data_type' => 'string'), 'var2' => array('value' => $cache_record['founds'], 'data_type' => 'i'), 'var3' => array('value' => $cache_record['notfounds'], 'data_type' => 'i'), 'var4' => array('value' => $cache_record['notes'], 'data_type' => 'i'), 'var5' => array('value' => $log_record['cache_id'], 'data_type' => 'i'));
            $updateCache->paramQuery($query, $params);
            unset($updateCache, $params, $cache_record);
            $_GET['cacheid'] = $log_record['cache_id'];
            $_REQUEST['cacheid'] = $log_record['cache_id'];
            require 'viewcache.php';
        } else {
            //TODO: hm ... no permission to revert the log
            $_GET['cacheid'] = $log_record['cache_id'];
            $_REQUEST['cacheid'] = $log_record['cache_id'];
            require 'viewcache.php';
        }
    } else {
        //TODO: log doesn't exist
        $_GET['cacheid'] = $log_record['cache_id'];
        $_REQUEST['cacheid'] = $log_record['cache_id'];
        require 'viewcache.php';
    }
}
 function run()
 {
     $db = new dataBase();
     $db->switchDebug(false);
     $sql = "SELECT cache_id, status FROM caches";
     $params = array();
     if (isset($_GET['cache_id'])) {
         $sql .= ' where cache_id=:cache_id';
         $params['cache_id']['value'] = intval($_GET['cache_id']);
         $params['cache_id']['data_type'] = 'integer';
     }
     $db->paramQuery($sql, $params);
     $caches = $db->dbResultFetchAll();
     set_time_limit(3600);
     $total_touched = 0;
     foreach ($caches as $cache) {
         $cache_id = $cache['cache_id'];
         // usuniecie falszywych ocen
         //echo "cache_logs.cache_id=".sql_escape($rs['cache_id']).", user.username="******"<br />";
         //$sql = "DELETE FROM scores WHERE cache_id = '".sql_escape($rs['cache_id'])."' AND user_id = '".sql_escape($rs['user_id'])."'";
         //mysql_query($sql);
         $db->multiVariableQuery("delete from scores where cache_id = :1 and user_id not in (\n                    select user_id from cache_logs where deleted=0 and cache_id = :2\n                )", $cache_id, $cache_id);
         // zliczenie ocen po usunieciu
         $db->multiVariableQuery("SELECT avg(score) as avg_score, count(score) as votes FROM scores WHERE cache_id = :1", $cache_id);
         $row = $db->dbResultFetch();
         if ($row == false) {
             $liczba = 0;
             $srednia = 0;
         } else {
             $liczba = $row['votes'];
             if ($liczba > 0) {
                 $srednia = round($row['avg_score'], 4);
             } else {
                 $srednia = 0;
             }
         }
         unset($row);
         $db->closeCursor();
         // repair founds
         $founds = $db->multiVariableQueryValue("SELECT count(*) FROM cache_logs WHERE deleted=0 AND cache_id = :1 AND (type=1 OR type=7)", 0, $cache_id);
         $notfounds = $db->multiVariableQueryValue("SELECT count(*) FROM cache_logs WHERE deleted=0 AND cache_id = :1 AND (type=2 OR type=8)", 0, $cache_id);
         $notes = $db->multiVariableQueryValue("SELECT count(*) FROM cache_logs WHERE deleted=0 AND cache_id = :1 AND type=3", 0, $cache_id);
         $watchers = $db->multiVariableQueryValue("SELECT count(*) FROM cache_watches WHERE cache_id = :1", 0, $cache_id);
         $ignorers = $db->multiVariableQueryValue("SELECT count(*) FROM cache_ignore WHERE cache_id = :1", 0, $cache_id);
         $sql = "\n                UPDATE caches\n                SET\n                    votes=:new_votes,\n                    score=:new_score,\n                    founds=:new_founds,\n                    notfounds=:new_notfounds,\n                    notes=:new_notes,\n                    watcher=:new_watchers,\n                    ignorer_count=:new_ignorers\n                WHERE\n                    cache_id=:cache_id\n                    AND (\n                        votes is null\n                        OR score is null\n                        OR founds is null\n                        OR notfounds is null\n                        OR notes is null\n                        OR watcher is null\n                        OR ignorer_count is null\n                        OR votes!=:new_votes\n                        OR abs(score-:new_score)>0.0001\n                        OR founds!=:new_founds\n                        OR notfounds!=:new_notfounds\n                        OR notes!=:new_notes\n                        OR watcher!=:new_watchers\n                        OR ignorer_count!=:new_ignorers\n                    )\n            ";
         $params = array();
         $params['new_votes']['value'] = intval($liczba);
         $params['new_votes']['data_type'] = 'integer';
         $params['new_score']['value'] = strval($srednia);
         $params['new_score']['data_type'] = 'string';
         $params['new_founds']['value'] = intval($founds);
         $params['new_founds']['data_type'] = 'integer';
         $params['new_notfounds']['value'] = intval($notfounds);
         $params['new_notfounds']['data_type'] = 'integer';
         $params['new_notes']['value'] = intval($notes);
         $params['new_notes']['data_type'] = 'integer';
         $params['new_watchers']['value'] = intval($watchers);
         $params['new_watchers']['data_type'] = 'integer';
         $params['new_ignorers']['value'] = intval($ignorers);
         $params['new_ignorers']['data_type'] = 'integer';
         $params['cache_id']['value'] = intval($cache_id);
         $params['cache_id']['data_type'] = 'integer';
         $db->paramQuery($sql, $params);
         if ($db->rowCount() > 0) {
             echo "<b>cache_id={$cache_id}</b><br>";
             echo "ratings={$liczba}<br>rating={$srednia}<br>";
             echo "founds={$founds}<br>notfounds={$notfounds}<br>";
             echo "notes={$notes}<br>watchers={$watchers}<br>";
             echo "ignorers={$ignorers}<br>";
             $total_touched++;
         }
         $db->closeCursor();
     }
     set_time_limit(60);
     unset($db);
     echo "-----------------------------------<br>total_touched={$total_touched}<br>";
 }
예제 #18
0
function outputSearchForm($options)
{
    global $stylepath, $usr, $error_plz, $error_locidnocoords, $error_ort, $error_noort, $error_nofulltext;
    global $default_lang, $search_all_countries, $cache_attrib_jsarray_line, $cache_attrib_img_line;
    global $lang, $language, $config;
    //simple mode (only one easy filter)
    $filters = read_file($stylepath . '/search.simple.tpl.php');
    tpl_set_var('filters', $filters, false);
    tpl_set_var('formmethod', 'get');
    // checkboxes
    if (isset($options['sort'])) {
        $bBynameChecked = $options['sort'] == 'byname';
    } else {
        $bBynameChecked = $usr['userid'] == 0;
    }
    tpl_set_var('byname_checked', $bBynameChecked == true ? ' checked="checked"' : '');
    if (isset($options['sort'])) {
        $bBydistanceChecked = $options['sort'] == 'bydistance';
    } else {
        $bBydistanceChecked = $usr['userid'] != 0;
    }
    tpl_set_var('bydistance_checked', $bBydistanceChecked == true ? ' checked="checked"' : '');
    if (isset($options['sort'])) {
        $bBycreatedChecked = $options['sort'] == 'bycreated';
    } else {
        $bBycreatedChecked = $usr['userid'] == 0;
    }
    tpl_set_var('bycreated_checked', $bBycreatedChecked == true ? ' checked="checked"' : '');
    tpl_set_var('hidopt_sort', $options['sort']);
    tpl_set_var('f_inactive_checked', $options['f_inactive'] == 1 ? ' checked="checked"' : '');
    tpl_set_var('hidopt_inactive', $options['f_inactive'] == 1 ? '1' : '0');
    tpl_set_var('f_ignored_disabled', $usr['userid'] == 0 ? ' disabled="disabled"' : '');
    if ($usr['userid'] != 0) {
        tpl_set_var('f_ignored_disabled', $options['f_ignored'] == 1 ? ' checked="checked"' : '');
    }
    tpl_set_var('hidopt_ignored', $options['f_ignored'] == 1 ? '1' : '0');
    tpl_set_var('f_userfound_disabled', $usr['userid'] == 0 ? ' disabled="disabled"' : '');
    if ($usr['userid'] != 0) {
        tpl_set_var('f_userfound_disabled', $options['f_userfound'] == 1 ? ' checked="checked"' : '');
    }
    tpl_set_var('hidopt_userfound', $options['f_userfound'] == 1 ? '1' : '0');
    tpl_set_var('f_userowner_disabled', $usr['userid'] == 0 ? ' disabled="disabled"' : '');
    if ($usr['userid'] != 0) {
        tpl_set_var('f_userowner_disabled', $options['f_userowner'] == 1 ? ' checked="checked"' : '');
    }
    tpl_set_var('hidopt_userowner', $options['f_userowner'] == 1 ? '1' : '0');
    tpl_set_var('f_watched_disabled', $usr['userid'] == 0 ? ' disabled="disabled"' : '');
    if ($usr['userid'] != 0) {
        tpl_set_var('f_watched_disabled', $options['f_watched'] == 1 ? ' checked="checked"' : '');
    }
    tpl_set_var('hidopt_watched', $options['f_watched'] == 1 ? '1' : '0');
    tpl_set_var('f_geokret_checked', $options['f_geokret'] == 1 ? ' checked="checked"' : '');
    tpl_set_var('hidopt_geokret', $options['f_geokret'] == 1 ? '1' : '0');
    if (isset($options['cacherating'])) {
        tpl_set_var('all_caches_checked', $options['cacherating'] == 0 ? ' checked="checked"' : '');
        tpl_set_var('recommended_caches_checked', $options['cacherating'] > 0 ? ' checked="checked"' : '');
        tpl_set_var('cache_min_rec', $options['cacherating'] > 0 ? $options['cacherating'] : 0);
        tpl_set_var('min_rec_caches_disabled', $options['cacherating'] == 0 ? ' disabled="disabled"' : '');
    }
    if (isset($options['cacherating'])) {
        tpl_set_var('cacherating', htmlspecialchars($options['cacherating'], ENT_COMPAT, 'UTF-8'));
    } else {
        tpl_set_var('cacherating', '');
    }
    if (isset($options['region'])) {
        tpl_set_var('region', htmlspecialchars($options['region'], ENT_COMPAT, 'UTF-8'));
    } else {
        tpl_set_var('region', '');
    }
    if (isset($options['country'])) {
        tpl_set_var('country', htmlspecialchars($options['country'], ENT_COMPAT, 'UTF-8'));
    } else {
        tpl_set_var('country', '');
    }
    if (isset($options['cachetype'])) {
        tpl_set_var('cachetype', htmlspecialchars($options['cachetype'], ENT_COMPAT, 'UTF-8'));
    } else {
        tpl_set_var('cachetype', '');
    }
    if (isset($options['cachesize_1'])) {
        tpl_set_var('cachesize_1', htmlspecialchars($options['cachesize_1'], ENT_COMPAT, 'UTF-8'));
    } else {
        tpl_set_var('cachesize_1', '');
    }
    if (isset($options['cachesize_2'])) {
        tpl_set_var('cachesize_2', htmlspecialchars($options['cachesize_2'], ENT_COMPAT, 'UTF-8'));
    } else {
        tpl_set_var('cachesize_2', '');
    }
    if (isset($options['cachesize_3'])) {
        tpl_set_var('cachesize_3', htmlspecialchars($options['cachesize_3'], ENT_COMPAT, 'UTF-8'));
    } else {
        tpl_set_var('cachesize_3', '');
    }
    if (isset($options['cachesize_4'])) {
        tpl_set_var('cachesize_4', htmlspecialchars($options['cachesize_4'], ENT_COMPAT, 'UTF-8'));
    } else {
        tpl_set_var('cachesize_4', '');
    }
    if (isset($options['cachesize_5'])) {
        tpl_set_var('cachesize_5', htmlspecialchars($options['cachesize_5'], ENT_COMPAT, 'UTF-8'));
    } else {
        tpl_set_var('cachesize_5', '');
    }
    if (isset($options['cachesize_6'])) {
        tpl_set_var('cachesize_6', htmlspecialchars($options['cachesize_6'], ENT_COMPAT, 'UTF-8'));
    } else {
        tpl_set_var('cachesize_6', '');
    }
    if (isset($options['cachesize_7'])) {
        tpl_set_var('cachesize_7', htmlspecialchars($options['cachesize_7'], ENT_COMPAT, 'UTF-8'));
    } else {
        tpl_set_var('cachesize_7', '');
    }
    if (isset($options['cachevote_1']) && isset($options['cachevote_2'])) {
        tpl_set_var('cachevote_1', htmlspecialchars($options['cachevote_1'], ENT_COMPAT, 'UTF-8'));
        tpl_set_var('cachevote_2', htmlspecialchars($options['cachevote_2'], ENT_COMPAT, 'UTF-8'));
    } else {
        tpl_set_var('cachevote_1', '');
        tpl_set_var('cachevote_2', '');
    }
    if (isset($options['cachenovote'])) {
        tpl_set_var('cachenovote', htmlspecialchars($options['cachenovote'], ENT_COMPAT, 'UTF-8'));
    } else {
        tpl_set_var('cachenovote', '');
    }
    if (isset($options['cachedifficulty_1']) && isset($options['cachedifficulty_2'])) {
        tpl_set_var('cachedifficulty_1', htmlspecialchars($options['cachedifficulty_1'], ENT_COMPAT, 'UTF-8'));
        tpl_set_var('cachedifficulty_2', htmlspecialchars($options['cachedifficulty_2'], ENT_COMPAT, 'UTF-8'));
    } else {
        tpl_set_var('cachedifficulty_1', '');
        tpl_set_var('cachedifficulty_2', '');
    }
    if (isset($options['cacheterrain_1']) && isset($options['cacheterrain_2'])) {
        tpl_set_var('cacheterrain_1', htmlspecialchars($options['cacheterrain_1'], ENT_COMPAT, 'UTF-8'));
        tpl_set_var('cacheterrain_2', htmlspecialchars($options['cacheterrain_2'], ENT_COMPAT, 'UTF-8'));
    } else {
        tpl_set_var('cacheterrain_1', '');
        tpl_set_var('cacheterrain_2', '');
    }
    // cachename
    tpl_set_var('cachename', isset($options['cachename']) ? htmlspecialchars($options['cachename'], ENT_COMPAT, 'UTF-8') : '');
    // koordinaten
    if (!isset($options['lat_h'])) {
        if ($usr !== false) {
            $rs = sql('SELECT `latitude`, `longitude` FROM `user` WHERE `user_id`=\'' . sql_escape($usr['userid']) . '\'');
            $record = sql_fetch_array($rs);
            $lon = $record['longitude'];
            $lat = $record['latitude'];
            mysql_free_result($rs);
            if ($lon < 0) {
                tpl_set_var('lonE_sel', '');
                tpl_set_var('lonW_sel', ' selected="selected"');
                $lon = -$lon;
            } else {
                tpl_set_var('lonE_sel', ' selected="selected"');
                tpl_set_var('lonW_sel', '');
            }
            if ($lat < 0) {
                tpl_set_var('latN_sel', '');
                tpl_set_var('latS_sel', ' selected="selected"');
                $lat = -$lat;
            } else {
                tpl_set_var('latN_sel', ' selected="selected"');
                tpl_set_var('latS_sel', '');
            }
            $lon_h = floor($lon);
            $lat_h = floor($lat);
            $lon_min = ($lon - $lon_h) * 60;
            $lat_min = ($lat - $lat_h) * 60;
            tpl_set_var('lat_h', $lat_h);
            tpl_set_var('lon_h', $lon_h);
            tpl_set_var('lat_min', sprintf("%02.3f", $lat_min));
            tpl_set_var('lon_min', sprintf("%02.3f", $lon_min));
        } else {
            tpl_set_var('lat_h', '00');
            tpl_set_var('lon_h', '000');
            tpl_set_var('lat_min', '00.000');
            tpl_set_var('lon_min', '00.000');
            tpl_set_var('latN_sel', ' selected="selected"');
            tpl_set_var('latS_sel', '');
            tpl_set_var('lonE_sel', ' selected="selected"');
            tpl_set_var('lonW_sel', '');
        }
    } else {
        tpl_set_var('lat_h', isset($options['lat_h']) ? $options['lat_h'] : '00');
        tpl_set_var('lon_h', isset($options['lon_h']) ? $options['lon_h'] : '000');
        tpl_set_var('lat_min', isset($options['lat_min']) ? $options['lat_min'] : '00.000');
        tpl_set_var('lon_min', isset($options['lon_min']) ? $options['lon_min'] : '00.000');
        if ($options['lonEW'] == 'W') {
            tpl_set_var('lonE_sel', '');
            tpl_set_var('lonW_sel', 'selected="selected"');
        } else {
            tpl_set_var('lonE_sel', 'selected="selected"');
            tpl_set_var('lonW_sel', '');
        }
        if ($options['latNS'] == 'S') {
            tpl_set_var('latS_sel', 'selected="selected"');
            tpl_set_var('latN_sel', '');
        } else {
            tpl_set_var('latS_sel', '');
            tpl_set_var('latN_sel', 'selected="selected"');
        }
    }
    tpl_set_var('distance', isset($options['distance']) ? $options['distance'] : 20);
    if (!isset($options['unit'])) {
        $options['unit'] = 'km';
    }
    if ($options['unit'] == 'km') {
        tpl_set_var('sel_km', 'selected="selected"');
        tpl_set_var('sel_sm', '');
        tpl_set_var('sel_nm', '');
    } else {
        if ($options['unit'] == 'sm') {
            tpl_set_var('sel_km', '');
            tpl_set_var('sel_sm', 'selected="selected"');
            tpl_set_var('sel_nm', '');
        } else {
            if ($options['unit'] == 'nm') {
                tpl_set_var('sel_km', '');
                tpl_set_var('sel_sm', '');
                tpl_set_var('sel_nm', 'selected="selected"');
            }
        }
    }
    // plz
    tpl_set_var('plz', isset($options['plz']) ? htmlspecialchars($options['plz'], ENT_COMPAT, 'UTF-8') : '');
    tpl_set_var('ort', isset($options['ort']) ? htmlspecialchars($options['ort'], ENT_COMPAT, 'UTF-8') : '');
    // owner
    tpl_set_var('owner', isset($options['owner']) ? htmlspecialchars($options['owner'], ENT_COMPAT, 'UTF-8') : '');
    // finder
    tpl_set_var('finder', isset($options['finder']) ? htmlspecialchars($options['finder'], ENT_COMPAT, 'UTF-8') : '');
    //countryoptions
    $countriesoptions = $search_all_countries;
    $rs = sql('SELECT `short` FROM `countries` WHERE `short` IN (SELECT DISTINCT `country` FROM `caches`) ');
    for ($i = 0; $i < mysql_num_rows($rs); $i++) {
        $record = sql_fetch_array($rs);
        if ($record['short'] == $options['country']) {
            $countriesoptions .= '<option value="' . htmlspecialchars($record['short'], ENT_COMPAT, 'UTF-8') . '" selected="selected">' . htmlspecialchars(tr($record['short']), ENT_COMPAT, 'UTF-8') . '</option>';
        } else {
            $countriesoptions .= '<option value="' . htmlspecialchars($record['short'], ENT_COMPAT, 'UTF-8') . '">' . htmlspecialchars(tr($record['short']), ENT_COMPAT, 'UTF-8') . '</option>';
        }
        $countriesoptions .= "\n";
    }
    tpl_set_var('countryoptions', $countriesoptions);
    //regionoptions
    $regionsoptions = '<option value="" selected="selected">' . tr('all_regions') . '</option>';
    tpl_set_var('regionoptions', $regionsoptions);
    // Typ skrzynki
    $cachetype_options = '';
    if (checkField('cache_type', $lang)) {
        $lang_db = $lang;
    } else {
        $lang_db = "en";
    }
    $rs = sql('SELECT `id`, `&1`, `icon_large` FROM `cache_type` ORDER BY `sort`', $lang_db);
    for ($i = 0; $i < mysql_num_rows($rs); $i++) {
        $record = sql_fetch_array($rs);
        /*
        if ($record['id'] == $options['cachetype'])
            $cachetype_options .= '<option value="' . htmlspecialchars($record['id'], ENT_COMPAT, 'UTF-8') . '" selected="selected">' . htmlspecialchars($record[$default_lang], ENT_COMPAT, 'UTF-8') . '</option>';
        else
            $cachetype_options .= '<option value="' . htmlspecialchars($record['id'], ENT_COMPAT, 'UTF-8') . '">' . htmlspecialchars($record[$default_lang], ENT_COMPAT, 'UTF-8') . '</option>';
        */
        $c_rec_id = $record['id'] - 1;
        $cachetype_icon = $record['icon_large'];
        //      if ($options['cachetype'][$c_rec_id] == '1') {
        //          $cachetype_options .= '<input type="checkbox" name="cachetype_' . htmlspecialchars($record['id'], ENT_COMPAT, 'UTF-8') . '" value="1" id="l_cachetype_' . htmlspecialchars($record['id'], ENT_COMPAT, 'UTF-8') . '" class="checkbox" onclick="javascript:sync_options(this)" checked="checked" /><label for="l_cachetype_' . htmlspecialchars($record['id'], ENT_COMPAT, 'UTF-8') . '">' . htmlspecialchars($record[$default_lang], ENT_COMPAT, 'UTF-8') . '</label>';
        //      } else {
        //          $cachetype_options .= '<input type="checkbox" name="cachetype_' . htmlspecialchars($record['id'], ENT_COMPAT, 'UTF-8') . '" value="1" id="l_cachetype_' . htmlspecialchars($record['id'], ENT_COMPAT, 'UTF-8') . '" class="checkbox" onclick="javascript:sync_options(this)" /><label for="l_cachetype_' . htmlspecialchars($record['id'], ENT_COMPAT, 'UTF-8') . '">' . htmlspecialchars($record[$default_lang], ENT_COMPAT, 'UTF-8') . '</label>';
        //      }
        $cachetype_icon = str_replace("mystery", "quiz", $cachetype_icon);
        // mystery is an outdated name, we use 'quiz' now :-)
        $cachetype_icon_bw = $cachetype_icon;
        $cachetype_icon = str_replace(".png", "-i.png", $cachetype_icon);
        $cachetype_icon_bw = str_replace(".png", "-i-bw.png", $cachetype_icon_bw);
        $cachetype_icon = str_replace(".gif", "-i.png", $cachetype_icon);
        $cachetype_icon_bw = str_replace(".gif", "-i-bw.png", $cachetype_icon_bw);
        $hidden_css = "position: absolute; visibility: hidden;";
        // css required to hide an image
        // this marks saved user preference for searching, if 1, the cache is by default searched
        // and thus making the colour image visibile
        if (isset($options['cachetype'][$c_rec_id]) && $options['cachetype'][$c_rec_id] == '1') {
            $icon_hidden = "";
            $icon_bw_hidden = $hidden_css;
        } else {
            $icon_hidden = $hidden_css;
            $icon_bw_hidden = "";
        }
        $hidden_css = "position: absolute; visibility: hidden;";
        $cachetype_options .= '<img id="cachetype_' . htmlspecialchars($record['id'], ENT_COMPAT, 'UTF-8') . '"    src="' . htmlspecialchars($stylepath . "/images/" . $cachetype_icon, ENT_COMPAT, 'UTF-8') . '" title="' . htmlspecialchars($record[$lang_db], ENT_COMPAT, 'UTF-8') . '" alt="' . htmlspecialchars($record[$lang_db], ENT_COMPAT, 'UTF-8') . '" onmousedown="javascript:switchCacheType(\'cachetype_' . htmlspecialchars($record['id'], ENT_COMPAT, 'UTF-8') . '\')" style="cursor: pointer;' . $icon_hidden . '" />';
        $cachetype_options .= '<img id="cachetype_' . htmlspecialchars($record['id'], ENT_COMPAT, 'UTF-8') . '_bw" src="' . htmlspecialchars($stylepath . "/images/" . $cachetype_icon_bw, ENT_COMPAT, 'UTF-8') . '" title="' . htmlspecialchars($record[$lang_db], ENT_COMPAT, 'UTF-8') . '" alt="' . htmlspecialchars($record[$lang_db], ENT_COMPAT, 'UTF-8') . '" onmousedown="javascript:switchCacheType(\'cachetype_' . htmlspecialchars($record['id'], ENT_COMPAT, 'UTF-8') . '\')" style="cursor: pointer;' . $icon_bw_hidden . '" />';
        if ($i == 2) {
            $cachetype_options .= '&nbsp;&nbsp;&nbsp;';
        }
        $cachetype_options .= "\n";
    }
    tpl_set_var('cachetype_options', $cachetype_options);
    //Rozmiar skrzynki
    $cachesize_options = '';
    if (checkField('cache_size', $lang)) {
        $lang_db = $lang;
    } else {
        $lang_db = "en";
    }
    $rs = sql('SELECT `id`, `&1` FROM `cache_size` ORDER BY `id`', $lang_db);
    for ($i = 0; $i < mysql_num_rows($rs); $i++) {
        $record = sql_fetch_array($rs);
        $cachesize_options .= '<input type="checkbox" name="cachesize_' . htmlspecialchars($record['id'], ENT_COMPAT, 'UTF-8') . '" value="1" id="l_cachesize_' . htmlspecialchars($record['id'], ENT_COMPAT, 'UTF-8') . '" class="checkbox" onclick="javascript:sync_options(this)" checked="checked" /><label for="l_cachesize_' . htmlspecialchars($record['id'], ENT_COMPAT, 'UTF-8') . '">' . htmlspecialchars($record[$lang_db], ENT_COMPAT, 'UTF-8') . '</label>';
        $cachesize_options .= "\n";
    }
    tpl_set_var('cachesize_options', $cachesize_options);
    // gpxlogLimit
    if ($options['gpxLogLimit'] == false) {
        tpl_set_var('gpxLogLimitUserChoice', 5);
    } else {
        tpl_set_var('gpxLogLimitUserChoice', $options['gpxLogLimit']);
    }
    function attr_jsline($tpl, $options, $id, $textlong, $iconlarge, $iconno, $iconundef, $category)
    {
        $line = $tpl;
        $line = mb_ereg_replace('{id}', $id, $line);
        if (array_search($id, $options['cache_attribs']) === false) {
            if (array_search($id, $options['cache_attribs_not']) === false) {
                $line = mb_ereg_replace('{state}', 0, $line);
            } else {
                $line = mb_ereg_replace('{state}', 2, $line);
            }
        } else {
            $line = mb_ereg_replace('{state}', 1, $line);
        }
        $line = mb_ereg_replace('{text_long}', addslashes($textlong), $line);
        $line = mb_ereg_replace('{icon}', $iconlarge, $line);
        $line = mb_ereg_replace('{icon_no}', $iconno, $line);
        $line = mb_ereg_replace('{icon_undef}', $iconundef, $line);
        $line = mb_ereg_replace('{category}', $category, $line);
        return $line;
    }
    function attr_image($tpl, $options, $id, $textlong, $iconlarge, $iconno, $iconundef, $category)
    {
        $line = $tpl;
        $line = mb_ereg_replace('{id}', $id, $line);
        $line = mb_ereg_replace('{text_long}', $textlong, $line);
        if (array_search($id, $options['cache_attribs']) === false) {
            if (array_search($id, $options['cache_attribs_not']) === false) {
                $line = mb_ereg_replace('{icon}', $iconundef, $line);
            } else {
                $line = mb_ereg_replace('{icon}', $iconno, $line);
            }
        } else {
            $line = mb_ereg_replace('{icon}', $iconlarge, $line);
        }
        return $line;
    }
    // cache-attributes
    $attributes_jsarray = '';
    $attributes_img = '';
    $attributesCat2_img = '';
    // select attributes depend on specified language.
    $database = new dataBase(false);
    $query = "SELECT `id`, `text_long`, `icon_large`, `icon_no`, `icon_undef`, `category` FROM `cache_attrib` WHERE `language` LIKE :1 ORDER BY `id`";
    $database->multiVariableQuery($query, strtoupper($lang));
    // if specified language is in database
    if ($database->rowCount() <= 0) {
        // if we have not specified language in db, just use english.
        $database->multiVariableQuery($query, 'EN');
    }
    $rs = $database->dbResultFetchAll();
    unset($database);
    foreach ($rs as $record) {
        // icon specified
        $line = attr_jsline($cache_attrib_jsarray_line, $options, $record['id'], $record['text_long'], $record['icon_large'], $record['icon_no'], $record['icon_undef'], $record['category']);
        if ($attributes_jsarray != '') {
            $attributes_jsarray .= ",\n";
        }
        $attributes_jsarray .= $line;
        $line = attr_image($cache_attrib_img_line, $options, $record['id'], $record['text_long'], $record['icon_large'], $record['icon_no'], $record['icon_undef'], $record['category']);
        if ($record['category'] != 1) {
            $attributesCat2_img .= $line;
        } else {
            $attributes_img .= $line;
        }
    }
    $line = attr_jsline($cache_attrib_jsarray_line, $options, "99", tr("with_password"), $config['search-attr-icons']['password'][0], $config['search-attr-icons']['password'][1], $config['search-attr-icons']['password'][2], 0);
    $attributes_jsarray .= ",\n" . $line;
    $line = attr_image($cache_attrib_img_line, $options, "99", tr("with_password"), $config['search-attr-icons']['password'][0], $config['search-attr-icons']['password'][1], $config['search-attr-icons']['password'][2], 0);
    $attributes_img .= $line;
    tpl_set_var('cache_attrib_list', $attributes_img);
    tpl_set_var('cache_attribCat2_list', $attributesCat2_img);
    tpl_set_var('attributes_jsarray', $attributes_jsarray);
    tpl_set_var('hidopt_attribs', implode(';', $options['cache_attribs']));
    tpl_set_var('hidopt_attribs_not', implode(';', $options['cache_attribs_not']));
    tpl_set_var('fulltext', '');
    tpl_set_var('ft_name_checked', 'checked="checked"');
    tpl_set_var('ft_desc_checked', '');
    tpl_set_var('ft_logs_checked', '');
    tpl_set_var('ft_pictures_checked', '');
    // fulltext options
    if ($options['searchtype'] == 'byfulltext') {
        if (!isset($options['fulltext'])) {
            $options['fulltext'] = '';
        }
        tpl_set_var('fulltext', htmlspecialchars($options['fulltext'], ENT_COMPAT, 'UTF-8'));
        if (isset($options['ft_name']) && $options['ft_name'] == 1) {
            tpl_set_var('ft_name_checked', 'checked="checked"');
        } else {
            tpl_set_var('ft_name_checked', '');
        }
        if (isset($options['ft_desc']) && $options['ft_desc'] == 1) {
            tpl_set_var('ft_desc_checked', 'checked="checked"');
        } else {
            tpl_set_var('ft_desc_checked', '');
        }
        if (isset($options['ft_logs']) && $options['ft_logs'] == 1) {
            tpl_set_var('ft_logs_checked', 'checked="checked"');
        } else {
            tpl_set_var('ft_logs_checked', '');
        }
        if (isset($options['ft_pictures']) && $options['ft_pictures'] == 1) {
            tpl_set_var('ft_pictures_checked', 'checked="checked"');
        } else {
            tpl_set_var('ft_pictures_checked', '');
        }
    }
    // errormeldungen
    tpl_set_var('ortserror', '');
    if (isset($options['error_plz'])) {
        tpl_set_var('ortserror', $error_plz);
    } else {
        if (isset($options['error_ort'])) {
            tpl_set_var('ortserror', $error_ort);
        } else {
            if (isset($options['error_locidnocoords'])) {
                tpl_set_var('ortserror', $error_locidnocoords);
            } else {
                if (isset($options['error_noort'])) {
                    tpl_set_var('ortserror', $error_noort);
                }
            }
        }
    }
    tpl_set_var('fulltexterror', isset($options['error_nofulltext']) ? $error_nofulltext : '');
    tpl_BuildTemplate();
    exit;
}
예제 #19
0
         //from mywatches_map.tpl.php
         $cookie->set("wcMapLatitude", $_REQUEST['wcMapLatitude']);
     }
     if (isset($_REQUEST['wcMapLongitude'])) {
         //from mywatches_map.tpl.php
         $cookie->set("wcMapLongitude", $_REQUEST['wcMapLongitude']);
     }
     if (isset($_REQUEST['wcMapWeather'])) {
         //from mywatches_map.tpl.php
         $cookie->set("wcMapWeather", $_REQUEST['wcMapWeather']);
     }
     $usrlatitude = 0;
     $usrlongitude = 0;
     $dbc->multiVariableQuery("SELECT `latitude` FROM user WHERE user_id=:1", sql_escape($usr['userid']));
     $record = $dbc->dbResultFetch();
     if ($dbc->rowCount() && $record["latitude"]) {
         $usrlatitude = $record["latitude"];
     }
     $dbc->multiVariableQuery("SELECT `longitude` FROM user WHERE user_id=:1", sql_escape($usr['userid']));
     $record = $dbc->dbResultFetch();
     if ($dbc->rowCount() && $record["longitude"]) {
         $usrlongitude = $record["longitude"];
     }
 }
 //get all caches watched
 //$rs = sql("SELECT `cache_watches`.`cache_id` AS `cache_id`, `caches`.`name` AS `name`, `caches`.`last_found` AS `last_found` FROM `cache_watches` INNER JOIN `caches` ON (`cache_watches`.`cache_id`=`caches`.`cache_id`) WHERE `cache_watches`.`user_id`='&1' ORDER BY `caches`.`name`", $usr['userid']);
 //$query = "SELECT `cache_watches`.`cache_id` AS `cache_id`, `caches`.`name` AS `name`, `caches`.`last_found` AS `last_found` FROM `cache_watches` INNER JOIN `caches` ON (`cache_watches`.`cache_id`=`caches`.`cache_id`) WHERE `cache_watches`.`user_id`= :1 ORDER BY `caches`.`name`";
 $query = "SELECT\n                        `cache_watches`.`cache_id` AS `cache_id`,\n                        `caches`.`name` AS `name`, `caches`.`last_found` AS `last_found`,\n                        `caches`.`latitude` `latitude`,\n                        `caches`.`longitude` `longitude`,\n                        caches.wp_oc AS wp,\n                        caches.type as cache_type,\n                        caches.user_id,\n                        cache_type.icon_small AS cache_icon_small,\n                        user.username AS user_name,\n                        log_types.icon_small AS icon_small,\n                        cl.text AS log_text,\n                        cl.type AS log_type,\n                        cl.user_id AS luser_id,\n                        cl.date AS log_date,\n                        cl.deleted as log_deleted,\n                        cl.id\n                        FROM `cache_watches`\n                        INNER JOIN `caches` ON (`cache_watches`.`cache_id`=`caches`.`cache_id`)\n                        INNER JOIN cache_type ON (caches.type = cache_type.id)\n\n                        left outer JOIN cache_logs as cl ON (caches.cache_id = cl.cache_id)\n                        left outer JOIN log_types ON (cl.type = log_types.id)\n                        left outer JOIN user ON (cl.user_id = user.user_id)\n\n\n                        WHERE `cache_watches`.`user_id`= :1 and\n                        ( cl.id is null or cl.id =\n                            ( SELECT id\n                                FROM cache_logs cl_id\n                                WHERE cl.cache_id = cl_id.cache_id and cl_id.date =\n\n                                    ( SELECT max( date )\n                                        FROM cache_logs\n                                        WHERE cl.cache_id = cache_id\n                                    )\n                                limit 1\n                            ))\n\n                        ORDER BY `caches`.`name`";
 $dbc->multiVariableQuery($query, $usr['userid']);
 //if (mysql_num_rows($rs) == 0)
 $rowCount = $dbc->rowCount();
예제 #20
0
global $dateFormat;
require_once './lib/common.inc.php';
db_disconnect();
//Preprocessing
if ($error == false) {
    //user logged in?
    if ($usr == false) {
        $target = urlencode(tpl_get_current_page());
        tpl_redirect('login.php?target=' . $target);
    } else {
        $tplname = 'logmap';
        $db = new dataBase();
        $query = "SELECT `cache_logs`.`id` FROM `cache_logs`, `caches` WHERE `cache_logs`.`cache_id`=`caches`.`cache_id` AND `cache_logs`.`deleted`=0 AND `caches`.`status` IN (1, 2, 3) AND `cache_logs`.`type` IN (1,2,3,4,5) ORDER BY  `cache_logs`.`date_created` DESC LIMIT 100";
        $db->simpleQuery($query);
        $cacheLogsCount = $db->rowCount();
        $log_ids = '';
        if ($cacheLogsCount == 0) {
            $log_ids = '0';
        }
        for ($i = 0; $i < $cacheLogsCount; $i++) {
            $record = $db->dbResultFetch();
            if ($i > 0) {
                $log_ids .= ', ' . $record['id'];
            } else {
                $log_ids = $record['id'];
            }
        }
        $query = "SELECT cache_logs.id, cache_logs.cache_id AS cache_id,\n                         cache_logs.type AS log_type,\n                         cache_logs.date AS log_date,\n                         cache_logs.user_id AS luser_id,\n                         caches.name AS cache_name,\n                         caches.wp_oc AS wp,\n                         user.username AS username,\n                         `caches`.`latitude` `latitude`,\n                         `caches`.`longitude` `longitude`,\n                         caches.type AS cache_type,\n                         cache_type.icon_small AS cache_icon_small,\n                         log_types.icon_small AS icon_small\n                         FROM (cache_logs INNER JOIN caches ON (caches.cache_id = cache_logs.cache_id)) INNER JOIN user ON (cache_logs.user_id = user.user_id) INNER JOIN log_types ON (cache_logs.type = log_types.id) INNER JOIN cache_type ON (caches.type = cache_type.id)\n                         WHERE cache_logs.deleted=0 AND cache_logs.id IN ( {$log_ids} )\n                         AND cache_logs.cache_id=caches.cache_id\n                         AND caches.status<> 4 AND caches.status<> 5 AND caches.status<> 6\n                         GROUP BY cache_logs.id\n                         ORDER BY cache_logs.date_created DESC";
        $db->simpleQuery($query);
        $point = "";
예제 #21
0
 $options['username'] = isset($_POST['username']) ? $_POST['username'] : '';
 if (!isset($options['username'])) {
     $options['username'] = '';
 }
 if ($options['username'] != '') {
     //$query = "SELECT user_id, username FROM user WHERE username LIKE '%" . sql_escape($options['username']) . "%' ORDER BY username ASC";;
     //$rs = sql($query);
     $query = "SELECT user_id, username, date_created FROM user WHERE username LIKE :username ORDER BY username ASC";
     $params = array("username" => array("value" => '%' . sql_escape($options['username']) . '%', "data_type" => "string"));
     $dbc = new dataBase();
     $dbc->paramQuery($query, $params);
     $bgcolor1 = '#eeeeee';
     $bgcolor2 = '#ffffff';
     $line = '<tr bgcolor={bgcolor}><td><a href=viewprofile.php?userid={user_id}>{username}</a></td><td>&nbsp;</td><td nowrap style="text-align:center;">{date_created}</td><td nowrap style="text-align:center;"></td></tr>';
     $lines = "";
     $ilosc = $dbc->rowCount();
     //if (mysql_num_rows($rs) != 0)
     if ($ilosc != 0) {
         if ($ilosc == 1) {
             $record = $dbc->dbResultFetch();
             tpl_redirect("viewprofile.php?userid=" . $record['user_id']);
         } else {
             //$ilosc=mysql_num_rows($rs);
             $linia = "Znaleziono {$ilosc} kont(a)</BR><UL>";
             //while ($record = sql_fetch_array($rs))
             $i = 0;
             while ($record = $dbc->dbResultFetch()) {
                 $tmp_line = $line;
                 $tmp_line = mb_ereg_replace('{bgcolor}', $i % 2 == 0 ? $bgcolor1 : $bgcolor2, $tmp_line);
                 $tmp_line = mb_ereg_replace('{username}', htmlspecialchars($record['username'], ENT_COMPAT, 'UTF-8'), $tmp_line);
                 $tmp_line = mb_ereg_replace('{user_id}', htmlspecialchars($record['user_id'], ENT_COMPAT, 'UTF-8'), $tmp_line);
예제 #22
0
//Preprocessing
if ($error == false) {
    //user logged in?
    if ($usr == false) {
        $target = urlencode(tpl_get_current_page());
        tpl_redirect('login.php?target=' . $target);
    } else {
        include $stylepath . '/myignores.inc.php';
        $tplname = 'myignores';
        tpl_set_var('title_text', $title_text);
        $dbc = new dataBase();
        //get all caches ignored
        //$rs = mysql_query('SELECT `cache_ignore`.`cache_id` AS `cache_id`, `caches`.`name` AS `name`, `caches`.`last_found` AS `last_found` FROM `cache_ignore` INNER JOIN `caches` ON (`cache_ignore`.`cache_id` = `caches`.`cache_id`) WHERE `cache_ignore`.`user_id`=\'' . addslashes($usr['userid']) . '\' ORDER BY `caches`.`name`', $dblink);
        $query = "SELECT `cache_ignore`.`cache_id` AS `cache_id`, `caches`.`name` AS `name`, `caches`.`last_found` AS `last_found` FROM `cache_ignore` INNER JOIN `caches` ON (`cache_ignore`.`cache_id` = `caches`.`cache_id`) WHERE `cache_ignore`.`user_id`= :1 ORDER BY `caches`.`name`";
        $dbc->multiVariableQuery($query, $usr['userid']);
        $rowCount = $dbc->rowCount();
        if ($rowCount == 0) {
            tpl_set_var('no_ignores', $no_ignores);
            tpl_set_var('ignores_caches', '');
            tpl_set_var('title_text_tab', '');
        } else {
            //tpl_set_var('title_text_tab', $title_text_lbl);
            tpl_set_var('no_ignores', '');
            $ignores = '';
            for ($i = 0; $i < $rowCount; $i++) {
                $record = $dbc->dbResultFetch();
                //$tmp_ignore = $i % 2 == 0 ? $ignoree : $ignoreo;
                $bgcolor = $i % 2 ? $bgcolor1 : $bgcolor2;
                $tmp_ignore = $ignore;
                $tmp_ignore = str_replace('{cachename}', htmlspecialchars($record['name']), $tmp_ignore);
                if ($record['last_found'] == NULL || $record['last_found'] == '0000-00-00 00:00:00') {
예제 #23
0
 // replace smilies in log-text with images
 // pictures
 $cachepicturelines = '';
 $append_atag = '';
 //  $rscpictures = sql("SELECT `pictures`.`url`, `pictures`.`title`, `pictures`.`uuid`, `pictures`.`user_id`,`pictures`.`object_id` FROM `pictures` WHERE `pictures`.`object_id`=&1 AND `pictures`.`object_type`=2 ORDER BY `pictures`.`date_created` ASC", $cache_id);
 if (!isset($dbc)) {
     $dbc = new dataBase();
 }
 $thatquery = "SELECT `pictures`.`url`, `pictures`.`title`, `pictures`.`uuid`, `pictures`.`user_id`,`pictures`.`object_id`, `pictures`.`spoiler` FROM `pictures` WHERE `pictures`.`object_id`=:v1 AND `pictures`.`object_type`=2 ORDER BY `pictures`.`seq`, `pictures`.`date_created` ASC";
 //// requires: ALTER TABLE `pictures` ADD `seq` SMALLINT UNSIGNED NOT NULL DEFAULT '1';
 $params['v1']['value'] = (int) $cache_id;
 $params['v1']['data_type'] = 'integer';
 $dbc->paramQuery($thatquery, $params);
 unset($params);
 //clear to avoid overlaping on next paramQuery (if any))
 $rscpictures_count = $dbc->rowCount();
 if ($rscpictures_count != 0) {
     tpl_set_var('cache_images_start', '');
     tpl_set_var('cache_images_end', '');
 } else {
     tpl_set_var('cache_images_start', '<!--');
     tpl_set_var('cache_images_end', '-->');
 }
 $rscpictures_all = $dbc->dbResultFetchAll();
 unset($dbc);
 //for ($j = 0; $j < mysql_num_rows($rscpictures); $j++)
 for ($j = 0; $j < $rscpictures_count; $j++) {
     //$pic_crecord = sql_fetch_array($rscpictures);
     $pic_crecord = $rscpictures_all[$j];
     $thisline = $cachepicture;
     if ($disable_spoiler_view && intval($pic_crecord['spoiler']) == 1) {