Beispiel #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;
}
Beispiel #2
0
function find_news($start, $end)
{
    global $tpl;
    global $lang;
    global $znalezione;
    $wp = mysql_real_escape_string($_GET['wp']);
    $query = "select id,type,user_id,date,text,deleted from cache_logs where cache_id = (select cache_id from caches where wp_oc = '" . $wp . "') order by date desc limit " . $start . "," . $end;
    $wynik = db_query($query);
    $query = "select name,cache_id from caches where cache_id = (select cache_id from caches where wp_oc = '" . $wp . "');";
    $wynik2 = db_query($query);
    $caches = mysql_fetch_assoc($wynik2);
    $tpl->assign("name", $caches['name']);
    // detailed cache access logging
    global $enable_cache_access_logs;
    if (@$enable_cache_access_logs) {
        if (!isset($dbc)) {
            $dbc = new dataBase();
        }
        $cache_id = $caches['cache_id'];
        $user_id = @$_SESSION['user_id'] > 0 ? $_SESSION['user_id'] : null;
        $access_log = @$_SESSION['CACHE_ACCESS_LOG_VL_' . $user_id];
        if ($access_log === null) {
            $_SESSION['CACHE_ACCESS_LOG_VL_' . $user_id] = array();
            $access_log = $_SESSION['CACHE_ACCESS_LOG_VL_' . $user_id];
        }
        if (@$access_log[$cache_id] !== true) {
            $dbc->multiVariableQuery('INSERT INTO CACHE_ACCESS_LOGS
                        (event_date, cache_id, user_id, source, event, ip_addr, user_agent, forwarded_for)
                     VALUES
                        (NOW(), :1, :2, \'M\', \'view_logs\', :3, :4, :5)', $cache_id, $user_id, $_SERVER['REMOTE_ADDR'], $_SERVER['HTTP_USER_AGENT'], $_SERVER['HTTP_X_FORWARDED_FOR']);
            $access_log[$cache_id] = true;
            $_SESSION['CACHE_ACCESS_LOG_VL_' . $user_id] = $access_log;
        }
    }
    $znalezione = array();
    while ($logs = mysql_fetch_assoc($wynik)) {
        if ($logs['deleted'] == 0) {
            $query = "select username from user where user_id = '" . $logs['user_id'] . "';";
            $wynik3 = db_query($query);
            $user = mysql_fetch_row($wynik3);
            $logs2['id'] = $logs['id'];
            $logs2['user_id'] = $logs['user_id'];
            $logs2['newtype'] = $logs['type'];
            $logs2['newdate'] = date('j.m.Y', strtotime($logs['date']));
            $logs2['username'] = $user[0];
            $logs2['newtext'] = html2log($logs['text']);
            $znalezione[] = $logs2;
        }
    }
    $tpl->assign("wp_oc", $wp);
    $tpl->assign("logs", $znalezione);
}
         $logfunctions = $functions_start . $tmpedit . $functions_middle . $tmpRevert . $functions_middle . $functions_end;
     }
 }
 $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);
function removeDbEntery($code)
{
    $db = new dataBase();
    $query = 'DELETE FROM `PowerTrail_cacheCandidate` WHERE `link` = :1';
    $db->multiVariableQuery($query, $code);
}
     tpl_set_var('username', 'Nicht gefunden');
     $userid = 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;
    $CalcCoordinates = true;
}
$distance_unit = 'km';
$sql = 'SELECT ';
if (isset($lat_rad) && isset($lon_rad)) {
    if ($CalcDistance) {
        $sql .= getCalcDistanceSqlFormula($usr !== false, $lon_rad * 180 / 3.14159, $lat_rad * 180 / 3.14159, 0, $multiplier[$distance_unit]) . ' `distance`, ';
    }
} else {
    if ($usr === false) {
        if ($CalcDistance) {
            $sql .= '0 distance, ';
        }
    } elseif ($CalcDistance) {
        //get the users home coords
        $dbc->multiVariableQuery("SELECT `latitude`, `longitude` FROM `user` WHERE `user_id`=:1", $usr['userid']);
        $record_coords = $dbc->dbResultFetch();
        if ($record_coords['latitude'] == NULL || $record_coords['longitude'] == NULL || ($record_coords['latitude'] == 0 || $record_coords['longitude'] == 0)) {
            $sql .= '0 distance, ';
        } else {
            //TODO: load from the users-profile
            $distance_unit = 'km';
            $lon_rad = $record_coords['longitude'] * 3.14159 / 180;
            $lat_rad = $record_coords['latitude'] * 3.14159 / 180;
            $sql .= getCalcDistanceSqlFormula($usr !== false, $record_coords['longitude'], $record_coords['latitude'], 0, $multiplier[$distance_unit]) . ' `distance`, ';
        }
        $dbc->reset();
    }
}
$sql .= '   `caches`.`name` `name`, `caches`.`status` `status`, `caches`.`wp_oc` `wp_oc`,
                `caches`.`difficulty` `difficulty`, `caches`.`terrain` `terrain`, `caches`.`desc_languages` `desc_languages`,
