Example #1
0
 function onJoin()
 {
     $info = $this->info;
     $lChannel = strtolower($info['channel']);
     if (!isset($this->peaks[$lChannel])) {
         $this->peaks[$lChannel] = array('users' => 0, 'time' => 0);
         $this->MySQL->query("INSERT INTO channel_peaks (channel, users, date) VALUES ('" . addslashes($lChannel) . "', 0, '" . time() . "')");
     }
     $users = $this->IRCBot->getUsers($info['channel']);
     if (!$users) {
         return;
     }
     $users = sizeof($users);
     if ($users > $this->peaks[$lChannel]['users']) {
         $oldpeak = array();
         $oldpeak['users'] = $this->peaks[$lChannel]['users'];
         $oldpeak['time'] = $this->peaks[$lChannel]['time'];
         $this->peaks[$lChannel]['users'] = $users;
         $this->peaks[$lChannel]['time'] = time();
         $this->MySQL->query("UPDATE channel_peaks SET users='" . $users . "', date='" . time() . "' WHERE channel='" . addslashes($lChannel) . "'");
         if ($oldpeak['users'] == 0) {
             return;
         }
         $this->sendOutput(sprintf($this->CONFIG['text_newpeak'], $info['channel'], $users, $oldpeak['users'], date('Y-m-d H:i:s', $oldpeak['time']), libTime::secondsToString(time() - $oldpeak['time'])), $info['channel']);
     }
 }
Example #2
0
 function getStats($username, $html)
 {
     if (strpos($html, 'There is no available information for') !== false) {
         return false;
     }
     preg_match('#<h3>User information of (VIP )?(.*?)</h3>#', $html, $arr);
     $nick = $arr[2];
     # inactive users will match the username regex with ' ' but there are no details about them, so return false then
     if (!preg_match('#<b>Rank:</b>.*?<font color=".*?">(.*?)</font>#', $html, $arr)) {
         return false;
     }
     $rank = $arr[1];
     preg_match('#<b>Number of hacks:</b>.*?<td>(.*?)</td>#', $html, $arr);
     $solved = $arr[1];
     preg_match('#<b>Rankpoints:</b>.*?<td>(.*?)</td>#', $html, $arr);
     $rankpoints = $arr[1];
     preg_match('#<b>Visited:</b>.*?<td>(.*?)</td>#', $html, $arr);
     $visited = $arr[1];
     preg_match('#<b>Time spent overall:</b>.*?<td>(.*?)</td>#', $html, $arr);
     $timeSpent = $arr[1];
     preg_match('#<b>Last online:</b>.*?<td>(.*?)</td>#', $html, $arr);
     $lastOnline = trim($arr[1]);
     $data = array('username' => $nick, 'user_title' => $rank, 'challs' => $solved, 'score' => $rankpoints, 'visits' => $visited, 'time' => libTime::secondsToString($timeSpent), 'last_online' => $lastOnline);
     return $data;
 }
Example #3
0
 private function assembleText($data)
 {
     $text = 'I\'ve last seen ' . $data['nick'] . ' ' . libTime::secondsToString(time() - $data['time']) . ' ago ';
     if ($data['server'] != $this->Server->host) {
         $text .= 'on ' . $data['server'] . ' ';
     }
     switch ($data['action']) {
         case 'ACTION':
             $text .= 'in ' . $data['channel'] . ' stating that he ' . $data['text'] . '.';
             break;
         case 'PRIVMSG':
             $text .= 'in ' . $data['channel'] . ' saying "' . $data['text'] . '".';
             break;
         case 'JOIN':
             $text .= 'joining ' . $data['channel'] . '.';
             break;
         case 'PART':
             $text .= 'parting ' . $data['channel'];
             if ($data['message'] !== false) {
                 $text .= ' with message ' . $data['message'] . '.';
             } else {
                 $text .= '.';
             }
             break;
         case 'QUIT':
             $text .= 'quitting the server with message "' . $data['message'] . '".';
             break;
     }
     return $text;
 }
Example #4
0
 function isTriggered()
 {
     $uptime = libTime::secondsToString(time() - $this->IRCBot->startTime);
     $res = $this->MySQL->query("SELECT SUM(seconds) total FROM uptime");
     $total_uptime = time() - $this->IRCBot->startTime + $res['result'][0]['total'];
     $this->sendOutput("Uptime: " . $uptime . ' - Total Uptime: ' . libTime::secondsToString($total_uptime));
 }
