function NextMailFile() { $dir = scandir(substr(BOUNCEBACK_PATH, 0, -1), SCANDIR_SORT_ASCENDING); $lockFail = false; $gotFile = false; foreach ($dir as $fileName) { if (preg_match('/^(\\d+)\\./', $fileName, $res)) { if (($handle = fopen(BOUNCEBACK_PATH . $fileName, 'rb')) === false) { continue; } if (!flock($handle, LOCK_EX | LOCK_NB)) { $lockFail = true; fclose($handle); continue; } if (feof($handle)) { fclose($handle); unlink(BOUNCEBACK_PATH . $fileName); continue; } $ts = intval($res[1], 10); $gotFile = $fileName; break; } } unset($dir); if (!$gotFile) { if ($lockFail) { sleep(3); return true; } return false; } DebugMessage('Found message received at ' . date('Y-m-d H:i:s', $ts) . ', ' . TimeDiff($ts)); $message = fread($handle, min(filesize(BOUNCEBACK_PATH . $fileName), 4194304)); ftruncate($handle, 0); fclose($handle); unlink(BOUNCEBACK_PATH . $fileName); $mailId = false; if (preg_match('/X-Undermine-MailID:\\s*([a-zA-Z0-9_-]{27})/', $message, $res)) { $mailId = $res[1]; } elseif (preg_match('/[Mm]essage ID: ([a-zA-Z0-9_-]{27})/', $message, $res)) { $mailId = $res[1]; } if (!$mailId) { DebugMessage('Could not find message ID, forwarding to editor'); NewsstandMail('*****@*****.**', 'The Editor', 'Unparsed notification reply', $message); } else { $address = GetAddressByMailID($mailId); if (!$address) { DebugMessage('Could not find address for mail ID ' . $mailId); } else { $cnt = DisableEmailAddress($address['address']); DebugMessage('Address ' . $address['address'] . ' removed from ' . $cnt . ' account' . ($cnt == 1 ? '' : 's') . '.'); } } return true; }
function SetList_Process_Expire(&$SetList) { $elements =& $SetList->DelegateParameters['Form']['elements']; // Throw an error if DaysOld is not a number. if (!is_numeric($elements['DaysOld']['value'])) { $Error = str_replace('//1', $elements['DaysOld']['label'], $SetList->Context->GetDefinition('Expire.Error.DaysOldNaN')); $SetList->Context->WarningCollector->Add($Error); } // Check for expired discussions whenever settings are saved. if ($SetList->Context->WarningCollector->Iif()) { $SetList->Context->Configuration['Expire.DaysOld'] = $elements['DaysOld']['value']; $SetList->Context->Configuration['Expire.Action'] = $elements['Action']['value']; $SetList->Context->Configuration['Expire.IgnoreWhispers'] = $elements['IgnoreWhispers']['value']; Expire_Old_Discussions($SetList->Context); $elements['ExpireOptions']['description'] = str_replace('//1', TimeDiff($SetList->Context, 1, 1), $SetList->Context->GetDefinition('Expire.ExpireOptions.description')); } }
function GetDiscussion(&$Context, $Discussion, $FirstRow = "0") { // Prefix the discussion name with the whispered-to username if this is a whisper if ($Discussion->WhisperUserID > 0) { $Discussion->Name = @$Discussion->WhisperUsername . ": " . $Discussion->Name; } $UnreadQS = $Context->Session->User->Settings['comments_order'] == 'asc' ? GetUnreadQuerystring($Discussion) : ''; $LastQS = $Context->Session->User->Settings['comments_order'] == 'asc' ? GetLastCommentQuerystring($Discussion) : ''; $sReturn = "<dl class=\"Discussion" . $Discussion->Status . ($FirstRow ? " FirstDiscussion" : "") . ($Discussion->CountComments == 1 ? " NoReplies" : "") . (agUSE_CATEGORIES ? " Category_" . $Discussion->CategoryID : "") . "\">\r\n\t\t<dt class=\"DataItemLabel DiscussionTopicLabel\">" . $Context->GetDefinition("DiscussionTopic") . "</dt>\r\n\t\t<dd class=\"DataItem DiscussionTopic\">" . DiscussionPrefix($Discussion) . "<a href=\"comments.php?DiscussionID=" . $Discussion->DiscussionID . ($Context->Session->User->Setting("JumpToLastReadComment", 1) ? $UnreadQS : "") . "\">" . $Discussion->Name . "</a></dd>"; if (agUSE_CATEGORIES) { $sReturn .= "\r\n\t\t\t<dt class=\"MetaItemLabel DiscussionInformationLabel DiscussionCategoryLabel\">" . $Context->GetDefinition("Category") . "</dt>\r\n\t\t\t<dd class=\"MetaItem DiscussionInformation DiscussionCategory\"><a href=\"./?CategoryID=" . $Discussion->CategoryID . "\">" . $Discussion->Category . "</a></dd>\r\n\t\t\t"; } $sReturn .= "<dt class=\"MetaItemLabel DiscussionInformationLabel StarterLabel\"><a href=\"./comments.php?DiscussionID=" . $Discussion->DiscussionID . "#Item_1\">" . $Context->GetDefinition("StartedBy") . "</a></dt>\r\n\t\t<dd class=\"MetaItem DiscussionInformation Starter\"><a href=\"./account.php?u=" . $Discussion->AuthUserID . "\">" . $Discussion->AuthUsername . "</a></dd>\r\n\t\t<dt class=\"MetaItemLabel DiscussionInformationLabel CommentCountLabel\">" . $Context->GetDefinition("Comments") . "</dt>\r\n\t\t<dd class=\"MetaItem DiscussionInformation CommentCount\">" . $Discussion->CountComments . "</dd>\r\n\t\t<dt class=\"MetaItemLabel DiscussionInformationLabel LastReplierLabel\"><a href=\"./comments.php?DiscussionID=" . $Discussion->DiscussionID . $LastQS . "\">" . $Context->GetDefinition("LastCommentBy") . "</a></dt>\r\n\t\t<dd class=\"MetaItem DiscussionInformation LastReplier\"><a href=\"./account.php?u=" . $Discussion->LastUserID . "\">" . $Discussion->LastUsername . "</a></dd>\r\n\t\t<dt class=\"MetaItemLabel DiscussionInformationLabel LastActiveLabel\"><a href=\"./comments.php?DiscussionID=" . $Discussion->DiscussionID . $LastQS . "\">" . $Context->GetDefinition("LastActive") . "</a></dt>\r\n\t\t<dd class=\"MetaItem DiscussionInformation LastActive\">" . TimeDiff($Discussion->DateLastActive, mktime()) . "</dd>"; if ($Context->Session->UserID > 0) { $sReturn .= "<dt class=\"MetaItemLabel DiscussionInformationLabel NewCommentCountLabel" . ($Discussion->NewComments > 0 ? " NewCommentsPresentLabel" : "") . "\"><a href=\"comments.php?DiscussionID=" . $Discussion->DiscussionID . $UnreadQS . "\">" . $Context->GetDefinition("New") . "</a></dt>\r\n\t\t\t<dd class=\"MetaItem DiscussionInformation NewCommentCount" . ($Discussion->NewComments > 0 ? " NewCommentsPresent" : "") . "\"><a href=\"comments.php?DiscussionID=" . $Discussion->DiscussionID . $UnreadQS . "\">" . $Discussion->NewComments . "</a></dd>"; } $sReturn .= "</dl>\n"; return $sReturn; }
if ($Comment->WhisperUserID == $this->Context->Session->UserID && $Comment->AuthUserID == $this->Context->Session->UserID) { $CommentList .= $this->Context->GetDefinition('ToYourself'); } elseif ($Comment->WhisperUserID == $this->Context->Session->UserID) { $CommentList .= $this->Context->GetDefinition('ToYou'); } else { $CommentList .= str_replace('//1', $Comment->WhisperUsername, $this->Context->GetDefinition('ToX')); } } $CommentList .= '</li> <li> <span>' . $this->Context->GetDefinition('CommentTime') . '</span>' . TimeDiff($this->Context, $Comment->DateCreated); if ($Comment->DateEdited != '') { $CommentList .= ' <em>' . $this->Context->GetDefinition('Edited') . '</em>'; } if ($Comment->Deleted) { $CommentList .= ' <i>' . str_replace(array('//1', '//2'), array(TimeDiff($this->Context, $Comment->DateDeleted), $Comment->DeleteUsername), $this->Context->GetDefinition('CommentHiddenOnXByY')) . '</i>'; } // Whisper back button if (!$this->Discussion->Closed && $Comment->WhisperUserID > 0 && $Comment->WhisperUserID == $this->Context->Session->UserID) { $CommentList .= '<a class="WhisperBack" onclick="' . "WhisperBack('" . $Comment->DiscussionID . "', '" . str_replace("'", "\\'", $CommentAuthUsername) . "', '" . $this->Context->Configuration['BASE_URL'] . "');" . '">' . $this->Context->GetDefinition('WhisperBack') . '</a>'; } $CommentList .= '</li> </ul> <span> '; // Set up comment options $this->DelegateParameters['Comment'] =& $Comment; $this->DelegateParameters['CommentList'] =& $CommentList; $this->DelegateParameters['RowNumber'] =& $RowNumber; $CommentList .= $this->CallDelegate('PreCommentOptionsRender'); if ($this->Context->Session->UserID > 0) {
function Prefix() { if ($this->Context->WarningCollector->Count() > 0) { $sReturn = "<div class=\"ErrorContainer\">\r\n\t\t\t\t<div class=\"ErrorTitle\">" . $this->Context->GetDefinition("ErrorTitle") . "</div>" . $this->Context->WarningCollector->GetMessages() . "</div>"; } else { $PageDetails = $this->pl->GetPageDetails($this->Context); $PageList = $this->pl->GetNumericList(); // Format the discussion information $this->Discussion->ForceNameSpaces(); $sReturn = "<a class=\"PageJump Bottom\" href=\"#pgbottom\">" . $this->Context->GetDefinition("BottomOfPage") . "</a>" . "<div class=\"Title\">"; if (agUSE_CATEGORIES) { $sReturn .= "<a href=\"./?CategoryID=" . $this->Discussion->CategoryID . "\">" . $this->Discussion->Category . "</a>:<br/> "; } $sReturn .= DiscussionPrefix($this->Discussion) . " "; if ($this->Discussion->WhisperUserID > 0) { $sReturn .= $this->Discussion->WhisperUsername . ": "; } $sReturn .= $this->Discussion->Name . "</div>" . $PageList . "<div class=\"PageDetails\">" . $PageDetails . "</div>"; $Comment = $this->Context->ObjectFactory->NewObject($Context, "Comment"); $RowNumber = 0; $CommentID = 0; if ($this->Context->Session->User->Settings['comments_order'] == 'desc') { $LastViewCountComments = $this->CommentDataCount - $this->Discussion->LastViewCountComments; } else { $LastViewCountComments = $this->Discussion->LastViewCountComments; } echo '<!-- $LastViewCountComments is: ' . $LastViewCountComments . ',' . $this->Context->Session->User->Settings['comments_order'] . '-->'; $sReturn .= "<div class=\"CommentGrid\" id=\"CommentGrid\">\n"; while ($Row = $this->Context->Database->GetRow($this->CommentData)) { $RowNumber++; $Comment->Clear(); $Comment->GetPropertiesFromDataSet($Row, $this->Context->Session->UserID); $ShowHtml = $Comment->FormatPropertiesForDisplay($this->Context); $sReturn .= "<a name=\"Comment_" . $Comment->CommentID . "\"></a>\r\n\t\t\t\t\t\t<a name=\"Item_" . $RowNumber . "\"></a>\r\n\t\t\t\t\t\t<div class=\"Comment " . $Comment->Status . ($RowNumber == 1 ? " FirstComment" : "") . "\">"; $sReturn .= "<div class=\"CommentHeader\">\n"; if ($Comment->Deleted) { $sReturn .= "<div class=\"ErrorContainer CommentHidden\">\r\n\t\t\t\t\t\t\t\t<div class=\"Error\">" . $this->Context->GetDefinition("CommentHiddenOn") . " " . date("F jS Y \\a\\t g:ia", $Comment->DateDeleted) . " " . $this->Context->GetDefinition("By") . " " . $Comment->DeleteUsername . ".</div>\r\n\t\t\t\t\t\t\t</div>"; } $ShowIcon = 0; if ($this->Context->Session->User->Setting("HtmlOn", 1)) { $ShowIcon = 1; } $sReturn .= "<div onclick=\"toggleCommentBody('" . $Comment->CommentID . "')\" class=\"ShowHide\" id=\"CommBodySwitcher_" . $Comment->CommentID . "\">"; if ($this->Context->Session->User->Settings['comments_order'] == 'asc') { $sReturn .= ($RowNumber >= $LastViewCountComments ? "Hide" : "Show") . "</div>\n"; } else { $sReturn .= ($RowNumber <= $LastViewCountComments ? "Hide" : "Show") . "</div>\n"; } $sReturn .= "<div class=\"CommentAuthor" . ($ShowIcon ? " CommentAuthorWithIcon" : "") . "\">"; if ($ShowIcon) { $sReturn .= "<span class=\"CommentIcon\" style=\"background-image:url('" . ($Comment->AuthIcon !== "" ? $Comment->AuthIcon : "images/def_icon.png") . "')\"></span>"; } // echo "<!-- icon is: [".$Comment->AuthIcon."]-->"; $sReturn .= "<a href=\"account.php?u=" . $Comment->AuthUserID . "\">" . $Comment->AuthFullName . "</a></div>"; if ($Comment->WhisperUserID > 0) { $sReturn .= "<div class=\"CommentWhisper\">" . $this->Context->GetDefinition("To") . " "; if ($Comment->WhisperUserID == $this->Context->Session->UserID && $Comment->AuthUserID == $this->Context->Session->UserID) { $sReturn .= $this->Context->GetDefinition("Yourself"); } elseif ($Comment->WhisperUserID == $this->Context->Session->UserID) { $sReturn .= $this->Context->GetDefinition("You"); } else { $this->Context->UserManager = $this->Context->ObjectFactory->NewContextObject($this->Context, "UserManager"); $WhisperUser = $this->Context->UserManager->GetUserById($Comment->WhisperUserID); $sReturn .= $WhisperUser->FullName; } $sReturn .= "</div>\n"; } $sReturn .= "<div class=\"CommentTime\">#" . $Comment->CommentID . " " . TimeDiff($Comment->DateCreated); if ($Comment->DateEdited != "") { $sReturn .= " <em>" . $this->Context->GetDefinition("Edited") . "</em>\n"; } $sReturn .= "</div>\r\n\t\t\t\t\t<div class=\"CommentOptions\">"; if ($this->Context->Session->UserID > 0) { if ($this->Context->Session->User->CanViewIps) { $sReturn .= "<div class=\"CommentIp\">" . $this->Context->GetDefinition("CommentPostedFrom") . " " . $Comment->RemoteIp . "</div>\n"; } if ($Comment->AuthUserID == $this->Context->Session->UserID || $this->Context->Session->User->AdminCategories) { if (!$this->Discussion->Closed && $this->Discussion->Active || $this->Context->Session->User->AdminCategories) { $sReturn .= "<div class=\"CommentEdit\"><a href=\"post.php?CommentID=" . $Comment->CommentID . "\">" . $this->Context->GetDefinition("Edit") . "</a></div>\n"; } if ($this->Context->Session->User->AdminCategories) { $sReturn .= "<div class=\"CommentHide\"><a href=\"javascript:ManageComment('" . ($Comment->Deleted ? "0" : "1") . "', '" . $this->Discussion->DiscussionID . "', '" . $Comment->CommentID . "', '" . $this->Context->GetDefinition("ShowConfirm") . "', '" . $this->Context->GetDefinition("HideConfirm") . "');\">" . $this->Context->GetDefinition($Comment->Deleted ? "Show" : "Hide") . "</a></div>\n"; } } } $sReturn .= "</div>"; if ($Comment->AuthRoleDesc != "") { $sReturn .= "<div class=\"CommentNotice\">" . $Comment->AuthRoleDesc . "</div>"; } $sReturn .= "</div><div class=\""; if ($this->Context->Session->User->Settings['comments_order'] == 'asc') { $sReturn .= ($RowNumber >= $LastViewCountComments ? "CommentBody" : "CommentBodyHidden") . "\" id=\"CommentBody_" . $Comment->CommentID . "\">"; } else { $sReturn .= ($RowNumber <= $LastViewCountComments ? "CommentBody" : "CommentBodyHidden") . "\" id=\"CommentBody_" . $Comment->CommentID . "\">"; } if ($this->Context->Session->User->Settings['comments_order'] == 'asc') { $sReturn .= $RowNumber >= $LastViewCountComments ? $Comment->Body . "<p><input type=\"button\" onclick=\"addQuoteToCommentBody(" . $Comment->CommentID . ")\" class=\"Button QuoteButton\" id=\"CommentQuote_" . $Comment->CommentID . "\" value=\"" . $this->Context->GetDefinition("Quote") . "\" /></p>" : ""; } else { $sReturn .= $RowNumber <= $LastViewCountComments ? $Comment->Body . "<p><input type=\"button\" onclick=\"addQuoteToCommentBody(" . $Comment->CommentID . ")\" class=\"Button QuoteButton\" id=\"CommentQuote_" . $Comment->CommentID . "\" value=\"" . $this->Context->GetDefinition("Quote") . "\" /></p>" : ""; } $sReturn .= "</div>"; //id=\"Comment_".$Comment->CommentID."\">".$Comment->Body."</div>"; if ($Comment->WhisperUserID > 0 && $Comment->WhisperUserID == $this->Context->Session->UserID) { $sReturn .= "<div class=\"WhisperBack\"><a href=\"Javascript:WhisperBack('" . $Comment->DiscussionID . "', '" . str_replace("'", "\\'", $Comment->AuthUsername) . "');\">" . $this->Context->GetDefinition("WhisperBack") . "</a></div>"; } $sReturn .= "</div>"; } $sReturn .= "</div>\n" . $PageList . "<div class=\"PageDetails\">" . $PageDetails . "</div>"; if ($this->ShowForm) { $sReturn .= "<a name=\"addcomments\"></a>\r\n\t\t\t\t\t<div class=\"Title AddCommentsTitle\">" . $this->Context->GetDefinition("AddYourComments") . "</div>"; } } return $sReturn; }
?> </td> <td><?php echo $rowIDLETIMEHISTORY['idle_name']; ?> </td> <td align="center"><?php echo dateFormat($rowIDLETIMEHISTORY['time_start'], "h:i"); ?> </td> <td align="center"><?php echo dateFormat($rowIDLETIMEHISTORY['time_end'], "h:i"); ?> </td> <?php $difference = TimeDiff($rowIDLETIMEHISTORY['time_start'], $rowIDLETIMEHISTORY['time_end']) / 60 . " minutes"; $totalidletime += $difference; ?> <td align="right"><?php echo $difference; ?> </td> <td><?php echo $rowIDLETIMEHISTORY['remarks']; ?> </td> </tr> <?php } ?> <tr>
function FullComment($CommentID) { $cm = $this->Context->ObjectFactory->NewContextObject($this->Context, "CommentManager"); $Comment = $cm->GetCommentById($CommentID, "0"); $sReturn = "<a name=\"Comment_" . $Comment->CommentID . "\"></a>\n <a name=\"Item_\"></a>\n <div class=\"Comment \">"; $sReturn .= "<div class=\"CommentHeader\">\n"; if ($Comment->Deleted) { $sReturn .= "<div class=\"ErrorContainer CommentHidden\">\n <div class=\"Error\">" . $this->Context->GetDefinition("CommentHiddenOn") . " " . date("F jS Y \\a\\t g:ia", $Comment->DateDeleted) . " " . $this->Context->GetDefinition("By") . " " . $Comment->DeleteUsername . ".</div>\n </div>"; } $ShowIcon = 0; if ($this->Context->Session->User->Setting("HtmlOn", 1)) { $ShowIcon = 1; } $sReturn .= "<div onclick=\"toggleCommentBody('" . $CommentID . "')\" class=\"ShowHide\" id=\"CommBodySwitcher_" . $Comment->CommentID . "\">" . "Hide" . "</div>\n"; $sReturn .= "<div class=\"CommentAuthor" . ($ShowIcon ? " CommentAuthorWithIcon" : "") . "\">"; if ($ShowIcon) { $sReturn .= "<span class=\"CommentIcon\" style=\"background-image:url('" . ($Comment->AuthIcon !== "" ? $Comment->AuthIcon : "images/def_icon.png") . "')\"></span>"; } $sReturn .= "<a href=\"account.php?u=" . $Comment->AuthUserID . "\">" . $Comment->AuthFullName . "</a></div>"; if ($Comment->WhisperUserID > 0) { $sReturn .= "<div class=\"CommentWhisper\">" . $this->Context->GetDefinition("To") . " "; if ($Comment->WhisperUserID == $this->Context->Session->UserID && $Comment->AuthUserID == $this->Context->Session->UserID) { $sReturn .= $this->Context->GetDefinition("Yourself"); } elseif ($Comment->WhisperUserID == $this->Context->Session->UserID) { $sReturn .= $this->Context->GetDefinition("You"); } else { $this->Context->UserManager = $this->Context->ObjectFactory->NewContextObject($this->Context, "UserManager"); $WhisperUser = $this->Context->UserManager->GetUserById($Comment->WhisperUserID); $sReturn .= $WhisperUser->FullName; } $sReturn .= "</div>\n"; } $sReturn .= "<div class=\"CommentTime\">#" . $Comment->CommentID . " " . TimeDiff($Comment->DateCreated); if ($Comment->DateEdited != "") { $sReturn .= " <em>" . $this->Context->GetDefinition("Edited") . "</em>\n"; } $sReturn .= "</div>\n <div class=\"CommentOptions\">"; if ($this->Context->Session->UserID > 0) { if ($this->Context->Session->User->CanViewIps) { $sReturn .= "<div class=\"CommentIp\">" . $this->Context->GetDefinition("CommentPostedFrom") . " " . $Comment->RemoteIp . "</div>\n"; } if ($Comment->AuthUserID == $this->Context->Session->UserID || $this->Context->Session->User->AdminCategories) { $sReturn .= "<div class=\"CommentEdit\"><a href=\"post.php?CommentID=" . $Comment->CommentID . "\">" . $this->Context->GetDefinition("Edit") . "</a></div>\n"; if ($this->Context->Session->User->AdminCategories) { $sReturn .= "<div class=\"CommentHide\"><a href=\"javascript:ManageComment('" . ($Comment->Deleted ? "0" : "1") . "', '" . $this->Discussion->DiscussionID . "', '" . $Comment->CommentID . "', '" . $this->Context->GetDefinition("ShowConfirm") . "','" . $this->Context->GetDefinition("HideConfirm") . "');\">" . $this->Context->GetDefinition($Comment->Deleted ? "Show" : "Hide") . "</a></div>\n"; } } } $sReturn .= "</div>"; if ($Comment->AuthRoleDesc != "") { $sReturn .= "<div class=\"CommentNotice\">" . $Comment->AuthRoleDesc . "</div>"; } $sReturn .= "</div><div class=\"CommentBody\" id=\"CommentBody_" . $Comment->CommentID . "\">" . $Comment->Body . "</div>"; $sReturn .= "<input type=\"button\" onclick=\"addQuoteToCommentBody(" . $Comment->CommentID . ")\" class=\"Button QuoteButton\" id=\"CommentQuote_" . $Comment->CommentID . "\" value=\"" . $this->Context->GetDefinition("Quote") . "\" />"; if ($Comment->WhisperUserID > 0 && $Comment->WhisperUserID == $this->Context->Session->UserID) { $sReturn .= "<div class=\"WhisperBack\"><a href=\"Javascript:WhisperBack('" . $Comment->DiscussionID . "', '" . str_replace("'", "\\'", $Comment->AuthUsername) . "');\">" . $this->Context->GetDefinition("WhisperBack") . "</a></div>"; } $sReturn .= "</div>"; return $sReturn; }
require_once '../incl/heartbeat.incl.php'; RunMeNTimes(1); CatchKill(); ini_set('memory_limit', '256M'); if (!DBConnect()) { DebugMessage('Cannot connect to db!', E_USER_ERROR); } $db->query('set session transaction isolation level read uncommitted'); $luaQuoteChange = ["\r" => '\\r', "\n" => '\\n', chr(26) => '\\026']; heartbeat(); file_put_contents('../addon/GetDetailedItemLevelInfo.lua', BuildGetDetailedItemLevelInfo()); file_put_contents('../addon/BonusSets.lua', BuildBonusSets()); file_put_contents('../addon/MarketData-US.lua', BuildAddonData('US')); file_put_contents('../addon/MarketData-EU.lua', BuildAddonData('EU')); MakeZip($zipPath); DebugMessage('Done! Started ' . TimeDiff($startTime)); function BuildGetDetailedItemLevelInfo() { global $db; $lua = <<<'EOF' --[[ GetDetailedItemLevelInfo Polyfill, v 1.0 by Erorus for The Undermine Journal https://theunderminejournal.com/ Based on these "specs" for a GetDetailedItemLevelInfo function coming in 7.1 https://www.reddit.com/r/woweconomy/comments/50hp5d/warning_be_careful_flipping/d74olsy Pass in an itemstring/link to GetDetailedItemLevelInfo Returns effectiveItemLevel, previewItemLevel, baseItemLevel
$file = []; $file['note'] = 'Brought to you by https://does.theapi.work/'; $file['started'] = JSNow(); foreach (['us', 'eu'] as $region) { $file['regions'][$region] = FetchRegionData($region); if ($caughtKill) { break; } } $file['finished'] = JSNow(); if (!$caughtKill) { $fn = isset($argv[1]) ? $argv[1] : __DIR__ . '/../theapi.work/times.json'; AtomicFilePutContents($fn, json_encode($file, JSON_NUMERIC_CHECK | JSON_UNESCAPED_UNICODE)); } DebugMessage("Opened {$connectionTracking['created']} connections to service {$connectionTracking['requests']} requests."); DebugMessage('Done! Started ' . TimeDiff($startTime, ['precision' => 'second'])); function JSNow() { return floor(microtime(true) * 1000); } function FetchRegionData($region) { global $caughtKill; $region = trim(strtolower($region)); $results = []; DebugMessage("Fetching realms for {$region}"); $url = GetBattleNetURL($region, 'wow/realm/status'); $jsonString = HTTP::Get($url); $json = json_decode($jsonString, true); if (json_last_error() != JSON_ERROR_NONE) { DebugMessage("Error decoding " . strlen($jsonString) . " length JSON string for {$region}: " . json_last_error_msg(), E_USER_WARNING);
' . $this->Get_PostBackForm('frmApplicants') . ' <p>' . $this->Context->GetDefinition('ApplicantsNotes') . '</p> <ul>'; if ($this->Context->Database->RowCount($this->ApplicantData) > 0) { echo '<li class="CheckController"><p>' . $this->Context->GetDefinition('Check') . " <a href=\"./\" onclick=\"CheckAll('ApplicantID'); return false;\">" . $this->Context->GetDefinition('All') . '</a>, ' . " <a href=\"./\" onclick=\"CheckNone('ApplicantID'); return false;\">" . $this->Context->GetDefinition('None') . '</a></p></li>'; $ApplicantList = ''; $Applicant = $this->Context->ObjectFactory->NewContextObject($this->Context, 'User'); while ($Row = $this->Context->Database->GetRow($this->ApplicantData)) { $Applicant->Clear(); $Applicant->GetPropertiesFromDataSet($Row); $Applicant->FormatPropertiesForDisplay(); $ApplicantList .= '<li class="Enabled"> <h3> ' . GetDynamicCheckBox('ApplicantID[]', $Applicant->UserID, 0, '', $Applicant->Name, '', 'ApplicantID' . $Applicant->UserID) . ' <span class="Applied"><a href="' . GetUrl($this->Context->Configuration, 'account.php', '', 'u', $Applicant->UserID) . '">' . TimeDiff($this->Context, $Applicant->DateFirstVisit, mktime()) . '</a></span> <span class="EmailAddress">' . FormatHyperlink('mailto:' . $Applicant->Email) . '</span>'; $this->DelegateParameters['Applicant'] =& $Applicant; $this->DelegateParameters['ApplicantList'] =& $ApplicantList; $this->CallDelegate('PostEmailAddress'); $ApplicantList .= '</h3> <p>' . $Applicant->Discovery . '</p> </li>'; } echo $ApplicantList; } else { echo '<li class="NoApplicants"><p>' . $this->Context->GetDefinition('NoApplicants') . '</p></li>'; } echo '</ul>'; if ($this->Context->Database->RowCount($this->ApplicantData) > 0) { echo '<div class="Approve">
function ShowRealms() { echo '<h1>Realms</h1>'; global $db; $sql = <<<EOF SELECT r.house, r.region, r.canonical, sch.nextcheck scheduled, hc.nextcheck delayednext, sch.lastupdate, sch.mindelta, sch.avgdelta, sch.maxdelta FROM tblRealm r left join tblHouseCheck hc on hc.house = r.house left join ( select deltas.house, timestampadd(second, least(ifnull(min(delta)+15-120, 45*60), 150*60), max(deltas.updated)) nextcheck, max(deltas.updated) lastupdate, min(delta) mindelta, round(avg(delta)) avgdelta, max(delta) maxdelta from ( select sn.updated, if(@prevhouse = sn.house and sn.updated > timestampadd(hour, -72, now()), unix_timestamp(sn.updated) - @prevdate, null) delta, @prevdate := unix_timestamp(sn.updated) updated_ts, @prevhouse := sn.house house from (select @prevhouse := null, @prevdate := null) setup, tblSnapshot sn order by sn.house, sn.updated) deltas group by deltas.house ) sch on sch.house = r.house where r.canonical is not null order by unix_timestamp(ifnull(delayednext, scheduled)) - unix_timestamp(scheduled) desc, ifnull(delayednext, scheduled), sch.lastupdate, region, canonical EOF; $stmt = $db->prepare($sql); $stmt->execute(); $result = $stmt->get_result(); $rows = DBMapArray($result, null); echo '<table cellspacing="0"><tr><th>House</th><th>Region</th><th>Canonical</th><th>Updated</th><th>Scheduled</th><th>Min</th><th>Avg</th><th>Max</th></tr>'; foreach ($rows as &$row) { echo '<tr><td class="r">' . $row['house'] . '</td>'; echo '<td>' . $row['region'] . '</td>'; echo '<td><a href="?bnetget=' . $row['region'] . '-' . $row['canonical'] . '">' . $row['canonical'] . '</a></td>'; if (is_null($row['lastupdate'])) { echo '<td> </td>'; } else { $css = ''; $updateDelta = time() - strtotime($row['lastupdate']); if ($updateDelta > $row['maxdelta'] + 180) { $css = 'color: red'; } elseif ($updateDelta > $row['avgdelta'] + 60) { $css = 'color: #999900'; } echo '<td style="' . $css . '" class="r">' . TimeDiff(strtotime($row['lastupdate'])) . '</td>'; } if (is_null($row['scheduled'])) { echo '<td> </td>'; } elseif (is_null($row['delayednext'])) { echo '<td style="color: green" class="r">' . TimeDiff(strtotime($row['scheduled'])) . '</td>'; } else { echo '<td style="color: #999900" class="r">' . TimeDiff(strtotime($row['delayednext'])) . '</td>'; } echo '<td class="r">' . round(intval($row['mindelta'], 10) / 60) . ' min</td>'; echo '<td class="r">' . round(intval($row['avgdelta'], 10) / 60) . ' min</td>'; echo '<td class="r">' . round(intval($row['maxdelta'], 10) / 60) . ' min</td>'; echo '</tr>'; } unset($row); echo '</table>'; }
function APIMaintenance($when = -1, $expire = false) { if (!function_exists('MCGet')) { DebugMessage('Tried to test for APIMaintenance without memcache loaded!', E_USER_ERROR); } $cacheKey = 'APIMaintenance'; if ($when == -1) { return MCGet($cacheKey); } if ($when === false) { $when = 0; } if (!is_numeric($when)) { $when = strtotime($when); } if ($when) { if ($expire == false) { $expire = $when + 72 * 60 * 60; } elseif (!is_numeric($expire)) { $expire = strtotime($expire); } DebugMessage('Setting API maintenance mode, expected to end ' . TimeDiff($when) . ', maximum ' . TimeDiff($expire)); MCSet($cacheKey, $when, $expire); } else { DebugMessage('Ending API maintenance mode.'); MCDelete($cacheKey); } return $when; }
function BuildDataIntervalsTable(&$rows) { $tr = <<<EOF <table border="1" cellspacing="0" cellpadding="5"> <tr> <th>Region</th> <th>Realms</th> <th>Minimum Delay</th> <th>Usual Delay</th> <th>Average Delay</th> <th>Maximum Delay</th> <th>Last Update</th> </tr> EOF; foreach ($rows as $row) { $tr .= '<tr>'; $tr .= '<td>' . $row['region'] . '</td>'; $tr .= '<td>' . $row['nms'] . '</td>'; $tr .= '<td align="right">' . (is_null($row['mindelta']) ? '' : DeltaToMinutes($row['mindelta'])) . '</td>'; $tr .= '<td align="right">' . (is_null($row['modedelta']) ? '' : DeltaToMinutes($row['modedelta'])) . '</td>'; $tr .= '<td align="right">' . (is_null($row['avgdelta']) ? '' : DeltaToMinutes($row['avgdelta'])) . '</td>'; $tr .= '<td align="right">' . (is_null($row['maxdelta']) ? '' : DeltaToMinutes($row['maxdelta'])) . '</td>'; $tr .= '<td align="right">' . TimeDiff(strtotime($row['lastupdate'])) . '</td>'; $tr .= '</tr>'; } $tr .= '</table>'; return $tr; }
function MCHouseLock($house, $waitSeconds = 30) { global $MCHousesLocked; static $registeredShutdown = false; if (isset($MCHousesLocked[$house])) { return true; } $giveUpAt = microtime(true) + $waitSeconds; $me = ['pid' => getmypid(), 'script' => $_SERVER["SCRIPT_FILENAME"], 'when' => time()]; do { if (MCAdd('mchouselock_' . $house, $me, 30 * 60)) { $MCHousesLocked[$house] = true; if (!$registeredShutdown) { $registeredShutdown = true; register_shutdown_function('MCHouseUnlock'); } return true; } usleep(500000); } while ($giveUpAt > microtime(true)); $currentLock = MCGet('mchouselock_' . $house); DebugMessage("Could not get house lock for {$house}, owned by " . $currentLock['pid'] . ' ' . $currentLock['script'] . ' ' . TimeDiff($currentLock['when'])); return false; }
$sumtime=0; while(list($hn,$time_opd,$time_dc) = mysql_fetch_row($result)){ // $sql = "Select count(hn) From opcard_now where hn = '".$hn."' limit 1 "; // list($rows) = mysql_fetch_row(mysql_query($sql)); // if($rows > 0){ $sql = "Select vn, hn , ptname, time1_1, time2_1 From opday_now where hn = '".$hn."' limit 1 "; $result_opday_now = mysql_query($sql); list($vn, $hn, $ptname,$time_reg,$time_freg) = mysql_fetch_row($result_opday_now); // $sql = "Select time_format(stkcutdate,'%H:%i') From dphardep_now where tvn = '".$vn."' limit 1 "; // list($time_drug) = mysql_fetch_row(mysql_query($sql)); $totaltime= TimeDiff($time_reg,$time_opd); if(!empty($hn) && !empty($time_reg) && !empty($time_opd) && ($time_reg < $time_opd) && ($totaltime >=5 && $totaltime<=30)){ $i++; echo " <TR> <TD>".$i.".</TD> <TD>".$hn."</TD> <TD>".$ptname."</TD> <TD>".$time_reg."</TD> <TD>".$time_opd."</TD> <TD>".$totaltime."</TD> </TR>"; $sumtime=$sumtime+$totaltime; } //close if // } //close if } //close while
function Render_NoPostBack() { $this->Render_SearchForm(); if ($this->PostBackAction == "Search") { $this->PageDetails = "<div class=\"PageDetails\">" . ($this->PageDetails ? $this->Context->GetDefinition("Results") . $this->PageDetails : $this->Context->GetDefinition("NoResultsFound")) . ($this->Search->Query == "" ? "" : " " . $this->Context->GetDefinition("for") . " <strong>" . $this->Search->Query . "</strong>") . "</div>"; // Set up the "save search" form $this->PostBackParams->Clear(); $this->PostBackParams->Add("Type", $this->Search->Type); $this->PostBackParams->Add("Keywords", $this->Search->Keywords, 0); $this->PostBackParams->Add("SearchID", $this->Search->SearchID); $this->PostBackParams->Add("PostBackAction", "SaveSearch"); $this->Context->Writer->Add("<div class=\"SearchLabelForm\">"); if ($this->Context->Session->UserID > 0) { $this->Render_PostBackForm("frmLabelSearch", "post"); $this->Context->Writer->Add("<input type=\"text\" name=\"Label\" class=\"SearchLabelInput\" value=\"" . $this->Search->Label . "\" maxlength=\"30\" />\r\n\t\t\t\t\t<input type=\"submit\" name=\"btnLabel\" value=\"" . $this->Context->GetDefinition("SaveSearch") . "\" class=\"SearchLabelButton\" />\r\n\t\t\t\t\t</form>"); } else { $this->Context->Writer->Add(" "); } $this->Context->Writer->Add("</div>" . "<div class=\"Title\">" . $this->Context->GetDefinition($this->Search->Type) . "</div>" . $this->PageList . $this->PageDetails); if ($this->DataCount > 0) { $Switch = 0; $FirstRow = 1; $Counter = 0; if ($this->Search->Type == "Topics") { $Discussion = $this->Context->ObjectFactory->NewObject($this->Context, "Discussion"); while ($Row = $this->Context->Database->GetRow($this->Data)) { $Discussion->Clear(); $Discussion->GetPropertiesFromDataSet($Row); $Discussion->FormatPropertiesForDisplay(); $Discussion->ForceNameSpaces(); if ($Counter < agSEARCH_RESULTS_PER_PAGE) { $this->Context->Writer->Add(GetDiscussion($this->Context, $Discussion, $FirstRow)); } $FirstRow = 0; $Counter++; } } elseif ($this->Search->Type == "Comments") { $Comment = $this->Context->ObjectFactory->NewObject($this->Context, "Comment"); $HighlightWords = ParseQueryForHighlighting($this->Context, $this->Search->Query); while ($Row = $this->Context->Database->GetRow($this->Data)) { $Comment->Clear(); $Comment->GetPropertiesFromDataSet($Row, $this->Context->Session->UserID); $Comment->FormatPropertiesForSafeDisplay(); if ($Counter < agSEARCH_RESULTS_PER_PAGE) { $this->Context->Writer->Add(GetCommentResult($this->Context, $Comment, $HighlightWords, $FirstRow)); } $FirstRow = 0; $Counter++; } } else { $u = $this->Context->ObjectFactory->NewContextObject($this->Context, "User"); while ($Row = $this->Context->Database->GetRow($this->Data)) { $Switch = $Switch == 1 ? 0 : 1; $u->Clear(); $u->GetPropertiesFromDataSet($Row); $u->FormatPropertiesForDisplay(); if ($Counter < agSEARCH_RESULTS_PER_PAGE) { $ShowIcon = $u->DisplayIcon != "" && $this->Context->Session->User->Setting("HtmlOn", 1); $this->Context->Writer->Add("<dl class=\"User" . ($Switch == 1 ? "" : "Alternate") . ($FirstRow ? " FirstUser" : "") . "\">\r\n\t\t\t\t\t\t\t\t<dt class=\"DataItemLabel SearchUserLabel\">" . $this->Context->GetDefinition("User") . "</dt>\r\n\t\t\t\t\t\t\t\t<dd class=\"DataItem SearchUser" . ($ShowIcon ? " SearchUserWithIcon" : "") . "\">"); if ($ShowIcon) { $this->Context->Writer->Add("<span class=\"SearchIcon\" style=\"background-image:url('" . $u->DisplayIcon . "');\"></span>"); } $this->Context->Writer->Add("<a href=\"account.php?u=" . $u->UserID . "\">" . $u->Name . "</a> (" . $u->Role . ")\r\n\t\t\t\t\t\t\t\t</dd>\r\n\t\t\t\t\t\t\t\t<dt class=\"MetaItemLabel SearchUserInformationLabel SearchUserAccountCreatedLabel\">" . $this->Context->GetDefinition("AccountCreated") . "</dt>\r\n\t\t\t\t\t\t\t\t<dd class=\"MetaItem SearchUserInformation SearchUserAccountCreated\">" . TimeDiff($u->DateFirstVisit, mktime()) . "</dd>\r\n\t\t\t\t\t\t\t\t<dt class=\"MetaItemLabel SearchUserInformationLabel SearchUserLastActiveLabel\">" . $this->Context->GetDefinition("LastActive") . "</dt>\r\n\t\t\t\t\t\t\t\t<dd class=\"MetaItem SearchUserInformation SearchUserLastActive\">" . TimeDiff($u->DateLastActive, mktime()) . "</dd>\r\n\t\t\t\t\t\t\t\t<dt class=\"MetaItemLabel SearchUserInformationLabel SearchUserVisitCountLabel\">" . $this->Context->GetDefinition("VisitCount") . "</dt>\r\n\t\t\t\t\t\t\t\t<dd class=\"MetaItem SearchUserInformation SearchUserVisitCount\">" . $u->CountVisit . "</dd>\r\n\t\t\t\t\t\t\t\t<dt class=\"MetaItemLabel SearchUserInformationLabel SearchUserDiscussionsCreatedLabel\">" . $this->Context->GetDefinition("DiscussionsCreated") . "</dt>\r\n\t\t\t\t\t\t\t\t<dd class=\"MetaItem SearchUserInformation SearchUserDiscussionsCreated\">" . $u->CountDiscussions . "</dd>\r\n\t\t\t\t\t\t\t\t<dt class=\"MetaItemLabel SearchUserInformationLabel SearchUserCommentsAddedLabel\">" . $this->Context->GetDefinition("CommentsAdded") . "</dt>\r\n\t\t\t\t\t\t\t\t<dd class=\"MetaItem SearchUserInformation SearchUserCommentsAdded\">" . $u->CountComments . "</dd>\r\n\t\t\t\t\t\t\t</dl>"); } $FirstRow = 0; $Counter++; } } } if ($this->DataCount > 0) { $this->Context->Writer->Add($this->PageList . $this->PageDetails . "<a class=\"PageJump Top\" href=\"#pgtop\">" . $this->Context->GetDefinition("TopOfPage") . "</a>"); } } $this->Context->Writer->Write(); }
function Render() { if ($this->Context->WarningCollector->Count() == 0 && $this->PostBackAction == "") { $this->Context->Writer->Add("<div class=\"RoleHistory\">\r\n\t\t\t\t<h1>" . $this->Context->GetDefinition("RoleHistory") . "</h1>"); // Loop through the user's role history $UserHistory = $this->Context->ObjectFactory->NewObject($this->Context, "UserRoleHistory"); if ($this->Context->Database->RowCount($this->History) == 0) { $this->Context->Writer->Add("<blockquote>" . $this->Context->GetDefinition("NoRoleHistory") . "</blockquote>"); } else { while ($Row = $this->Context->Database->GetRow($this->History)) { $UserHistory->Clear(); $UserHistory->GetPropertiesFromDataSet($Row); $UserHistory->FormatPropertiesForDisplay($this->Context); $this->Context->Writer->Add("<blockquote>\r\n\t\t\t\t\t\t\t<h2>" . $UserHistory->Role . "</strong></h2> <small>(" . TimeDiff($UserHistory->Date, mktime()) . ")</small>\r\n\t\t\t\t\t\t\t<h3>" . $this->Context->GetDefinition("RoleAssignedBy") . " " . ($UserHistory->AdminUserID == 0 ? $this->Context->GetDefinition("Applicant") : "<a href=\"account.php?u=" . $UserHistory->AdminUserID . "\">" . $UserHistory->AdminUsername . "</a>") . " " . $this->Context->GetDefinition("WithTheFollowingNotes") . "</h3>\r\n\t\t\t\t\t\t\t<p>" . $UserHistory->Notes . "</p>\r\n\t\t\t\t\t\t</blockquote>"); } } $this->Context->Writer->Write("</div>"); } }
echo '<li> <h3>' . $this->Context->GetDefinition('RealName') . '</h3> <p class="fn">' . ReturnNonEmpty($this->User->FullName) . '</p> </li>'; } echo '<li> <h3>' . $this->Context->GetDefinition('Email') . '</h3> <p class="email">' . ($this->Context->Session->UserID > 0 && $this->User->UtilizeEmail ? GetEmail($this->User->Email) : $this->Context->GetDefinition('NA')) . '</p> </li> <li> <h3>' . $this->Context->GetDefinition('AccountCreated') . '</h3> <p>' . TimeDiff($this->Context, $this->User->DateFirstVisit, mktime()) . '</p> </li> <li> <h3>' . $this->Context->GetDefinition('LastActive') . '</h3> <p>' . TimeDiff($this->Context, $this->User->DateLastActive, mktime()) . '</p> </li> <li> <h3>' . $this->Context->GetDefinition('VisitCount') . '</h3> <p>' . $this->User->CountVisit . '</p> </li> <li> <h3>' . $this->Context->GetDefinition('DiscussionsStarted') . '</h3> <p>' . $this->User->CountDiscussions . '</p> </li> <li> <h3>' . $this->Context->GetDefinition('CommentsAdded') . '</h3> <p>' . $this->User->CountComments . '</p> </li>'; $this->CallDelegate('PostBasicPropertiesRender'); if ($this->Context->Session->User->Permission('PERMISSION_IP_ADDRESSES_VISIBLE')) {
function NextDataFile() { $dir = scandir(substr(SNAPSHOT_PATH, 0, -1), SCANDIR_SORT_ASCENDING); $lockFail = false; $gotFile = false; foreach ($dir as $fileName) { if (preg_match('/^(\\d+)-(\\d+)\\.json$/', $fileName, $res)) { if (($handle = fopen(SNAPSHOT_PATH . $fileName, 'rb')) === false) { continue; } if (!flock($handle, LOCK_EX | LOCK_NB)) { $lockFail = true; fclose($handle); continue; } if (feof($handle)) { fclose($handle); unlink(SNAPSHOT_PATH . $fileName); continue; } $snapshot = intval($res[1], 10); $house = intval($res[2], 10); if (!MCHouseLock($house, 3)) { $lockFail = true; continue; } $gotFile = $fileName; break; } } unset($dir); if (!$gotFile) { return $lockFail ? 3 : 10; } DebugMessage("House " . str_pad($house, 5, ' ', STR_PAD_LEFT) . " data file from " . TimeDiff($snapshot, array('parts' => 2, 'precision' => 'second'))); $json = json_decode(fread($handle, filesize(SNAPSHOT_PATH . $fileName)), true); ftruncate($handle, 0); fclose($handle); unlink(SNAPSHOT_PATH . $fileName); if (json_last_error() != JSON_ERROR_NONE) { DebugMessage("House " . str_pad($house, 5, ' ', STR_PAD_LEFT) . " {$snapshot} data file corrupted! " . json_last_error_msg(), E_USER_WARNING); MCHouseUnlock($house); return 0; } ParseAuctionData($house, $snapshot, $json); MCHouseUnlock($house); return 0; }
} } if (MCHouseLock($curHouse)) { DBQueryWithError($db, sprintf('UPDATE tblRealm SET canonical = NULL WHERE house = %d', $curHouse)); DBQueryWithError($db, sprintf('UPDATE tblRealm SET canonical = \'%s\' WHERE house = %d AND region = \'%s\' AND slug = \'%s\'', $db->escape_string($canon), $curHouse, $db->escape_string($region), $db->escape_string($rep))); MCHouseUnlock($curHouse); } else { PrintImportantMessage("Could not lock {$curHouse} to set canonical to {$canon}"); } MCHouseUnlock(); } $memcache->delete('realms_' . $region); } //CleanOldHouses(); //DebugMessage('Skipped cleaning old houses!'); PrintImportantMessage('Done! Started ' . TimeDiff($startTime)); function GetDataRealms($region, $hash) { heartbeat(); $region = strtolower($region); $pth = __DIR__ . '/realms2houses_cache'; if (!is_dir($pth)) { DebugMessage('Could not find realms2houses_cache!', E_USER_ERROR); } $cachePath = "{$pth}/{$region}-{$hash}.json"; if (file_exists($cachePath) && filemtime($cachePath) > time() - 23 * 60 * 60) { return json_decode(file_get_contents($cachePath), true); } $result = array('slug' => false, 'realms' => array()); $url = sprintf('http://%s.battle.net/auction-data/%s/auctions.json', $region, $hash); $outHeaders = array();
// Note: This file is included from the library/Vanilla/Vanilla.Control.SearchForm.php class. $ShowIcon = $u->DisplayIcon != '' && $this->Context->Session->User->Preference('HtmlOn'); $UserList .= '<li class="UserAccount' . ($Alternate ? ' Alternate' : '') . ($FirstRow ? ' FirstUser' : '') . '"> <ul> <li class="User Name' . ($ShowIcon ? ' WithIcon' : '') . '">'; if ($ShowIcon) { $UserList .= '<div class="UserIcon" style="' . "background-image:url('" . $u->DisplayIcon . "');\"> </div>"; } $UserList .= ' <span>' . $this->Context->GetDefinition('User') . '</span> <a href="' . GetUrl($this->Context->Configuration, 'account.php', '', 'u', $u->UserID) . '">' . $u->Name . '</a> (' . $u->Role . ') </li> <li class="User AccountCreated"> <span>' . $this->Context->GetDefinition('AccountCreated') . '</span> ' . TimeDiff($this->Context, $u->DateFirstVisit, mktime()) . ' </li> <li class="User LastActive"> <span>' . $this->Context->GetDefinition('LastActive') . '</span> ' . TimeDiff($this->Context, $u->DateLastActive, mktime()) . ' </li> <li class="User VisitCount"> <span>' . $this->Context->GetDefinition('VisitCount') . '</span> ' . $u->CountVisit . ' </li> <li class="User DiscussionsCreated"> <span>' . $this->Context->GetDefinition('DiscussionsCreated') . '</span> ' . $u->CountDiscussions . ' </li> <li class="User CommentsAdded"> <span>' . $this->Context->GetDefinition('CommentsAdded') . '</span> ' . $u->CountComments . ' </li>'; $this->DelegateParameters['User'] =& $u; $this->DelegateParameters['UserList'] =& $UserList; $this->CallDelegate('PostUserOptionsRender'); $UserList .= ' </ul>
<?php /** * Used by RoleHistory in extensions/RoleHistory/default.php */ if (!defined('IN_VANILLA')) { exit; } echo '<h2>' . $this->Context->GetDefinition("RoleHistory") . '</h2> <ul>'; // Loop through the user's role history $UserHistory = $this->Context->ObjectFactory->NewObject($this->Context, "UserRoleHistory"); while ($Row = $this->Context->Database->GetRow($this->History)) { $UserHistory->Clear(); $UserHistory->GetPropertiesFromDataSet($Row); $UserHistory->FormatPropertiesForDisplay($this->Context); echo '<li> <h3> ' . $UserHistory->Role . ' <small>(' . TimeDiff($this->Context, $UserHistory->Date, mktime()) . ')</small></h3> <p class="Info"> ' . str_replace("//1", $UserHistory->AdminUserID == 0 ? $this->Context->GetDefinition("Applicant") : "<a href=\"" . GetUrl($this->Context->Configuration, "account.php", "", "u", $UserHistory->AdminUserID) . "\">" . $UserHistory->AdminUsername . "</a>", $this->Context->GetDefinition("RoleAssignedByX")) . ' </p> <p class="Note"> ' . $UserHistory->Notes . ' </p> </li>'; } echo "</ul>";
function SendTweet($region, $tweetData, $chartUrl, $lastTweetData) { global $regionNames; $msg = isset($regionNames[$region]) ? $regionNames[$region] : $region; $msg .= " WoW Token: " . $tweetData['formatted']['BUY'] . "g."; //, sells in " . $tweetData['formatted']['TIMETOSELL'] . '.'; if ($tweetData['timestamp'] < time() - 30 * 60) { // show timestamp if older than 30 mins $msg .= " From " . TimeDiff($tweetData['timestamp'], ['parts' => 2, 'precision' => 'minute']) . '.'; } if ($tweetData['record']['result'] != 1) { $msg .= " " . $tweetData['formatted']['RESULT'] . "."; } else { if (isset($tweetData['formatted']['BUYCHANGEAMOUNT']) && $tweetData['formatted']['BUYCHANGEAMOUNT'] != '0') { $msg .= " Changed " . $tweetData['formatted']['BUYCHANGEAMOUNT'] . 'g'; if (isset($tweetData['formatted']['BUYCHANGEPERCENT'])) { $msg .= ' or ' . $tweetData['formatted']['BUYCHANGEPERCENT']; if (isset($lastTweetData['timestamp'])) { $msg .= ' since ' . round((time() - $lastTweetData['timestamp']) / 3600, 1) . 'h ago'; } } elseif (isset($lastTweetData['timestamp'])) { $msg .= ' since ' . round((time() - $lastTweetData['timestamp']) / 3600, 1) . 'h ago'; } $msg .= '.'; } if (isset($tweetData['formatted']['TURNAROUND'])) { $msg .= ' ' . $tweetData['formatted']['TURNAROUND']; } } if ($msg == '') { return false; } DebugMessage('Sending tweet of ' . strlen($msg) . " chars:\n" . $msg); global $twitterCredentials; if ($twitterCredentials === false) { return true; } $media = false; if ($chartUrl) { $media = UploadTweetMedia($chartUrl); } $params = array(); if ($media) { $params['media_ids'][] = $media; } $params['status'] = $msg; $oauth = new OAuth($twitterCredentials['consumerKey'], $twitterCredentials['consumerSecret']); $oauth->setToken($twitterCredentials['WoWTokens']['accessToken'], $twitterCredentials['WoWTokens']['accessTokenSecret']); $url = 'https://api.twitter.com/1.1/statuses/update.json'; try { $didWork = $oauth->fetch($url, $params, 'POST', array('Connection' => 'close')); } catch (OAuthException $e) { $didWork = false; } $ri = $oauth->getLastResponseInfo(); $r = $oauth->getLastResponse(); if ($didWork && $ri['http_code'] == '200') { $json = json_decode($r, true); if (json_last_error() == JSON_ERROR_NONE) { if (isset($json['id_str'])) { return $json['id_str']; } } return true; } if (isset($ri['http_code'])) { DebugMessage('Twitter returned HTTP code ' . $ri['http_code'], E_USER_WARNING); } else { DebugMessage('Twitter returned unknown HTTP code', E_USER_WARNING); } DebugMessage('Twitter returned: ' . print_r($ri, true), E_USER_WARNING); DebugMessage('Twitter returned: ' . print_r($r, true), E_USER_WARNING); return false; }
// Note: This file is included from the library/Vanilla/Vanilla.Control.SearchForm.php class. $CommentList .= '<li class="SearchComment' . ($Alternate ? ' Alternate' : '') . '"> <ul> <li class="DiscussionTopic"> <span>' . $this->Context->GetDefinition('DiscussionTopic') . '</span> <a href="' . GetUrl($this->Context->Configuration, 'comments.php', '', 'DiscussionID', $Comment->DiscussionID, '', '', CleanupString($Comment->Discussion) . '/') . '">' . $Comment->Discussion . '</a> </li> <li class="CommentText"> <span>' . $this->Context->GetDefinition('Comment') . '</span> <a href="' . GetUrl($this->Context->Configuration, 'comments.php', '', 'DiscussionID', $Comment->DiscussionID, '', 'Focus=' . $Comment->CommentID . '#Comment_' . $Comment->CommentID, CleanupString($Comment->Discussion) . '/') . '">' . HighlightTrimmedString($Comment->Body, $HighlightWords, 300) . '</a> </li> <li class="DiscussionCategory"> <span>' . $this->Context->GetDefinition('Category') . '</span> <a href="' . GetUrl($this->Context->Configuration, 'index.php', '', 'CategoryID', $Comment->CategoryID) . '">' . $Comment->Category . '</a> </li> <li class="CommentAuthor"> <span>' . $this->Context->GetDefinition('WrittenBy') . '</span> <a href="' . GetUrl($this->Context->Configuration, 'account.php', '', 'u', $Comment->AuthUserID) . '">' . $Comment->AuthUsername . '</a> </li> <li class="CommentAdded"> <span>' . $this->Context->GetDefinition('Added') . '</span> ' . TimeDiff($this->Context, $Comment->DateCreated, mktime()) . ' </li>'; $this->DelegateParameters['Comment'] =& $Comment; $this->DelegateParameters['CommentList'] =& $CommentList; $this->CallDelegate('PostCommentOptionsRender'); $CommentList .= ' </ul> </li> ';
$WhosOnline->UpdateGuestLastActive(); } } if (in_array($Context->SelfUrl, array("account.php", "categories.php", "comments.php", "index.php", "post.php", "search.php", "settings.php")) && $Context->Session->UserID > 0 && !$Context->Session->User->Preference("HideWhosOnline")) { $ListName = $Context->GetDefinition("Who's Online"); $Panel->AddList($ListName); $online_list = $WhosOnline->GetWhosOnline(); $guest_count = $WhosOnline->GetGuestCount(); $phantom_count = 0; if ($online_list) { foreach ($online_list as $name) { if ($name["Phantom"]) { $phantom_count++; } if (!$name["Phantom"] || !isset($name["Phantom"]) || $Context->Session->User->Permission("PERMISSION_WHOS_PHANTOM")) { $TimePast = TimeDiff($Context, unixtimestamp($name["DateLastActive"])); $Panel->AddListItem($ListName, $Context->GetDefinition($name["Name"]), "account.php?u=" . $name["UserID"], NULL, "title=\"{$TimePast}\""); } } if ($phantom_count > 0) { $phantom_string = "{$phantom_count} phantom user"; if ($phantom_count > 1) { $phantom_string .= "s"; } $Panel->AddListItem($ListName, '', '', $phantom_string); } if ($guest_count > 0) { $guest_string = "{$guest_count} guest"; if ($guest_count > 1) { $guest_string .= "s"; }
'; if ($this->Context->Configuration['USE_CATEGORIES']) { $DiscussionList .= ' <li class="DiscussionCategory"> <span>' . $this->Context->GetDefinition('Category') . ' </span><a href="' . GetUrl($this->Context->Configuration, 'index.php', '', 'CategoryID', $Discussion->CategoryID) . '">' . $Discussion->Category . '</a> </li> '; } $DiscussionList .= '<li class="DiscussionStarted"> <span><a href="' . GetUrl($this->Context->Configuration, 'comments.php', '', 'DiscussionID', $Discussion->DiscussionID, '', '#Item_1', CleanupString($Discussion->Name) . '/') . '">' . $this->Context->GetDefinition('StartedBy') . '</a> </span><a href="' . GetUrl($this->Context->Configuration, 'account.php', '', 'u', $Discussion->AuthUserID) . '">' . $Discussion->AuthUsername . '</a> </li> <li class="DiscussionComments"> <span>' . $this->Context->GetDefinition('Comments') . ' </span>' . $Discussion->CountComments . ' </li> <li class="DiscussionLastComment"> <span><a href="' . $LastUrl . '">' . $this->Context->GetDefinition('LastCommentBy') . '</a> </span><a href="' . GetUrl($this->Context->Configuration, 'account.php', '', 'u', $Discussion->LastUserID) . '">' . $Discussion->LastUsername . '</a> </li> <li class="DiscussionActive"> <span><a href="' . $LastUrl . '">' . $this->Context->GetDefinition('LastActive') . '</a> </span>' . TimeDiff($this->Context, $Discussion->DateLastActive, mktime()) . ' </li>'; if ($this->Context->Session->UserID > 0) { $DiscussionList .= ' <li class="DiscussionNew"> <a href="' . $NewUrl . '"><span>' . $this->Context->GetDefinition('NewCaps') . ' </span>' . $Discussion->NewComments . '</a> </li> '; } $this->CallDelegate('PostDiscussionOptionsRender'); $DiscussionList .= '</ul> </li>'; $this->CallDelegate('PostDiscussionRender');
function CheckNextUser() { $db = DBConnect(); $sql = <<<'EOF' select * from tblUser u where watchesobserved > ifnull(watchesreported, '2000-01-01') and timestampadd(minute, greatest(if(paiduntil is null or paiduntil < now(), ?, ?), watchperiod), ifnull(watchesreported, '2000-01-01')) < now() order by ifnull(watchesreported, '2000-01-01'), watchesobserved limit 1 for update EOF; $db->begin_transaction(); $stmt = $db->prepare($sql); $freeFreq = SUBSCRIPTION_WATCH_MIN_PERIOD_FREE; $paidFreq = SUBSCRIPTION_WATCH_MIN_PERIOD; $stmt->bind_param('ii', $freeFreq, $paidFreq); $stmt->execute(); $result = $stmt->get_result(); $row = $result->fetch_assoc(); $result->close(); $stmt->close(); if (is_null($row)) { $db->rollback(); return 10; } $stmt = $db->prepare('update tblUser set watchesreported = ? where id = ?'); $userId = $row['id']; $now = date('Y-m-d H:i:s'); $stmt->bind_param('si', $now, $userId); $stmt->execute(); $stmt->close(); $db->commit(); $expectedReport = strtotime($row['watchesobserved']); if (!is_null($row['watchesreported'])) { $expectedReport = max($expectedReport, max(is_null($row['paiduntil']) || strtotime($row['paiduntil']) < time() ? SUBSCRIPTION_WATCH_MIN_PERIOD_FREE : SUBSCRIPTION_WATCH_MIN_PERIOD, $row['watchperiod']) * 60 + strtotime($row['watchesreported'])); } DebugMessage("User " . str_pad($row['id'], 7, ' ', STR_PAD_LEFT) . " (" . $row['name'] . ') checking for new watches/rares, overdue by ' . TimeDiff($expectedReport, array('parts' => 2, 'precision' => 'second'))); $subjects = []; $messages = []; $houseSubjects = []; $ret = ReportUserWatches($now, $row); if ($ret !== false) { $subjects[] = $ret[0]; $messages[] = $ret[1]; if ($ret[2]) { $houseSubjects[] = $ret[2]; } } $ret = ReportUserRares($now, $row); if ($ret !== false) { $subjects[] = $ret[0]; $messages[] = $ret[1]; if ($ret[2]) { $houseSubjects[] = $ret[2]; } } if (!count($messages)) { return 0; } $locale = $row['locale']; $LANG = GetLang($locale); $message = $row['name'] . ',<br>' . implode('<hr>', $messages) . '<br><hr>' . $LANG['notificationsMessage'] . '<br><br>'; $subject = implode(', ', $subjects); if (count($houseSubjects) == count($subjects)) { $houseSubjects = array_unique($houseSubjects); if (count($houseSubjects) == 1) { $subject .= ' - ' . $houseSubjects[0]; } } if (is_null($row['paiduntil']) || strtotime($row['paiduntil']) < time()) { $message .= $LANG['freeSubscriptionAccount']; $hoursNext = round((max(intval($row['watchperiod'], 10), SUBSCRIPTION_WATCH_MIN_PERIOD_FREE) + 5) / 60, 1); } else { $message .= sprintf(preg_replace('/\\{(\\d+)\\}/', '%$1$s', $LANG['paidExpires']), date('Y-m-d H:i:s e', strtotime($row['paiduntil']))); $hoursNext = round((max(intval($row['watchperiod'], 10), SUBSCRIPTION_WATCH_MIN_PERIOD) + 5) / 60, 1); } if ($hoursNext > 0.3) { $hoursNext = sprintf(preg_replace('/\\{(\\d+)\\}/', '%$1$s', $LANG['timeFuture']), $hoursNext . ' ' . ($hoursNext == 1 ? $LANG['timeHour'] : $LANG['timeHours'])); $message .= ' ' . sprintf(preg_replace('/\\{(\\d+)\\}/', '%$1$s', $LANG['notificationPeriodNext']), $hoursNext); } SendUserMessage($userId, 'marketnotification', $subject, $message); return 0; }