/**
 * after delete a log it is a good idea to full recalculate stats of user, that can avoid
 * possible errors which used to appear when was calculated old method.
 *
 * by Andrzej Łza Woźniak, 10-2013
 *
 */
function recalculateUserStats($userId)
{
    $query = "\n        UPDATE `user`\n        SET `founds_count`   = (SELECT count(*) FROM `cache_logs` WHERE `user_id` =:1 AND TYPE =1 AND `deleted` =0 ),\n            `notfounds_count`= (SELECT count(*) FROM `cache_logs` WHERE `user_id` =:1 AND TYPE =2 AND `deleted` =0 ),\n            `log_notes_count`= (SELECT count(*) FROM `cache_logs` WHERE `user_id` =:1 AND TYPE =3 AND `deleted` =0 )\n        WHERE `user_id` =:1\n    ";
    $db = new dataBase();
    $db->multiVariableQuery($query, $userId);
}
function getUserRow($userId)
{
    require_once __DIR__ . '/Database/Db.php';
    $db = new dataBase();
    $db->multiVariableQuery('SELECT username, hidden_count, log_notes_count, founds_count, notfounds_count, email, country, latitude, longitude FROM `user` WHERE `user_id`=:1', $userId);
    return $db->dbResultFetchOneRowOnly();
}
    // Another instance of the script is running - exit
    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
