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); }
$loggeduserCache = isCacheOwnByLoggedUser($cacheId); if (!$loggeduserCache) { $isCacheCanditate = isCacheCanditate($projectId, $cacheId); if (!$isCacheCanditate && !$caheIsAttaschedToPt) { addCacheToCacheCandidate($cacheId, $projectId); } else { print 'cache is already candidate or belongs to other pt'; exit; } } if (isset($_REQUEST['calledFromConfirm']) && $_REQUEST['calledFromConfirm'] === 1) { addCacheToPowerTrail($cacheId, $projectId, new dataBase(), $ptAPI); $cacheAddedToPt = true; return; } $ptDbRow = powerTrailBase::getPtDbRow($resultPowerTrailId['PowerTrailId']); if ($projectId > 0 && $caheIsAttaschedToPt === false) { addCacheToPowerTrail($cacheId, $projectId, $db, $ptAPI); print 'cacheAddedToPt'; } if ($ptDbRow['conquestedCount'] > 0) { // cache bellongs to PT wchcich was 'completed' print "this cache cannot be removed"; } if ($projectId <= 0 && $ptDbRow['conquestedCount'] == 0) { removeCacheFromPowerTrail($cacheId, $resultPowerTrailId, $db, $ptAPI); recalculate($resultPowerTrailId['PowerTrailId']); print 'removed'; } if ($projectId > 0 && $caheIsAttaschedToPt === true && $ptDbRow['conquestedCount'] == 0) { removeCacheFromPowerTrail($cacheId, $resultPowerTrailId, $db, $ptAPI);
} } } $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) {
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';
$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'];
$pt = new powerTrailController($usr); $result = $pt->run(); if ($usr['userid'] == 9067) { } else { if (!(isset($usr['admin']) && $usr['admin'] == 1)) { print tr('pt236'); exit; } } tpl_set_var("selPtDiv", 'none'); tpl_set_var("PtDetailsDiv", 'none'); 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();
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); }