示例#1
0
 /**
  * Send a message to the public forum. The variables passed are assumed to be already sanitized
  *
  * @param int $toID User/Thread ID to send to
  * @param int $fromUserID UserID sent from
  * @param string $message The message to be sent
  * @param string[optional] $subject The subject
  * @param string[optional] $type 'Bulletin'(GameMaster->Player) 'ThreadStart'(User->All) 'ThreadReply'(User->Thread)
  *
  * @return int The message ID
  */
 public static function send($toID, $fromUserID, $message, $subject = "", $type = 'Bulletin')
 {
     global $DB;
     if (defined('AdminUserSwitch')) {
         $fromUserID = AdminUserSwitch;
     }
     $message = self::linkify($message);
     $sentTime = time();
     if (65000 < strlen($message)) {
         throw new Exception(l_t("Message too long"));
     }
     libCache::wipeDir(libCache::dirName('forum'));
     $DB->sql_put("INSERT INTO wD_ForumMessages\r\n\t\t\t\t\t\tSET toID = " . $toID . ", fromUserID = " . $fromUserID . ", timeSent = " . $sentTime . ",\r\n\t\t\t\t\t\tmessage = '" . $message . "', subject = '" . $subject . "', replies = 0,\r\n\t\t\t\t\t\ttype = '" . $type . "', latestReplySent = 0");
     $id = $DB->last_inserted();
     if ($type == 'ThreadReply') {
         $DB->sql_put("UPDATE wD_ForumMessages " . "SET latestReplySent = " . $id . ", replies = replies + 1 WHERE ( id=" . $id . " OR id=" . $toID . " )");
     } else {
         $DB->sql_put("UPDATE wD_ForumMessages SET latestReplySent = id WHERE id = " . $id);
     }
     $tabl = $DB->sql_tabl("SELECT t.id FROM wD_ForumMessages t LEFT JOIN wD_ForumMessages r ON ( r.toID=t.id AND r.fromUserID=" . $fromUserID . " AND r.type='ThreadReply' ) WHERE t.type='ThreadStart' AND ( t.fromUserID=" . $fromUserID . " OR r.id IS NOT NULL ) GROUP BY t.id");
     $participatedThreadIDs = array();
     while (list($participatedThreadID) = $DB->tabl_row($tabl)) {
         $participatedThreadIDs[$participatedThreadID] = $participatedThreadID;
     }
     $cacheUserParticipatedThreadIDsFilename = libCache::dirID('users', $fromUserID) . '/readThreads.js';
     file_put_contents($cacheUserParticipatedThreadIDsFilename, 'participatedThreadIDs = $A([' . implode(',', $participatedThreadIDs) . ']);');
     return $id;
 }
示例#2
0
libHTML::starthtml(l_t('GameMaster'));
print '<div class="content">';
$DB->sql_put("COMMIT");
// Unlock our user row, to prevent deadlocks below
// This means our $User object should only be used for reading from
ini_set('memory_limit', "40M");
ini_set('max_execution_time', '40');
/*
 * - Update session table
 * - Update misc values (if running as admin/mod)
 * - Check last process time, pause processing/save current process time
 * - Check queue and games table for games to process, votes to enact, and system functions to perform
 */
print l_t('Updating session table') . '<br />';
libGameMaster::updateSessionTable();
$statsDir = libCache::dirName('stats');
$onlineFile = $statsDir . '/onlineUsers.json';
$tabl = $DB->sql_tabl("SELECT userID FROM wD_Sessions");
$onlineUsers = array();
while (list($userID) = $DB->tabl_row($tabl)) {
    $onlineUsers[] = $userID;
}
file_put_contents($onlineFile, 'onlineUsers=$A([' . implode(',', $onlineUsers) . ']);');
//- Update misc values (if running as admin/mod)
if (!$User->type['System'] || time() % (15 * 60) <= 5 * 60) {
    print l_t('Updating Misc values') . '<br />';
    miscUpdate::errorLog();
    miscUpdate::forum();
    miscUpdate::game();
    miscUpdate::user();
}
示例#3
0
print $forumPager->html();
if ($User->type['User']) {
    print '<div id="forumOpenPostbox" style="' . ($postboxopen ? libHTML::$hideStyle : '') . '" >
			<form action="forum.php#postbox" method="get" onsubmit="$(\'forumPostbox\').show(); $(\'forumOpenPostbox\').hide(); return false;">
			<p style="padding:5px;">
				<input type="hidden" name="postboxopen" value="1" />
				<input type="hidden" name="page" value="' . $forumPager->pageCount . '" />
				<input type="submit" class="form-submit" value="' . l_t('New thread') . '" />
			</p>
		</form>
		</div>';
}
print '<div style="clear:both;"> </div>
		</div>
		';