Example #5
0
 function isTriggered()
 {
     if (!isset($this->info['text'])) {
         $nick = $this->info['nick'];
     } else {
         $nick = $this->info['text'];
     }
     $domain = $this->CONFIG['domain'];
     $get = sprintf($this->CONFIG['get'], urlencode($nick));
     $result = libHTTP::GET($domain, $get);
     $result = implode($result['content'], "\n");
     if (preg_match("/There is no available information for/", $result)) {
         $this->sendOutput(sprintf($this->CONFIG['doesnt_exist'], $nick, $this->CONFIG['domain']));
         return;
     }
     preg_match('#<h3>User information of (VIP )?(.*?)</h3>#', $result, $arr);
     $nick = $arr[2];
     preg_match('#<b>Rank:</b>.*?<font color=".*?">(.*?)</font>#', $result, $arr);
     $rank = $arr[1];
     preg_match('#<b>Donated:</b>.*?<font color=".*?">(.*?)</font>#', $result, $arr);
     $donated = $arr[1];
     if ($donated == "This guy didn't donate anything yet!") {
         $donated = false;
     } else {
         $donated = str_replace(" ", "", $donated);
     }
     preg_match('#<b>Number of hacks:</b>.*?<td>(.*?)</td>#', $result, $arr);
     $solved = $arr[1];
     preg_match('#<b>Rankpoints:</b>.*?<td>(.*?)</td>#', $result, $arr);
     $rankpoints = $arr[1];
     preg_match('#<b>Visited:</b>.*?<td>(.*?)</td>#', $result, $arr);
     $visited = $arr[1];
     preg_match('#<b>Time spent overall:</b>.*?<td>(.*?)</td>#', $result, $arr);
     $timeSpent = $arr[1];
     preg_match('#<b>Last online:</b>.*?<td>(.*?)</td>#', $result, $arr);
     $lastOnline = trim($arr[1]);
     preg_match('#<b>User\'s current status:</b>.*?<td>(.*?)</td>#', $result, $arr);
     if ($arr[1] == "offline") {
         $online = false;
     } else {
         $online = true;
     }
     $output = sprintf($this->CONFIG['text_status'], $nick, $rank, $solved, libString::end_s("challenge", $solved), $rankpoints);
     $output .= " ";
     $output .= sprintf($this->CONFIG['text_visit'], $nick, $this->CONFIG['domain'], $visited, libTime::secondsToString($timeSpent));
     if ($donated) {
         $output .= " ";
         $output .= sprintf($this->CONFIG['text_donate'], $nick, $donated);
     }
     $output .= " ";
     if ($online) {
         $output .= sprintf($this->CONFIG['text_online'], $nick, $domain);
     } else {
         $output .= sprintf($this->CONFIG['text_lastonline'], $nick, $lastOnline);
     }
     $this->sendOutput($output);
 }
Example #6
0
 function onJoin()
 {
     $user_count = sizeof($this->Channel->users);
     if ($user_count > $this->Channel->getVar('peak')) {
         if ($this->getConfig('peakshow') === 'yes') {
             $this->reply(sprintf("New channel peak for %s: %d users online. Old one was %d users online at %s (%s ago)", $this->Channel->name, $user_count, $this->Channel->getVar('peak'), $this->Channel->getVar('peak_date'), libTime::secondsToString(libTime::getSecondsDifference(date('r'), $this->Channel->getVar('peak_date')))));
         }
         $this->Channel->saveVar('peak', $user_count);
         $this->Channel->saveVar('peak_date', date('Y-m-d H:i:s'));
     }
 }
Example #7
0
 function isTriggered()
 {
     $uptime = libTime::secondsToString($this->Bot->time - $this->started);
     $servercount = sizeof($this->Bot->servers);
     $channelcount = 0;
     $usercount = 0;
     foreach ($this->Bot->servers as $Server) {
         $channelcount += sizeof($Server->channels);
         $usercount += sizeof($Server->users);
     }
     $mem_current = number_format(memory_get_usage() / 1000000, 2);
     $mem_peak = number_format(memory_get_peak_usage() / 1000000, 2);
     $this->reply(sprintf("Uptime: %s. Memory: %.2f MB (%.2f MB max). SQL: %d queries total (%.2f q/s). Jobs: %d (%d max). Timers: %d. Servers: %d, Channels: %d, Users: %d. ", $uptime, $mem_current, $mem_peak, $this->MySQL->queryCount, $this->MySQL->queryCount / ($this->Bot->time - $this->started), $this->Bot->jobCount, $this->Bot->jobCountMax, $this->Bot->timerCount, $servercount, $channelcount, $usercount));
 }
Example #8
0
 function processSummary()
 {
     $a = array();
     foreach (self::$processSummaryFields as $field) {
         $a[$field] = $this->{$field};
     }
     if ($this->processTime) {
         $a['processTime'] = libTime::stamp($this->processTime);
     } else {
         $a['processTime'] = 'NULL';
     }
     $a['turn'] = $this->datetxt();
     $a['members'] = $this->Members->processSummary();
     return $a;
 }
