Skip to content

Commit

Permalink
Update new forum integration
Browse files Browse the repository at this point in the history
  • Loading branch information
kestasjk authored and TimothyJones committed Dec 15, 2017
1 parent e48d739 commit 02b4d49
Show file tree
Hide file tree
Showing 8 changed files with 176 additions and 74 deletions.
6 changes: 0 additions & 6 deletions config.sample.php
Original file line number Diff line number Diff line change
Expand Up @@ -149,12 +149,6 @@ class Config
*/
public static $faq=array('Have any extra questions been added?'=>'No, not yet.');

/**
* If this is set it is used as a link to a custom forum, instead of the built-in forum
* @var string
*/
//public static $customForumURL = 'contrib/phpBB3/';

/**
* The directory in which error logs are stored. If this returns false errors will not be logged.
* *Must not be accessible to the web server, as sensitive info is stored in this folder.*
Expand Down
8 changes: 4 additions & 4 deletions contrib/phpBB3-files/phpbb/auth/provider/webdip.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ public function __construct(\phpbb\db\driver\driver_interface $db, \phpbb\config
$this->phpbb_root_path = $phpbb_root_path;
$this->php_ext = $php_ext;

require_once($this->phpbb_root_path . '..\..\config.php');
require_once($this->phpbb_root_path . '..\..\lib\auth.php');
require_once($this->phpbb_root_path . '../../config.php');
require_once($this->phpbb_root_path . '../../lib/auth.php');
}

// Ignore usernames and passwords but allow a successful login with credentials to allow for "reauthentication" for the admin CP
Expand Down Expand Up @@ -87,8 +87,8 @@ public function autologin() {
'username'=>$wD_Data['username'],
'group_id'=>2,
'user_email'=>$wD_Data['email'],
'user_type'=>0, // Regular user; 3 = forum founder, with admin access
'webdip_user_id'=>$userId
'user_type'=>0, // Normal user. 3 = founder
'webdip_user_id'=>$userId
);

if (!function_exists('user_add'))
Expand Down
5 changes: 0 additions & 5 deletions forum.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,6 @@
* @package Base
*/
require_once('header.php');

if( isset(Config::$customForumURL) ) {
libHTML::notice("Forum moved", "Please visit <a href='".Config::$customForumURL."'>here</a> for the forum.");
}

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

Expand Down
2 changes: 1 addition & 1 deletion global/definitions.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@

defined('IN_CODE') or die('This script can not be run by itself.');

define("VERSION", 142);
define("VERSION", 143);

// Some integer values which are named for clarity.

Expand Down
2 changes: 1 addition & 1 deletion global/error.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ function assert_handler ($file, $line, $expr)
trigger_error("An assertion, ".$expr.", was not met as required.");
}

function exception_handler(Throwable $exception)
function exception_handler(Exception $exception)
{
$file = $exception->getFile();
$trace = $exception->getTraceAsString();
Expand Down
218 changes: 164 additions & 54 deletions index.php
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -242,59 +242,59 @@ static function globalInfo()
return $buf;
}


