Skip to content

Commit

Permalink
code updates and minor bug fix
Browse files Browse the repository at this point in the history
  • Loading branch information
jmo1121109 committed Feb 1, 2020
1 parent fab46fe commit ecee95f
Show file tree
Hide file tree
Showing 4 changed files with 54 additions and 45 deletions.
7 changes: 3 additions & 4 deletions botgamecreate.php
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@

list($countryCount) = $DB->sql_row("SELECT countryCount FROM wD_VariantInfo WHERE variantID=".$input['variantID']);

if ($input['countryID'] < 0 or $input['countryID'] > 7)
if ($input['countryID'] < 0 or $input['countryID'] > $countryCount)
{
throw new Exception(l_t("%s is an invalid country ID.",(string)$input['countryID']));
}
Expand All @@ -95,10 +95,12 @@

// Create first Member record & object
processMember::create($User->id, 5, $input['countryID']);

//Add Bots
$botNum = $countryCount - 1;
$tabl = $DB->sql_tabl("SELECT id FROM wD_Users WHERE type LIKE '%bot%' LIMIT ".$botNum);
$currCountry = 1;

while (list($botID) = $DB->tabl_row($tabl))
{
if($currCountry == $input['countryID'])
Expand Down Expand Up @@ -169,7 +171,6 @@ function setExtOptions(i){
{
if (in_array($variantID, Config::$apiConfig['variantIDs']))
{

$Variant = libVariant::loadFromVariantName($variantName);
$checkboxes[$Variant->fullName] = '<option value="'.$variantID.'"'.(($first=='')?' selected':'').'>'.$Variant->fullName.'</option>';
if($first=='')
Expand Down Expand Up @@ -209,8 +210,6 @@ function setExtOptions(i){
print '</form>
</div>';



print '</div>';
libHTML::footer();
?>
3 changes: 1 addition & 2 deletions halloffame.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,6 @@
$showMe = 1;
while ( list($id, $username, $points) = $DB->tabl_row($crashed) )
{

print ' <tr class="hof">
<td class="hof"> '.number_format($points).' '.libHTML::points().' - #'.$i.' </td>';
if ($User->username == $username)
Expand Down Expand Up @@ -122,7 +121,6 @@
$showMe = 1;
while ( list($id, $username, $points) = $DB->tabl_row($crashed) )
{

print ' <tr class="hof">
<td class="hof"> '.number_format($points).' '.libHTML::points().' - #'.$i.' </td>';
if ($User->username == $username)
Expand All @@ -137,6 +135,7 @@
print' </tr>';
$i++;
}

if ( $User->type['User'] && $User->points > 100 && $User->timeLastSessionEnded > $sixMonths and $showMe == 1 )
{
print ' <tr class="hof">
Expand Down
23 changes: 12 additions & 11 deletions objects/notice.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,15 @@ class notice

private static $recent;
private static $new;

public function viewedSplitter()
{
global $User;

self::$recent=($this->timeSent >= $_SESSION['lastSeenHome'] );
self::$new=($this->timeSent >= $User->timeLastSessionEnded );
}

public function __construct(array $hash)
{
foreach($hash as $n=>$v)
Expand All @@ -65,9 +67,10 @@ public function __construct(array $hash)
}
else
$this->linkURL = '';

}

public static $noticesPage=false;

private function isRespondable()
{
global $User;
Expand All @@ -80,6 +83,7 @@ private function isRespondable()

return true;
}

public static function sendPMs()
{
global $User;
Expand All @@ -106,6 +110,7 @@ public static function sendPMs()
}
return false;
}

private function replyBox()
{
if( !isset(Config::$customForumURL) )
Expand All @@ -124,6 +129,7 @@ private function replyBox()
</div>';
}
}

public function html()
{
global $User;
Expand All @@ -141,7 +147,7 @@ public function html()

elseif (strpos($this->text, 'Your application to join') !== false || strpos($this->text, 'Congratulations! You have been accepted into') !== false || strpos($this->text, 'You have been removed from') !== false)
{
$buf = '<div style="background-color: #ddd;" class="homeNotice '.($this->type=='Game'?'" gameID="'.$this->fromID.'"':'userID'.$this->fromID.'"').'>
$buf = '<div style="background-color: #F08080;" class="homeNotice '.($this->type=='Game'?'" gameID="'.$this->fromID.'"':'userID'.$this->fromID.'"').'>
<div class="homeForumGroup homeForumAlt'.libHTML::alternate().'">
<div class="homeForumSubject homeForumTopBorder">'.$this->fromLink().'</div>
<div class="homeForumPostAlt'.libHTML::alternate().' homeForumPost">
Expand Down Expand Up @@ -171,19 +177,11 @@ public function html()
$buf .= '<div class="homeForumPostAlt'.libHTML::alternate().' homeForumPost">'.$this->replyBox().'</div>';

$buf .= ' </div>';
//<div class="homeForumMessage">'.$post['message'].'</div>

/*
$buf .= '<div class="homeForumLink">
<div class="homeForumPostTime"><strong>'.$data['replies'].'</strong> replies</div>
<a href="forum.php?threadID='.$threadID.'#'.$threadID.'">Open</a>
</div>
</div>';*/

$buf .= '</div>';

return $buf;
}

public function fromLink()
{
$linkName=$this->linkName;
Expand All @@ -196,14 +194,17 @@ public function fromLink()

return $buf;
}

public function timeSent()
{
return libTime::text($this->timeSent);
}

public function message()
{
return $this->text;
}

public static function send($toUserID, $fromID, $type, $keep, $private, $text, $linkName, $linkID='NULL')
{
global $DB;
Expand Down
66 changes: 38 additions & 28 deletions objects/silence.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php

class Silence {
class Silence
{
/**
* Silence ID
* @var int
Expand Down Expand Up @@ -57,14 +57,18 @@ class Silence {
public $reason;


public function isEnabled() {
public function isEnabled()
{
return $this->enabled && !$this->isExpired();
}
protected function isExpired() {

protected function isExpired()
{
return !($this->length==0 || ( time() < ($this->startTime + $this->length*60*60*24)));
}

public function disable() {
public function disable()
{
global $DB;

$this->enabled=false;
Expand All @@ -84,7 +88,8 @@ public function disable() {
* @param int/null $length The length in days (for user silences). If not given this is indefinite
* @return int The silence ID
*/
public static function create($moderatorUserID,$reason,$postID=null,$userID=null,$length=null) {
public static function create($moderatorUserID,$reason,$postID=null,$userID=null,$length=null)
{
global $DB;

$moderatorUserID=(int)$moderatorUserID;
Expand All @@ -111,7 +116,8 @@ public static function create($moderatorUserID,$reason,$postID=null,$userID=null
if( is_numeric($userID) )
$DB->sql_put("UPDATE wD_Users SET silenceID = ".$silenceID." WHERE id=".$userID);

if( is_numeric($postID) ) {
if( is_numeric($postID) )
{
// The post
$DB->sql_put("UPDATE wD_ForumMessages SET silenceID = ".$silenceID." WHERE id=".$postID);

Expand All @@ -120,12 +126,13 @@ public static function create($moderatorUserID,$reason,$postID=null,$userID=null
INNER JOIN wD_ForumMessages post ON post.toID = thread.id
SET thread.silenceID = ".$silenceID."
WHERE post.id=".$postID);
}
}

return $silenceID;
}

public function changeLength($length) {
public function changeLength($length)
{
global $DB;

$length = (int) $length;
Expand All @@ -141,12 +148,14 @@ public function changeLength($length) {
$this->length = $length;
}

public function load($id) {
public function load($id)
{
global $DB;

$record = array();

if( is_array($id) ) {
if( is_array($id) )
{
// If it's an array this may be coming in from a forum joined hash
$record = $id;
}
Expand Down Expand Up @@ -178,14 +187,15 @@ public function load($id) {
$this->startTime = (int)$record['silenceStartTime'];
$this->length = (int)$record['silenceLength'];
$this->reason = $record['silenceReason'];

}

public function Silence($id) {
public function Silence($id)
{
$this->load($id);
}

public static function isSilenced(array $forumRecord) {
public static function isSilenced(array $forumRecord)
{
return ( isset($forumRecord['silenceID']) && is_numeric($forumRecord['silenceID']));
}
/**
Expand All @@ -198,22 +208,20 @@ public static function isSilenced(array $forumRecord) {
*
* @return string A text message containing the results. Will be "" if nothing happened.
*/
public static function formActions() {
public static function formActions()
{
global $User;

if( !$User->type['ForumModerator'] ) return;

if(
isset($_REQUEST['silencePostID']) &&
isset($_REQUEST['silenceReason'])
) {
// Validation is done within create(), so these values can be passed straight through


// Validation is done within create(), so these values can be passed straight through
if(isset($_REQUEST['silencePostID']) && isset($_REQUEST['silenceReason']) )
{
return l_t("Silence created successfully");
}

if( isset($_REQUEST['disableSilenceID']) ) {
if( isset($_REQUEST['disableSilenceID']) )
{
$silence = new Silence();
$silence->load($_REQUEST['disableSilenceID']);
$silence->disable();
Expand All @@ -224,8 +232,8 @@ public static function formActions() {
return "";
}

public function toString() {
public function toString()
{
$Moderator = new User($this->moderatorUserID);

$startTime = libTime::text($this->startTime);
Expand All @@ -239,7 +247,8 @@ public function toString() {
'Reason' => $this->reason
);

if( $this->userID ) {
if( $this->userID )
{
$SilencedUser = new User($this->userID);
$silenceData['User'] = $SilencedUser->profile_link();
}
Expand All @@ -250,12 +259,13 @@ public function toString() {
$strArr = array('<ul class="formlist"><li>');
foreach($silenceData as $k=>$v)
$strArr[] = l_t($k).": <i>".$v."</i>";

$strArr[]='</li></ul>';
return implode("</li><li>",$strArr);
}

public static function printLength($length) {
public static function printLength($length)
{
return ($length==0 ? l_t("indefinitely") : l_t("for %s days",$length) );

}
}

0 comments on commit ecee95f

Please sign in to comment.