Example #9
0
    static function reportsDisplay($linkIDType, $linkID = 0)
    {
        global $User, $DB;
        if ($linkIDType != 'User' && $linkIDType != 'Game' && $linkIDType != 'All') {
            throw new Exception("Invalid note link-ID-type given: '" . $linkIDType . "', only User/Game allowed");
        }
        $linkID = (int) $linkID;
        $sql = "SELECT m.linkIDType, m.linkID, m.fromUserID, u.username, m.type, m.note, m.timeSent FROM wD_ModeratorNotes m INNER JOIN wD_Users u ON ( u.id = m.fromUserID ) WHERE 1=1 ";
        if (!$User->type['Moderator']) {
            $sql .= "AND ( m.type='Report' OR m.type='PublicNote' )";
        }
        if ($linkIDType != 'All' || !$User->type['Moderator']) {
            $sql .= "AND m.linkIDType='" . $linkIDType . "' AND m.linkID=" . $linkID;
        }
        $sql .= " ORDER BY m.timeSent DESC LIMIT " . ($linkIDType == 'All' ? '50' : '5');
        $tabl = $DB->sql_tabl($sql);
        $html = '';
        while ($note = $DB->tabl_hash($tabl)) {
            $html .= '<tr>
				' . ($linkIDType == 'All' ? '<td><a href="' . ($note['linkIDType'] == 'User' ? 'profile.php?userID=' . $note['linkID'] . '">Go to user</a>' : 'board.php?gameID=' . $note['linkID'] . '">Go to game</a>') . '</td>' : '') . '
				' . ($User->type['Moderator'] ? '<td><a href="?modNoteDelete=' . $note['linkIDType'] . '_' . $note['linkID'] . '_' . $note['timeSent'] . '">Delete</a></td>' : '') . '
				<td><a href="profile.php?userID=' . $note['fromUserID'] . '">' . $note['username'] . '</a></td>
				<td>' . libTime::text($note['timeSent']) . '</td>
				<td>' . $note['type'] . '</td>
				<td>' . $note['note'] . '</td>
				</tr>';
        }
        if ($html) {
            return '<table><tr>' . ($linkIDType == 'All' ? '<th>Link</th>' : '') . ($User->type['Moderator'] ? '<th>Control</th>' : '') . '<th>From</th><th>Sent</th><th>Type</th><th>Text</th></tr>' . $html . '</table>';
        } else {
            switch ($linkIDType) {
                case 'User':
                    return 'No reports/notes exist for this user.';
                case 'Game':
                    return 'No reports/notes exist for this game.';
                case 'All':
                    return 'No reports/notes exist';
                default:
                    return 'Unknown type "' . $linkIDType . '"';
            }
        }
    }
Example #10
0
 function isTriggered()
 {
     if (!isset($this->info['text'])) {
         $this->sendOutput("Usage: " . $this->info['triggerUsed'] . " nick");
         return;
     }
     $nick = addslashes($this->info['text']);
     $res = $this->MySQL->sendQuery("SELECT * FROM seen WHERE nick='" . $nick . "'");
     if ($res['count'] == 0) {
         $this->sendOutput("I don't know " . $nick . ".");
         return;
     }
     $data = $res['result'][0];
     switch ($data['action']) {
         case "PRIVMSG":
             $action = "saying";
             break;
     }
     $text = sprintf($this->CONFIG['text'], $data['nick'], libTime::secondsToString(time() - strtotime($data['last_update'])), $data['channel'], $action, $data['text']);
     $this->sendOutput($text);
 }
 private function printTimeDataRow($row, $lastRow = false)
 {
     static $alternate;
     if (!isset($alternate)) {
         $alternate = false;
     }
     $alternate = !$alternate;
     print '<tr class="replyalternate' . (2 - $alternate) . ' replyborder' . (2 - $alternate) . '">';
     foreach ($row as $name => $part) {
         print '<td>';
         if ($name == 'userID') {
             if ($part == $this->aUserID) {
                 print '<strong>' . $part . '</strong>';
             } else {
                 print $part;
             }
             continue;
         }
         if ($lastRow) {
             if ($name == 'lastRequest') {
                 $timeComparison = l_t('(%s earlier)', libTime::remainingText($lastRow['lastRequest'], $part));
                 if ($lastRow['lastRequest'] - $part < 15 * 60) {
                     print '<span class="Austria">' . $timeComparison . '</span>';
                 } elseif ($lastRow['lastRequest'] - $part < 30 * 60) {
                     print '<span class="Turkey">' . $timeComparison . '</span>';
                 } elseif ($lastRow['lastRequest'] - $part < 45 * 60) {
                     print '<span class="Italy">' . $timeComparison . '</span>';
                 } else {
                     print $timeComparison;
                 }
             } else {
                 if ($part == $lastRow[$name]) {
                     print '<span class="Austria">' . $part . '</span>';
                 } else {
                     print $part;
                 }
             }
         } else {
             if ($name == 'lastRequest') {
                 print libTime::text($part);
             } else {
                 print $part;
             }
         }
         print '</td>';
     }
     print '</tr>';
 }
Example #12
0
 private function writeLog()
 {
     if (!isset(Config::$pointsLogFile) || !Config::$pointsLogFile) {
         return;
     }
     assert('is_array($this->logBefore);');
     $before = $this->logBefore;
     $after = $this->pointsInfoLog();
     $log = array('gameID' => $this->Game->id);
     foreach ($before as $name => $value) {
         $log[$name] = array('before' => $value, 'after' => $after[$name]);
     }
     if (!file_put_contents(Config::$pointsLogFile, libTime::text() . ":\n" . print_r($log, true) . "\n-----\n\n", FILE_APPEND)) {
         trigger_error("Couldn't write points log to log file");
     }
 }