static public function gameWatchBlock ()
{
global $User, $DB;

$tabl=$DB->sql_tabl("SELECT g.* FROM wD_Games g
INNER JOIN wD_WatchedGames w ON ( w.userID = ".$User->id." AND w.gameID = g.id )
WHERE NOT g.phase = 'Finished'
ORDER BY g.processStatus ASC, g.processTime ASC");
$buf = '';

$count=0;
while($game=$DB->tabl_hash($tabl))
{
$count++;
$Variant=libVariant::loadFromVariantID($game['variantID']);
$Game=$Variant->panelGameHome($game);

$buf .= '<div class="hr"></div>';
$buf .= $Game->summary();
}

if($count==0)
{
$buf .= '<div class="hr"></div>';
$buf .= '<div><p class="notice">'.l_t('You\'re not spectating any games.').'<br />
'.l_t('Click the \'spectate\' button on an existing game to add games to your list of spectated games.').
'</p></div>';
}
return $buf;
}
static public function upcomingLiveGames ()
{
global $User, $DB;

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

$tabl=$DB->sql_tabl("SELECT g.* FROM wD_Games g
WHERE g.phase = 'Pre-game' AND g.phaseMinutes < 60 AND g.password IS NULL
ORDER BY g.processStatus ASC, g.processTime ASC LIMIT 3");
$buf = '';
$count=0;
while($game=$DB->tabl_hash($tabl))
{
$count++;
$Variant=libVariant::loadFromVariantID($game['variantID']);
$Game=$Variant->panelGameHome($game);
$buf .= '<div class="hr"></div>';
$buf .= $Game->summary();
}
return $buf;
}


static public function gameWatchBlock ()
{
global $User, $DB;

$tabl=$DB->sql_tabl("SELECT g.* FROM wD_Games g
INNER JOIN wD_WatchedGames w ON ( w.userID = ".$User->id." AND w.gameID = g.id )
WHERE NOT g.phase = 'Finished'
ORDER BY g.processStatus ASC, g.processTime ASC");
$buf = '';

$count=0;
while($game=$DB->tabl_hash($tabl))
{
$count++;
$Variant=libVariant::loadFromVariantID($game['variantID']);
$Game=$Variant->panelGameHome($game);

$buf .= '<div class="hr"></div>';
$buf .= $Game->summary();
}

if($count==0)
{
$buf .= '<div class="hr"></div>';
$buf .= '<div><p class="notice">'.l_t('You\'re not spectating any games.').'<br />
'.l_t('Click the \'spectate\' button on an existing game to add games to your list of spectated games.').
'</p></div>';
}
return $buf;
}
static public function upcomingLiveGames ()
{
global $User, $DB;

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

$tabl=$DB->sql_tabl("SELECT g.* FROM wD_Games g
WHERE g.phase = 'Pre-game' AND g.phaseMinutes < 60 AND g.password IS NULL
ORDER BY g.processStatus ASC, g.processTime ASC LIMIT 3");
$buf = '';
$count=0;
while($game=$DB->tabl_hash($tabl))
{
$count++;
$Variant=libVariant::loadFromVariantID($game['variantID']);
$Game=$Variant->panelGameHome($game);
$buf .= '<div class="hr"></div>';
$buf .= $Game->summary();
}
return $buf;
}


static public function gameNotifyBlock ()
{
Expand Down Expand Up @@ -453,6 +453,102 @@ static function forumBlock()
$buf .= '<table><tr><td>'.implode('</td></tr><tr><td>',$forumNew).'</td></tr></table>';
return $buf;
}


static function forumBlockExtern()
{
$buf = '<div class="homeHeader">'.l_t('Forum').'</div>';

$forumNew=libHome::forumNewExtern();
$buf .= '<table><tr><td>'.implode('</td></tr><tr><td>',$forumNew).'</td></tr></table>';
return $buf;
}

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,
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
FROM phpbb_topics t
INNER JOIN phpbb_forums f ON f.forum_id = t.forum_id
INNER JOIN phpbb_users u1 ON u1.user_id = t.topic_poster
INNER JOIN phpbb_users u2 ON u2.user_id = t.topic_last_poster_id
WHERE t.topic_visibility = 1
ORDER BY t.topic_last_post_time DESC
LIMIT 20");

$buf = '';
while($t = $DB->tabl_hash($tabl))
{
$buf .= '<div class="hr"></div>';

$alt = libHTML::alternate();
$buf .= '<div class="homeForumGroup homeForumAlt'.$alt.'">';

$buf .= '
<div class="homeForumSubject" >';
//$buf .= '<div style="float:right"><img src="http://127.0.0.1/images/historyicons/external.png" width="10" height="10"></div>';

$buf .= '<span style=\'color:black; font-size:90%\'>'.($t['topic_posts_approved']>1?'Re: ':'').'</span>'
.'<a href="" style=\'font-size:110%\'>'.$t['topic_title'].'</a><div style="clear:both"></div></div>';
$buf .= '<div class="homeForumPost homeForumPostAlt'.$alt.'">';


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"><em>'.libTime::text($t['topic_last_post_time']).'</em></div>';
$buf .= '<span style=\'color:black; font-size:90%\'>';
$buf .= 'Latest:</span> <a href="profile.php?userID='.$t['topic_last_poster_webdip'].'" class="light">'.$t['topic_last_poster_name'].'</a> '.libHTML::loggedOn($t['topic_last_poster_webdip'])
.'</div>';


}

$buf .= '<div class="" style="margin-bottom:5px;margin-left:3px; margin-right:3px;">';
$buf .= '<div class="homeForumPostTime" style="float:right"><em>'.libTime::text($t['topic_time']).'</em></div>';
$buf .= '<span style=\'color:black; font-size:90%\'>';
$buf .= 'By:</span> <a href="profile.php?userID='.$t['topic_poster_webdip'].'" class="light">'.$t['topic_first_poster_name'].'</a> '.libHTML::loggedOn($t['topic_poster_webdip'])
.'</div>';


$buf .= '<div style="margin-left:3px; margin-right:3px; font-size:90%">';
$buf .= '<div style="float:right">';
$buf .= l_t('%s replies','<strong>'.($t['topic_posts_approved']-1).'</strong>');
$buf .= ', '.l_t('%s views','<strong style=\'content: "\f14c"\'>'.($t['topic_views']-1).'</strong>');
$buf .= '</div>';
$buf .= '&raquo;
<a href="forum.php?threadID=">'.$t['forum_name'].'</a>
</div>';
$buf .= '</div>';

$buf .= '<div class="">';



$buf .= '</div>';
}

if( $buf )
{
return $buf;
}
else
{
return '<div class="homeNoActivity">'.l_t('No forum posts found, why not start one?');
}
}
}

