Skip to content

Commit

Permalink
linter: delete superfluous whitespace
Browse files Browse the repository at this point in the history
  • Loading branch information
RedDragonWebDesign committed Jan 24, 2024
1 parent a983794 commit 12fc00c
Show file tree
Hide file tree
Showing 628 changed files with 14,529 additions and 14,984 deletions.
6 changes: 6 additions & 0 deletions .phpcs.xml
Original file line number Diff line number Diff line change
@@ -1,9 +1,15 @@
<ruleset>
<arg name="tab-width" value="4"/>

<!-- don't touch files that aren't in git -->
<exclude-pattern>/.github/</exclude-pattern>
<exclude-pattern>/.vscode/</exclude-pattern>
<exclude-pattern>/gitignore/</exclude-pattern>
<exclude-pattern>/screenshots/</exclude-pattern>
<exclude-pattern>/vendor/</exclude-pattern>

<!-- only check *.php files -->
<exclude-pattern>*\.(?!php$)</exclude-pattern>

<rule ref="Squiz.WhiteSpace.SuperfluousWhitespace"/>
</ruleset>
69 changes: 31 additions & 38 deletions src/_functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ function filterArray($arrValues) {
$temp = str_replace("&middot;", "&#38;middot;", $value);
$temp = str_replace("&raquo;", "&#38;raquo;", $temp);
$temp = str_replace("&laquo;", "&#38;laquo;", $temp);

$newArray[$key] = $temp;
}
return $newArray;
Expand Down Expand Up @@ -75,9 +75,8 @@ function getPreciseTime($intTime, $timeFormat="", $bypassTimeDiff=false) {
$timeFormat = "D M j, Y g:i a";
}


$dispLastDate = date($timeFormat, $intTime);

}

return $dispLastDate;
Expand All @@ -87,7 +86,7 @@ function getDateUTC($time, $timeFormat = "D M j, Y g:i a") {
$date = new DateTime();
$date->setTimezone(new DateTimeZone("UTC"));
$date->setTimestamp($time);

return $date->format($timeFormat);
}