Example #13
0
 function pausedInfo()
 {
     $buf = parent::pausedInfo();
     if (is_null($this->pauseTimeRemaining)) {
         $remaining = $this->phaseMinutes * 60;
     } else {
         $remaining = $this->pauseTimeRemaining;
     }
     return $buf . ' (' . l_t('%s left on unpause', libTime::timeLengthText($remaining)) . ')';
 }
/**
 * Display the error logs and other lists useful for admins
 *
 * @package Admin
 */
if ($User->type['Admin']) {
    //There may be sensitive info that would allow privilege escalation in these error logs
    print '<p><strong>' . l_t('Error logs:') . '</strong> ' . libError::stats() . ' (' . libHTML::admincp('clearErrorLogs', null, 'Clear') . ')</p>';
    $dir = libError::directory();
    $errorlogs = libError::errorTimes();
    $alternate = false;
    print '<TABLE class="credits">';
    foreach ($errorlogs as $errorlog) {
        $alternate = !$alternate;
        print '<tr class="replyalternate' . ($alternate ? '1' : '2') . '">';
        print '<td class="left time">' . libTime::text($errorlog) . '</td>';
        print '<td class="right message"><a class="light" href="admincp.php?viewErrorLog=' . $errorlog . '">Open</a></td>';
        print '</tr>';
    }
    print '</TABLE>';
}
/**
 * Fill a named table from a single column query
 *
 * @param string $name The table's name
 * @param string $query The single columned query which will return the data to display
 */