Beispiel #10
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;
}
 } else {
     $user_id = $usr['userid'];
 }
 tpl_set_var('userid', $user_id);
 require $stylepath . '/viewprofile.inc.php';
 require $stylepath . '/lib/icons.inc.php';
 $tplname = 'viewprofile';
 if ($user_id != $usr['userid']) {
     // do not highlight My stats menu item if browsing other users stats
     $mnu_siteid = 'start';
 }
 $stat_menu = array('title' => tr('Statictics'), 'menustring' => tr('Statictics'), 'siteid' => 'statlisting', 'navicolor' => '#E8DDE4', 'visible' => false, 'filename' => 'viewprofile.php?userid=' . $user_id, 'submenu' => array(array('title' => tr('graph_find'), 'menustring' => tr('graph_find'), 'visible' => true, 'filename' => 'ustatsg2.php?userid=' . $user_id, 'newwindow' => false, 'siteid' => 'findstat', 'icon' => 'images/actions/stat'), array('title' => tr('graph_created'), 'menustring' => tr('graph_created'), 'visible' => true, 'filename' => 'ustatsg1.php?userid=' . $user_id, 'newwindow' => false, 'siteid' => 'createstat', 'icon' => 'images/actions/stat')));
 $content = "";
 $database = new dataBase();
 $rddQuery = "select TO_DAYS(NOW()) - TO_DAYS(`date_created`) `diff` from `user` WHERE user_id=:1 ";
 $database->multiVariableQuery($rddQuery, $user_id);
 $ddays = $database->dbResultFetch();
 $query = "SELECT admin, guru, hidden_count, founds_count, is_active_flag, email, password, log_notes_count, notfounds_count, username, last_login, country, date_created, description, hide_flag FROM user WHERE user_id=:1 LIMIT 1";
 $database->multiVariableQuery($query, $user_id);
 $user_record = $database->dbResultFetch();
 tpl_set_var('username', $user_record['username']);
 if (date('m') == 4 and date('d') == 1) {
     tpl_set_var('username', tr('primaAprilis1'));
 }
 tpl_set_var('country', tr($user_record['country']));
 tpl_set_var('registered', fixPlMonth(strftime($dateformat, strtotime($user_record['date_created']))));
 $description = $user_record['description'];
 tpl_set_var('description', nl2br($description));
 if ($description != "") {
     tpl_set_var('description_start', '');
     tpl_set_var('description_end', '');
 /**
  * @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;
 }
Beispiel #13
0
 } else {
     if (isset($_GET['accept']) && $_GET['accept'] == 1) {
         $sql = "SELECT count(id) FROM chowner WHERE cache_id = :1 AND user_id = :2";
         $potwierdzenie = $db->multiVariableQueryValue($sql, 0, $_GET['cacheid'], $usr['userid']);
         if ($potwierdzenie > 0) {
             // zmiana wlasciciela
             tpl_set_var("error_msg", tr('adopt_30'));
             tpl_set_var("info_msg", "");
             $db->beginTransaction();
             require_once $rootpath . 'lib/cache_owners.inc.php';
             $pco = new OrgCacheOwners($db);
             $pco->populateForCache($_GET['cacheid']);
             $oldOwnerId = getCacheOwner($_GET['cacheid']);
             $isCachePublished = isCachePublished($_GET['cacheid']);
             $sql = "DELETE FROM chowner WHERE cache_id = :1 AND user_id = :2";
             $db->multiVariableQuery($sql, $_GET['cacheid'], $usr['userid']);
             if ($isCachePublished) {
                 $sql = "UPDATE caches SET user_id = :2, org_user_id = IF(org_user_id IS NULL, :3, org_user_id) WHERE cache_id= :1";
                 $db->multiVariableQuery($sql, $_GET['cacheid'], $usr['userid'], $oldOwnerId);
             } else {
                 $sql = "UPDATE caches SET user_id = :2 WHERE cache_id= :1";
                 $db->multiVariableQuery($sql, $_GET['cacheid'], $usr['userid']);
             }
             $sql = "UPDATE pictures SET user_id = :2 WHERE object_id = :1";
             $db->multiVariableQuery($sql, $_GET['cacheid'], $usr['userid']);
             // this should be kept consistent by a trigger
             //$sql = "UPDATE user SET hidden_count = hidden_count - 1 WHERE user_id = :1";
             //$db->multiVariableQuery($sql, $oldOwnerId);
             //$sql = "UPDATE user SET hidden_count = hidden_count + 1 WHERE user_id = :1";
             //$db->multiVariableQuery($sql, $usr['userid']);
             // ... but it's not
 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>";
 }
}
require_once './lib/common.inc.php';
//Preprocessing
if ($error == false) {
    $db = new dataBase();
    $description = "";
    //user logged in?
    if ($usr == false) {
        $target = urlencode(tpl_get_current_page());
        tpl_redirect('login.php?target=' . $target);
    } else {
        tpl_set_var('desc_updated', '');
        tpl_set_var('displayGeoPathSection', displayGeoPatchSection('table'));
        if (isset($_POST['description'])) {
            $sql = "UPDATE user SET description = :1 WHERE user_id=:2";
            $db->multiVariableQuery($sql, strip_tags($_POST['description']), (int) $usr['userid']);
            $db->reset();
            tpl_set_var('desc_updated', "<font color='green'>" . tr('desc_updated') . "</font>");
        }
        if (isset($_POST['submit'])) {
            $sql = "UPDATE user SET get_bulletin = :1 WHERE user_id = :2 ";
            $db->multiVariableQuery($sql, intval(sql_escape($_POST['bulletin'])), (int) $usr['userid']);
            $db->reset();
        }
        $sql = "SELECT description, get_bulletin FROM user WHERE user_id = :1 LIMIT 1";
        $db->multiVariableQuery($sql, (int) $usr['userid']);
        $userinfo = $db->dbResultFetchOneRowOnly();
        $description = $userinfo['description'];
        $bulletin = $userinfo['get_bulletin'];
        tpl_set_var('bulletin_label', $bulletin == 1 ? tr('bulletin_label_yes') : tr('bulletin_label_no'));
        tpl_set_var('bulletin_value', $bulletin);
 private function storeErrorsInDb($operationType, $dataSent, $response = null)
 {
     $db = new dataBase();
     $query = "INSERT INTO `GeoKretyAPIerrors`(`dateTime`, `operationType`, `dataSent`, `response`)\n                  VALUES (NOW(),:1,:2,:3)";
     $db->multiVariableQuery($query, $operationType, addslashes(serialize($dataSent)), addslashes(serialize($response)));
 }
 //user logged in?
 if ($usr == false) {
     $target = urlencode(tpl_get_current_page());
     tpl_redirect('login.php?target=' . $target);
 } else {
     $tplname = 'mycache_notes';
     //get user record
     $userid = $usr['userid'];
     $tr_COG = tr('cog_user_name');
     $no_found_date = '---';
     $db = new dataBase();
     if (isset($_REQUEST["delete"])) {
         $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>';
<?php

global $titled_cache_nr_found, $titled_cache_period_prefix;
require_once './lib/common.inc.php';
if (!isset($_REQUEST['CRON'])) {
    exit;
}
$dbc = new dataBase();
$start_date_alg = date("Y-m-d");
$date_alg = $start_date_alg;
$queryS = " \r\n    select\r\n    top.cacheId, top.cacheName, top.cacheRegion, ifnull( nrT.nrTinR, 0) nrTinR,\r\n    top.RATE, top.ratio, \r\n    top.cRating, top.cFounds, top.cNrDays, top.cDateCrt\r\n    \r\n    from\r\n    (\r\n    SELECT caches.cache_id cacheId , caches.name cacheName, adm3 cacheRegion,\r\n    user.user_id userId, user.username userName,\r\n    \r\n    round((r.rating/f.nr_founds) + DATEDIFF(caches.date_created, :1 )/5000,4) RATE, \r\n            round((r.rating/f.nr_founds), 4) ratio,\r\n    \r\n    r.rating cRating, f.nr_founds cFounds, caches.date_created cDateCrt,\r\n    DATEDIFF(caches.date_created, :1 ) cNrDays\r\n    \r\n    FROM `caches`\r\n    \r\n    JOIN\r\n    (\r\n    SELECT lcaches.cache_id cid, count(*) rating\r\n    FROM `caches` lcaches\r\n    INNER JOIN `cache_logs` ON `cache_logs`.`cache_id` = lcaches .`cache_id`\r\n    JOIN cache_rating ON `cache_rating`.`cache_id` = `cache_logs`.`cache_id`\r\n    AND `cache_rating`.`user_id` = `cache_logs`.user_id\r\n    where\r\n    `cache_logs`.`deleted` =0 AND `cache_logs`.`type` =1\r\n    and cache_logs.date_created < :1\r\n    \r\n    group by 1\r\n    )\r\n    as r ON r.cid = caches.cache_id\r\n    \r\n    JOIN\r\n    (\r\n    SELECT fcaches.cache_id cid, count(*) nr_founds\r\n    FROM\r\n    caches fcaches\r\n    JOIN cache_logs ON cache_logs.cache_id = fcaches.cache_id\r\n    \r\n    where\r\n    cache_logs.deleted=0 AND cache_logs.type=1\r\n    and cache_logs.date_created < :1\r\n    \r\n    group by 1\r\n    )\r\n    as f ON f.cid = caches.cache_id\r\n    \r\n    JOIN user ON `caches`.`user_id` = `user`.`user_id`\r\n    JOIN `cache_location` ON `caches`.`cache_id` = `cache_location`.`cache_id`\r\n    left JOIN cache_titled ON cache_titled.cache_id = caches.cache_id\r\n    \r\n    WHERE\r\n    `status` =1\r\n    AND `caches`.`type` <>4 AND `caches`.`type` <>5 AND caches.type <>6\r\n    and f.nr_founds >= :2 and caches.date_created < :1\r\n    and cache_titled.cache_id is NULL\r\n    \r\n    ORDER BY RATE DESC, founds DESC, caches.date_created DESC\r\n    LIMIT 30) as top\r\n    \r\n    left join\r\n    (\r\n    select adm3 cacheRegion, count(*) nrTinR from cache_titled\r\n    JOIN cache_location ON cache_titled.cache_id = cache_location.cache_id\r\n    group by adm3\r\n    ) as nrT on top.cacheRegion = nrT.cacheRegion\r\n    order by nrTinR, cFounds DESC, cDateCrt, RATE DESC\r\n    ";
$dbc->multiVariableQuery($queryS, $date_alg, $titled_cache_nr_found);
$rec = $dbc->dbResultFetch();
$queryL = "\r\n    SELECT i.id logId\r\n    FROM\r\n    (select cache_logs.id, cache_logs.cache_id from\r\n        cache_logs\r\n        where\r\n        cache_logs.cache_id = :1 and\r\n        cache_logs.id = \r\n            (select id from cache_logs cl\r\n            JOIN cache_rating ON `cache_rating`.`cache_id` = cl.`cache_id`\r\n            AND `cache_rating`.`user_id` = cl.user_id\r\n            where cl.cache_id = cache_logs.cache_id\r\n            ORDER BY length(cl.text) DESC LIMIT 1 ) \r\n    ) as i";
$dbc->multiVariableQuery($queryL, $rec["cacheId"]);
$recL = $dbc->dbResultFetch();
$queryI = "INSERT INTO cache_titled \r\n        (cache_id, rate, ratio, rating, found, days, date_alg, log_id) \r\n        VALUES (:1, :2, :3, :4, :5, :6, :7, :8)";
$dbc->multiVariableQuery($queryI, $rec["cacheId"], $rec["RATE"], $rec["ratio"], $rec["cRating"], $rec["cFounds"], $rec["cNrDays"], $date_alg, $recL["logId"]);
$queryLogI = "INSERT INTO cache_logs \r\n            (cache_id, user_id, type, date, \r\n            text, text_html, text_htmledit, last_modified , okapi_syncbase, uuid, picturescount, mp3count, \r\n            date_created, owner_notified, node, deleted, encrypt, \r\n            del_by_user_id, last_deleted, edit_by_user_id, edit_count )\r\n    VALUES ( :1, :2, :3, :4, :5, :6, :7, :8 , :9 , :10, :11, :12, :13, :14, :15, '0', '0', NULL , NULL , NULL , '0' )";
$SystemUser = -1;
$LogType = 12;
//OCTeam
$ntitled_cache = $titled_cache_period_prefix . '_titled_cache_congratulations';
$msgText = tr($ntitled_cache);
$LogUuid = create_uuid();
$dbc->multiVariableQuery($queryLogI, $rec["cacheId"], $SystemUser, $LogType, $date_alg, $msgText, '1', '1', $date_alg, $date_alg, $LogUuid, '0', '0', $date_alg, '0', $oc_nodeid);
unset($dbc);
Beispiel #19
0
/**
 * after add a log it is a good idea to full recalculate stats of cache, that can avoid
 * possible errors which used to appear when was calculated old method.
 *
 * TODO: (regarding issue #138)
 * 1. recalculate last_found from DB
 * 2. make this method a library method or so
 * 3. use this method in other places, where such recalculation is needed
 *
 * by Andrzej Łza Woźniak, 12-2013
 */
function recalculateCacheStats($cacheId, $cacheType, $lastFoundQueryString)
{
    if ($cacheType == 6) {
        // event (no idea who developed so irracional rules, not me!)
        $query = "\n            UPDATE `caches`\n            SET `founds`   = (SELECT count(*) FROM `cache_logs` WHERE `cache_id` =:1 AND TYPE =7 AND `deleted` =0 ),\n                `notfounds`= (SELECT count(*) FROM `cache_logs` WHERE `cache_id` =:1 AND TYPE =8 AND `deleted` =0 ),\n                `notes`= (SELECT count(*) FROM `cache_logs` WHERE `cache_id` =:1 AND TYPE =3 AND `deleted` =0 )\n            {$lastFoundQueryString}\n            WHERE `cache_id` =:1\n        ";
    } else {
        $query = "\n            UPDATE `caches`\n            SET `founds`   = (SELECT count(*) FROM `cache_logs` WHERE `cache_id` =:1 AND TYPE =1 AND `deleted` =0 ),\n                `notfounds`= (SELECT count(*) FROM `cache_logs` WHERE `cache_id` =:1 AND TYPE =2 AND `deleted` =0 ),\n                `notes`= (SELECT count(*) FROM `cache_logs` WHERE `cache_id` =:1 AND TYPE =3 AND `deleted` =0 )\n            {$lastFoundQueryString}\n            WHERE `cache_id` =:1\n        ";
    }
    $db = new dataBase();
    $db->multiVariableQuery($query, $cacheId);
}
Beispiel #20
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();
Beispiel #21
0
if ($BlogSwitchOn) {
    tpl_set_var('blogDisplay', 'block');
} 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);
     }
     if ($bOK == true) {
         if ($nHour < 24 && $nHour >= 0 && $nDay < 8 && $nDay > 0 && $nMode < 4 && $nMode >= 0) {
             $bOK = true;
         } else {
             $bOK = false;
         }
     }
     if ($bOK == true) {
         /* sql("UPDATE `user` SET `watchmail_mode`='&1', `watchmail_hour`='&2', `watchmail_day`='&3' WHERE `user_id`='&4'",
            $nMode,
            $nHour,
            $nDay,
            $usr['userid']); */
         $query = "UPDATE `user` SET `watchmail_mode`=:1, `watchmail_hour`=:2, `watchmail_day`=:3 WHERE `user_id`=:4";
         $dbc->multiVariableQuery($query, $nMode, $nHour, $nDay, $usr['userid']);
         tpl_set_var('commit', $commit);
     } else {
         tpl_set_var('commit', $commiterr);
     }
 } else {
     tpl_set_var('commit', '');
 }
 // einstellungen auslesen
 $rs = sql("SELECT `watchmail_mode`, `watchmail_hour`, `watchmail_day` FROM `user` WHERE `user_id`='&1'", $usr['userid']);
 $r = sql_fetch_array($rs);
 mysql_free_result($rs);
 $tmpOptions = "";
 for ($i = 0; $i < 24; $i++) {
     $tmpOptions .= sprintf("<option value='%d' %s>%02d:00</option>\n", $i, $i == $r['watchmail_hour'] ? "selected='selected'" : "", $i);
 }