if( !$User->type['User'] )
Expand Down Expand Up @@ -528,7 +624,21 @@ class="light">Avalon Hill</a>)</em>'); ?></p>
print $liveGames;
}

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

print '<div class="homeHeader">'.l_t('Forum').' <a href="'.'">'.libHTML::link().'</a></div>';
if( false && file_exists(libCache::dirName('forum').'/home-forum.html') )
print file_get_contents(libCache::dirName('forum').'/home-forum.html');
else
{
$buf_home_forum=libHome::forumNewExtern();
//file_put_contents(libCache::dirName('forum').'/home-forum.html', $buf_home_forum);
print $buf_home_forum;
}


}
else { //if( !isset(Config::$customForumURL)) {
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 Down
2 changes: 1 addition & 1 deletion javascript/board/model-newandbroke.js
Original file line number Diff line number Diff line change
Expand Up @@ -491,7 +491,7 @@ function loadModel() {
StartTerr.getBorderTerritories().pluck('id').intersect(this.Fleets.pluck('Territory').pluck('id')).map(
function(fleetID) {
if( !FleetPaths.keys().any(function(id) { return ( id == fleetID ); }) ) {
//FleetPaths.
FleetPaths.
}
}
);
Expand Down
7 changes: 5 additions & 2 deletions profile.php
Original file line number Diff line number Diff line change
Expand Up @@ -455,8 +455,11 @@

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->id !=15658)
{
print '<li><strong>'.l_t('Mod/Admin team').'</strong></li>';
print '<li>&nbsp;</li>';
}
}

if ( $UserProfile->online )
Expand Down

2 comments on commit 02b4d49

@kestasjk
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if ($UserProfile->id !=15658) ? That's jmo's account, what's the deal?

@TimothyJones
Copy link
Contributor

@TimothyJones TimothyJones commented on 02b4d49 Feb 9, 2018 via email

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.