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>";
 }
    echo "Another instance of run_notify.php is currently running.\nExiting.\n";
    fclose($lock_file);
    exit;
}
// No other instance - do normal processing
$db = new dataBase();
$rsNotifyQuery = " SELECT  `notify_waiting`.`id`, `notify_waiting`.`cache_id`, `notify_waiting`.`type`,\n                `user`.`username`, user.user_id as cache_owner_id,\n                user.hidden_count as hidden, user.notfounds_count as dnf, user.founds_count as found,\n                `user2`.`email`, `user2`.`username` as `recpname`, `user2`.`latitude` as `lat1`, `user2`.`longitude` as `lon1`, `user2`.`user_id` as `recid`,\n                `caches`.`name` as `cachename`, `caches`.`date_hidden`, `caches`.`latitude` as `lat2`, `caches`.`longitude` as `lon2`, `caches`.`wp_oc`,\n                `caches`.`type` as `cachetype`,\n                `caches`.`size` as `cachesize`\n            FROM `notify_waiting`, `caches`, `user`, `user` `user2`\n            WHERE `notify_waiting`.`cache_id`=`caches`.`cache_id`\n              AND `notify_waiting`.`user_id`=`user2`.`user_id`\n              AND `caches`.`user_id`=`user`.`user_id`\n              AND `notify_waiting`.`id` > :1\n            ORDER BY `notify_waiting`.`id`\n            LIMIT 0,100\n";
/* init caches container */
$cacheCntainer = cache::instance();
$cacheTypes = $cacheCntainer->getCacheTypes();
$cacheSizes = $cacheCntainer->getCacheSizes();
$cacheTypeIcons = $cacheCntainer->getCacheTypeIcons();
$id = 0;
do {
    $db->multiVariableQuery($rsNotifyQuery, $id);
    $rsNotify = $db->dbResultFetchAll();
    foreach ($rsNotify as $rNotify) {
        $id = $rNotify['id'];
        /* send out everything that has to be sent */
        if (process_new_cache($rNotify) == 0) {
            $db->multiVariableQuery("DELETE FROM `notify_waiting` WHERE `id` =:1", $rNotify['id']);
        }
    }
    if (count($rsNotify) > 0) {
        sleep(5);
    } else {
        break;
    }
} while (true);
// Release lock
fclose($lock_file);
Example #3
0
 } else {
     $pages .= '{last_img_inactive}';
 }
 $caches_query = "\n            SELECT\n                `caches`.`cache_id`,\n                `caches`.`name`,\n                `date_hidden`,\n                `status`,cache_type.icon_small AS cache_icon_small,\n                `cache_status`.`id` AS `cache_status_id`,\n                `caches`.`founds` AS `founds`,\n                `caches`.`topratings` AS `topratings`,\n                datediff(now(),`caches`.`last_found` ) as `ilosc_dni`,\n                datediff(now(),`caches`.`last_modified` ) as `dni_od_zmiany`,\n                COUNT(`gk_item`.`id`) AS `gkcount`,\n                COALESCE(`cv`.`count`,0) AS `visits`\n            FROM `caches`\n                LEFT JOIN `gk_item_waypoint` ON `gk_item_waypoint`.`wp` = `caches`.`wp_oc`\n                LEFT JOIN `gk_item`\n                    ON `gk_item`.`id` = `gk_item_waypoint`.`id`\n                        AND `gk_item`.`stateid`<>1\n                        AND `gk_item`.`stateid`<>4\n                        AND `gk_item`.`typeid`<>2\n                        AND `gk_item`.`stateid` <>5\n                LEFT JOIN (\n                    SELECT\n                        `count`,\n                        `user_id_ip`,\n                        `cache_id`\n                    FROM `cache_visits`\n                    WHERE `user_id_ip`=0\n                    ) `cv`\n                    ON `caches`.`cache_id` = `cv`.`cache_id`\n                INNER JOIN `cache_type` ON (`caches`.`type` = `cache_type`.`id`),\n                `cache_status`\n            WHERE\n                `user_id`=:user_id\n                AND `cache_status`.`id`=`caches`.`status`\n                AND `caches`.`status` = :stat_cache\n            GROUP BY `caches`.`cache_id`\n            ORDER BY `{$sort_warunek}` {$sort_txt}\n            LIMIT " . intval($start) . ", " . intval($LOGS_PER_PAGE);
 //$params['v1']['value'] = (string) $lang_db;;
 //$params['v1']['data_type'] = 'string';
 $params['user_id']['value'] = (int) $user_id;
 $params['user_id']['data_type'] = 'integer';
 $params['stat_cache']['value'] = (int) $stat_cache;
 $params['stat_cache']['data_type'] = 'integer';
 if (!isset($dbc)) {
     $dbc = new dataBase();
 }
 $dbc->paramQuery($caches_query, $params);
 unset($params);
 $log_record_all = $dbc->dbResultFetchAll();
 $log_record_count = count($log_record_all);
 $file_content = '';
 //while ($log_record=sql_fetch_assoc($rs))
 //prepare second queryt
 $logs_query = "\n            SELECT\n                cache_logs.id,\n                cache_logs.type AS log_type,\n                cache_logs.text AS log_text,\n                DATE_FORMAT(cache_logs.date,'%Y-%m-%d') AS log_date,\n                caches.user_id AS cache_owner,\n                cache_logs.encrypt encrypt,\n                cache_logs.user_id AS luser_id,\n                user.username AS user_name,\n                user.user_id AS user_id,\n                log_types.icon_small AS icon_small,\n                datediff(now(),`cache_logs`.`date_created`) as `ilosc_dni`\n            FROM\n                cache_logs\n                JOIN caches USING (cache_id)\n                JOIN user ON (cache_logs.user_id=user.user_id)\n                JOIN log_types ON (cache_logs.type = log_types.id)\n            WHERE\n                cache_logs.deleted=0 AND\n                `cache_logs`.`cache_id`=:v1\n            ORDER BY `cache_logs`.`date_created` DESC\n            LIMIT 5";
 $edit_geocache_tr = tr('mc_edit_geocache');
 for ($zz = 0; $zz < $log_record_count; $zz++) {
     $log_record = $log_record_all[$zz];
     $tabelka = '';
     $tabelka .= '<td style="width: 90px;">' . htmlspecialchars(date($dateFormat, strtotime($log_record['date_hidden'])), ENT_COMPAT, 'UTF-8') . '</td>';
     $tabelka .= '<td ><a href="editcache.php?cacheid=' . htmlspecialchars($log_record['cache_id'], ENT_COMPAT, 'UTF-8') . '"><img src="tpl/stdstyle/images/free_icons/pencil.png" alt="' . $edit_geocache_tr . '" title="' . $edit_geocache_tr . '"/></a></td>';
     $tabelka .= '<td >&nbsp;<img src="tpl/stdstyle/images/' . $log_record['cache_icon_small'] . '" border="0" alt=""/></td>';
     $tabelka .= '<td><b><a class="links" href="viewcache.php?cacheid=' . htmlspecialchars($log_record['cache_id'], ENT_COMPAT, 'UTF-8') . '">' . htmlspecialchars($log_record['name'], ENT_COMPAT, 'UTF-8') . '</a></b></td>';
     $tabelka .= '<td align="right">&nbsp;' . intval($log_record['founds']) . '&nbsp;</td>';
     $tabelka .= '<td  align="right">&nbsp;' . intval($log_record['topratings']) . '&nbsp;</td>';
<?php

$rootpath = __DIR__ . DIRECTORY_SEPARATOR;
require_once $rootpath . 'lib/common.inc.php';
$db = new dataBase();
$countryCode = addslashes($_REQUEST['countryCode']);
$selectedRegion = $_REQUEST['selectedRegion'];
$query = "SELECT `code`, `name` FROM `nuts_codes` WHERE `code` LIKE '" . $countryCode . "__' ORDER BY `name` COLLATE utf8_polish_ci ASC";
$db->simpleQuery($query);
$regons = $db->dbResultFetchAll();
if (count($regons) == 0) {
    if (isset($_REQUEST['searchForm']) && $_REQUEST['searchForm'] == 1) {
        $regionoptions = '<option value="">' . tr('search01') . '</option>';
    } else {
        $regionoptions = '<option value="-1">-</option>';
    }
} else {
    if (isset($_REQUEST['searchForm']) && $_REQUEST['searchForm'] == 1) {
        $regionoptions = '<option value="">' . tr('search01') . '</option>';
    } else {
        $regionoptions = '<option value="0">' . tr('select_regions') . '</option>';
    }
    foreach ($regons as $record) {
        if ($record['code'] == $selectedRegion) {
            $regionoptions .= '<option value="' . htmlspecialchars($record['code'], ENT_COMPAT, 'UTF-8') . '" selected="selected" >' . htmlspecialchars($record['name'], ENT_COMPAT, 'UTF-8') . '</option>';
        } else {
            $regionoptions .= '<option value="' . htmlspecialchars($record['code'], ENT_COMPAT, 'UTF-8') . '">' . htmlspecialchars($record['name'], ENT_COMPAT, 'UTF-8') . '</option>';
        }
        $regionoptions .= "\n";
    }
}
Example #5
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;
}
Example #6
0
     //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++) {
             $tmpline1 = $mp3line;
