Ejemplo n.º 1
0
$SpecialFlag = true;
$NoLoginStuff = true;
require '_std-include.php';
$mypage = page::standard();
if (@$_SESSION['LoggedIn']) {
    $_SESSION['AllowUse'] = 0;
    $mypage->title_body('Logged in');
    $mypage->leaf('p', 'You cannot access this page while logged in. Please either <a href="logout.php">log out</a> first, or return to the <a href="index.php">Main Page</a>.');
    $mypage->finish();
} else {
    if (isset($_POST['FormSubmit'])) {
        if (!isset($_SESSION['AllowUseUID'])) {
            die($unexpectederrormessage);
        }
        $errors = false;
        $errorlist = fragment::blank();
        $EscapedUserID = sanitise_int(@$_POST['UserID']);
        if ($EscapedUserID != $_SESSION['AllowUseUID']) {
            die($unexpectederrormessage);
        }
        $EscapedAnswer = trim(@$_POST['Answer']);
        $EscapedPassword = trim(@$_POST['Password']);
        $EscapedConfirmPassword = trim(@$_POST['ConfirmPassword']);
        $row = dbquery(DBQUERY_READ_SINGLEROW, 'SELECT "SecretQuestion", "SecretAnswer", "UserValidated" FROM "User" WHERE "UserID" = :user:'******'user', $EscapedUserID);
        if ($row === 'NONE' or !$row['UserValidated']) {
            die($unexpectederrormessage);
        }
        if ($row['SecretAnswer'] != crypt($EscapedAnswer, $row['SecretAnswer'])) {
            $errors = true;
            $errorlist->leaf('li', 'The Secret Answer you entered was not correct.');
        }
Ejemplo n.º 2
0
function gamelistdisplayuf(tagtree &$tt, $ThePlayerID, $PlayerName, $PlayerPronoun, $DisplayNotification, $StartPoint, $MaxResults, $Pagenum)
{
    if ($DisplayNotification) {
        $MaxResults++;
    }
    $QueryResult = dbquery(DBQUERY_READ_RESULTSET, 'SELECT "PlayerGameRcd"."Colour" AS "UsersColour", "PlayerGameRcd"."Inherited", "PlayerGameRcd"."GameCounts", "PlayerGameRcd"."GameResult", "PlayerGameRcd"."NumLongTurns", "Game"."GameID", "Game"."Friendly", "Game"."GameName", "Game"."GTitleDeletedByAdmin", "Game"."LastMove", "Game"."GameCreator", "Game"."OriginalPlayers", "Game"."CurrentPlayers", "Game"."GameStatus", "GameVersion"."ShortVersionName", "GameVersionGroup"."VersionName", "GameVersion"."VersionNameSuffix", "GameVersion"."Creators", "User"."Name" AS "GameCreatorName", "GameInProgress"."PlayerToMove", "GameInProgress"."AbortVote", "GameInProgress"."KickVote", ROUND("PGRScore"."Score"/100, 2) AS "Score", "ParticipantRcd"."CurrentOccupant" FROM "PlayerGameRcd" JOIN "Game" ON "PlayerGameRcd"."Game" = "Game"."GameID" JOIN "GameVersion" ON "Game"."GVersion" = "GameVersion"."VersionID" JOIN "GameVersionGroup" ON "GameVersion"."VersionGroup" = "GameVersionGroup"."VersionGroupID" JOIN "User" ON "Game"."GameCreator" = "User"."UserID" LEFT JOIN "GameInProgress" ON "Game"."GameID" = "GameInProgress"."Game" LEFT JOIN "PGRScore" ON "PlayerGameRcd"."Game" = "PGRScore"."Game" AND "PlayerGameRcd"."User" = "PGRScore"."User" LEFT JOIN "PlayerGameRcd" AS "ParticipantRcd" ON "ParticipantRcd"."User" = :me: AND "Game"."GameID" = "ParticipantRcd"."Game" WHERE "PlayerGameRcd"."User" = :user: AND "PlayerGameRcd"."GameResult" NOT IN (\'Playing\', \'Hide\') ORDER BY "Game"."LastMove" DESC LIMIT :startpoint:, :maxresults:', 'user', $ThePlayerID, 'me', $_SESSION['MyUserID'], 'startpoint', $StartPoint, 'maxresults', $MaxResults);
    if ($DisplayNotification) {
        $MaxResults--;
        if ($QueryResult === 'NONE') {
            $tt->leaf('p', 'None');
            return;
        }
        $fb = fragment::blank();
        $PaginationBar = array($fb, $fb);
    } else {
        require_once HIDDEN_FILES_PATH . 'paginate.php';
        $CountQueryResult = dbquery(DBQUERY_READ_INTEGER, 'CALL "CountUsersGamesFinished"(:user:)', 'user', $ThePlayerID);
        if (!$CountQueryResult) {
            return false;
        }
        $PaginationBar = paginationbar('game', 'games', SITE_ADDRESS . 'oldgames.php', array('UserID' => $ThePlayerID), 100, $Pagenum, $CountQueryResult);
        if ($QueryResult === 'NONE') {
            $tt->append($PaginationBar[0]);
            return;
        }
    }
    $PlayerColours = array('FFC18A', 'FFFFAF', '9FFF9F', 'FFC6FF', 'C4C4C4');
    $ColourNames = array(transtext('_colourRed'), transtext('_colourYellow'), transtext('_colourGreen'), transtext('_colourPurple'), transtext('_colourGrey'));
    $TranslatedResults = array('Finished 1st' => transtext('_ugResult1st'), 'Finished 2nd' => transtext('_ugResult2nd'), 'Finished 3rd' => transtext('_ugResult3rd'), 'Finished 4th' => transtext('_ugResult4th'), 'Finished 5th' => transtext('_ugResult5th'), 'Game Aborted' => transtext('_ugResultAborted'), 'Quit' => transtext('_ugResultQuit'), 'Kicked by Admin' => transtext('_ugResultKickA'), 'Kicked by System' => transtext('_ugResultKickS'), 'Kicked by Vote' => transtext('_ugResultKickV'));
    $frag = fragment::blank();
    $OldGameID = 0;
    $i = 0;
    while ($row = db_fetch_assoc($QueryResult)) {
        if ($row['GameID'] != $OldGameID) {
            $i++;
            if ($i > $MaxResults) {
                // "This table shows only X's last 20 games" etc
                $tt->leaf('p', str_replace(array('\\username', '\\pronoun', '\\userid'), array($PlayerName, $PlayerPronoun, $ThePlayerID), transtext('_ugFinishedNote')));
                break;
            }
            $OldGameID = $row['GameID'];
            if ($row['GTitleDeletedByAdmin']) {
                $row['GameName'] = 'The title of this game has been cleared by an Administrator';
            }
            if (is_null($row['CurrentOccupant']) or $row['CurrentOccupant'] > 0 and !$row['GameIsFinished']) {
                $RowTagAttributes = null;
            } else {
                if ($row['GameStatus'] == 'In Progress' and $row['PlayerToMoveID'] == $_SESSION['MyUserID'] or $row['GameStatus'] == 'Recruiting Replacement' and !is_null($row['Colour'])) {
                    $RowTagAttributes = 'class="mymove"';
                } else {
                    if (($row['GameStatus'] == 'In Progress' or $row['GameStatus'] == 'Recruiting Replacement') and ($row['AbortVote'] != '00000' or $row['KickVote'] != '00000')) {
                        $RowTagAttributes = 'class="myattn"';
                    } else {
                        $RowTagAttributes = 'class="mygame"';
                    }
                }
            }
            $frag->opennode('tr', $RowTagAttributes);
            $version_name = vname($row['VersionName'], $row['VersionNameSuffix']);
            $frag->leaf('td', '<img src="gfx/icon-' . strtolower($row['ShortVersionName']) . '.png" alt="' . $version_name . '" title="' . $version_name . ' (' . $row['Creators'] . ')">', 'width=23 style="border-right: none;"');
            $frag->leaf('td', '<a href="board.php?GameID=' . $row['GameID'] . '">' . $row['GameName'] . '</a>', 'style="border-left: none; padding-left: 0px; text-align: left;"');
            $frag->leaf('td', '<a href="userdetails.php?UserID=' . $row['GameCreator'] . '">' . $row['GameCreatorName'] . '</a>');
            if ($row['Friendly']) {
                $frag->leaf('td', transtext('^Yes'), 'bgcolor="#9FFF9F"');
            } else {
                $frag->leaf('td', transtext('^No'), 'bgcolor="#FFC18A"');
            }
            $frag->leaf('td', $row['CurrentPlayers'] . ($row['CurrentPlayers'] == $row['OriginalPlayers'] ? '' : '&#8239;/&#8239;' . $row['OriginalPlayers']));
            $frag->leaf('td', $row['GameStatus']);
            $lmtime = strtotime($row['LastMove']);
            $frag->opennode('td');
            $frag->leaf('span', date('Y', $lmtime), 'style="font-size: 50%;"');
            $frag->text(date('M-d', $lmtime));
            $frag->closenode();
            $frag->leaf('td', $ColourNames[$row['UsersColour']], 'bgcolor="#' . $PlayerColours[$row['UsersColour']] . '"');
            $frag->leaf('td', $TranslatedResults[$row['GameResult']]);
            $frag->leaf('td', $row['NumLongTurns']);
            $frag->leaf('td', is_null($row['Score']) ? 'n/a' : $row['Score']);
            $frag->leaf('td', $row['GameCounts'] ? transtext('^Yes') : transtext('^No'));
            $frag->leaf('td', $row['Inherited'] ? transtext('^Yes') : transtext('^No'));
            $frag->closenode();
        }
    }
    $tt->append($PaginationBar[0]);
    $tt->opennode('table', 'class="table_extra_horizontal_padding"');
    $tt->opennode('thead');
    $tt->opennode('tr');
    $tt->leaf('th', 'Name', 'colspan=2 style="width: 175px;"');
    $tt->leaf('th', 'Creator');
    $tt->leaf('th', 'Frdly', 'title="Whether the game was a &quot;friendly&quot; game."');
    $tt->leaf('th', 'P', 'title="The number of players the game had when it finished (or currently has, if it hasn\'t finished) / the number of players it had when it started."');
    $tt->leaf('th', 'Status');
    $tt->leaf('th', 'Last Move', 'style="min-width: 75px;"');
    $tt->leaf('th', transtext('_ugColColour'), 'title="The colour ' . $PlayerName . ' played as in this game."');
    $tt->leaf('th', transtext('_ugColResult'), 'style="min-width: 90px;" title="The result ' . $PlayerName . ' achieved in this game. Usually this will be a rank achieved at the final scoring."');
    $tt->leaf('th', transtext('_ugColLT'), 'title="&quot;Long Turns&quot;: The number of times in this game ' . $PlayerName . ' took longer than Time Limit A to make a decision."');
    $tt->leaf('th', transtext('_ugColScore'), 'title="The score ' . $PlayerName . ' achieved in this game. The decimal part gives the player\'s position on the income track."');
    $tt->leaf('th', 'Counts', 'title="Whether the game counts towards ' . $PlayerName . '\'s statistics. Sometimes if you join a game in the middle, it does not contibute (either negatively or positively) toward your personal statistics."');
    $tt->leaf('th', 'Inhrtd', 'title="Whether ' . $PlayerName . ' inherited this game, that is, took over from another player who had left the game."');
    $tt->closenode(2);
    // tr, thead
    $tt->opennode('tbody');
    $tt->append($frag);
    $tt->closenode(2);
    // tbody, table
    $tt->append($PaginationBar[1]);
}
Ejemplo n.º 3
0
function paginationbar($ObjectDescriptionSingular, $ObjectDescriptionPlural, $PageURL, $PageParameters, $NumberPerPage, $ThisPage, $NumberOfItems)
{
    $output = fragment::blank();
    if ($NumberOfItems == 0) {
        return array($output, $output);
    }
    $output->opennode('p');
    $PageURLWithParameters = $PageURL . '?';
    if (is_array($PageParameters)) {
        foreach ($PageParameters as $key => $value) {
            $PageURLWithParameters .= $key . '=' . $value . '&amp;';
        }
    }
    $PageURLWithParameters .= 'Page=';
    $NoSecondBar = false;
    $NumberOfPages = $NumberOfItems / $NumberPerPage;
    $NumberOfPages = (int) $NumberOfPages;
    if ($NumberOfItems % $NumberPerPage) {
        $NumberOfPages++;
    }
    if ($NumberOfPages == 1) {
        if ($NumberOfItems == 1) {
            $IsAre = 'is';
        } else {
            $IsAre = 'are';
            $ObjectDescriptionSingular = $ObjectDescriptionPlural;
        }
        $output->text('This script displays up to ' . $NumberPerPage . ' ' . $ObjectDescriptionPlural . ' to a page.');
        $output->text('<br>There ' . $IsAre . ' ' . $NumberOfItems . ' ' . $ObjectDescriptionSingular . ' to display, which is only one page\'s worth.');
        if ($ThisPage != 1) {
            $NoSecondBar = true;
            $output->text('<br><span class="font_sans_serif" style="font-weight: bold;"><a href="' . $PageURLWithParameters . '1">Go to page 1</a></span>');
        }
        $output->closenode();
    } else {
        if ($ThisPage > $NumberOfPages) {
            $NoSecondBar = true;
            $output->text('This script displays up to ' . $NumberPerPage . ' ' . $ObjectDescriptionPlural . ' to a page.');
            $output->text('<br>There are ' . $NumberOfItems . ' ' . $ObjectDescriptionPlural . ' to display, which isn\'t enough to reach to the specified number of pages.');
            $output->emptyleaf('br');
            $output->opennode('span', 'class="font_sans_serif"');
            $output->leaf('b', 'Pages:');
            $output->opennode('ul', 'class="paginationlist"');
        } else {
            $output->text('This script displays up to ' . $NumberPerPage . ' ' . $ObjectDescriptionPlural . ' to a page. There are ' . $NumberOfItems . ' ' . $ObjectDescriptionPlural . ' to display.');
            $output->emptyleaf('br');
            $output->opennode('span', 'class="font_sans_serif"');
            $output->leaf('b', 'Pages:');
            $output->opennode('ul', 'class="paginationlist"');
            if ($ThisPage > 1) {
                $output->leaf('li', '<a href="' . $PageURLWithParameters . ($ThisPage - 1) . '">Previous</a>', 'class="separator_dash_after"');
            }
            if ($ThisPage > 0 and $ThisPage < $NumberOfPages) {
                $output->leaf('li', '<a href="' . $PageURLWithParameters . '2">Next</a>', 'class="separator_dash_after"');
            }
            if ($ThisPage < 1) {
                $NoSecondBar = true;
            }
        }
        $PagesWanted = array(1, 2);
        if ($ThisPage <= $NumberOfPages) {
            for ($i = $ThisPage - 2; $i < $ThisPage + 3; $i++) {
                if ($i > 0 and $i <= $NumberOfPages and !in_array($i, $PagesWanted)) {
                    $PagesWanted[] = $i;
                }
            }
        }
        if (!in_array($NumberOfPages - 1, $PagesWanted)) {
            $PagesWanted[] = $NumberOfPages - 1;
        }
        if (!in_array($NumberOfPages, $PagesWanted)) {
            $PagesWanted[] = $NumberOfPages;
        }
        for ($i = 0; $i < count($PagesWanted) - 1; $i++) {
            if ($PagesWanted[$i + 1] == $PagesWanted[$i] + 2) {
                for ($j = count($PagesWanted); $j > $i; $j--) {
                    $PagesWanted[$j] = $PagesWanted[$j - 1];
                }
                $PagesWanted[$i + 1] = $PagesWanted[$i] + 1;
            }
        }
        $MissingPages = false;
        for ($i = 0; $i < count($PagesWanted); $i++) {
            if ($PagesWanted[$i] == $NumberOfPages and $MissingPages) {
                $attributes = 'class="separator_dash_after"';
            } else {
                $attributes = null;
            }
            if ($PagesWanted[$i] == $ThisPage) {
                $output->leaf('li', '<b>' . $PagesWanted[$i] . '</b>', $attributes);
            } else {
                $output->leaf('li', '<b><a href="' . $PageURLWithParameters . $PagesWanted[$i] . '">' . $PagesWanted[$i] . '</a></b>', $attributes);
            }
            if ($i != count($PagesWanted) - 1 and $PagesWanted[$i + 1] != $PagesWanted[$i] + 1) {
                $output->leaf('li', '&hellip;');
                $MissingPages = true;
            }
        }
        if ($MissingPages) {
            $output->opennode('li');
            $output->opennode('form', 'action="' . $PageURL . '" method="GET" style="display: inline;"');
            $output->text('Or enter a page number:');
            $output->emptyleaf('input', 'type="text" name="Page" size=5 maxlength=10');
            $output->emptyleaf('input', 'type="submit" value="Go"');
            if (is_array($PageParameters)) {
                foreach ($PageParameters as $key => $value) {
                    $output->emptyleaf('input', 'type="hidden" name="' . $key . '" value="' . $value . '"');
                }
            }
            $output->closenode(5);
            // form, li, ul, span, p
        } else {
            $output->closenode(3);
            // ul, span, p
        }
    }
    if ($NoSecondBar) {
        return array($output, fragment::blank());
    } else {
        return array($output, $output);
    }
}
Ejemplo n.º 4
0
 $RatingOptions->closenode();
 // td
 $RatingOptions->next();
 $RatingOptions->leaf('td', '');
 $RatingOptions->leaf('td', '(Your rating is ' . $Rating . '. You cannot create a private game with a minimum or maximum player rating - if creating a private game, leave these set to "0" and "none" respectively. Your game <b>must</b> be a Competitive game if you set a <b>minimum</b> player rating - the setting of the tickbox option above will be ignored. However, you <b>can</b> create a Friendly game and give it a <b>maximum</b> player rating.)', 'class="font_serif"');
 $RatingOptions->closenode();
 // tr
 if ($Administrator) {
     $QR = dbquery(DBQUERY_READ_RESULTSET, 'SELECT "GameVersion"."VersionID", "GameVersionGroup"."VersionName", "GameVersion"."VersionNameSuffix", "GameVersion"."Creators", "GameVersion"."MinimumPlayersAllowed", "GameVersion"."MaximumPlayersAllowed" FROM "GameVersion" JOIN "GameVersionGroup" ON "GameVersion"."VersionGroup" = "GameVersionGroup"."VersionGroupID"');
 } else {
     $QR = dbquery(DBQUERY_READ_RESULTSET, 'SELECT "GameVersion"."VersionID", "GameVersionGroup"."VersionName", "GameVersion"."VersionNameSuffix", "GameVersion"."Creators", "GameVersion"."MinimumPlayersAllowed", "GameVersion"."MaximumPlayersAllowed" FROM "GameVersion" LEFT JOIN "GameVersionAuth" JOIN "GameVersionGroup" ON "GameVersion"."VersionGroup" = "GameVersionGroup"."VersionGroupID" ON "GameVersion"."VersionID" = "GameVersionAuth"."Version" AND "GameVersionAuth"."User" = :user: WHERE "GameVersion"."GVAdminOnly" = 0 OR "GameVersionAuth"."User" IS NOT NULL', 'user', $_SESSION['MyUserID']);
 }
 if ($QR === 'NONE') {
     myerror($unexpectederrormessage, 'No game versions to display', MYERROR_NOT_IN_FUNCTION);
 }
 $VersionString = fragment::blank();
 while ($row = db_fetch_assoc($QR)) {
     $VersionString->leaf('option', vname($row['VersionName'], $row['VersionNameSuffix']) . ' (' . $row['Creators'] . ') (' . $row['MinimumPlayersAllowed'] . '-' . $row['MaximumPlayersAllowed'] . ')', 'value=' . $row['VersionID']);
 }
 if ($DefaultFriendly) {
     $FriendlyChecked = ' checked';
 } else {
     $FriendlyChecked = '';
 }
 if ($DefaultNoSC) {
     $ScotCanalChecked = ' checked';
 } else {
     $ScotCanalChecked = '';
 }
 if ($DefaultRVC) {
     $RVCChecked = ' checked';
Ejemplo n.º 5
0
}
if (!$Language) {
    $mypage->title_body('Language set to English');
    $mypage->leaf('p', 'Your language is set to English. Please visit <a href="translatea.php">this page</a> and set it to a different language, then try again.');
    $mypage->finish();
}
if (!isset($_GET['PhraseName'])) {
    myerror($unexpectederrormessage, 'No phrase name specified in GET request');
}
$PhraseName = sanitise_str($_GET['PhraseName'], STR_GPC | STR_ENSURE_ASCII);
$QR = dbquery(DBQUERY_READ_SINGLEROW, 'SELECT "PhraseInEnglish", "Description", "Notes", "CurrentlyInUse" FROM "Phrase" WHERE "PhraseName" = :phrasename:', 'phrasename', $PhraseName);
if ($QR === 'NONE') {
    myerror($unexpectederrormessage, 'Phrase with the specified phrase name "' . htmlspecialchars($PhraseName) . '" was not found');
}
$QRX = dbquery(DBQUERY_READ_SINGLEROW, 'SELECT "Translation", "Comment" FROM "TranslatedPhrase" WHERE "Language" = :language: AND "Translator" = :translator: AND "PhraseName" = :phrasename:', 'language', $Language, 'translator', $_SESSION['MyUserID'], 'phrasename', $PhraseName);
$notifications = fragment::blank();
if (!$QR['CurrentlyInUse']) {
    $notifications->leaf('p', 'This phrase is not now in use on the website - it was previously in use, but currently is not. It is not necessary to translate this phrase at present.', 'style="color: #FF0000;"');
}
if ($QRX === 'NONE') {
    $mypage->title_body('Translate phrase');
    $mypage->leaf('h3', 'Translate phrase');
    $QRX = array('Translation' => '', 'Comment' => '');
} else {
    $mypage->title_body('Edit translation');
    $mypage->leaf('h3', 'Edit translation');
    $notifications->leaf('p', '(You can delete your translation by blanking the "Translation" field and clicking "Submit". This will delete the comment too.)');
    if (is_null($QRX['Comment'])) {
        $QRX['Comment'] = '';
    }
}
Ejemplo n.º 6
0
            $this_file = file_get_contents(HIDDEN_FILES_PATH . $current_file_name);
            if ($this_file === false) {
                $mypage->title_body('File error');
                $mypage->leaf('p', 'Encountered a problem while attempting to read file "' . htmlspecialchars($current_file_name) . '"');
                $mypage->finish();
            }
            $files[] = $this_file;
        }
    }
}
closedir($hf_directory_resource);
$num_files = count($file_names);
///////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////
$page_top = fragment::blank();
$procedure_treated = array();
$procedure_files = array();
$procedure_names = array();
$procedures = array();
if ($num_files) {
    $page_top->leaf('p', 'The following procedures files were found:');
    $page_top->opennode('table', 'class="table_extra_horizontal_padding"');
    $page_top->opennode('thead');
    $page_top->opennode('tr');
    $page_top->leaf('th', 'File name');
    $page_top->leaf('th', 'Number of procedures');
    $page_top->closenode(2);
    // tr, thead
    $page_top->opennode('tbody', 'class="table_monospace_font"');
    for ($i = 0; $i < $num_files; $i++) {