$cacheHTML = libCache::dirName('forum') . '/page_' . $forumPager->currentPage . '.html';
if (file_exists($cacheHTML)) {
    print $cacheHTML;
}
$tabl = $DB->sql_tabl("SELECT\r\n\tf.id, f.fromUserID, f.timeSent, f.message, f.subject, f.replies,\r\n\t\tu.username as fromusername, u.points as points, f.latestReplySent, IF(s.userID IS NULL,0,1) as online, u.type as userType, \r\n\t\tf.likeCount as likeCount, \r\n\t\tf.silenceID,\r\n\t\tsilence.userID as silenceUserID,\r\n\t\tsilence.postID as silencePostID,\r\n\t\tsilence.moderatorUserID as silenceModeratorUserID,\r\n\t\tsilence.enabled as silenceEnabled,\r\n\t\tsilence.startTime as silenceStartTime,\r\n\t\tsilence.length as silenceLength,\r\n\t\tsilence.reason as silenceReason\r\n\tFROM wD_ForumMessages f\r\n\tINNER JOIN wD_Users u ON ( f.fromUserID = u.id )\r\n\tLEFT JOIN wD_Sessions s ON ( u.id = s.userID )\r\n\tLEFT JOIN wD_Silences silence ON ( f.silenceID = silence.id )\r\n\tWHERE f.type = 'ThreadStart'\r\n\tORDER BY f.latestReplySent DESC\r\n\t" . $forumPager->SQLLimit());
/*
 * If it's a new post, jump to it
 *
 */