Example #7
0
<?php

/**
 * text cache founded statistics year 2 year.
 * All caches in database.
 */
header('Content-type: text/html; charset=utf-8');
require_once __DIR__ . '/lib/ClassPathDictionary.php';
$db = new dataBase();
$query = "SELECT `date_hidden`\nFROM `caches` , cache_location\nWHERE cache_location.code3 = 'PL21'\nAND cache_location.cache_id = caches.cache_id\nORDER BY `date_hidden`\n";
$query = "SELECT `date_hidden`, cache_location.code3, cache_location.adm3\nFROM `caches`, cache_location\nWHERE cache_location.cache_id = caches.cache_id\nORDER BY `date_hidden`\n";
$db->simpleQuery($query);
$arr = $db->dbResultFetchAll();
print '<pre>';
// print_r($arr);
foreach ($arr as $value) {
    $data = explode('-', $value['date_hidden']);
    if (!isset($count[$data[0]])) {
        $count[$data[0]] = 0;
    }
    $count[$data[0]]++;
    if (!isset($region[$value['adm3']][$data[0]])) {
        $region[$value['adm3']][$data[0]] = 0;
    }
    $region[$value['adm3']][$data[0]]++;
}
print 'region <br>';
print '[rok] => ilosc utworzonych keszy w danym roku<br><br>';
print 'caly opencaching.pl:<br>';
print_r($count);
print 'regiony: <br>';
 /**
  *
  * @@param array $opt -  database accesing data from opencaching config
  * @param float $lat geografical latitude (coordinates)
  * @param float $lon geografical longitude (coordinates)
  *
  * @return array with code and names of regions selected from input geografical coordinates.void
  */
 public function GetRegion($lat, $lon)
 {
     require_once __DIR__ . '/lib/gis/gis.class.php';
     $lat_float = (double) $lat;
     $lon_float = (double) $lon;
     $sCode = '';
     $tmpqery = "SELECT `level`, `code`, AsText(`shape`) AS `geometry` FROM `nuts_layer` WHERE WITHIN(GeomFromText('POINT({$lon}  {$lat})'), `shape`) ORDER BY `level` DESC";
     $db = new dataBase();
     $db->simpleQuery($tmpqery);
     $rsLayers = $db->dbResultFetchAll();
     foreach ($rsLayers as $rLayers) {
         if (gis::ptInLineRing($rLayers['geometry'], 'POINT(' . $lon . ' ' . $lat . ')')) {
             $sCode = $rLayers['code'];
             break;
         }
     }
     if ($sCode != '') {
         $adm1 = null;
         $code1 = null;
         $adm2 = null;
         $code2 = null;
         $adm3 = null;
         $code3 = null;
         $adm4 = null;
         $code4 = null;
         if (mb_strlen($sCode) > 5) {
             $sCode = mb_substr($sCode, 0, 5);
         }
         if (mb_strlen($sCode) == 5) {
             $code4 = $sCode;
             $q = "SELECT `name` FROM `nuts_codes` WHERE `code`='{$sCode}'";
             $db->simpleQuery($q);
             $re = $db->dbResultFetch();
             $adm4 = $re["name"];
             unset($re, $q);
             $sCode = mb_substr($sCode, 0, 4);
         }
         if (mb_strlen($sCode) == 4) {
             $code3 = $sCode;
             $q = "SELECT `name` FROM `nuts_codes` WHERE `code`='{$sCode}'";
             $db->simpleQuery($q);
             $re = $db->dbResultFetch();
             $adm3 = $re["name"];
             unset($re, $q);
             $sCode = mb_substr($sCode, 0, 3);
         }
         if (mb_strlen($sCode) == 3) {
             $code2 = $sCode;
             $q = "SELECT `name` FROM `nuts_codes` WHERE `code`='{$sCode}'";
             $db->simpleQuery($q);
             $re = $db->dbResultFetch();
             $adm2 = $re["name"];
             unset($re, $q);
             $sCode = mb_substr($sCode, 0, 2);
         }
         if (mb_strlen($sCode) == 2) {
             $code1 = $sCode;
             // try to get localised name first
             $q = "SELECT `countries`.`pl` FROM `countries` WHERE `countries`.`short`='{$sCode}'";
             // TODO: country column should be localized
             $db->simpleQuery($q);
             $re = $db->dbResultFetch();
             $adm1 = $re["pl"];
             unset($re, $q);
             if ($adm1 == null) {
                 $q = "SELECT `name` FROM `nuts_codes` WHERE `code`='{$sCode}'";
                 $db->simpleQuery($q);
                 $re = $db->dbResultFetch();
                 $adm1 = $re["name"];
                 unset($re, $q);
             }
         }
         $wynik['adm1'] = $adm1;
         $wynik['adm2'] = $adm2;
         $wynik['adm3'] = $adm3;
         $wynik['adm4'] = $adm4;
         $wynik['code1'] = $code1;
         $wynik['code2'] = $code2;
         $wynik['code3'] = $code3;
         $wynik['code4'] = $code4;
     } else {
         $wynik = false;
     }
     return $wynik;
 }
