function run()
 {
     $db = new dataBase();
     $db->switchDebug(false);
     $sql = "SELECT user_id FROM user where user_id >= 0 ";
     $params = array();
     if (isset($_GET['user_id'])) {
         $sql .= ' and user_id=:user_id';
         $params['user_id']['value'] = intval($_GET['user_id']);
         $params['user_id']['data_type'] = 'integer';
     }
     $db->paramQuery($sql, $params);
     $users = $db->dbResultFetchAll();
     set_time_limit(3600);
     $total_touched = 0;
     foreach ($users as $user) {
         $user_id = $user['user_id'];
         // repair founds
         $founds_count = $db->multiVariableQueryValue("SELECT count(id) FROM cache_logs WHERE deleted=0 AND user_id = :1 AND type=1", 0, $user_id);
         $notfounds_count = $db->multiVariableQueryValue("SELECT count(id) FROM cache_logs WHERE deleted=0 AND user_id = :1 AND type=2", 0, $user_id);
         $log_notes_count = $db->multiVariableQueryValue("SELECT count(id) FROM cache_logs WHERE deleted=0 AND user_id = :1 AND type=3", 0, $user_id);
         $cache_watches = $db->multiVariableQueryValue("SELECT count(id) FROM cache_watches WHERE user_id = :1", 0, $user_id);
         $cache_ignores = $db->multiVariableQueryValue("SELECT count(id) FROM cache_ignore WHERE user_id = :1", 0, $user_id);
         $hidden_count = $db->multiVariableQueryValue("select count(cache_id) from caches where status in (1,2,3) and user_id = :1", 0, $user_id);
         $sql = "\n                UPDATE user\n                SET\n                    hidden_count=:new_hidden_count,\n                    cache_ignores=:new_cache_ignores,\n                    log_notes_count=:new_log_notes_count,\n                    founds_count=:new_founds_count,\n                    notfounds_count=:new_notfounds_count,\n                    cache_watches=:new_cache_watches\n                WHERE\n                    user_id=:user_id\n                    AND (\n                        hidden_count is null\n                        OR cache_ignores is null\n                        OR log_notes_count is null\n                        OR founds_count is null\n                        OR notfounds_count is null\n                        OR cache_watches is null\n                        OR hidden_count!=:new_hidden_count\n                        OR cache_ignores!=:new_cache_ignores\n                        OR log_notes_count!=:new_log_notes_count\n                        OR founds_count!=:new_founds_count\n                        OR notfounds_count!=:new_notfounds_count\n                        OR cache_watches!=:new_cache_watches\n                    )\n            ";
         $params = array();
         $params['new_hidden_count']['value'] = intval($hidden_count);
         $params['new_hidden_count']['data_type'] = 'integer';
         $params['new_cache_ignores']['value'] = intval($cache_ignores);
         $params['new_cache_ignores']['data_type'] = 'integer';
         $params['new_log_notes_count']['value'] = intval($log_notes_count);
         $params['new_log_notes_count']['data_type'] = 'integer';
         $params['new_founds_count']['value'] = intval($founds_count);
         $params['new_founds_count']['data_type'] = 'integer';
         $params['new_notfounds_count']['value'] = intval($notfounds_count);
         $params['new_notfounds_count']['data_type'] = 'integer';
         $params['new_cache_watches']['value'] = intval($cache_watches);
         $params['new_cache_watches']['data_type'] = 'integer';
         $params['user_id']['value'] = intval($user_id);
         $params['user_id']['data_type'] = 'integer';
         $db->paramQuery($sql, $params);
         if ($db->rowCount() > 0) {
             echo "<b>user_id={$user_id}</b><br>";
             echo "hidden_count={$hidden_count}<br>cache_ignores={$cache_ignores}<br>";
             echo "log_notes_count={$log_notes_count}<br>founds_count={$founds_count}<br>";
             echo "notfounds_count={$notfounds_count}<br>cache_watches={$cache_watches}<br>";
             $total_touched++;
         }
         $db->closeCursor();
     }
     set_time_limit(60);
     unset($db);
     echo "-----------------------------------<br>total_touched={$total_touched}<br>";
 }
