<?php $rootpath = __DIR__ . '/../'; require_once __DIR__ . '/../lib/common.inc.php'; db_disconnect(); $ptId = (int) $_REQUEST['ptId']; $ptTotalCacheesCount = powerTrailBase::getPtCacheCount($ptId); if ($ptTotalCacheesCount == 0) { // power Trail has no caches! print tr('pt105'); exit; } $o1 = ' AND `user`.`is_active_flag` = 1 '; $o2 = ' AND `user`.`last_login` > date_sub(now(), interval 12 month )'; $q = "\n\nSELECT `user`.`username` , `cache_logs`.`user_id`, count( * ) AS `FoundCount`, `cache_logs`.`date`\nFROM `cache_logs` , `user`\nWHERE `cache_id`\nIN (\nSELECT `cacheId`\nFROM `powerTrail_caches`\nWHERE `PowerTrailId` =:1\n)\nAND `deleted` =0\nAND `type` =1\nAND `cache_logs`.`user_id` = `user`.`user_id`\n\n{$o1} {$o2}\n\nGROUP BY `user_id`, `date`\nORDER BY `FoundCount` DESC, `username` ASC\n\n"; $db = \lib\Database\DataBaseSingleton::Instance(); $db->multiVariableQuery($q, $ptId); $statsArr = $db->dbResultFetchAll(); // echo '<pre>'; var_dump($ptTotalCacheesCount, $statsArr); if (count($statsArr) == 0) { // no result! print tr('pt105'); exit; } foreach ($statsArr as $user) { $tmpDate = substr($user['date'], 0, -9); if (!isset($sorted[$user["user_id"]])) { $sorted[$user["user_id"]] = array('user_id' => $user['user_id'], 'username' => $user['username'], 'FoundCount' => $user['FoundCount']); $tmp[$user["user_id"]]['dates'][] = $tmpDate; } else { $sorted[$user["user_id"]]['FoundCount'] += $user['FoundCount'];