Expand All @@ -106,50 +105,44 @@ function parseBBCode($strText) {
$arrBBCodes['RightAlign'] = array("bbOpenTag" => "[right]", "bbCloseTag" => "[/right]", "htmlOpenTag" => "<p align='right'>", "htmlCloseTag" => "</p>");
$arrBBCodes['Quote'] = array("bbOpenTag" => "[quote]", "bbCloseTag" => "[/quote]", "htmlOpenTag" => "<div class='forumQuote'>", "htmlCloseTag" => "</div>");
$arrBBCodes['Code'] = array("bbOpenTag" => "[code]", "bbCloseTag" => "[/code]", "htmlOpenTag" => "<div class='forumCode'>", "htmlCloseTag" => "</div>");

$randPollDiv = "poll_".md5(time().uniqid());

$arrBBCodes['Poll'] = array("bbOpenTag" => "[poll]", "bbCloseTag" => "[/poll]", "htmlOpenTag" => "<div id='".$randPollDiv."'></div><script type='text/javascript'>embedPoll('".$MAIN_ROOT."', '".$randPollDiv."', '", "htmlCloseTag" => "');</script>");



$arrBBCodes['Poll'] = array("bbOpenTag" => "[poll]", "bbCloseTag" => "[/poll]", "htmlOpenTag" => "<div id='".$randPollDiv."'></div><script type='text/javascript'>embedPoll('".$MAIN_ROOT."', '".$randPollDiv."', '", "htmlCloseTag" => "');</script>");

foreach($arrBBCodes as $bbCode) {

$strText = str_ireplace($bbCode['bbOpenTag'],$bbCode['htmlOpenTag'],$strText);
$strText = str_ireplace($bbCode['bbCloseTag'],$bbCode['htmlCloseTag'],$strText);

}

// Emoticons

$arrEmoticonCodes = array(":)", ":(", ":D", ";)", ":p");
$arrEmoticonImg = array("smile.png", "sad.png", "grin.png", "wink.png", "cheeky.png");

foreach($arrEmoticonCodes as $key => $value) {

$imgURL = "<img src='".$MAIN_ROOT."images/emoticons/".$arrEmoticonImg[$key]."' width='15' height='15'>";
$strText = str_ireplace($value, $imgURL, $strText);

}


// Complex Codes, ex. Links, colors...

$strText = preg_replace("/\[url](.*?)\[\/url]/i", "<a href='$1' target='_blank'>$1</a>", $strText); // Links no Titles
$strText = preg_replace("/\[url=(.*?)\](.*?)\[\/url\]/i", "<a href='$1' target='_blank'>$2</a>", $strText); // Links with Titles



$strText = preg_replace("/\[color=(.*)\](.*)\[\/color\]/i", "<span style='color: $1'>$2</span>", $strText); // Text Color

$strText = str_replace("[/youtube]", "[/youtube]\n", $strText);
$strText = preg_replace("/\[youtube\](http|https)(\:\/\/www\.youtube\.com\/watch\?v\=)(.*)\[\/youtube\]/i", "<iframe class='youtubeEmbed' src='http://www.youtube.com/embed/$3?wmode=opaque' frameborder='0' allowfullscreen></iframe>", $strText);
$strText = preg_replace("/\[\youtube\](http|https)(\:\/\/youtu\.be\/)(.*)\[\/youtube\]/i", "<iframe class='youtubeEmbed' src='http://www.youtube.com/embed/$3?wmode=opaque' frameborder='0' allowfullscreen></iframe>", $strText);

$strText = str_replace("[/twitch]", "[/twitch]\n", $strText);
$strText = preg_replace("/\[twitch\](http|https)(\:\/\/www\.twitch\.tv\/)(.*)\[\/twitch\]/i", "<object class='youtubeEmbed' type='application/x-shockwave-flash' id='live_embed_player_flash' data='http://www.twitch.tv/widgets/live_embed_player.swf?channel=$3' bgcolor='#000000'><param name='allowFullScreen' value='true' /><param name='wmode' value='opaque' /><param name='allowScriptAccess' value='always' /><param name='allowNetworking' value='all' /><param name='movie' value='http://www.twitch.tv/widgets/live_embed_player.swf' /><param name='flashvars' value='hostname=www.twitch.tv&channel=$3&auto_play=false&start_volume=25' /></object>", $strText);

$strText = autolink($strText);

return $strText;
Expand All @@ -159,16 +152,16 @@ function autoLinkImage($strText) {
$strText = preg_replace("/<img src=(\"|\')(.*)(\"|\')>/", "<a href='$2' target='_blank'><img src='$2'></a>", $strText);
$strText = preg_replace("/<img src=(\"|\')(.*)(\"|\') alt=(\"|\')(.*)(\"|\') width=(\"|\')(.*)(\"|\') height=(\"|\')(.*)(\"|\') \/>/", "<a href='$2' target='_blank'><img src='$2' width='$8' height='$11'></a>", $strText);
$strText = preg_replace("/<img src=(\"|\')(.*)(\"|\') alt=(\"|\')(.*)(\"|\') \/>/", "<a href='$2' target='_blank'><img src='$2'></a>", $strText);

return $strText;
}

function deleteFile($filename) {
$returnVal = false;
if(file_exists($filename)) {
$returnVal = unlink($filename);
$returnVal = unlink($filename);
}

return $returnVal;
}

Expand All @@ -179,31 +172,31 @@ function getHTTP() {
else {
$dispHTTP = "https://";
}

return $dispHTTP;
}

function addArraySpace($arr, $space, $atSpot) {
$newArr = array();
$i=0;
foreach($arr as $key => $value) {

if($atSpot == $key) {

for($x=0; $x<$space; $x++) {
$newArr[$i] = "";
$i++;
}

$newArr[$i] = $value;
}
else {
$newArr[$i] = $value;
$newArr[$i] = $value;
}
$i++;

$i++;
}

return $newArr;
}

Expand All @@ -215,7 +208,7 @@ function pluralize($word, $num) {
else {
$returnVal = $word."s";
}

return $returnVal;
}

Expand All @@ -225,12 +218,12 @@ function encryptPassword($password) {
if($randomNum < 10) {
$randomNum = "0".$randomNum;
}

$strSalt = "$2a$".$randomNum."$".$randomString;
$encryptPassword = crypt($password, $strSalt);

$returnArr = array("password" => $encryptPassword, "salt" => $strSalt);

return $returnArr;
}

Expand All @@ -251,16 +244,16 @@ function debug_string_backtrace() {
// Remove first item from backtrace as it's this function which
// is redundant.
$trace = preg_replace ('/^#0\s+' . __FUNCTION__ . "[^\n]*\n/", '', $trace, 1);

// sanitize HTML
$trace = htmlspecialchars($trace);

// Put each stack trace on its own line
$trace = preg_replace('/\n/', '<br />', $trace);

// Delete all but 1st stack trace
// $trace = preg_replace('/\n.*/', '', $trace);

return $trace;
}

Expand All @@ -272,7 +265,7 @@ function sql_array_select_where($sqlTableAsArray, $condition1Field, $condition1V
if ( $condition2Field ) {
$condition2 = isset($row[$condition2Field]) && $row[$condition2Field] == $condition2Value;
}

if (
isset($row[$condition1Field]) &&
$row[$condition1Field] == $condition1Value &&
Expand Down
20 changes: 10 additions & 10 deletions src/_global_setup.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,45 +27,45 @@ function debug() {

// Check PHP Version
if(version_compare(phpversion(), "7.0") < 0) {
die("You must be using at least PHP version 7.0 in order to run BlueThrust Clan Scripts. Your current PHP Version: ".phpversion().". You can usually change your PHP version in your website control panel. For example, cPanel.");
die("You must be using at least PHP version 7.0 in order to run BlueThrust Clan Scripts. Your current PHP Version: ".phpversion().". You can usually change your PHP version in your website control panel. For example, cPanel.");
}

/** Useful debug function. Pretty prints the contents of a variable.
Example usage: html_var_export($limit, '$limit'); */
function html_var_export($var, $var_name = NULL) {
$output = '<span class="html-var-export">';

if ( $var_name ) {
$output .= $var_name . ' = ';
}

$output .= nl2br_and_nbsp(var_export($var, TRUE)) . "</span><br /><br />";

echo $output;
}

function nl2br_and_nbsp($string) {
$string = nl2br($string);

$string = nbsp($string);

return $string;
}

function nbsp($string) {
$string = preg_replace('/\t/', '&nbsp;&nbsp;&nbsp;&nbsp;', $string);

// replace more than 1 space in a row with &nbsp;
$string = preg_replace('/ /m', '&nbsp;&nbsp;', $string);
$string = preg_replace('/ &nbsp;/m', '&nbsp;&nbsp;', $string);
$string = preg_replace('/&nbsp; /m', '&nbsp;&nbsp;', $string);

if ( $string == ' ' ) {
$string = '&nbsp;';
}

// Convert 2 space tab to 4 space tab
$string = preg_replace('/&nbsp;&nbsp;/m', '&nbsp;&nbsp;&nbsp;&nbsp;', $string);

return $string;
}
6 changes: 3 additions & 3 deletions src/_setup.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
ini_set('session.gc_maxlifetime', 60*60*24*3);

if(!isset($prevFolder)) {
$prevFolder = "";
$prevFolder = "";
}


Expand Down Expand Up @@ -141,7 +141,7 @@ function BTCS4Loader($class_name) {
'rankcategory' => 'rankcategory_id',
'ranks' => 'rank_id',
];

foreach ( $tablesToCache as $table => $primaryKey ) {
$sqlCache[$table] = [];
$result = $mysqli->query("SELECT * FROM ".$dbprefix.$table);
Expand Down Expand Up @@ -169,7 +169,7 @@ function BTCS4Loader($class_name) {
$sqlCache['rank_privileges'][] = $row;
}
}

// classes/consoleoptions.php::findConsoleIDByName()
$sqlCache['console-pagetitle'] = [];
$result = $mysqli->query("SELECT * FROM ".$dbprefix."console");
Expand Down
Loading

0 comments on commit 12fc00c

Please sign in to comment.