function generateStatusSelector($currStatus) { $selector = '<select id="ptStatusSelector">'; foreach (powerTrailBase::getPowerTrailStatus() as $val => $desc) { if ($val == $currStatus) { $selected = 'selected="selected"'; } else { $selected = ''; } if ($val == 2 && $currStatus != 2) { } else { // (this status is only after new geoPath creation.) $selector .= '<option ' . $selected . ' value="' . $val . '">' . tr($desc['translate']) . '</option>'; } } $selector .= '</select>'; return $selector; }
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); }
private function makePt() { include __DIR__ . '/../../lib/settings.inc.php'; include_once __DIR__ . '/../../lib/language.inc.php'; $langArray = available_languages(); $oldFileArr = explode('xxkgfj8ipzxx', file_get_contents($dynstylepath . 'ptPromo.inc-' . $lang . '.php')); $region = new GetRegions(); $newPt = powerTrailBase::writePromoPt4mainPage($oldFileArr[1]); $regions = $region->GetRegion($newPt['centerLatitude'], $newPt['centerLongitude']); foreach ($langArray as $language) { $this->makePtContent($newPt, $language, $dynstylepath, $regions); } }
<?php use Utils\Database\OcDb; $rootpath = __DIR__ . '/../'; require_once __DIR__ . '/../lib/common.inc.php'; $db = OcDb::instance(); $query = 'SELECT user.username, `userId` FROM `PowerTrail_comments` , user WHERE `commentType` =2 AND `deleted` =0 AND `PowerTrail_comments`.`userId` = user.user_id GROUP BY `userId` '; $s = $db->simpleQuery($query); $result = $db->dbResultFetchAll($s); foreach ($result as $user) { $resArr[$user['userId']] = array('username' => $user['username'], 'userPoints' => powerTrailBase::getUserPoints($user['userId'])); } echo '<pre>'; print_r($resArr);
<?php $rootpath = __DIR__ . '/../'; require_once __DIR__ . '/../lib/common.inc.php'; if (!isset($_SESSION['user_id'])) { print 'no hacking please!'; exit; } $powerTrailId = (int) $_REQUEST['ptId']; $commentId = (int) $_REQUEST['commentId']; $callingUser = (int) $_REQUEST['callingUser']; if ($callingUser != $_SESSION['user_id']) { print 'wrong user!'; exit; } //get selected comment and check if it is $callingUser comment. $commentDbRow = powerTrailBase::getSingleComment($commentId); // check if user is owner of selected power Trail if (powerTrailBase::checkIfUserIsPowerTrailOwner($_SESSION['user_id'], $powerTrailId) == 1 || $commentDbRow['userId'] == $callingUser) { $query = 'UPDATE `PowerTrail_comments` SET `deleted` = 1 WHERE `id` = :1'; $db = \lib\Database\DataBaseSingleton::Instance(); $db->multiVariableQuery($query, $commentId); if ($commentDbRow['commentType'] == 2) { print '2'; $q = 'UPDATE `PowerTrail` SET `PowerTrail`.`conquestedCount`= (SELECT COUNT(*) FROM `PowerTrail_comments` WHERE `PowerTrail_comments`.`PowerTrailId` = :1 AND `PowerTrail_comments`.`commentType` = 2 AND `PowerTrail_comments`.`deleted` = 0 ) WHERE `PowerTrail`.`id` = :1 '; $db->multiVariableQuery($q, $powerTrailId); } sendEmail::emailOwners($powerTrailId, $commentDbRow['commentType'], $commentDbRow['logDateTime'], $commentDbRow['commentText'], 'delComment', $commentDbRow['userId'], $_REQUEST['delReason']); }
$sorted[$user["user_id"]]['FoundCount'] += $user['FoundCount']; if (!in_array($tmpDate, $tmp[$user["user_id"]]['dates'])) { $tmp[$user["user_id"]]['dates'][] = $tmpDate; } } } foreach ($tmp as $userId => $value) { $sorted[$userId]['daysSpent'] = count($value['dates']); } $sort = array(); foreach ($sorted as $k => $v) { $sort['username'][$k] = $v['username']; $sort['FoundCount'][$k] = $v['FoundCount']; } array_multisort($sort['FoundCount'], SORT_DESC, $sort['username'], SORT_ASC, $sorted); $ptDbRow = powerTrailBase::getPtDbRow($ptId); // print_r($sorted); // print_r($tmp); $stats2display = '<table class="statsTable" style="border-collapse:collapse;" align="center"><tr> <th>' . tr('pt095') . '</th> <th>' . tr('pt096') . '</th> <th>' . tr('pt097') . '</th> <th>' . tr('pt101') . '</th> <th>' . tr('pt102') . '</th> </tr>'; if ($ptTotalCacheesCount != 0) { $bgcolor = '#ffffff'; $fullPtFoundCount = 0; $totCacheDays = 0; foreach ($sorted as $user) { $totCacheDays += $user['daysSpent'];
/** * generate html string displaying geoPaths completed by user (power trail) medals * @author Andrzej Łza Woźniak, 2013-11-23 */ function getPowerTrailsCompletedByUser($userId) { $ptTypes = powerTrailBase::getPowerTrailTypes(); $ptCompletedList = powerTrailBase::getPowerTrailsCompletedByUser($userId); // var_dump($ptCompletedList); $result = '<table width="100%"><tr><td>'; foreach ($ptCompletedList as $pt) { if ($pt['image'] == '') { $pt['image'] = 'tpl/stdstyle/images/blue/powerTrailGenericLogo.png'; } $result .= '<div class="ptMedal"><table style="padding-top: 7px;" align="center" height="51" width="51"><tr><td width=52 height=52 valign="center" align="center"><a title="' . $pt['name'] . '" href="powerTrail.php?ptAction=showSerie&ptrail=' . $pt['id'] . '"><img class="imgPtMedal" src="' . $pt['image'] . '"></a></td></tr><tr><td align="center"><img src="' . $ptTypes[$pt["type"]]['icon'] . '" /></td></tr></table></div><div class="ptMedalSpacer"></div>'; } return $result . '</td></tr><tr><td></td></tr></table><br /><br />'; }
} } $sql_select[] = '`caches`.`cache_id` `cache_id`'; $sql_from[] = '`caches`'; $sql_where[] = '`caches`.`cache_id` IN (' . $cache_bylist . ')'; } elseif ($options['searchtype'] == 'bypt') { //print '<pre>'; //print_r($_SESSION['geoPathCacheList']); if (isset($_SESSION['geoPathCacheList']) && count($_SESSION['geoPathCacheList']) > 0) { $cache_bylist = implode(",", $_SESSION['geoPathCacheList']); $options['gpxPtFileName'] = $_SESSION['ptName']; } else { $options['ptId'] = (int) $_REQUEST['ptId']; $cache_bylist = implode(",", powerTrailBase::getPtCachesIds($options['ptId'])); $ptDetails = powerTrailBase::getPtDbRow($options['ptId']); $options['gpxPtFileName'] = powerTrailBase::clearPtNames($ptDetails['name']); } $sql_select[] = '`caches`.`cache_id` `cache_id`'; $sql_from[] = '`caches`'; $sql_where[] = '`caches`.`cache_id` IN (' . $cache_bylist . ')'; // unset ($_SESSION['geoPathCacheList']); } elseif ($options['searchtype'] == 'bywaypoint' && $options['waypoint'] != '') { $sql_select[] = '`caches`.`cache_id` `cache_id`'; $sql_from[] = '`caches`'; $sql_where[] = '`caches`.`wp_' . sql_escape($options['waypointtype']) . '`=\'' . sql_escape($options['waypoint']) . '\''; } elseif ($options['searchtype'] == 'byfulltext') { require_once $rootpath . 'lib/ftsearch.inc.php'; $fulltext = $options['fulltext']; $hashes = ftsearch_hash($fulltext); if (count($hashes) == 0) { $options['error_nofulltext'] = true;
/** * just for recalculate all points in powerTrail_caches if any problem occur * or points algo were changed. */ function recalculateOnce() { $db = OcDb::instance(); $stmt = $db->multiVariableQuery('SELECT * FROM `caches` where `cache_id` IN (SELECT `cacheId` FROM `powerTrail_caches` WHERE 1)'); $allCaches = $db->dbResultFetchAll($stmt); foreach ($allCaches as $cache) { $cachePoints = powerTrailBase::getCachePoints($cache); $db->multiVariableQuery('UPDATE `powerTrail_caches` SET `points`=:1 WHERE `cacheId`=:2', $cachePoints, $cache['cache_id']); print $cache['wp_oc'] . ' updated ' . $cachePoints . '<br/>'; } }
public static function emailOwners($ptId, $commentType, $commentDateTime, $commentText, $action, $commentOwnerId = false, $delReason = '') { /*ugly, but we need this values from common.inc.php*/ global $watchlistMailfrom, $usr, $absolute_server_URI, $site_name, $siteDateFormat, $siteDateTimeFormat; $siteDateFormat = 'Y-m-d'; $siteDateTimeFormat = 'Y-m-d H:i'; $owners = powerTrailBase::getPtOwners($ptId); $commentTypes = powerTrailBase::getPowerTrailComments(); $ptDbRow = powerTrailBase::getPtDbRow($ptId); //remove images $commentText = preg_replace("/<img[^>]+\\>/i", "", $commentText); $headers = 'MIME-Version: 1.0' . "\r\n"; $headers .= 'Content-type: text/html; charset=UTF-8 ' . "\r\n"; $headers .= "From: {$site_name} <" . $watchlistMailfrom . ">\r\n"; $headers .= "Reply-To: " . $watchlistMailfrom . "\r\n"; $mailbody = read_file(dirname(__FILE__) . '/commentEmail.html'); switch ($action) { case 'delComment': $subject = tr('pt131') . ' ' . $ptDbRow['name']; $mailbody = mb_ereg_replace('{commentAction}', tr('pt132'), $mailbody); $mailbody = mb_ereg_replace('{actionDesc}', tr('pt131'), $mailbody); $mailbody = mb_ereg_replace('{delReason}', $delReason, $mailbody); $mailbody = mb_ereg_replace('{pt153}', tr('pt153'), $mailbody); break; case 'newComment': $subject = tr('pt128') . ' ' . $ptDbRow['name']; $mailbody = mb_ereg_replace('{commentAction}', tr('pt127'), $mailbody); $mailbody = mb_ereg_replace('{actionDesc}', tr('pt128'), $mailbody); $mailbody = mb_ereg_replace('{delReason}', '', $mailbody); $mailbody = mb_ereg_replace('{pt153}', '', $mailbody); break; case 'editComment': $subject = tr('pt146') . ' ' . $ptDbRow['name']; $mailbody = mb_ereg_replace('{commentAction}', tr('pt147'), $mailbody); $mailbody = mb_ereg_replace('{actionDesc}', tr('pt146'), $mailbody); $mailbody = mb_ereg_replace('{delReason}', '', $mailbody); $mailbody = mb_ereg_replace('{pt153}', '', $mailbody); break; } if (!isset($usr['userid'])) { $usr['userid'] = -1; } if (!isset($usr['username'])) { $usr['username'] = '******'; } $mailbody = mb_ereg_replace('{runwatch14}', tr('runwatch14'), $mailbody); $mailbody = mb_ereg_replace('{commentDateTime}', date($siteDateTimeFormat, strtotime($commentDateTime)), $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); if (isset($commentTypes[$commentType]['translate'])) { $mailbody = mb_ereg_replace('{commentType}', tr($commentTypes[$commentType]['translate']), $mailbody); } else { $mailbody = mb_ereg_replace('{commentType}', ' ', $mailbody); } $mailbody = mb_ereg_replace('{ptName}', $ptDbRow['name'], $mailbody); $mailbody = mb_ereg_replace('{ptId}', $ptId, $mailbody); $mailbody = mb_ereg_replace('{pt133}', tr('pt133'), $mailbody); $mailbody = mb_ereg_replace('{pt134}', tr('pt134'), $mailbody); $mailbody = mb_ereg_replace('{commentText}', htmlspecialchars_decode(stripslashes($commentText)), $mailbody); $mailbody = mb_ereg_replace('{addingCommentDateTime}', date($siteDateTimeFormat), $mailbody); $doNotSendEmailToCommentAuthor = false; foreach ($owners as $owner) { $to = $owner['email']; if ($owner['power_trail_email'] == 1) { mb_send_mail($to, $subject, $mailbody, $headers); } if ($commentOwnerId && $commentOwnerId == $owner["user_id"]) { $doNotSendEmailToCommentAuthor = true; } } if ($commentOwnerId && !$doNotSendEmailToCommentAuthor) { $userDetails = powerTrailBase::getUserDetails($commentOwnerId); if ($userDetails['power_trail_email']) { mb_send_mail($userDetails['email'], $subject, $mailbody, $headers); } } //for debug only //mb_send_mail('*****@*****.**', $subject, $mailbody, $headers); }
<?php use Utils\Database\OcDb; session_start(); if (!isset($_SESSION['user_id'])) { print 'no hacking please!'; exit; } require_once __DIR__ . '/../lib/ClassPathDictionary.php'; $ptAPI = new powerTrailBase(); $db = OcDb::instance(); $projectId = $_REQUEST['projectId']; $allCachesQuery = 'SELECT * FROM `caches` where `cache_id` IN (SELECT `cacheId` FROM `powerTrail_caches` WHERE `PowerTrailId` =:1 )'; $s = $db->multiVariableQuery($allCachesQuery, $projectId); $allCaches = $db->dbResultFetchAll($s); $newData = powerTrailBase::recalculateCenterAndPoints($allCaches); $query = 'SELECT count( `cacheId` ) AS cacheCount FROM `powerTrail_caches` WHERE `PowerTrailId` =:1'; $s = $db->multiVariableQuery($query, $projectId); $cacheCountResult = $db->dbResultFetchOneRowOnly($s); $cacheCountResult = $cacheCountResult['cacheCount']; $updateQuery = 'UPDATE `PowerTrail` SET `cacheCount`= :1, `centerLatitude` = ' . $newData['avgLat'] . ', `centerLongitude` = ' . $newData['avgLon'] . ', `points` = ' . $newData['points'] . ' WHERE `id` = :2'; $db->multiVariableQuery($updateQuery, $cacheCountResult, $projectId); // $result = json_encode($cacheCountResult); echo $cacheCountResult;
function displayPtCommentsSelector($htmlid, \lib\Objects\PowerTrail\PowerTrail $powerTrail, $selectedId = 0, $usr = null) { $appContainer = lib\Objects\ApplicationContainer::Instance(); if ($appContainer->getLoggedUser() === false) { return ''; } $cachesFoundByUser = $powerTrail->getFoundCachsByUser($appContainer->getLoggedUser()->getUserId()); $percetDemand = $powerTrail->getPerccentRequired(); $ptId = $powerTrail->getId(); if ($powerTrail->getCacheCount() != 0) { $percentUserFound = round(count($cachesFoundByUser) * 100 / $powerTrail->getCacheCount(), 2); } else { $percentUserFound = 0; } $commentsArr = lib\Controllers\PowerTrailController::getEntryTypes(); $ptOwners = powerTrailBase::getPtOwners($ptId); $selector = '<select id="' . $htmlid . '" name="' . $htmlid . '">'; foreach ($commentsArr as $id => $type) { if ($id == 2) { if ($percentUserFound < $percetDemand || powerTrailBase::checkUserConquestedPt($appContainer->getLoggedUser()->getUserId(), $ptId) > 0) { continue; } $selected = 'selected="selected"'; } if (!isset($ptOwners[$appContainer->getLoggedUser()->getUserId()]) && ($id == 3 || $id == 4 || $id == 5)) { continue; } if ($id == 3 && $powerTrail->canBeOpened() === false && $powerTrail->getStatus() != \lib\Objects\PowerTrail\PowerTrail::STATUS_OPEN) { /* this PT cannot be opened */ continue; } if ($id === \lib\Objects\PowerTrail\Log::TYPE_ADD_WARNING && $appContainer->getLoggedUser()->getIsAdmin() === false) { continue; } if (!isset($selected)) { $selected = ''; } if ($selectedId == $id) { $selected = 'selected'; } $selector .= '<option value="' . $id . '" ' . $selected . '>' . tr($type['translate']) . '</option>'; unset($selected); } $selector .= '</select>'; return $selector; }
tpl_set_var('viewcache_header', $decrypt_script); } else { tpl_set_var('branding', "<span class='txt-green07'>Automatic translation thanks to:</span>"); tpl_set_var('viewcache_header', $viewcache_header . $decrypt_script); } tpl_set_var('bodyMod', ''); // pass to tmplate if user is logged (hide other geocaching portals links) if ($usr == false || $usr['userFounds'] < 99) { $userLogged = 'none'; } else { $userLogged = 'block'; } tpl_set_var('userLogged', $userLogged); // power trails if ($powerTrailModuleSwitchOn && $cache_id != null) { $ptArr = powerTrailBase::checkForPowerTrailByCache($cache_id); if (count($ptArr) > 0) { $ptHtml = '<table width="99%">'; foreach ($ptArr as $pt) { if ($pt['image'] == '') { $ptImg = 'tpl/stdstyle/images/blue/powerTrailGenericLogo.png'; } else { $ptImg = $pt['image']; } $ptHtml .= '<tr><td width="51"><img border="0" width="50" src="' . $ptImg . '" /></td><td align="center"><span style="font-size: 13px;"><a href="powerTrail.php?ptAction=showSerie&ptrail=' . $pt['id'] . '">' . $pt['name'] . '</a> </td></tr>'; } $ptHtml .= '</table>'; $ptDisplay = 'block'; } else { $ptHtml = ''; $ptDisplay = 'none';
<?php $rootpath = __DIR__ . '/../'; require_once __DIR__ . '/../lib/common.inc.php'; db_disconnect(); $commentsArr = powerTrailBase::getPowerTrailComments(); $ptOwners = powerTrailBase::getPtOwners($_REQUEST['projectId']); $paginateCount = powerTrailBase::commentsPaginateCount; foreach ($ptOwners as $owner) { $ownersIdArray[] = $owner['user_id']; } $nextSearchStart = $_REQUEST['start'] + $_REQUEST['limit']; $db = \lib\Database\DataBaseSingleton::Instance(); $q = 'SELECT count(*) AS `count` FROM `PowerTrail_comments` WHERE `PowerTrailId` =:1 AND `deleted` = 0 '; $db->multiVariableQuery($q, $_REQUEST['projectId']); $count = $db->dbResultFetch(); $count = $count['count']; $query = 'SELECT * FROM `PowerTrail_comments`, `user` WHERE `PowerTrailId` =:variable1 AND `deleted` = 0 AND `PowerTrail_comments`.`userId` = `user`.`user_id` ORDER BY `logDateTime` DESC LIMIT :variable2 , :variable3 '; $params['variable1']['value'] = (int) $_REQUEST['projectId']; $params['variable1']['data_type'] = 'integer'; $params['variable2']['value'] = (int) $_REQUEST['start']; $params['variable2']['data_type'] = 'integer'; $params['variable3']['value'] = (int) $_REQUEST['limit']; $params['variable3']['data_type'] = 'integer'; $db->paramQuery($query, $params); // multiVariableQuery($query, $projectId, 0, 8); $result = $db->dbResultFetchAll(); // print_r($result); if (count($result) == 0) { echo '<p><br /><br />' . tr('pt118') . '</p><br /><br />'; exit;
<?php $poweTrailMarkers = powerTrailBase::getPowerTrailTypes(); function icon_log_type($icon_small, $text) { global $stylepath; return "<img src='{$stylepath}/images/{$icon_small}' class='icon16' alt='{$text}' title='{$text}'/>"; } function icon_cache_status($status, $text) { global $stylepath; switch ($status) { case 1: $icon = "log/16x16-go.png"; break; case 2: $icon = "log/16x16-stop.png"; break; case 3: $icon = "log/16x16-trash.png"; break; case 4: $icon = "log/16x16-wattend.png"; break; case 5: $icon = "log/16x16-wattend.png"; break; case 6: $icon = "log/16x16-stop.png"; break; default:
tpl_set_var('hack', 'none'); tpl_set_var('ptName', ''); tpl_set_var('noRecord', 'none'); tpl_set_var('ptId', ''); // check if logged user is a cache owner $code = $_REQUEST['code']; $ownerDecision = (int) $_REQUEST['result']; $query = 'SELECT * FROM `PowerTrail_cacheCandidate`, caches WHERE `link` = :1 AND PowerTrail_cacheCandidate.CacheId = caches.cache_id'; $db = new dataBase(); $db->multiVariableQuery($query, $code); $dbData = $db->dbResultFetch(); if ($dbData === false) { // record not found tpl_set_var('noRecord', 'block'); } else { $ptData = powerTrailBase::getPtDbRow($dbData['PowerTrailId']); tpl_set_var('ptName', $ptData['name']); tpl_set_var('ptId', $dbData['PowerTrailId']); if ($usr['userid'] == $dbData['user_id']) { // go on if ($ownerDecision === 0) { // just remove cache from candidate table removeDbEntery($code); tpl_set_var('ptNo', 'block'); } if ($ownerDecision === 1) { // addcachetoPt $_REQUEST['calledFromConfirm'] = 1; $_REQUEST['projectId'] = $dbData['PowerTrailId']; $_REQUEST['cacheId'] = $dbData['cache_id']; include_once 'powerTrail/ajaxAddCacheToPt.php';
<?php session_start(); if (!isset($_SESSION['user_id'])) { print 'no hacking please!'; exit; } require_once __DIR__ . '/../lib/ClassPathDictionary.php'; $ptAPI = new powerTrailBase(); $db = \lib\Database\DataBaseSingleton::Instance(); $projectId = $_REQUEST['projectId']; $userId = $_REQUEST['userId']; //check if user is only one owner if (count(powerTrailBase::getPtOwners($projectId)) > 1 && $ptAPI::checkIfUserIsPowerTrailOwner($_SESSION['user_id'], $projectId) == 1) { $addQuery = 'DELETE FROM `PowerTrail_owners` WHERE `userId` = :1 AND `PowerTrailId` = :2'; $db->multiVariableQuery($addQuery, $userId, $projectId); $logQuery = 'INSERT INTO `PowerTrail_actionsLog`(`PowerTrailId`, `userId`, `actionDateTime`, `actionType`, `description`, `cacheId`) VALUES (:1,:2,NOW(),5,:3,:4)'; $db->multiVariableQuery($logQuery, $projectId, $_SESSION['user_id'], $ptAPI->logActionTypes[5]['type'] . ' removed owner is: ' . $userId, $userId); } $pt = new powerTrailController($_SESSION['user_id']); $pt->findPtOwners($projectId); $ptOwners = displayPtOwnerList($pt->getPtOwners()); // $result = json_encode($cacheCountResult); // sleep(5); echo $ptOwners; function displayPtOwnerList($ptOwners) { $ownerList = ''; foreach ($ptOwners as $userId => $user) { $ownerList .= '<a href="viewprofile.php?userid=' . $userId . '">' . $user['username'] . '</a>'; if ($userId != $_SESSION['user_id']) {
tpl_set_var('language4js', $lang); if (isset($_REQUEST['ptSelector'])) { $powerTrail = new PowerTrail(array('id' => $_REQUEST['ptSelector'])); $_SESSION['ptRmByCog'] = 1; $ptData = powerTrailBase::getPtDbRow($_REQUEST['ptSelector']); $ptStatus = \lib\Controllers\PowerTrailController::getPowerTrailStatus(); $ptType = powerTrailBase::getPowerTrailTypes(); tpl_set_var("ptCaches", preparePtCaches($powerTrail)); tpl_set_var("ptStatSelect", generateStatusSelector($powerTrail->getStatus())); tpl_set_var("ptId", $powerTrail->getId()); tpl_set_var("ptName", $powerTrail->getName()); tpl_set_var("ptType", tr($ptType[$ptData['type']]['translate'])); tpl_set_var("ptStatus", tr($ptStatus[$ptData['status']]['translate'])); tpl_set_var("PtDetailsDiv", 'block'); } else { tpl_set_var("ptSelector", makePtSelector(powerTrailBase::getAllPt('AND status != 2'), 'ptSelector')); tpl_set_var("selPtDiv", 'block'); } } tpl_BuildTemplate(); function makePtSelector($ptAll, $id) { $selector = '<select id=' . $id . ' name=' . $id . '>'; foreach ($ptAll as $pt) { $selector .= '<option value=' . $pt['id'] . '>' . $pt['name'] . '</option>'; } $selector .= '</select>'; return $selector; } function preparePtCaches(PowerTrail $powerTrail) {
$ars = XDb::xSql("SELECT\n `user`.`hidden_count` AS `ukryte`,\n `user`.`founds_count` AS `znalezione`,\n `user`.`notfounds_count` AS `nieznalezione`\n FROM `user` WHERE `user_id`= ? ", $user_id); $record = XDb::xFetchArray($ars); $act = $record['ukryte'] + $record['znalezione'] + $record['nieznalezione']; if (date('m') == 4 and date('d') == 1) { $act = rand(-10, 10); } $content .= '<br /><p> </p><div class="content2-container bg-blue02"><p class="content-title-noshade-size1"> <img src="tpl/stdstyle/images/blue/event.png" class="icon32" alt="Caches Find" title="Caches Find" /> ' . tr('user_activity01') . '</p></div><br /><p><span class="content-title-noshade txt-blue08">' . tr('user_activity02') . '</span>: <strong>' . $act . '</strong></p>'; // PowerTrails stats if ($powerTrailModuleSwitchOn) { $content .= '<div class="content2-container bg-blue02"> <p class="content-title-noshade-size1"> <img src="tpl/stdstyle/images/blue/powerTrailGenericLogo.png" width="33" class="icon32" alt="geoPaths" title="geoPaths" /> ' . tr('pt001') . '</div>'; //geoPaths medals $content .= buildPowerTrailIcons($user->getPowerTrailCompleted()); $content .= '<p><span class="content-title-noshade txt-blue08">' . tr('pt140') . '</span>: <strong>' . powerTrailBase::getUserPoints($user_id) . '</strong> (' . tr('pt093') . ' ' . powerTrailBase::getPoweTrailCompletedCountByUser($user_id) . ')</p>'; $pointsEarnedForPlacedCaches = powerTrailBase::getOwnerPoints($user_id); $content .= buildPowerTrailIcons($user->getPowerTrailOwed()); $content .= '<p><span class="content-title-noshade txt-blue08">' . tr('pt224') . '</span>: <strong>' . $pointsEarnedForPlacedCaches['totalPoints'] . '</strong></p>'; } //$content .= '</div>'; // ----------- begin Find section ------------------------------------- $content .= '<p> </p><div class="content2-container bg-blue02"><p class="content-title-noshade-size1"> <img src="tpl/stdstyle/images/blue/cache-open.png" class="icon32" alt="Caches Find" title="Caches Find" /> ' . tr('stat_number_found') . '</p></div><br />'; $seek = XDb::xMultiVariableQueryValue("SELECT COUNT(*) FROM cache_logs\n WHERE (type=1 OR type=2) AND cache_logs.deleted='0' AND user_id= :1\n GROUP BY YEAR(`date`), MONTH(`date`), DAY(`date`)", 0, $user_id); if ($seek == 0) { $content .= '<br /><p> <b>' . tr('not_found_caches') . '</b></p>'; } else { $events_count = XDb::xMultiVariableQueryValue("SELECT COUNT(*) events_count FROM cache_logs\n WHERE user_id= :1 AND type=7 AND deleted=0", 0, $user_id); $days_since_first_find = XDb::xMultiVariableQueryValue("SELECT datediff(now(), date) as old FROM cache_logs\n WHERE deleted=0 AND user_id = :1 AND type=1 ORDER BY date LIMIT 1", 0, $user_id); $rsfc2 = XDb::xSql("SELECT cache_logs.cache_id cache_id, DATE_FORMAT(cache_logs.date,'%d-%m-%Y') data, caches.wp_oc cache_wp\n FROM cache_logs, caches\n WHERE caches.cache_id=cache_logs.cache_id AND cache_logs.type='1'\n AND cache_logs.user_id= ? AND cache_logs.deleted='0'\n ORDER BY cache_logs.date DESC LIMIT 1", $user_id); $rfc2 = XDb::xFetchArray($rsfc2); $rcNumber = XDb::xMultiVariableQueryValue("SELECT COUNT(*) number FROM cache_logs\n WHERE type=1 AND cache_logs.deleted='0' AND user_id= :1\n GROUP BY YEAR(`date`), MONTH(`date`), DAY(`date`)\n ORDER BY number DESC LIMIT 1", 0, $user_id);
private function createNewPowerTrail() { if (!isset($_SESSION['user_id'])) { /* user is not logged in */ return false; } $this->action = 'createNewSerie'; if (isset($_POST['powerTrailName']) && $_POST['powerTrailName'] != '' && $_POST['type'] != 0 && $_POST['status'] != 0 && $_SESSION['powerTrail']['userFounds'] >= powerTrailBase::userMinimumCacheFoundToSetNewPowerTrail()) { $query = "INSERT INTO `PowerTrail`(`name`, `type`, `status`, `dateCreated`, `cacheCount`, `description`, `perccentRequired`) VALUES (:1,:2,:3,NOW(),0,:4,:5)"; $db = OcDb::instance(); $db->multiVariableQuery($query, strip_tags($_POST['powerTrailName']), (int) $_POST['type'], (int) $_POST['status'], htmlspecialchars($_POST['description']), (int) $_POST['dPercent']); $newProjectId = $db->lastInsertId(); // exit; $query = "INSERT INTO `PowerTrail_owners`(`PowerTrailId`, `userId`, `privileages`) VALUES (:1,:2,:3)"; $db->multiVariableQuery($query, $newProjectId, $this->user['userid'], 1); $logQuery = 'INSERT INTO `PowerTrail_actionsLog`(`PowerTrailId`, `userId`, `actionDateTime`, `actionType`, `description`) VALUES (:1,:2,NOW(),1,:3)'; $db->multiVariableQuery($logQuery, $newProjectId, $this->user['userid'], $this->ptAPI->logActionTypes[1]['type']); header("location: powerTrail.php?ptAction=showSerie&ptrail={$newProjectId}"); return true; } else { return false; } }
/** * just for recalculate all points in powerTrail_caches if any problem occur * or points algo were changed. */ function recalculateOnce() { $allCachesQuery = 'SELECT * FROM `caches` where `cache_id` IN (SELECT `cacheId` FROM `powerTrail_caches` WHERE 1)'; $db = \lib\Database\DataBaseSingleton::Instance(); $db->multiVariableQuery($allCachesQuery); $allCaches = $db->dbResultFetchAll(); foreach ($allCaches as $cache) { $cachePoints = powerTrailBase::getCachePoints($cache); $updateQuery = 'UPDATE `powerTrail_caches` SET `points`=:1 WHERE `cacheId`=:2'; $db->multiVariableQuery($updateQuery, $cachePoints, $cache['cache_id']); print $cache['wp_oc'] . ' updated ' . $cachePoints . '<br/>'; } // print '<pre>'; // print_r($allCaches); }
<?php $rootpath = __DIR__ . '/../'; require_once __DIR__ . '/../lib/common.inc.php'; db_disconnect(); $statusArr = powerTrailBase::getPowerTrailStatus(); if (!isset($_SESSION['user_id'])) { print 'no hacking please!'; exit; } $ptAPI = new powerTrailBase(); $powerTrailId = (int) $_REQUEST['projectId']; $newStatus = (int) $_REQUEST['newStatus']; if (isset($_REQUEST['commentTxt'])) { $commentText = htmlspecialchars($_REQUEST['commentTxt']); } else { $commentText = false; } // check if user is owner of selected power Trail if ($ptAPI::checkIfUserIsPowerTrailOwner($_SESSION['user_id'], $powerTrailId) == 1 || isset($usr['admin']) && $usr['admin'] == 1) { switch ($newStatus) { case 1: // publish $commentType = 3; if (!$commentText) { $commentText = tr('pt215') . '!'; } break; case 4: // in service $commentType = 4;