public function upgrade(PDO $pdo) { if ($this->fromVersion != schema_version($pdo)) { throw new RuntimeException(lng('cantexec')); } $pdo->exec(<<<SQL CREATE TABLE {$pdo->prefix}flood ( userid INT(10) NOT NULL DEFAULT 0, type TINYINT(1) DEFAULT NULL, time TIMESTAMP(6) NOT NULL, ip VARCHAR(16) NOT NULL DEFAULT '' ) ENGINE = HEAP SQL ); $pdo->exec(<<<SQL INSERT INTO {$pdo->prefix}registrygroup VALUES (8, 'Flood Protection', 7), (9, 'Error Reporting', 8) SQL ); $pdo->exec(<<<SQL INSERT INTO {$pdo->prefix}registry VALUES ('flood_login_count', '3', 'integer', 'Login failure count', 'Number of failed logins before the account gets locked for specific IP.<br>(0 to disable)', 8, 1), ('flood_login_timeout', '15', 'integer', 'Login failure timeout', 'Time (in minutes) for which an account gets locked after several failed logins.', 8, 2), ('flood_register_count', '5', 'integer', 'Registration count', 'Number of registrations before register gets locked for specific IP.<br>(0 to disable)', 8, 3), ('flood_register_timeout', '15', 'integer', 'Registration timeout', 'Time (in minutes) for which an IP gets locked after several registrations.', 8, 4), ('flood_mail_count', '3', 'integer', 'Mail count', 'Number of sent mails before mail function gets locked for specific user.<br>(0 to disable)', 8, 5), ('flood_mail_timeout', '15', 'integer', 'Mail timeout', 'Time (in minutes) for which mail function gets locked after several sent mails.', 8, 6), ('debug_what', '0', 'integer', 'Error Reporting', '0 - Disabled<br>1 - PHP only<br>2 - SQL only<br>3 - both', 9, 0), ('debug_mail', '0', 'boolean', 'Error Mails', 'Send error reports as email? This requires "Use eMail Functions" and "Board Admin/Tech eMail".', 9, 1), ('debug_do_log', '0', 'boolean', 'Log errors?', 'Log errors to file?<br>In order to use this feature, you must create a directory with the correct permissions and set the path below.<br><strong>It is highly recommended that this directory be secured by a .htaccess</strong>.', 9, 2), ('debug_log_path', 'logs/thwb_err', 'string', 'Log file path', 'path to the log file and log file prefix.<br><strong>See above</strong>.', 9, 3) SQL ); $stmt = $pdo->prepare(<<<SQL UPDATE {$pdo->prefix}registry SET keyvalue = :version WHERE keyname = 'version' SQL ); $stmt->bindValue(':version', $this->toVersion, PDO::PARAM_STR); $stmt->execute(); }
public function upgrade(PDO $pdo) { if ($this->fromVersion != schema_version($pdo)) { throw new RuntimeException(lng('cantexec')); } $pdo->exec(<<<SQL ALTER TABLE {$pdo->prefix}user ADD COLUMN usernoipcheck TINYINT(1) UNSIGNED NOT NULL DEFAULT 0 SQL ); $pdo->exec(<<<SQL UPDATE {$pdo->prefix}style SET boardimage = './templates/default/images/space.png' WHERE boardimage = './templates/default/images/space.gif' SQL ); $pdo->exec(<<<SQL UPDATE {$pdo->prefix}style SET boardimage = './templates/default/images/newtopic.png' WHERE boardimage = './templates/default/images/newtopic.gif' SQL ); $pdo->exec(<<<SQL UPDATE {$pdo->prefix}style SET stdfont = 'Verdana, Helevetica' WHERE stdfont = 'Verdana' SQL ); $stmt = $pdo->prepare(<<<SQL UPDATE {$pdo->prefix}registry SET keyvalue = :version WHERE keyname = 'version' SQL ); $stmt->bindValue(':version', $this->toVersion, PDO::PARAM_STR); $stmt->execute(); }
public function upgrade(PDO $pdo) { if ($this->fromVersion != schema_version($pdo)) { throw new RuntimeException(lng('cantexec')); } $pdo->exec(<<<SQL ALTER TABLE {$pdo->prefix}calendar ADD COLUMN userid INT(10) UNSIGNED NOT NULL SQL ); $stmt = $pdo->prepare(<<<SQL UPDATE {$pdo->prefix}registry SET keyvalue = :version WHERE keyname = 'version' SQL ); $stmt->bindValue(':version', $this->toVersion, PDO::PARAM_STR); $stmt->execute(); }
} switch ($_GET['step']) { case 'update-run': $update = (include 'updates/' . $_SESSION['update']); try { $update->upgrade($pdo); } catch (RuntimeException $e) { p_errormsg(lng('error'), $e->getMessage(), 'JavaScript:history.back(0)'); exit; } p_errormsg(lng('updatesuccess'), lng('updatesuccesstxt')); exit; break; case 'update-show': $update = (include 'updates/' . $_SESSION['update']); echo $template->render('update-show', ['about_handler' => 'install.php?step=about', 'step' => 'update-run', 'update' => $update, 'schema_version' => schema_version($pdo)]); break; case 'update-select': $updates = []; $dp = opendir('updates/'); while ($file = readdir($dp)) { if (substr($file, -4, 4) == '.php' && substr($file, -6, 6) != '.0.php') { $update = (include 'updates/' . $file); $updates[$file] = sprintf('%s -> %s', $update->fromVersion, $update->toVersion); } } if (isset($_POST['submit'])) { if (empty($_POST['update-selected']) || !in_array($_POST['update-selected'], array_keys($updates))) { p_errormsg(lng('error'), lng('notfound'), 'JavaScript:history.back(0)'); exit; }
}; </script> <script type="text/javascript" src="js/update.js"></script> <title>Race Schedule</title> <?php require 'inc/stylesheet.inc'; ?> </head> <body> <?php $banner_title = 'Racing Heats'; require 'inc/banner.inc'; running_round_header($now_running); require_once 'inc/rounds.inc'; $groups = all_schedule_groups(); $sql = 'SELECT' . ' Classes.class, round, heat, lane, finishtime, resultid, completed, ' . ($use_master_sched ? 'round' : 'Rounds.roundid') . ' as racinggroup,' . ($use_master_sched ? 'masterheat' : 'heat') . ' as seq,' . ' RegistrationInfo.carnumber, RegistrationInfo.firstname, RegistrationInfo.lastname,' . ' Classes.classid, Rounds.roundid, RaceChart.racerid' . ' FROM ' . inner_join('RaceChart', 'RegistrationInfo', 'RegistrationInfo.racerid = RaceChart.racerid', 'Roster', 'Roster.racerid = RegistrationInfo.Racerid', 'Rounds', 'Rounds.roundid = Roster.roundid', 'Classes', 'Rounds.classid = Classes.classid') . ' WHERE Rounds.roundid = RaceChart.roundid' . ' ORDER BY ' . ($use_master_sched ? 'round, masterheat, lane' : (schema_version() >= 2 ? 'Classes.sortorder, ' : '') . 'class, round, heat, lane'); $stmt = $db->query($sql); if ($stmt === FALSE) { $info = $db->errorInfo(); echo '<h2>Error: ' . $info[2] . '</h2>' . "\n"; } ?> <table class="main_table"> <?php function byes($n) { $result = ''; while ($n > 0) { $result .= '<td>Bye</td>'; --$n; }
} catch (PDOException $p) { echo '<p>Unable to query RegistrationInfo table.</p>'; } ?> <div class="block_buttons"> <input type="button" data-enhanced="true" value="Initialize Schema" onclick="show_initialize_schema_modal()"/> <br/> <?php function pad3($n) { return str_pad($n, 3, '0', STR_PAD_LEFT); } try { echo '<p>Schema version S1' . pad3(schema_version()) . ' (expecting version S1' . pad3(expected_schema_version()) . ')</p>' . "\n"; if (schema_version() < expected_schema_version()) { ?> <input type="button" data-enhanced="true" value="Update Schema" onclick="show_update_schema_modal()"/> <br/> <?php } } catch (PDOException $p) { echo '<p>Can\'t determine schema version (expecting version S1' . pad3(expected_schema_version()) . ')</p>' . "\n"; } ?> </div> <?php } function label_driver_check($driver)
<style> .scroll-bounding-rect { overflow: hidden; } </style> </head> <body> <?php $banner_title = 'Results By Racer'; require 'inc/banner.inc'; $nlanes = get_lane_count_from_results(); $now_running = get_running_round(); running_round_header($now_running, TRUE); require_once 'inc/rounds.inc'; $rounds = all_rounds(); $sql = 'SELECT RegistrationInfo.racerid,' . ' Classes.class, round, heat, lane, finishtime, resultid,' . ' carnumber, RegistrationInfo.firstname, RegistrationInfo.lastname,' . ' Classes.classid, Rounds.roundid' . ' FROM ' . inner_join('RaceChart', 'RegistrationInfo', 'RegistrationInfo.racerid = RaceChart.racerid', 'Roster', 'Roster.racerid = RegistrationInfo.racerid', 'Rounds', 'Rounds.roundid = Roster.roundid', 'Classes', 'Rounds.classid = Classes.classid') . ' WHERE Rounds.roundid = RaceChart.roundid' . (isset($_GET['racerid']) ? ' AND RaceChart.racerid = ' . $_GET['racerid'] : '') . ' ORDER BY ' . (schema_version() >= 2 ? 'Classes.sortorder, ' : '') . 'class, round, lastname, firstname, carnumber, resultid, lane'; $stmt = $db->query($sql); if ($stmt === FALSE) { $info = $db->errorInfo(); echo '<h2>Error: ' . $info[2] . '</h2>' . "\n"; } ?> <div class="scroll-bounding-rect"> <table class="main_table"> <?php function byes($n) { $result = ''; while ($n > 0) { $result .= '<td>--</td>'; --$n;
<div class="listview"> <ul id="all_awards" data-role="listview" data-split-icon="gear"> <?php // The list of awards gets generated by javascript code when the page loads, // and then periodically updated as necessary. ?> </ul> </div><!-- listview --> <div id="racers"> <div id="racers-inset"> <ul data-role="listview"> <?php // Generate the list of racers: foreach ($db->query('SELECT racerid, firstname, lastname, carnumber, rankid, classid' . (schema_version() >= 2 ? ', carphoto' : '') . ' FROM RegistrationInfo' . ' ORDER BY lastname, firstname') as $row) { $classid = $row['classid']; $rankid = $row['rankid']; $class = $classid ? htmlspecialchars($classes[$classid]['class'], ENT_QUOTES, 'UTF-8') : ''; $rank = $rankid ? htmlspecialchars($ranks[$rankid]['rank'], ENT_QUOTES, 'UTF-8') : ''; echo '<li'; echo ' data-racerid="' . $row['racerid'] . '"'; echo ' data-classid="' . $classid . '"'; echo ' data-rankid="' . $rankid . '"'; echo '>'; if (isset($row['carphoto']) && $row['carphoto']) { echo '<img src="' . car_photo_repository()->url_for_racer($row, RENDER_LISTVIEW) . '"/>'; } echo '<span>' . $row['carnumber'] . ' ' . htmlspecialchars($row['firstname'] . ' ' . $row['lastname'], ENT_QUOTES, 'UTF-8') . '</span>'; echo '<p>' . ($use_subgroups ? $rank . ', ' : '') . $class . '</p>'; echo '</li>';
<?php @session_start(); // Redirects to setup page if the database hasn't yet been set up require_once 'inc/data.inc'; require_once 'inc/schema_version.inc'; // This first database access is surrounded by a try/catch in order to catch // broken/corrupt databases (e.g., sqlite pointing to a file that's not actually // a database). The pdo may get created OK, but then fail on the first attempt // to access. try { $schema_version = schema_version(); } catch (PDOException $p) { $_SESSION['setting_up'] = 1; header('Location: database-setup.php'); exit; } ?> <!DOCTYPE html> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/> <title>Pinewood Derby Race Information</title> <?php require 'inc/stylesheet.inc'; ?> <script type="text/javascript" src="js/jquery.js"></script> <script type="text/javascript" src="js/modal.js"></script> </head> <body> <?php
public function upgrade(PDO $pdo) { if ($this->fromVersion != schema_version($pdo)) { throw new RuntimeException(lng('cantexec')); } /* no update if templates/css/ does not exist */ if (!is_writable(__DIR__ . '/../../templates/css/') || !is_writable(__DIR__ . '/../../templates/css/1.css')) { throw new RuntimeException("You must set templates/css/ and any css files inside to be writable by php scripts. Often this means setting permissions to 777."); } $pdo->exec(<<<SQL ALTER TABLE {$pdo->prefix}user DROP COLUMN usernoipcheck SQL ); $pdo->exec(<<<SQL UPDATE {$pdo->prefix}registry SET keydescription = 'Used in eMails & some board features<br>It is vital to set this correctly! ' WHERE keyname = 'board_baseurl' SQL ); $styles = $pdo->query(<<<SQL SELECT styleid FROM {$pdo->prefix}style WHERE styleid != 1 SQL )->fetchAll(PDO::FETCH_COLUMN, 0); foreach ($styles as $styleid) { $this->writestyle($pdo, $v); } $boards = $pdo->query(<<<SQL SELECT boardid FROM {$pdo->prefix}board SQL )->fetchAll(PDO::FETCH_COLUMN, 0); foreach ($boards as $boardid) { $this->updateboard($pdo, $boardid); } $stmt = $pdo->prepare(<<<SQL UPDATE {$pdo->prefix}registry SET keyvalue = :version WHERE keyname = 'version' SQL ); $stmt->bindValue(':version', $this->toVersion, PDO::PARAM_STR); $stmt->execute(); return 0; }
<div id='kiosk_modal' class="modal_dialog hidden block_buttons"> <form> <label for="kiosk_name_field">Name for kiosk:</label> <input type="text" id="kiosk_name_field"/> <input type="submit" data-enhanced="true" value="Assign"/> <input type="button" data-enhanced="true" value="Cancel" onclick='close_modal("#kiosk_modal");'/> </form> </div> <div id='config_classes_modal' class="modal_dialog hidden block_buttons"> <form> <?php require_once 'inc/schema_version.inc'; $stmt = $db->prepare('SELECT classid, class' . ' FROM Classes' . ' WHERE EXISTS(SELECT 1 FROM RegistrationInfo' . ' WHERE RegistrationInfo.classid = Classes.classid)' . ' ORDER BY ' . (schema_version() >= 2 ? 'sortorder, ' : '') . 'class'); $stmt->execute(array()); foreach ($stmt as $row) { echo '<input type="checkbox" name="class-' . $row['classid'] . '"' . ' id="config-class-' . $row['classid'] . '"' . ' data-classid="' . $row['classid'] . '"' . '/>' . "\n"; echo '<label for="config-class-' . $row['classid'] . '">' . htmlspecialchars($row['class'], ENT_QUOTES, 'UTF-8') . '</label>' . "\n"; } ?> <input type="submit" data-enhanced="true" value="Configure Kiosk"/> <input type="button" data-enhanced="true" value="Cancel" onclick='close_modal("#config_classes_modal");'/> </form> </div> </body> </html>
public function upgrade(PDO $pdo) { if ($this->fromVersion != schema_version($pdo)) { throw new RuntimeException(lng('cantexec')); } $pdo->exec(<<<SQL ALTER TABLE {$pdo->prefix}user MODIFY COLUMN userinterests TINYTEXT NOT NULL, ADD COLUMN useractivate TINYINT(1) UNSIGNED NOT NULL DEFAULT 0 AFTER usernodelete SQL ); $pdo->exec(<<<SQL ALTER TABLE {$pdo->prefix}online ADD COLUMN sessionid VARCHAR(32) DEFAULT '' NOT NULL FIRST, ADD INDEX sessionid (sessionid), DROP COLUMN onlineid, ENGINE = Heap SQL ); $pdo->exec(<<<SQL ALTER TABLE {$pdo->prefix}group CHANGE COLUMN accessmask accessmask_old INT(10) UNSIGNED NOT NULL DEFAULT 0, ADD COLUMN accessmask VARCHAR(50) DEFAULT '' NOT NULL SQL ); $pdo->exec(<<<SQL ALTER TABLE {$pdo->prefix}groupboard CHANGE COLUMN accessmask accessmask_old INT(10) UNSIGNED NOT NULL DEFAULT 0, ADD COLUMN accessmask VARCHAR(50) DEFAULT '' NOT NULL SQL ); $pdo->exec(<<<SQL UPDATE {$pdo->prefix}group SET accessmask = RPAD(REVERSE(BIN(accessmask_old)), 22, '0') SQL ); $pdo->exec(<<<SQL UPDATE {$pdo->prefix}groupboard SET accessmask = RPAD(REVERSE(BIN(accessmask_old)), 22, '0') SQL ); $pdo->exec(<<<SQL ALTER TABLE {$pdo->prefix}group DROP COLUMN accessmask_old SQL ); $pdo->exec(<<<SQL ALTER TABLE {$pdo->prefix}groupboard DROP COLUMN accessmask_old SQL ); $pdo->exec(<<<SQL CREATE TABLE {$pdo->prefix}statcache ( stat_id INT(11) UNSIGNED NOT NULL AUTO_INCREMENT, stat_stime INT(11) UNSIGNED NOT NULL DEFAULT 0, stat_etime INT(11) UNSIGNED NOT NULL DEFAULT 0, stat_uid INT(11) UNSIGNED NOT NULL DEFAULT 0, stat_month VARCHAR(64) NOT NULL DEFAULT '', stat_auser INT(11) UNSIGNED NOT NULL DEFAULT 0, stat_nuser INT(11) UNSIGNED NOT NULL DEFAULT 0, stat_nthread INT(11) UNSIGNED NOT NULL DEFAULT 0, stat_npost INT(11) UNSIGNED NOT NULL DEFAULT 0, PRIMARY KEY (stat_id), KEY stat_stime (stat_stime, stat_etime), KEY stat_month (stat_month), KEY stat_uid (stat_uid) ) ENGINE = MyISAM SQL ); $pdo->exec(<<<SQL INSERT INTO {$pdo->prefix}registry VALUES ('session_timeout', '1800', 'integer', 'Session timeout', 'Time for sessions to expire.', 3, 13) SQL ); $posts = $pdo->query(<<<SQL SELECT postid, posttext FROM {$pdo->prefix}post WHERE posttext LIKE '%[QUOTE]%' OR posttext LIKE '%[/QUOTE]%' SQL )->fetchAll(); foreach ($posts as $post) { $post['posttext'] = preg_replace("/\\[(\\/|)QUOTE\\]/", "[\$1quote]", $post['posttext']); $stmt = $pdo->prepare(<<<SQL UPDATE {$pdo->prefix}post SET posttext = :posttext WHERE postid = :postid SQL ); $stmt->bindValue(':posttext', $post['posttext'], PDO::PARAM_STR); $stmt->bindValue(':postid', $post['postid'], PDO::PARAM_INT); $stmt->execute(); } $stmt = $pdo->prepare(<<<SQL UPDATE {$pdo->prefix}registry SET keyvalue = :version WHERE keyname = 'version' SQL ); $stmt->bindValue(':version', $this->toVersion, PDO::PARAM_STR); $stmt->execute(); }
<label for="edit_firstname">First name:</label> <input id="edit_firstname" type="text" name="edit_firstname" value=""/> <label for="edit_lastname">Last name:</label> <input id="edit_lastname" type="text" name="edit_lastname" value=""/> <label for="edit_carno">Car number:</label> <input id="edit_carno" type="text" name="edit_carno" value=""/> <br/> <label for="edit_carname">Car name:</label> <input id="edit_carname" type="text" name="edit_carname" value=""/> <br/> <label for="edit_rank">Racing group:</label> <select id="edit_rank"><?php $sql = 'SELECT rankid, rank, Ranks.classid, class' . ' FROM Ranks INNER JOIN Classes' . ' ON Ranks.classid = Classes.classid' . ' ORDER BY ' . (schema_version() >= 2 ? 'Classes.sortorder, ' : '') . 'class, rank'; $stmt = $db->query($sql); foreach ($stmt as $rs) { echo "\n" . '<option value="' . $rs['rankid'] . '"' . ' data-class="' . htmlspecialchars($rs['class'], ENT_QUOTES, 'UTF-8') . '"' . ' data-rank="' . htmlspecialchars($rs['rank'], ENT_QUOTES, 'UTF-8') . '"' . '>' . htmlspecialchars($rs['class'], ENT_QUOTES, 'UTF-8') . ' / ' . htmlspecialchars($rs['rank'], ENT_QUOTES, 'UTF-8') . '</option>'; } ?> </select> <br/> <label for="eligible">Trophy eligibility:</label> <input type="checkbox" data-role="flipswitch" name="eligible" id="eligible" data-wrapper-class="trophy-eligible-flipswitch" data-off-text="Excluded" data-on-text="Eligible"/> <br/> <input type="submit" data-enhanced="true"/> <input type="button" value="Cancel" data-enhanced="true"