예제 #2
0
 $rscc2 = sql("SELECT cache_id, wp_oc, DATE_FORMAT(date_created,'%d-%m-%Y') data FROM caches WHERE status <> 4 AND status <> 5 AND status <> 6 AND user_id=&1 GROUP BY YEAR(`date_created`), MONTH(`date_created`), DAY(`date_created`) ORDER BY YEAR(`date_created`) DESC, MONTH(`date_created`) DESC, DAY(`date_created`) DESC, HOUR(`date_created`) DESC LIMIT 1", $user_id);
 $rcc2 = mysql_fetch_array($rscc2);
 $rsc = sql("SELECT COUNT(*) number FROM caches WHERE status <> 4 AND status <> 5 AND user_id=&1 GROUP BY YEAR(`date_created`), MONTH(`date_created`), DAY(`date_created`) ORDER BY number DESC LIMIT 1", $user_id);
 $rc = sql_fetch_array($rsc);
 $rsncd = sql("SELECT COUNT(*) FROM caches WHERE status <> 5 AND status <> 4 AND user_id=&1 GROUP BY YEAR(`date_created`), MONTH(`date_created`), DAY(`date_created`)", $user_id);
 $rsnca = sql("SELECT COUNT(*) FROM caches WHERE status <> 2 AND status <> 3 AND status <> 5 AND status <> 4 AND user_id=&1 GROUP BY YEAR(`date_created`), MONTH(`date_created`), DAY(`date_created`)", $user_id);
 $num_rows = mysql_num_rows($rsnca);
 $num_rows = mysql_num_rows($rsncd);
 if ($ddays['diff'] != 0) {
     $aver1 = round($user_record['hidden_count'] / $ddays['diff'], 2);
 } else {
     $aver1 = 0;
 }
 $aver2 = round($user_record['hidden_count'] / $num_rows, 2);
 // total owned
 $total_owned_caches = $database->multiVariableQueryValue("select count(cache_id) from caches where user_id = :1 and status in (1,2,3) and type not in (6)", 0, $user_id);
 // total adopted
 $total_owned_caches_adopted = $database->multiVariableQueryValue("select count(cache_id) from caches where user_id = :1 and org_user_id <> user_id and status in (1,2,3) and type not in (6)", 0, $user_id);
 // created and owned
 $total_created_and_owned_caches = $database->multiVariableQueryValue("select count(cache_id) from caches where user_id = :1 and (org_user_id = user_id or org_user_id is null) and status in (1,2,3) and type not in (6)", 0, $user_id);
 // created, but given to adoption
 $total_created_caches_adopted = $database->multiVariableQueryValue("select count(cache_id) from caches where org_user_id = :1 and org_user_id <> user_id and status in (1,2,3) and type not in (6)", 0, $user_id);
 $total_created_caches = $total_created_and_owned_caches + $total_created_caches_adopted;
 $content .= '<p><span class="content-title-noshade txt-blue08">' . tr('total_owned_caches') . ':  </span><strong>' . $total_owned_caches . '</strong>';
 if ($total_owned_caches == 0) {
     $content .= '</p>';
 } else {
     $content .= '&nbsp;&nbsp;&nbsp;<img src="tpl/stdstyle/images/blue/arrow.png" alt="" /> [<a class="links" href="search.php?showresult=1&amp;expert=0&amp;output=HTML&amp;sort=bycreated&amp;ownerid=' . $user_id . '&amp;cachetype=1111101111&amp;searchbyowner=&amp;f_inactive=0&amp;f_ignored=0&amp;f_userfound=0&amp;f_userowner=0">' . tr('show') . '</a>]</p>';
     if ($total_owned_caches_adopted > 0) {
         $content .= '<p><span class="content-title-noshade txt-blue08">' . tr('total_owned_caches_adopted') . ':  </span><strong>' . $total_owned_caches_adopted . '</strong></p>';
     }
 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>";
 }
예제 #4
0
if ($error == false && isset($usr['userid'])) {
    tpl_set_var('error_msg', "");
    tpl_set_var('info_msg', "");
    tpl_set_var('start_przejmij', "<!--");
    tpl_set_var('end_przejmij', "-->");
    tpl_set_var('acceptList', "");
    tpl_set_var('cacheList', "");
    // wybor wlasciciela - mozna zmieniac tylko swoje skrzynki... chyba, ze jest sie czlonkiem oc team
    if (isset($_GET['cacheid']) && (isUserOwner($usr['userid'], $_GET['cacheid']) && !isset($_GET['abort']) && !isset($_GET['accept']))) {
        tpl_set_var('cachename', getCacheName($_GET['cacheid']));
        tpl_set_var('cacheid', $_GET['cacheid']);
        $tplname = "chowner_chooseuser";
    } 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);
예제 #5
0
 $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);
 tpl_set_var('is_checked', $bulletin == 1 ? "checked" : "");
 tpl_set_var('description', $description);
 $tplname = 'myprofile';
 $using_permantent_login_message = tr('no_auto_logout');
 $no_htmledit_message = tr('hide_html_editor');
 $notify_radius_message = tr('notify_new_caches_radius') . ' {radius} km';
 $no_notify_message = tr('no_new_caches_notification');
 // check user can set as Geocaching guide
 // Number of recommendations
 $nrecom = $db->multiVariableQueryValue("SELECT SUM(topratings) as nrecom FROM caches WHERE `caches`.`user_id`= :1", 0, $usr['userid']);
 if ($nrecom >= 20) {
     tpl_set_var('guide_start', '');
     tpl_set_var('guide_end', '');
 } else {
     tpl_set_var('guide_start', '<!--');
     tpl_set_var('guide_end', '-->');
 }
 $sql = "SELECT `guru`,`username`, `email`, `country`, `latitude`, `longitude`, `date_created`, `permanent_login_flag`, `power_trail_email`, `notify_radius`, `ozi_filips` FROM `user` WHERE `user_id`=:1 ";
 $db->multiVariableQuery($sql, (int) $usr['userid']);
 $record = $db->dbResultFetchOneRowOnly();
 if ($record['guru'] == 1) {
     tpl_set_var('guides_start', '');
     tpl_set_var('guides_end', '');
 } else {
     tpl_set_var('guides_start', '<!--');