Skip to content

Commit

Permalink
Fix Code Layout
Browse files Browse the repository at this point in the history
A lot of the code in html and index was oddly formatted, and the recent changes misplaced a javascript function that needs to be moved up for speed of loading.
  • Loading branch information
jmo1121109 committed Aug 12, 2019
1 parent 9307daa commit 30b1c2a
Show file tree
Hide file tree
Showing 2 changed files with 79 additions and 103 deletions.
80 changes: 26 additions & 54 deletions index.php
Expand Up @@ -22,11 +22,8 @@
* @package Base
*/
require_once('header.php');

require_once(l_r('lib/message.php'));

require_once(l_r('objects/game.php'));

require_once(l_r('gamepanel/gamehome.php'));

/*
Expand Down Expand Up @@ -245,9 +242,7 @@ static function globalInfo()
{
$userStats = self::statsGlobalUser();
$gameStats = self::statsGlobalGame();
//$topUsers = self::topUsers();

//$buf='<div class="content" style="text-align:center;"><strong>Users:</strong> ';
$buf='<strong>'.l_t('Users:').'</strong> ';
$first=true;
foreach($userStats as $name => $val)
Expand All @@ -264,14 +259,9 @@ static function globalInfo()
$buf .= l_t($name).':<strong>'.$val.'</strong>';
}

//$buf .= '</div>';
//$buf .= '<br /><h3>Hall of fame</h3>'.implode('<br />',$topUsers);


return $buf;
}


static public function gameWatchBlock ()
{
global $User, $DB;
Expand Down Expand Up @@ -306,7 +296,7 @@ static public function upcomingLiveGames ()
{
global $User, $DB;

if ($User->options->value['displayUpcomingLive'] == 'No') return '';
if ($User->options->value['displayUpcomingLive'] == 'No') return '';

$tabl=$DB->sql_tabl("SELECT g.* FROM wD_Games g
WHERE (g.phase = 'Pre-game' OR (g.phase in ('Diplomacy','Retreats','Builds') and g.minimumBet is not null and g.gameOver = 'No')) AND g.phaseMinutes < 60 AND g.password IS NULL
Expand Down Expand Up @@ -397,7 +387,8 @@ static public function gameDefeatedNotifyBlock ()
return $buf;
}

static function forumNew() {
static function forumNew()
{
// Select by id, prints replies and new threads
global $DB, $Misc;

Expand All @@ -418,9 +409,7 @@ static function forumNew() {
$threadIDs = array();
$threads = array();

while(list(
$postID, $threadID, $type, $timeSent, $replies, $subject,
$userID, $username, $points, $online, $userType, $message, $latestReplySent,$threadStarterUserID
while(list($postID, $threadID, $type, $timeSent, $replies, $subject, $userID, $username, $points, $online, $userType, $message, $latestReplySent,$threadStarterUserID
) = $DB->tabl_row($tabl))
{
$threadCount++;
Expand All @@ -436,8 +425,7 @@ static function forumNew() {
{
if(strlen($subject)>30) $subject = substr($subject,0,40).'...';
$threadIDs[] = $threadID;
$threads[$threadID] = array('subject'=>$subject, 'replies'=>$replies,
'posts'=>array(),'threadStarterUserID'=>$threadStarterUserID);
$threads[$threadID] = array('subject'=>$subject, 'replies'=>$replies, 'posts'=>array(),'threadStarterUserID'=>$threadStarterUserID);
}

$message=Message::refilterHTML($message);
Expand Down Expand Up @@ -471,7 +459,6 @@ static function forumNew() {
...</div>';
}


$data['posts'] = array_reverse($data['posts']);
foreach($data['posts'] as $post)
{
Expand All @@ -485,7 +472,6 @@ static function forumNew() {
<div style="clear:both"></div>
<div class="homeForumMessage">'.$post['message'].'</div>
</div>';

}

$buf .= '<div class="homeForumLink">
Expand Down Expand Up @@ -529,17 +515,11 @@ static function forumNewExtern()
// Select by id, prints replies and new threads
global $DB, $Misc;

$tabl = $DB->sql_tabl("SELECT t.forum_id, f.forum_name,
t.topic_id, t.topic_title, t.topic_time,
t.topic_views, t.topic_posts_approved,
$tabl = $DB->sql_tabl("SELECT t.forum_id, f.forum_name, t.topic_id, t.topic_title, t.topic_time, t.topic_views, t.topic_posts_approved,
u1.webdip_user_id as topic_poster_webdip, t.topic_poster, t.topic_first_poster_name, t.topic_first_poster_colour,
t.topic_last_post_id, t.topic_last_post_time,
u2.webdip_user_id as topic_last_poster_webdip, t.topic_last_poster_id, t.topic_last_poster_name, t.topic_last_poster_colour,
p.post_id, p.post_text
FROM phpbb_topics t
INNER JOIN phpbb_posts p ON p.post_id = t.topic_last_post_id
INNER JOIN phpbb_forums f ON f.forum_id = t.forum_id
Expand Down Expand Up @@ -578,7 +558,8 @@ static function forumNewExtern()
$buf .= '<div class="homeForumPost homeForumPostAlt'.$alt.'">';


if( $t['topic_posts_approved']>1 ) {
if( $t['topic_posts_approved']>1 )
{

$buf .= '<div class="" style="margin-bottom:5px;margin-left:3px; margin-right:3px;">';
$buf .= '<div class="homeForumPostTime" style="float:right;font-weight:bold"><em>'.libTime::text($t['topic_last_post_time']).'</em></div>';
Expand All @@ -602,7 +583,6 @@ static function forumNewExtern()

$buf .= '<div class="" style="margin-bottom:5px;margin-left:3px; margin-right:3px;">';


$buf .= '<div style="margin-left:3px; margin-right:3px; font-size:90%">';
$buf .= '<div style="float:right">';
$buf .= l_t('<span class="forum-preview-span">%s replies, </span>','<strong>'.($t['topic_posts_approved']-1).'</strong>');
Expand All @@ -614,7 +594,6 @@ static function forumNewExtern()
</div>';
$buf .= '</div>';
$buf .= '</div>';

}

if( $buf )
Expand All @@ -630,22 +609,21 @@ static function forumNewExtern()

if( !$User->type['User'] )
{

print '<div class = "introToDiplomacy"><div class="content-notice" style="text-align:center">'.libHome::globalInfo().'</div></div>';
print libHTML::pageTitle(l_t('Welcome to webDiplomacy!'),l_t('A multiplayer web implementation of the popular turn-based strategy game Diplomacy.'));
//print '<div class="content">';
?>
<p style="text-align: center;"><img
src="<?php print l_s('images/startmap.png'); ?>" alt="<?php print l_t('The map'); ?>"
title="<?php print l_t('A webDiplomacy map'); ?>" /></p>
<div class = "introToDiplomacy_show"><p class="welcome"><?php print l_t('<em> "Luck plays no part in Diplomacy. Cunning and
cleverness, honesty and perfectly-timed betrayal are the tools needed to
outwit your fellow players. The most skillful negotiator will climb to
victory over the backs of both enemies and friends.<br />
<br />
Who do you trust?"<br />
(<a href="https://avalonhill.wizards.com/games/diplomacy">Avalon Hill</a>)</em>'); ?></p>
<div class = "introToDiplomacy_show"><p class="welcome"><?php print l_t('<em> "Luck plays no part in Diplomacy. Cunning and
cleverness, honesty and perfectly-timed betrayal are the tools needed to
outwit your fellow players. The most skillful negotiator will climb to
victory over the backs of both enemies and friends.<br />
<br />
Who do you trust?"<br />
(<a href="https://avalonhill.wizards.com/games/diplomacy">Avalon Hill</a>)</em>'); ?></p>
<?php
print '</div></div>';

Expand All @@ -662,7 +640,8 @@ static function forumNewExtern()
print '<table class="homeTable"><tr>';

notice::$noticesPage=true;
if( !isset(Config::$customForumURL) ) {
if( !isset(Config::$customForumURL) )
{
print '<td class="homeNoticesPMs">';
print '<div class="homeHeader">'.l_t('Private messages').'</a></div>';
print libHome::NoticePMs();
Expand All @@ -680,31 +659,28 @@ static function forumNewExtern()
}
else
{
/*
print '<div class="content-bare content-home-header">';
print '<div class="boardHeader">blabla</div>';
print '</div>';
*/
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 != '') {
if ($liveGames != '')
{
print '<div class="homeHeader">'.l_t('Joinable live games').' <a href="gamelistings.php?gamelistType=Search&phaseLengthMax=30m&messageNorm=Yes&messagePub=Yes&messageNon=Yes&messageRule=Yes&Submit=Search#results">'.libHTML::link().'</a></div>';
print $liveGames;
}

if( isset(Config::$customForumURL) ) { // isset($_REQUEST['HomeForumTest']) ) {

if( isset(Config::$customForumURL) )
{
print '<div class="homeHeader">'.l_t('Forum').' <a href="/contrib/phpBB3/">'.libHTML::link().'</a></div>';
if( file_exists(libCache::dirName('forum').'/home-forum.html') )
{
print file_get_contents(libCache::dirName('forum').'/home-forum.html');
$diff = (time() - filemtime(libCache::dirName('forum').'/home-forum.html'));
if( $diff > 60*5 ) {
if( $diff > 60*5 )
{
unlink(libCache::dirName('forum').'/home-forum.html');
}
}
Expand All @@ -715,7 +691,8 @@ static function forumNewExtern()
print $buf_home_forum;
}
}
else { //if( !isset(Config::$customForumURL)) {
else
{
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');
Expand All @@ -732,11 +709,6 @@ static function forumNewExtern()

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>';
Expand Down

0 comments on commit 30b1c2a

Please sign in to comment.