Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

More tweaks #697

Merged
merged 8 commits into from
Aug 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions gatherling/action.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,11 @@
$message = "Your series <a href=\"seriescp.php?series=$player_series\">$player_series</a> doesn't have an upcoming event.<br/>";
$nameMostRecent = $series->mostRecentEvent()->name;
if (is_null($nameMostRecent) || $nameMostRecent == '') {
$createLink = 'event.php?mode=Create Next Event&name=' . $series->name . ' 1.00';
$createLink = 'event.php?mode=Create Next Event&name='.$series->name.' 1.00';
} else {
$createLink = 'event.php?mode=Create Next Event&name=' . $nameMostRecent;
$createLink = 'event.php?mode=Create Next Event&name='.$nameMostRecent;
}
$message = $message . "<a href=\"$createLink\">Create one</a> or set the series as inactive.";
$message = $message."<a href=\"$createLink\">Create one</a> or set the series as inactive.";
}
}
$recent = $series->mostRecentEvent();
Expand Down Expand Up @@ -83,12 +83,12 @@
$message = "You have an unreported match in $event->name vs. ";
if ($event->decklistsVisible()) {
$opp_entry = Entry::findByEventAndPlayer($event->id, $oppplayer->name);
$message = $message . $oppplayer->linkTo($event->client) . ' (' . $opp_entry->deck->linkTo() . ').';
$message = $message.$oppplayer->linkTo($event->client).' ('.$opp_entry->deck->linkTo().').';
} else {
$message = $message . $oppplayer->linkTo($event->client) . '.';
$message = $message.$oppplayer->linkTo($event->client).'.';
}
if ($match->player_reportable_check() == true) {
$message = $message . ' <a href="report.php?mode=submit_result&match_id=' . $match->id . '&player=' . $player_number . '">(Report Result)</a>';
$message = $message.' <a href="report.php?mode=submit_result&match_id='.$match->id.'&player='.$player_number.'">(Report Result)</a>';
}
}
} elseif ($match->result != 'BYE' && $match->verification == 'failed') {
Expand All @@ -101,8 +101,8 @@
$oppplayer = new Player($opp);

if ($match->player_reportable_check() == true) {
$message = "The reported result wasn't consistent with your opponent's, please resubmit $event->name vs. " . $oppplayer->linkTo() . '.';
$message = $message . '<a href="report.php?mode=submit_result&match_id=' . $match->id . '&player=' . $player_number . '">(Report Result)</a>';
$message = "The reported result wasn't consistent with your opponent's, please resubmit $event->name vs. ".$oppplayer->linkTo().'.';
$message = $message.'<a href="report.php?mode=submit_result&match_id='.$match->id.'&player='.$player_number.'">(Report Result)</a>';
} else {
$message = "You have an unreported match in $match->eventname.";
}
Expand Down
2 changes: 1 addition & 1 deletion gatherling/admin/clean_decks.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
if ($deck != null || $deck->id != 0) {
if ($deck->playername == null) {
$totalHangingDecks++;
echo '<a href="deck.php?mode=view&id=' . $deck->id . '">' . $deck->name . '</a> Deck ID: ' . $deck->id . " is a hanging deck and will be deleted.<br />\n";
echo '<a href="deck.php?mode=view&id='.$deck->id.'">'.$deck->name.'</a> Deck ID: '.$deck->id." is a hanging deck and will be deleted.<br />\n";
$deck->delete();
}
}
Expand Down
6 changes: 3 additions & 3 deletions gatherling/admin/db-upgrade.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

// If this fails with foreign key errors, execute `ALTER SCHEMA <gatherling> DEFAULT CHARACTER SET latin1;`

require_once __DIR__ . '/../lib.php';
require_once __DIR__.'/../lib.php';

// Try to connect multiple times in case the MySQL container is still starting up in the test environment.
$db = null;
Expand Down Expand Up @@ -90,14 +90,14 @@ function upgrade_db($new_version, $text, $func)
function redirect_deck_update($latest_id = 0)
{
$url = explode('?', $_SERVER['REQUEST_URI']);
$url = $url[0] . '?deckupdate=' . $latest_id;
$url = $url[0].'?deckupdate='.$latest_id;
echo "<a href=\"{$url}\">Continue</a>";
echo "<script type=\"text/javascript\"> window.location = \"http://{$_SERVER['SERVER_NAME']}$url\"; </script>";
exit(0);
}

if (isset($_GET['deckupdate'])) {
$deckquery = do_query('SELECT id FROM decks WHERE id > ' . intval($_GET['deckupdate']));
$deckquery = do_query('SELECT id FROM decks WHERE id > '.intval($_GET['deckupdate']));
$timestart = time();
while ($deckid = $deckquery->fetch_array()) {
flush();
Expand Down
2 changes: 1 addition & 1 deletion gatherling/admin/infobot.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

use Gatherling\Player;

require_once __DIR__ . '/../lib.php';
require_once __DIR__.'/../lib.php';

if (strncmp($_SERVER['HTTP_USER_AGENT'], 'infobot', 7) != 0) {
exit("<error>You're not infobot!</error>");
Expand Down
2 changes: 1 addition & 1 deletion gatherling/admin/removeDecks.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
if ($deck != null || $deck->id != 0) {
if ($deck->playername == null) {
$totalHangingDecks++;
echo '<a href="deck.php?mode=view&id=' . $deck->id . '">' . $deck->name . '</a> Deck ID: ' . $deck->id . " is a hanging deck and will be deleted.<br />\n";
echo '<a href="deck.php?mode=view&id='.$deck->id.'">'.$deck->name.'</a> Deck ID: '.$deck->id." is a hanging deck and will be deleted.<br />\n";
$deck->delete();
}
}
Expand Down
6 changes: 3 additions & 3 deletions gatherling/admin/updateDecks.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,14 @@
if ($result2) {
$db = Database::getConnection();
$stmt = $db->prepare('UPDATE decks SET playername = ?, format = ?, deck_colors = ?, created_date = ? WHERE id = ?');
echo 'Playername: ' . $deck->playername . '<br />Format: ' . $deck->format . '<br />Color String: ' . $deck->deck_color_str . "<br />\n";
echo 'Playername: '.$deck->playername.'<br />Format: '.$deck->format.'<br />Color String: '.$deck->deck_color_str."<br />\n";
$stmt->bind_param('ssssd', $deck->playername, $deck->format, $deck->deck_color_str, $deck->created_date, $deck->id);
$stmt->execute() or exit($stmt->error);
echo '<a href="deck.php?mode=view&id=' . $deck->id . '">' . $deck->name . '</a> Deck ID: ' . $deck->id . ' Sucessfully updated<br />';
echo '<a href="deck.php?mode=view&id='.$deck->id.'">'.$deck->name.'</a> Deck ID: '.$deck->id.' Sucessfully updated<br />';
$successUpdatedDecks++;
//if ($decksChecked > 10) { die; }
} else {
echo $deck->id . ' Has no data in entries, missing playername, no player association. Deck will be deleted<br />';
echo $deck->id.' Has no data in entries, missing playername, no player association. Deck will be deleted<br />';
$failedUpdatedDecks++;
$deck->delete();
}
Expand Down
6 changes: 3 additions & 3 deletions gatherling/authdebug.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php

require_once __DIR__ . '/lib.php';
require __DIR__ . '/authlib.php';
require_once __DIR__.'/lib.php';
require __DIR__.'/authlib.php';

global $CONFIG;
global $provider;
Expand Down Expand Up @@ -43,7 +43,7 @@ function send_to_discord()
$options = ['scope' => ['identify', 'email']];
$authUrl = $provider->getAuthorizationUrl($options);
$_SESSION['oauth2state'] = $provider->getState();
header('Location: ' . $authUrl);
header('Location: '.$authUrl);
}

function store_token($token)
Expand Down
14 changes: 7 additions & 7 deletions gatherling/authlib.php
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
<?php

require_once __DIR__ . '/lib.php';
require_once __DIR__.'/lib.php';

global $CONFIG;

$provider = new \Wohali\OAuth2\Client\Provider\Discord([
'clientId' => $CONFIG['DISCORD_CLIENT_ID'],
'clientSecret' => $CONFIG['DISCORD_CLIENT_SECRET'],
'redirectUri' => $CONFIG['base_url'] . 'auth.php',
'redirectUri' => $CONFIG['base_url'].'auth.php',
]);

function load_cached_token()
Expand All @@ -24,7 +24,7 @@ function get_user_guilds($token)
{
global $provider;

$guildsRequest = $provider->getAuthenticatedRequest('GET', $provider->getResourceOwnerDetailsUrl($token) . '/guilds', $token);
$guildsRequest = $provider->getAuthenticatedRequest('GET', $provider->getResourceOwnerDetailsUrl($token).'/guilds', $token);

return $provider->getParsedResponse($guildsRequest);
}
Expand All @@ -33,10 +33,10 @@ function debug_info($token)
{
// Show some token details
echo '<h2>Token details:</h2>';
echo 'Token: ' . $token->getToken() . '<br/>';
echo 'Refresh token: ' . $token->getRefreshToken() . '<br/>';
echo 'Expires: ' . $token->getExpires() . ' - ';
echo($token->hasExpired() ? 'expired' : 'not expired') . '<br/>';
echo 'Token: '.$token->getToken().'<br/>';
echo 'Refresh token: '.$token->getRefreshToken().'<br/>';
echo 'Expires: '.$token->getExpires().' - ';
echo($token->hasExpired() ? 'expired' : 'not expired').'<br/>';
echo 'Values: <br/>';
foreach ($token->getValues() as $key => $value) {
echo "$key=$value<br/>";
Expand Down
20 changes: 10 additions & 10 deletions gatherling/bootstrap.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,26 +10,26 @@ function autoload($class_name)
$names = explode('\\', $class_name);
if ($names[0] == 'Gatherling') {
$class_name = $names[1];
if (file_exists('models/' . $class_name . '.php')) {
require_once 'models/' . $class_name . '.php';
} elseif (file_exists('../models/' . $class_name . '.php')) {
require_once '../models/' . $class_name . '.php';
} elseif (file_exists('gatherling/models/' . $class_name . '.php')) {
require_once 'gatherling/models/' . $class_name . '.php';
if (file_exists('models/'.$class_name.'.php')) {
require_once 'models/'.$class_name.'.php';
} elseif (file_exists('../models/'.$class_name.'.php')) {
require_once '../models/'.$class_name.'.php';
} elseif (file_exists('gatherling/models/'.$class_name.'.php')) {
require_once 'gatherling/models/'.$class_name.'.php';
}
}
}

spl_autoload_register('autoload');
// Fix for MAGIC_QUOTES_GPC

if (file_exists(__DIR__ . '/vendor/autoload.php')) {
include_once __DIR__ . '/vendor/autoload.php';
if (file_exists(__DIR__.'/vendor/autoload.php')) {
include_once __DIR__.'/vendor/autoload.php';
} else {
include_once __DIR__ . '/../vendor/autoload.php';
include_once __DIR__.'/../vendor/autoload.php';
}

if (file_exists(__DIR__ . '/config.php')) {
if (file_exists(__DIR__.'/config.php')) {
require_once 'config.php';
} else {
$CONFIG = $_ENV;
Expand Down
6 changes: 3 additions & 3 deletions gatherling/deckdl.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,17 +30,17 @@
foreach ($deck->maindeck_cards as $card => $qty) {
// Æ to AE litigation
$card = normaliseCardName($card);
$content .= $qty . ' ' . $card . "\r\n";
$content .= $qty.' '.$card."\r\n";
}

$content .= "\r\nSideboard\r\n";

foreach ($deck->sideboard_cards as $card => $qty) {
$card = normaliseCardName($card);
$content .= $qty . ' ' . $card . "\r\n";
$content .= $qty.' '.$card."\r\n";
}

$filename = preg_replace('/ /', '_', $deck->name) . '.txt';
$filename = preg_replace('/ /', '_', $deck->name).'.txt';
header('Content-type: text/plain');
header("Content-Disposition: attachment; filename=$filename");
echo $content;
Expand Down
2 changes: 1 addition & 1 deletion gatherling/email.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ function sendEmail($to, $subj, $msg): bool

$headers = [];
$headers[] = 'Accept: application/json';
$headers[] = 'Api-Key: ' . $CONFIG['brevo_api_key'];
$headers[] = 'Api-Key: '.$CONFIG['brevo_api_key'];
$headers[] = 'Content-Type: application/json';
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);

Expand Down
14 changes: 7 additions & 7 deletions gatherling/event.php
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ function content()
$newevent->number = $oldevent->number + 1;
$newevent->format = $oldevent->format;

$newevent->start = strftime('%Y-%m-%d %H:%M:00', strtotime($oldevent->start) + (86400 * 7));
$newevent->start = date('Y-m-d H:i:00', strtotime($oldevent->start) + (86400 * 7));
$newevent->kvalue = $oldevent->kvalue;
$newevent->finalized = 0;
$newevent->prereg_allowed = $oldevent->prereg_allowed;
Expand Down Expand Up @@ -219,7 +219,7 @@ function content()
$newevent->number = 1;
$newevent->format = $oldevent->format;

$newevent->start = strftime('%Y-%m-%d %H:%M:00', strtotime($oldevent->start) + (86400 * 7));
$newevent->start = date('Y-m-d H:i:00', strtotime($oldevent->start) + (86400 * 7));
$newevent->kvalue = $oldevent->kvalue;
$newevent->finalized = 0;
$newevent->prereg_allowed = $oldevent->prereg_allowed;
Expand Down Expand Up @@ -529,11 +529,11 @@ function eventForm(Event $event = null, bool $forcenew = false)
$hour = $datearr[4];
$minutes = $datearr[5];
} else {
$year = strftime('Y', time());
$month = strftime('B', time());
$day = strftime('Y', time());
$hour = strftime('H', time());
$minutes = strftime('M', time());
$year = date('Y', time());
$month = date('n', time());
$day = date('j', time());
$hour = date('H', time());
$minutes = date('i', time());
}

if ($edit) {
Expand Down
Loading