コード例 #1
0
ファイル: query.php プロジェクト: kojoty/opencaching-pl
function viewqueries()
{
    global $tplname, $usr;
    global $viewquery_line, $noqueries, $bgcolor1, $bgcolor2;
    $tplname = 'viewqueries';
    $dbc = OcDb::instance();
    $i = 0;
    $content = '';
    $query = "SELECT id, name FROM `queries` WHERE `user_id`=:1 ORDER BY `name` ASC";
    $s = $dbc->multiVariableQuery($query, $usr['userid']);
    if ($dbc->rowCount($s) != 0) {
        while ($r = $dbc->dbResultFetch($s)) {
            $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++;
        }
    } else {
        $content = $noqueries;
    }
    unset($dbc);
    tpl_set_var('queries', $content);
    tpl_BuildTemplate();
    exit;
}
コード例 #2
0
ファイル: CacheTitled.php プロジェクト: kojoty/opencaching-pl
 public static function isTitled($cacheId)
 {
     $queryPt = 'SELECT ratio FROM cache_titled WHERE cache_id=:1';
     $db = OcDb::instance();
     $s = $db->multiVariableQuery($queryPt, $cacheId);
     return $db->rowCount($s);
 }
コード例 #3
0
 private function getPlacedCount(User $user)
 {
     $db = OcDb::instance();
     $placedCountQuery = 'SELECT count(*) as cacheCount FROM `caches_additions`, caches WHERE caches_additions.`altitude` > :1 AND caches.cache_id = caches_additions.cache_id AND caches.user_id = :2 AND caches.type IN (:3) AND status = :4 AND `caches`.`date_created` > :5';
     $s = $db->multiVariableQuery($placedCountQuery, $this->conditions['minimumAltitude'], $user->getUserId(), $this->buildCacheTypesSqlString(), \lib\Objects\GeoCache\GeoCache::STATUS_READY, $this->dateIntroduced);
     $dbResult = $db->dbResultFetchOneRowOnly($s);
     return $dbResult['cacheCount'];
 }
コード例 #4
0
 private function getGeocacherDays(User $user)
 {
     $db = OcDb::instance();
     $query = 'SELECT period_diff(date_format(now(), "%Y%m"), date_format( `date_created`, "%Y%m")) as months FROM `user` WHERE user_id = :1 LIMIT 1';
     $s = $db->multiVariableQuery($query, $user->getUserId());
     $dbResult = $db->dbResultFetchOneRowOnly($s);
     return $dbResult['months'];
 }
コード例 #5
0
 private function getPlacedCacheCount(User $user)
 {
     $query = 'SELECT count(caches.cache_id) as cacheCount FROM `caches` ' . 'WHERE `caches`.`user_id` = :1 AND `caches`.`status` IN ( :2 ) AND `caches`.`date_created` > :3 ' . 'AND `caches`.`type` IN ( :4 ) ';
     $db = OcDb::instance();
     $s = $db->multiVariableQuery($query, $user->getUserId(), $this->buildCacheStatusSqlString(), $this->dateIntroduced, $this->buildCacheTypesSqlString());
     $dbResult = $db->dbResultFetchOneRowOnly($s);
     return $dbResult['cacheCount'];
 }
コード例 #6
0
ファイル: Altitude.php プロジェクト: kojoty/opencaching-pl
 private function storeAlitudeInDb()
 {
     $query = 'INSERT INTO `caches_additions` (`cache_id`, `altitude`, `altitude_update_datetime`)
                     VALUES (:2, :1, NOW())
                     ON DUPLICATE KEY UPDATE
                     `altitude` = :1, altitude_update_datetime = NOW()';
     $db = OcDb::instance();
     $db->multiVariableQuery($query, $this->altitude, $this->geoCache->getCacheId());
 }