Example #9
0
     $show_deleted_logs2 = " AND `cache_logs`.`deleted` = 0 ";
 }
 $thatquery = "SELECT `cache_logs`.`user_id` `userid`,\n                    " . $show_deleted_logs . "\n                    `cache_logs`.`id` AS `log_id`,\n                    `cache_logs`.`encrypt` `encrypt`,\n                    `cache_logs`.`picturescount` AS `picturescount`,\n                    `cache_logs`.`user_id` AS `user_id`,\n                    `cache_logs`.`date` AS `date`,\n                    `cache_logs`.`type` AS `type`,\n                    `cache_logs`.`text` AS `text`,\n                    `cache_logs`.`text_html` AS `text_html`,\n                    `cache_logs`.`last_modified` AS `last_modified`,\n                    `cache_logs`.`last_deleted` AS `last_deleted`,\n                    `cache_logs`.`edit_count` AS `edit_count`,\n                    `cache_logs`.`date_created` AS `date_created`,\n                    `user`.`username` AS `username`,\n                    `user`.`hidden_count` AS    `ukryte`,\n                    `user`.`founds_count` AS    `znalezione`,\n                    `user`.`notfounds_count` AS `nieznalezione`,\n                    `user`.`admin` AS `admin`,\n                    `u2`.`username` AS `del_by_username`,\n                    `u2`.`admin` AS `del_by_admin`,\n                    `u3`.`username` AS `edit_by_username`,\n                    `u3`.`admin` AS `edit_by_admin`,\n                    `log_types`.`icon_small` AS `icon_small`,\n                    `cache_moved`.`longitude` AS `mobile_longitude`,\n                    `cache_moved`.`latitude` AS `mobile_latitude`,\n                    `cache_moved`.`km` AS `km`,\n\n                IF(ISNULL(`cache_rating`.`cache_id`), 0, 1) AS `recommended`\n                FROM `cache_logs`\n                INNER JOIN `log_types` ON `log_types`.`id`=`cache_logs`.`type`\n\n                INNER JOIN `user` ON `user`.`user_id` = `cache_logs`.`user_id`\n                LEFT JOIN `cache_moved` ON `cache_moved`.`log_id` = `cache_logs`.`id`\n                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 `user` `u2` ON `cache_logs`.`del_by_user_id`=`u2`.`user_id`\n                LEFT JOIN `user` `u3` ON `cache_logs`.`edit_by_user_id`=`u3`.`user_id`\n                WHERE `cache_logs`.`cache_id`=:v1\n                " . $show_deleted_logs2 . "\n                " . $show_one_log . "\n                ORDER BY `cache_logs`.`date` DESC, `cache_logs`.`Id` DESC LIMIT :v2, :v3";
 $params['v1']['value'] = (int) $cache_id;
 $params['v1']['data_type'] = 'integer';
 $params['v2']['value'] = (int) $start;
 $params['v2']['data_type'] = 'integer';
 $params['v3']['value'] = (int) $count;
 $params['v3']['data_type'] = 'integer';
 $dbc->paramQuery($thatquery, $params);
 $logs = '';
 $thisdateformat = $dateformat;
 $thisdatetimeformat = $datetimeformat;
 $edit_count_date_from = date_create('2005-01-01 00:00');
 $logs_count = $dbc->rowCount();
 $all_rec = $dbc->dbResultFetchAll();
 for ($i = 0; $i < $logs_count; $i++) {
     //$record = sql_fetch_array($rs);
     //$record = $dbc->dbResultFetch();
     $record = $all_rec[$i];
     $record['text_listing'] = ucfirst(tr('logType' . $record['type']));
     //add new attrib 'text_listing based on translation (instead of query as before)'
     $show_deleted = "";
     $processed_text = "";
     if (isset($record['deleted']) && $record['deleted']) {
         if ($usr['admin']) {
             $show_deleted = "show_deleted";
             $processed_text = $record['text'];
         } else {
             // BoguĊ› z Polska, 2014-11-15
             // for 'Needs maintenance', 'Ready to search' and 'Temporarly unavailable' log types
Example #10
0
 /**
  * @param type $db
  */
 public static function getUserActiveCacheCountByType(dataBase $db, $userId)
 {
     $query = 'SELECT type, count(*) as cacheCount FROM `caches` WHERE `user_id` = :1 AND STATUS !=3 GROUP by type';
     $db->multiVariableQuery($query, $userId);
     $userCacheCountByType = $db->dbResultFetchAll();
     $cacheLimitByTypePerUser = array();
     foreach ($userCacheCountByType as $cacheCount) {
         $cacheLimitByTypePerUser[$cacheCount['type']] = $cacheCount['cacheCount'];
     }
     return $cacheLimitByTypePerUser;
 }
 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>";
 }
 public static function getErrorsFromDb()
 {
     $db = new dataBase();
     $query = "SELECT * FROM `GeoKretyAPIerrors` WHERE 1";
     $db->simpleQuery($query);
     return $db->dbResultFetchAll();
 }
Example #13
0
        $tos = false;
    }
    tpl_set_var('email', htmlspecialchars($email, ENT_COMPAT, 'UTF-8'));
    tpl_set_var('username', htmlspecialchars($username, ENT_COMPAT, 'UTF-8'));
    //make countries list
    if ($country == 'XX') {
        $stmp = '<option value="XX" selected="selected">' . $no_answer . '</option>';
    } else {
        $stmp = '<option value="XX">' . $no_answer . '</option>';
    }
    if ($display_all_countries == 0) {
        tpl_set_var('all_countries_submit', '<input type="submit" name="show_all_countries_submit" value="' . $allcountries . '" />');
    } else {
        $query = 'SELECT `short` FROM `countries` WHERE 1 ORDER BY `short` ASC';
        $db->simpleQuery($query);
        $dbResult = $db->dbResultFetchAll();
        foreach ($dbResult as $key => $value) {
            $defaultCountryList[] = $value['short'];
        }
    }
    foreach ($defaultCountryList as $countryCode) {
        if ($country == $countryCode) {
            $stmp .= '<option value="' . $countryCode . '" selected="selected">' . htmlspecialchars(tr($countryCode), ENT_COMPAT, 'UTF-8') . "</option>\n";
        } else {
            $stmp .= '<option value="' . $countryCode . '">' . htmlspecialchars(tr($countryCode), ENT_COMPAT, 'UTF-8') . "</option>\n";
        }
    }
    tpl_set_var('countries_list', $stmp);
    unset($stmp);
    tpl_set_var('show_all_countries', $display_all_countries);
}
 $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) {
         // 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_crecord['url'], $thisline);
         $thisline = mb_ereg_replace('{longdesc}', str_replace("uploads", "uploads", $pic_crecord['url']), $thisline);