function adminStatusTable($name, $query)
{
    global $DB;
    print '<p><strong>' . $name . '</strong></p>';
Example #15
0
 public static function stats()
 {
     global $Misc;
     $errorTimes = self::errorTimes();
     $count = count($errorTimes);
     $Misc->ErrorLogs = $count;
     return $count . ' error log files' . ($count > 0 ? ', last error log at ' . libTime::text($errorTimes[0]) : '');
 }
Example #16
0
 /**
  * Return the next process time in textual format, in terms of time remaining
  *
  * @return string
  */
 function processTimetxt()
 {
     if ($this->processTime < time()) {
         return l_t("Now");
     } else {
         return libTime::remainingText($this->processTime);
     }
 }
Example #17
0
 private static function footerStats()
 {
     global $DB, $Misc, $User;
     $buf = '';
     // Run time, select queries, insert queries
     $buf .= l_t('Rendered in: <strong>%ssec</strong> - ' . 'Data retrievals: <strong>%s</strong> - ' . 'Data insertions: <strong>%s</strong>', round(microtime(true) - $GLOBALS['scriptStartTime'], 2), $DB->getqueries, $DB->putqueries) . ' ';
     if (function_exists('memory_get_usage')) {
         $buf .= ' - ' . l_t('Memory used: <strong>%sMB</strong>', round(memory_get_usage() / 1024 / 1024, 3)) . ' ';
     }
     $buf .= '<br /><br />';
     $stats = array('Logged on' => $Misc->OnlinePlayers, 'Playing' => $Misc->ActivePlayers, 'Registered' => $Misc->TotalPlayers);
     $first = true;
     foreach ($stats as $name => $stat) {
         if ($first) {
             $first = false;
         } else {
             $buf .= ' - ';
         }
         $buf .= l_t($name) . ': <strong>' . $stat . '</strong> ';
     }
     $buf .= ' - ' . l_t('Pages served: <strong>%s</strong>', $Misc->Hits);
     $buf .= '<br />';
     $stats = array('Starting games' => $Misc->GamesNew, 'Joinable games' => $Misc->GamesOpen, 'Active games' => $Misc->GamesActive, 'Finished games' => $Misc->GamesFinished);
     $first = true;
     foreach ($stats as $name => $stat) {
         if ($first) {
             $first = false;
         } else {
             $buf .= ' - ';
         }
         $buf .= l_t($name) . ': <strong>' . $stat . '</strong> ';
     }
     if (!isset($User) || !$User->type['Moderator']) {
         return $buf;
     }
     $buf .= '<br /><br />';
     $stats = array('<a href="gamemaster.php" class="light">' . l_t('Last process') . '</a>' => $Misc->LastProcessTime ? libTime::text($Misc->LastProcessTime) : l_t('Never'), '<a href="admincp.php?tab=Control%20Panel%20Logs" class="light">' . l_t('Last mod action') . '</a>' => $Misc->LastModAction ? libTime::text($Misc->LastModAction) : l_t('Never'), '<a href="admincp.php?tab=Status%20lists" class="light">' . l_t('Error logs') . '</a>' => $Misc->ErrorLogs, l_t('Paused games') => $Misc->GamesPaused, '<a href="admincp.php?tab=Status%20lists" class="light">' . l_t('Crashed games') . '</a>' => $Misc->GamesCrashed);
     $first = true;
     foreach ($stats as $name => $stat) {
         if ($first) {
             $first = false;
         } else {
             $buf .= ' - ';
         }
         $buf .= $name . ': <strong>' . $stat . '</strong> ';
     }
     return $buf;
 }
Example #18
0
    public function renderMessages($msgCountryID, $messages)
    {
        global $DB, $User, $Member, $Game;
        $messagestxt = "";
        $alternate = false;
        for ($i = count($messages); $i >= 1; --$i) {
            $message = $messages[$i - 1];
            $alternate = !$alternate;
            // If member info is hidden and the message isn't from me
            if ($Game->isMemberInfoHidden() && (!is_object($Member) || $message['fromCountryID'] != $Member->countryID)) {
                /*
                 * Take the last 2^12 bits off the timestamp (~70 mins), to fudge
                 * it so players can't use it to compare to who was online/offline
                 * at the time.
                 */
                // 1010-1010-1010-1010-1010-xxxx-xxxx-xxxx -> 1010-1010-1010-1010-1010-0000-0000-0000
                $message['timeSent'] &= 0xfffff000;
                $approxIndicator = '~';
            } else {
                $approxIndicator = '';
            }
            $messagestxt .= '<TR class="replyalternate' . ($alternate ? '1' : '2') . ' gameID' . $Game->id . 'countryID' . $message['fromCountryID'] . '">' . '<TD class="left time">' . $approxIndicator . libTime::text($message['timeSent']);
            $messagestxt .= '</TD>
					<TD class="right ';
            if ($message['fromCountryID'] != 0) {
                // If the message isn't from the GameMaster color it in the countryID's color
                $messagestxt .= 'country' . $message['fromCountryID'];
            }
            $messagestxt .= '">';
            if ($msgCountryID == -1 && isset($Member)) {
                if ($Member->countryID == $message['fromCountryID']) {
                    $fromtxt = l_t(', from <strong>you</strong>');
                } elseif (0 == $message['fromCountryID']) {
                    $fromtxt = l_t(', from <strong>Gamemaster</strong>');
                } else {
                    $fromtxt = l_t(', from <strong>%s</strong>', l_t($this->countryName($message['fromCountryID'])));
                }
                if ($Member->countryID == $message['toCountryID']) {
                    $messagestxt .= '(' . l_t('To: <strong>You</strong>') . $fromtxt . ') - ';
                } else {
                    $messagestxt .= '(' . l_t('To: <strong>%s</strong>', l_t($this->countryName($message['toCountryID']))) . $fromtxt . ') - ';
                }
            }
            if ($message['turn'] < $Game->turn) {
                $messagestxt .= '<strong>' . $Game->datetxt($message['turn']) . '</strong>: ';
            }
            if (is_object($Member) && $message['fromCountryID'] == $Member->countryID) {
                $message['message'] = '<span class="messageFromMe">' . $message['message'] . '</span>';
            }
            // Display the country name in front of the text (for colorblind people)
            if ($User->options->value['colourblind'] != 'No') {
                if (isset($Member) && $Member->countryID == $message['fromCountryID']) {
                    $messagestxt .= '<strong>You:</strong> ';
                } elseif ($message['fromCountryID'] != 0) {
                    $messagestxt .= '<strong>' . $this->countryName($message['fromCountryID']) . ':</strong> ';
                }
            }
            $messagestxt .= $message['message'] . '</TD>
				</TR>';
        }
        return $messagestxt;
    }
Example #19
0
 private function printPlayerStats($nick)
 {
     $ranking = $this->getVar('ranking', array());
     $stats = false;
     if (preg_match('/[^0-9]/', $nick)) {
         foreach ($ranking as $index => $rank) {
             if ($rank['nick'] == $nick) {
                 $stats = $rank;
                 $stats['rank'] = $index + 1;
                 break;
             }
         }
         if ($stats === false) {
             $this->reply($nick . ' has never played dice.');
             return;
         }
     } else {
         if (isset($ranking[$nick - 1])) {
             $stats = $ranking[$nick - 1];
             $stats['rank'] = $nick;
         } else {
             $this->reply("No one is on that rank.");
             return;
         }
     }
     $text = sprintf("%s has played %s, won %d and lost %d. %s is on rank %d of %d. %s's last game was %s ago.", $stats['nick'], libString::plural('game', $stats['played']), $stats['won'], $stats['played'] - $stats['won'], $stats['nick'], $stats['rank'], sizeof($ranking), $stats['nick'], libTime::secondsToString(time() - $stats['last_played']));
     if ($stats['rank'] != 1) {
         $text .= sprintf(" %s needs to win %s to rankup.", $stats['nick'], libString::plural('more game', $ranking[$stats['rank'] - 2]['won'] - $stats['won'] + 1));
     }
     $this->reply($text);
 }
Example #20
0
 /**
  * Hours per phase, whether the game is slow or fast etc
  * @return string
  */
 function gameHoursPerPhase()
 {
     $buf = l_t('<strong>%s</strong> /phase', libTime::timeLengthText($this->phaseMinutes * 60)) . ' <span class="gameTimeHoursPerPhaseText">(';
     if ($this->isLiveGame()) {
         $buf .= l_t('live');
     } elseif ($this->phaseMinutes < 6 * 60) {
         $buf .= l_t('very fast');
     } elseif ($this->phaseMinutes < 16 * 60) {
         $buf .= l_t('fast');
     } elseif ($this->phaseMinutes < 36 * 60) {
         $buf .= l_t('normal');
     } elseif ($this->phaseMinutes < 3 * 24 * 60) {
         $buf .= l_t('slow');
     } else {
         $buf .= l_t('very slow');
     }
     return $buf . ')</span>';
 }
Example #21
0
 public function timeSent()
 {
     return libTime::text($this->timeSent);
 }
Example #22
0
    static function forumNew()
    {
        // Select by id, prints replies and new threads
        global $DB, $Misc;
        $tabl = $DB->sql_tabl("\r\n\t\t\tSELECT m.id as postID, t.id as threadID, m.type, m.timeSent, IF(t.replies IS NULL,m.replies,t.replies) as replies,\r\n\t\t\t\tIF(t.subject IS NULL,m.subject,t.subject) as subject,\r\n\t\t\t\tu.id as userID, u.username, u.points, IF(s.userID IS NULL,0,1) as online, u.type as userType,\r\n\t\t\t\tSUBSTRING(m.message,1,100) as message, m.latestReplySent, t.fromUserID as threadStarterUserID\r\n\t\t\tFROM wD_ForumMessages m\r\n\t\t\tINNER JOIN wD_Users u ON ( m.fromUserID = u.id )\r\n\t\t\tLEFT JOIN wD_Sessions s ON ( m.fromUserID = s.userID )\r\n\t\t\tLEFT JOIN wD_ForumMessages t ON ( m.toID = t.id AND t.type = 'ThreadStart' AND m.type = 'ThreadReply' )\r\n\t\t\tORDER BY m.timeSent DESC\r\n\t\t\tLIMIT 50");
        $oldThreads = 0;
        $threadCount = 0;
        $threadIDs = array();
        $threads = array();
        while (list($postID, $threadID, $type, $timeSent, $replies, $subject, $userID, $username, $points, $online, $userType, $message, $latestReplySent, $threadStarterUserID) = $DB->tabl_row($tabl)) {
            $threadCount++;
            if ($threadID) {
                $iconMessage = libHTML::forumMessage($threadID, $postID);
            } else {
                $iconMessage = libHTML::forumMessage($postID, $postID);
            }
            if ($type == 'ThreadStart') {
                $threadID = $postID;
            }
            if (!isset($threads[$threadID])) {
                if (strlen($subject) > 30) {
                    $subject = substr($subject, 0, 40) . '...';
                }
                $threadIDs[] = $threadID;
                $threads[$threadID] = array('subject' => $subject, 'replies' => $replies, 'posts' => array(), 'threadStarterUserID' => $threadStarterUserID);
            }
            $message = Message::refilterHTML($message);
            if (strlen($message) >= 50) {
                $message = substr($message, 0, 50) . '...';
            }
            $message = '<div class="message-contents threadID' . $threadID . '" fromUserID="' . $userID . '">' . $message . '</div>';
            $threads[$threadID]['posts'][] = array('iconMessage' => $iconMessage, 'userID' => $userID, 'username' => $username, 'message' => $message, 'points' => $points, 'online' => $online, 'userType' => $userType, 'timeSent' => $timeSent);
        }
        $buf = '';
        $threadCount = 0;
        foreach ($threadIDs as $threadID) {
            $data = $threads[$threadID];
            $buf .= '<div class="hr userID' . $threads[$threadID]['threadStarterUserID'] . ' threadID' . $threadID . '"></div>';
            $buf .= '<div class="homeForumGroup homeForumAlt' . ($threadCount % 2 + 1) . ' userID' . $threads[$threadID]['threadStarterUserID'] . ' threadID' . $threadID . '">
				<div class="homeForumSubject homeForumTopBorder">' . libHTML::forumParticipated($threadID) . ' ' . $data['subject'] . '</div> ';
            if (count($data['posts']) < $data['replies']) {
                $buf .= '<div class="homeForumPost homeForumMessage homeForumPostAlt' . libHTML::alternate() . ' ">

				...</div>';
            }
            $data['posts'] = array_reverse($data['posts']);
            foreach ($data['posts'] as $post) {
                $buf .= '<div class="homeForumPost homeForumPostAlt' . libHTML::alternate() . ' userID' . $post['userID'] . '">


					<div class="homeForumPostTime">' . libTime::text($post['timeSent']) . ' ' . $post['iconMessage'] . '</div>
					<a href="profile.php?userID=' . $post['userID'] . '" class="light">' . $post['username'] . '</a>
						' . libHTML::loggedOn($post['userID']) . ' (' . $post['points'] . libHTML::points() . User::typeIcon($post['userType']) . ')

					<div style="clear:both"></div>
					<div class="homeForumMessage">' . $post['message'] . '</div>
					</div>';
            }
            $buf .= '<div class="homeForumLink">
					<div class="homeForumReplies">' . l_t('%s replies', '<strong>' . $data['replies'] . '</strong>') . '</div>
					<a href="forum.php?threadID=' . $threadID . '#' . $threadID . '">' . l_t('Open') . '</a>
					</div>
					</div>';
        }
        if ($buf) {
            return $buf;
        } else {
            return '<div class="homeNoActivity">' . l_t('No forum posts found, why not ' . '<a href="forum.php?postboxopen=1#postbox" class="light">start one</a>?');
        }
    }
Example #23
0
 /**
  * A textual display of this user's last log-in time
  * @return string Last log-in time
  */
 function lastLoggedInTxt()
 {
     return libTime::timeLengthText(time() - $this->timeLoggedIn) . ' (' . libTime::text($this->timeLoggedIn) . ')';
 }
Example #24
0
   along with webDiplomacy.  If not, see <http://www.gnu.org/licenses/>.
*/
defined('IN_CODE') or die('This script can not be run by itself.');
/**
 * This script displays the 20 most recent admin/moderator actions made with the adminActionsForms class.
 *
 * @package Admin
 */
if (!isset($_REQUEST['full'])) {
    print '<a href="admincp.php?tab=Control Panel Logs&full=on">' . l_t('View all logs') . '</a>';
}
print '<table class="credits">';
$alternate = 1;
$tabl = $DB->sql_tabl("SELECT a.name, u.username, a.time, a.details, a.params\r\n\t\tFROM wD_AdminLog a INNER JOIN wD_Users u ON ( a.userID = u.id )\r\n\t\tORDER BY a.time DESC " . (isset($_REQUEST['full']) ? '' : "LIMIT 20"));
while ($row = $DB->tabl_hash($tabl)) {
    $row['time'] = libTime::text($row['time']);
    $params = $row['params'];
    /*
    $params = @unserialize($row['params']);
    if( count($params) )
    {
    	$p=array();
    	foreach($params as $name=>$value) {
    		if( $name=='userID' )
    			$value = '<a href="profile.php?userID='.$value.'" class="light">'.$value.'</a>';
    		elseif( $name=='gameID' )
    			$value = '<a href="board.php?gameID='.$value.'" class="light">'.$value.'</a>';
    
    		$p[]=$name.'='.$value;
    	}
    	$params='<br />Params: '.implode(', ',$p);
Example #25
0
 public function changePhaseLength(array $params)
 {
     global $DB;
     require_once l_r('objects/game.php');
     $newPhaseMinutes = (int) $params['phaseMinutes'];
     if ($newPhaseMinutes < 5 || $newPhaseMinutes > 10 * 24 * 60) {
         throw new Exception(l_t("Given phase minutes out of bounds (5 minutes to 10 days)"));
     }
     $Variant = libVariant::loadFromGameID($params['gameID']);
     $Game = $Variant->Game($params['gameID']);
     if ($Game->processStatus != 'Not-processing' || $Game->phase == 'Finished') {
         throw new Exception(l_t("Game is either crashed/paused/finished/processing, and so the next-process time cannot be altered."));
     }
     $oldPhaseMinutes = $Game->phaseMinutes;
     $Game->phaseMinutes = $newPhaseMinutes;
     $Game->processTime = time() + $newPhaseMinutes * 60;
     $DB->sql_put("UPDATE wD_Games SET\r\n\t\t\tphaseMinutes = " . $Game->phaseMinutes . ",\r\n\t\t\tprocessTime = " . $Game->processTime . "\r\n\t\t\tWHERE id = " . $Game->id);
     return l_t('Process time changed from %s to %s. Next process time is %s.', libTime::timeLengthText($oldPhaseMinutes * 60), libTime::timeLengthText($Game->phaseMinutes * 60), libTime::text($Game->processTime));
 }
Example #26
0
print '<div class="leftHalf" style="width:50%">';
if ($UserProfile->type['Banned']) {
    print '<p><strong>' . l_t('Banned') . '</strong></p>';
}
if ($UserProfile->comment) {
    print '<p class="profileComment">"' . $UserProfile->comment . '"</p>';
}
print '<p><ul class="formlist">';
if ($UserProfile->type['Moderator'] || $UserProfile->type['ForumModerator'] || $UserProfile->type['Admin']) {
    print '<li><strong>' . l_t('Mod/Admin team') . '</strong></li>';
    print '<li>&nbsp;</li>';
}
if ($UserProfile->online) {
    print '<li><strong>' . l_t('Currently logged in.') . '</strong> (' . libHTML::loggedOn($UserProfile->id) . ')</li>';
} else {
    print '<li><strong>' . l_t('Last visited:') . '</strong> ' . libTime::text($UserProfile->timeLastSessionEnded) . '</li>';
}
list($posts) = $DB->sql_row("SELECT (\r\n\t\tSELECT COUNT(fromUserID) FROM `wD_ForumMessages` WHERE type='ThreadStart' AND fromUserID = " . $UserProfile->id . "\r\n\t\t) + (\r\n\t\tSELECT COUNT(fromUserID) FROM `wD_ForumMessages` WHERE type='ThreadReply' AND fromUserID = " . $UserProfile->id . "\r\n\t\t)");
// Doing the query this way makes MySQL use the type, fromUserID index
if (is_null($posts)) {
    $posts = 0;
}
list($likes) = $DB->sql_row("SELECT COUNT(*) FROM wD_LikePost WHERE userID=" . $UserProfile->id);
list($liked) = $DB->sql_row("SELECT COUNT(*) FROM wD_ForumMessages fm \r\n\tINNER JOIN wD_LikePost lp ON lp.likeMessageID = fm.id \r\n\tWHERE fm.fromUserID=" . $UserProfile->id);
$likes = $likes ? '<strong>' . l_t('Likes:') . '</strong> ' . $likes : '';
$liked = $liked ? '<strong>' . l_t('Liked:') . '</strong> ' . $liked : '';
print '<li><strong>' . l_t('Forum posts:') . '</strong> ' . $posts . '<br />';
//<strong>'.l_t('View:').'</strong> <a class="light" href="profile.php?detail=threads&userID='.$UserProfile->id.'">'.l_t('Threads').'</a>,
//	<a class="light" href="profile.php?detail=replies&userID='.$UserProfile->id.'">'.l_t('replies').'</a>';
print '<br/>' . implode(' / ', array($likes, $liked)) . '
	</li>';
Example #27
0
 $replyNumber++;
 print '<a name="' . $reply['id'] . '"></a>';
 if ($new['id'] == $reply['id']) {
     print '<a name="postbox"></a>';
     $messageAnchor = '';
 } elseif ($User->timeLastSessionEnded < $reply['timeSent']) {
     print $messageAnchor;
     $messageAnchor = '';
 } elseif ($reply['id'] == $maxReplyID) {
     print $messageAnchor;
     $messageAnchor = '';
 }
 print '<div class="message-head replyalternate' . $replyswitch . ' leftRule">';
 print '<strong><a href="profile.php?userID=' . $reply['fromUserID'] . '">' . $reply['fromusername'] . ' ' . libHTML::loggedOn($reply['fromUserID']) . ' (' . $reply['points'] . ' ' . libHTML::points() . User::typeIcon($reply['userType']) . ')</a>' . '</strong><br />';
 print libHTML::forumMessage($message['id'], $reply['id']);
 print '<em>' . libTime::text($reply['timeSent']) . '</em>';
 print '<br />' . $User->likeMessageToggleLink($reply['id'], $reply['fromUserID']) . libHTML::likeCount($reply['likeCount']);
 if ($User->type['Admin'] || $User->type['ForumModerator']) {
     if (Silence::isSilenced($reply)) {
         $silence = new Silence($reply);
     } else {
         unset($silence);
     }
     print '<br />';
     if (isset($silence) && $silence->isEnabled()) {
         print '<a class="light likeMessageToggleLink" href="admincp.php?tab=Control%20Panel&amp;silenceID=' . $silence->id . '#disableSilence">' . l_t('Disable silence') . '</a>';
     } else {
         print '<a class="light likeMessageToggleLink" href="admincp.php?tab=Control%20Panel&amp;postID=' . $reply['id'] . '&amp;userID=' . $reply['fromUserID'] . '#createUserThreadSilence">' . l_t('Silence user') . '</a>';
     }
 }
 print '</div>';
Example #28
0
		<input type="radio" name="newGame[drawType]" value="draw-votes-hidden">Hidden draw votes
	</li>
	<li class="formlistdesc">
		Whether or not draw votes can be seen by the other players. In both modes, the game will be drawn when all players have voted draw. However, if draw votes are 
		hidden then you are the only one who knows whether you have voted to draw or not. 
		<br /><br /><strong>Default:</strong>Public draw votes
	</li>

	<li class="formlisttitle">
		Joining pre-game period length: (5 minutes - 10 days)
	</li>
	<li class="formlistfield">
		<select id="wait" name="newGame[joinPeriod]">
		<?php 
foreach ($phaseList as $i) {
    $opt = libTime::timeLengthText($i * 60);
    print '<option value="' . $i . '"' . ($i == 1440 ? ' selected' : '') . '>' . $opt . '</option>';
}
?>
		</select>
	</li>
	<li class="formlistdesc">
		The amount of time to wait for people to join. For 5 minute games you may want to give players longer than 5 minutes to join.

		<br /><br /><strong>Default:</strong> The same as phase length
	</li>
	<li class="formlisttitle">
		Reliability Requirements
	</li>
	<li class="formlistfield">
		Reliability rating: <input id="minRating" type="text" name="newGame[minimumReliabilityRating]" size="2" value="0"
Example #29
0
 /**
  * The time this user joined
  * @return string Date joined
  */
 function timeJoinedtxt()
 {
     return libTime::text($this->timeJoined);
 }
Example #30
0
 function isTriggered()
 {
     $this->reply(sprintf("Uptime: %s - Total Uptime: %s", libTime::secondsToString($this->Bot->time - $this->started), libTime::secondsToString($this->getVar('total_uptime', 0) + $this->Bot->time - $this->started)));
 }