コード例 #7
0
 public static function buildWaypointsForGeocache(GeoCache $geoCache)
 {
     $db = OcDb::instance();
     $stmt = $db->multiVariableQuery("SELECT `wp_id`, `type`, `longitude`, `latitude`,  `desc`, `status`, `stage` FROM `waypoints` WHERE `cache_id`=:1 ORDER BY `stage`,`wp_id`", $geoCache->getCacheId());
     foreach ($db->dbResultFetchAll($stmt) as $wpRecord) {
         $waypoint = new Waypoint();
         $waypoint->setCoordinates(new Coordinates(array('dbRow' => $wpRecord)))->setDescription($wpRecord['desc'])->setId((int) $wpRecord['wp_id'])->setStage((int) $wpRecord['stage'])->setStatus((int) $wpRecord['status'])->setType((int) $wpRecord['type'])->setGeocache($geoCache);
         $geoCache->getWaypoints()->append($waypoint);
     }
 }
コード例 #8
0
 function run()
 {
     $db = OcDb::instance();
     $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';
     }
     $s = $db->paramQuery($sql, $params);
     $users = $db->dbResultFetchAll($s);
     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';
         $s = $db->paramQuery($sql, $params);
         if ($db->rowCount($s) > 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++;
         }
     }
     set_time_limit(60);
     unset($db);
     echo "-----------------------------------<br>total_touched={$total_touched}<br>";
 }
コード例 #9
0
 private function getPlacedCacheCount(User $user)
 {
     $query = 'SELECT count(caches.cache_id) as cacheCount FROM `caches`, `cache_location` ' . 'WHERE `caches`.`user_id` = :1 ' . $this->buildLocationCode4QueryString(5) . ' ' . 'AND `caches`.`status` = :2 AND `caches`.`date_created` > :3 AND cache_location.code3 = :4 ' . 'AND `caches`.`type` IN (' . $this->buildCacheTypesSqlString() . ') ' . 'AND cache_location.cache_id = caches.cache_id ';
     $db = OcDb::instance();
     $code4 = isset($this->conditions['cacheLocation']['code4']) ? $this->conditions['cacheLocation']['code4'] : false;
     if ($code4) {
         $s = $db->multiVariableQuery($query, $user->getUserId(), \cache::STATUS_READY, $this->dateIntroduced, $this->conditions['cacheLocation']['code3'], $code4);
     } else {
         $s = $db->multiVariableQuery($query, $user->getUserId(), \cache::STATUS_READY, $this->dateIntroduced, $this->conditions['cacheLocation']['code3']);
     }
     $dbResult = $db->dbResultFetchOneRowOnly($s);
     return $dbResult['cacheCount'];
 }