$switch = 2;
while ($message = $DB->tabl_hash($tabl)) {
    if (Silence::isSilenced($message)) {
        $silence = new Silence($message);
    } else {
        unset($silence);
    }
示例#4
0
    private static function footerScripts()
    {
        global $User, $Locale;
        $jsVersion = 4;
        // increment this to force clients to reload their JS files
        $buf = '';
        // onlineUsers, for the online icons
        $statsDir = libCache::dirName('stats');
        $onlineFile = l_s($statsDir . '/onlineUsers.json');
        if (file_exists($onlineFile)) {
            $buf .= '<script type="text/javascript" src="' . STATICSRV . $onlineFile . '"></script>';
        } else {
            $buf .= '<script type="text/javascript">onlineUsers = $A([ ]);</script>';
        }
        if (!is_object($User)) {
            return $buf;
        } elseif ($User->type['User']) {
            // Muted users
            $gameMutePairs = array();
            foreach ($User->getMuteCountries() as $gameMutePair) {
                $gameMutePairs[] = '[' . $gameMutePair[0] . ',' . $gameMutePair[1] . ']';
            }
            $buf .= '
			<script type="text/javascript">
			muteUsers = $A([' . implode(',', $User->getMuteUsers()) . ']);
			muteCountries = $A([' . implode(',', $gameMutePairs) . ']);
			muteThreads = $A([' . implode(',', $User->getMuteThreads()) . ']);
			</script>';
            unset($gameMutePairs);
            self::$footerIncludes[] = l_j('mute.js');
            self::$footerScript[] = l_jf('muteAll') . '();';
            // Participated threads
            $cacheUserParticipatedThreadIDsFilename = libCache::dirID('users', $User->id) . '/readThreads.js';
            if (file_exists($cacheUserParticipatedThreadIDsFilename)) {
                $buf .= '<script type="text/javascript" src="' . STATICSRV . $cacheUserParticipatedThreadIDsFilename . '?nocache=' . rand(0, 999999) . '"></script>';
                libHTML::$footerScript[] = l_jf('setForumParticipatedIcons') . '();';
            }
        }
        if (is_object($Locale)) {
            $Locale->onFinish();
        }
        // Add the javascript includes:
        $footerIncludes = array();
        $footerIncludes[] = l_j('../locales/layer.js');
        $footerIncludes[] = l_j('../locales/English/layer.js');
        $footerIncludes[] = l_j('contrib/sprintf.js');
        $footerIncludes[] = l_j('utility.js');
        $footerIncludes[] = l_j('cacheUpdate.js');
        $footerIncludes[] = l_j('timeHandler.js');
        $footerIncludes[] = l_j('forum.js');
        $footerIncludes[] = l_j('Color.Vision.Daltonize.js');
        // Don't localize all the footer includes here, as some of them may be dynamically generated
        foreach (array_merge($footerIncludes, self::$footerIncludes) as $includeJS) {
            // Add on the dynamically added includes
            $buf .= '<script type="text/javascript" src="' . STATICSRV . JSDIR . '/' . $includeJS . '?ver=' . $jsVersion . '"></script>';
        }
        // Utility (error detection, message protection), HTML post-processing,
        // time handling functions. Only logged-in users need to run these
        $buf .= '
		<script type="text/javascript">
			var UserClass = function () {
				this.id=' . $User->id . ';
				this.username="******";
				this.points=' . $User->points . '
				this.lastMessageIDViewed=' . $User->lastMessageIDViewed . ';
				this.timeLastSessionEnded=' . $User->timeLastSessionEnded . ';
				this.token="' . md5(Config::$secret . $User->id . 'Array') . '";
			}
			User = new UserClass();
			
			WEBDIP_DEBUG=' . (Config::$debug ? 'true' : 'false') . ';

			document.observe("dom:loaded", function() {
			
				try {
					' . l_jf('Locale.onLoad') . '();
					
					' . l_jf('onlineUsers.push') . '(User.id);
	
					' . l_jf('setUserOnlineIcons') . '();
					' . l_jf('setForumMessageIcons') . '();
					' . l_jf('setPostsItalicized') . '();
					' . l_jf('updateTimestamps') . '();
					' . l_jf('updateUTCOffset') . '();
					' . l_jf('updateTimers') . '();
	
					' . implode("\n", self::$footerScript) . '
					
					' . l_jf('Locale.afterLoad') . '();
				}
				catch( e ) {
				' . (Config::$debug ? 'alert(e);' : '') . '
				}
			}, this);
		</script>
		';
        if (Config::$debug) {
            $buf .= '<br /><strong>JavaScript localization lookup failures:</strong><br /><span id="jsLocalizationDebug"></span>';
        }
        return $buf;
    }
示例#5
0
 */
 print '<div class="content-bare content-home-header">';
 // content-follow-on">';
 print '<table class="homeTable"><tr>';
 print '<td class="homeMessages">';
 $liveGames = libHome::upcomingLiveGames();
 if ($liveGames != '') {
     print '<div class="homeHeader">' . l_t('Upcoming live games') . ' <a href="gamelistings.php?page-games=1&gamelistType=New">' . libHTML::link() . '</a></div>';
     print $liveGames;
 }
 print '<div class="homeHeader">' . l_t('Forum') . ' <a href="forum.php">' . libHTML::link() . '</a></div>';
 if (file_exists(libCache::dirName('forum') . '/home-forum.html')) {
     print file_get_contents(libCache::dirName('forum') . '/home-forum.html');
 } else {
     $buf_home_forum = libHome::forumNew();
     file_put_contents(libCache::dirName('forum') . '/home-forum.html', $buf_home_forum);
     print $buf_home_forum;
 }
 print '</td>';
 print '<td class="homeSplit"></td>';
 print '<td class="homeGameNotices">';
 /*$buf = libHome::PMs();
 	if(strlen($buf))
 		print '<div class="homeHeader">Private messages</div>'.$buf;
 	*/
 print '<div class="homeHeader">' . l_t('Notices') . ' <a href="index.php?notices=on">' . libHTML::link() . '</a></div>';
 print libHome::Notice();
 print '</td>';
 print '<td class="homeSplit"></td>';
 print '<td class="homeGamesStats">';
 print '<div class="homeHeader">' . l_t('My games') . ' <a href="gamelistings.php?page=1&gamelistType=My games">' . libHTML::link() . '</a></div>';