require_once './lib/common.inc.php';
//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);
 // detailed cache access logging
 global $enable_cache_access_logs;
 if (@$enable_cache_access_logs) {
     if (!isset($dbc)) {
         $dbc = new dataBase();
     }
     $cache_id = $caches['cache_id'];
     $user_id = @$_SESSION['user_id'] > 0 ? $_SESSION['user_id'] : null;
     $access_log = @$_SESSION['CACHE_ACCESS_LOG_VC_' . $user_id];
     if ($access_log === null) {
         $_SESSION['CACHE_ACCESS_LOG_VC_' . $user_id] = array();
         $access_log = $_SESSION['CACHE_ACCESS_LOG_VC_' . $user_id];
     }
     if (@$access_log[$cache_id] !== true) {
         $dbc->multiVariableQuery('INSERT INTO CACHE_ACCESS_LOGS
                     (event_date, cache_id, user_id, source, event, ip_addr, user_agent, forwarded_for)
                  VALUES
                     (NOW(), :1, :2, \'M\', \'view_cache\', :3, :4, :5)', $cache_id, $user_id, $_SERVER['REMOTE_ADDR'], $_SERVER['HTTP_USER_AGENT'], $_SERVER['HTTP_X_FORWARDED_FOR']);
         $access_log[$cache_id] = true;
         $_SESSION['CACHE_ACCESS_LOG_VC_' . $user_id] = $access_log;
     }
 }
 $query = "select username from user where user_id = " . $caches['user_id'] . ";";
 $wynik = db_query($query);
 $user = mysql_fetch_row($wynik);
 $query = "select cache_desc.desc,hint,short_desc from cache_desc where cache_id ='" . $caches['cache_id'] . '\'';
 $query .= ' order by field(`language`, \'pl\', \'en\', \'de\', \'nl\') ASC;';
 $wynik = db_query($query);
 $i = 0;
 while ($rekord = mysql_fetch_assoc($wynik)) {
     if ($i > 0) {
         $cache_desc['desc'] .= "<br/><br/>";
Beispiel #25
0
    $sPN = $nPeriod . $sPeriodName;
    echo "gcb.addColumn('number', '{$sPN}');";
    $i = $i + 1;
}
////////////////////
//echo " var chartOpt = gcb.getChartOption();";
//echo " chartOpt.vAxis.title= '".tr2('NrCaches',$lang)."';";
echo "</script>";
unset($dbc);
////////////////////////////
foreach ($asUserID as $sID) {
    $sCondition = " and cl.user_id = '" . $sID . "'";
    $sCondition .= $sDateCondition;
    $dbc = new dataBase();
    $query = "SELECT u.username username, u.user_id user_id,\n            " . $sGranulate . ",\n            COUNT(*) count\n\n            FROM\n            cache_logs cl\n            join caches c on c.cache_id = cl.cache_id\n            join user u on cl.user_id = u.user_id\n\n            WHERE cl.deleted=0 " . $sTypeCondition . $sCondition . "GROUP BY period";
    $dbc->multiVariableQuery($query);
    echo "<script type='text/javascript'>";
    $nStart = 1;
    while ($record = $dbc->dbResultFetch()) {
        $nPeriod = $record['period'];
        $nVal = $record['count'];
        if ($nStart == 1) {
            $sUserName = $record['username'];
            $sUserName = str_replace("'", "`", $sUserName);
            $nUserId = $record['user_id'];
            echo "\n            gcb.addEmptyRow();\n            gcb.addToLastRow( 0, '{$sUserName}' );\n            ";
            $nStart = 0;
        }
        $nrCol = $aNrColumn[$nPeriod];
        echo "gcb.addToLastRow( {$nrCol}+1 , {$nVal} );";
    }
        $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);
}