コード例 #10
0
ファイル: logs.php プロジェクト: kojoty/opencaching-pl
function find_news($start, $end)
{
    global $tpl;
    global $lang;
    global $znalezione;
    $wp = XDb::xEscape($_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 = XDb::xSql($query);
    $query = "select name,cache_id from caches where cache_id = (select cache_id from caches where wp_oc = '" . $wp . "');";
    $wynik2 = XDb::xSql($query);
    $caches = XDb::xFetchArray($wynik2);
    $tpl->assign("name", $caches['name']);
    // detailed cache access logging
    global $enable_cache_access_logs;
    if (@$enable_cache_access_logs) {
        $dbc = OcDb::instance();
        $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 = XDb::xFetchArray($wynik)) {
        if ($logs['deleted'] == 0) {
            $query = "select username from user where user_id = '" . $logs['user_id'] . "';";
            $wynik3 = XDb::xSql($query);
            $user = XDb::xFetchArray($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);
}
コード例 #11
0
 /**
  * get all today's active users
  */
 public function checkAllUsersMedals()
 {
     $query = 'SELECT user_id, username, founds_count, notfounds_count, hidden_count, latitude, longitude, country, email FROM `user` WHERE (`last_login` BETWEEN DATE_SUB(NOW(), INTERVAL 24 HOUR) AND NOW()) ';
     $db = OcDb::instance();
     $s = $db->simpleQuery($query);
     d($db->rowCount($s));
     $timeStart = microtime();
     $usersToCheck = $db->dbResultFetchAll($s);
     foreach ($usersToCheck as $userDbRow) {
         $user = new \lib\Objects\User\User(array('userDbRow' => $userDbRow));
         $user->loadMedalsFromDb();
         $this->checkMedalConditions($user);
     }
     $timeEnd = microtime() - $timeStart;
     d($timeEnd);
 }
コード例 #12
0
ファイル: myn.inc.php プロジェクト: kojoty/opencaching-pl
 /**  =====================================================================================
      * Funkcja sprawdzająca czy użytkownik uczestniczył w wydarzeniu
      *
      * dane wejściowe:
      * id skrzynki
      * id zalogowanego użytkownika
      *
      * zwraca true lub false
      *
       ===================================================================================== */
 private static function is_event_attended($cache_id, $user_id)
 {
     $q = 'SELECT user_id FROM cache_logs WHERE cache_id =:v1 AND user_id =:v2 AND type = 7 AND Deleted=0';
     $db = OcDb::instance();
     $params['v1']['value'] = (int) $cache_id;
     $params['v1']['data_type'] = 'integer';
     $params['v2']['value'] = (int) $user_id;
     $params['v2']['data_type'] = 'integer';
     $s = $db->paramQuery($q, $params);
     $rec = $db->dbResultFetch($s);
     if (isset($rec['user_id'])) {
         return true;
     } else {
         return false;
     }
 }
コード例 #13
0
 public function checkConditionsForUser(\lib\Objects\User\User $user)
 {
     if (!in_array($this->config->getOcNodeId(), $this->conditions['ocNodeId'])) {
         /* this medal is not available in current node */
         return;
     }
     $query = 'SELECT count(`id`) as `completedLogCount` FROM `PowerTrail_comments` WHERE `deleted` = 0 AND `userId` = :1 AND `PowerTrailId` = :2 ';
     $db = OcDb::instance();
     $s = $db->multiVariableQuery($query, $user->getUserId(), $this->conditions['geoPath']['geoPathId']);
     $cacheCountArr = $db->dbResultFetchOneRowOnly($s);
     if ($cacheCountArr['completedLogCount'] == 1) {
         $this->prizedTime = date($this->config->getDbDateTimeFormat());
         $this->level = 0;
     } else {
         $this->prizedTime = false;
     }
     $this->storeMedalStatus($user);
 }
コード例 #14
0
function emailCacheOwner($ptId, $cacheId, $linkCode)
{
    global $octeam_email, $usr, $absolute_server_URI, $site_name, $siteDateFormat, $siteDateTimeFormat;
    $owners = powerTrailBase::getPtOwners($ptId);
    $ptDbRow = powerTrailBase::getPtDbRow($ptId);
    $query = 'SELECT `caches` . * , `user`.`email`, `user`.`username` FROM `caches` , `user`
        WHERE `cache_id` =:1 AND `caches`.`user_id` = `user`.`user_id` LIMIT 1';
    $db = OcDb::instance();
    $s = $db->multiVariableQuery($query, $cacheId);
    $cacheData = $db->dbResultFetchOneRowOnly($s);
    //remove images
    $headers = 'MIME-Version: 1.0' . "\r\n";
    $headers .= 'Content-type: text/html; charset=UTF-8 ' . "\r\n";
    $headers .= "From: {$site_name} <" . $octeam_email . ">\r\n";
    $headers .= "Reply-To: " . $octeam_email . "\r\n";
    $mailbody = file_get_contents(dirname(__FILE__) . '/candidateEmail.html');
    $mailbody = mb_ereg_replace('{cacheOwnerName}', $cacheData['username'], $mailbody);
    $mailbody = mb_ereg_replace('{ptName}', $ptDbRow['name'], $mailbody);
    $mailbody = mb_ereg_replace('{ptId}', $ptId, $mailbody);
    $mailbody = mb_ereg_replace('{cacheName}', $cacheData['name'], $mailbody);
    $mailbody = mb_ereg_replace('{dateTime}', date($siteDateFormat), $mailbody);
    $mailbody = mb_ereg_replace('{userId}', $usr['userid'], $mailbody);
    $mailbody = mb_ereg_replace('{userName}', $usr['username'], $mailbody);
    $mailbody = mb_ereg_replace('{absolute_server_URI}', $absolute_server_URI, $mailbody);
    $mailbody = mb_ereg_replace('{linkCode}', $linkCode, $mailbody);
    $mailbody = mb_ereg_replace('{runwatch14}', tr('runwatch14'), $mailbody);
    $mailbody = mb_ereg_replace('{cacheWaypoint}', $cacheData['wp_oc'], $mailbody);
    $mailbody = mb_ereg_replace('{pt183}', tr('pt183'), $mailbody);
    $mailbody = mb_ereg_replace('{pt184}', tr('pt184'), $mailbody);
    $mailbody = mb_ereg_replace('{pt185}', tr('pt185'), $mailbody);
    $mailbody = mb_ereg_replace('{pt189}', tr('pt189'), $mailbody);
    $mailbody = mb_ereg_replace('{pt186}', tr('pt186'), $mailbody);
    $mailbody = mb_ereg_replace('{pt187}', tr('pt187'), $mailbody);
    $mailbody = mb_ereg_replace('{pt188}', tr('pt188'), $mailbody);
    $mailbody = mb_ereg_replace('{pt190}', tr('pt190'), $mailbody);
    mb_send_mail($cacheData['email'], tr('pt183'), $mailbody, $headers);
    // for debug only
    // mb_send_mail('*****@*****.**', tr('pt183'), $mailbody, $headers);
}
コード例 #15
0
 public function checkConditionsForUser(User $user)
 {
     if (!in_array($this->config->getOcNodeId(), $this->conditions['ocNodeId'])) {
         /* this medal is not available in current node */
         return;
     }
     $db = OcDb::instance();
     $queryFound = 'SELECT MAX(`altitude`) as maxAltitude FROM `caches`, `caches_additions`, cache_logs
         WHERE caches.`cache_id` = caches_additions.`cache_id` AND cache_logs.cache_id = caches.`cache_id`
         AND cache_logs.type = 1 AND cache_logs.user_id = :1 AND caches.type IN(:2)';
     $cacheTypes = $this->buildCacheTypesSqlString();
     $s = $db->multiVariableQuery($queryFound, $user->getUserId(), $cacheTypes);
     $foundMaxAltitudeRaw = $db->dbResultFetchOneRowOnly($s);
     $foundMaxAltitude = (int) $foundMaxAltitudeRaw['maxAltitude'];
     $queryPlaced = 'SELECT MAX(`altitude`) as maxAltitude FROM `caches`, `caches_additions`
         WHERE caches.`cache_id` = caches_additions.`cache_id`
         AND cache.user_id = :1 AND caches.type IN(:2) AND cache.status = :3';
     $s = $db->multiVariableQuery($queryPlaced, $user->getUserId(), $cacheTypes, \cache::STATUS_READY);
     $placedMaxAltitudeRaw = $db->dbResultFetchOneRowOnly($s);
     $placedMaxAltitude = (int) $placedMaxAltitudeRaw['maxAltitude'];
     $this->findLevel($foundMaxAltitude, $placedMaxAltitude);
     $this->storeMedalStatus($user);
 }
コード例 #16
0
ファイル: login.class.php プロジェクト: kojoty/opencaching-pl
 function __construct()
 {
     $this->db = OcDb::instance();
     global $cookie;
     if ($cookie->is_set('userid') && $cookie->is_set('username')) {
         $this->userid = $cookie->get('userid') + 0;
         $this->username = $cookie->get('username');
         $this->permanent = $cookie->get('permanent') + 0 == 1;
         $this->lastlogin = $cookie->get('lastlogin');
         $this->sessionid = $cookie->get('sessionid');
         $this->admin = $cookie->get('admin') + 0 == 1;
         $this->verified = false;
         // wenn lastlogin zu 50% abgelaufen, verify()
         // permanent = 90 Tage, sonst 60 Minuten
         if ($this->permanent == true && strtotime($this->lastlogin) + LOGIN_TIME / 2 < time() || $this->permanent == false && strtotime($this->lastlogin) + LOGIN_TIME_PERMANENT / 2 < time()) {
             $this->verify();
         }
         if ($this->admin != false) {
             $this->verify();
         }
     } else {
         $this->pClear();
     }
 }
コード例 #17
0
function removeDbEntery($code)
{
    $db = OcDb::instance();
    $query = 'DELETE FROM `PowerTrail_cacheCandidate` WHERE `link` = :1';
    $db->multiVariableQuery($query, $code);
}
コード例 #18
0
function viewcache_getpicturestable($cacheid, $viewthumbs = true, $viewtext = true, $spoiler_only = false, $showspoiler = false, $picturescount, $disable_spoiler = false)
{
    $db = OcDb::instance();
    $retval = '';
    global $thumb_max_width;
    global $thumb_max_height;
    global $spoiler_disable_msg;
    $nCol = 0;
    if ($spoiler_only) {
        $spoiler_only = 'spoiler=1 AND';
    } else {
        $spoiler_only = "";
    }
    $stmt = $db->multiVariableQuery('
        SELECT uuid, title, url, spoiler FROM pictures
        WHERE ' . $spoiler_only . ' object_id=:1
            AND object_type=2 AND display=1
        ORDER BY seq, date_created', $cacheid);
    if ($disable_spoiler == false) {
        $spoiler_onclick = "enlarge(this);";
    } else {
        $spoiler_onclick = "alert('" . $spoiler_disable_msg . "'); return false;";
    }
    foreach ($db->dbResultFetchAll($stmt) as $key => $r) {
        if ($viewthumbs) {
            if ($nCol == 4) {
                $nCol = 0;
                $retval .= '<br style="clear: left;" />';
            }
            if ($showspoiler) {
                $showspoiler = "showspoiler=1&amp;";
            } else {
                $showspoiler = "";
            }
            $retval .= '<div class="viewcache-pictureblock">';
            if (isset($_REQUEST['print'])) {
                $reqPrint = $_REQUEST['print'];
            } else {
                $reqPrint = '';
            }
            if ($r['spoiler'] == 1) {
                if ($disable_spoiler == true) {
                    $r['url'] = 'tpl\\stdstyle\\images\\thumb\\thumbspoiler.gif';
                }
                //hide URL so cannot be viewed
            }
            if ($reqPrint != 'y') {
                $retval .= '<div class="img-shadow">';
                $retval .= '<a class="example-image-link" href="' . str_replace("images/uploads", "upload", $r['url']) . '" data-lightbox="example-1" data-title="' . htmlspecialchars($r['title']) . '"><img class="example-image" src="thumbs.php?' . $showspoiler . 'uuid=' . urlencode($r['uuid']) . '" alt="' . htmlspecialchars($r['title']) . '" /></a>';
            } else {
                if ($disable_spoiler == true && $r['spoiler'] == 1) {
                    $retval .= '<div><BR><strong>' . $spoiler_disable_msg . '</strong><BR><BR>';
                } else {
                    $retval .= '<div class="img-shadow"><a href="' . $r['url'] . '" title="' . htmlspecialchars($r['title']) . '" >';
                    $retval .= '<img src="thumbs.php?' . $showspoiler . 'uuid=' . urlencode($r['uuid']) . '" alt="' . htmlspecialchars($r['title']) . '" title="' . htmlspecialchars($r['title']) . '" /></a>';
                }
            }
            $retval .= '</div>';
            if ($viewtext) {
                $retval .= '<span class="title">' . $r['title'] . '</span>';
            }
            $retval .= '</div>';
            $nCol++;
        } else {
            // only text
            $retval .= '<a href="' . $r['url'] . '" title="' . $r['title'] . '">';
            $retval .= $r['title'];
            $retval .= "</a>\n";
        }
    }
    return $retval;
}
コード例 #19
0
<?php

session_start();
if (!isset($_SESSION['user_id'])) {
    print 'no hacking please!';
    exit;
}
require_once __DIR__ . '/../lib/ClassPathDictionary.php';
$ptAPI = new powerTrailBase();
$db = \Utils\Database\OcDb::instance();
$projectId = $_REQUEST['projectId'];
$userId = $_REQUEST['userId'];
if (is_numeric($userId)) {
    $queryParam = ' user_id = ';
} else {
    $queryParam = ' username LIKE ';
}
$query = 'SELECT user_id, username FROM user WHERE ' . $queryParam . ' :1 LIMIT 1';
$s = $db->multiVariableQuery($query, $userId);
$userResult = $db->dbResultFetchOneRowOnly($s);
$addQuery = "INSERT INTO `PowerTrail_owners`(`PowerTrailId`, `userId`, `privileages`) VALUES (:1,:2,:3)";
$db->multiVariableQuery($addQuery, $projectId, $userResult['user_id'], 1);
$logQuery = 'INSERT INTO `PowerTrail_actionsLog`(`PowerTrailId`, `userId`, `actionDateTime`, `actionType`, `description`, `cacheId`) VALUES (:1,:2,NOW(),4,:3,:4)';
$db->multiVariableQuery($logQuery, $projectId, $_SESSION['user_id'], $ptAPI->logActionTypes[4]['type'] . ' new owner is: ' . $userResult['user_id'], $userResult['user_id']);
$powerTrail = new \lib\Objects\PowerTrail\PowerTrail(array('id' => $projectId));
$ptOwners = displayPtOwnerList($powerTrail->getOwners());
echo $ptOwners;
function displayPtOwnerList($ptOwners)
{
    $ownerList = '';
    foreach ($ptOwners as $user) {
コード例 #20
0
 private function freeCacheCandidates()
 {
     $db = OcDb::instance();
     $query = 'DELETE FROM `PowerTrail_cacheCandidate` WHERE `date` < DATE_SUB(curdate(), INTERVAL 2 WEEK)';
     $db->simpleQuery($query);
 }
コード例 #21
0
<?php

use Utils\Database\OcDb;
$rootpath = __DIR__ . DIRECTORY_SEPARATOR;
require_once $rootpath . 'lib/common.inc.php';
$db = OcDb::instance();
$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";
$s = $db->simpleQuery($query);
$regons = $db->dbResultFetchAll($s);
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";
    }
コード例 #22
0
function getCacheIcon($user_id, $cache_id, $cache_status, $cache_userid, $iconname)
{
    $cacheicon_searchable = false;
    $cacheicon_type = "";
    $inactive = false;
    $iconname = str_replace("mystery", "quiz", $iconname);
    // mark if found
    if (isset($user_id)) {
        $db = OcDb::instance();
        $found = 0;
        $respSql = "SELECT `type` FROM `cache_logs` WHERE `cache_id`=:1 AND `user_id`=:2 AND `deleted`=0 ORDER BY `type`";
        $s = $db->multiVariableQuery($respSql, $cache_id, $user_id);
        foreach ($db->dbResultFetchAll($s) as $row) {
            if ($found <= 0) {
                switch ($row['type']) {
                    case 1:
                    case 7:
                        $found = $row['type'];
                        $cacheicon_type = "-found";
                        $inactive = true;
                        break;
                    case 2:
                        $found = $row['type'];
                        $cacheicon_type = "-dnf";
                        break;
                }
            }
        }
    }
    if ($cache_userid == $user_id) {
        $cacheicon_type = "-owner";
        $inactive = true;
        switch ($cache_status) {
            case 1:
                $cacheicon_searchable = "-s";
                break;
            case 2:
                $cacheicon_searchable = "-n";
                break;
            case 3:
                $cacheicon_searchable = "-a";
                break;
            case 4:
                $cacheicon_searchable = "-a";
                break;
            case 6:
                $cacheicon_searchable = "-d";
                break;
            default:
                $cacheicon_searchable = "-s";
                break;
        }
    } else {
        switch ($cache_status) {
            case 1:
                $cacheicon_searchable = "-s";
                break;
            case 2:
                $inactive = true;
                $cacheicon_searchable = "-n";
                break;
            case 3:
                $inactive = true;
                $cacheicon_searchable = "-a";
                break;
            case 4:
                $inactive = true;
                $cacheicon_searchable = "-a";
                break;
            case 6:
                $cacheicon_searchable = "-d";
                break;
        }
    }
    // cacheicon
    $iconname = mb_eregi_replace("\\..*", "", $iconname);
    $iconname .= $cacheicon_searchable . $cacheicon_type . ".png";
    return array($iconname, $inactive);
}
コード例 #23
0
ファイル: viewprofile.php プロジェクト: kojoty/opencaching-pl
 // check for old-style parameters
 if (isset($_REQUEST['userid'])) {
     $user_id = $_REQUEST['userid'];
 } else {
     $user_id = $usr['userid'];
 }
 tpl_set_var('userid', $user_id);
 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 = OcDb::instance();
 $rddQuery = "select TO_DAYS(NOW()) - TO_DAYS(`date_created`) `diff` from `user` WHERE user_id=:1 LIMIT 1";
 $s = $database->multiVariableQuery($rddQuery, $user_id);
 $ddays = $database->dbResultFetchOneRowOnly($s);
 $query = "SELECT user_id, 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\n            FROM user WHERE user_id=:1 LIMIT 1";
 $s = $database->multiVariableQuery($query, $user_id);
 $user_record = $database->dbResultFetchOneRowOnly($s);
 $user = new User(array('userDbRow' => $user_record));
 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));
コード例 #24
0
ファイル: GeoCache.php プロジェクト: kojoty/opencaching-pl
 /**
  * get mobile cache distnace.
  * (calculate mobile cache distance if were not counted before)
  * @return float
  */
 public function getDistance()
 {
     if ($this->distance === -1) {
         $db = OcDb::instance();
         $sql = 'SELECT sum(km) AS dystans FROM cache_moved WHERE cache_id=:1';
         $s = $db->multiVariableQuery($sql, $this->id);
         $dst = $db->dbResultFetchOneRowOnly($s);
         $this->distance = round($dst['dystans'], 2);
     }
     return $this->distance;
 }
コード例 #25
0
         }
     }
     XDb::xFreeResults($rs);
 }
 if ($cache_id != 0) {
     //ok, cache is here, let's process
     $owner_id = $cache_record['user_id'];
     //cache data
     tpl_set_var('cachename', htmlspecialchars($cache_record['name'], ENT_COMPAT, 'UTF-8'));
     tpl_set_var('cacheid', $cache_id);
     $pictureslog = '';
     // replace smilies in log-text with images
     // pictures
     $cachepicturelines = '';
     $append_atag = '';
     $dbc = OcDb::instance();
     $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';
     $s = $dbc->paramQuery($thatquery, $params);
     unset($params);
     //clear to avoid overlaping on next paramQuery (if any))
     $rscpictures_count = $dbc->rowCount($s);
     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', '-->');
     }
