Skip to content

Commit

Permalink
Move SQL call to gateway, fix HTML compliance, clean up formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
The Kabal committed Sep 1, 2014
1 parent 54c2aa0 commit 585d89e
Showing 1 changed file with 41 additions and 56 deletions.
97 changes: 41 additions & 56 deletions options.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,70 +27,55 @@
$langvars = Bnt\Translate::load($pdo_db, $lang, array('options', 'common', 'global_includes', 'global_funcs', 'footer'));
$title = $langvars['l_opt_title'];
Bnt\Header::display($pdo_db, $lang, $template, $title, $body_class);
$players_gateway = new \Bnt\Players\PlayersGateway($pdo_db); // Build a player gateway object to handle the SQL calls
$playerinfo = $players_gateway->selectPlayerInfo($_SESSION['username']);

echo "<body class='options'>\n";
echo "<h1>" . $title . "</h1>\n";
echo "<body class = " . $body_class . ">";
$res = $db->Execute("SELECT * FROM {$db->prefix}ships WHERE email = ?;", array($_SESSION['username']));
$playerinfo = $res->fields;
echo "<form accept-charset='utf-8' action=option2.php method=post>\n";
echo "<table>\n";
echo "<tr>\n";
echo "<th colspan=2><strong>" . $langvars['l_opt_chpass'] . "</strong></th>\n";
echo "</tr>\n";
echo "<tr>\n";
echo "<td>" . $langvars['l_opt_curpass'] . "</td>\n";
echo "<td><input type=password name=oldpass size=20 maxlength=20 value=\"\"></td>\n";
echo "</tr>\n";
echo "<tr>\n";
echo "<td>" . $langvars['l_opt_newpass'] . "</td>\n";
echo "<td><input type=password name=newpass1 size=20 maxlength=20 value=\"\"></td>\n";
echo "</tr>\n";
echo "<tr>\n";
echo "<td>" . $langvars['l_opt_newpagain'] . "</td>\n";
echo "<td><input type=password name=newpass2 size=20 maxlength=20 value=\"\"></td>\n";
echo "</tr>\n";
echo "<tr>\n";
echo "<th colspan=2><strong>" . $langvars['l_opt_lang'] . "</strong></th>\n";
echo "</tr>\n";
echo "<tr>\n";
echo "<td>" . $langvars['l_opt_select'] . "</td><td><select name=newlang>\n";

echo "<form accept-charset='utf-8' action=option2.php method=post>";
echo "<table>";
echo "<tr>";
echo "<th colspan=2><strong>" . $langvars['l_opt_chpass'] . "</strong></th>";
echo "</tr>";
echo "<tr>";
echo "<td>" . $langvars['l_opt_curpass'] . "</td>";
echo "<td><input type=password name=oldpass size=20 maxlength=20 value=\"\"></td>";
echo "</tr>";
echo "<tr>";
echo "<td>" . $langvars['l_opt_newpass'] . "</td>";
echo "<td><input type=password name=newpass1 size=20 maxlength=20 value=\"\"></td>";
echo "</tr>";
echo "<tr>";
echo "<td>" . $langvars['l_opt_newpagain'] . "</td>";
echo "<td><input type=password name=newpass2 size=20 maxlength=20 value=\"\"></td>";
echo "</tr>";
echo "<tr>";
echo "<th colspan=2><strong>" . $langvars['l_opt_lang'] . "</strong></th>";
echo "</tr>";
echo "<tr>";
echo "<td>" . $langvars['l_opt_select'] . "</td><td><select name=newlang>";

$lang_dir = new DirectoryIterator('languages/');
foreach ($lang_dir as $file_info) // Get a list of the files in the languages directory
$avail_langs = Bnt\Languages::listAvailable($pdo_db, $lang);
foreach($avail_langs as $language_list_item_name => $language_list_item)
{
// If it is a PHP file, add it to the list of accepted language files
if ($file_info->isFile() && $file_info->getExtension() == 'php') // If it is a PHP file, add it to the list of accepted make galaxy files
if ($language_list_item_name == $playerinfo['lang'])
{
$lang_file = mb_substr($file_info->getFilename(), 0, -8); // The actual file name

// Select from the database and return the localized name of the language
$result = $db->Execute("SELECT value FROM {$db->prefix}languages WHERE category = 'regional' AND section = ? AND name = 'local_lang_name';", array($lang_file));
Bnt\Db::logDbErrors($db, $result, __LINE__, __FILE__);
while ($result && !$result->EOF)
{
$row = $result->fields;

if ($lang_file == $playerinfo['lang'])
{
$selected = " selected";
}
else
{
$selected = null;
}
echo "<option value='" . $lang_file . "'" . $selected . ">" . $row['value'] . "</option>";
$result->MoveNext();
}
$selected = " selected";
}
else
{
$selected = null;
}

echo "<option value='" . $language_list_item_name . "'" . $selected . ">" . $language_list_item['lang_name'] . "</option>\n";
}

echo "</select></td>";
echo "</tr>";
echo "</table>";
echo "<br>";
echo "<input type=submit value=" . $langvars['l_opt_save'] . ">";
echo "</form><br>";
echo "</select></td>\n";
echo "</tr>\n";
echo "</table>\n";
echo "<br>\n";
echo "<input type=submit value=" . $langvars['l_opt_save'] . ">\n";
echo "</form><br>\n";

Bnt\Text::gotoMain($db, $lang, $langvars);
Bnt\Footer::display($pdo_db, $lang, $bntreg, $template);
Expand Down

0 comments on commit 585d89e

Please sign in to comment.