Skip to content

Commit

Permalink
Makes root directory files compliant with our coding standard
Browse files Browse the repository at this point in the history
Signed-off-by: Jon Stovell <[email protected]>
  • Loading branch information
Sesquipedalian committed Nov 21, 2023
1 parent 509f1b3 commit 9a22931
Show file tree
Hide file tree
Showing 6 changed files with 146 additions and 142 deletions.
17 changes: 11 additions & 6 deletions .php-cs-fixer.dist.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,20 @@
*/

$finder = (new PhpCsFixer\Finder())
->in(__DIR__ . '/Sources')
->in(__DIR__)
// Don't touch libraries.
->exclude([
'minify',
'random_compat',
'ReCaptcha',
'cache',
'other',
'Packages',
'Smileys',
'Sources/minify',
'Sources/random_compat',
'Sources/ReCaptcha',
'Themes',
])
// Skip all index.php files.
->notName('index.php')
// Skip all index.php files and ssi_example.php.
->notName(['index.php', 'ssi_examples.php'])
// Skip anything being ignored in .gitignore.
->ignoreVCSIgnored(true);

Expand Down
5 changes: 3 additions & 2 deletions SSI.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,14 @@
*/

// Don't do anything if SMF is already loaded.
if (defined('SMF'))
if (defined('SMF')) {
return true;
}

define('SMF', 'SSI');

// Initialize.
require_once(__DIR__ . '/index.php');
require_once __DIR__ . '/index.php';

$ssi = new SMF\ServerSideIncludes();
$ssi->execute();
Expand Down
5 changes: 3 additions & 2 deletions cron.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,14 @@
*/

// Don't do anything if SMF is already loaded.
if (defined('SMF'))
if (defined('SMF')) {
return true;
}

define('SMF', 'BACKGROUND');

// Initialize.
require_once(__DIR__ . '/index.php');
require_once __DIR__ . '/index.php';

$task_runner = new SMF\TaskRunner();
$task_runner->execute();
Expand Down
11 changes: 5 additions & 6 deletions proxy.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,20 +13,19 @@
* @version 3.0 Alpha 1
*/

if (!defined('SMF'))
if (!defined('SMF')) {
define('SMF', 'PROXY');
}

if (SMF == 'PROXY')
{
if (SMF == 'PROXY') {
// Initialize.
require_once(__DIR__ . '/index.php');
require_once __DIR__ . '/index.php';

$proxy = new SMF\ProxyServer();
$proxy->serve();
}
// In case a old mod included this file in order to load the ProxyServer class.
else
{
else {
class_exists('SMF\\ProxyServer');
}

Expand Down
39 changes: 15 additions & 24 deletions ssi_examples.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,12 @@
$ssi_guest_access = false;

// Include the SSI file.
require(dirname(__FILE__) . '/SSI.php');
require __DIR__ . '/SSI.php';

// Viewing the homepage sample?
if (isset($_GET['view']) && $_GET['view'] == 'home1')
{
if (isset($_GET['view']) && $_GET['view'] == 'home1') {
template_homepage_sample1('output');

exit;
}

Expand Down Expand Up @@ -408,8 +408,6 @@

/**
* Displays the header for this file
*
* @return void
*/
function template_ssi_above()
{
Expand Down Expand Up @@ -515,8 +513,6 @@ function toggleVisibleByClass(sClassName, bHide)

/**
* Displays the footer for this file
*
* @return void
*/
function template_ssi_below()
{
Expand Down Expand Up @@ -590,32 +586,28 @@ function template_homepage_sample1($method = 'source')
</body>
</html>';

if ($method == 'source')
{
if ($method == 'source') {
$header = '<?php require("' . (SMF\User::$me->is_admin ? addslashes(realpath(SMF\Config::$boarddir . '/SSI.php')) : 'SSI.php') . '"); ?>' . "\n" . $header;

return $header . template_homepage_sample1_html() . $footer;
}
else
{
echo $header;
template_homepage_sample1_php();
echo $footer;
}

echo $header;
template_homepage_sample1_php();
echo $footer;
}

/**
* Generates the sample homepage. Used with template_homepage_sample1 if $method isn't 'source'.
*
* @return void
*/
function template_homepage_sample1_php()
{
$topics = SMF\ServerSideIncludes::recentTopics(8, null, null, 'array');

foreach ($topics as $topic)
foreach ($topics as $topic) {
echo '
<li><a href="', $topic['href'], '">', $topic['subject'], '</a> ', SMF\Lang::$txt['by'], ' ', $topic['poster']['link'], '</li>';
}

unset($topics);

Expand All @@ -641,7 +633,6 @@ function template_homepage_sample1_php()

echo '
</div>';

}

/**
Expand All @@ -654,27 +645,27 @@ function template_homepage_sample1_html()
$result = '
<?php
// Using array method to show shorter display style.
$topics = SMF\ServerSideIncludes::recentTopics(8, null, null, \'array\');
$topics = SMF\\ServerSideIncludes::recentTopics(8, null, null, \'array\');
foreach ($topics as $topic)
{
// Uncomment the following code to get a listing of array elements that SMF provides for this function.
// echo \'<pre>\', print_r($topic), \'</pre>\';
echo \'
<li><a href=\"\', $topic[\'href\'], \'\">\', $topic[\'subject\'], \'</a> \', SMF\Lang::$txt[\'by\'], \' \', $topics[$i][\'poster\'][\'link\'], \'</li>\';
<li><a href=\\"\', $topic[\'href\'], \'\\">\', $topic[\'subject\'], \'</a> \', SMF\\Lang::$txt[\'by\'], \' \', $topics[$i][\'poster\'][\'link\'], \'</li>\';
}
unset($topics);
?>
</ul><br>
<h3>Online Users</h3>
<?php SMF\ServerSideIncludes::logOnline(); ?>
<?php SMF\\ServerSideIncludes::logOnline(); ?>
</div>
<div id="content">
<?php SMF\ServerSideIncludes::welcome(); ?><br><br>
<?php SMF\\ServerSideIncludes::welcome(); ?><br><br>
<h2>News</h2>
<?php SMF\ServerSideIncludes::boardNews(); ?>
<?php SMF\\ServerSideIncludes::boardNews(); ?>
</div>';

return $result;
Expand Down
Loading

0 comments on commit 9a22931

Please sign in to comment.