コード例 #26
0
ファイル: Medal.php プロジェクト: kojoty/opencaching-pl
 private function addMedalToUserMedalsDb(User $user)
 {
     $query = 'INSERT INTO `medals`(`user_id`, `medal_type`, `prized_time`, `medal_level`) VALUES (:1, :2, :3, :4)';
     $db = OcDb::instance();
     $db->multiVariableQuery($query, $user->getUserId(), $this->medalId, $this->prizedTime, $this->level);
 }
コード例 #27
0
ファイル: auth.inc.php プロジェクト: kojoty/opencaching-pl
function getUserRow($userId)
{
    $db = OcDb::instance();
    $s = $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($s);
}
コード例 #28
0
 private function getUserPTs()
 {
     $query = "SELECT * FROM `PowerTrail`, PowerTrail_owners  WHERE  PowerTrail_owners.userId = :1 AND PowerTrail_owners.PowerTrailId = PowerTrail.id";
     $db = OcDb::instance();
     $s = $db->multiVariableQuery($query, $this->user['userid']);
     $userPTs = $db->dbResultFetchAll($s);
     $this->userPTs = $userPTs;
 }
コード例 #29
0
 private function __construct()
 {
     $this->ocConfig = OcConfig::instance();
     $this->db = OcDb::instance();
 }
コード例 #30
0
ファイル: Log.php プロジェクト: kojoty/opencaching-pl
 public function storeInDb()
 {
     $db = OcDb::instance();
     if ($_REQUEST['type'] == Log::TYPE_CONQUESTED && $this->powerTrail->isAlreadyConquestedByUser($this->user)) {
         /* atempt to add second 'conquested' log */
         return false;
     }
     if ($this->id) {
         ddd('TODO');
     } else {
         if ($this->type === self::TYPE_ADD_WARNING && $this->user->getIsAdmin() === false) {
             return false;
             /* regular user is not allowed to add entery of this type */
         }
         $query = 'INSERT INTO `PowerTrail_comments`(`userId`, `PowerTrailId`, `commentType`, `commentText`, `logDateTime`, `dbInsertDateTime`, `deleted`) VALUES (:1, :2, :3, :4, :5, NOW(),0)';
         $db->multiVariableQuery($query, $this->user->getUserId(), $this->powerTrail->getId(), $this->type, $this->text, $this->dateTime->format('Y-m-d H:i:s'));
         if ($this->type == self::TYPE_CONQUESTED) {
             $this->powerTrail->increaseConquestedCount();
         }
     }
     $this->changePowerTrailStatusAfterLog();
     return true;
 }