repo
stringlengths
7
63
file_url
stringlengths
81
284
file_path
stringlengths
5
200
content
stringlengths
0
32.8k
language
stringclasses
1 value
license
stringclasses
7 values
commit_sha
stringlengths
40
40
retrieved_at
stringdate
2026-01-04 15:02:33
2026-01-05 05:24:06
truncated
bool
2 classes
jeffpiazza/derbynet
https://github.com/jeffpiazza/derbynet/blob/07b0d7303c2d2563b7adfd8af1cabe389c114bac/website/import-roster.php
website/import-roster.php
<?php @session_start(); require_once('inc/data.inc'); require_once('inc/authorize.inc'); session_write_close(); require_once('inc/partitions.inc'); require_once('inc/plural.inc'); require_permission(SET_UP_PERMISSION); require_once('inc/import-csv.inc'); try { $partitions = all_partitions(); } catch (PDOException $p) { $partitions = []; } class ImportRoster extends ImportCsvGenerator { protected function make_state_of_play_div() { global $partitions; try { $nracers = read_single_value("SELECT COUNT(*) FROM RegistrationInfo", array()); } catch (PDOException $p) { $nracers = -1; } ?> <div id="state-of-play" class="<?php echo $nracers <= 0 ? 'hidden' : ''; ?>"> <div id="file-stats" class="hidden"> <span id="file-name">File</span> contains <span id="file-racer-count">0</span> racers<span id='file-class-count-and-label'>, <a id="class-counts-button" href="#"> <span id="file-class-count"></span> <span id="file-partition-label"><?php echo partition_label_pl_lc(); ?></span> (<span id='file-class-new-count'></span> new)</a></span>. </div> <?php if ($nracers > 0) { $n_partitions = count($partitions); $label = $n_partitions == 1 ? partition_label_lc() : partition_label_pl_lc(); echo "There are already ".$nracers." racer(s) and ".$n_partitions ." <span id='existing-partition-label'>".$label."</span> in the database."; } ?> </div><!--- state-of-play --> <?php } protected function make_relabeling_section() { ?><br/> <label for="supergroup-label">The full roster is a (or the)</label> <input id="supergroup-label" name="supergroup-label" type="text" class="not-mobile" value="<?php echo supergroup_label(); ?>"/>, <br/> <label for="partition-label">and a sub-division is a(n)</label> <input id="partition-label" name="partition-label" type="text" class="not-mobile" value="<?php echo partition_label(); ?>"/>. <?php } } ?><!DOCTYPE html> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/> <title>Import Roster</title> <?php make_head_matter_for_import_page(); ?> <link rel="stylesheet" type="text/css" href="css/import-roster.css"/> <script type="text/javascript" src="js/modal.js"></script> <script type="text/javascript" src="js/plural.js"></script> <script type="text/javascript" src="js/import-roster.js"></script> </head> <script type="text/javascript"> function all_partitions() { return <?php echo json_encode($partitions, JSON_HEX_TAG | JSON_HEX_AMP | JSON_PRETTY_PRINT); ?>; } </script> <body> <?php make_banner('Import Roster', 'setup.php'); $page_maker = new ImportRoster; $page_maker->make_import_csv_div('Import Roster', array( array( 'lastname' => array('name' => "Last Name", 'required' => true), 'firstname' => array('name' => "First Name", 'required' => true), 'partition' => array('name' => partition_label(), 'required' => false), 'carnumber' => array('name' => "Car Number", 'required' => false), 'carname' => array('name' => "Car Name", 'required' => false), 'note_from' => array('name' => 'From', 'required' => false), 'exclude' => array('name' => 'Ineligible for Award?', 'required' => false)), array( 'first-last' => array('name' => 'First & Last Name', 'required' => true, 'span' => 2), 1 => array('span' => 4)), )); ?> <div id="new_partitions_modal" class="modal_dialog block_buttons hidden"> <div id="existing_partitions_div"> </div> <div id="new_partitions_div"> </div> <form> <input type="button" value="Dismiss" onclick='close_modal("#new_partitions_modal");'/> </form> </div> <div class="footer">Or instead: <a href="import-results.php">Import results exported from another race...</a></div> <?php require_once('inc/ajax-pending.inc'); ?> </body> </html>
php
MIT
07b0d7303c2d2563b7adfd8af1cabe389c114bac
2026-01-05T04:46:00.013344Z
false
jeffpiazza/derbynet
https://github.com/jeffpiazza/derbynet/blob/07b0d7303c2d2563b7adfd8af1cabe389c114bac/website/import-awards.php
website/import-awards.php
<?php @session_start(); require_once('inc/data.inc'); require_once('inc/authorize.inc'); session_write_close(); require_once('inc/partitions.inc'); require_permission(SET_UP_PERMISSION); require_once('inc/import-csv.inc'); class ImportAwards extends ImportCsvGenerator { protected function make_state_of_play_div() { try { $nawards = read_single_value("SELECT COUNT(*) FROM Awards", array()); } catch (PDOException $p) { $nawards = -1; } try { $ncategories = read_single_value("SELECT DISTINCT(awardtypeid) FROM Awards", array()); } catch (PDOException $p) { $ncategories = -1; } ?> <div id="state-of-play" class="<?php echo $nawards <= 0 ? 'hidden' : ''; ?>"> <?php if ($nawards > 0) { echo "There are already ".$nawards." awards(s)" .($ncategories > 1 ? " in ".$ncategories." categories" : '') ." in the database."; } ?> </div> <?php } } ?><!DOCTYPE html> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/> <title>Import Awards</title> <?php make_head_matter_for_import_page(); ?> <script type="text/javascript" src="js/import-awards.js"></script> </head> <body> <?php make_banner('Import Awards', 'setup.php'); $page_maker = new ImportAwards; $page_maker->make_import_csv_div('Import Awards', array( 'awardname' => array('name' => "Award Name", 'required' => true), 'awardtype' => array('name' => "Award Type", 'required' => true), 'classname' => array('name' => group_label(), 'required' => false), 'subgroup' => array('name' => subgroup_label(), 'required' => false), 'carnumber' => array('name' => "Winning Car Number", 'required' => false))); require_once('inc/ajax-pending.inc'); ?> </body> </html>
php
MIT
07b0d7303c2d2563b7adfd8af1cabe389c114bac
2026-01-05T04:46:00.013344Z
false
jeffpiazza/derbynet
https://github.com/jeffpiazza/derbynet/blob/07b0d7303c2d2563b7adfd8af1cabe389c114bac/website/export.php
website/export.php
<?php @session_start(); require_once('inc/banner.inc'); require_once('inc/data.inc'); require_once('inc/authorize.inc'); session_write_close(); require_once('inc/name-mangler.inc'); require_once('inc/awards.inc'); require_once('inc/export-all.inc'); require_permission(VIEW_RACE_RESULTS_PERMISSION); $workbook = export_all(); ?> <!DOCTYPE html> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/> <title>Export Results</title> <?php require('inc/stylesheet.inc'); ?> <script type="text/javascript" src="js/jquery.js"></script> <script type="text/javascript" src="js/jquery.ui.touch-punch.min.js"></script> <script type="text/javascript" src="js/dashboard-ajax.js"></script> <script type="text/javascript" src="js/xlsx.full.min.js"></script> <script type="text/javascript" src="js/modal.js"></script> <script type="text/javascript" src="js/plural.js"></script> <script type="text/javascript"> var workbook; $(function() { console.log('On page load'); workbook = XLSX.utils.book_new(); var wb_json = workbook_json(); for (var sh in wb_json) { var rec = wb_json[sh]; // { title, sheet } console.log("Building sheet " + rec[0]); XLSX.utils.book_append_sheet(workbook, XLSX.utils.aoa_to_sheet(rec[1]), rec[0]); } }); function write_workbook(extension) { XLSX.writeFile(workbook, 'derbynet-<?php echo date('Y-m-d'); ?>.' + extension); } function write_sheet_csv(sheet) { XLSX.writeFile(workbook, 'derbynet-' + sheet + '-<?php echo date('Y-m-d'); ?>.csv', {type: 'csv', sheet: sheet}); } </script> <script type="text/javascript"> function workbook_json() { // START_JSON return <?php // Tests depend on the export JSON being on one line, so don't use JSON_PRETTY_PRINT echo json_encode($workbook, JSON_HEX_QUOT | JSON_HEX_TAG | JSON_HEX_AMP | JSON_NUMERIC_CHECK); ?>; // END_JSON } </script> </head> <body> <?php make_banner('Export Results'); ?> <div class="block_buttons" style="margin-top: 20px;"> <input type="button" value="Everything As .xlsx" onclick="write_workbook('xlsx');"/> <input type="button" value="Everything As .ods" onclick="write_workbook('ods');"/> <input type="button" value="Everything As .xls" onclick="write_workbook('xls');"/> <div>&nbsp;</div> <input type="button" value="Roster As .csv" onclick="write_sheet_csv('Roster');"/> <input type="button" value="Results As .csv" onclick="write_sheet_csv('Results');"/> <input type="button" value="Standings As .csv" onclick="write_sheet_csv('Standings');"/> <input type="button" value="Awards As .csv" onclick="write_sheet_csv('Awards');"/> </div> </body> </html>
php
MIT
07b0d7303c2d2563b7adfd8af1cabe389c114bac
2026-01-05T04:46:00.013344Z
false
jeffpiazza/derbynet
https://github.com/jeffpiazza/derbynet/blob/07b0d7303c2d2563b7adfd8af1cabe389c114bac/website/kiosk-dashboard.php
website/kiosk-dashboard.php
<?php session_start(); ?> <?php require_once('inc/data.inc'); require_once('inc/authorize.inc'); session_write_close(); require_once('inc/banner.inc'); require_once('inc/path-info.inc'); require_once('inc/scenes.inc'); require_once('inc/schema_version.inc'); require_once('inc/standings.inc'); require_once('inc/locked.inc'); require_permission(PRESENT_AWARDS_PERMISSION); $urls = preferred_urls(); ?><!DOCTYPE html> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/> <title>Kiosks</title> <link rel="stylesheet" type="text/css" href="css/jquery-ui.min.css"/> <?php require('inc/stylesheet.inc'); ?> <link rel="stylesheet" type="text/css" href="css/mobile.css"/> <script type="text/javascript" src="js/jquery.js"></script> <script type="text/javascript" src="js/ajax-setup.js"></script> <script type="text/javascript" src="js/jquery-ui.min.js"></script> <link rel="stylesheet" type="text/css" href="css/kiosk-dashboard.css"/> <script type="text/javascript" src="js/mobile.js"></script> <script type="text/javascript" src="js/dashboard-ajax.js"></script> <script type="text/javascript" src="js/modal.js"></script> <script type="text/javascript" src="js/kiosk-parameters.js"></script> <script type="text/javascript" src="js/kiosk-dashboard.js"></script> <script type="text/javascript"> var g_all_scenes = <?php echo json_encode(all_scenes(), JSON_HEX_TAG | JSON_HEX_AMP | JSON_PRETTY_PRINT); ?>; var g_current_scene = <?php echo json_encode(read_raceinfo('current_scene', ''), JSON_HEX_TAG | JSON_HEX_AMP); ?>; var g_all_scene_kiosk_names = <?php echo json_encode(all_scene_kiosk_names(), JSON_HEX_TAG | JSON_HEX_AMP); ?>; var g_url = <?php echo json_encode($urls[0], JSON_HEX_TAG | JSON_HEX_AMP | JSON_PRETTY_PRINT); ?>; <?php $standings = new StandingsOracle(); ?> var g_standings_choices = <?php $choices = array_map(function($entry) { return array('name' => $entry['name'], 'value' => array('key' => $entry['key'])); }, $standings->standings_catalog()); echo json_encode($choices, JSON_HEX_TAG | JSON_HEX_AMP); ?>; </script> </head> <body> <?php make_banner('Kiosks'); ?> <div class="block_buttons" style="float: right; width: 300px;"> <a class="button_link" href="scenes.php">Scene Editor</a> </div> <div id="scenes-control"> <label for="scenes-select">Current scene:</label> <div id="select-wrap"> <select id="scenes-select"></select> </div> <div id="scenes-status-message"></div> </div> <div id="kiosk_control_group" class="kiosk_control_group"> </div> <div class="block_buttons" style="width: 300px;"> <input id="new_kiosk_window_button" type="button" value="New Kiosk Window"/> </div> <?php require_once('inc/ajax-failure.inc'); ?> <div id='kiosk_modal' class="modal_dialog hidden block_buttons"> <form> <label for="kiosk_name_field">Name for kiosk:</label> <div id="preferred_kiosk_names"></div> <input type="text" id="kiosk_name_field"/> <input type="submit" value="Assign"/> <input type="button" value="Cancel" onclick='close_modal("#kiosk_modal");'/> </form> </div> <?php require('inc/kiosk-parameters.inc'); ?> </body> </html>
php
MIT
07b0d7303c2d2563b7adfd8af1cabe389c114bac
2026-01-05T04:46:00.013344Z
false
jeffpiazza/derbynet
https://github.com/jeffpiazza/derbynet/blob/07b0d7303c2d2563b7adfd8af1cabe389c114bac/website/awards-presentation.php
website/awards-presentation.php
<?php @session_start(); // Controls the "current award" kiosk display require_once('inc/data.inc'); require_once('inc/authorize.inc'); session_write_close(); require_once('inc/partitions.inc'); require_once('inc/classes.inc'); require_once('inc/banner.inc'); require_once('inc/schema_version.inc'); require_once('inc/standings.inc'); require_once('inc/ordinals.inc'); require_once('inc/name-mangler.inc'); require_once('inc/awards.inc'); require_once('inc/aggregate_round.inc'); require_permission(PRESENT_AWARDS_PERMISSION); $name_style = read_name_style(); ?><!DOCTYPE html> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/> <link rel="stylesheet" type="text/css" href="css/jquery-ui.min.css"/> <title>Awards Presentation Dashboard</title><?php require('inc/stylesheet.inc'); ?> <script type="text/javascript" src="js/jquery.js"></script> <script type="text/javascript" src="js/ajax-setup.js"></script> <script type="text/javascript" src="js/jquery-ui.min.js"></script> <script type="text/javascript" src="js/dashboard-ajax.js"></script> <script type="text/javascript" src="js/mobile.js"></script> <script type="text/javascript" src="js/awards-presentation.js"></script> <?php try { $nkiosks = read_single_value('SELECT COUNT(*) FROM Kiosks' .' WHERE page LIKE \'%award%present%\'', array()); } catch (PDOException $p) { if (is_no_such_table_exception($p)) { create_kiosk_table(); } $nkiosks = 0; } if ($nkiosks == 0) { echo '<script type="text/javascript">'."\n"; echo '$(window).load(function() {'."\n"; echo ' setTimeout(function() {'."\n"; echo ' alert("NOTE: There are NO kiosks ready for award presentation."+'."\n"; echo ' " Selections on this dashboard won\'t have any observable effect.");'."\n"; echo '}, 500); });'."\n"; echo '</script>'."\n"; } ?> <link rel="stylesheet" type="text/css" href="css/mobile.css"/> <link rel="stylesheet" type="text/css" href="css/awards-presentation.css"/> </head> <body> <?php make_banner('Awards Presentation'); $use_subgroups = use_subgroups(); list($classes, $classseq, $ranks, $rankseq) = classes_and_ranks(); $agg_classes = aggregate_classes(); $pack_aggregate_id = read_raceinfo('full-field-calc', 0); $pack_trophies = read_raceinfo('n-pack-trophies', 3); list($awards, $supergroup_awards, $awards_per_class, $awards_per_rank) = compute_awards_for_presentation(); ?> <div class="block_buttons"> <?php if ($pack_trophies > 0 && count($agg_classes) > 0) { ?> <div id="pack_agg_div" class="pack-awards"> <?php echo supergroup_label(); ?> standings:<br/> <input id="pack-ok" type="radio" name="pack-agg" class="not-mobile" value="0" onchange="on_pack_agg_change()" <?php echo $pack_aggregate_id == 0 ? "checked" : ""; ?> /> <label for="pack-ok">Calculate normally</label> <?php foreach ($agg_classes as $agg) { echo "<br/>"; echo "<input id=\"pack-$agg[classid]\" type=\"radio\"" ." name=\"pack-agg\" class=\"not-mobile\" value=\"$agg[classid]\"" ." onchange=\"on_pack_agg_change()\"" ." ".($pack_aggregate_id == $agg['classid'] ? "checked" : "") ."/> "; echo "<label for=\"pack-$agg[classid]\">Use <span class=\"group-name\">$agg[class]</span> group</label>"; } ?> </div> <?php } /* agg_classes for pack awards */ ?> <div class="center-select"> <select id="awardtype-select"> <option selected="Selected">All Awards</option> <?php foreach ($db->query('SELECT awardtypeid, awardtype FROM AwardTypes ORDER BY awardtype') as $atype) { echo '<option data-awardtypeid="'.$atype['awardtypeid'].'">' .htmlspecialchars($atype['awardtype'], ENT_QUOTES, 'UTF-8') .'</option>'."\n"; } ?> </select> </div> <div class="center-select"> <select id="group-select"> <option selected="Selected">All</option> <?php if ($supergroup_awards != 0) { echo "<option data-supergroup=\"1\">".supergroup_label()."</option>\n"; } $rankseq_index = 0; foreach ($classseq as $classid) { $cl = $classes[$classid]; if (@$awards_per_class[$classid] > 0) { echo '<option data-classid="'.$classid.'">' .htmlspecialchars($cl['class'], ENT_QUOTES, 'UTF-8') .'</option>'."\n"; } if ($use_subgroups) { for (; $rankseq_index < count($rankseq); ++$rankseq_index) { $rank = $ranks[$rankseq[$rankseq_index]]; if ($rank['classid'] != $classid) { break; } if (@$awards_per_rank[$rank['rankid']] > 0) { echo '<option data-rankid="'.$rank['rankid'].'">' .'&nbsp;&nbsp;' .htmlspecialchars($rank['rank'], ENT_QUOTES, 'UTF-8') .'</option>'."\n"; } } } } ?> </select> </div> <div class="listview"> <ul class="mlistview"> <?php foreach ($awards as &$row) { $classid = isset($row['classid']) ? $row['classid'] : 0; $rankid = (isset($row['rankid']) && $use_subgroups) ? $row['rankid'] : 0; echo '<li class="icon-right button '.($row['awardtypeid'] == AD_HOC_AWARDTYPEID ? ' adhoc' : '').'"' .' onclick="on_choose_award(this);"' .' data-awardkey="'.$row['awardkey'].'"' .' data-awardtypeid="'.$row['awardtypeid'].'"' .' data-classid="'.$classid.'"' // 0 except for class-level award .' data-rankid="'.$rankid.'"' // 0 except for rank-level award .' data-awardname="'.htmlspecialchars($row['awardname'], ENT_QUOTES, 'UTF-8').'"' .' data-recipient="'.htmlspecialchars(mangled_name($row, $name_style), ENT_QUOTES, 'UTF-8').'"' .' data-carnumber="'.$row['carnumber'].'"' .' data-carname="'.htmlspecialchars($row['carname'], ENT_QUOTES, 'UTF-8').'"' .($classid == 0 ? '' : ' data-class="'.htmlspecialchars($classes[$classid]['class'], ENT_QUOTES, 'UTF-8').'"') .($rankid == 0 ? '' : ' data-rank="'.htmlspecialchars($ranks[$rankid]['rank'], ENT_QUOTES, 'UTF-8').'"') .'>'; echo '<span>'.htmlspecialchars($row['awardname'], ENT_QUOTES, 'UTF-8').'</span>'; echo '<p><strong>'.$row['carnumber'].':</strong> '; echo htmlspecialchars(mangled_name($row, $name_style), ENT_QUOTES, 'UTF-8'); echo '</p>'; echo '</li>'; } ?> </ul> </div> <div class="presenter"> <div id="kiosk-summary"> <?php // TODO Kiosks table may not exist $nkiosks = read_single_value('SELECT COUNT(*) FROM Kiosks' .' WHERE page LIKE \'%award%present%\'', array()); if ($nkiosks == 0) { echo '<h3>NOTE:</h3>'; echo '<h3>There are NO kiosks ready for award presentation.</h3>'; echo '<p class="moot">Selections on this dashboard won\'t have any observable effect.</p>'; echo '<p class="moot">Visit the <a href="kiosk-dashboard.php">Kiosk Dashboard</a> to assign displays.</p>'; } ?> </div> <h3 id="awardname"></h3> <h3 id="classname"></h3> <h3 id="rankname"></h3> <h3 id="recipient"></h3> <p id="carnumber" class="detail"></p> <p id="carname" class="detail"></p> <div class="presenter-inner hidden"> <input type="checkbox" class="flipswitch" id="reveal-checkbox" data-on-text="Showing" data-off-text="Hidden" onchange="on_reveal();"/> </div> <div class="block_buttons"> <input type="button" value="Clear" onclick="on_clear_awards()"/> </div> <?php if (false) { echo "<div>\n"; echo "<pre>\n"; //echo json_encode($awards, JSON_PRETTY_PRINT); $oracle = new StandingsOracle(); echo json_encode($oracle->debug_summary(), JSON_PRETTY_PRINT); // echo json_encode($oracle->award_ladder_subgroup($r), JSON_PRETTY_PRINT); echo "</pre>\n"; echo "</div>\n"; } ?> </div> </div> </body> </html>
php
MIT
07b0d7303c2d2563b7adfd8af1cabe389c114bac
2026-01-05T04:46:00.013344Z
false
jeffpiazza/derbynet
https://github.com/jeffpiazza/derbynet/blob/07b0d7303c2d2563b7adfd8af1cabe389c114bac/website/image.php
website/image.php
<?php session_start(); // E.g., .../image.php/emblem // The path_info ("/emblem") provides the image stem name, without any extension. require_once('inc/data.inc'); session_write_close(); require_once('inc/path-info.inc'); require_once('inc/photo-config.inc'); $exploded = explode('/', path_info()); if (count($exploded) == 2) { $file_path = image_file_path($exploded[1]); } else { // Don't want this to be a vector for traversing around the server file system exit(1); } if (is_readable($file_path)) { // Cache renewal required every 2 minutes (120 seconds), to get most of the // benefit of caching while allowing changing image sets in a "reasonable" // amount of time. header('Cache-Control: max-age=120, public'); header('Expires: '.gmdate('D, d M Y H:i:s', time() + 120).' GMT'); header('Content-type: '.pseudo_mime_content_type($file_path)); readfile($file_path); } else { header('File-path: '.$file_path); header('file_exists: '.file_exists($file_path)); header('file: '.filesize($file_path)); echo "Can't read file."; } ?>
php
MIT
07b0d7303c2d2563b7adfd8af1cabe389c114bac
2026-01-05T04:46:00.013344Z
false
jeffpiazza/derbynet
https://github.com/jeffpiazza/derbynet/blob/07b0d7303c2d2563b7adfd8af1cabe389c114bac/website/slideshow.php
website/slideshow.php
<!DOCTYPE html> <html> <?php require_once('inc/banner.inc'); require_once('inc/photo-config.inc'); ?><head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/> <title>DerbyNet Slideshow</title> <script type="text/javascript" src="js/jquery.js"></script> <?php if (isset($as_kiosk)) require_once('inc/kiosk-poller.inc'); ?> <?php require('inc/stylesheet.inc'); ?> <link rel="stylesheet" type="text/css" href="css/kiosks.css"/> <link rel="stylesheet" type="text/css" href="css/slideshow.css"/> <script type="text/javascript"> var g_kiosk_parameters = <?php echo isset($as_kiosk) ? json_encode(kiosk_parameters()) : "{}"; ?>; </script> <script type="text/javascript" src="js/slideshow.js"></script> </head> <body> <?php if (!isset($as_kiosk)) make_banner('Slideshow'); ?> <div id="photo-background" class="photo-background"> <div class="next"> <img class='mainphoto' onload='mainphoto_onload(this)' src='slide.php/title'/> </div> </div> <?php if (isset($as_kiosk)) require('inc/ajax-failure.inc'); ?> </body> </html>
php
MIT
07b0d7303c2d2563b7adfd8af1cabe389c114bac
2026-01-05T04:46:00.013344Z
false
jeffpiazza/derbynet
https://github.com/jeffpiazza/derbynet/blob/07b0d7303c2d2563b7adfd8af1cabe389c114bac/website/awards-editor.php
website/awards-editor.php
<?php @session_start(); // Add, edit, reorder, and assign awards require_once('inc/data.inc'); require_once('inc/authorize.inc'); session_write_close(); require_once('inc/partitions.inc'); require_once('inc/classes.inc'); require_once('inc/banner.inc'); require_once('inc/schema_version.inc'); require_once('inc/photo-config.inc'); require_permission(EDIT_AWARDS_PERMISSION); ?><!DOCTYPE html> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/> <title>Awards Editor</title> <?php require('inc/stylesheet.inc'); ?> <script type="text/javascript" src="js/jquery.js"></script> <script type="text/javascript" src="js/jquery-ui.min.js"></script> <script type="text/javascript" src="js/ajax-setup.js"></script> <script type="text/javascript" src="js/jquery.ui.touch-punch.min.js"></script> <script type="text/javascript" src="js/dashboard-ajax.js"></script> <script type="text/javascript" src="js/mobile.js"></script> <script type="text/javascript" src="js/modal.js"></script> <script type="text/javascript" src="js/awards-editor.js"></script> <link rel="stylesheet" type="text/css" href="css/mobile.css"/> <link rel="stylesheet" type="text/css" href="css/awards-editor.css"/> </head> <body> <?php make_banner('Awards Editor'); $use_subgroups = use_subgroups(); require_once('inc/awards.inc'); maybe_populate_award_types(); list($classes, $classseq, $ranks, $rankseq) = classes_and_ranks(); ?> <div class="instructions-wrapper" style="position: relative;"> <div class="left"> <p class="instructions">Drag awards to re-order.</p> </div> <div class="center-button-up block_buttons"> <input type="button" value="New Award" onclick="handle_new_award();"/> </div> </div> <div class="block_buttons"> <div class="listview"> <ul id="all_awards" class="mlistview has-alts"> <?php // The list of awards gets generated by javascript code when the page loads, // and then periodically updated as necessary. ?> </ul> </div><!-- listview --> </div><!-- block_buttons --> <div id="award_editor_modal" class="modal_dialog hidden block_buttons"> <form id="award_editor_form"> <input type="hidden" name="action" value="award.edit"/> <input type="hidden" name="awardid" value=""/> <label for="name">Award Name:</label> <input name="name" type="text"/> <label for="awardtype-select">Award Category:</label> <select name="awardtypeid" id="awardtype-select"> <?php foreach ($db->query('SELECT awardtypeid, awardtype FROM AwardTypes ORDER BY awardtype') as $atype) { if ($atype['awardtypeid'] != AD_HOC_AWARDTYPEID) { echo '<option value="'.$atype['awardtypeid'].'">' .htmlspecialchars($atype['awardtype'], ENT_QUOTES, 'UTF-8') .'</option>'."\n"; } } ?> </select> <select name="class_and_rank"> <option selected="selected" value="0,0"><?php echo supergroup_label(); ?></option> <?php $rankseq_index = 0; foreach ($classseq as $classid) { $cl = $classes[$classid]; echo '<option value="'.$classid.',0">' .htmlspecialchars($cl['class'], ENT_QUOTES, 'UTF-8') .'</option>'."\n"; for (; $rankseq_index < count($rankseq); ++$rankseq_index) { $rank = $ranks[$rankseq[$rankseq_index]]; if ($rank['classid'] != $classid) { break; } if ($use_subgroups) { echo '<option value="'.$classid.','.$rank['rankid'].'">' .htmlspecialchars($rank['rank'], ENT_QUOTES, 'UTF-8') .'</option>'."\n"; } } } ?> </select> <br/> <input type="submit"/> <input type="button" value="Close" onclick="close_modal('#award_editor_modal');"/> <hr/><br/> <input type="button" class="delete_button" value="Delete Award" onclick="handle_delete_award();"/> </form> </div><!-- award_editor_modal --> </body> </html>
php
MIT
07b0d7303c2d2563b7adfd8af1cabe389c114bac
2026-01-05T04:46:00.013344Z
false
jeffpiazza/derbynet
https://github.com/jeffpiazza/derbynet/blob/07b0d7303c2d2563b7adfd8af1cabe389c114bac/website/action.php
website/action.php
<?php @session_start(); ?> <?php // Receive POSTs to perform actions, return XML responses // // <action-response> is document root of reply, constructed from $_POST arguments // // This script will load the database config (i.e., perform a require_once of // inc/data.inc) UNLESS the query or action name ends in ".nodata'. Since // inc/data.inc will force a page redirect if the database cannot be loaded, any // queries or actions that potentially run before a database config file exists // should be in include files that end in ".nodata.inc'. require_once('inc/permissions.inc'); require_once('inc/authorize.inc'); require_once('inc/action-helpers.inc'); $json_out = array(); function json_out($key, $value) { global $json_out; $json_out[$key] = $value; } function json_success() { json_out('outcome', array('summary' => 'success', 'code' => 'success', 'description' => '')); } function json_failure($code, $description) { json_out('outcome', array('summary' => 'failure', 'code' => $code, 'description' => $description)); } function json_sql_failure($sql) { global $db; $info = $db->errorInfo(); json_failure('sql'.$info[0].'-'.$info[1], "$sql failed: $info[2] [EOM]"); } function json_not_authorized() { json_failure('notauthorized', "Not authorized -- please see race coordinator."); } if (empty($_POST) && empty($_GET)) { echo '<!DOCTYPE html><html><head><title>Not a Page</title></head><body><h1>This is not a page.</h1></body></html>'; exit(1); } $is_action = !empty($_POST); $inc = $is_action ? @$_POST['action'] : @$_GET['query']; $in_json = $inc != 'timer-message' && (strpos($inc, 'snapshot') === false) // These are to provide an error message for older derby-timer.jar && $inc != 'login' && $inc != 'roles'; if ($in_json) { header('Content-Type: application/json; charset=utf-8'); } else { header('Content-Type: text/xml; charset=utf-8'); echo "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"; } if (substr($inc, -7) != '.nodata') { require_once('inc/data.inc'); // We can close the session for writing except for these three that might // perform some write to $_SESSION. if (strstr($inc, 'ballot.get') === false && strstr($inc, 'session.write') === false && strstr($inc, 'role.login') === false) { session_write_close(); } } if ($is_action) { $args = array(); foreach ($_POST as $attr => $val) { $args[$attr] = $attr == 'password' ? '...' : $val; } json_out('action', $args); json_out('outcome', array('summary' => 'in-progress', 'code' => 'in-progress', 'description' => 'No outcome defined.')); if (isset($db) && !($args['action'] == 'timer-message' && $args['message'] == 'HEARTBEAT') && array_search($args['action'], array('role.login', 'vote.cast', 'replay-message')) === false) { record_action($args); } } $prefix = $is_action ? 'action' : 'query'; if (!@include 'ajax/'.$prefix.'.'.$inc.'.inc') { if ($in_json) { json_failure('unrecognized', "Unrecognized $prefix: $inc"); } else { start_response(); echo '<failure code="unrecognized">Unrecognized '.$prefix.': '.$inc.'</failure>'; end_response(); } } if ($in_json) { if (empty($json_out)) { $json_out = new stdClass(); } echo json_encode($json_out, JSON_PRETTY_PRINT | JSON_NUMERIC_CHECK); echo "\n"; } ?>
php
MIT
07b0d7303c2d2563b7adfd8af1cabe389c114bac
2026-01-05T04:46:00.013344Z
false
jeffpiazza/derbynet
https://github.com/jeffpiazza/derbynet/blob/07b0d7303c2d2563b7adfd8af1cabe389c114bac/website/preferences.php
website/preferences.php
<?php @session_start(); // In contrast to query.snapshot.get.inc, this download link stands on its own // in order to have full control over the Content-Type headers, without // interference from action.php. require_once('inc/preferences.inc'); session_write_close(); header('Content-Type: text/plain'); // header('Content-Disposition: attachment; '.$this->_httpencode('filename',$name,$isUTF8)); header('Cache-Control: private, max-age=0, must-revalidate'); header('Pragma: public'); echo dump_preferences(); ?>
php
MIT
07b0d7303c2d2563b7adfd8af1cabe389c114bac
2026-01-05T04:46:00.013344Z
false
jeffpiazza/derbynet
https://github.com/jeffpiazza/derbynet/blob/07b0d7303c2d2563b7adfd8af1cabe389c114bac/website/print.php
website/print.php
<?php session_start(); require_once('inc/data.inc'); require_once('inc/authorize.inc'); session_write_close(); require_once('inc/partitions.inc'); require_once('inc/banner.inc'); require_once('inc/photo-config.inc'); require_once('print/inc/printable_racer_document.inc'); require_once('print/inc/printable_award_document.inc'); require_once('print/inc/printable_summary_document.inc'); // TODO Printables should really have their own permission, but we need a // migration path for updating existing user config files. require_permission(ASSIGN_RACER_IMAGE_PERMISSION); // $doc_classes keys are document class names, values are { type:, options: } $doc_classes = array(); foreach (get_declared_classes() as $c) { if (is_subclass_of($c, 'PrintableRacerDocument') && !(new ReflectionClass($c))->isAbstract()) { $doc = new $c(); $doc_classes[$c] = array('type' => 'racer', 'order' => 1, 'name' => $doc->name(), 'options' => $doc->get_available_options()); } if (is_subclass_of($c, 'PrintableAwardDocument') && !(new ReflectionClass($c))->isAbstract()) { $doc = new $c(); $doc_classes[$c] = array('type' => 'award', 'order' => 2, 'name' => $doc->name(), 'options' => $doc->get_available_options()); } if (is_subclass_of($c, 'PrintableSummaryDocument') && !(new ReflectionClass($c))->isAbstract()) { $doc = new $c(); $doc_classes[$c] = array('type' => 'summary', 'order' => 3, 'name' => $doc->name(), 'options' => $doc->get_available_options()); } } function order_by_name($left, $right) { if ($left['order'] < $right['order']) { return -1; } else if ($left['order'] > $right['order']) { return 1; } else if ($left['name'] < $right['name']) { return -1; } else if ($left['name'] > $right['name']) { return 1; } else { return 0; } } uasort($doc_classes, 'order_by_name'); ?><!DOCTYPE html> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/> <title>Printables</title> <meta name="viewport" content="width=device-width, initial-scale=1"/> <link rel="stylesheet" type="text/css" href="css/jquery-ui.min.css"/> <?php require('inc/stylesheet.inc'); ?> <link rel="stylesheet" type="text/css" href="css/mobile.css"/> <link rel="stylesheet" type="text/css" href="css/print.css"/> <script type="text/javascript" src="js/jquery.js"></script> <script type="text/javascript" src="js/ajax-setup.js"></script> <script type="text/javascript" src="js/jquery-ui.min.js"></script> <script type="text/javascript" src="js/jquery.ui.touch-punch.min.js"></script> <script type="text/javascript" src="js/mobile.js"></script> <script type="text/javascript" src="js/print.js"></script> <script type="text/javascript"> var doc_classes = <?php echo json_encode($doc_classes); ?>; </script> </head> <body> <?php make_banner('Printables'); ?> <div class="block_buttons"> <input type="button" id="print-selected" value="Print Selected" onclick="print_selected();"/> </div> <div id="document-controls"> <div class='mradiogroup'> <?php $radio_count = 0; $last_type = ''; foreach ($doc_classes as $c => $details) { ++$radio_count; if ($radio_count > 0 && $details['type'] != $last_type) { echo "<div class='radio-spacer'>&nbsp;</div>\n"; } $last_type = $details['type']; echo "<label for='doc-class-".$c."'>"; echo "<b>".$details['name']."</b>"; echo "</label>\n"; echo "<input type='radio' name='doc-class' id='doc-class-".$c."'"; if ($radio_count == 1) { echo " checked='checked'"; } echo " value='".$c."'/>"; } ?> </div> <!-- mradiogroup --> </div> <div id="page-controls"> <div class="block_buttons"> <div id="sortorder-racers-div"> <p id="sortorder-paragraph"> <label for="sortorder-racers">Choose sort order:</label> <select id="sortorder-racers" onchange="handle_sortorder_racers_change()"> <option value="checkin">Check-In Order</option> <option value="name">Last Name</option> <option value="class"><?php echo htmlspecialchars(group_label(), ENT_QUOTES, 'UTF-8'); ?></option> <?php if (use_subgroups()) { echo "<option value='rank'>".htmlspecialchars(subgroup_label(), ENT_QUOTES, 'UTF-8')."</option>"; } ?> <option value="car" selected="selected">Car Number</option> </select> </p> </div> <div id="sortorder-awards-div"> </div> <div id="sortorder-summary-div"> </div> <input type="button" value="Select All" onclick="select_all(true)"/> <input type="button" value="Deselect All" onclick="select_all(false)"/> </div> <div id="walkins-div" class="hidden"> Add <input id="walkins-count" type="number" class="not-mobile" value="0"/> extras <input id='walkins-by-partition' type='checkbox' class='flipswitch' checked='checked' data-on-text="Per <?php echo group_label();?>" data-off-text="Overall"/> </div> <?php // Options for each document type are in a div[data-docname='...'], and so can // be switched on and off depending on which document type is chosen. $doc_index = 0; // To distinguish radio options, if needed foreach ($doc_classes as $c => $details) { ++$doc_index; echo "<div data-docname=\"".$c."\" class=\"sub-options hidden\">"; echo "<p>Options for <b>".$details['name']."</b></p>"; foreach ($details['options'] as $opt => $opt_data) { $ctrl_name = $c.'-'.$opt; echo "<div class='param'>\n"; if ($opt_data['type'] == 'bool') { echo "<input type='checkbox' name='".$ctrl_name."'"; if ($opt_data['default']) { echo " checked='checked'"; } echo "/><label for='".$ctrl_name."'>".$opt_data['desc']."</label><br/>\n"; } else if ($opt_data['type'] == 'int') { echo "<input type='number' name='".$ctrl_name."' value='".$opt_data['default']."'/>"; echo "<label for='".$ctrl_name."'>".$opt_data['desc']."</label><br/>\n"; } else if ($opt_data['type'] == 'string') { echo "<label for='".$ctrl_name."'>".$opt_data['desc']."</label>"; echo "<input type='text' name='".$ctrl_name."' value='".$opt_data['default']."' class='param-string'/><br/>\n"; } else if ($opt_data['type'] == 'radio') { // values: $first_radio = true; echo "<div class='mradiogroup'>\n"; foreach ($opt_data['values'] as $v) { // {value:, desc:} echo "<input type='radio' id=\"opt-$doc_index-$opt-$v[value]\"" .($first_radio ? " checked=\"checked\"" : "") ." name=\"$ctrl_name\" value=\"$v[value]\"/>\n"; echo "<label for=\"opt-$doc_index-$opt-$v[value]\">$v[desc]</label>\n"; $first_radio = false; } echo "</div>\n"; } echo "</div>\n"; } echo "</div>\n"; } ?> </div> <div id="subjects-context"> <div id="subjects-scroll"> <div id="subject-racers" class="block_buttons"> <?php if (read_raceinfo_boolean('fake-racers')) { echo "<h3 style='text-align: center; color: red;'>Photos for fake racers<br/>do not render in printables</h3>\n"; } ?> <table></table> </div> <div id="subject-awards" class="block_buttons hidden"> <table></table> </div> <div id="subject-summary" class="block_buttons hidden"> <table></table> </div> </div> &nbsp; </div> </body> </html>
php
MIT
07b0d7303c2d2563b7adfd8af1cabe389c114bac
2026-01-05T04:46:00.013344Z
false
jeffpiazza/derbynet
https://github.com/jeffpiazza/derbynet/blob/07b0d7303c2d2563b7adfd8af1cabe389c114bac/website/playlist.php
website/playlist.php
<?php @session_start(); // $_GET['back'] if "Back" button should go to another page, otherwise coordinator.php. require_once('inc/data.inc'); require_once('inc/authorize.inc'); session_write_close(); require_once('inc/partitions.inc'); require_once('inc/banner.inc'); require_once('inc/schema_version.inc'); require_once('inc/kiosks.inc'); require_once('inc/scenes.inc'); require_once('inc/classes.inc'); require_once('inc/playlist.inc'); require_once('inc/rounds.inc'); require_permission(SET_UP_PERMISSION); list($classes, $classeq, $ranks, $rankseq) = classes_and_ranks(); $all_scenes = array(); foreach (all_scenes() as $sc) { $all_scenes[$sc['sceneid']] = $sc; } $use_groups = use_groups(); $all_rounds_by_class = array(); foreach (all_rounds_with_counts() as $round) { if (!isset($all_rounds_by_class[$round['classid']])) { $all_rounds_by_class[$round['classid']] = array(); } $all_rounds_by_class[$round['classid']][] = $round; } ?><!DOCTYPE html> <html> <head> <title>Rounds Playlist</title> <?php require('inc/stylesheet.inc'); ?> <link rel="stylesheet" type="text/css" href="css/jquery-ui.min.css"/> <link rel="stylesheet" type="text/css" href="css/mobile.css"/> <link rel="stylesheet" type="text/css" href="css/playlist.css"/> <script type="text/javascript" src="js/jquery.js"></script> <script type="text/javascript" src="js/jquery-ui.min.js"></script> <script type="text/javascript" src="js/jquery.ui.touch-punch.min.js"></script> <script type="text/javascript" src="js/mobile.js"></script> <script type='text/javascript' src="js/modal.js"></script> <script type='text/javascript'> var g_use_subgroups = <?php echo use_subgroups() ? "true" : "false"; ?>; var g_group_label = <?php echo json_encode(group_label(), JSON_HEX_TAG | JSON_HEX_AMP); ?>; var g_subgroup_label = <?php echo json_encode(subgroup_label(), JSON_HEX_TAG | JSON_HEX_AMP); ?>; var g_all_scenes = <?php echo json_encode(all_scenes(), JSON_HEX_TAG | JSON_HEX_AMP | JSON_PRETTY_PRINT | JSON_NUMERIC_CHECK); ?>; var g_current_racing_scene = <?php echo json_encode(read_raceinfo('racing_scene', ''), JSON_HEX_TAG | JSON_HEX_AMP | JSON_NUMERIC_CHECK); ?>; var g_current_round = <?php echo json_encode(get_running_round(), JSON_HEX_TAG | JSON_HEX_AMP | JSON_PRETTY_PRINT | JSON_NUMERIC_CHECK); ?>; var g_all_rounds = <?php echo json_encode($all_rounds_by_class, JSON_HEX_TAG | JSON_HEX_AMP | JSON_PRETTY_PRINT | JSON_NUMERIC_CHECK); ?>; var g_queue = <?php $stmt = $db->query('SELECT queueid, seq, Playlist.classid, Playlist.round,' .' bucket_limit, bucketed, n_times_per_lane,' .' sceneid_at_finish, continue_racing,' .' Classes.classid, class, round,' .($use_groups ? "class || ', ' || " : "") .'\'Round \' || round AS roundname' .' FROM '.inner_join('Playlist', 'Classes', 'Playlist.classid = Classes.classid') .' ORDER BY seq'); echo json_encode($stmt->fetchAll(PDO::FETCH_ASSOC), JSON_HEX_TAG | JSON_HEX_AMP | JSON_PRETTY_PRINT | JSON_NUMERIC_CHECK); ?>; var g_classes = <?php echo json_encode($classes, JSON_HEX_TAG | JSON_HEX_AMP | JSON_PRETTY_PRINT | JSON_NUMERIC_CHECK); ?>; $(function() { $.each(g_queue, function(i, entry) { append_playlist_entry_li(entry, g_all_scenes); }); maybe_change_playlist_message(); build_rounds(g_queue, g_classes, g_all_rounds); build_after_action_select("#after-action-sel", g_all_scenes); }); </script> <script type="text/javascript" src="js/playlist.js"></script> </head> <body> <?php make_banner('Rounds Playlist', isset($_GET['back']) ? $_GET['back'] : 'coordinator.php'); ?> <div id="main"> <div id="queue"> <div id="racing-scene-div"> <label for="racing-scene">Racing scene:</label> <select id="racing-scene"> </select> <p id='racing-scene-psa' class='hidden'> It's usually a good idea to set a racing scene if you're using playlists. </p> </div> <p id="top-of-queue"></p> <ul class="mlistview" id="queue-ul"> </ul> </div> <div id="rounds-div"> <p>Available rounds:</p> <ul class="mlistview" id="rounds-ul"> </ul> </div> </div> <div id='add-to-queue-modal' class='modal_dialog block_buttons hidden'> <form> <div id='new-roster-div'> <p>Choose top</p> <input type="number" id="new-roster-top" value="3"/> <div class='no-buckets hidable'> <p>racers</p> </div> <div class='subgroup-buckets hidable'> <p>racers from</p> <div class="centered_flipswitch"> <input type="checkbox" class="flipswitch bucketed-single" id="bucketed_subgroups" data-on-text="Each <?php echo subgroup_label(); ?>" data-off-text="Overall"/> </div> </div> <div class='group-buckets hidable'> <p>racers from</p> <div class="centered_flipswitch"> <input type="checkbox" class="flipswitch bucketed-multi" id="bucketed_groups" data-on-text="Each <?php echo group_label(); ?>" data-off-text="Overall"/> </div> </div> </div> <label for='schedule-reps'>Runs per lane:</label> <select id='schedule-reps'> <option>1</option> <option>2</option> <option>3</option> <option>4</option> <option>5</option> <option>6</option> </select> <label for='after-action-sel'>And then:</label> <select id='after-action-sel'> <!-- Options populated by javascript at the top of this file. --> </select> <input type="submit" value="Submit"/> <input type="button" value="Cancel" onclick='close_modal("#add-to-queue-modal");'/> </form> </div> </body> </html>
php
MIT
07b0d7303c2d2563b7adfd8af1cabe389c114bac
2026-01-05T04:46:00.013344Z
false
jeffpiazza/derbynet
https://github.com/jeffpiazza/derbynet/blob/07b0d7303c2d2563b7adfd8af1cabe389c114bac/website/racer-results.php
website/racer-results.php
<?php @session_start(); require_once('inc/data.inc'); session_write_close(); require_once('inc/banner.inc'); require_once('inc/photo-config.inc'); require_once('inc/name-mangler.inc'); require_once('inc/schema_version.inc'); require_once('inc/running_round_header.inc'); require_once('inc/ordinals.inc'); require_once('inc/rounds.inc'); $use_master_sched = use_master_sched(); $high_water_rounds = high_water_rounds(); $signatures = schedule_signature(); $limit_to_roundid = false; if (isset($as_kiosk)) { $params = kiosk_parameters(); if (isset($params['roundid'])) { $limit_to_roundid = $params['roundid']; } } ?><!DOCTYPE html> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/> <script type="text/javascript" src="js/jquery.js"></script> <script type="text/javascript" src="js/ajax-setup.js"></script> <script type="text/javascript"> var g_as_kiosk = <?php echo isset($as_kiosk) ? "true" : "false"; ?>; var g_limited_to_roundid = <?php echo $limit_to_roundid ? "true" : "false"; ?>; </script> <?php if (isset($as_kiosk)) { require_once('inc/kiosk-poller.inc'); echo "<style type='text/css'>\n"; echo "body { overflow: hidden; }\n"; echo "</style>\n"; } ?> <script type="text/javascript" src="js/common-update.js"></script> <script type="text/javascript" src="js/results-by-racer-update.js"></script> <?php if (isset($as_kiosk)) echo '<script type="text/javascript" src="js/results-by-racer-scrolling.js"></script>'."\n"; ?> <title>Results By Racer <?php if (isset($_GET['racerid']) && is_numeric($_GET['racerid'])) { echo ' for '.$_GET['racerid']; } ?></title> <?php require('inc/stylesheet.inc'); ?> <link rel="stylesheet" type="text/css" href="css/kiosks.css"/> <link rel="stylesheet" type="text/css" href="css/main-table.css"/> <link rel="stylesheet" type="text/css" href="css/racer-results.css"/> </head> <body> <?php make_banner('Results By Racer', isset($as_kiosk) ? '' : 'index.php'); $nlanes = get_lane_count_from_results(); $now_running = get_running_round(); if (!$limit_to_roundid) { running_round_header($now_running, /* Use RoundID */ true); } $show_racer_photos = read_raceinfo_boolean('show-racer-photos-rr'); $show_car_photos = read_raceinfo_boolean('show-car-photos-rr'); $use_points = read_raceinfo_boolean('use-points'); $rounds = all_rounds(); $sql = 'SELECT RegistrationInfo.racerid,' .' Classes.class, round, heat, lane, finishtime, finishplace, resultid,' .' carnumber, firstname, lastname, imagefile, ' .(schema_version() >= 2 ? 'carphoto, ' : '') .' 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' .($limit_to_roundid !== false ? " AND Rounds.roundid = $limit_to_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; } return $result; } function write_rr($racer_label, $roundid, $racer_cells, $nrows) { global $nlanes; global $row; // read and written $rrow = '<tr class="d'.($row & 1).'" data-roundid="'.$roundid.'">' .'<th rowspan="'.$nrows.'" class="nrows'.$nrows.'">'.$racer_label.'</th>'; ++$row; for ($r = 0; $r < $nrows; ++$r) { if ($r > 0) { $rrow .= '</tr><tr class="d'.($row & 1).'">'; ++$row; } foreach ($racer_cells as $cols) { if (count($cols) <= $r) { // This racer didn't race in this lane (in this round) $rrow .= '<td/>'; // '<td>row '.$r.' count '.(count($cols)).'</td>'; // TODO: Bye } else { $rrow .= $cols[$r]; } } } $rrow .= '</tr>'; echo $rrow; } $name_style = read_name_style(); $time_format = get_finishtime_formatting_string(); $rs = $stmt->fetch(PDO::FETCH_ASSOC); foreach ($rounds as $round) { // Generate header and tbody $roundid = $round['roundid']; $classid = $round['classid']; $groupid = $round['groupid']; $is_current = 0; if ($now_running['roundid'] == $roundid and $now_running['classid'] == $classid) $is_current = 1; // For this page, 'groupid' is always roundid, regardless of master scheduling or not. echo '<tbody id="tbody_'.$groupid.'" data-roundid="'.$groupid.'" data-signature="'.$signatures[$groupid].'">'."\n"; echo '<tr><th/><th class="group_spacer wide" colspan="'.$nlanes.'"/></tr>'."\n"; echo '<tr><th class="pre_group_title"/>' .'<th class="group_title wide" colspan="'.$nlanes.'">' .(use_groups() ? htmlspecialchars($round['class'], ENT_QUOTES, 'UTF-8').', ' : '') .'Round '.$round['round'].'</th>' .'</tr>'."\n"; echo '<tr>'; echo '<th>Racer</th>'; for ($l = 1; $l <= $nlanes; ++$l) echo '<th>Lane '.$l.'</th>'; echo '</tr>'."\n"; $row = 1; $racerid = 0; $racer_label = ''; while ($rs and $rs['roundid'] == $roundid) { if ($racerid <> $rs['racerid']) { if ($racer_label) { write_rr($racer_label, $roundid, $racer_cells, $nrows); } $racerid = $rs['racerid']; $racer_label = ''; // 68h images completely fill one row's height if ($rs['imagefile'] && $show_racer_photos) { $head_url = headshots()->url_for_racer($rs, RENDER_RACER_RESULTS); $racer_label .= "<img src=\"$head_url\" class=\"racer-photo\"/>"; } if (isset($rs['carphoto']) && $rs['carphoto'] && $show_car_photos) { $car_url = car_photo_repository()->url_for_racer($rs, RENDER_RACER_RESULTS); $racer_label .= "<img src=\"$car_url\" class=\"racer-photo\"/>"; } $racer_label .= '<div class="racer_label"><span class="racer">' .htmlspecialchars(mangled_name($rs, $name_style), ENT_QUOTES, 'UTF-8').'</span>' .' (<span class="car">'.$rs['carnumber'].'</span>)</div>'; $racer_cells = array(); for ($i = 1; $i <= $nlanes; ++$i) { $racer_cells[] = array(); } //++$row; $lane = 1; $nrows = 1; } $lane = $rs['lane']; $ft = $use_points ? (isset($rs['finishplace']) ? ordinal($rs['finishplace']) : '--') : (isset($rs['finishtime']) ? sprintf($time_format, $rs['finishtime']) : '--'); $racer_cells[$lane - 1][] = '<td class="resultid_'.$rs['resultid'].'">' //.'<a class="heat_link" href="ondeck.php#heat_'.$roundid.'_'.$rs['heat'].'">' .'<span class="time">'.$ft.'</span>' //.'</a>' .'</td>'."\n"; if (count($racer_cells[$lane - 1]) > $nrows) { $nrows = count($racer_cells[$lane - 1]); } ++$lane; $rs = $stmt->fetch(PDO::FETCH_ASSOC); } if ($racer_label) { write_rr($racer_label, $roundid, $racer_cells, $nrows); } echo '</tbody>'."\n"; } $stmt->closeCursor(); ?> </table> </div> <div class="block_buttons"> <?php if (isset($_GET['racerid'])) { echo '<a class="button_link" href="racer-results.php">View All Racers</a>'."\n"; } ?> </div> <?php require_once('inc/ajax-failure.inc'); ?> </body> </html>
php
MIT
07b0d7303c2d2563b7adfd8af1cabe389c114bac
2026-01-05T04:46:00.013344Z
false
jeffpiazza/derbynet
https://github.com/jeffpiazza/derbynet/blob/07b0d7303c2d2563b7adfd8af1cabe389c114bac/website/fake-timer.php
website/fake-timer.php
<?php @session_start(); ?> <?php require_once('inc/data.inc'); require_once('inc/authorize.inc'); session_write_close(); require_once('inc/banner.inc'); require_once('inc/plural.inc'); require_permission(CHECK_IN_RACERS_PERMISSION); ?><!DOCTYPE html> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/> <title>Fake Timer</title> <?php require('inc/stylesheet.inc'); ?> <link rel="stylesheet" type="text/css" href="css/mobile.css"/> <script type="text/javascript" src="js/jquery.js"></script> <script type="text/javascript" src="js/mobile.js"></script> <script type="text/javascript" src="js/fake-timer.js"></script> <style type="text/css"> p.frontmatter { margin-left: auto; margin-right: auto; width: 500px; } #lane-count-div { width: 300px; margin-left: auto; margin-right: auto; } #lane-count-div label { font-size: 20px; line-height: 1.3; } #lane-count { display: block; margin-left: auto; margin-right: auto; font-size: 24px; line-height: 1.3; /* Weirdly, this causes the control to widen considerably in Safari, much more than the text would require. */ font-family: sans-serif; } p#summary { font-size: 36px; text-align: center; width: 500px; margin-left: auto; margin-right: auto; } p#summary .heatno, p#summary .round-class, p#summary .roundno { font-weight: bold; font-size: inherit; } #timer-sim { margin-left: auto; margin-right: auto; } #timer-sim-times { font-size: 48px; } #timer-sim input[type='button'] { width: 150px; } #auto-mode-outer-div { margin-top: 50px; margin-left: auto; margin-right: auto; width: 500px; font-size: normal; } #auto-mode-div { width: 300px; margin-left: auto; margin-right: auto; } </style> </head> <body> <?php make_banner('Fake Timer', false /* no back button */); ?> <p class='frontmatter'>This page simulates the behavior of a timer connected to the DerbyNet server. It's intended to allow you to get a feel for using DerbyNet without having to connect a real timer.</p> <p class='frontmatter'>The fake timer operates <b>only while this page is open</b>, and <b>only when <a href="coordinator.php" target="_blank">"Racing"</a> or <a href="timer.php" target="_blank">"Simulated Racing"</a> is underway.</b></p> <p class='frontmatter'>We <b><i>strongly</i></b> encourage connecting and testing your real timer before the day of your actual race.</p> <div id='lane-count-div'> <label for="lane-count">Number of lanes on the track:</label> <input id="lane-count" type="number" class="not-mobile" min="2" max="8" value="<?php echo get_lane_count(); ?>"/> </div> <div class='block_buttons'> <p id="summary">Not racing.</p> <input id='start-button' type='button' value='Start' onclick='start_timer();' disabled='1'/> <table id='timer-sim'> <tr id='timer-sim-headers'> <th>Lane 1</th> <th>Lane 2</th> <th>Lane 3</th> <th>Lane 4</th> </tr> <tr id='timer-sim-times' data-time='0'> <td data-running='1'/> <td data-running='1'/> <td data-running='1'/> <td data-running='1'/> </tr> <tr id='timer-sim-stop-buttons'> <td><input type='button' value='Stop' onclick='stop_timer(this);'/></td> <td><input type='button' value='Stop' onclick='stop_timer(this);'/></td> <td><input type='button' value='Stop' onclick='stop_timer(this);'/></td> <td><input type='button' value='Stop' onclick='stop_timer(this);'/></td> </tr> </table> </div> <div id='auto-mode-outer-div'> <p>"Auto mode" simulates a very efficient race crew that stages and starts each heat within a few seconds after it's set ready from the server.</p> <div id='auto-mode-div'> <label for='auto-mode-checkbox'>Auto Mode: </label> <input id='auto-mode-checkbox' type='checkbox' class='flipswitch'/> </div> </div> </body> </html>
php
MIT
07b0d7303c2d2563b7adfd8af1cabe389c114bac
2026-01-05T04:46:00.013344Z
false
jeffpiazza/derbynet
https://github.com/jeffpiazza/derbynet/blob/07b0d7303c2d2563b7adfd8af1cabe389c114bac/website/ondeck.php
website/ondeck.php
<?php // TODO - Write a photo src template as a data attribute instead of as the src, // then convert to a square photo size based on nlanes // // When presented as a kiosk page, i.e., when this php file is included from // kiosks/ondeck.kiosk, the session_start() function will already have been // called. The @ is necessary to suppress the error notice that may arise in // this case. @session_start(); require_once('inc/data.inc'); require_once('inc/authorize.inc'); session_write_close(); require_once('inc/banner.inc'); require_once('inc/photo-config.inc'); require_once('inc/name-mangler.inc'); require_once('inc/schema_version.inc'); ?><!DOCTYPE html> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/> <script type="text/javascript" src="js/jquery.js"></script> <script type="text/javascript" src="js/ajax-setup.js"></script> <script type="text/javascript" src="js/modal.js"></script> <!-- For measure_text --> <script type="text/javascript" src="js/mobile.js"></script> <script type="text/javascript"> <?php $nlanes = get_lane_count_from_results(); $colors_info = read_raceinfo('lane-colors', ''); $lane_colors = empty($colors_info) ? [] : explode(',', $colors_info); while (count($lane_colors) < $nlanes) { // Including the case of no colors assigned $lane_colors[] = 'none'; } ?> var g_nlanes = <?php echo $nlanes; ?>; var g_lane_colors = <?php echo json_encode($lane_colors); ?>; var g_show_car_photos = <?php echo read_raceinfo_boolean('show-cars-on-deck') ? "true" : "false"; ?>; var g_set_nextheat = true; </script> <script type="text/javascript" src="js/ondeck.js"></script> <?php if (isset($as_kiosk)) { require_once('inc/kiosk-poller.inc'); echo "<style type='text/css'>\n"; echo "body { overflow: hidden; }\n"; echo "</style>\n"; }?> <title>Racers On Deck</title> <?php require('inc/stylesheet.inc'); ?> <link rel="stylesheet" type="text/css" href="css/kiosks.css"/> <link rel="stylesheet" type="text/css" href="css/main-table.css"/> <link rel="stylesheet" type="text/css" href="css/lane-colors.css"/> <link rel="stylesheet" type="text/css" href="css/ondeck.css"/> </head> <body> <?php make_banner('Racers On Deck', isset($as_kiosk) ? '' : 'index.php'); ?> <table id="schedule" class="main_table curgroup"> </table> <?php require_once('inc/ajax-failure.inc'); ?> <div id='photo_view_modal' class="modal_dialog hidden block_buttons"> <img id='photo_view_img'/> <br/> <input type="button" value="Close" onclick='close_modal("#photo_view_modal");'/> </div> </body> </html>
php
MIT
07b0d7303c2d2563b7adfd8af1cabe389c114bac
2026-01-05T04:46:00.013344Z
false
jeffpiazza/derbynet
https://github.com/jeffpiazza/derbynet/blob/07b0d7303c2d2563b7adfd8af1cabe389c114bac/website/standings.php
website/standings.php
<?php session_start(); // This page contains a table of all the "standings" entries, as produced by the // result_summary() function. There's a control at the top that lets the user // choose to view standings by individual rounds, or for the final standings of // the pack. // // If rounds are present for a single aggregate class, the "All" settings is // exactly equivalent to viewing the results for the last round of the aggregate // class. // // TODO We'd like to be able to see how the members of an aggregate class were // selected, and what the pack standings were/would have been without the agg // round(s). Note that the roster.new action performs SQL queries directly, // without using result_summary(), but performs a similar query. require_once('inc/data.inc'); require_once('inc/authorize.inc'); session_write_close(); require_once('inc/banner.inc'); require_once('inc/schema_version.inc'); require_permission(VIEW_RACE_RESULTS_PERMISSION); require_once('inc/standings.inc'); ?><!DOCTYPE html> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/> <script type="text/javascript" src="js/jquery.js"></script> <script type="text/javascript" src="js/mobile.js"></script> <script type="text/javascript" src="js/standings.js"></script> <script type="text/javascript"> // This bit of javascript has to be here and not standings.js because of the PHP portions $(function () { $("tr").not(".headers").addClass('hidden'); $("#view-selector").on("change", function(event) { standings_select_on_change($(this).find("option:selected")); }); standings_select_on_change($("#view-selector").find("option:selected")); }); </script> <title>Standings</title> <?php require('inc/stylesheet.inc'); ?> <link rel="stylesheet" type="text/css" href="css/mobile.css"/> <link rel="stylesheet" type="text/css" href="css/main-table.css"/> <style type="text/css"> .center-select { width: 400px; margin-left: auto; margin-right: auto; } .center-select h3 { text-align: center; } </style> </head> <body> <?php make_banner('Race Standings'); ?> <div class="block_buttons"> <div class="center-select"> <h3><?php $scoring = read_raceinfo('scoring', 0); if (read_raceinfo_boolean('use-points')) { if ($scoring == 0) { echo "Scoring by points"; } else if ($scoring == 1) { echo "Scoring by points,<br/>dropping each racer's worst heat"; } else { echo "Scoring by points,<br/>best heat"; } } else { if ($scoring == 0) { echo "Averaging all heat times"; } else if ($scoring == 1) { echo "Dropping each racer's worst heat"; } else { echo "Selecting best heat"; } } ?></h3> </div> <?php $standings = new StandingsOracle(); if (isset($_GET['debug'])) { echo "<pre>\n"; echo json_encode($standings->debug_summary(), JSON_PRETTY_PRINT | JSON_HEX_TAG); echo "</pre>\n"; } ?> <div class="center-select"> <select id="view-selector"> <?php foreach ($standings->standings_catalog() as $entry) { echo "<option data-presentation=\"$entry[presentation]\" value=\"$entry[key]\">" .htmlspecialchars($entry['name'], ENT_QUOTES, 'UTF-8') ."</option>\n"; } ?> </select> </div> </div> <table class="main_table"> <?php $standings->write_standings_table(); ?> </table> </body> </html>
php
MIT
07b0d7303c2d2563b7adfd8af1cabe389c114bac
2026-01-05T04:46:00.013344Z
false
jeffpiazza/derbynet
https://github.com/jeffpiazza/derbynet/blob/07b0d7303c2d2563b7adfd8af1cabe389c114bac/website/kiosk.php
website/kiosk.php
<?php @session_start(); require_once('inc/data.inc'); require_once('inc/kiosks.inc'); require_once('inc/permissions.inc'); require_once('inc/servername.inc'); if (!isset($_GET['address']) && !isset($_GET['page'])) { header('Location: ' . request_path() . '?' . http_build_query(array('address' => address_for_current_kiosk()))); exit(); } // The award presentation kiosk wants to reset the current award when it starts // up. @$_SESSION['permissions'] |= PRESENT_AWARDS_PERMISSION; session_write_close(); $g_kiosk_parameters_string = ''; function kiosk_parameters() { global $g_kiosk_parameters_string; return json_decode(empty($g_kiosk_parameters_string) ? '{}' : $g_kiosk_parameters_string, true); } // We're setting $g_kiosk_address here, and then exposing the value in // javascript generated by kiosk-poller.inc. // To support testing, user can pass 'page' as a query parameter to name the // kiosk page they want to see. if (isset($_GET['page'])) { $g_kiosk_address = 'page-param'; // i.e., this kiosk won't register with the server // Confirm the requested page falls under the kiosks directory // (Thank you, https://chocapikk.com !) $self = dirname(realpath($_SERVER['SCRIPT_FILENAME'])); $page = realpath($self.'/'.$_GET['page']); $kiosks_dir = $self.DIRECTORY_SEPARATOR.'kiosks'; for ($i = 1; true; ++$i) { $dir = dirname($page, $i); if ($dir == "/" || $dir == ".") { $page = 'kiosks/identify.kiosk'; break; } if ($dir == $kiosks_dir) { break; } } $g_kiosk_parameters_string = isset($_GET['parameters']) ? $_GET['parameters'] : '{}'; require($page); } else { $g_kiosk_address = address_for_current_kiosk(); $kpage = kiosk_page($g_kiosk_address); $g_kiosk_parameters_string = $kpage['parameters']; require($kpage['page']); } ?>
php
MIT
07b0d7303c2d2563b7adfd8af1cabe389c114bac
2026-01-05T04:46:00.013344Z
false
jeffpiazza/derbynet
https://github.com/jeffpiazza/derbynet/blob/07b0d7303c2d2563b7adfd8af1cabe389c114bac/website/timer-test.php
website/timer-test.php
<?php @session_start(); require_once('inc/data.inc'); session_write_close(); require_once('inc/banner.inc'); require_once('inc/locked.inc'); require_once('inc/json-current-heat.inc'); require_once('inc/json-timer-state.inc'); require_once('inc/timer-test.inc'); $current = get_running_round(); // $timer_state_status comprises two values. This is just the initial value; the // page will poll for updates $timer_state_status = expand_timer_state_status(new TimerState()); ?><!DOCTYPE html> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/> <title>Timer</title> <?php require('inc/stylesheet.inc'); ?> <link rel="stylesheet" type="text/css" href="css/mobile.css"/> <link rel="stylesheet" type="text/css" href="css/timer-test.css"/> <script type="text/javascript" src="js/jquery.js"></script> <script type="text/javascript" src="js/mobile.js"></script> <script type="text/javascript" src="js/ajax-setup.js"></script> <script type="text/javascript" src="js/modal.js"></script> <script type="text/javascript" src="js/timer-test.js"></script> <script type="text/javascript"> $(function() { update_timer_summary(<?php echo json_encode(json_timer_state(), JSON_HEX_TAG | JSON_HEX_AMP); ?>, <?php echo json_encode(json_timer_details(), JSON_HEX_TAG | JSON_HEX_AMP); ?>, <?php echo json_encode(json_current_heat($current), JSON_HEX_TAG | JSON_HEX_AMP); ?>); }); </script> </head> <body> <?php make_banner('Timer Testing', 'coordinator.php'); ?> <div id="log_outer"> <div class="test-control"> <label for="timer-send-logs">Remote logging:</label> <input id="timer-send-logs" type="checkbox" class="flipswitch" <?php if (read_raceinfo_boolean('timer-send-logs')) { echo " checked='checked'"; } ?>/> <span id="log-location"><?php if (!locked_settings()) { echo htmlspecialchars(read_raceinfo('timer-log', ''), ENT_QUOTES, 'UTF-8'); } ?></span> </div> <div id="log_container"> <pre id="log_text"></pre> </div> </div> <div id="timer_summary"> <img id="timer_summary_icon" src="img/status/unknown.png"/> <div id="timer_summary_text"> <h3>Timer Status</h3> <p><b id="timer_status_text">Timer status not yet updated</b></p> <div id="timer-details"></div> </div> </div> <div class="test-control"> <label for="test-mode">Simulate racing:</label> <input id="test-mode" type="checkbox" class="flipswitch" <?php if ($current['roundid'] == TIMER_TEST_ROUNDID && $current['now_racing']) { echo " checked=\"checked\""; } ?>/> </div> <div id="now-racing"> <label id="n-lanes-label" for="n-lanes">Number of lanes on the track:</label> <input id="n-lanes" name="n-lanes" type="number" class="not-mobile" min="0" max="20" value="<?php echo get_lane_count(); ?>"/> <div> <input id="reverse-lanes" name="reverse-lanes" class="not-mobile" type="checkbox"<?php if (read_raceinfo_boolean('reverse-lanes')) echo ' checked="checked"';?>/> <label id="reverse-lanes-label" for="reverse-lanes">Number lanes in reverse</label> </div> <input type="hidden" id="unused-lane-mask" name="unused-lane-mask" value="<?php echo read_raceinfo('tt-mask', read_raceinfo('unused-lane-mask', 0)); ?>"/> <table id="lanes"> <tr><th>Lane</th> <th>Occupied?</th> <th>Time</th> <th>Place</th> </tr> </table> <div id="timer_settings_button_div" class="block_buttons"> <input type="button" value="Timer Settings" onclick="handle_timer_settings_button()"/> </div> <div id="start_race_button_div" class="block_buttons hidden"> <input type="button" value="Start Race" onclick="handle_start_race_button()"/> </div> <div id="fake_timer_div" class="block_buttons hidden"> <a class="button_link" href="fake-timer.php" target="_blank">Fake Timer</a> </div> </div> <div id='timer_settings_modal' class='modal_dialog wide_modal hidden block_buttons'> <div id='timer_settings_port_and_device'> <div id='timer_settings_port'> <select></select> </div> <div id='timer_settings_device'> <select></select> </div> </div> <table id="timer_settings_modal_flags"></table> <input type="button" value="Cancel" onclick='close_modal("#timer_settings_modal");'/> </div> </body> </html>
php
MIT
07b0d7303c2d2563b7adfd8af1cabe389c114bac
2026-01-05T04:46:00.013344Z
false
jeffpiazza/derbynet
https://github.com/jeffpiazza/derbynet/blob/07b0d7303c2d2563b7adfd8af1cabe389c114bac/website/mcheckin.php
website/mcheckin.php
<?php @session_start(); require_once('inc/banner.inc'); require_once('inc/authorize.inc'); $_SESSION['permissions'] |= CHECK_IN_RACERS_PERMISSION | REVERT_CHECK_IN_PERMISSION | PHOTO_UPLOAD_PERMISSION ; session_write_close(); ?><!DOCTYPE html> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/> <title>Mobile Check-In</title> <link rel="stylesheet" type="text/css" href="css/jquery-ui.min.css"/> <?php require('inc/stylesheet.inc'); ?> <link rel="stylesheet" type="text/css" href="css/mobile.css"/> <link rel="stylesheet" type="text/css" href="css/camera.css"/> <link rel="stylesheet" type="text/css" href="css/mcheckin.css"/> <script type="text/javascript" src="js/jquery.js"></script> <script type="text/javascript" src="js/jquery-ui.min.js"></script> <script type="text/javascript" src="js/mobile.js"></script> <!-- webrtc adapter: recommended for use with quaggajs --> <script type="text/javascript" src="js/adapter.js"></script> <script type="text/javascript" src="js/video-device-picker.js"></script> <script type="text/javascript" src="js/zxing.js"></script> <script type="text/javascript" src="js/mcheckin.js"></script> <script type="text/javascript"> //window.addEventListener('resize', function(event) { report_trouble('resize event'); }); //window.addEventListener('orientationchange', function(event) { report_trouble('orientationchange event'); }); $(function() { refresh_racer_list(); }); </script> </head> <body> <?php make_banner('Mobile Check-In', 'checkin.php'); ?> <div id="greetings-background" class="hidden"><!-- Added "hidden" as an experiment --> <div id="greetings" class="block_buttons"> <p id="step1">Point your camera at the barcode identifying a racer. Then:</p> <p>Tap <img src="img/photo-headshot.png"/> to capture a picture of the racer.</p> <p>Use the switch to mark the racer as checked in.</p> <p>Tap <img src="img/photo-car.png"/> to capture a picture of the car.</p> <input type="button" value="Start" onclick="dismiss_greetings()"/> </div> </div> <div id="trouble" class="hidden" onclick="close_trouble();"> </div> <div id="announce-hover" class="hidden" onclick="close_announce_hover();"></div> <div id="camera-div" class='hidden'> <div id="device-picker-div"> <select id="device-picker" ><option>Please wait</option></select> </div> <div id="preview-container"> <video id="preview" autoplay muted playsinline onclick="on_preview_click()"> </video> <div id="preview-overlay"> <div id="preview-overlay-content"> Orient barcode like this. </div> </div> </div> </div> <div id="racer-list"> <ul class="mlistview"></ul> <div id="switch-to-camera-button" onclick="on_switch_to_camera_cllicked();">Switch to Camera</div> </div> <audio id="beep" src="img/barcode.mp3"></audio> <div id="flash-overlay"></div> <div id="slide-in"> <div id="slide-in-inner"> <div id="racer-div"></div> <div id="controls"> <div id="controls-inner"> <div id="head-button" class="escutcheon" onclick="capture_photo('head');"> <div class="thumbnail-carrier" > <img class="thumbnail" src="img/photo-headshot.png"/> </div> </div> <div id="autocrop-button" class="escutcheon passed" onclick="on_autocrop_button_click();"> <div id="autocrop-holder"> <img src="img/autocrop.png"/> <div id="autocrop-overlay"></div> </div> </div> <div id="checkin-button" class="escutcheon" onclick="on_checkin_button_click();"> <div id="checkin-button-text">No racer selected</div> </div> <div id="car-button" class="escutcheon" onclick="capture_photo('car');"> <div class="thumbnail-carrier"> <img class="thumbnail" src="img/photo-car.png"/> </div> </div> </div> </div> </div> </div> <img id="logo-bug" src="img/derbynet.png"/> </body> </html>
php
MIT
07b0d7303c2d2563b7adfd8af1cabe389c114bac
2026-01-05T04:46:00.013344Z
false
jeffpiazza/derbynet
https://github.com/jeffpiazza/derbynet/blob/07b0d7303c2d2563b7adfd8af1cabe389c114bac/website/setup.php
website/setup.php
<?php session_start(); require_once('inc/authorize.inc'); require_once('inc/banner.inc'); require_permission(SET_UP_PERMISSION); ?><!DOCTYPE html> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/> <title>DerbyNet Set-Up</title> <link rel="stylesheet" type="text/css" href="css/jquery-ui.min.css"/> <link rel="stylesheet" type="text/css" href="css/mobile.css"/> <link rel="stylesheet" type="text/css" href="css/dropzone.min.css"/> <?php require('inc/stylesheet.inc'); ?> <link rel="stylesheet" type="text/css" href="css/setup.css"/> <script type="text/javascript" src="js/jquery.js"></script> <script type="text/javascript" src="js/dropzone.min.js"></script> <script type="text/javascript" src="js/ajax-setup.js"></script> <script type="text/javascript" src="js/jquery-ui.min.js"></script> <script type="text/javascript" src="js/mobile.js"></script> <script type="text/javascript" src="js/modal.js"></script> <script type="text/javascript" src="js/chooser.js"></script> <script type="text/javascript" src="js/setup.js"></script> </head> <body> <?php make_banner('Set-Up'); ?> <?php require_once('inc/parse-connection-string.inc'); require_once('inc/details-for-setup-page.inc'); require_once('inc/default-database-directory.inc'); require_once('inc/standard-configs.inc'); require_once('inc/locked.inc'); $configdir = isset($_SERVER['DERBYNET_CONFIG_DIR']) ? $_SERVER['DERBYNET_CONFIG_DIR'] : 'local'; try { @include($configdir.DIRECTORY_SEPARATOR."config-database.inc"); } catch (PDOException $p) { } if (isset($db) && $db) { require_once('inc/data.inc'); require_once('inc/schema_version.inc'); } session_write_close(); // If there's an existing database config, then $db_connection_string should // contain the connection string (having been set in data.inc). We parse the // connection string to figure out how to populate the fields of the "advanced" // database dialog. $initial_details = build_setup_page_details(); $ez_configs = list_standard_configs(default_database_directory()); if (defined('JSON_PARTIAL_OUTPUT_ON_ERROR')) { $initial_details = json_encode($initial_details, JSON_PARTIAL_OUTPUT_ON_ERROR); } else { $initial_details = json_encode($initial_details); } ?> <script type="text/javascript"> //<![CDATA[ $(function() { populate_details(<?php echo $initial_details; ?>); }); //]]> </script> <div id="right-float"> <div id="offer_fake" class="block_buttons"> <p>For experimenting, you might want to make a</p> <a class="button_link" href="fakeroster.php">Fake Roster</a> </div> <div id="remind_fake" class="block_buttons"> <p>To remove the fake roster data, re-initialize the database, or click "Purge Data" and delete racers.</p> </div> </div> <!-- Database --> <div id="database_step" class="step_div"> <div class="status_icon"><img/></div> <div class="step_button block_buttons"> <input type="button" value="Choose Database" onclick="show_ezsetup_modal()"/> </div> <div class="step_details"></div> </div> <!-- Schema --> <div id="schema_step" class="step_div"> <div class="status_icon"><img/></div> <div class="upper"> <div class="step_button block_buttons"> <input id="schema_button" type="button"/> </div> <div id="schema_details" class="step_details"></div> </div> <div class="lower"> <div class="step_button block_buttons"> <input id="purge_data_button" type="button" value="Purge Data" onclick="show_purge_modal()"/> </div> <div class="step_details"> <p>After testing or experimentation, you may wish to delete some or all of the data in the database.</p> </div> </div> </div> <!-- Roster --> <div id="roster_step" class="step_div"> <div class="status_icon"><img/></div> <div class="step_button block_buttons"> <a class="button_link" href="import-roster.php">Import Roster</a> </div> <div class="step_details"></div> </div> <!-- Groups --> <div id="groups_step" class="step_div"> <div class="status_icon"><img/></div> <div class="step_button block_buttons"> <a class="button_link" href="racing-groups.php">Racing Groups</a> </div> <div class="step_details"></div> </div> <!-- Awards --> <div id="awards_step" class="step_div"> <div class="status_icon"><img/></div> <div class="step_button block_buttons"> <a class="button_link" href="import-awards.php">Import Awards</a> </div> <div class="step_details"></div> </div> <!-- Photo directories and lane count --> <div id="settings_step" class="step_div"> <div class="status_icon"><img/></div> <div class="step_button block_buttons"> <a class="button_link" href="settings.php">Settings</a> </div> <div class="step_details"></div> </div> <div id="directions_step" class="step_div"> <div class="status_icon">&nbsp;</div> <div class="step_button block_buttons"> <p id="prefs-drop-intro">If you have a saved prefs file,</p> <form id="prefs-drop" action="action.php" class="dropzone"> <p id="prefs-drop-msg" class="dz-message">Drop prefs file here</p> <div class="fallback"> <input type="file" name="prefs" value="Upload Files"/> </div> <input type="hidden" name="action" value="preferences.upload"/> </form> </div> <div class="step_details"> <p>You may also want to visit the <a class="button_link" href="scenes.php?back=setup.php">Scene Editor</a> or the <a class="button_link" href="playlist.php?back=setup.php">Playlist Editor</a></p> </div> </div> <?php require_once('inc/ajax-failure.inc'); ?> <div id="ezsetup_modal" class="modal_dialog hidden block_buttons"> <form> <input type="hidden" name="action" value="setup.nodata"/> <div id="ez_database"> <label for="ez_database_name">Name for new database:</label> <input type="text" name="ez-new" id="ez_database_name"/> </div> <?php if (count($ez_configs) > 0) { ?> <p style="text-align: center;"><b>OR</b></p> <select name="ez-old" id="ez_database_select"> <option id="ez-old-nochoice" disabled="disabled" selected="selected" value="">Please select:</option> <?php foreach ($ez_configs as $config) { $path = htmlspecialchars($config['relpath'], ENT_QUOTES, 'UTF-8'); echo "<option value='".$path."'>".$path."</option>\n"; } ?> </select> <?php } ?> <br/> <input type="submit" value="Submit"/> <input type="button" value="Cancel" onclick="close_modal('#ezsetup_modal');"/> <br/> <input type="button" value="Advanced" onclick="show_advanced_database_modal()"/> </form> </div> <div id="advanced_database_modal" class="modal_dialog wide_modal tall_modal hidden block_buttons"> <form><?php $is_windows = strtoupper(substr(PHP_OS, 0, 3)) === 'WIN'; ?> <input type="hidden" name="action" value="setup.nodata"/> <input id="sqlite_connection" type="radio" name="connection_type" value="sqlite" checked="checked"/> <label for="sqlite_connection">SQLite data source<span class="missing_driver"></span></label> <input id="odbc_connection" type="radio" name="connection_type" value="odbc"/> <label for="odbc_connection">ODBC data source<span class="missing_driver"></span></label> <input type="radio" name="connection_type" value="string" id="string_connection"/> <label for="string_connection">Arbitrary connection string</label> <div id="for_odbc_connection" class="hidden connection_details"> <label for="odbc_dsn_name">ODBC data source name (DSN):</label> <input type="text" name="odbc_dsn_name" id="odbc_dsn_name"/> </div> <div id="for_sqlite_connection" class="hidden connection_details"> <input type="button" id="browse_for_sqlite" value="Browse" onclick='show_choose_file_modal($("#sqlite_path").val(), "new.sqlite", function(fullpath) { $("#sqlite_path").val(fullpath); update_sqlite_path(); });'/> <div style="width: 80%"> <label for="sqlite_path">Path (on server) to SQLite data file:</label> <input type="text" name="sqlite_path" id="sqlite_path"/> </div> </div> <div id="for_string_connection"> <label for="connection_string">Database connection string:</label> <input type="text" name="connection_string" id="connection_string" <?php if (!isset($db_connection_string)) { echo 'placeholder="Database connection string"'; } ?>/> </div> <input type="submit" value="Submit"/> <input type="button" value="Cancel" onclick='close_modal("#advanced_database_modal");'/> </form> </div> <div id="initialize_schema_modal" class="modal_dialog hidden block_buttons"> <form> <p>Initializing the schema will wipe out any existing data in the database, and cannot be undone. Are you sure that's what you want to do?</p> <input type="submit" value="Initialize"/> <input type="button" value="Cancel" onclick='close_secondary_modal("#initialize_schema_modal");'/> </form> </div> <div id="update_schema_modal" class="modal_dialog hidden block_buttons"> <form> <p>Before updating the schema, it's wise to back up any important data that's already in the database. Updating the schema cannot be undone. Are you sure that's what you want to do?</p> <input type="submit" value="Update Schema"/> <input type="button" value="Cancel" onclick='close_modal("#update_schema_modal");'/> </form> </div> <div id="purge_modal" class="modal_dialog wide_modal block_buttons hidden"> <form> <div id="purge_modal_inner"> <div class="purge_div"> <div class="purge_button block_buttons"> <input type="button" id="delete_race_results" value="Delete Race Results" onclick="confirm_purge('results');"/> </div> <p id="purge_results_para"><span id="purge_nresults_span"></span> completed heat(s)</p> </div> <div class="purge_div"> <div class="purge_button block_buttons"> <input type="button" id="delete_schedules" value="Delete Schedules" onclick="confirm_purge('schedules');"/> </div> <p id="purge_schedules_para"><span id="purge_nschedules_span"></span> scheduled heat(s)</p> </div> <div class="purge_div"> <div class="purge_button block_buttons"> <input type="button" id="delete_racers" value="Delete Racers" onclick="confirm_purge('racers');"/> </div> <p id="purge_racers_para"><span id="purge_nracers_span"></span> registered racer(s)</p> </div> <!-- TODO delete classes/ranks? --> <div class="purge_div"> <div class="purge_button block_buttons"> <input type="button" id="delete_awards" value="Delete Awards" onclick="confirm_purge('awards');"/> </div> <p id="purge_awards_para"><span id="purge_nawards_span"></span> award(s)</p> </div> <div class="purge_div"> <div class="purge_button block_buttons"> <input type="button" value="Re-Initialize" onclick="show_initialize_schema_modal();"/> </div> <p>Delete everything in the database</p> </div> <input type="button" value="Cancel" onclick='close_modal("#purge_modal");'/> </div> </form> </div> <div id="purge_confirmation_modal" class="modal_dialog hidden block_buttons"> <form> <p>You are about to purge</p> <p id="purge_operation"></p> <p>from the database. This operation cannot be undone. Are you sure that's what you want to do?</p> <input type="submit" value="Purge"/> <input type="button" value="Cancel" onclick='close_secondary_modal("#purge_confirmation_modal");'/> </form> </div> <div id="reporting_box" class="hidden"> <div id="reporting_box_content"></div> <div id="reporting_box_dismiss" class="hidden" onclick="hide_reporting_box(); return false;">Dismiss</div> </div> <?php require('inc/chooser.inc'); ?> </body> </html>
php
MIT
07b0d7303c2d2563b7adfd8af1cabe389c114bac
2026-01-05T04:46:00.013344Z
false
jeffpiazza/derbynet
https://github.com/jeffpiazza/derbynet/blob/07b0d7303c2d2563b7adfd8af1cabe389c114bac/website/vote.php
website/vote.php
<?php @session_start(); require_once('inc/data.inc'); require_once('inc/authorize.inc'); session_write_close(); require_once('inc/banner.inc'); require_once('inc/photo-config.inc'); require_once('inc/awards.inc'); require_once('inc/voterid.inc'); require_once('inc/standings.inc'); require_once('inc/schema_version.inc'); $is_open = read_raceinfo('balloting', 'closed') == 'open'; ?><!DOCTYPE html> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/> <title>Award Ballot</title> <script type="text/javascript" src="js/jquery.js"></script> <script type="text/javascript" src="js/ajax-setup.js"></script> <script type="text/javascript" src="js/jquery-ui.min.js"></script> <script type="text/javascript" src="js/jquery.ui.touch-punch.min.js"></script> <script type="text/javascript" src="js/modal.js"></script> <script type="text/javascript" src="js/vote.js"></script> <script type="text/javascript"> var g_ballot; var g_awardid; var g_racerid; <?php if ($is_open) { ?> $(function() { get_ballot(); }); <?php } ?> </script> <?php require('inc/stylesheet.inc'); ?> <link rel="stylesheet" type="text/css" href="css/vote.css"/> </head> <body> <?php make_banner('Ballot'); $order = ''; if (isset($_GET['order'])) $order = $_GET['order']; // Values are: name, class, car if (!$order) $order = 'car'; function link_for_ordering($key, $text) { global $order; echo "<a "; if ($order == $key) { echo 'class="current_sort"'; } echo " href='ballot.php?order=".$key."'>"; echo $text; echo "</a>"; } $racers = array(); $sql = 'SELECT racerid, carnumber, lastname, firstname,' .' RegistrationInfo.classid, class, RegistrationInfo.rankid, rank, imagefile,' .' '.(schema_version() < 2 ? "class" : "Classes.sortorder").' AS class_sort, ' .(schema_version() < 2 ? '\'\' as ' : '').' carphoto' .' FROM '.inner_join('RegistrationInfo', 'Classes', 'Classes.classid = RegistrationInfo.classid', 'Ranks', 'Ranks.rankid = RegistrationInfo.rankid') .' WHERE passedinspection = 1 AND exclude = 0' .' ORDER BY ' .($order == 'car' ? 'carnumber, lastname, firstname' : ($order == 'class' ? 'class_sort, lastname, firstname' : 'lastname, firstname')); foreach ($db->query($sql) as $rs) { $racerid = $rs['racerid']; $racers[$racerid] = array('racerid' => $racerid, 'carnumber' => $rs['carnumber'], 'lastname' => $rs['lastname'], 'firstname' => $rs['firstname'], 'classid' => $rs['classid'], 'class' => $rs['class'], 'rankid' => $rs['rankid'], 'rank' => $rs['rank'], 'imagefile' => $rs['imagefile'], 'carphoto' => $rs['carphoto']); } ?> <div id="awards"> <div <?php if ($is_open) echo 'class="hidden"'; ?>> <h3>Balloting is currently closed.</h3> </div> <div id='no-awards' class='hidden'> <h3>There are no awards available for voting.</h3> </div> <div class='please-click hidden'> Please click on an award to vote. </div> <?php // This enumerates all awards, not just those that are ballotable. $awards = all_awards(false); mark_award_eligibility($awards); foreach ($awards as $award) { echo "<div class='award hidden' data-awardid='$award[awardid]'"; if ($award['classid'] != 0) { echo " data-classid='$award[classid]'"; } if ($award['rankid'] != 0) { echo " data-rankid='$award[rankid]'"; } echo " data-eligible-classids='".implode(',', $award['eligible-classids'])."'"; echo " data-eligible-rankids='".implode(',', $award['eligible-rankids'])."'"; echo " onclick='click_one_award($(this));'>"; echo "<p class='award-name'>".htmlspecialchars($award['awardname'], ENT_QUOTES, 'UTF-8')."</p>"; echo "<p class='please-vote-for'>Please vote for no more than <span class='please-vote-count'>UNSET</span>.</p>"; echo "</div>\n"; } ?> </div> <div id="racers_modal" class="modal_dialog hidden"> <div id="racers_modal_headline" class="block_buttons"> <input type="button" value="Close" data-enhanced="true" onclick='close_modal("#racers_modal");'/> <span>Please choose up to <span id="racer_view_max_votes"></span> for <span id="racer_view_award_name"></span></span> <span id="selected_racers"> </span> </div> <div id="racers"> <?php $use_subgroups = read_raceinfo_boolean('use-subgroups'); foreach ($racers as $racer) { // Javascript depends on each div.ballot_racer having data-racerid, data-img // for the full-size image, an interior img element for thumbnail, and an // interior div.carno with the car number. echo "<div class='ballot_racer'" ." data-racerid='$racer[racerid]'" ." data-classid='$racer[classid]'" ." data-rankid='$racer[rankid]'" ." data-img='".car_photo_repository()->url_for_racer($racer, RENDER_WORKING)."'" ." onclick='show_racer_view_modal($(this));'>\n"; if ($racer['carphoto']) { echo "<img src='".car_photo_repository()->lookup(RENDER_JUDGING)->render_url($racer['carphoto'])."'/>"; } echo "<div class='carno'>"; echo $racer['carnumber']; echo "</div>"; // echo "<div class='racer_name'>".htmlspecialchars($racer['firstname'].' '.$racer['lastname'], ENT_QUOTES, 'UTF-8')."</div>"; echo "<div class='group_name'>" .htmlspecialchars($racer['class'], ENT_QUOTES, 'UTF-8') ."</div>"; if ($use_subgroups) { echo "<div class='subgroup_name'>" .htmlspecialchars($racer['rank'], ENT_QUOTES, 'UTF-8') ."</div>"; } echo "</div>\n"; } ?> </div><!-- racers --> </div><!-- racers_modal --> <div id='racer_view_modal' class='modal_dialog hidden block_buttons'> <div id='racer_view_check' onclick='toggle_vote($(this));'> Vote: <img src="img/checkbox-with-check.png"/> </div> <div id='racer_view_carnumber'></div> <img id='racer_view_photo'/> <br/> <p id="full-ballot">You already have <span id="full-ballot-max">UNSET</span> racer(s) chosen.</p> <input type="button" value="Close" data-enhanced="true" onclick='close_secondary_modal("#racer_view_modal");'/> </div> <div id='password_modal' class='modal_dialog hidden block_buttons'> <form> <h3>Please enter the ballot password</h3> <input id="password_input" type='password'/> <p id="wrong-password" class="hidden">The password you entered is incorrect. Please try again.</p> <input type='submit'/> </form> </div> </body> </html>
php
MIT
07b0d7303c2d2563b7adfd8af1cabe389c114bac
2026-01-05T04:46:00.013344Z
false
jeffpiazza/derbynet
https://github.com/jeffpiazza/derbynet/blob/07b0d7303c2d2563b7adfd8af1cabe389c114bac/website/login.php
website/login.php
<?php @session_start(); // Login page: present a list of the possible roles, and, upon // selection, prompt for a password and log the user in. require_once('inc/data.inc'); require_once('inc/authorize.inc'); session_write_close(); require_once('inc/banner.inc'); require_once('inc/permissions.inc'); require_once('inc/locked.inc'); ?><!DOCTYPE html> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/> <title>Please Log In</title> <?php require('inc/stylesheet.inc'); ?> <style type="text/css"> #pw_for_password { display: block; width: 270px; /* Allow for 15px horizontal padding from global.css */ margin-left: auto; margin-right: auto; } #banner_link { cursor: default; } #login-kiosk { position: fixed; bottom: 20px; /* left: 1em; padding: 1em; */ width: 25em; left: 50%; margin-left: -12.5em; } #camera_button { padding-bottom: 15px; padding-top: 5px; font-size: 22px; height: 20px; width: 150px; } #kiosk_button { margin-bottom: 6px; } </style> <script type="text/javascript" src="js/jquery.js"></script> <script type="text/javascript" src="js/ajax-setup.js"></script> <script type="text/javascript" src="js/modal.js"></script> <script type="text/javascript" src="js/login.js"></script> </head> <body<?php if (isset($_GET['logout'])) echo ' onload="handle_logout()"'; ?>> <a id="banner_link" href="<?php echo isset($_GET['all']) ? '?' : '?all'; ?>"> <?php make_banner(''); ?> </a> <div class="index_background"> <div class="block_buttons"> <legend>Please choose a role:</legend> <?php foreach ($roles as $name => $details) { if (empty($name)) { // "Logged out" role: no name, no password } else if (isset($details['interactive']) && !$details['interactive'] && !isset($_GET['all'])) { // Ignore logins intended for robots } else { echo '<input type="button" value="'.$name.'" onclick=\'show_password_form("'.$name.'");\'/>'."\n"; } } ?> <div id="login-kiosk"> <input type="button" id="kiosk_button" value="Be a Kiosk" onclick="show_kiosk_form();"/> <a class="button_link" id="camera_button" href="camera.php">Be a Camera</a> </div> <?php if (@$_SESSION['role']) { ?> <br/> <input type="button" value="Log out" onclick='handle_logout();'/> <?php } ?> </div> </div> <div id='password_modal' class="modal_dialog hidden block_buttons"> <form> <input type="hidden" name="name" id="name_for_password" value=""/> <p>Enter password:</p> <p><input type="password" name="pw" id="pw_for_password"/></p> <?php if (!locked_settings()) { ?> <p>&nbsp;</p> <p>Don't remember setting a password? Consult the documentation.</p> <?php } ?> <input type="submit" value="Submit"/> <input type="button" value="Cancel" onclick='close_modal("#password_modal");'/> </form> </div> <div id='kiosk_modal' class="modal_dialog hidden block_buttons"> <input type="button" value="Be a Kiosk" onclick="window.location='kiosk.php'"/> <input type="button" value="Fullscreen Kiosk" onclick="window.location='fullscreen.php'"/> <input type="button" value="Replay Kiosk" onclick="window.location='replay.php'"/> <br/> <input type="button" value="Cancel" onclick='close_modal("#kiosk_modal");'/> </div> </body> </html>
php
MIT
07b0d7303c2d2563b7adfd8af1cabe389c114bac
2026-01-05T04:46:00.013344Z
false
jeffpiazza/derbynet
https://github.com/jeffpiazza/derbynet/blob/07b0d7303c2d2563b7adfd8af1cabe389c114bac/website/photo.php
website/photo.php
<?php session_start(); require_once('inc/photo-config.inc'); require_once('inc/path-info.inc'); session_write_close(); // URL for a file in one of the repositories is: // photo.php/<repository>/file/<render>/<file-basename>/<cachebreaker>, e.g. // photo.php/head /file/80x80 /mygreatphoto.jpg/20150204133502 // // URL for an arbitrary file named by a racer's database entry is: // photo.php/<repository>/racer/<racerid>/<cachebreaker> // A racer-based URL requires another database fetch to get the file path, and // then returns exactly that file. // // URL for a file named by a RaceInfo key: // photo.php/info/<key>/<cachebreaker>/<default img path> // parse_photo_url returns: // { 'repository', 'url_type' }, and, depending, possibly other keys. function parse_photo_url($url_path_info) { $exploded = explode('/', $url_path_info); if ($exploded[2] == 'file') { return array('repository' => $exploded[1], 'url_type' => $exploded[2], // 'file' 'render' => $exploded[3], 'basename' => urldecode($exploded[4])); } else if ($exploded[2] == 'racer') { if (count($exploded) > 5) { return array( 'repository' => $exploded[1], 'url_type' => $exploded[2], // 'racer' 'racerid' => $exploded[3], 'render' => $exploded[4]); } return array('repository' => $exploded[1], 'url_type' => $exploded[2], // 'racer' 'racerid' => $exploded[3]); } else if ($exploded[1] == 'info') { return array('repository' => 'info', 'url_type' => 'info', 'key' => $exploded[2], 'default' => implode('/', array_slice($exploded, 4))); } else { return false; } } $parsed = parse_photo_url($path_info = path_info()); if (!$parsed) { // Malformed URL http_response_code(404); echo "Malformed URL\n"; // var_dump($path_info); exit(1); } if ($parsed['url_type'] == 'info') { $file_path = read_raceinfo($parsed['key'], $parsed['default']); } else { $repo = photo_repository($parsed['repository']); if (!$repo) { // No such repository http_response_code(404); echo "No such repository\n"; // var_dump($parsed); exit(1); } if (isset($parsed['render'])) { $render = $repo->lookup($parsed['render']); if (!$render) { // No such render http_response_code(404); echo "No such render\n"; // var_dump($parsed); exit(1); } } if ($parsed['url_type'] == 'racer') { $file_path = read_single_value('SELECT '.$repo->column_name() .' FROM RegistrationInfo' .' WHERE racerid = :racerid', array(':racerid' => $parsed['racerid'])); if (!$file_path) { // Return a 1x1 transparent image if this racer doesn't have an image. $file_path = 'img/1x1.png'; } else if (isset($render)) { $file_path = $render->find_or_make_image_file(basename($file_path)); } } else { $file_path = $render->find_or_make_image_file($parsed['basename']); } } if (!$file_path) { // No such racer/no such photo http_response_code(404); echo "No file path\n"; // var_dump($parsed); exit(1); } header('Pragma: public'); header('Cache-Control: max-age=86400, public'); header('Expires: '.gmdate('D, d M Y H:i:s', time() + 86400).' GMT'); header('Content-type: '.pseudo_mime_content_type($file_path)); readfile($file_path); ?>
php
MIT
07b0d7303c2d2563b7adfd8af1cabe389c114bac
2026-01-05T04:46:00.013344Z
false
jeffpiazza/derbynet
https://github.com/jeffpiazza/derbynet/blob/07b0d7303c2d2563b7adfd8af1cabe389c114bac/website/index.php
website/index.php
<?php @session_start(); //////////////////////////////////////////////////////////////////////////////////////////////////////// // // If you're seeing this page, your web server isn't configured correctly. (PHP is not enabled.) // //////////////////////////////////////////////////////////////////////////////////////////////////////// // Redirects to setup page if the database hasn't yet been set up require_once('inc/data.inc'); require_once('inc/schema_version.inc'); require_once('inc/banner.inc'); require_once('inc/authorize.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: setup.php'); exit(); } session_write_close(); $show_voting_button = $schema_version >= BALLOTING_SCHEMA && read_single_value('SELECT COUNT(*) FROM BallotAwards') > 0; // Returns true if we actually showed a button function make_link_button($label, $link, $permission, $button_class) { if (have_permission($permission)) { echo "<a class='button_link ".$button_class."' href='".$link."'>".$label."</a>\n"; echo "<br/>\n"; return true; } else { return false; } } function make_spacer_if($cond) { if ($cond) { echo "<div class='index_spacer'>&nbsp;</div>\n"; } } ?><!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> <style type="text/css"> div.index_spacer { height: 40px; } div.index_background { width: 100%; } div.index_column { width: 50%; display: inline-block; float: left; } .block_buttons a.button_link { width: 238px; height: 30px; } .block_buttons a.button_link.before_button, .block_buttons input.before_button[type='submit'] { color: #ffffcc; } .block_buttons a.button_link.during_button, .block_buttons input.during_button[type='submit'] { color: #ddffdd; } .block_buttons a.button_link.after_button, .block_buttons input.after_button[type='submit'] { color: #ddddff; } .block_buttons a.button_link.other_button, .block_buttons input.other_button[type='submit'] { color: #ffddff; } </style> </head> <body> <?php make_banner('', /* back_button */ false); $need_spacer = false; // This is a heuristic more than a hard rule -- when are there so many buttons that we need a second column? $two_columns = have_permission(SET_UP_PERMISSION); echo "<div class='index_background'>\n"; if ($two_columns) { echo "<div class='index_column'>\n"; } echo "<div class='block_buttons'>\n"; // *********** Before *************** $need_spacer = make_link_button('Set-Up', 'setup.php', SET_UP_PERMISSION, 'before_button'); $need_spacer = make_link_button('Race Check-In', 'checkin.php', CHECK_IN_RACERS_PERMISSION, 'before_button') || $need_spacer; if (have_permission(ASSIGN_RACER_IMAGE_PERMISSION)) { if ($schema_version > 1) { echo "<div class='double'>"; echo "<a class='button_link left before_button' href='photo-thumbs.php?repo=head'><b>Racer</b><br/>Photos</a>\n"; echo "<a class='button_link right before_button' href='photo-thumbs.php?repo=car'><b>Car</b><br/>Photos</a>\n"; echo "</div>"; } else { $need_spacer = make_link_button('Edit Racer Photos', 'photo-thumbs.php?repo=head', ASSIGN_RACER_IMAGE_PERMISSION, 'before_button') || $need_spacer; } } make_spacer_if($need_spacer); // *********** During *************** $need_spacer = make_link_button('Race Dashboard', 'coordinator.php', SET_UP_PERMISSION, 'during_button'); $need_spacer = make_link_button('Kiosk Dashboard', 'kiosk-dashboard.php', SET_UP_PERMISSION, 'during_button') || $need_spacer; $need_spacer = make_link_button('Judging', 'judging.php', JUDGING_PERMISSION, 'during_button') || $need_spacer; if (!have_permission(SET_UP_PERMISSION)) { $need_spacer = make_link_button('Slideshow', 'slideshow.php', VIEW_RACE_RESULTS_PERMISSION, 'during_button') || $need_spacer; if ($show_voting_button) { $need_spacer = make_link_button('Vote!', 'vote.php', VIEW_RACE_RESULTS_PERMISSION, 'during_button') || $need_spacer; } } // *********** During, part 2 *************** $need_spacer = make_link_button('Racers On Deck', 'ondeck.php', -1, 'during_button') || $need_spacer; $need_spacer = make_link_button('Results By Racer', 'racer-results.php', VIEW_RACE_RESULTS_PERMISSION, 'during_button') || $need_spacer; // end first column default set-up if ($two_columns) { echo "</div>\n"; // block_buttons echo "</div>\n"; // index_column echo "<div class='index_column'>\n"; echo "<div class='block_buttons'>\n"; } // *********** After *************** $need_spacer = make_link_button('Present Awards', 'awards-presentation.php', PRESENT_AWARDS_PERMISSION, 'after_button'); $need_spacer = make_link_button('Standings', 'standings.php', VIEW_AWARDS_PERMISSION, 'after_button') || $need_spacer; $need_spacer = make_link_button('Export Results', 'export.php', VIEW_RACE_RESULTS_PERMISSION, 'after_button') || $need_spacer; $need_spacer = make_link_button('Retrospective', 'history.php', SET_UP_PERMISSION, 'after_button') || $need_spacer; make_spacer_if($need_spacer); // *********** Other *************** make_link_button('Printables', 'print.php', ASSIGN_RACER_IMAGE_PERMISSION, 'other_button'); make_link_button('About', 'about.php', -1, 'other_button'); if (@$_SESSION['role']) { make_link_button('Log out', 'login.php?logout', -1, 'other_button'); } else { make_link_button('Log in', 'login.php', -1, 'other_button'); } echo "</div>\n"; // block_buttons if ($two_columns) { echo "</div>\n"; // index_column } echo "</div>\n"; // index_background echo "</body>\n"; echo "</html>\n"; ?>
php
MIT
07b0d7303c2d2563b7adfd8af1cabe389c114bac
2026-01-05T04:46:00.013344Z
false
jeffpiazza/derbynet
https://github.com/jeffpiazza/derbynet/blob/07b0d7303c2d2563b7adfd8af1cabe389c114bac/website/camera.php
website/camera.php
<?php @session_start(); require_once('inc/banner.inc'); require_once('inc/data.inc'); session_write_close(); ?><!DOCTYPE html> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/> <title>Replay Camera</title> <link rel="stylesheet" type="text/css" href="css/jquery-ui.min.css"/> <?php require('inc/stylesheet.inc'); ?> <link rel="stylesheet" type="text/css" href="css/camera.css"/> <script type="text/javascript" src="js/jquery.js"></script> <script type="text/javascript" src="js/jquery-ui.min.js"></script> <script type="text/javascript" src="js/adapter.js"></script> <script type="text/javascript" src="js/message-poller.js"></script> <script type="text/javascript" src="js/camera-signaling.js"></script> <script type="text/javascript" src="js/video-device-picker.js"></script> <script type="text/javascript"> g_websocket_url = <?php echo json_encode(read_raceinfo('_websocket_url', '')); ?>; function on_add_client() { // Adding a new client may give new information about the ideal width and // height for the video stream. on_device_selection($("#device-picker")); } var g_client_manager = new ViewClientManager(on_add_client); function on_device_selection(selectq) { // mobile_select_refresh(selectq); // If a stream is already open, stop it. stream = document.getElementById("preview").srcObject; if (stream != null) { stream.getTracks().forEach(function(track) { track.stop(); }); } let device_id = selectq.find(':selected').val(); let video_constraint = {deviceId: device_id}; let ideal = g_client_manager.ideal(); if (ideal.width) { video_constraint.width = {ideal: ideal.width}; } if (ideal.height) { video_constraint.height = {ideal: ideal.height}; } navigator.mediaDevices.getUserMedia({video: video_constraint}) .then(stream => { document.getElementById("preview").srcObject = stream; g_client_manager.setstream(stream); let tracks = stream.getVideoTracks(); if (tracks.length > 0) { logstream("Video stream width is " + tracks[0].getSettings().width); } }); } $(function() { if (typeof(navigator.mediaDevices) == 'undefined') { $("#no-camera-warning").removeClass('hidden'); if (window.location.protocol == 'http:') { var https_url = "https://" + window.location.hostname + window.location.pathname; $("#no-camera-warning").append("<p>You may need to switch to <a href='" + https_url + "'>" + https_url + "</a></p>"); } } else { navigator.mediaDevices.ondevicechange = function(event) { build_device_picker($("#device-picker"), /*include_remote*/false, on_device_selection); }; } build_device_picker($("#device-picker"), /*include_remote*/false, on_device_selection); }); function toggle_preview() { $("#preview").toggleClass('hidden', !document.getElementById('show-preview').checked); return false; } </script> </head> <body> <?php make_banner('Replay Camera'); ?> <div id="log" <?php if (!isset($_GET['debug'])) echo 'class="hidden"'; ?> ></div> <div class="block_buttons"> <video id="preview" autoplay="true" muted="true" playsinline="true"></video> <div id="no-camera-warning" class="hidden"> <h2 id='reject'>Access to cameras is blocked.</h2> </div> <div id="device-picker-div"> <select id="device-picker"><option>Please wait</option></select> </div> <div> <input type="checkbox" id="show-preview" checked="checked" onclick="toggle_preview();"/> <label for="show-preview">Show preview?</label> </div> </div> </body> </html>
php
MIT
07b0d7303c2d2563b7adfd8af1cabe389c114bac
2026-01-05T04:46:00.013344Z
false
jeffpiazza/derbynet
https://github.com/jeffpiazza/derbynet/blob/07b0d7303c2d2563b7adfd8af1cabe389c114bac/website/replay.php
website/replay.php
<?php @session_start(); require_once('inc/banner.inc'); require_once('inc/data.inc'); session_write_close(); ?><!DOCTYPE html> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/> <title>Replay Recording</title> <?php require('inc/stylesheet.inc'); require('inc/servername.inc'); $server = server_name(); $path = request_path(); $url = $server . $path; $last = strrpos($url, '/'); if ($last === false) { $last = -1; } // Don't force http ! $kiosk_url = '//'.substr($url, 0, $last + 1).'kiosk.php'; if (isset($_REQUEST['address'])) { $kiosk_url .= "?address=".$_REQUEST['address']; } ?> <link rel="stylesheet" type="text/css" href="css/jquery-ui.min.css"/> <link rel="stylesheet" type="text/css" href="css/replay.css"/> <script type="text/javascript" src="js/jquery.js"></script> <script type="text/javascript" src="js/ajax-setup.js"></script> <script type="text/javascript" src="js/jquery-ui.min.js"></script> <script type="text/javascript" src="js/screenfull.min.js"></script> <!-- WebRTC adapter: a shim to insulate apps from spec changes and prefix differences in WebRTC. Latest: https://webrtc.github.io/adapter/adapter-latest.js --> <script type="text/javascript" src="js/adapter.js"></script> <script type="text/javascript" src="js/message-poller.js"></script> <script type="text/javascript" src="js/viewer-signaling.js"></script> <script type="text/javascript" src="js/video-capture.js"></script> <script type="text/javascript" src="js/circular-frame-buffer.js"></script> <script type="text/javascript" src="js/video-device-picker.js"></script> <script type="text/javascript"> g_websocket_url = <?php echo json_encode(read_raceinfo('_websocket_url', '')); ?>; // If using websockets to listen for replay messages, this variable will hold // the websocket object. var g_trigger_websocket; // Avoid starting another poll request if another one is still in flight. g_poll_in_flight = false; function poll_once_for_replay() { if (g_poll_in_flight) { return; } g_poll_in_flight = true; $.ajax("action.php", {type: 'POST', data: {action: 'replay.message', status: 0, 'finished-replay': 0}, success: function(data) { for (let i = 0; i < data.replay.length; ++i) { handle_replay_message(data.replay[i]); } }, complete: function() { // Called after success (or error) g_poll_in_flight = false; }, }); } function listen_for_replay_messages() { if (g_websocket_url != "") { // g_trigger_websocket is the websocket on which we listen for replay messages g_trigger_websocket = new MessagePoller(make_id_string('replay-'), function(msg) { handle_replay_message(msg.cmd); }, ['replay-commands']); // Even though we're using the websocket for triggering, poll every 5s (as // opposed to several times per second), so we get credit for being // connected. setInterval(poll_once_for_replay, 5000); } else { setInterval(poll_once_for_replay, 250); } } g_upload_videos = <?php echo read_raceinfo_boolean('upload-videos') ? "true" : "false"; ?>; g_video_name_root = ""; // If a replay is triggered by timing out after a RACE_STARTS, then ignore any // subsequent REPLAY messages until the next START. // // If a replay is triggered by a REPLAY message that arrives before the timeout // (as most will), then we just cancel the g_replay_timeout. g_preempted = false; var g_remote_poller; var g_recorder; var g_replay_options = { count: 2, rate: 50, // expressed as a percentage length: 4000 // ms }; function parse_replay_options(cmdline) { g_replay_options.length = parseInt(cmdline.split(" ")[1]); if (g_recorder) { g_recorder.set_recording_length(g_replay_options.length); } g_replay_options.count = parseInt(cmdline.split(" ")[2]); g_replay_options.rate = parseInt(cmdline.split(" ")[3]); } // If non-zero, holds the timeout ID of a pending timeout that will trigger a // replay based on the start of a heat. var g_replay_timeout = 0; // Milliseconds short of g_replay_length to start a replay after a race start. var g_replay_timeout_epsilon = 0; function handle_replay_message(cmdline) { console.log('* Replay message:', cmdline); var root = g_video_name_root; if (cmdline.startsWith("HELLO")) { } else if (cmdline.startsWith("TEST")) { parse_replay_options(cmdline); on_replay(root); } else if (cmdline.startsWith("START")) { // Setting up for a new heat // This assumes that we'll get a queued START when the page is freshly // loaded. g_video_name_root = cmdline.substr(6).trim(); g_preempted = false; } else if (cmdline.startsWith("REPLAY")) { // REPLAY skipback showings rate // (Must be exactly one space between fields:) parse_replay_options(cmdline); if (!g_preempted) { clearTimeout(g_replay_timeout); console.log('Triggering replay from REPLAY message', root); on_replay(root); } } else if (cmdline.startsWith("CANCEL")) { clearTimeout(g_replay_timeout); } else if (cmdline.startsWith("RACE_STARTS")) { // This message signals that the start gate has actually opened (if that can // be detected). The START message identifies what heat is queued next. parse_replay_options(cmdline); g_replay_timeout = setTimeout( function() { g_preempted = true; console.log('Triggering replay from timeout after RACE_STARTS', root); on_replay(root); }, g_replay_options.length - g_replay_timeout_epsilon); } else { console.log("Unrecognized replay message: " + cmdline); } } $(function() { listen_for_replay_messages(); console.log('Replay page (re)loaded'); }); function on_stream_ready(stream) { $("#waiting-for-remote").addClass('hidden'); g_recorder = new CircularFrameBuffer(stream, g_replay_options.length); g_recorder.start_recording(); document.getElementById("preview").srcObject = stream; } function on_remote_stream_ready(stream) { let resize = function(w, h) { $("#recording-stream-info").removeClass('hidden'); $("#recording-stream-size").text(w + 'x' + h); }; resize(-1, -1); // Says we've got a stream, even if no frames yet. on_stream_ready(stream); g_recorder.on_resize(resize); } function on_device_selection(selectq) { // mobile_select_refresh(selectq); // If a stream is already open, stop it. stream = document.getElementById("preview").srcObject; if (stream != null) { stream.getTracks().forEach(function(track) { track.stop(); }); } let device_id = selectq.find(':selected').val(); if (typeof(navigator.mediaDevices) == 'undefined') { $("no-camera-warning").toggleClass('hidden', device_id == 'remote'); } if (device_id == 'remote') { if (g_remote_poller) { g_remote_poller.close(); g_remote_poller = null; } $("#waiting-for-remote").removeClass('hidden'); let id = make_id_string("viewer-"); console.log("Viewer id is " + id); g_remote_poller = new RemoteCamera( id, {width: $(window).width(), height: $(window).height()}, on_remote_stream_ready); } else { if (g_remote_poller) { g_remote_poller.close(); g_remote_poller = null; } $("#recording-stream-info").addClass('hidden'); navigator.mediaDevices.getUserMedia( { video: { deviceId: device_id, width: { ideal: $(window).width() }, height: { ideal: $(window).height() } } }) .then(on_stream_ready); } } $(function() { if (typeof(window.MediaRecorder) == 'undefined') { g_upload_videos = false; $("#user_agent").text(navigator.userAgent); $("#recorder-warning").removeClass('hidden'); } }); $(function() { if (typeof(navigator.mediaDevices) == 'undefined') { $("#no-camera-warning").removeClass('hidden'); if (window.location.protocol == 'http:') { var https_url = "https://" + window.location.hostname + window.location.pathname; $("#no-camera-warning").append("<p>You may need to switch to <a href='" + https_url + "'>" + https_url + "</a></p>"); } } else { navigator.mediaDevices.ondevicechange = function(event) { build_device_picker($("#device-picker"), /*include_remote*/true, on_device_selection, on_setup); }; } build_device_picker($("#device-picker"), /*include_remote*/true, on_device_selection); }); // Posts a message to the page running in the interior iframe. function announce_to_interior(msg) { document.querySelector("#interior").contentWindow.postMessage(msg, '*'); } function upload_video(root, blob) { if (blob) { console.log("Uploading video " + root + ".mkv"); let form_data = new FormData(); form_data.append('video', blob, root + ".mkv"); form_data.append('action', 'video.upload'); $.ajax("action.php", {type: 'POST', data: form_data, processData: false, contentType: false, success: function(data) { console.log('video upload success:'); console.log(data); } }); } } function on_replay(root) { console.log('* on_replay'); if (root != g_video_name_root) { console.log('** root=', root, ', g_video_name_root=', g_video_name_root); } // Capture this global variable before starting the asynchronous operation, // because it's reasonably likely to be clobbered by another queued message // from the server. var upload = g_upload_videos; // If this is a replay triggered after RACE_START, make sure we don't start // another replay for the same heat. if (g_replay_timeout > 0) { clearTimeout(g_replay_timeout); } g_replay_timeout = 0; g_recorder.stop_recording(); var delay = $("#delay")[0].valueAsNumber * 1000; if (delay > 0) { setTimeout(function() { start_playback(root, upload); }, delay); } else { console.log('Direct playback'); start_playback(root, upload); } } function start_playback(root, upload) { let playback = document.querySelector("#playback"); playback.width = $(window).width(); playback.height = $(window).height(); announce_to_interior('replay-started'); $("#playback-background").show('slide', function() { let playback_start_ms = Date.now(); let vc; // When the offscreen <canvas> is first created, we construct a // VideoCapture object to record its capture stream. After the first play // through, stop the VideoCapture and upload the resulting Blob. g_recorder.playback(playback, g_replay_options.count, g_replay_options.rate, function(pre_canvas) { if (upload && root != "") { vc = new VideoCapture(pre_canvas.captureStream()); } else if (!upload) { console.log("No video upload planned."); } else { console.log("No video root name specified; will not upload."); } }, function() { // The first time through, consume the captured // video and destroy the VideoCapture object. if (vc) { vc.stop(function(blob) { upload_video(root, blob); }); vc = null; } }, function() { $("#playback-background").hide('slide'); announce_to_interior('replay-ended'); g_recorder.start_recording(); }); }); } function on_proceed() { $("#interior").attr('src', $("#inner_url").val()); if (document.getElementById('go-fullscreen').checked) { if (screenfull.enabled) { // Temporarily remove resize handler while switching to fullscreen, to // avoid having to click "Proceed" again. $(window).off('resize'); screenfull.request(); setTimeout(function() { $(window).on('resize', function(event) { on_setup(); }); }, 2000); } } $("#replay-setup").hide('slide', {direction: 'down'}); $("#playback-background").hide('slide').removeClass('hidden'); $("#interior").removeClass('hidden'); $("#click-shield").removeClass('hidden'); } function on_setup() { $("#click-shield").addClass('hidden'); $("#replay-setup").show('slide', {direction: 'down'}); } $(window).on('resize', function(event) { on_setup(); }); </script> </head> <body> <div id="fps"></div> <div id="debug" <?php if (!isset($_GET['debug'])) echo 'class="hidden"'; ?> > <div id="log"> </div> </div> <iframe id="interior" class="hidden full-window"> </iframe> <div id="click-shield" class="hidden full-window" onclick="on_setup(); return false;" oncontextmenu="on_replay(); return false;"> </div> <div id="playback-background" class="hidden full-window"> <canvas id="playback" class="full-window"> </canvas> </div> <div id="replay-setup" class="full-window block_buttons"> <?php make_banner('Replay'); ?> <div id="recorder-warning" class="hidden"> <h2>This browser does not support MediaRecorder.</h2> <p>Replay is still possible, but you can't upload videos.</p> <p>Your browser's User Agent string is:<br/><span id="user_agent"></span></p> </div> <div id="no-camera-warning" class="hidden"> <h2 id='reject'>Access to cameras is blocked.</h2> </div> <div id="preview-container"> <video id="preview" autoplay="true" muted="true" playsinline="true"> </video> <div id="waiting-for-remote" class="hidden"> <p>Waiting for remote camera to connect...</p> </div> </div> <div id="device-picker-div"> <select id="device-picker"><option>Please wait</option></select> </div> <p id="recording-stream-info" class="hidden"> Recording at <span id="recording-stream-size"></span> </p> <div id="replay-setup-controls" style="margin-left: 25%; margin-right: 25%;"> <p> <input type="checkbox" id="go-fullscreen" checked="checked"/> <label for="go-fullscreen">Change to fullscreen?</label> </p> <label for="inner_url">URL:</label> <input type="text" name="inner_url" id="inner_url" size="50" value="<?php echo htmlspecialchars($kiosk_url, ENT_QUOTES, 'UTF-8'); ?>"/> <p style="font-size: 1em; margin-left: 10%;">Delay playback by: <input type="number" name="delay" id="delay" min="0" step="0.1" value="0.0" size="8" style="font-size: 1em; width: 5em; "/> (s) after heat ends </p> <input type="button" value="Proceed" onclick="on_proceed();"/> </div> </div> </body> </html>
php
MIT
07b0d7303c2d2563b7adfd8af1cabe389c114bac
2026-01-05T04:46:00.013344Z
false
jeffpiazza/derbynet
https://github.com/jeffpiazza/derbynet/blob/07b0d7303c2d2563b7adfd8af1cabe389c114bac/website/checkin.php
website/checkin.php
<?php @session_start(); ?> <?php require_once('inc/data.inc'); require_once('inc/authorize.inc'); session_write_close(); require_once('inc/banner.inc'); require_once('inc/car-numbering.inc'); require_once('inc/schema_version.inc'); require_once('inc/photo-config.inc'); require_once('inc/classes.inc'); require_once('inc/partitions.inc'); require_once('inc/locked.inc'); require_once('inc/checkin-table.inc'); require_permission(CHECK_IN_RACERS_PERMISSION); // This is the racer check-in page. It appears as a table of all the registered // racers, with a flipswitch for each racer. Clicking on the check-in button // invokes some javascript that sends an ajax POST request to check-in (or // un-check-in) that racer. See checkin.js. // In addition to the actual check-in, it's possible to change a // racer's car number from this form, or mark the racer for our // "exclusively by scout" award. // Here on the server side, a GET request sends HTML for the whole // page. POST requests to make changes to the database are sent to // action.php, and produce just a small XML document. // Our pack provides an "exclusively by scout" award, based on a // signed statement from the parent. Collecting the statement is part // of the check-in process, so there's provision for a checkbox on the // check-in form. For groups that don't do this, $xbs will be false // (and $xbs_award_name will be blank), and the checkboxes won't be // shown. $xbs = read_raceinfo_boolean('use-xbs'); $xbs_award_name = xbs_award(); $order = ''; if (isset($_GET['order']) && in_array($_GET['order'], ['name', 'class', 'car', 'partition'])) $order = $_GET['order']; if (!$order) $order = 'name'; // The table of racers can be presented in order by name, car, or class (and // then by name within the class). Each sortable column has a header which is a // link to change the ordering, with the exception that the header for the // column for ordering currently in use is NOT a link (because it wouldn't do // anything). function column_header($text, $o) { global $order; return "<a data-order='".$o."' " .($o == $order ? "" : " href='#'").">".$text."</a>"; } ?><!DOCTYPE html> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/> <title>Check-In</title> <link rel="stylesheet" type="text/css" href="css/dropzone.min.css"/> <link rel="stylesheet" type="text/css" href="css/mobile.css"/> <?php require('inc/stylesheet.inc'); ?> <link rel="stylesheet" type="text/css" href="css/main-table.css"/> <link rel="stylesheet" type="text/css" href="css/checkin.css"/> <script type="text/javascript" src="js/jquery.js"></script> <script type="text/javascript" src="js/jquery-ui.min.js"></script> <script type="text/javascript" src="js/qrcode.min.js"></script> <script type="text/javascript" src="js/ajax-setup.js"></script> <script type="text/javascript"> var g_order = '<?php echo $order; ?>'; var g_action_on_barcode = "<?php echo isset($_SESSION['barcode-action']) ? $_SESSION['barcode-action'] : "locate"; ?>"; var g_preferred_urls = <?php echo json_encode(preferred_urls(/*use_https=*/true), JSON_HEX_TAG | JSON_HEX_AMP | JSON_PRETTY_PRINT); ?>; function set_checkin_table_height() { $("#main-checkin-table-div").height( $(window).height() - $(".banner").height() - $("#top-buttons").height()); } $(function() { set_checkin_table_height(); }); $(window).on('resize', set_checkin_table_height); </script> <script type="text/javascript" src="js/mobile.js"></script> <script type="text/javascript" src="js/dashboard-ajax.js"></script> <script type="text/javascript" src="js/modal.js"></script> <script type="text/javascript" src="js/dropzone.min.js"></script> <script type="text/javascript" src="js/partitions-modal.js"></script> <script type="text/javascript" src="js/video-device-picker.js"></script> <script type="text/javascript" src="js/imagecapture.js"></script> <script type="text/javascript" src="js/photo-capture-modal.js"></script> <script type="text/javascript" src="js/find-racer.js"></script> <script type="text/javascript" src="js/checkin.js"></script> </head> <body> <?php make_banner('Racer Check-In'); ?> <div id="top-buttons" class="block_buttons"> <img id="barcode-button" src="img/barcode.png" onclick="handle_barcode_button_click()"/> <input id="mobile-button" type="button" value="Mobile" onclick="handle_qrcode_button_click()"/> <input class="bulk_button" type="button" value="Bulk" onclick='show_bulk_form();'/> <?php if (have_permission(REGISTER_NEW_RACER_PERMISSION)) { ?> <input type="button" value="New Racer" onclick='show_new_racer_form();'/> <?php } else { ?> <div style='padding: 10px 15px; font-size: x-large; line-height: 1.3; margin-bottom: 20px; margin-top: 3px; '>&nbsp;</div> <?php } ?> </div> <div id="main-checkin-table-div"> <table id="main-checkin-table" class="main_table"> <thead> <tr> <th/> <th><?php echo column_header(htmlspecialchars(partition_label(), ENT_QUOTES, 'UTF-8'), 'partition'); ?></th> <th><?php echo column_header('Car Number', 'car'); ?></th> <th>Photo</th> <th><?php echo column_header('Last Name', 'name'); ?></th> <th>First Name</th> <th>Car Name &amp; From</th> <th>Passed?</th> <?php if ($xbs) { echo '<th>'.$xbs_award_name.'</th>'; } ?> </tr> </thead> <tbody id="main_tbody"> </tbody> </table> </div> <?php $stmt = $db->query('SELECT partitionid, name,' .' (SELECT COUNT(*) FROM RegistrationInfo' .' WHERE RegistrationInfo.partitionid = Partitions.partitionid) AS count' .' FROM Partitions' .' ORDER BY sortorder'); $partitions = $stmt->fetchAll(PDO::FETCH_ASSOC); if (count($partitions) == 0) { // 0 won't be used as a partitionid, but will cause the server to create a new // partition with default name. $partitions[] = array('partitionid' => 0, 'name' => DEFAULT_PARTITION_NAME); } list($classes, $classseq, $ranks, $rankseq) = classes_and_ranks(); $sql = checkin_table_SELECT_FROM_sql() .' ORDER BY ' .($order == 'car' ? 'carnumber, lastname, firstname' : ($order == 'class' ? 'class_sort, rank_sort, lastname, firstname' : ($order == 'partition' ? 'partition_sortorder, lastname, firstname' : 'lastname, firstname'))); $stmt = $db->prepare($sql); $stmt->execute(array(':xbs_award_name' => xbs_award())); ?> <script> function addrow0(racer) { return add_table_row('#main_tbody', racer, <?php echo $xbs ? json_encode($xbs_award_name) : "false"; ?>); } <?php $n = 1; foreach ($stmt as $rs) { // TODO $rs['rankseq'] = $ranks[$rs['rankid']]['seq']; if (is_null($rs['note'])) { $rs['note'] = ''; } echo "addrow0(".json_encode(json_table_row($rs, $n), JSON_NUMERIC_CHECK | JSON_UNESCAPED_SLASHES | JSON_HEX_AMP | JSON_HEX_TAG | JSON_HEX_APOS).");\n"; ++$n; } ?> $(function () { var partitions = <?php echo json_encode($partitions, JSON_NUMERIC_CHECK | JSON_UNESCAPED_SLASHES | JSON_HEX_AMP | JSON_HEX_TAG | JSON_HEX_APOS); ?>; var partition_label_pl = <?php echo json_encode(partition_label_pl(), JSON_NUMERIC_CHECK | JSON_UNESCAPED_SLASHES | JSON_HEX_AMP | JSON_HEX_TAG | JSON_HEX_APOS); ?>; $("#edit_partition").empty(); for (var i in partitions) { var opt = $("<option/>") .attr('value', partitions[i].partitionid) .text(partitions[i].name); opt.appendTo("#edit_partition"); opt.clone().appendTo("#bulk_who"); } var opt = $("<option/>") .attr('value', -1) .text("(Edit " + partition_label_pl + ")"); opt.appendTo("#edit_partition"); opt.clone().appendTo("#bulk_who"); mobile_select_refresh($("#edit_partition")); mobile_select_refresh($("#bulk_who")); { var reorder_modal = PartitionsModal( "<?php echo htmlspecialchars(partition_label(), ENT_QUOTES, 'UTF-8'); ?>", "<?php echo htmlspecialchars(partition_label_pl(), ENT_QUOTES, 'UTF-8'); ?>", partitions, callback_after_partition_modal); $("#edit_partition").on('change', function(ev) { on_edit_partition_change(ev.target, reorder_modal); }); $("#bulk_who").on('change', function(ev) { on_edit_partition_change(ev.target, reorder_modal); }); } }); </script> <div id='edit_racer_modal' class="modal_dialog hidden block_buttons"> <form id="editracerform"> <div id="left-edit"> <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=""/> <label for="edit_carname">Car name:</label> <input id="edit_carname" type="text" name="edit_carname" value=""/> </div> <div id="right-edit"> <label for="edit_partition"> <?php echo htmlspecialchars(partition_label().':', ENT_QUOTES, 'UTF-8'); ?> </label> <!-- Populated by javascript --> <select id="edit_partition" data-wrapper-class="partition_mselect"></select> <label for="edit_note_from">From (if desired):</label> <input id="edit_note_from" type="text" name="edit_note_from" value=""/> <label for="eligible">Trophy eligibility:</label> <input type="checkbox" class="flipswitch" name="eligible" id="eligible" data-wrapper-class="trophy-eligible-flipswitch" data-off-text="Excluded" data-on-text="Eligible"/> <br/> <input type="submit"/> <input type="button" value="Cancel" onclick='close_modal("#edit_racer_modal");'/> <div id="delete_racer_extension"> <input type="button" value="Delete Racer" class="delete_button" onclick="handle_delete_racer();"/> </div> </div> <input id="edit_racer" type="hidden" name="racer" value=""/> </form> </div> <div id='photo_modal' class="modal_dialog hidden block_buttons"> <form id="photo_drop" class="dropzone"> <input type="hidden" name="action" value="photo.upload"/> <input type="hidden" id="photo_modal_repo" name="repo"/> <input type="hidden" id="photo_modal_racerid" name="racerid"/> <input type="hidden" name="MAX_FILE_SIZE" value="30000000" /> <h3>Capture <span id="racer_photo_repo"></span> photo for <span id="racer_photo_name"></span> </h3> <video id="preview" autoplay="true" muted="true" playsinline="true"></video> <div id="left-photo"> <?php if (headshots()->status() != 'ok') { echo '<p class="warning">Check <a href="settings.php">photo directory settings</a> before proceeding!</p>'; } ?> <div class="block_buttons"> <input type="submit" value="Capture &amp; Check In" id="capture_and_check_in" onclick='g_check_in = true;'/> <br/> <input type="submit" value="Capture Only" onclick='g_check_in = false;'/> <input type="button" value="Cancel" onclick='close_photo_modal();'/> </div> </div> <div id="right-photo"> <select id="device-picker"></select> <label id="autocrop-label" for="autocrop">Auto-crop after upload:</label> <div class="centered_flipswitch"> <input type="checkbox" class="flipswitch" name="autocrop" id="autocrop" checked="checked"/> </div> <div> <a id="thumb-link" class="button_link">To Photo Page</a> </div> </div> <div class="dz-message"><span>NOTE: You can drop a photo here to upload instead</span></div> </form> </div> <div id='bulk_modal' class="modal_dialog hidden block_buttons"> <input type="button" value="Bulk Check-In" onclick="bulk_check_in(true);"/> <input type="button" value="Bulk Check-In Undo" onclick="bulk_check_in(false);"/> <br/> <input type="button" value="Bulk Renumbering" onclick="bulk_numbering();"/> <input type="button" value="Bulk Eligibility" onclick="bulk_eligibility();"/> <br/> <input type="button" value="Cancel" onclick='close_modal("#bulk_modal");'/> </div> <div id="bulk_details_modal" class="modal_dialog hidden block_buttons"> <form id="bulk_details"> <h2 id="bulk_details_title"></h2> <label id="who_label" for="bulk_who">Assign car numbers to</label> <select id="bulk_who"> <option value="all">All</option> <!-- Replaced by javascript --> </select> <div id="numbering_controls" class="hidable"> <label for="number_auto">Numbering:</label> <input id="number_auto" name="number_auto" type="checkbox" class="flipswitch eligible-flip" checked="checked" data-wrapper-class="trophy-eligible-flipswitch" data-off-text="Custom" data-on-text="Standard"/> <?php list($car_numbering_mult, $car_numbering_smallest) = read_car_numbering_values(); ?> <div id="numbering_start_div" style="display: none"> <label for="bulk_numbering_start">Custom numbering from:</label> <input type="number" id="bulk_numbering_start" name="bulk_numbering_start" disabled="disabled" value="<?php echo $car_numbering_smallest; ?>"/> </div> <div id="bulk_numbering_explanation"> <p>Car numbers start at <?php echo $car_numbering_smallest; ?><?php if ($car_numbering_mult != 0) { ?><br/> and the hundreds place increments for each <?php echo partition_label_lc(); ?>. <?php } else { echo "."; } ?> </p> </div> </div> <div id="elibility_controls" class="hidable"> <label for="bulk_eligible">Trophy eligibility:</label> <input type="checkbox" class="flipswitch eligible-flip" checked="checked" name="bulk_eligible" id="bulk_eligible" data-wrapper-class="trophy-eligible-flipswitch" data-off-text="Excluded" data-on-text="Eligible"/> </div> <input type="submit"/> <input type="button" value="Cancel" onclick='pop_modal("#bulk_details_modal");'/> </form> </div> <div id="barcode_settings_modal" class="modal_dialog hidden block_buttons"> <form> <h2>Barcode Responses</h2> <input id="barcode-handling-locate" name="barcode-handling" type="radio" value="locate"/> <label for="barcode-handling-locate">Locate racer</label> <input id="barcode-handling-checkin" name="barcode-handling" type="radio" value="checkin"/> <label for="barcode-handling-checkin">Check in racer</label> <input id="barcode-handling-racer" name="barcode-handling" type="radio" value="racer-photo"/> <label for="barcode-handling-racer">Capture racer photo</label> <input id="barcode-handling-car" name="barcode-handling" type="radio" value="car-photo"/> <label for="barcode-handling-car">Capture car photo</label> <input type="submit" value="Close"/> </form> </div> <div id="qrcode_settings_modal" class="modal_dialog wide_modal hidden block_buttons"> <form id="mobile-checkin-form"> <h2>Mobile Check-In</h2> <div id="mobile-checkin-qrcode" style="width: 256px; margin-left: 122px;"></div> <div id="mobile-checkin-title" style="text-align: center; font-size: 1.5em; font-weight: bold; margin-bottom: 25px; margin-top: 10px;"></div> <input id="mobile-checkin-url" name="mobile-checkin-url" type="text" /> <a id="mcheckin-link" class="button_link" href="mcheckin.php">Mobile Check-In &gt;</a> <input type="button" value="Close" onclick="close_modal('#qrcode_settings_modal');"/> </form> </div> <?php require_once('inc/ajax-pending.inc'); ?> <div id="find-racer" class="hidden"> <div id="find-racer-form"> Find Racer: <input type="text" id="find-racer-text" name="narrowing-text" class="not-mobile"/> <span id="find-racer-message" ><span id="find-racer-index" data-index="1">1</span> of <span id="find-racer-count">0</span> </span> <img onclick="cancel_find_racer()" src="img/cancel-20.png"/> </div> </div> </body> </html>
php
MIT
07b0d7303c2d2563b7adfd8af1cabe389c114bac
2026-01-05T04:46:00.013344Z
false
jeffpiazza/derbynet
https://github.com/jeffpiazza/derbynet/blob/07b0d7303c2d2563b7adfd8af1cabe389c114bac/website/settings.php
website/settings.php
<?php session_start(); require_once('inc/data.inc'); require_once('inc/authorize.inc'); session_write_close(); require_once('inc/banner.inc'); require_once('inc/car-numbering.inc'); require_once('inc/partitions.inc'); require_once('inc/photo-config.inc'); require_once('inc/locked.inc'); require_once('inc/default-database-directory.inc'); require_once('inc/name-mangler.inc'); require_once('inc/photos-on-now-racing.inc'); require_once('inc/pick_image_set.inc'); require_once('inc/xbs.inc'); require_permission(SET_UP_PERMISSION); $schedules_exist = read_single_value('SELECT COUNT(*) FROM RaceChart' .' WHERE COALESCE(completed, \'\') = \'\''); ?><!DOCTYPE html> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/> <title>Pinewood Derby Race Settings</title> <?php require('inc/stylesheet.inc'); ?> <link rel="stylesheet" type="text/css" href="css/mobile.css"/> <link rel="stylesheet" type="text/css" href="css/chooser.css"/> <link rel="stylesheet" type="text/css" href="css/settings.css"/> <?php if ($schedules_exist) { ?> <style type="text/css"> .track-settings { border-left: 30px solid red; padding-left: 30px; border-top: 5px solid red; border-bottom: 5px solid red; } .settings_group .track-settings .warning { display: block; visibility: visible; width: 100px; padding: 11px; /* margin-top: 0px; */ margin-right: 0px; float: right; font-size: 18px; font-weight: bold; background-color: red; } </style> <?php } ?> <script type="text/javascript" src="js/jquery.js"></script> <script type="text/javascript" src="js/ajax-setup.js"></script> <script type="text/javascript" src="js/mobile.js"></script> <script type="text/javascript" src="js/modal.js"></script> <script type="text/javascript" src="js/dashboard-ajax.js"></script> <script type="text/javascript" src="js/chooser.js"></script> <script type="text/javascript" src="js/settings.js"></script> <script type="text/javascript"> // Returns a string identifying the directory at which browsing for photo // directories should start. See js/settings.js' browse_for_photo_directory(). function photo_directory_base() { <?php if (isset($db_connection_string) && substr($db_connection_string, 0, 7) == 'sqlite:') { echo 'return '.json_encode(substr($db_connection_string, 7)).';'; } else { $default_path = default_database_directory(); if (!empty($default_path)) { echo 'return '.json_encode($default_path.DIRECTORY_SEPARATOR).';'; } else { echo 'return "";'; } } ?> } </script> </head> <body> <?php make_banner('Settings', 'setup.php'); $use_subgroups = use_subgroups(); $use_xbs = read_raceinfo_boolean('use-xbs'); $xbs_award = xbs_award(); $use_master_sched = read_raceinfo_boolean('use-master-sched'); $upload_videos = read_raceinfo_boolean('upload-videos'); $photos_on_now_racing = read_photos_on_now_racing(); $show_car_photos_on_deck = read_raceinfo_boolean('show-cars-on-deck'); $show_racer_photos_rr = read_raceinfo_boolean('show-racer-photos-rr'); $show_car_photos_rr = read_raceinfo_boolean('show-car-photos-rr'); $locked_settings = locked_settings(); $name_style = read_name_style(); $finish_formatting = get_finishtime_formatting_string(); if (read_raceinfo('drop-slowest') && read_raceinfo('scoring', -1) == -1) { write_raceinfo('scoring', 1); } $scoring = read_raceinfo('scoring', 0); list($car_numbering_mult, $car_numbering_smallest) = read_car_numbering_values(); if (read_raceinfo('max-runs-per-car', 0) != 0) { $schedule_method = 'abbreviated'; } else if (read_raceinfo_boolean('rotation-schedule')) { $schedule_method = 'rotation'; } else { $schedule_method = 'normal'; } ?> <div class="block_buttons"> <form id="settings_form"> <div class="settings_group"> <div class="settings_group_image"> <img src="img/settings-timer.png"/> </div> <div class="settings_group_settings"> <p> <input id="warn-no-timer" name="warn-no-timer" class="not-mobile" type="checkbox"<?php if (warn_no_timer()) echo ' checked="checked"';?>/> <label title="Enable this if you plan to enter times manually or use with GPRM. It will remove the warning from the 'now racing' dashboard regarding the timer not being connected."> Warn when timer not connected</label> </p> <div class="track-settings"> <p class="warning hidden">Racing schedules already exist.</p> <p> <input id="n-lanes" name="n-lanes" type="number" min="0" max="20" class="not-mobile" <?php if ($schedules_exist) echo 'disabled="disabled"'; ?> value="<?php echo get_lane_count(); ?>"/> <label for="n-lanes">Number of lanes on the track.</label> </p> <p> <input type="hidden" id="unused-lane-mask" name="unused-lane-mask" <?php if ($schedules_exist) echo 'disabled="disabled"'; ?> value="<?php echo read_raceinfo('unused-lane-mask', 0); ?>"/> Lanes available for scheduling:</p> <p> <span id="lanes-in-use"></span> </p> </div> <p> <input id="reverse-lanes" name="reverse-lanes" class="not-mobile" type="checkbox"<?php if (read_raceinfo_boolean('reverse-lanes')) echo ' checked="checked"';?>/> <label for="reverse-lanes">Number lanes in reverse</label> <a href="#" class="small-button" style="margin-left: 20px;" onclick="on_set_lane_colors_click(); return false;">Set Lane Colors</a> <input type="hidden" id="lane-colors" name="lane-colors" value="<?php echo read_raceinfo('lane-colors', ''); ?>"/> </p> <p> <input id="track-length" name="track-length" type="number" min="0" max="999" class="not-mobile" value="<?php echo read_raceinfo('track-length', 40); ?>"/> <label for="track-length">Track length (in feet)</label> </p> <p>Displayed time precision: <input type="radio" name="finish-formatting" value="%5.3f" id="finish-formatting-3" class="not-mobile"<?php echo $finish_formatting == "%5.3f" ? ' checked="checked"' : ''; ?>/><label for="finish-formatting-3">4 digits (0.001)</label>&nbsp; <input type="radio" name="finish-formatting" value="%6.4f" id="finish-formatting-4" class="not-mobile"<?php echo $finish_formatting == "%6.4f" ? ' checked="checked"' : ''; ?>/><label for="finish-formatting-4">5 digits (0.0001)</label> </p> <p> <label for="now-racing-linger-sec">Previous heat linger time (sec.) for "Now Racing"</label> <input type="hidden" id="now-racing-linger-ms" name="now-racing-linger-ms" value="<?php echo read_raceinfo('now-racing-linger-ms', 10000); ?>"/> <input type="number" id="now-racing-linger-sec" name="now-racing-linger-sec" value="<?php echo sprintf("%0.1f", read_raceinfo('now-racing-linger-ms', 10000) / 1000); ?>" step="0.1" class="do-not-post not-mobile" style="width: 100px;"/> </p> </div> </div> <div class="settings_group"> <div class="settings_group_image"> <img src="img/settings-groups.png"/> </div> <div class="settings_group_settings"> <p> <label for="supergroup-label">The full roster is a (or the)</label> <input id="supergroup-label" name="supergroup-label" type="text" class="not-mobile" value="<?php echo htmlspecialchars( supergroup_label(), ENT_QUOTES, 'UTF-8'); ?>"/>, </p> <p> <label for="partition-label">and a sub-division is a(n)</label> <input id="partition-label" name="partition-label" type="text" class="not-mobile" value="<?php echo htmlspecialchars(partition_label(), ENT_QUOTES, 'UTF-8'); ?>"/>. </p> <p>Show racer names as:<br/> <input type="radio" name="name-style" value="0" id="name-style-0" class="not-mobile"<?php echo $name_style == FULL_NAME ? ' checked="checked"' : ''; ?>/><label for="name-style-0">First name and last name</label><br/> <input type="radio" name="name-style" value="1" id="name-style-1" class="not-mobile"<?php echo $name_style == FIRST_NAME_LAST_INITIAL ? ' checked="checked"' : ''; ?>/><label for="name-style-1">First name and last initial</label> </p> <p> <input type="hidden" id="car-numbering" name="car-numbering" value="<?php echo read_raceinfo('car-numbering', '100+101'); ?>"/> Assigned car numbers start at <input type="radio" id="number-from-101" name="number-from" value="101" class="do-not-post not-mobile"<?php echo $car_numbering_smallest == 101 ? ' checked="checked"' : ''; ?>/><label for="number-from-101">101</label> <input type="radio" id="number-from-1" name="number-from" value="1" class="do-not-post not-mobile"<?php echo $car_numbering_smallest == 1 ? ' checked="checked"' : ''; ?>/><label for="number-from-1">1</label><br/>&nbsp; and <input type="checkbox" id="number-by-segment" name="number-by-segment" class="do-not-post not-mobile" <?php echo $car_numbering_mult == 0 ? '' : ' checked="checked"'; ?>/> <label for="number-by-segment">the hundreds place increments for each <span class="partition-label"><?php echo partition_label_lc(); ?></span>. </label> </p> </div> </div> <div class="settings_group"> <div class="settings_group_image"> <img src="img/settings-gold-medal.png"/> </div> <div class="settings_group_settings"> <p> <input id="n-pack" name="n-pack-trophies" type="number" min="0" max="20" class="not-mobile" value="<?php echo read_raceinfo('n-pack-trophies', 3); ?>"/> <label for="n-pack">Number of speed trophies at the <span class="supergroup-label"><?php echo supergroup_label_lc(); ?></span> level</label> </p> <p> <input id="n-den" name="n-den-trophies" type="number" min="0" max="20" class="not-mobile" value="<?php echo read_raceinfo('n-den-trophies', 3); ?>"/> <label for="n-den">Number of speed trophies per group</label> </p> <p> <input id="n-rank" name="n-rank-trophies" type="number" min="0" max="20" class="not-mobile" value="<?php echo read_raceinfo('n-rank-trophies', 0); ?>"/> <label for="n-rank">Number of speed trophies per subgroup</label> </p> <p> <input id="one-trophy-per" name="one-trophy-per" class="not-mobile" type="checkbox"<?php if (read_raceinfo_boolean('one-trophy-per')) echo ' checked="checked"';?>/> <label>At most one trophy per racer?</label> </p> <p> <input id="use-xbs" name="use-xbs" class="not-mobile" type="checkbox"<?php if ($use_xbs) echo ' checked="checked"';?>/> <label>Offer "Exclusively By Scout" award?</label> </p> <p> <input id="xbs-award" name="xbs-award" type="text" class="not-mobile" value="<?php echo htmlspecialchars($xbs_award, ENT_QUOTES, 'UTF-8'); ?>"/> <label for="xbs-award">"Exclusively By Scout" award name (if used)</label> </p> </div> </div> <?php function photo_settings($purpose, $photo_dir_id, $photo_dir_value) { if (!locked_settings()) { echo "<p>\n"; echo '<label for="'.$photo_dir_id.'">Directory for '.$purpose.':</label>'."\n"; echo '<input id="'.$photo_dir_id.'" name="'.$photo_dir_id.'" type="text" class="not-mobile"' .' size="50"' .' value="'.htmlspecialchars($photo_dir_value, ENT_QUOTES, 'UTF-8').'"/>'."\n"; echo '<span id="'.$photo_dir_id.'_icon" class="status_icon"></span>'."\n"; echo '</p>'; echo '<p class="photo_dir_status_message" id="'.$photo_dir_id.'_message"></p>'; echo '<p>'; echo '<span class="photo_dir_choose"><input type="button" value="Browse"' .' class="not-mobile"' .' onclick="browse_for_photo_directory(\'#'.$photo_dir_id.'\')"/>' .'</span>'."\n"; echo "</p>\n"; } } ?> <div class="settings_group"> <div class="settings_group_image"> <img src="img/settings-photos.png"/> </div> <div class="settings_group_settings"> <p id='images-dir-p'> <label for='images-dir'>Image set:</label> <?php emit_images_dir_select("id='images-dir' name='images-dir'"); ?> </p> <p><b>Now Racing</b> display:<br/>&nbsp;&nbsp; <input type="radio" name="photos-on-now-racing" value="0" id="now-racing-photos-0" class="not-mobile"<?php echo $photos_on_now_racing ? '' : ' checked="checked"'; ?>/><label for="now-racing-photos-0">No photos</label>&nbsp; <input type="radio" name="photos-on-now-racing" value="head" id="now-racing-photos-head" class="not-mobile"<?php echo $photos_on_now_racing == "head" ? ' checked="checked"' : ''; ?>/><label for="now-racing-photos-head">Racer photos</label>&nbsp; <input type="radio" name="photos-on-now-racing" value="car" id="now-racing-photos-car" class="not-mobile"<?php echo $photos_on_now_racing == "car" ? ' checked="checked"' : ''; ?>/><label for="now-racing-photos-car">Car photos</label> </p> <p><b>On Deck</b> display:<br/>&nbsp;&nbsp; <input id="show-car-photos-on-deck" name="show-car-photos-on-deck" class="not-mobile" type="checkbox"<?php if ($show_car_photos_on_deck) echo ' checked="checked"';?>/> <label>Car photos</label> </p> <p><b>Racer Results</b> display:<br/>&nbsp;&nbsp; <input id="show-racer-photos-rr" name="show-racer-photos-rr" class="not-mobile" type="checkbox"<?php if ($show_racer_photos_rr) echo ' checked="checked"';?>/> <label>Racer photos</label>&nbsp; <input id="show-car-photos-rr" name="show-car-photos-rr" class="not-mobile" type="checkbox"<?php if ($show_car_photos_rr) echo ' checked="checked"';?>/> <label>Car photos</label> </p> <?php photo_settings('racer photos', 'photo-dir', photo_directory()); ?> <?php photo_settings('car photos', 'car-photo-dir', car_photo_directory()); ?> <p> <input id="upload-videos" name="upload-videos" class="not-mobile" type="checkbox"<?php if ($upload_videos) echo ' checked="checked"';?>/> <label>Upload replay videos?</label> </p> <?php photo_settings('videos', 'video-dir', read_raceinfo('video-directory')); ?> </div> </div> <div class="settings_group"> <div class="settings_group_image"> <img src="img/settings-rulebook.png"/> </div> <div class="settings_group_settings"> <p> <input id="use-master-sched" name="use-master-sched" class="not-mobile" type="checkbox"<?php if ($use_master_sched) echo ' checked="checked"';?>/> <label>Interleave heats from different <?php echo group_label_lc(); ?>s</label> </p> <p> <input id="use-points" name="use-points" class="not-mobile" type="checkbox"<?php if (read_raceinfo_boolean('use-points')) echo ' checked="checked"';?>/> <label>Race by points (place) instead of by times?</label> </p> <p>Scoring method:</p> <input type='radio' name='scoring' id='scoring_avg' value='0' class="not-mobile" <?php if ($scoring == 0) echo 'checked="checked"'; ?>/> <label for='scoring_avg'>Average all heat times</label><br/> <input type='radio' name='scoring' id='scoring_drop' value='1' class="not-mobile" <?php if ($scoring == 1) echo 'checked="checked"'; ?>/> <label for='scoring_avg'>Drop slowest heat</label><br/> <input type='radio' name='scoring' id='scoring_fastest' value='2' class="not-mobile" <?php if ($scoring == 2) echo 'checked="checked"'; ?>/> <label for='scoring_avg'>Take single fastest heat</label> <p> <a href="#" class="small-button" style="width: 200px;" onclick="on_scheduling_method_click(); return false;">Change Scheduling Method</a> </p> </div> </div> </form> </div> <div id="lane_colors_modal" class="modal_dialog hidden block_buttons"> <p>Some tracks mark lanes by color rather than number.</p> <input id='lane-colors' name='lane-colors' type='hidden' /> <form id="lane_colors_modal_form"> </form> </div> <div id="scheduling_method_modal" class="modal_dialog wide_modal hidden block_buttons"> <p>Scheduling method:</p> <input type='radio' name='schedule-method' id='schedule-method-normal' value='normal' class="do-not-post not-mobile" <?php if ($schedule_method == 'normal') echo 'checked="checked"'; ?>/> <label for='schedule-method-normal'>Normal scheduling</label> <p class="schedule_method_note">Prefer this unless you have a reason to need one of the other choices.</p> <input type='radio' name='schedule-method' id='schedule-method-abbreviated' value='abbreviated' class="do-not-post not-mobile" <?php if ($schedule_method == 'abbreviated') echo 'checked="checked"'; ?>/> <label for='schedule-method-abbreviated'>Abbreviated single-run-per-car schedule</label> <p class="schedule_method_note">Each car runs just once in a round. Sometimes useful for preiminary rounds if you have a very large field.</p> <input type='radio' name='schedule-method' id='schedule-method-rotation' value='rotation' class="do-not-post not-mobile" <?php if ($schedule_method == 'rotation') echo 'checked="checked"'; ?>/> <label for='schedule-method-rotation'>Lane rotation scheduling</label> <p class="schedule_method_note">Cars shift over one lane for each heat, e.g., A-B-C-D is followed by B-C-D-E, then C-D-E-F, etc. Racers meet fewer competitors head to head, but this method may be slightly easier for an inexperienced race crew to manage.</p> <input id="max-runs-per-car" type="hidden" name="max-runs-per-car" value="<?php echo read_raceinfo("max-runs-per-car", 0); ?>"/> <input id="rotation-schedule" type="hidden" name="rotation-schedule" value="<?php echo (read_raceinfo_boolean('rotation-schedule')) ? "1" : "0";?>"/> <form id="scheduling_method_modal_form"> <input type='submit' value='Close'/> </form> </div> <?php require('inc/chooser.inc'); ?> </body> </html>
php
MIT
07b0d7303c2d2563b7adfd8af1cabe389c114bac
2026-01-05T04:46:00.013344Z
false
jeffpiazza/derbynet
https://github.com/jeffpiazza/derbynet/blob/07b0d7303c2d2563b7adfd8af1cabe389c114bac/website/import-snapshot.php
website/import-snapshot.php
<?php @session_start(); require_once('inc/data.inc'); require_once('inc/authorize.inc'); session_write_close(); require_once('inc/banner.inc'); require_permission(SET_UP_PERMISSION); ?><!DOCTYPE html> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/> <title>Import Snapshot</title> <?php require('inc/stylesheet.inc'); ?> <link rel="stylesheet" type="text/css" href="css/import-snapshot.css"/> <script type="text/javascript" src="js/jquery.js"></script> <script type="text/javascript" src="js/ajax-setup.js"></script> <script type="text/javascript" src="js/import-snapshot.js"></script> </head> <body> <?php make_banner('Import Database Snapshot', 'setup.php'); ?> <div class="warning"> <span class="red">WARNING:</span> Importing a database snapshot<br/> will <b>delete</b> all the data<br/> that's currently in the database. </div> <form id="upload-form"> <input type="hidden" name="action" value="snapshot.put"/> <div class="file_target"> <input type="file" id="snapshot_file" name="snapshot"/> <label for="snapshot_file"> <div id="drop_img"><img src="img/drop.png"/></div> <div id="please_select_message"> Please select a previously-exported snapshot to import<br/>or drag it here. </div> </label> <div id="filepath"></div> </div> <p>&nbsp;</p> <div class="block_buttons"> <input type="submit" id="submit-snapshot"/> </div> </form> <?php require_once('inc/ajax-pending.inc'); require_once('inc/ajax-failure.inc'); ?> </body> </html>
php
MIT
07b0d7303c2d2563b7adfd8af1cabe389c114bac
2026-01-05T04:46:00.013344Z
false
jeffpiazza/derbynet
https://github.com/jeffpiazza/derbynet/blob/07b0d7303c2d2563b7adfd8af1cabe389c114bac/website/fakeroster.php
website/fakeroster.php
<?php @session_start(); ?> <?php require_once('inc/data.inc'); require_once('inc/authorize.inc'); session_write_close(); require_once('inc/banner.inc'); require_once('inc/partitions.inc'); require_once('inc/plural.inc'); require_permission(CHECK_IN_RACERS_PERMISSION); ?><!DOCTYPE html> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/> <title>Build Fake Roster</title> <?php require('inc/stylesheet.inc'); ?> <script type="text/javascript" src="js/jquery.js"></script> <script type="text/javascript" src="js/mobile.js"></script> <script type="text/javascript"> function make_the_fake_racers() { console.log('make_the_fake_racers'); $.ajax("action.php", {type: 'POST', data: {action: 'racer.fake', ngroups: Number($("#ngroups").val()), racers_per_group: Number($("#racers_per_group").val()), check_in: $("#check_in_all").is(':checked') ? 1 : 0}, success: function(data) { console.log('success'); // Jump to the check-in page window.location.href = "checkin.php"; } }); return false; } $(function() { $("#do_it").on('click', function() { make_the_fake_racers(); }); }); </script> <style type="text/css"> div input { font-size: 1em; } </style> </head> <body> <?php make_banner('Build Fake Roster', 'setup.php'); ?> <p>This page allows you to manufacture a roster of made-up racers.</p> <p>A fake roster lets you experiment with the software without having to gather a list of your real racers.</p> <p>The fake roster is randomly generated and reflects a typical race-by-den structure. It includes fake racer and car images.</p> <p>You can purge the fake roster data by <b>returning to the Set-Up page</b>.</p> <div style="margin-left: 20px; font-size: 24px;"> Generate <input id="ngroups" type="number" min="1" max="10" class="not-mobile" value="6"/> <?php echo plural(group_label()); ?> <br/> of approximately <input id="racers_per_group" type="number" min="2" max="20" class="not-mobile" value="5"/> fake racers each. <br/> <p> <input id="check_in_all" type="checkbox" checked="checked"/> <label for="check_in_all">Fake racers have passed inspection</label> </p> <br/> <div class="block_buttons" style="width: 350px;"> <input id="do_it" type="button" value="Make Fake Racers"/> </div> </div> <div id="attributions" style="position: fixed; bottom: 0;"> Some fake racer images came from one or more of these sources: <br/> <a href="https://www.vecteezy.com/free-vector/artwork">Artwork Vectors by Vecteezy</a> <br/> <a href="https://www.vecteezy.com/free-vector/portrait">Portrait Vectors by Vecteezy</a> <br/> <a href="https://www.vecteezy.com/free-vector/doodle">Doodle Vectors by Vecteezy</a> <br/> <a href="https://www.vecteezy.com/free-vector/family">Family Vectors by Vecteezy</a> <br/> <a href="https://www.vecteezy.com/free-vector/race-car">Race Car Vectors by Vecteezy</a> <br/> <a href="https://www.vecteezy.com/free-vector/race-car">Race Car Vectors by Vecteezy</a> <br/> <a href="https://www.vecteezy.com/free-vector/car">Car Vectors by Vecteezy</a> <br/> <a href="https://www.vecteezy.com/free-vector/cardboard-box">Cardboard Box Vectors by Vecteezy</a> </div> </body> </html>
php
MIT
07b0d7303c2d2563b7adfd8af1cabe389c114bac
2026-01-05T04:46:00.013344Z
false
jeffpiazza/derbynet
https://github.com/jeffpiazza/derbynet/blob/07b0d7303c2d2563b7adfd8af1cabe389c114bac/website/export-json.php
website/export-json.php
<?php @session_start(); require_once('inc/authorize.inc'); session_write_close(); require_once('inc/export-all.inc'); require_permission(VIEW_RACE_RESULTS_PERMISSION); header('Content-Type: application/json'); echo json_encode(export_all(), JSON_PRETTY_PRINT); echo "\n"; ?>
php
MIT
07b0d7303c2d2563b7adfd8af1cabe389c114bac
2026-01-05T04:46:00.013344Z
false
jeffpiazza/derbynet
https://github.com/jeffpiazza/derbynet/blob/07b0d7303c2d2563b7adfd8af1cabe389c114bac/website/render-document.php
website/render-document.php
<?php session_start(); require_once('inc/data.inc'); session_write_close(); // Usage e.g. /derbynet/print.php/racer/CarTagsDocument // ["DOCUMENT_URI"]=> "/derbynet/pack153/2019/render-document.php/racer/CarTagsDocument" // ["SCRIPT_NAME"]=> "/derbynet/pack153/2019/render-document.php" // We're trying to extract the "racer/CarTagsDocument" part into $args variable function confirm_args($str) { $ex = explode('/', $str); while (count($ex) > 0 && $ex[0] == '') { array_shift($ex); } if (count($ex) == 0) { return false; } return file_exists(__DIR__.'/print/render/'.$ex[0].'.inc'); } $have_args = false; if (!$have_args && isset($_SERVER['DOCUMENT_URI']) && isset($_SERVER['SCRIPT_NAME']) && substr($_SERVER['DOCUMENT_URI'], 0, strlen($_SERVER['SCRIPT_NAME'])) == $_SERVER['SCRIPT_NAME']) { $args = substr($_SERVER['DOCUMENT_URI'], strlen($_SERVER['SCRIPT_NAME'])); $have_args = confirm_args($args); } if (!$have_args && isset($_SERVER['PATH_INFO'])) { $args = $_SERVER['PATH_INFO']; $have_args = confirm_args($args); } if (!$have_args && isset($_SERVER['ORIG_PATH_INFO'])) { // Rewrite rules e.g. for hosted DerbyNet may leave ORIG_PATH_INFO instead of PATH_INFO $args = $_SERVER['ORIG_PATH_INFO']; $have_args = confirm_args($args); } /* 'DOCUMENT_URI' => '/render-document.php/racer/CarTagsDocument', 'SCRIPT_NAME' => '/render-document.php/racer/CarTagsDocument', 'SCRIPT_FILENAME' => '/var/www/html/render-document.php', 'PATH_TRANSLATED' => '/var/www/html', 'PHP_SELF' => '/render-document.php/racer/CarTagsDocument', 'DOCUMENT_ROOT' => '/var/www/html', */ if (!$have_args && isset($_SERVER['PHP_SELF']) && isset($_SERVER['DOCUMENT_ROOT']) && isset($_SERVER['SCRIPT_FILENAME']) && substr($_SERVER['SCRIPT_FILENAME'], 0, strlen($_SERVER['DOCUMENT_ROOT'])) == $_SERVER['DOCUMENT_ROOT'] && substr($_SERVER['PHP_SELF'], 0, strlen($_SERVER['SCRIPT_FILENAME']) - strlen($_SERVER['DOCUMENT_ROOT'])) == substr($_SERVER['SCRIPT_FILENAME'], strlen($_SERVER['DOCUMENT_ROOT']))) { $args = substr($_SERVER['PHP_SELF'], strlen($_SERVER['SCRIPT_FILENAME']) - strlen($_SERVER['DOCUMENT_ROOT'])); $have_args = confirm_args($args); } if (!$have_args) { // echo "Debugging \$_SERVER:\n"; // var_export($_SERVER); exit(0); } $exploded = explode('/', $args); while ($exploded[0] == '') { array_shift($exploded); } $inc = array_shift($exploded); function document_class() { global $exploded; return $exploded[0]; } function new_document() { $doc_class = document_class(); return new $doc_class; } // Use windows-1252 encodings in the PDF to display correctly function convert($s) { return iconv('UTF-8', 'windows-1252', $s); } function convert_strings(&$row) { foreach ($row as $key => $value) { if (is_string($value)) { $row[$key] = iconv('UTF-8', 'windows-1252', $value); } } } function clean_fake_photos(&$row) { // "Fake" roster includes svg files, but fpdf doesn't support them if (isset($row['imagefile']) && substr($row['imagefile'], -4) == '.svg') { $row['imagefile'] = ''; } if (isset($row['carphoto']) && substr($row['carphoto'], -4) == '.svg') { $row['carphoto'] = ''; } } require_once('print/render/'.$inc.'.inc'); ?>
php
MIT
07b0d7303c2d2563b7adfd8af1cabe389c114bac
2026-01-05T04:46:00.013344Z
false
jeffpiazza/derbynet
https://github.com/jeffpiazza/derbynet/blob/07b0d7303c2d2563b7adfd8af1cabe389c114bac/website/slide.php
website/slide.php
<?php session_start(); // Serve image files out of the Images directory, according to the current images-dir setting. require_once('inc/data.inc'); session_write_close(); require_once('inc/path-info.inc'); require_once('inc/photo-config.inc'); // path_info (URL) should be: // slide.php/title (no extension for title slide) // or // slide.php/my-great-slide.png $exploded = explode('/', urldecode(path_info())); if (count($exploded) == 3 && is_acceptable_subdir($exploded[2])) { $exploded[1] = $exploded[1].DIRECTORY_SEPARATOR.$exploded[2]; array_pop($exploded); } if (count($exploded) != 2) { // Not for probing around the file system exit(1); } $glob = $exploded[1]; if ($glob == 'title') { $glob = 'title.*'; } $file_path = slide_file_path($glob); if (is_readable($file_path)) { // Cache renewal required every 2 minutes (120 seconds), to get most of the // benefit of caching while allowing changing image sets in a "reasonable" // amount of time. header('Cache-Control: max-age=120, public'); header('Expires: '.gmdate('D, d M Y H:i:s', time() + 120).' GMT'); header('Content-type: '.pseudo_mime_content_type($file_path)); readfile($file_path); } else { header('File-path: '.$file_path); header('file_exists: '.file_exists($file_path)); header('file: '.filesize($file_path)); echo "Can't read file ".$file_path; } ?>
php
MIT
07b0d7303c2d2563b7adfd8af1cabe389c114bac
2026-01-05T04:46:00.013344Z
false
jeffpiazza/derbynet
https://github.com/jeffpiazza/derbynet/blob/07b0d7303c2d2563b7adfd8af1cabe389c114bac/website/racing-groups.php
website/racing-groups.php
<?php @session_start(); require_once('inc/data.inc'); require_once('inc/authorize.inc'); session_write_close(); require_once('inc/classes.inc'); require_once('inc/banner.inc'); require_once('inc/partitions.inc'); require_once('inc/schema_version.inc'); require_permission(SET_UP_PERMISSION); if (schema_version() < PARTITION_SCHEMA) { header('Location: setup.php'); exit(0); } ?><!DOCTYPE html> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/> <title>Racing Groups Editor</title> <?php require('inc/stylesheet.inc'); ?> <script type="text/javascript" src="js/jquery.js"></script> <script type="text/javascript" src="js/jquery-ui.min.js"></script> <script type="text/javascript" src="js/ajax-setup.js"></script> <script type="text/javascript" src="js/jquery.ui.touch-punch.min.js"></script> <script type="text/javascript" src="js/dashboard-ajax.js"></script> <script type="text/javascript" src="js/mobile.js"></script> <script type="text/javascript" src="js/modal.js"></script> <script type="text/javascript" src="js/racing-groups.js"></script> <script type="text/javascript" src="js/racing-groups-add.js"></script> <script type="text/javascript" src="js/racing-groups-edit.js"></script> <script type="text/javascript"> $(function() { var rule = <?php echo json_encode(group_formation_rule()); ?>; $("input[name='form-groups-by'][value='" + rule + "']").prop('checked', true); mobile_radio_refresh($("input[name='form-groups-by']")); }); </script> <link rel="stylesheet" type="text/css" href="css/mobile.css"/> <link rel="stylesheet" type="text/css" href="css/racing-groups.css"/> </head> <body> <?php make_banner('Racing Groups', 'setup.php'); ?> <div id="below-banner"> <div id="race-rules"> <input id="by-partition-radio" type="radio" name="form-groups-by" value="by-partition"/> <label for="by-partition-radio">Race each <span class="partition-label-lc"><?php echo partition_label_lc(); ?></span> as a group</label> <input id="one-group-radio" type="radio" name="form-groups-by" value="one-group"/> <label for="one-group-radio">Race as one big group</label> <input id="custom-group-radio" type="radio" name="form-groups-by" value="custom"/> <label for="custom-group-radio">Custom racing groups</label> <div class="switch"> <label for="use-subgroups">Use Subgroups?</label> <input id="use-subgroups" type="checkbox" class="flipswitch" data-on-text="Yes" data-off-text="No" <?php if (use_subgroups()) echo "checked=\"checked\""; ?>/> </div> <div class="labels"> <label for="supergroup-label">The full roster is a (or the)</label> <input id="supergroup-label" name="supergroup-label" type="text" class="not-mobile" value="<?php echo supergroup_label(); ?>"/>, <label for="partition-label">and a sub-division is a(n)</label> <input id="partition-label" name="partition-label" type="text" class="not-mobile" value="<?php echo partition_label(); ?>"/>. </div> <h3>Awards</h3> <div class="n_default_trophies"> <input id="n-pack" name="n-pack-trophies" type="number" min="0" max="20" class="not-mobile" value="<?php echo read_raceinfo('n-pack-trophies', 3); ?>"/> <label for="n-pack">speed trophies at the <span class="supergroup-label"><?php echo supergroup_label_lc(); ?></span> level</label> </div> <div id="pack_agg_div"> <span class="supergroup-label"><?php echo supergroup_label(); ?></span> standings: <br/> <input id="pack-ok" type="radio" name="pack-agg" class="not-mobile" value="0"/> <label for="pack-ok">Calculate normally</label> <br/> <input id="pack-no" type="radio" name="pack-agg" class="not-mobile" value="-1"/> <label for="pack-no"><span id="dimmable-for-pack-no"><?php echo "Don't calculate"; ?></span> <span id="why-not-pack-no">(needed for <span class="supergroup-label"><?php echo supergroup_label(); ?></span> trophies)</span></label> <!-- div pack-agg-option --> </div> <div class="n_default_trophies"> <input id="n-den" name="n-den-trophies" type="number" min="0" max="20" class="not-mobile" value="<?php echo read_raceinfo('n-den-trophies', 3); ?>"/> <label for="n-den">speed trophies per group</label> </div> <div class="n_default_trophies"> <input id="n-rank" name="n-rank-trophies" type="number" min="0" max="20" class="not-mobile" value="<?php echo read_raceinfo('n-rank-trophies', 0); ?>"/> <label for="n-rank">speed trophies per subgroup</label> </div> </div><!-- race-rules --> <div id="race-structure"> <p class="instructions" id="drag-groups">Drag <span class="group-color">&nbsp;</span> groups to reorder.</p> <p class="instructions" id="drag-subgroups">Drag <span class="subgroup-color">&nbsp;</span> subgroups to reorder<span id="or-to-move"> or to move to another group</span>.</p> <ul id="all-groups"> <li id='new-group' class='group' data-classid="-1"> <p class='class-name'>New Group</p> <ul class='subgroups'></ul> </li> </ul> <div class="block_buttons add_button"> <input id="add-partition-button" class="modest-button" type="button" value="Add <?php echo partition_label(); ?>"/> </div> <ul id="aggregate-groups" class="mlistview"> </ul> <div class="block_buttons add_button"> <input id="add-aggregate-button" class="modest-button" type="button" value="Add Aggregate"/> </div> </div><!-- race-structure --> </div><!-- below-banner --> <div id="add_class_modal" class="modal_dialog wide_modal hidden block_buttons"> <form> <input type="hidden" name="action" value="class.add"/> <div id='aggregate-by-div' class="aggregate-only"> <label for='aggregate-by-checkbox'>Aggregate by &nbsp;</label> <input id='aggregate-by-checkbox' type='checkbox' class='flipswitch' onchange='on_aggregate_by_change()' data-off-text="<?php echo group_label();?>" data-on-text="<?php echo subgroup_label();?>"/> </div> <h3>Add New <span class="group-label"><?php echo group_label(); ?></span></h3> <input id='add-class-name' name="name" type="text"/> <div class="ntrophies"> <label for='add-class-ntrophies'>Number of speed trophies:</label> <select id='add-class-ntrophies' name="ntrophies"> <option value="-1" selected="selected">Default</option> <option>0</option> <option>1</option> <option>2</option> <option>3</option> <option>4</option> <option>5</option> <option>6</option> <option>7</option> <option>8</option> <option>9</option> <option>10</option> </select> </div> <div id='constituent-clip' class='aggregate-only'> <div id='constituent-div'> <div id='constituent-classes'></div> <div id='constituent-subgroups'></div> </div> </div> <input type="submit"/> <input type="button" value="Cancel" onclick="close_add_class_modal();"/> </form> </div> <div id="edit_one_class_modal" class="modal_dialog hidden block_buttons"> <form> <h3><span class="group-label"><?php echo group_label(); ?></span> Name</h3> <input id="edit_class_name" name="name" type="text"/> <div class="ntrophies"> <label for='edit_class_ntrophies'>Number of speed&nbsp;trophies:</label> <select id='edit_class_ntrophies' name='ntrophies'> <option value="-1">Default</option> <option>0</option> <option>1</option> <option>2</option> <option>3</option> <option>4</option> <option>5</option> <option>6</option> <option>7</option> <option>8</option> <option>9</option> <option>10</option> </select> </div> <div id="completed_rounds_extension"> <p><span id="completed_rounds_count"></span> completed round(s) exist for this class.</p> </div> <div id="constituent_extension"> <p>Constituent of <span id="constituent_owner"></span>, possibly other aggregates.</p> </div> <div id="edit_ranks_extension" class="hidden"> <input id="add_rank_button" type="button" value="Add <?php echo subgroup_label(); ?>" onclick="show_add_rank_modal();" /> <br/> </div> <input type="submit"/> <input type="button" value="Cancel" onclick="close_edit_one_class_modal();"/> <div id="delete_class_extension"> <input id="delete_class_button" type="button" value="Delete <?php echo group_label(); ?>" data-label="<?php echo group_label(); ?>" class="delete_button" onclick="handle_delete_class(this);"/> </div> </form> </div> <div id="edit_one_rank_modal" class="modal_dialog hidden block_buttons"> <h3>New <span class="subgroup-label"><?php echo subgroup_label(); ?></span> Name</h3> <form> <input id="edit_rank_name" name="name" type="text"/> <div class="ntrophies"> <label for='edit_rank_ntrophies'>Number of speed&nbsp;trophies:</label> <select id='edit_rank_ntrophies' name='ntrophies'> <option value="-1">Default</option> <option>0</option> <option>1</option> <option>2</option> <option>3</option> <option>4</option> <option>5</option> <option>6</option> <option>7</option> <option>8</option> <option>9</option> <option>10</option> </select> </div> <input type="submit"/> <input type="button" value="Cancel" onclick="close_edit_one_rank_modal();"/> <div id="delete_rank_extension"> <input id="delete_rank_button" type="button" value="Delete <?php echo subgroup_label(); ?>" data-label="<?php echo subgroup_label(); ?>" class="delete_button" onclick="handle_delete_rank(this);"/> </div> </form> </div> <div id="add_partition_modal" class="modal_dialog hidden block_buttons"> <h3>Add New <span class="partition-label"><?php echo partition_label(); ?></span></h3> <form> <input type="hidden" name="action" value="partition.add"/> <input name="name" type="text"/> <input type="submit"/> <input type="button" value="Cancel" onclick="close_add_partition_modal();"/> </form> </div> <div id="edit_one_partition_modal" class="modal_dialog hidden block_buttons"> <h3>New <span class="partition-label"><?php echo partition_label(); ?></span> Name</h3> <form> <input id="edit_partition_name" name="name" type="text"/> <input type="submit"/> <input type="button" value="Cancel" onclick="close_edit_one_partition_modal();"/> <div id="delete_partition_extension"> <input id="delete_partition_button" type="button" value="Delete <?php echo partition_label(); ?>" data-label="<?php echo partition_label(); ?>" class="delete_button" onclick="handle_delete_partition(this);"/> </div> </form> </div> </body> </html>
php
MIT
07b0d7303c2d2563b7adfd8af1cabe389c114bac
2026-01-05T04:46:00.013344Z
false
jeffpiazza/derbynet
https://github.com/jeffpiazza/derbynet/blob/07b0d7303c2d2563b7adfd8af1cabe389c114bac/website/judging.php
website/judging.php
<?php @session_start(); require_once('inc/data.inc'); require_once('inc/authorize.inc'); session_write_close(); require_once('inc/banner.inc'); require_once('inc/photo-config.inc'); require_permission(JUDGING_PERMISSION); ?><!DOCTYPE html> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/> <title>Award Judging</title> <script type="text/javascript" src="js/jquery.js"></script> <script type="text/javascript" src="js/ajax-setup.js"></script> <script type="text/javascript" src="js/jquery-ui.min.js"></script> <script type="text/javascript" src="js/jquery.ui.touch-punch.min.js"></script> <script type="text/javascript" src="js/dashboard-ajax.js"></script> <script type="text/javascript" src="js/mobile.js"></script> <script type="text/javascript" src="js/modal.js"></script> <script type="text/javascript" src="js/judging.js"></script> <link rel="stylesheet" type="text/css" href="css/jquery-ui.min.css"/> <link rel="stylesheet" type="text/css" href="css/mobile.css"/> <?php require('inc/stylesheet.inc'); ?> <link rel="stylesheet" type="text/css" href="css/judging.css"/> <script type="text/javascript"> $(function() { $("#ballot_password").val(<?php echo json_encode(read_raceinfo('ballot_password', '')); ?>); }); </script> </head> <body> <?php make_banner('Judging'); require_once('inc/standings.inc'); require_once('inc/schema_version.inc'); $order = ''; if (isset($_GET['order'])) $order = $_GET['order']; // Values are: name, class, car if (!$order) $order = 'car'; function link_for_ordering($key, $text) { global $order; echo "<a "; if ($order == $key) { echo 'class="current_sort"'; } echo " href='judging.php?order=".$key."'>"; echo $text; echo "</a>"; } $racers = array(); $sql = 'SELECT racerid, carnumber, lastname, firstname,' .' RegistrationInfo.classid, class, RegistrationInfo.rankid, rank, imagefile,' .' '.(schema_version() < 2 ? "class" : "Classes.sortorder").' AS class_sort, ' .(schema_version() < 2 ? '\'\' as ' : '').' carphoto' .' FROM '.inner_join('RegistrationInfo', 'Classes', 'Classes.classid = RegistrationInfo.classid', 'Ranks', 'Ranks.rankid = RegistrationInfo.rankid') .' WHERE passedinspection = 1 AND exclude = 0' .' ORDER BY ' .($order == 'car' ? 'carnumber, lastname, firstname' : ($order == 'class' ? 'class_sort, lastname, firstname' : 'lastname, firstname')); foreach ($db->query($sql) as $rs) { $racerid = $rs['racerid']; $racers[$racerid] = array('racerid' => $racerid, 'carnumber' => $rs['carnumber'], 'lastname' => $rs['lastname'], 'firstname' => $rs['firstname'], 'classid' => $rs['classid'], 'class' => $rs['class'], 'rankid' => $rs['rankid'], 'rank' => $rs['rank'], 'imagefile' => $rs['imagefile'], 'carphoto' => $rs['carphoto']); } ?> <div id="top_matter" class="block_buttons"> <div id="ballot-button-div"> <input type='button' value='Manage Ballot' onclick='show_modal($("#ballot_modal"));'/> </div> <div id="sort_controls"> Sort racers by:<br/> <?php link_for_ordering('name', "name,"); ?> <?php link_for_ordering('class', group_label_lc().","); ?> or <?php link_for_ordering('car', "car number"); ?>. </div> <a class="button_link" href="awards-editor.php">Edit Awards</a> </div> <div id="awards"> <div id="dd-prompt">Drag awards to racers,<br/>or racers to awards.</div> <p id="awards-empty">There are currently no awards defined.</p> <ul> </ul> </div> <div id="racers"> <?php $use_groups = use_groups(); $use_subgroups = use_subgroups(); foreach ($racers as $racer) { echo "<div class='judging_racer' data-racerid='".$racer['racerid']."' onclick='show_racer_awards_modal($(this));'>\n"; if ($racer['carphoto']) { echo "<img src='".car_photo_repository()->lookup(RENDER_JUDGING)->render_url($racer['carphoto'])."'/>"; } echo "<div class='carno'>"; echo $racer['carnumber']; echo "</div>"; echo "<div class='racer_name'>".htmlspecialchars($racer['firstname'].' '.$racer['lastname'], ENT_QUOTES, 'UTF-8')."</div>"; echo "<div class='group_name' data-classid='".$racer['classid']."'>"; if ($use_groups) { echo htmlspecialchars($racer['class'], ENT_QUOTES, 'UTF-8'); } echo "</div>"; if ($use_subgroups) { echo "<div class='subgroup_name' data-rankid='".$racer['rankid']."'>" .htmlspecialchars($racer['rank'], ENT_QUOTES, 'UTF-8') ."</div>"; } // These get hidden/unhidden by javascript code, based on award results echo "<img class='award_marker' src='img/award-ribbon-27x36.png'/>"; echo "<img class='adhoc_marker' src='img/goldstar.png'/>"; echo "</div>\n"; } ?> </div> <div id="racer_awards_modal" class="modal_dialog hidden block_buttons"> <h3>Awards for <span id="racer_awards_recipient_carno"></span> <span id="racer_awards_recipient_name"></span> </h3> <ul id="racer_awards"> </ul> <form id="racer_awards_form"> <input type="hidden" name="action" value="award.adhoc"/> <input type="hidden" name="racerid" value="" id="racer_awards_racerid"/> <label for="awardname"><i>Ad hoc</i> award:</label> <input type="text" name="awardname" id="racer_awards_awardname"/> <input type="submit"/> <input type="button" value="Close" onclick='close_racer_awards_modal();'/> </form> </div> <div id="ballot_modal" class="modal_dialog wide_modal hidden block_buttons"> <label for='balloting_state'>Balloting is: </label> <input id='balloting_state' type='checkbox' class='flipswitch' data-on-text='Open' data-off-text='Closed' <?php if (read_raceinfo('balloting', 'closed') == 'open') echo "checked='checked'"; ?>/> <div> <label for='ballot_password'>Ballot password:</label> <input id='ballot_password' type='text' class='not-mobile' onchange='on_ballot_password_change()'/> </div> <div id="ballot_modal_awards"> </div> <p class="usage-hint">Removing an award from the ballot will clear any votes for that award, perhaps from testing. The award can be immediately re-added to the ballot if desired.</p> <input type="button" value="Close" onclick='close_modal($("#ballot_modal"));'/> </div> <div id="ballot_results_modal" class="modal_dialog hidden"> <div id="ballot_results_tabulation"> </div> <div class="block_buttons"> <input type="button" value="Close" onclick='close_modal($("#ballot_results_modal"));'/> </div> </div> </body> </html>
php
MIT
07b0d7303c2d2563b7adfd8af1cabe389c114bac
2026-01-05T04:46:00.013344Z
false
jeffpiazza/derbynet
https://github.com/jeffpiazza/derbynet/blob/07b0d7303c2d2563b7adfd8af1cabe389c114bac/website/photo-thumbs.php
website/photo-thumbs.php
<?php session_start(); require_once('inc/data.inc'); require_once('inc/authorize.inc'); session_write_close(); require_once('inc/banner.inc'); require_once('inc/schema_version.inc'); require_once('inc/partitions.inc'); require_permission(ASSIGN_RACER_IMAGE_PERMISSION); require_once('inc/photo-config.inc'); $repo = isset($_GET['repo']) ? $_GET['repo'] : 'head'; $photo_repository = photo_repository($repo); $other_repo = $repo == 'car' ? 'head' : 'car'; $order = ''; if (isset($_GET['order']) && in_array($_GET['order'], ['name', 'class', 'car'])) $order = $_GET['order']; if (!$order) $order = 'name'; function link_for_ordering($key, $text) { global $order, $photo_repository; echo "<div class='sort_div'>"; echo "<a class='sort_button button_link"; if ($order == $key) { echo ' current_sort'; } echo "' href='photo-thumbs.php?repo=".$photo_repository->name()."&amp;order=".$key."'>"; //echo "<span class='sort_by'>Sort by</span>"; //echo "<br/>"; echo $text; echo "</a>"; echo "</div>"; } function scan_directory($directory, $pattern) { $files = array(); $dh = @opendir($directory); if ($dh !== false) { while (($filename = readdir($dh)) !== false) { if (preg_match($pattern, $filename) && is_file($directory.DIRECTORY_SEPARATOR.$filename)) { $files[] = $filename; } } closedir($dh); } asort($files); return $files; } $allfiles = scan_directory($photo_repository->directory(), "/(jpg|jpeg|png|gif|bmp|svg)\$/i"); // Returns a javascript expression, suitable for onclick, to perform cropping of a particular photo. function photo_crop_expression($basename) { global $photo_repository; return htmlspecialchars('showPhotoCropModal(this, "'.$photo_repository->name().'", "'.$basename.'", '.time().')', ENT_QUOTES, 'UTF-8'); } // TODO: line-height? "End of photos" text aligns with thumbnail image bottom. // *** Both div's are overhanging the bottom by the amount taken up by the banner and refresh button! // *** height=100% could be at issue. ?> <!DOCTYPE HTML> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/> <title>Assign Racer Photos</title> <meta name="viewport" content="width=device-width, initial-scale=1"/> <link rel="stylesheet" type="text/css" href="css/jquery-ui.min.css"/> <link rel="stylesheet" type="text/css" href="css/mobile.css"/> <link rel="stylesheet" type="text/css" href="css/jquery.Jcrop.min.css"/> <link rel="stylesheet" type="text/css" href="css/dropzone.min.css"/> <?php require('inc/stylesheet.inc'); ?> <link rel="stylesheet" type="text/css" href="css/photo-thumbs.css"/> <script type="text/javascript" src="js/jquery.js"></script> <script type="text/javascript" src="js/ajax-setup.js"></script> <script type="text/javascript" src="js/dashboard-ajax.js"></script> <script type="text/javascript" src="js/jquery-ui.min.js"></script> <script type="text/javascript" src="js/jquery.ui.touch-punch.min.js"></script> <script type="text/javascript" src="js/dashboard-ajax.js"></script> <script type="text/javascript" src="js/modal.js"></script> <script type="text/javascript" src="js/jquery.Jcrop.min.js"></script> <script type="text/javascript" src="js/dropzone.min.js"></script> <script type="text/javascript"> var g_photo_repo_name = '<?php echo $photo_repository->name(); ?>'; <?php if (isset($_GET['racerid']) && is_numeric($_GET['racerid'])) { ?> $(function() { scroll_to_racerid(<?php echo $_GET['racerid']; ?>); }); <?php } ?> </script> <script type="text/javascript" src="js/find-racer.js"></script> <script type="text/javascript" src="js/photo-thumbs.js"></script> </head> <body> <?php make_banner(($repo == 'head' ? 'Racer' : 'Car').' Photos', isset($_GET['back']) ? $_GET['back'] : 'index.php'); ?> <div class="block_buttons"> <div id="sort_controls"> <?php link_for_ordering('name', "Name"); ?> <?php link_for_ordering('class', group_label()); ?> <?php link_for_ordering('car', "Car#"); ?>. </div> <?php if (!is_writable($photo_repository->directory())) { ?> <div id="upload_target"> <div class="dz-message"> <span>Photo directory is not writable; check <a href="settings.php">settings.</a></span> </div> </div> <?php } else { ?> <form id="upload_target" action="action.php" class="dropzone"> <div class="fallback"> <input type="file" name="photo" value="Upload Files"/> </div> <input type="hidden" name="action" value="photo.upload"/> <input type="hidden" name="repo" value="<?php echo $photo_repository->name(); ?>"/> <input type="hidden" name="MAX_FILE_SIZE" value="30000000" /> </form> <?php } ?> <div id="center_buttons"> <?php echo "<a class='button_link' id='refresh-button' onclick='window.location.reload();'>Refresh</a>"; $url = "photo-thumbs.php?repo=$other_repo&amp;order=$order"; if (isset($_GET['racerid']) && is_numeric($_GET['racerid'])) { $url .= "&amp;racerid=$_GET[racerid]"; } if (isset($_GET['back'])) { $url .= "&amp;back=$_GET[back]"; } echo "<a id='other-button' class='button_link' href='$url'>"; echo $other_repo == 'head' ? 'Racers' : 'Cars'; echo "</a>"; ?> </div> </div> <div class="body-wrapper"> <div class="thumblist"> <ul class="mlistview has-thumbs"> <?php require_once('inc/data.inc'); $use_groups = use_groups(); $racers_by_photo = array(); $stmt = $db->query('SELECT racerid, lastname, firstname, '.$photo_repository->column_name().',' .' carnumber, class,' .' '.(schema_version() < 2 ? "class" : "Classes.sortorder").' AS class_sort ' .' FROM RegistrationInfo' .' INNER JOIN Classes' .' ON RegistrationInfo.classid = Classes.classid' .' ORDER BY ' .($order == 'car' ? 'carnumber, lastname, firstname' : ($order == 'class' ? 'class_sort, lastname, firstname' : 'lastname, firstname'))); foreach ($stmt as $rs) { $raw_imagefile = $rs[$photo_repository->column_name()]; $racer = array('firstname' => $rs['firstname'], 'lastname' => $rs['lastname'], 'class' => $rs['class'], 'racerid' => $rs['racerid'], 'imagefile' => $raw_imagefile); // CSS classes control drag and drop behavior $css_classes = ''; if ($raw_imagefile !== null && $raw_imagefile !== "") { // If there's an associated photo... $image_filename = basename($raw_imagefile); $racers_by_photo[$image_filename] = $racer; if (array_search($image_filename, $allfiles) === false) { $css_classes .= ' without-photo lost_photo'; } } else { $css_classes .= ' without-photo'; } echo '<li data-racer-id="'.$racer['racerid'].'" ' .' class="'.$css_classes.'"' .'>'; if ($raw_imagefile != '') { echo "\n".'<img class="assigned"' .' data-image-filename="'.htmlspecialchars($image_filename, ENT_QUOTES, 'UTF-8').'"' .' onclick="'.photo_crop_expression($image_filename).'"' .' src="'.$photo_repository->lookup(RENDER_LISTVIEW)->render_url($image_filename).'"/>'; } echo "<span class='racer-name'>".htmlspecialchars($rs['firstname'].' '.$rs['lastname'], ENT_QUOTES, 'UTF-8')."</span>"; if ($use_groups) { echo '<p><span class="car-number">'.$rs['carnumber'].':</span> '.htmlspecialchars($rs['class'], ENT_QUOTES, 'UTF-8').'</p>'; } else { echo '<p><span class="car-number">'.$rs['carnumber'].'</span></p>'; } echo '</li>'."\n"; } ?> </ul> </div> <div class="photothumbs"> <?php foreach ($allfiles as $imagefile) { echo '<div class="thumbnail'.(isset($racers_by_photo[$imagefile]) ? ' hidden' : '').'">'; echo '<img class="unassigned-photo"' .' data-image-filename="'.htmlspecialchars($imagefile, ENT_QUOTES, 'UTF-8').'"' .' onclick="'.photo_crop_expression($imagefile).'"' .' src="'.$photo_repository->lookup(RENDER_THUMBNAIL)->render_url($imagefile).'"/>'; echo '</div>'."\n"; } if (empty($allfiles)) { $trouble_first = '<h2 class="trouble"><img src="img/status/trouble.png"/>'; $dir_name = htmlspecialchars($photo_repository->directory(), ENT_QUOTES, 'UTF-8'); $trouble_last = "</h2>\n"; if (!file_exists($photo_repository->directory())) { echo $trouble_first.'Directory '.$dir_name.' does not exist.'.$trouble_last; } else if (!is_dir($photo_repository->directory())) { echo $trouble_first.'Directory path '.$dir_name.' exists but is not a directory.'.$trouble_last; } else if (!is_readable($photo_repository->directory())) { echo $trouble_first.'Directory '.$dir_name.' cannot be read.'.$trouble_last; } else if (!is_writable($photo_repository->directory())) { echo $trouble_first.'Directory '.$dir_name.' is not writable.'.$trouble_last; } else { echo '<h2>There are no photos in the photo directory yet.</h2>'; } } ?> </div> </div> <div id="photo_crop_modal" class="modal_dialog hidden block_buttons"> <p id='photo_basename'></p> <div id="work_image"></div> <p id="crop_instructions">Indicate new crop boundary, <i>then</i> press Crop.</p> <input type="button" value="Crop" onclick="cropPhoto(); return false;"/> <input type="button" value="Rotate Right" onclick="rotatePhoto(-90); return false;"/> <input type="button" value="Rotate Left" onclick="rotatePhoto(90); return false;"/> <input type="button" value="Cancel" onclick="close_modal('#photo_crop_modal');"/> <input type="button" value="Delete" class="delete_button" onclick="on_delete_photo_button(); return false;"/> </div> <div id="ajax_working" class="hidden"> <span id="ajax_num_requests">0</span> request(s) pending. </div> <div id="delete_confirmation_modal" class="modal_dialog block_buttons hidden"> <form> <p>Are you sure you want to delete this photo?</p> <input type="submit" value="Delete Photo"/> <p>&nbsp;</p> <input type="button" value="Cancel" onclick='close_secondary_modal("#delete_confirmation_modal");'/> </form> </div> <div id="find-racer" class="hidden"> <div id="find-racer-form"> Find Racer: <input type="text" id="find-racer-text" name="narrowing-text" class="not-mobile"/> <span id="find-racer-message" ><span id="find-racer-index" data-index="1">1</span> of <span id="find-racer-count">0</span> </span> <img onclick="cancel_find_racer()" src="img/cancel-20.png"/> </div> </div> </body> </html>
php
MIT
07b0d7303c2d2563b7adfd8af1cabe389c114bac
2026-01-05T04:46:00.013344Z
false
jeffpiazza/derbynet
https://github.com/jeffpiazza/derbynet/blob/07b0d7303c2d2563b7adfd8af1cabe389c114bac/website/fpdf/fpdf.php
website/fpdf/fpdf.php
<?php /******************************************************************************* * FPDF * * * * Version: 1.82 * * Date: 2019-12-07 * * Author: Olivier PLATHEY * *******************************************************************************/ define('FPDF_VERSION','1.82'); class FPDF { protected $page; // current page number protected $n; // current object number protected $offsets; // array of object offsets protected $buffer; // buffer holding in-memory PDF protected $pages; // array containing pages protected $state; // current document state protected $compress; // compression flag protected $k; // scale factor (number of points in user unit) protected $DefOrientation; // default orientation protected $CurOrientation; // current orientation protected $StdPageSizes; // standard page sizes protected $DefPageSize; // default page size protected $CurPageSize; // current page size protected $CurRotation; // current page rotation protected $PageInfo; // page-related data protected $wPt, $hPt; // dimensions of current page in points protected $w, $h; // dimensions of current page in user unit protected $lMargin; // left margin protected $tMargin; // top margin protected $rMargin; // right margin protected $bMargin; // page break margin protected $cMargin; // cell margin protected $x, $y; // current position in user unit protected $lasth; // height of last printed cell protected $LineWidth; // line width in user unit protected $fontpath; // path containing fonts protected $CoreFonts; // array of core font names protected $fonts; // array of used fonts protected $FontFiles; // array of font files protected $encodings; // array of encodings protected $cmaps; // array of ToUnicode CMaps protected $FontFamily; // current font family protected $FontStyle; // current font style protected $underline; // underlining flag protected $CurrentFont; // current font info protected $FontSizePt; // current font size in points protected $FontSize; // current font size in user unit protected $DrawColor; // commands for drawing color protected $FillColor; // commands for filling color protected $TextColor; // commands for text color protected $ColorFlag; // indicates whether fill and text colors are different protected $WithAlpha; // indicates whether alpha channel is used protected $ws; // word spacing protected $images; // array of used images protected $PageLinks; // array of links in pages protected $links; // array of internal links protected $AutoPageBreak; // automatic page breaking protected $PageBreakTrigger; // threshold used to trigger page breaks protected $InHeader; // flag set when processing header protected $InFooter; // flag set when processing footer protected $AliasNbPages; // alias for total number of pages protected $ZoomMode; // zoom display mode protected $LayoutMode; // layout display mode protected $metadata; // document properties protected $PDFVersion; // PDF version number /******************************************************************************* * Public methods * *******************************************************************************/ function __construct($orientation='P', $unit='mm', $size='A4') { // Some checks $this->_dochecks(); // Initialization of properties $this->state = 0; $this->page = 0; $this->n = 2; $this->buffer = ''; $this->pages = array(); $this->PageInfo = array(); $this->fonts = array(); $this->FontFiles = array(); $this->encodings = array(); $this->cmaps = array(); $this->images = array(); $this->links = array(); $this->InHeader = false; $this->InFooter = false; $this->lasth = 0; $this->FontFamily = ''; $this->FontStyle = ''; $this->FontSizePt = 12; $this->underline = false; $this->DrawColor = '0 G'; $this->FillColor = '0 g'; $this->TextColor = '0 g'; $this->ColorFlag = false; $this->WithAlpha = false; $this->ws = 0; // Font path if(defined('FPDF_FONTPATH')) { $this->fontpath = FPDF_FONTPATH; if(substr($this->fontpath,-1)!='/' && substr($this->fontpath,-1)!='\\') $this->fontpath .= '/'; } elseif(is_dir(dirname(__FILE__).'/font')) $this->fontpath = dirname(__FILE__).'/font/'; else $this->fontpath = ''; // Core fonts $this->CoreFonts = array('courier', 'helvetica', 'times', 'symbol', 'zapfdingbats'); // Scale factor if($unit=='pt') $this->k = 1; elseif($unit=='mm') $this->k = 72/25.4; elseif($unit=='cm') $this->k = 72/2.54; elseif($unit=='in') $this->k = 72; else $this->Error('Incorrect unit: '.$unit); // Page sizes $this->StdPageSizes = array('a3'=>array(841.89,1190.55), 'a4'=>array(595.28,841.89), 'a5'=>array(420.94,595.28), 'letter'=>array(612,792), 'legal'=>array(612,1008)); $size = $this->_getpagesize($size); $this->DefPageSize = $size; $this->CurPageSize = $size; // Page orientation $orientation = strtolower($orientation); if($orientation=='p' || $orientation=='portrait') { $this->DefOrientation = 'P'; $this->w = $size[0]; $this->h = $size[1]; } elseif($orientation=='l' || $orientation=='landscape') { $this->DefOrientation = 'L'; $this->w = $size[1]; $this->h = $size[0]; } else $this->Error('Incorrect orientation: '.$orientation); $this->CurOrientation = $this->DefOrientation; $this->wPt = $this->w*$this->k; $this->hPt = $this->h*$this->k; // Page rotation $this->CurRotation = 0; // Page margins (1 cm) $margin = 28.35/$this->k; $this->SetMargins($margin,$margin); // Interior cell margin (1 mm) $this->cMargin = $margin/10; // Line width (0.2 mm) $this->LineWidth = .567/$this->k; // Automatic page break $this->SetAutoPageBreak(true,2*$margin); // Default display mode $this->SetDisplayMode('default'); // Enable compression $this->SetCompression(true); // Set default PDF version number $this->PDFVersion = '1.3'; } function SetMargins($left, $top, $right=null) { // Set left, top and right margins $this->lMargin = $left; $this->tMargin = $top; if($right===null) $right = $left; $this->rMargin = $right; } function SetLeftMargin($margin) { // Set left margin $this->lMargin = $margin; if($this->page>0 && $this->x<$margin) $this->x = $margin; } function SetTopMargin($margin) { // Set top margin $this->tMargin = $margin; } function SetRightMargin($margin) { // Set right margin $this->rMargin = $margin; } function SetAutoPageBreak($auto, $margin=0) { // Set auto page break mode and triggering margin $this->AutoPageBreak = $auto; $this->bMargin = $margin; $this->PageBreakTrigger = $this->h-$margin; } function SetDisplayMode($zoom, $layout='default') { // Set display mode in viewer if($zoom=='fullpage' || $zoom=='fullwidth' || $zoom=='real' || $zoom=='default' || !is_string($zoom)) $this->ZoomMode = $zoom; else $this->Error('Incorrect zoom display mode: '.$zoom); if($layout=='single' || $layout=='continuous' || $layout=='two' || $layout=='default') $this->LayoutMode = $layout; else $this->Error('Incorrect layout display mode: '.$layout); } function SetCompression($compress) { // Set page compression if(function_exists('gzcompress')) $this->compress = $compress; else $this->compress = false; } function SetTitle($title, $isUTF8=false) { // Title of document $this->metadata['Title'] = $isUTF8 ? $title : utf8_encode($title); } function SetAuthor($author, $isUTF8=false) { // Author of document $this->metadata['Author'] = $isUTF8 ? $author : utf8_encode($author); } function SetSubject($subject, $isUTF8=false) { // Subject of document $this->metadata['Subject'] = $isUTF8 ? $subject : utf8_encode($subject); } function SetKeywords($keywords, $isUTF8=false) { // Keywords of document $this->metadata['Keywords'] = $isUTF8 ? $keywords : utf8_encode($keywords); } function SetCreator($creator, $isUTF8=false) { // Creator of document $this->metadata['Creator'] = $isUTF8 ? $creator : utf8_encode($creator); } function AliasNbPages($alias='{nb}') { // Define an alias for total number of pages $this->AliasNbPages = $alias; } function Error($msg) { // Fatal error throw new Exception('FPDF error: '.$msg); } function Close() { // Terminate document if($this->state==3) return; if($this->page==0) $this->AddPage(); // Page footer $this->InFooter = true; $this->Footer(); $this->InFooter = false; // Close page $this->_endpage(); // Close document $this->_enddoc(); } function AddPage($orientation='', $size='', $rotation=0) { // Start a new page if($this->state==3) $this->Error('The document is closed'); $family = $this->FontFamily; $style = $this->FontStyle.($this->underline ? 'U' : ''); $fontsize = $this->FontSizePt; $lw = $this->LineWidth; $dc = $this->DrawColor; $fc = $this->FillColor; $tc = $this->TextColor; $cf = $this->ColorFlag; if($this->page>0) { // Page footer $this->InFooter = true; $this->Footer(); $this->InFooter = false; // Close page $this->_endpage(); } // Start new page $this->_beginpage($orientation,$size,$rotation); // Set line cap style to square $this->_out('2 J'); // Set line width $this->LineWidth = $lw; $this->_out(sprintf('%.2F w',$lw*$this->k)); // Set font if($family) $this->SetFont($family,$style,$fontsize); // Set colors $this->DrawColor = $dc; if($dc!='0 G') $this->_out($dc); $this->FillColor = $fc; if($fc!='0 g') $this->_out($fc); $this->TextColor = $tc; $this->ColorFlag = $cf; // Page header $this->InHeader = true; $this->Header(); $this->InHeader = false; // Restore line width if($this->LineWidth!=$lw) { $this->LineWidth = $lw; $this->_out(sprintf('%.2F w',$lw*$this->k)); } // Restore font if($family) $this->SetFont($family,$style,$fontsize); // Restore colors if($this->DrawColor!=$dc) { $this->DrawColor = $dc; $this->_out($dc); } if($this->FillColor!=$fc) { $this->FillColor = $fc; $this->_out($fc); } $this->TextColor = $tc; $this->ColorFlag = $cf; } function Header() { // To be implemented in your own inherited class } function Footer() { // To be implemented in your own inherited class } function PageNo() { // Get current page number return $this->page; } function SetDrawColor($r, $g=null, $b=null) { // Set color for all stroking operations if(($r==0 && $g==0 && $b==0) || $g===null) $this->DrawColor = sprintf('%.3F G',$r/255); else $this->DrawColor = sprintf('%.3F %.3F %.3F RG',$r/255,$g/255,$b/255); if($this->page>0) $this->_out($this->DrawColor); } function SetFillColor($r, $g=null, $b=null) { // Set color for all filling operations if(($r==0 && $g==0 && $b==0) || $g===null) $this->FillColor = sprintf('%.3F g',$r/255); else $this->FillColor = sprintf('%.3F %.3F %.3F rg',$r/255,$g/255,$b/255); $this->ColorFlag = ($this->FillColor!=$this->TextColor); if($this->page>0) $this->_out($this->FillColor); } function SetTextColor($r, $g=null, $b=null) { // Set color for text if(($r==0 && $g==0 && $b==0) || $g===null) $this->TextColor = sprintf('%.3F g',$r/255); else $this->TextColor = sprintf('%.3F %.3F %.3F rg',$r/255,$g/255,$b/255); $this->ColorFlag = ($this->FillColor!=$this->TextColor); } function GetStringWidth($s) { // Get width of a string in the current font $s = (string)$s; $cw = &$this->CurrentFont['cw']; $w = 0; $l = strlen($s); for($i=0;$i<$l;$i++) $w += $cw[$s[$i]]; return $w*$this->FontSize/1000; } function SetLineWidth($width) { // Set line width $this->LineWidth = $width; if($this->page>0) $this->_out(sprintf('%.2F w',$width*$this->k)); } function Line($x1, $y1, $x2, $y2) { // Draw a line $this->_out(sprintf('%.2F %.2F m %.2F %.2F l S',$x1*$this->k,($this->h-$y1)*$this->k,$x2*$this->k,($this->h-$y2)*$this->k)); } function Rect($x, $y, $w, $h, $style='') { // Draw a rectangle if($style=='F') $op = 'f'; elseif($style=='FD' || $style=='DF') $op = 'B'; else $op = 'S'; $this->_out(sprintf('%.2F %.2F %.2F %.2F re %s',$x*$this->k,($this->h-$y)*$this->k,$w*$this->k,-$h*$this->k,$op)); } function AddFont($family, $style='', $file='') { // Add a TrueType, OpenType or Type1 font $family = strtolower($family); if($file=='') $file = str_replace(' ','',$family).strtolower($style).'.php'; $style = strtoupper($style); if($style=='IB') $style = 'BI'; $fontkey = $family.$style; if(isset($this->fonts[$fontkey])) return; $info = $this->_loadfont($file); $info['i'] = count($this->fonts)+1; if(!empty($info['file'])) { // Embedded font if($info['type']=='TrueType') $this->FontFiles[$info['file']] = array('length1'=>$info['originalsize']); else $this->FontFiles[$info['file']] = array('length1'=>$info['size1'], 'length2'=>$info['size2']); } $this->fonts[$fontkey] = $info; } function SetFont($family, $style='', $size=0) { // Select a font; size given in points if($family=='') $family = $this->FontFamily; else $family = strtolower($family); $style = strtoupper($style); if(strpos($style,'U')!==false) { $this->underline = true; $style = str_replace('U','',$style); } else $this->underline = false; if($style=='IB') $style = 'BI'; if($size==0) $size = $this->FontSizePt; // Test if font is already selected if($this->FontFamily==$family && $this->FontStyle==$style && $this->FontSizePt==$size) return; // Test if font is already loaded $fontkey = $family.$style; if(!isset($this->fonts[$fontkey])) { // Test if one of the core fonts if($family=='arial') $family = 'helvetica'; if(in_array($family,$this->CoreFonts)) { if($family=='symbol' || $family=='zapfdingbats') $style = ''; $fontkey = $family.$style; if(!isset($this->fonts[$fontkey])) $this->AddFont($family,$style); } else $this->Error('Undefined font: '.$family.' '.$style); } // Select it $this->FontFamily = $family; $this->FontStyle = $style; $this->FontSizePt = $size; $this->FontSize = $size/$this->k; $this->CurrentFont = &$this->fonts[$fontkey]; if($this->page>0) $this->_out(sprintf('BT /F%d %.2F Tf ET',$this->CurrentFont['i'],$this->FontSizePt)); } function SetFontSize($size) { // Set font size in points if($this->FontSizePt==$size) return; $this->FontSizePt = $size; $this->FontSize = $size/$this->k; if($this->page>0) $this->_out(sprintf('BT /F%d %.2F Tf ET',$this->CurrentFont['i'],$this->FontSizePt)); } function AddLink() { // Create a new internal link $n = count($this->links)+1; $this->links[$n] = array(0, 0); return $n; } function SetLink($link, $y=0, $page=-1) { // Set destination of internal link if($y==-1) $y = $this->y; if($page==-1) $page = $this->page; $this->links[$link] = array($page, $y); } function Link($x, $y, $w, $h, $link) { // Put a link on the page $this->PageLinks[$this->page][] = array($x*$this->k, $this->hPt-$y*$this->k, $w*$this->k, $h*$this->k, $link); } function Text($x, $y, $txt) { // Output a string if(!isset($this->CurrentFont)) $this->Error('No font has been set'); $s = sprintf('BT %.2F %.2F Td (%s) Tj ET',$x*$this->k,($this->h-$y)*$this->k,$this->_escape($txt)); if($this->underline && $txt!='') $s .= ' '.$this->_dounderline($x,$y,$txt); if($this->ColorFlag) $s = 'q '.$this->TextColor.' '.$s.' Q'; $this->_out($s); } function AcceptPageBreak() { // Accept automatic page break or not return $this->AutoPageBreak; } function Cell($w, $h=0, $txt='', $border=0, $ln=0, $align='', $fill=false, $link='') { // Output a cell $k = $this->k; if($this->y+$h>$this->PageBreakTrigger && !$this->InHeader && !$this->InFooter && $this->AcceptPageBreak()) { // Automatic page break $x = $this->x; $ws = $this->ws; if($ws>0) { $this->ws = 0; $this->_out('0 Tw'); } $this->AddPage($this->CurOrientation,$this->CurPageSize,$this->CurRotation); $this->x = $x; if($ws>0) { $this->ws = $ws; $this->_out(sprintf('%.3F Tw',$ws*$k)); } } if($w==0) $w = $this->w-$this->rMargin-$this->x; $s = ''; if($fill || $border==1) { if($fill) $op = ($border==1) ? 'B' : 'f'; else $op = 'S'; $s = sprintf('%.2F %.2F %.2F %.2F re %s ',$this->x*$k,($this->h-$this->y)*$k,$w*$k,-$h*$k,$op); } if(is_string($border)) { $x = $this->x; $y = $this->y; if(strpos($border,'L')!==false) $s .= sprintf('%.2F %.2F m %.2F %.2F l S ',$x*$k,($this->h-$y)*$k,$x*$k,($this->h-($y+$h))*$k); if(strpos($border,'T')!==false) $s .= sprintf('%.2F %.2F m %.2F %.2F l S ',$x*$k,($this->h-$y)*$k,($x+$w)*$k,($this->h-$y)*$k); if(strpos($border,'R')!==false) $s .= sprintf('%.2F %.2F m %.2F %.2F l S ',($x+$w)*$k,($this->h-$y)*$k,($x+$w)*$k,($this->h-($y+$h))*$k); if(strpos($border,'B')!==false) $s .= sprintf('%.2F %.2F m %.2F %.2F l S ',$x*$k,($this->h-($y+$h))*$k,($x+$w)*$k,($this->h-($y+$h))*$k); } if($txt!=='') { if(!isset($this->CurrentFont)) $this->Error('No font has been set'); if($align=='R') $dx = $w-$this->cMargin-$this->GetStringWidth($txt); elseif($align=='C') $dx = ($w-$this->GetStringWidth($txt))/2; else $dx = $this->cMargin; if($this->ColorFlag) $s .= 'q '.$this->TextColor.' '; $s .= sprintf('BT %.2F %.2F Td (%s) Tj ET',($this->x+$dx)*$k,($this->h-($this->y+.5*$h+.3*$this->FontSize))*$k,$this->_escape($txt)); if($this->underline) $s .= ' '.$this->_dounderline($this->x+$dx,$this->y+.5*$h+.3*$this->FontSize,$txt); if($this->ColorFlag) $s .= ' Q'; if($link) $this->Link($this->x+$dx,$this->y+.5*$h-.5*$this->FontSize,$this->GetStringWidth($txt),$this->FontSize,$link); } if($s) $this->_out($s); $this->lasth = $h; if($ln>0) { // Go to next line $this->y += $h; if($ln==1) $this->x = $this->lMargin; } else $this->x += $w; } function MultiCell($w, $h, $txt, $border=0, $align='J', $fill=false) { // Output text with automatic or explicit line breaks if(!isset($this->CurrentFont)) $this->Error('No font has been set'); $cw = &$this->CurrentFont['cw']; if($w==0) $w = $this->w-$this->rMargin-$this->x; $wmax = ($w-2*$this->cMargin)*1000/$this->FontSize; $s = str_replace("\r",'',$txt); $nb = strlen($s); if($nb>0 && $s[$nb-1]=="\n") $nb--; $b = 0; if($border) { if($border==1) { $border = 'LTRB'; $b = 'LRT'; $b2 = 'LR'; } else { $b2 = ''; if(strpos($border,'L')!==false) $b2 .= 'L'; if(strpos($border,'R')!==false) $b2 .= 'R'; $b = (strpos($border,'T')!==false) ? $b2.'T' : $b2; } } $sep = -1; $i = 0; $j = 0; $l = 0; $ns = 0; $nl = 1; while($i<$nb) { // Get next character $c = $s[$i]; if($c=="\n") { // Explicit line break if($this->ws>0) { $this->ws = 0; $this->_out('0 Tw'); } $this->Cell($w,$h,substr($s,$j,$i-$j),$b,2,$align,$fill); $i++; $sep = -1; $j = $i; $l = 0; $ns = 0; $nl++; if($border && $nl==2) $b = $b2; continue; } if($c==' ') { $sep = $i; $ls = $l; $ns++; } $l += $cw[$c]; if($l>$wmax) { // Automatic line break if($sep==-1) { if($i==$j) $i++; if($this->ws>0) { $this->ws = 0; $this->_out('0 Tw'); } $this->Cell($w,$h,substr($s,$j,$i-$j),$b,2,$align,$fill); } else { if($align=='J') { $this->ws = ($ns>1) ? ($wmax-$ls)/1000*$this->FontSize/($ns-1) : 0; $this->_out(sprintf('%.3F Tw',$this->ws*$this->k)); } $this->Cell($w,$h,substr($s,$j,$sep-$j),$b,2,$align,$fill); $i = $sep+1; } $sep = -1; $j = $i; $l = 0; $ns = 0; $nl++; if($border && $nl==2) $b = $b2; } else $i++; } // Last chunk if($this->ws>0) { $this->ws = 0; $this->_out('0 Tw'); } if($border && strpos($border,'B')!==false) $b .= 'B'; $this->Cell($w,$h,substr($s,$j,$i-$j),$b,2,$align,$fill); $this->x = $this->lMargin; } function Write($h, $txt, $link='') { // Output text in flowing mode if(!isset($this->CurrentFont)) $this->Error('No font has been set'); $cw = &$this->CurrentFont['cw']; $w = $this->w-$this->rMargin-$this->x; $wmax = ($w-2*$this->cMargin)*1000/$this->FontSize; $s = str_replace("\r",'',$txt); $nb = strlen($s); $sep = -1; $i = 0; $j = 0; $l = 0; $nl = 1; while($i<$nb) { // Get next character $c = $s[$i]; if($c=="\n") { // Explicit line break $this->Cell($w,$h,substr($s,$j,$i-$j),0,2,'',false,$link); $i++; $sep = -1; $j = $i; $l = 0; if($nl==1) { $this->x = $this->lMargin; $w = $this->w-$this->rMargin-$this->x; $wmax = ($w-2*$this->cMargin)*1000/$this->FontSize; } $nl++; continue; } if($c==' ') $sep = $i; $l += $cw[$c]; if($l>$wmax) { // Automatic line break if($sep==-1) { if($this->x>$this->lMargin) { // Move to next line $this->x = $this->lMargin; $this->y += $h; $w = $this->w-$this->rMargin-$this->x; $wmax = ($w-2*$this->cMargin)*1000/$this->FontSize; $i++; $nl++; continue; } if($i==$j) $i++; $this->Cell($w,$h,substr($s,$j,$i-$j),0,2,'',false,$link); } else { $this->Cell($w,$h,substr($s,$j,$sep-$j),0,2,'',false,$link); $i = $sep+1; } $sep = -1; $j = $i; $l = 0; if($nl==1) { $this->x = $this->lMargin; $w = $this->w-$this->rMargin-$this->x; $wmax = ($w-2*$this->cMargin)*1000/$this->FontSize; } $nl++; } else $i++; } // Last chunk if($i!=$j) $this->Cell($l/1000*$this->FontSize,$h,substr($s,$j),0,0,'',false,$link); } function Ln($h=null) { // Line feed; default value is the last cell height $this->x = $this->lMargin; if($h===null) $this->y += $this->lasth; else $this->y += $h; } function Image($file, $x=null, $y=null, $w=0, $h=0, $type='', $link='') { // Put an image on the page if($file=='') $this->Error('Image file name is empty'); if(!isset($this->images[$file])) { // First use of this image, get info if($type=='') { $pos = strrpos($file,'.'); if(!$pos) $this->Error('Image file has no extension and no type was specified: '.$file); $type = substr($file,$pos+1); } $type = strtolower($type); if($type=='jpeg') $type = 'jpg'; $mtd = '_parse'.$type; if(!method_exists($this,$mtd)) $this->Error('Unsupported image type: '.$type); $info = $this->$mtd($file); $info['i'] = count($this->images)+1; $this->images[$file] = $info; } else $info = $this->images[$file]; // Automatic width and height calculation if needed if($w==0 && $h==0) { // Put image at 96 dpi $w = -96; $h = -96; } if($w<0) $w = -$info['w']*72/$w/$this->k; if($h<0) $h = -$info['h']*72/$h/$this->k; if($w==0) $w = $h*$info['w']/$info['h']; if($h==0) $h = $w*$info['h']/$info['w']; // Flowing mode if($y===null) { if($this->y+$h>$this->PageBreakTrigger && !$this->InHeader && !$this->InFooter && $this->AcceptPageBreak()) { // Automatic page break $x2 = $this->x; $this->AddPage($this->CurOrientation,$this->CurPageSize,$this->CurRotation); $this->x = $x2; } $y = $this->y; $this->y += $h; } if($x===null) $x = $this->x; $this->_out(sprintf('q %.2F 0 0 %.2F %.2F %.2F cm /I%d Do Q',$w*$this->k,$h*$this->k,$x*$this->k,($this->h-($y+$h))*$this->k,$info['i'])); if($link) $this->Link($x,$y,$w,$h,$link); } function GetPageWidth() { // Get current page width return $this->w; } function GetPageHeight() { // Get current page height return $this->h; } function GetX() { // Get x position return $this->x; } function SetX($x) { // Set x position if($x>=0) $this->x = $x; else $this->x = $this->w+$x; } function GetY() { // Get y position return $this->y; } function SetY($y, $resetX=true) { // Set y position and optionally reset x if($y>=0) $this->y = $y; else $this->y = $this->h+$y; if($resetX) $this->x = $this->lMargin; } function SetXY($x, $y) { // Set x and y positions $this->SetX($x); $this->SetY($y,false); } function Output($dest='', $name='', $isUTF8=false) { // Output PDF to some destination $this->Close(); if(strlen($name)==1 && strlen($dest)!=1) { // Fix parameter order $tmp = $dest; $dest = $name; $name = $tmp; } if($dest=='') $dest = 'I'; if($name=='') $name = 'doc.pdf'; switch(strtoupper($dest)) { case 'I': // Send to standard output $this->_checkoutput(); if(PHP_SAPI!='cli') { // We send to a browser header('Content-Type: application/pdf'); header('Content-Disposition: inline; '.$this->_httpencode('filename',$name,$isUTF8)); header('Cache-Control: private, max-age=0, must-revalidate'); header('Pragma: public'); } echo $this->buffer; break; case 'D': // Download file $this->_checkoutput(); header('Content-Type: application/x-download'); header('Content-Disposition: attachment; '.$this->_httpencode('filename',$name,$isUTF8)); header('Cache-Control: private, max-age=0, must-revalidate'); header('Pragma: public'); echo $this->buffer; break; case 'F': // Save to local file if(!file_put_contents($name,$this->buffer)) $this->Error('Unable to create output file: '.$name); break; case 'S': // Return as a string return $this->buffer; default: $this->Error('Incorrect output destination: '.$dest); } return ''; } /******************************************************************************* * Protected methods * *******************************************************************************/ protected function _dochecks() { // Check mbstring overloading if(ini_get('mbstring.func_overload') & 2) $this->Error('mbstring overloading must be disabled'); } protected function _checkoutput() { if(PHP_SAPI!='cli') { if(headers_sent($file,$line)) $this->Error("Some data has already been output, can't send PDF file (output started at $file:$line)"); } if(ob_get_length()) { // The output buffer is not empty if(preg_match('/^(\xEF\xBB\xBF)?\s*$/',ob_get_contents())) { // It contains only a UTF-8 BOM and/or whitespace, let's clean it ob_clean(); } else $this->Error("Some data has already been output, can't send PDF file"); } } protected function _getpagesize($size) { if(is_string($size)) { $size = strtolower($size); if(!isset($this->StdPageSizes[$size])) $this->Error('Unknown page size: '.$size); $a = $this->StdPageSizes[$size]; return array($a[0]/$this->k, $a[1]/$this->k); } else { if($size[0]>$size[1]) return array($size[1], $size[0]); else return $size; } } protected function _beginpage($orientation, $size, $rotation) { $this->page++; $this->pages[$this->page] = ''; $this->state = 2; $this->x = $this->lMargin; $this->y = $this->tMargin; $this->FontFamily = ''; // Check page size and orientation if($orientation=='') $orientation = $this->DefOrientation; else $orientation = strtoupper($orientation[0]); if($size=='') $size = $this->DefPageSize; else $size = $this->_getpagesize($size); if($orientation!=$this->CurOrientation || $size[0]!=$this->CurPageSize[0] || $size[1]!=$this->CurPageSize[1]) { // New size or orientation if($orientation=='P') { $this->w = $size[0]; $this->h = $size[1]; } else { $this->w = $size[1]; $this->h = $size[0]; } $this->wPt = $this->w*$this->k; $this->hPt = $this->h*$this->k; $this->PageBreakTrigger = $this->h-$this->bMargin; $this->CurOrientation = $orientation; $this->CurPageSize = $size; } if($orientation!=$this->DefOrientation || $size[0]!=$this->DefPageSize[0] || $size[1]!=$this->DefPageSize[1]) $this->PageInfo[$this->page]['size'] = array($this->wPt, $this->hPt); if($rotation!=0) { if($rotation%90!=0) $this->Error('Incorrect rotation value: '.$rotation); $this->CurRotation = $rotation; $this->PageInfo[$this->page]['rotation'] = $rotation; } } protected function _endpage() { $this->state = 1; } protected function _loadfont($font) { // Load a font definition file from the font directory if(strpos($font,'/')!==false || strpos($font,"\\")!==false) $this->Error('Incorrect font definition file name: '.$font); include($this->fontpath.$font); if(!isset($name)) $this->Error('Could not include font definition file'); if(isset($enc)) $enc = strtolower($enc); if(!isset($subsetted)) $subsetted = false; return get_defined_vars(); } protected function _isascii($s) { // Test if string is ASCII $nb = strlen($s); for($i=0;$i<$nb;$i++) { if(ord($s[$i])>127) return false; } return true; } protected function _httpencode($param, $value, $isUTF8) { // Encode HTTP header field parameter if($this->_isascii($value)) return $param.'="'.$value.'"'; if(!$isUTF8) $value = utf8_encode($value); if(strpos($_SERVER['HTTP_USER_AGENT'],'MSIE')!==false) return $param.'="'.rawurlencode($value).'"'; else return $param."*=UTF-8''".rawurlencode($value); } protected function _UTF8toUTF16($s) { // Convert UTF-8 to UTF-16BE with BOM $res = "\xFE\xFF"; $nb = strlen($s); $i = 0; while($i<$nb) { $c1 = ord($s[$i++]); if($c1>=224) { // 3-byte character $c2 = ord($s[$i++]); $c3 = ord($s[$i++]); $res .= chr((($c1 & 0x0F)<<4) + (($c2 & 0x3C)>>2)); $res .= chr((($c2 & 0x03)<<6) + ($c3 & 0x3F)); } elseif($c1>=192) { // 2-byte character $c2 = ord($s[$i++]); $res .= chr(($c1 & 0x1C)>>2); $res .= chr((($c1 & 0x03)<<6) + ($c2 & 0x3F)); } else { // Single-byte character $res .= "\0".chr($c1); } } return $res; } protected function _escape($s) { // Escape special characters if(strpos($s,'(')!==false || strpos($s,')')!==false || strpos($s,'\\')!==false || strpos($s,"\r")!==false) return str_replace(array('\\','(',')',"\r"), array('\\\\','\\(','\\)','\\r'), $s); else return $s; } protected function _textstring($s) { // Format a text string if(!$this->_isascii($s)) $s = $this->_UTF8toUTF16($s); return '('.$this->_escape($s).')'; } protected function _dounderline($x, $y, $txt) { // Underline text $up = $this->CurrentFont['up']; $ut = $this->CurrentFont['ut']; $w = $this->GetStringWidth($txt)+$this->ws*substr_count($txt,' '); return sprintf('%.2F %.2F %.2F %.2F re f',$x*$this->k,($this->h-($y-$up/1000*$this->FontSize))*$this->k,$w*$this->k,-$ut/1000*$this->FontSizePt); } protected function _parsejpg($file) { // Extract info from a JPEG file $a = getimagesize($file); if(!$a) $this->Error('Missing or incorrect image file: '.$file); if($a[2]!=2) $this->Error('Not a JPEG file: '.$file); if(!isset($a['channels']) || $a['channels']==3) $colspace = 'DeviceRGB'; elseif($a['channels']==4) $colspace = 'DeviceCMYK'; else $colspace = 'DeviceGray'; $bpc = isset($a['bits']) ? $a['bits'] : 8; $data = file_get_contents($file); return array('w'=>$a[0], 'h'=>$a[1], 'cs'=>$colspace, 'bpc'=>$bpc, 'f'=>'DCTDecode', 'data'=>$data); } protected function _parsepng($file) { // Extract info from a PNG file $f = fopen($file,'rb'); if(!$f) $this->Error('Can\'t open image file: '.$file); $info = $this->_parsepngstream($f,$file); fclose($f); return $info; } protected function _parsepngstream($f, $file) { // Check signature if($this->_readstream($f,8)!=chr(137).'PNG'.chr(13).chr(10).chr(26).chr(10)) $this->Error('Not a PNG file: '.$file); // Read header chunk $this->_readstream($f,4); if($this->_readstream($f,4)!='IHDR') $this->Error('Incorrect PNG file: '.$file); $w = $this->_readint($f); $h = $this->_readint($f); $bpc = ord($this->_readstream($f,1)); if($bpc>8) $this->Error('16-bit depth not supported: '.$file); $ct = ord($this->_readstream($f,1)); if($ct==0 || $ct==4) $colspace = 'DeviceGray'; elseif($ct==2 || $ct==6) $colspace = 'DeviceRGB'; elseif($ct==3) $colspace = 'Indexed'; else $this->Error('Unknown color type: '.$file); if(ord($this->_readstream($f,1))!=0) $this->Error('Unknown compression method: '.$file); if(ord($this->_readstream($f,1))!=0) $this->Error('Unknown filter method: '.$file); if(ord($this->_readstream($f,1))!=0) $this->Error('Interlacing not supported: '.$file);
php
MIT
07b0d7303c2d2563b7adfd8af1cabe389c114bac
2026-01-05T04:46:00.013344Z
true
jeffpiazza/derbynet
https://github.com/jeffpiazza/derbynet/blob/07b0d7303c2d2563b7adfd8af1cabe389c114bac/website/fpdf/font/courieri.php
website/fpdf/font/courieri.php
<?php $type = 'Core'; $name = 'Courier-Oblique'; $up = -100; $ut = 50; for($i=0;$i<=255;$i++) $cw[chr($i)] = 600; $enc = 'cp1252'; $uv = array(0=>array(0,128),128=>8364,130=>8218,131=>402,132=>8222,133=>8230,134=>array(8224,2),136=>710,137=>8240,138=>352,139=>8249,140=>338,142=>381,145=>array(8216,2),147=>array(8220,2),149=>8226,150=>array(8211,2),152=>732,153=>8482,154=>353,155=>8250,156=>339,158=>382,159=>376,160=>array(160,96)); ?>
php
MIT
07b0d7303c2d2563b7adfd8af1cabe389c114bac
2026-01-05T04:46:00.013344Z
false
jeffpiazza/derbynet
https://github.com/jeffpiazza/derbynet/blob/07b0d7303c2d2563b7adfd8af1cabe389c114bac/website/fpdf/font/helveticai.php
website/fpdf/font/helveticai.php
<?php $type = 'Core'; $name = 'Helvetica-Oblique'; $up = -100; $ut = 50; $cw = array( chr(0)=>278,chr(1)=>278,chr(2)=>278,chr(3)=>278,chr(4)=>278,chr(5)=>278,chr(6)=>278,chr(7)=>278,chr(8)=>278,chr(9)=>278,chr(10)=>278,chr(11)=>278,chr(12)=>278,chr(13)=>278,chr(14)=>278,chr(15)=>278,chr(16)=>278,chr(17)=>278,chr(18)=>278,chr(19)=>278,chr(20)=>278,chr(21)=>278, chr(22)=>278,chr(23)=>278,chr(24)=>278,chr(25)=>278,chr(26)=>278,chr(27)=>278,chr(28)=>278,chr(29)=>278,chr(30)=>278,chr(31)=>278,' '=>278,'!'=>278,'"'=>355,'#'=>556,'$'=>556,'%'=>889,'&'=>667,'\''=>191,'('=>333,')'=>333,'*'=>389,'+'=>584, ','=>278,'-'=>333,'.'=>278,'/'=>278,'0'=>556,'1'=>556,'2'=>556,'3'=>556,'4'=>556,'5'=>556,'6'=>556,'7'=>556,'8'=>556,'9'=>556,':'=>278,';'=>278,'<'=>584,'='=>584,'>'=>584,'?'=>556,'@'=>1015,'A'=>667, 'B'=>667,'C'=>722,'D'=>722,'E'=>667,'F'=>611,'G'=>778,'H'=>722,'I'=>278,'J'=>500,'K'=>667,'L'=>556,'M'=>833,'N'=>722,'O'=>778,'P'=>667,'Q'=>778,'R'=>722,'S'=>667,'T'=>611,'U'=>722,'V'=>667,'W'=>944, 'X'=>667,'Y'=>667,'Z'=>611,'['=>278,'\\'=>278,']'=>278,'^'=>469,'_'=>556,'`'=>333,'a'=>556,'b'=>556,'c'=>500,'d'=>556,'e'=>556,'f'=>278,'g'=>556,'h'=>556,'i'=>222,'j'=>222,'k'=>500,'l'=>222,'m'=>833, 'n'=>556,'o'=>556,'p'=>556,'q'=>556,'r'=>333,'s'=>500,'t'=>278,'u'=>556,'v'=>500,'w'=>722,'x'=>500,'y'=>500,'z'=>500,'{'=>334,'|'=>260,'}'=>334,'~'=>584,chr(127)=>350,chr(128)=>556,chr(129)=>350,chr(130)=>222,chr(131)=>556, chr(132)=>333,chr(133)=>1000,chr(134)=>556,chr(135)=>556,chr(136)=>333,chr(137)=>1000,chr(138)=>667,chr(139)=>333,chr(140)=>1000,chr(141)=>350,chr(142)=>611,chr(143)=>350,chr(144)=>350,chr(145)=>222,chr(146)=>222,chr(147)=>333,chr(148)=>333,chr(149)=>350,chr(150)=>556,chr(151)=>1000,chr(152)=>333,chr(153)=>1000, chr(154)=>500,chr(155)=>333,chr(156)=>944,chr(157)=>350,chr(158)=>500,chr(159)=>667,chr(160)=>278,chr(161)=>333,chr(162)=>556,chr(163)=>556,chr(164)=>556,chr(165)=>556,chr(166)=>260,chr(167)=>556,chr(168)=>333,chr(169)=>737,chr(170)=>370,chr(171)=>556,chr(172)=>584,chr(173)=>333,chr(174)=>737,chr(175)=>333, chr(176)=>400,chr(177)=>584,chr(178)=>333,chr(179)=>333,chr(180)=>333,chr(181)=>556,chr(182)=>537,chr(183)=>278,chr(184)=>333,chr(185)=>333,chr(186)=>365,chr(187)=>556,chr(188)=>834,chr(189)=>834,chr(190)=>834,chr(191)=>611,chr(192)=>667,chr(193)=>667,chr(194)=>667,chr(195)=>667,chr(196)=>667,chr(197)=>667, chr(198)=>1000,chr(199)=>722,chr(200)=>667,chr(201)=>667,chr(202)=>667,chr(203)=>667,chr(204)=>278,chr(205)=>278,chr(206)=>278,chr(207)=>278,chr(208)=>722,chr(209)=>722,chr(210)=>778,chr(211)=>778,chr(212)=>778,chr(213)=>778,chr(214)=>778,chr(215)=>584,chr(216)=>778,chr(217)=>722,chr(218)=>722,chr(219)=>722, chr(220)=>722,chr(221)=>667,chr(222)=>667,chr(223)=>611,chr(224)=>556,chr(225)=>556,chr(226)=>556,chr(227)=>556,chr(228)=>556,chr(229)=>556,chr(230)=>889,chr(231)=>500,chr(232)=>556,chr(233)=>556,chr(234)=>556,chr(235)=>556,chr(236)=>278,chr(237)=>278,chr(238)=>278,chr(239)=>278,chr(240)=>556,chr(241)=>556, chr(242)=>556,chr(243)=>556,chr(244)=>556,chr(245)=>556,chr(246)=>556,chr(247)=>584,chr(248)=>611,chr(249)=>556,chr(250)=>556,chr(251)=>556,chr(252)=>556,chr(253)=>500,chr(254)=>556,chr(255)=>500); $enc = 'cp1252'; $uv = array(0=>array(0,128),128=>8364,130=>8218,131=>402,132=>8222,133=>8230,134=>array(8224,2),136=>710,137=>8240,138=>352,139=>8249,140=>338,142=>381,145=>array(8216,2),147=>array(8220,2),149=>8226,150=>array(8211,2),152=>732,153=>8482,154=>353,155=>8250,156=>339,158=>382,159=>376,160=>array(160,96)); ?>
php
MIT
07b0d7303c2d2563b7adfd8af1cabe389c114bac
2026-01-05T04:46:00.013344Z
false
jeffpiazza/derbynet
https://github.com/jeffpiazza/derbynet/blob/07b0d7303c2d2563b7adfd8af1cabe389c114bac/website/fpdf/font/helveticab.php
website/fpdf/font/helveticab.php
<?php $type = 'Core'; $name = 'Helvetica-Bold'; $up = -100; $ut = 50; $cw = array( chr(0)=>278,chr(1)=>278,chr(2)=>278,chr(3)=>278,chr(4)=>278,chr(5)=>278,chr(6)=>278,chr(7)=>278,chr(8)=>278,chr(9)=>278,chr(10)=>278,chr(11)=>278,chr(12)=>278,chr(13)=>278,chr(14)=>278,chr(15)=>278,chr(16)=>278,chr(17)=>278,chr(18)=>278,chr(19)=>278,chr(20)=>278,chr(21)=>278, chr(22)=>278,chr(23)=>278,chr(24)=>278,chr(25)=>278,chr(26)=>278,chr(27)=>278,chr(28)=>278,chr(29)=>278,chr(30)=>278,chr(31)=>278,' '=>278,'!'=>333,'"'=>474,'#'=>556,'$'=>556,'%'=>889,'&'=>722,'\''=>238,'('=>333,')'=>333,'*'=>389,'+'=>584, ','=>278,'-'=>333,'.'=>278,'/'=>278,'0'=>556,'1'=>556,'2'=>556,'3'=>556,'4'=>556,'5'=>556,'6'=>556,'7'=>556,'8'=>556,'9'=>556,':'=>333,';'=>333,'<'=>584,'='=>584,'>'=>584,'?'=>611,'@'=>975,'A'=>722, 'B'=>722,'C'=>722,'D'=>722,'E'=>667,'F'=>611,'G'=>778,'H'=>722,'I'=>278,'J'=>556,'K'=>722,'L'=>611,'M'=>833,'N'=>722,'O'=>778,'P'=>667,'Q'=>778,'R'=>722,'S'=>667,'T'=>611,'U'=>722,'V'=>667,'W'=>944, 'X'=>667,'Y'=>667,'Z'=>611,'['=>333,'\\'=>278,']'=>333,'^'=>584,'_'=>556,'`'=>333,'a'=>556,'b'=>611,'c'=>556,'d'=>611,'e'=>556,'f'=>333,'g'=>611,'h'=>611,'i'=>278,'j'=>278,'k'=>556,'l'=>278,'m'=>889, 'n'=>611,'o'=>611,'p'=>611,'q'=>611,'r'=>389,'s'=>556,'t'=>333,'u'=>611,'v'=>556,'w'=>778,'x'=>556,'y'=>556,'z'=>500,'{'=>389,'|'=>280,'}'=>389,'~'=>584,chr(127)=>350,chr(128)=>556,chr(129)=>350,chr(130)=>278,chr(131)=>556, chr(132)=>500,chr(133)=>1000,chr(134)=>556,chr(135)=>556,chr(136)=>333,chr(137)=>1000,chr(138)=>667,chr(139)=>333,chr(140)=>1000,chr(141)=>350,chr(142)=>611,chr(143)=>350,chr(144)=>350,chr(145)=>278,chr(146)=>278,chr(147)=>500,chr(148)=>500,chr(149)=>350,chr(150)=>556,chr(151)=>1000,chr(152)=>333,chr(153)=>1000, chr(154)=>556,chr(155)=>333,chr(156)=>944,chr(157)=>350,chr(158)=>500,chr(159)=>667,chr(160)=>278,chr(161)=>333,chr(162)=>556,chr(163)=>556,chr(164)=>556,chr(165)=>556,chr(166)=>280,chr(167)=>556,chr(168)=>333,chr(169)=>737,chr(170)=>370,chr(171)=>556,chr(172)=>584,chr(173)=>333,chr(174)=>737,chr(175)=>333, chr(176)=>400,chr(177)=>584,chr(178)=>333,chr(179)=>333,chr(180)=>333,chr(181)=>611,chr(182)=>556,chr(183)=>278,chr(184)=>333,chr(185)=>333,chr(186)=>365,chr(187)=>556,chr(188)=>834,chr(189)=>834,chr(190)=>834,chr(191)=>611,chr(192)=>722,chr(193)=>722,chr(194)=>722,chr(195)=>722,chr(196)=>722,chr(197)=>722, chr(198)=>1000,chr(199)=>722,chr(200)=>667,chr(201)=>667,chr(202)=>667,chr(203)=>667,chr(204)=>278,chr(205)=>278,chr(206)=>278,chr(207)=>278,chr(208)=>722,chr(209)=>722,chr(210)=>778,chr(211)=>778,chr(212)=>778,chr(213)=>778,chr(214)=>778,chr(215)=>584,chr(216)=>778,chr(217)=>722,chr(218)=>722,chr(219)=>722, chr(220)=>722,chr(221)=>667,chr(222)=>667,chr(223)=>611,chr(224)=>556,chr(225)=>556,chr(226)=>556,chr(227)=>556,chr(228)=>556,chr(229)=>556,chr(230)=>889,chr(231)=>556,chr(232)=>556,chr(233)=>556,chr(234)=>556,chr(235)=>556,chr(236)=>278,chr(237)=>278,chr(238)=>278,chr(239)=>278,chr(240)=>611,chr(241)=>611, chr(242)=>611,chr(243)=>611,chr(244)=>611,chr(245)=>611,chr(246)=>611,chr(247)=>584,chr(248)=>611,chr(249)=>611,chr(250)=>611,chr(251)=>611,chr(252)=>611,chr(253)=>556,chr(254)=>611,chr(255)=>556); $enc = 'cp1252'; $uv = array(0=>array(0,128),128=>8364,130=>8218,131=>402,132=>8222,133=>8230,134=>array(8224,2),136=>710,137=>8240,138=>352,139=>8249,140=>338,142=>381,145=>array(8216,2),147=>array(8220,2),149=>8226,150=>array(8211,2),152=>732,153=>8482,154=>353,155=>8250,156=>339,158=>382,159=>376,160=>array(160,96)); ?>
php
MIT
07b0d7303c2d2563b7adfd8af1cabe389c114bac
2026-01-05T04:46:00.013344Z
false
jeffpiazza/derbynet
https://github.com/jeffpiazza/derbynet/blob/07b0d7303c2d2563b7adfd8af1cabe389c114bac/website/fpdf/font/timesi.php
website/fpdf/font/timesi.php
<?php $type = 'Core'; $name = 'Times-Italic'; $up = -100; $ut = 50; $cw = array( chr(0)=>250,chr(1)=>250,chr(2)=>250,chr(3)=>250,chr(4)=>250,chr(5)=>250,chr(6)=>250,chr(7)=>250,chr(8)=>250,chr(9)=>250,chr(10)=>250,chr(11)=>250,chr(12)=>250,chr(13)=>250,chr(14)=>250,chr(15)=>250,chr(16)=>250,chr(17)=>250,chr(18)=>250,chr(19)=>250,chr(20)=>250,chr(21)=>250, chr(22)=>250,chr(23)=>250,chr(24)=>250,chr(25)=>250,chr(26)=>250,chr(27)=>250,chr(28)=>250,chr(29)=>250,chr(30)=>250,chr(31)=>250,' '=>250,'!'=>333,'"'=>420,'#'=>500,'$'=>500,'%'=>833,'&'=>778,'\''=>214,'('=>333,')'=>333,'*'=>500,'+'=>675, ','=>250,'-'=>333,'.'=>250,'/'=>278,'0'=>500,'1'=>500,'2'=>500,'3'=>500,'4'=>500,'5'=>500,'6'=>500,'7'=>500,'8'=>500,'9'=>500,':'=>333,';'=>333,'<'=>675,'='=>675,'>'=>675,'?'=>500,'@'=>920,'A'=>611, 'B'=>611,'C'=>667,'D'=>722,'E'=>611,'F'=>611,'G'=>722,'H'=>722,'I'=>333,'J'=>444,'K'=>667,'L'=>556,'M'=>833,'N'=>667,'O'=>722,'P'=>611,'Q'=>722,'R'=>611,'S'=>500,'T'=>556,'U'=>722,'V'=>611,'W'=>833, 'X'=>611,'Y'=>556,'Z'=>556,'['=>389,'\\'=>278,']'=>389,'^'=>422,'_'=>500,'`'=>333,'a'=>500,'b'=>500,'c'=>444,'d'=>500,'e'=>444,'f'=>278,'g'=>500,'h'=>500,'i'=>278,'j'=>278,'k'=>444,'l'=>278,'m'=>722, 'n'=>500,'o'=>500,'p'=>500,'q'=>500,'r'=>389,'s'=>389,'t'=>278,'u'=>500,'v'=>444,'w'=>667,'x'=>444,'y'=>444,'z'=>389,'{'=>400,'|'=>275,'}'=>400,'~'=>541,chr(127)=>350,chr(128)=>500,chr(129)=>350,chr(130)=>333,chr(131)=>500, chr(132)=>556,chr(133)=>889,chr(134)=>500,chr(135)=>500,chr(136)=>333,chr(137)=>1000,chr(138)=>500,chr(139)=>333,chr(140)=>944,chr(141)=>350,chr(142)=>556,chr(143)=>350,chr(144)=>350,chr(145)=>333,chr(146)=>333,chr(147)=>556,chr(148)=>556,chr(149)=>350,chr(150)=>500,chr(151)=>889,chr(152)=>333,chr(153)=>980, chr(154)=>389,chr(155)=>333,chr(156)=>667,chr(157)=>350,chr(158)=>389,chr(159)=>556,chr(160)=>250,chr(161)=>389,chr(162)=>500,chr(163)=>500,chr(164)=>500,chr(165)=>500,chr(166)=>275,chr(167)=>500,chr(168)=>333,chr(169)=>760,chr(170)=>276,chr(171)=>500,chr(172)=>675,chr(173)=>333,chr(174)=>760,chr(175)=>333, chr(176)=>400,chr(177)=>675,chr(178)=>300,chr(179)=>300,chr(180)=>333,chr(181)=>500,chr(182)=>523,chr(183)=>250,chr(184)=>333,chr(185)=>300,chr(186)=>310,chr(187)=>500,chr(188)=>750,chr(189)=>750,chr(190)=>750,chr(191)=>500,chr(192)=>611,chr(193)=>611,chr(194)=>611,chr(195)=>611,chr(196)=>611,chr(197)=>611, chr(198)=>889,chr(199)=>667,chr(200)=>611,chr(201)=>611,chr(202)=>611,chr(203)=>611,chr(204)=>333,chr(205)=>333,chr(206)=>333,chr(207)=>333,chr(208)=>722,chr(209)=>667,chr(210)=>722,chr(211)=>722,chr(212)=>722,chr(213)=>722,chr(214)=>722,chr(215)=>675,chr(216)=>722,chr(217)=>722,chr(218)=>722,chr(219)=>722, chr(220)=>722,chr(221)=>556,chr(222)=>611,chr(223)=>500,chr(224)=>500,chr(225)=>500,chr(226)=>500,chr(227)=>500,chr(228)=>500,chr(229)=>500,chr(230)=>667,chr(231)=>444,chr(232)=>444,chr(233)=>444,chr(234)=>444,chr(235)=>444,chr(236)=>278,chr(237)=>278,chr(238)=>278,chr(239)=>278,chr(240)=>500,chr(241)=>500, chr(242)=>500,chr(243)=>500,chr(244)=>500,chr(245)=>500,chr(246)=>500,chr(247)=>675,chr(248)=>500,chr(249)=>500,chr(250)=>500,chr(251)=>500,chr(252)=>500,chr(253)=>444,chr(254)=>500,chr(255)=>444); $enc = 'cp1252'; $uv = array(0=>array(0,128),128=>8364,130=>8218,131=>402,132=>8222,133=>8230,134=>array(8224,2),136=>710,137=>8240,138=>352,139=>8249,140=>338,142=>381,145=>array(8216,2),147=>array(8220,2),149=>8226,150=>array(8211,2),152=>732,153=>8482,154=>353,155=>8250,156=>339,158=>382,159=>376,160=>array(160,96)); ?>
php
MIT
07b0d7303c2d2563b7adfd8af1cabe389c114bac
2026-01-05T04:46:00.013344Z
false
jeffpiazza/derbynet
https://github.com/jeffpiazza/derbynet/blob/07b0d7303c2d2563b7adfd8af1cabe389c114bac/website/fpdf/font/times.php
website/fpdf/font/times.php
<?php $type = 'Core'; $name = 'Times-Roman'; $up = -100; $ut = 50; $cw = array( chr(0)=>250,chr(1)=>250,chr(2)=>250,chr(3)=>250,chr(4)=>250,chr(5)=>250,chr(6)=>250,chr(7)=>250,chr(8)=>250,chr(9)=>250,chr(10)=>250,chr(11)=>250,chr(12)=>250,chr(13)=>250,chr(14)=>250,chr(15)=>250,chr(16)=>250,chr(17)=>250,chr(18)=>250,chr(19)=>250,chr(20)=>250,chr(21)=>250, chr(22)=>250,chr(23)=>250,chr(24)=>250,chr(25)=>250,chr(26)=>250,chr(27)=>250,chr(28)=>250,chr(29)=>250,chr(30)=>250,chr(31)=>250,' '=>250,'!'=>333,'"'=>408,'#'=>500,'$'=>500,'%'=>833,'&'=>778,'\''=>180,'('=>333,')'=>333,'*'=>500,'+'=>564, ','=>250,'-'=>333,'.'=>250,'/'=>278,'0'=>500,'1'=>500,'2'=>500,'3'=>500,'4'=>500,'5'=>500,'6'=>500,'7'=>500,'8'=>500,'9'=>500,':'=>278,';'=>278,'<'=>564,'='=>564,'>'=>564,'?'=>444,'@'=>921,'A'=>722, 'B'=>667,'C'=>667,'D'=>722,'E'=>611,'F'=>556,'G'=>722,'H'=>722,'I'=>333,'J'=>389,'K'=>722,'L'=>611,'M'=>889,'N'=>722,'O'=>722,'P'=>556,'Q'=>722,'R'=>667,'S'=>556,'T'=>611,'U'=>722,'V'=>722,'W'=>944, 'X'=>722,'Y'=>722,'Z'=>611,'['=>333,'\\'=>278,']'=>333,'^'=>469,'_'=>500,'`'=>333,'a'=>444,'b'=>500,'c'=>444,'d'=>500,'e'=>444,'f'=>333,'g'=>500,'h'=>500,'i'=>278,'j'=>278,'k'=>500,'l'=>278,'m'=>778, 'n'=>500,'o'=>500,'p'=>500,'q'=>500,'r'=>333,'s'=>389,'t'=>278,'u'=>500,'v'=>500,'w'=>722,'x'=>500,'y'=>500,'z'=>444,'{'=>480,'|'=>200,'}'=>480,'~'=>541,chr(127)=>350,chr(128)=>500,chr(129)=>350,chr(130)=>333,chr(131)=>500, chr(132)=>444,chr(133)=>1000,chr(134)=>500,chr(135)=>500,chr(136)=>333,chr(137)=>1000,chr(138)=>556,chr(139)=>333,chr(140)=>889,chr(141)=>350,chr(142)=>611,chr(143)=>350,chr(144)=>350,chr(145)=>333,chr(146)=>333,chr(147)=>444,chr(148)=>444,chr(149)=>350,chr(150)=>500,chr(151)=>1000,chr(152)=>333,chr(153)=>980, chr(154)=>389,chr(155)=>333,chr(156)=>722,chr(157)=>350,chr(158)=>444,chr(159)=>722,chr(160)=>250,chr(161)=>333,chr(162)=>500,chr(163)=>500,chr(164)=>500,chr(165)=>500,chr(166)=>200,chr(167)=>500,chr(168)=>333,chr(169)=>760,chr(170)=>276,chr(171)=>500,chr(172)=>564,chr(173)=>333,chr(174)=>760,chr(175)=>333, chr(176)=>400,chr(177)=>564,chr(178)=>300,chr(179)=>300,chr(180)=>333,chr(181)=>500,chr(182)=>453,chr(183)=>250,chr(184)=>333,chr(185)=>300,chr(186)=>310,chr(187)=>500,chr(188)=>750,chr(189)=>750,chr(190)=>750,chr(191)=>444,chr(192)=>722,chr(193)=>722,chr(194)=>722,chr(195)=>722,chr(196)=>722,chr(197)=>722, chr(198)=>889,chr(199)=>667,chr(200)=>611,chr(201)=>611,chr(202)=>611,chr(203)=>611,chr(204)=>333,chr(205)=>333,chr(206)=>333,chr(207)=>333,chr(208)=>722,chr(209)=>722,chr(210)=>722,chr(211)=>722,chr(212)=>722,chr(213)=>722,chr(214)=>722,chr(215)=>564,chr(216)=>722,chr(217)=>722,chr(218)=>722,chr(219)=>722, chr(220)=>722,chr(221)=>722,chr(222)=>556,chr(223)=>500,chr(224)=>444,chr(225)=>444,chr(226)=>444,chr(227)=>444,chr(228)=>444,chr(229)=>444,chr(230)=>667,chr(231)=>444,chr(232)=>444,chr(233)=>444,chr(234)=>444,chr(235)=>444,chr(236)=>278,chr(237)=>278,chr(238)=>278,chr(239)=>278,chr(240)=>500,chr(241)=>500, chr(242)=>500,chr(243)=>500,chr(244)=>500,chr(245)=>500,chr(246)=>500,chr(247)=>564,chr(248)=>500,chr(249)=>500,chr(250)=>500,chr(251)=>500,chr(252)=>500,chr(253)=>500,chr(254)=>500,chr(255)=>500); $enc = 'cp1252'; $uv = array(0=>array(0,128),128=>8364,130=>8218,131=>402,132=>8222,133=>8230,134=>array(8224,2),136=>710,137=>8240,138=>352,139=>8249,140=>338,142=>381,145=>array(8216,2),147=>array(8220,2),149=>8226,150=>array(8211,2),152=>732,153=>8482,154=>353,155=>8250,156=>339,158=>382,159=>376,160=>array(160,96)); ?>
php
MIT
07b0d7303c2d2563b7adfd8af1cabe389c114bac
2026-01-05T04:46:00.013344Z
false
jeffpiazza/derbynet
https://github.com/jeffpiazza/derbynet/blob/07b0d7303c2d2563b7adfd8af1cabe389c114bac/website/fpdf/font/symbol.php
website/fpdf/font/symbol.php
<?php $type = 'Core'; $name = 'Symbol'; $up = -100; $ut = 50; $cw = array( chr(0)=>250,chr(1)=>250,chr(2)=>250,chr(3)=>250,chr(4)=>250,chr(5)=>250,chr(6)=>250,chr(7)=>250,chr(8)=>250,chr(9)=>250,chr(10)=>250,chr(11)=>250,chr(12)=>250,chr(13)=>250,chr(14)=>250,chr(15)=>250,chr(16)=>250,chr(17)=>250,chr(18)=>250,chr(19)=>250,chr(20)=>250,chr(21)=>250, chr(22)=>250,chr(23)=>250,chr(24)=>250,chr(25)=>250,chr(26)=>250,chr(27)=>250,chr(28)=>250,chr(29)=>250,chr(30)=>250,chr(31)=>250,' '=>250,'!'=>333,'"'=>713,'#'=>500,'$'=>549,'%'=>833,'&'=>778,'\''=>439,'('=>333,')'=>333,'*'=>500,'+'=>549, ','=>250,'-'=>549,'.'=>250,'/'=>278,'0'=>500,'1'=>500,'2'=>500,'3'=>500,'4'=>500,'5'=>500,'6'=>500,'7'=>500,'8'=>500,'9'=>500,':'=>278,';'=>278,'<'=>549,'='=>549,'>'=>549,'?'=>444,'@'=>549,'A'=>722, 'B'=>667,'C'=>722,'D'=>612,'E'=>611,'F'=>763,'G'=>603,'H'=>722,'I'=>333,'J'=>631,'K'=>722,'L'=>686,'M'=>889,'N'=>722,'O'=>722,'P'=>768,'Q'=>741,'R'=>556,'S'=>592,'T'=>611,'U'=>690,'V'=>439,'W'=>768, 'X'=>645,'Y'=>795,'Z'=>611,'['=>333,'\\'=>863,']'=>333,'^'=>658,'_'=>500,'`'=>500,'a'=>631,'b'=>549,'c'=>549,'d'=>494,'e'=>439,'f'=>521,'g'=>411,'h'=>603,'i'=>329,'j'=>603,'k'=>549,'l'=>549,'m'=>576, 'n'=>521,'o'=>549,'p'=>549,'q'=>521,'r'=>549,'s'=>603,'t'=>439,'u'=>576,'v'=>713,'w'=>686,'x'=>493,'y'=>686,'z'=>494,'{'=>480,'|'=>200,'}'=>480,'~'=>549,chr(127)=>0,chr(128)=>0,chr(129)=>0,chr(130)=>0,chr(131)=>0, chr(132)=>0,chr(133)=>0,chr(134)=>0,chr(135)=>0,chr(136)=>0,chr(137)=>0,chr(138)=>0,chr(139)=>0,chr(140)=>0,chr(141)=>0,chr(142)=>0,chr(143)=>0,chr(144)=>0,chr(145)=>0,chr(146)=>0,chr(147)=>0,chr(148)=>0,chr(149)=>0,chr(150)=>0,chr(151)=>0,chr(152)=>0,chr(153)=>0, chr(154)=>0,chr(155)=>0,chr(156)=>0,chr(157)=>0,chr(158)=>0,chr(159)=>0,chr(160)=>750,chr(161)=>620,chr(162)=>247,chr(163)=>549,chr(164)=>167,chr(165)=>713,chr(166)=>500,chr(167)=>753,chr(168)=>753,chr(169)=>753,chr(170)=>753,chr(171)=>1042,chr(172)=>987,chr(173)=>603,chr(174)=>987,chr(175)=>603, chr(176)=>400,chr(177)=>549,chr(178)=>411,chr(179)=>549,chr(180)=>549,chr(181)=>713,chr(182)=>494,chr(183)=>460,chr(184)=>549,chr(185)=>549,chr(186)=>549,chr(187)=>549,chr(188)=>1000,chr(189)=>603,chr(190)=>1000,chr(191)=>658,chr(192)=>823,chr(193)=>686,chr(194)=>795,chr(195)=>987,chr(196)=>768,chr(197)=>768, chr(198)=>823,chr(199)=>768,chr(200)=>768,chr(201)=>713,chr(202)=>713,chr(203)=>713,chr(204)=>713,chr(205)=>713,chr(206)=>713,chr(207)=>713,chr(208)=>768,chr(209)=>713,chr(210)=>790,chr(211)=>790,chr(212)=>890,chr(213)=>823,chr(214)=>549,chr(215)=>250,chr(216)=>713,chr(217)=>603,chr(218)=>603,chr(219)=>1042, chr(220)=>987,chr(221)=>603,chr(222)=>987,chr(223)=>603,chr(224)=>494,chr(225)=>329,chr(226)=>790,chr(227)=>790,chr(228)=>786,chr(229)=>713,chr(230)=>384,chr(231)=>384,chr(232)=>384,chr(233)=>384,chr(234)=>384,chr(235)=>384,chr(236)=>494,chr(237)=>494,chr(238)=>494,chr(239)=>494,chr(240)=>0,chr(241)=>329, chr(242)=>274,chr(243)=>686,chr(244)=>686,chr(245)=>686,chr(246)=>384,chr(247)=>384,chr(248)=>384,chr(249)=>384,chr(250)=>384,chr(251)=>384,chr(252)=>494,chr(253)=>494,chr(254)=>494,chr(255)=>0); $uv = array(32=>160,33=>33,34=>8704,35=>35,36=>8707,37=>array(37,2),39=>8715,40=>array(40,2),42=>8727,43=>array(43,2),45=>8722,46=>array(46,18),64=>8773,65=>array(913,2),67=>935,68=>array(916,2),70=>934,71=>915,72=>919,73=>921,74=>977,75=>array(922,4),79=>array(927,2),81=>920,82=>929,83=>array(931,3),86=>962,87=>937,88=>926,89=>936,90=>918,91=>91,92=>8756,93=>93,94=>8869,95=>95,96=>63717,97=>array(945,2),99=>967,100=>array(948,2),102=>966,103=>947,104=>951,105=>953,106=>981,107=>array(954,4),111=>array(959,2),113=>952,114=>961,115=>array(963,3),118=>982,119=>969,120=>958,121=>968,122=>950,123=>array(123,3),126=>8764,160=>8364,161=>978,162=>8242,163=>8804,164=>8725,165=>8734,166=>402,167=>9827,168=>9830,169=>9829,170=>9824,171=>8596,172=>array(8592,4),176=>array(176,2),178=>8243,179=>8805,180=>215,181=>8733,182=>8706,183=>8226,184=>247,185=>array(8800,2),187=>8776,188=>8230,189=>array(63718,2),191=>8629,192=>8501,193=>8465,194=>8476,195=>8472,196=>8855,197=>8853,198=>8709,199=>array(8745,2),201=>8835,202=>8839,203=>8836,204=>8834,205=>8838,206=>array(8712,2),208=>8736,209=>8711,210=>63194,211=>63193,212=>63195,213=>8719,214=>8730,215=>8901,216=>172,217=>array(8743,2),219=>8660,220=>array(8656,4),224=>9674,225=>9001,226=>array(63720,3),229=>8721,230=>array(63723,10),241=>9002,242=>8747,243=>8992,244=>63733,245=>8993,246=>array(63734,9)); ?>
php
MIT
07b0d7303c2d2563b7adfd8af1cabe389c114bac
2026-01-05T04:46:00.013344Z
false
jeffpiazza/derbynet
https://github.com/jeffpiazza/derbynet/blob/07b0d7303c2d2563b7adfd8af1cabe389c114bac/website/fpdf/font/helveticabi.php
website/fpdf/font/helveticabi.php
<?php $type = 'Core'; $name = 'Helvetica-BoldOblique'; $up = -100; $ut = 50; $cw = array( chr(0)=>278,chr(1)=>278,chr(2)=>278,chr(3)=>278,chr(4)=>278,chr(5)=>278,chr(6)=>278,chr(7)=>278,chr(8)=>278,chr(9)=>278,chr(10)=>278,chr(11)=>278,chr(12)=>278,chr(13)=>278,chr(14)=>278,chr(15)=>278,chr(16)=>278,chr(17)=>278,chr(18)=>278,chr(19)=>278,chr(20)=>278,chr(21)=>278, chr(22)=>278,chr(23)=>278,chr(24)=>278,chr(25)=>278,chr(26)=>278,chr(27)=>278,chr(28)=>278,chr(29)=>278,chr(30)=>278,chr(31)=>278,' '=>278,'!'=>333,'"'=>474,'#'=>556,'$'=>556,'%'=>889,'&'=>722,'\''=>238,'('=>333,')'=>333,'*'=>389,'+'=>584, ','=>278,'-'=>333,'.'=>278,'/'=>278,'0'=>556,'1'=>556,'2'=>556,'3'=>556,'4'=>556,'5'=>556,'6'=>556,'7'=>556,'8'=>556,'9'=>556,':'=>333,';'=>333,'<'=>584,'='=>584,'>'=>584,'?'=>611,'@'=>975,'A'=>722, 'B'=>722,'C'=>722,'D'=>722,'E'=>667,'F'=>611,'G'=>778,'H'=>722,'I'=>278,'J'=>556,'K'=>722,'L'=>611,'M'=>833,'N'=>722,'O'=>778,'P'=>667,'Q'=>778,'R'=>722,'S'=>667,'T'=>611,'U'=>722,'V'=>667,'W'=>944, 'X'=>667,'Y'=>667,'Z'=>611,'['=>333,'\\'=>278,']'=>333,'^'=>584,'_'=>556,'`'=>333,'a'=>556,'b'=>611,'c'=>556,'d'=>611,'e'=>556,'f'=>333,'g'=>611,'h'=>611,'i'=>278,'j'=>278,'k'=>556,'l'=>278,'m'=>889, 'n'=>611,'o'=>611,'p'=>611,'q'=>611,'r'=>389,'s'=>556,'t'=>333,'u'=>611,'v'=>556,'w'=>778,'x'=>556,'y'=>556,'z'=>500,'{'=>389,'|'=>280,'}'=>389,'~'=>584,chr(127)=>350,chr(128)=>556,chr(129)=>350,chr(130)=>278,chr(131)=>556, chr(132)=>500,chr(133)=>1000,chr(134)=>556,chr(135)=>556,chr(136)=>333,chr(137)=>1000,chr(138)=>667,chr(139)=>333,chr(140)=>1000,chr(141)=>350,chr(142)=>611,chr(143)=>350,chr(144)=>350,chr(145)=>278,chr(146)=>278,chr(147)=>500,chr(148)=>500,chr(149)=>350,chr(150)=>556,chr(151)=>1000,chr(152)=>333,chr(153)=>1000, chr(154)=>556,chr(155)=>333,chr(156)=>944,chr(157)=>350,chr(158)=>500,chr(159)=>667,chr(160)=>278,chr(161)=>333,chr(162)=>556,chr(163)=>556,chr(164)=>556,chr(165)=>556,chr(166)=>280,chr(167)=>556,chr(168)=>333,chr(169)=>737,chr(170)=>370,chr(171)=>556,chr(172)=>584,chr(173)=>333,chr(174)=>737,chr(175)=>333, chr(176)=>400,chr(177)=>584,chr(178)=>333,chr(179)=>333,chr(180)=>333,chr(181)=>611,chr(182)=>556,chr(183)=>278,chr(184)=>333,chr(185)=>333,chr(186)=>365,chr(187)=>556,chr(188)=>834,chr(189)=>834,chr(190)=>834,chr(191)=>611,chr(192)=>722,chr(193)=>722,chr(194)=>722,chr(195)=>722,chr(196)=>722,chr(197)=>722, chr(198)=>1000,chr(199)=>722,chr(200)=>667,chr(201)=>667,chr(202)=>667,chr(203)=>667,chr(204)=>278,chr(205)=>278,chr(206)=>278,chr(207)=>278,chr(208)=>722,chr(209)=>722,chr(210)=>778,chr(211)=>778,chr(212)=>778,chr(213)=>778,chr(214)=>778,chr(215)=>584,chr(216)=>778,chr(217)=>722,chr(218)=>722,chr(219)=>722, chr(220)=>722,chr(221)=>667,chr(222)=>667,chr(223)=>611,chr(224)=>556,chr(225)=>556,chr(226)=>556,chr(227)=>556,chr(228)=>556,chr(229)=>556,chr(230)=>889,chr(231)=>556,chr(232)=>556,chr(233)=>556,chr(234)=>556,chr(235)=>556,chr(236)=>278,chr(237)=>278,chr(238)=>278,chr(239)=>278,chr(240)=>611,chr(241)=>611, chr(242)=>611,chr(243)=>611,chr(244)=>611,chr(245)=>611,chr(246)=>611,chr(247)=>584,chr(248)=>611,chr(249)=>611,chr(250)=>611,chr(251)=>611,chr(252)=>611,chr(253)=>556,chr(254)=>611,chr(255)=>556); $enc = 'cp1252'; $uv = array(0=>array(0,128),128=>8364,130=>8218,131=>402,132=>8222,133=>8230,134=>array(8224,2),136=>710,137=>8240,138=>352,139=>8249,140=>338,142=>381,145=>array(8216,2),147=>array(8220,2),149=>8226,150=>array(8211,2),152=>732,153=>8482,154=>353,155=>8250,156=>339,158=>382,159=>376,160=>array(160,96)); ?>
php
MIT
07b0d7303c2d2563b7adfd8af1cabe389c114bac
2026-01-05T04:46:00.013344Z
false
jeffpiazza/derbynet
https://github.com/jeffpiazza/derbynet/blob/07b0d7303c2d2563b7adfd8af1cabe389c114bac/website/fpdf/font/courierbi.php
website/fpdf/font/courierbi.php
<?php $type = 'Core'; $name = 'Courier-BoldOblique'; $up = -100; $ut = 50; for($i=0;$i<=255;$i++) $cw[chr($i)] = 600; $enc = 'cp1252'; $uv = array(0=>array(0,128),128=>8364,130=>8218,131=>402,132=>8222,133=>8230,134=>array(8224,2),136=>710,137=>8240,138=>352,139=>8249,140=>338,142=>381,145=>array(8216,2),147=>array(8220,2),149=>8226,150=>array(8211,2),152=>732,153=>8482,154=>353,155=>8250,156=>339,158=>382,159=>376,160=>array(160,96)); ?>
php
MIT
07b0d7303c2d2563b7adfd8af1cabe389c114bac
2026-01-05T04:46:00.013344Z
false
jeffpiazza/derbynet
https://github.com/jeffpiazza/derbynet/blob/07b0d7303c2d2563b7adfd8af1cabe389c114bac/website/fpdf/font/timesbi.php
website/fpdf/font/timesbi.php
<?php $type = 'Core'; $name = 'Times-BoldItalic'; $up = -100; $ut = 50; $cw = array( chr(0)=>250,chr(1)=>250,chr(2)=>250,chr(3)=>250,chr(4)=>250,chr(5)=>250,chr(6)=>250,chr(7)=>250,chr(8)=>250,chr(9)=>250,chr(10)=>250,chr(11)=>250,chr(12)=>250,chr(13)=>250,chr(14)=>250,chr(15)=>250,chr(16)=>250,chr(17)=>250,chr(18)=>250,chr(19)=>250,chr(20)=>250,chr(21)=>250, chr(22)=>250,chr(23)=>250,chr(24)=>250,chr(25)=>250,chr(26)=>250,chr(27)=>250,chr(28)=>250,chr(29)=>250,chr(30)=>250,chr(31)=>250,' '=>250,'!'=>389,'"'=>555,'#'=>500,'$'=>500,'%'=>833,'&'=>778,'\''=>278,'('=>333,')'=>333,'*'=>500,'+'=>570, ','=>250,'-'=>333,'.'=>250,'/'=>278,'0'=>500,'1'=>500,'2'=>500,'3'=>500,'4'=>500,'5'=>500,'6'=>500,'7'=>500,'8'=>500,'9'=>500,':'=>333,';'=>333,'<'=>570,'='=>570,'>'=>570,'?'=>500,'@'=>832,'A'=>667, 'B'=>667,'C'=>667,'D'=>722,'E'=>667,'F'=>667,'G'=>722,'H'=>778,'I'=>389,'J'=>500,'K'=>667,'L'=>611,'M'=>889,'N'=>722,'O'=>722,'P'=>611,'Q'=>722,'R'=>667,'S'=>556,'T'=>611,'U'=>722,'V'=>667,'W'=>889, 'X'=>667,'Y'=>611,'Z'=>611,'['=>333,'\\'=>278,']'=>333,'^'=>570,'_'=>500,'`'=>333,'a'=>500,'b'=>500,'c'=>444,'d'=>500,'e'=>444,'f'=>333,'g'=>500,'h'=>556,'i'=>278,'j'=>278,'k'=>500,'l'=>278,'m'=>778, 'n'=>556,'o'=>500,'p'=>500,'q'=>500,'r'=>389,'s'=>389,'t'=>278,'u'=>556,'v'=>444,'w'=>667,'x'=>500,'y'=>444,'z'=>389,'{'=>348,'|'=>220,'}'=>348,'~'=>570,chr(127)=>350,chr(128)=>500,chr(129)=>350,chr(130)=>333,chr(131)=>500, chr(132)=>500,chr(133)=>1000,chr(134)=>500,chr(135)=>500,chr(136)=>333,chr(137)=>1000,chr(138)=>556,chr(139)=>333,chr(140)=>944,chr(141)=>350,chr(142)=>611,chr(143)=>350,chr(144)=>350,chr(145)=>333,chr(146)=>333,chr(147)=>500,chr(148)=>500,chr(149)=>350,chr(150)=>500,chr(151)=>1000,chr(152)=>333,chr(153)=>1000, chr(154)=>389,chr(155)=>333,chr(156)=>722,chr(157)=>350,chr(158)=>389,chr(159)=>611,chr(160)=>250,chr(161)=>389,chr(162)=>500,chr(163)=>500,chr(164)=>500,chr(165)=>500,chr(166)=>220,chr(167)=>500,chr(168)=>333,chr(169)=>747,chr(170)=>266,chr(171)=>500,chr(172)=>606,chr(173)=>333,chr(174)=>747,chr(175)=>333, chr(176)=>400,chr(177)=>570,chr(178)=>300,chr(179)=>300,chr(180)=>333,chr(181)=>576,chr(182)=>500,chr(183)=>250,chr(184)=>333,chr(185)=>300,chr(186)=>300,chr(187)=>500,chr(188)=>750,chr(189)=>750,chr(190)=>750,chr(191)=>500,chr(192)=>667,chr(193)=>667,chr(194)=>667,chr(195)=>667,chr(196)=>667,chr(197)=>667, chr(198)=>944,chr(199)=>667,chr(200)=>667,chr(201)=>667,chr(202)=>667,chr(203)=>667,chr(204)=>389,chr(205)=>389,chr(206)=>389,chr(207)=>389,chr(208)=>722,chr(209)=>722,chr(210)=>722,chr(211)=>722,chr(212)=>722,chr(213)=>722,chr(214)=>722,chr(215)=>570,chr(216)=>722,chr(217)=>722,chr(218)=>722,chr(219)=>722, chr(220)=>722,chr(221)=>611,chr(222)=>611,chr(223)=>500,chr(224)=>500,chr(225)=>500,chr(226)=>500,chr(227)=>500,chr(228)=>500,chr(229)=>500,chr(230)=>722,chr(231)=>444,chr(232)=>444,chr(233)=>444,chr(234)=>444,chr(235)=>444,chr(236)=>278,chr(237)=>278,chr(238)=>278,chr(239)=>278,chr(240)=>500,chr(241)=>556, chr(242)=>500,chr(243)=>500,chr(244)=>500,chr(245)=>500,chr(246)=>500,chr(247)=>570,chr(248)=>500,chr(249)=>556,chr(250)=>556,chr(251)=>556,chr(252)=>556,chr(253)=>444,chr(254)=>500,chr(255)=>444); $enc = 'cp1252'; $uv = array(0=>array(0,128),128=>8364,130=>8218,131=>402,132=>8222,133=>8230,134=>array(8224,2),136=>710,137=>8240,138=>352,139=>8249,140=>338,142=>381,145=>array(8216,2),147=>array(8220,2),149=>8226,150=>array(8211,2),152=>732,153=>8482,154=>353,155=>8250,156=>339,158=>382,159=>376,160=>array(160,96)); ?>
php
MIT
07b0d7303c2d2563b7adfd8af1cabe389c114bac
2026-01-05T04:46:00.013344Z
false
jeffpiazza/derbynet
https://github.com/jeffpiazza/derbynet/blob/07b0d7303c2d2563b7adfd8af1cabe389c114bac/website/fpdf/font/timesb.php
website/fpdf/font/timesb.php
<?php $type = 'Core'; $name = 'Times-Bold'; $up = -100; $ut = 50; $cw = array( chr(0)=>250,chr(1)=>250,chr(2)=>250,chr(3)=>250,chr(4)=>250,chr(5)=>250,chr(6)=>250,chr(7)=>250,chr(8)=>250,chr(9)=>250,chr(10)=>250,chr(11)=>250,chr(12)=>250,chr(13)=>250,chr(14)=>250,chr(15)=>250,chr(16)=>250,chr(17)=>250,chr(18)=>250,chr(19)=>250,chr(20)=>250,chr(21)=>250, chr(22)=>250,chr(23)=>250,chr(24)=>250,chr(25)=>250,chr(26)=>250,chr(27)=>250,chr(28)=>250,chr(29)=>250,chr(30)=>250,chr(31)=>250,' '=>250,'!'=>333,'"'=>555,'#'=>500,'$'=>500,'%'=>1000,'&'=>833,'\''=>278,'('=>333,')'=>333,'*'=>500,'+'=>570, ','=>250,'-'=>333,'.'=>250,'/'=>278,'0'=>500,'1'=>500,'2'=>500,'3'=>500,'4'=>500,'5'=>500,'6'=>500,'7'=>500,'8'=>500,'9'=>500,':'=>333,';'=>333,'<'=>570,'='=>570,'>'=>570,'?'=>500,'@'=>930,'A'=>722, 'B'=>667,'C'=>722,'D'=>722,'E'=>667,'F'=>611,'G'=>778,'H'=>778,'I'=>389,'J'=>500,'K'=>778,'L'=>667,'M'=>944,'N'=>722,'O'=>778,'P'=>611,'Q'=>778,'R'=>722,'S'=>556,'T'=>667,'U'=>722,'V'=>722,'W'=>1000, 'X'=>722,'Y'=>722,'Z'=>667,'['=>333,'\\'=>278,']'=>333,'^'=>581,'_'=>500,'`'=>333,'a'=>500,'b'=>556,'c'=>444,'d'=>556,'e'=>444,'f'=>333,'g'=>500,'h'=>556,'i'=>278,'j'=>333,'k'=>556,'l'=>278,'m'=>833, 'n'=>556,'o'=>500,'p'=>556,'q'=>556,'r'=>444,'s'=>389,'t'=>333,'u'=>556,'v'=>500,'w'=>722,'x'=>500,'y'=>500,'z'=>444,'{'=>394,'|'=>220,'}'=>394,'~'=>520,chr(127)=>350,chr(128)=>500,chr(129)=>350,chr(130)=>333,chr(131)=>500, chr(132)=>500,chr(133)=>1000,chr(134)=>500,chr(135)=>500,chr(136)=>333,chr(137)=>1000,chr(138)=>556,chr(139)=>333,chr(140)=>1000,chr(141)=>350,chr(142)=>667,chr(143)=>350,chr(144)=>350,chr(145)=>333,chr(146)=>333,chr(147)=>500,chr(148)=>500,chr(149)=>350,chr(150)=>500,chr(151)=>1000,chr(152)=>333,chr(153)=>1000, chr(154)=>389,chr(155)=>333,chr(156)=>722,chr(157)=>350,chr(158)=>444,chr(159)=>722,chr(160)=>250,chr(161)=>333,chr(162)=>500,chr(163)=>500,chr(164)=>500,chr(165)=>500,chr(166)=>220,chr(167)=>500,chr(168)=>333,chr(169)=>747,chr(170)=>300,chr(171)=>500,chr(172)=>570,chr(173)=>333,chr(174)=>747,chr(175)=>333, chr(176)=>400,chr(177)=>570,chr(178)=>300,chr(179)=>300,chr(180)=>333,chr(181)=>556,chr(182)=>540,chr(183)=>250,chr(184)=>333,chr(185)=>300,chr(186)=>330,chr(187)=>500,chr(188)=>750,chr(189)=>750,chr(190)=>750,chr(191)=>500,chr(192)=>722,chr(193)=>722,chr(194)=>722,chr(195)=>722,chr(196)=>722,chr(197)=>722, chr(198)=>1000,chr(199)=>722,chr(200)=>667,chr(201)=>667,chr(202)=>667,chr(203)=>667,chr(204)=>389,chr(205)=>389,chr(206)=>389,chr(207)=>389,chr(208)=>722,chr(209)=>722,chr(210)=>778,chr(211)=>778,chr(212)=>778,chr(213)=>778,chr(214)=>778,chr(215)=>570,chr(216)=>778,chr(217)=>722,chr(218)=>722,chr(219)=>722, chr(220)=>722,chr(221)=>722,chr(222)=>611,chr(223)=>556,chr(224)=>500,chr(225)=>500,chr(226)=>500,chr(227)=>500,chr(228)=>500,chr(229)=>500,chr(230)=>722,chr(231)=>444,chr(232)=>444,chr(233)=>444,chr(234)=>444,chr(235)=>444,chr(236)=>278,chr(237)=>278,chr(238)=>278,chr(239)=>278,chr(240)=>500,chr(241)=>556, chr(242)=>500,chr(243)=>500,chr(244)=>500,chr(245)=>500,chr(246)=>500,chr(247)=>570,chr(248)=>500,chr(249)=>556,chr(250)=>556,chr(251)=>556,chr(252)=>556,chr(253)=>500,chr(254)=>556,chr(255)=>500); $enc = 'cp1252'; $uv = array(0=>array(0,128),128=>8364,130=>8218,131=>402,132=>8222,133=>8230,134=>array(8224,2),136=>710,137=>8240,138=>352,139=>8249,140=>338,142=>381,145=>array(8216,2),147=>array(8220,2),149=>8226,150=>array(8211,2),152=>732,153=>8482,154=>353,155=>8250,156=>339,158=>382,159=>376,160=>array(160,96)); ?>
php
MIT
07b0d7303c2d2563b7adfd8af1cabe389c114bac
2026-01-05T04:46:00.013344Z
false
jeffpiazza/derbynet
https://github.com/jeffpiazza/derbynet/blob/07b0d7303c2d2563b7adfd8af1cabe389c114bac/website/fpdf/font/courierb.php
website/fpdf/font/courierb.php
<?php $type = 'Core'; $name = 'Courier-Bold'; $up = -100; $ut = 50; for($i=0;$i<=255;$i++) $cw[chr($i)] = 600; $enc = 'cp1252'; $uv = array(0=>array(0,128),128=>8364,130=>8218,131=>402,132=>8222,133=>8230,134=>array(8224,2),136=>710,137=>8240,138=>352,139=>8249,140=>338,142=>381,145=>array(8216,2),147=>array(8220,2),149=>8226,150=>array(8211,2),152=>732,153=>8482,154=>353,155=>8250,156=>339,158=>382,159=>376,160=>array(160,96)); ?>
php
MIT
07b0d7303c2d2563b7adfd8af1cabe389c114bac
2026-01-05T04:46:00.013344Z
false
jeffpiazza/derbynet
https://github.com/jeffpiazza/derbynet/blob/07b0d7303c2d2563b7adfd8af1cabe389c114bac/website/fpdf/font/courier.php
website/fpdf/font/courier.php
<?php $type = 'Core'; $name = 'Courier'; $up = -100; $ut = 50; for($i=0;$i<=255;$i++) $cw[chr($i)] = 600; $enc = 'cp1252'; $uv = array(0=>array(0,128),128=>8364,130=>8218,131=>402,132=>8222,133=>8230,134=>array(8224,2),136=>710,137=>8240,138=>352,139=>8249,140=>338,142=>381,145=>array(8216,2),147=>array(8220,2),149=>8226,150=>array(8211,2),152=>732,153=>8482,154=>353,155=>8250,156=>339,158=>382,159=>376,160=>array(160,96)); ?>
php
MIT
07b0d7303c2d2563b7adfd8af1cabe389c114bac
2026-01-05T04:46:00.013344Z
false
jeffpiazza/derbynet
https://github.com/jeffpiazza/derbynet/blob/07b0d7303c2d2563b7adfd8af1cabe389c114bac/website/fpdf/font/black-chancery.php
website/fpdf/font/black-chancery.php
<?php $type = 'TrueType'; $name = 'BlackChancery'; $desc = array('Ascent'=>833,'Descent'=>-417,'CapHeight'=>833,'Flags'=>32,'FontBBox'=>'[-194 -351 1462 833]','ItalicAngle'=>0,'StemV'=>70,'MissingWidth'=>833); $up = -278; $ut = 25; $cw = array( chr(0)=>833,chr(1)=>833,chr(2)=>833,chr(3)=>833,chr(4)=>833,chr(5)=>833,chr(6)=>833,chr(7)=>833,chr(8)=>833,chr(9)=>833,chr(10)=>833,chr(11)=>833,chr(12)=>833,chr(13)=>833,chr(14)=>833,chr(15)=>833,chr(16)=>833,chr(17)=>833,chr(18)=>833,chr(19)=>833,chr(20)=>833,chr(21)=>833, chr(22)=>833,chr(23)=>833,chr(24)=>833,chr(25)=>833,chr(26)=>833,chr(27)=>833,chr(28)=>833,chr(29)=>833,chr(30)=>833,chr(31)=>833,' '=>250,'!'=>365,'"'=>323,'#'=>445,'$'=>392,'%'=>490,'&'=>650,'\''=>125,'('=>230,')'=>230,'*'=>573,'+'=>563, ','=>240,'-'=>586,'.'=>240,'/'=>464,'0'=>450,'1'=>280,'2'=>424,'3'=>424,'4'=>480,'5'=>464,'6'=>480,'7'=>480,'8'=>400,'9'=>448,':'=>240,';'=>240,'<'=>426,'='=>416,'>'=>365,'?'=>592,'@'=>656,'A'=>785, 'B'=>914,'C'=>728,'D'=>999,'E'=>849,'F'=>919,'G'=>846,'H'=>912,'I'=>581,'J'=>670,'K'=>878,'L'=>577,'M'=>974,'N'=>822,'O'=>882,'P'=>842,'Q'=>909,'R'=>920,'S'=>790,'T'=>750,'U'=>922,'V'=>960,'W'=>1134, 'X'=>810,'Y'=>419,'Z'=>784,'['=>262,'\\'=>454,']'=>272,'^'=>397,'_'=>454,'`'=>202,'a'=>462,'b'=>370,'c'=>394,'d'=>458,'e'=>414,'f'=>285,'g'=>410,'h'=>430,'i'=>261,'j'=>196,'k'=>428,'l'=>220,'m'=>681, 'n'=>446,'o'=>450,'p'=>434,'q'=>426,'r'=>402,'s'=>330,'t'=>266,'u'=>490,'v'=>472,'w'=>767,'x'=>491,'y'=>467,'z'=>410,'{'=>350,'|'=>182,'}'=>350,'~'=>456,chr(127)=>833,chr(128)=>833,chr(129)=>833,chr(130)=>833,chr(131)=>833, chr(132)=>833,chr(133)=>762,chr(134)=>404,chr(135)=>349,chr(136)=>833,chr(137)=>833,chr(138)=>833,chr(139)=>180,chr(140)=>1152,chr(141)=>833,chr(142)=>833,chr(143)=>833,chr(144)=>833,chr(145)=>141,chr(146)=>125,chr(147)=>298,chr(148)=>298,chr(149)=>408,chr(150)=>403,chr(151)=>694,chr(152)=>833,chr(153)=>704, chr(154)=>833,chr(155)=>180,chr(156)=>712,chr(157)=>833,chr(158)=>833,chr(159)=>335,chr(160)=>250,chr(161)=>365,chr(162)=>427,chr(163)=>486,chr(164)=>673,chr(165)=>833,chr(166)=>833,chr(167)=>442,chr(168)=>278,chr(169)=>672,chr(170)=>833,chr(171)=>326,chr(172)=>833,chr(173)=>833,chr(174)=>688,chr(175)=>833, chr(176)=>394,chr(177)=>549,chr(178)=>833,chr(179)=>833,chr(180)=>202,chr(181)=>576,chr(182)=>653,chr(183)=>833,chr(184)=>294,chr(185)=>833,chr(186)=>833,chr(187)=>326,chr(188)=>833,chr(189)=>833,chr(190)=>833,chr(191)=>533,chr(192)=>628,chr(193)=>628,chr(194)=>628,chr(195)=>628,chr(196)=>628,chr(197)=>628, chr(198)=>1128,chr(199)=>582,chr(200)=>679,chr(201)=>679,chr(202)=>679,chr(203)=>679,chr(204)=>465,chr(205)=>465,chr(206)=>465,chr(207)=>465,chr(208)=>833,chr(209)=>658,chr(210)=>706,chr(211)=>706,chr(212)=>706,chr(213)=>706,chr(214)=>706,chr(215)=>833,chr(216)=>882,chr(217)=>738,chr(218)=>738,chr(219)=>738, chr(220)=>738,chr(221)=>833,chr(222)=>833,chr(223)=>560,chr(224)=>462,chr(225)=>462,chr(226)=>462,chr(227)=>462,chr(228)=>462,chr(229)=>462,chr(230)=>672,chr(231)=>394,chr(232)=>414,chr(233)=>414,chr(234)=>414,chr(235)=>414,chr(236)=>261,chr(237)=>261,chr(238)=>261,chr(239)=>261,chr(240)=>833,chr(241)=>446, chr(242)=>450,chr(243)=>450,chr(244)=>450,chr(245)=>450,chr(246)=>450,chr(247)=>549,chr(248)=>450,chr(249)=>490,chr(250)=>490,chr(251)=>490,chr(252)=>490,chr(253)=>833,chr(254)=>833,chr(255)=>467); $enc = 'cp1252'; $uv = array(0=>array(0,128),128=>8364,130=>8218,131=>402,132=>8222,133=>8230,134=>array(8224,2),136=>710,137=>8240,138=>352,139=>8249,140=>338,142=>381,145=>array(8216,2),147=>array(8220,2),149=>8226,150=>array(8211,2),152=>732,153=>8482,154=>353,155=>8250,156=>339,158=>382,159=>376,160=>array(160,96)); $file = 'black-chancery.z'; $originalsize = 44180; $subsetted = true; ?>
php
MIT
07b0d7303c2d2563b7adfd8af1cabe389c114bac
2026-01-05T04:46:00.013344Z
false
jeffpiazza/derbynet
https://github.com/jeffpiazza/derbynet/blob/07b0d7303c2d2563b7adfd8af1cabe389c114bac/website/fpdf/font/helvetica.php
website/fpdf/font/helvetica.php
<?php $type = 'Core'; $name = 'Helvetica'; $up = -100; $ut = 50; $cw = array( chr(0)=>278,chr(1)=>278,chr(2)=>278,chr(3)=>278,chr(4)=>278,chr(5)=>278,chr(6)=>278,chr(7)=>278,chr(8)=>278,chr(9)=>278,chr(10)=>278,chr(11)=>278,chr(12)=>278,chr(13)=>278,chr(14)=>278,chr(15)=>278,chr(16)=>278,chr(17)=>278,chr(18)=>278,chr(19)=>278,chr(20)=>278,chr(21)=>278, chr(22)=>278,chr(23)=>278,chr(24)=>278,chr(25)=>278,chr(26)=>278,chr(27)=>278,chr(28)=>278,chr(29)=>278,chr(30)=>278,chr(31)=>278,' '=>278,'!'=>278,'"'=>355,'#'=>556,'$'=>556,'%'=>889,'&'=>667,'\''=>191,'('=>333,')'=>333,'*'=>389,'+'=>584, ','=>278,'-'=>333,'.'=>278,'/'=>278,'0'=>556,'1'=>556,'2'=>556,'3'=>556,'4'=>556,'5'=>556,'6'=>556,'7'=>556,'8'=>556,'9'=>556,':'=>278,';'=>278,'<'=>584,'='=>584,'>'=>584,'?'=>556,'@'=>1015,'A'=>667, 'B'=>667,'C'=>722,'D'=>722,'E'=>667,'F'=>611,'G'=>778,'H'=>722,'I'=>278,'J'=>500,'K'=>667,'L'=>556,'M'=>833,'N'=>722,'O'=>778,'P'=>667,'Q'=>778,'R'=>722,'S'=>667,'T'=>611,'U'=>722,'V'=>667,'W'=>944, 'X'=>667,'Y'=>667,'Z'=>611,'['=>278,'\\'=>278,']'=>278,'^'=>469,'_'=>556,'`'=>333,'a'=>556,'b'=>556,'c'=>500,'d'=>556,'e'=>556,'f'=>278,'g'=>556,'h'=>556,'i'=>222,'j'=>222,'k'=>500,'l'=>222,'m'=>833, 'n'=>556,'o'=>556,'p'=>556,'q'=>556,'r'=>333,'s'=>500,'t'=>278,'u'=>556,'v'=>500,'w'=>722,'x'=>500,'y'=>500,'z'=>500,'{'=>334,'|'=>260,'}'=>334,'~'=>584,chr(127)=>350,chr(128)=>556,chr(129)=>350,chr(130)=>222,chr(131)=>556, chr(132)=>333,chr(133)=>1000,chr(134)=>556,chr(135)=>556,chr(136)=>333,chr(137)=>1000,chr(138)=>667,chr(139)=>333,chr(140)=>1000,chr(141)=>350,chr(142)=>611,chr(143)=>350,chr(144)=>350,chr(145)=>222,chr(146)=>222,chr(147)=>333,chr(148)=>333,chr(149)=>350,chr(150)=>556,chr(151)=>1000,chr(152)=>333,chr(153)=>1000, chr(154)=>500,chr(155)=>333,chr(156)=>944,chr(157)=>350,chr(158)=>500,chr(159)=>667,chr(160)=>278,chr(161)=>333,chr(162)=>556,chr(163)=>556,chr(164)=>556,chr(165)=>556,chr(166)=>260,chr(167)=>556,chr(168)=>333,chr(169)=>737,chr(170)=>370,chr(171)=>556,chr(172)=>584,chr(173)=>333,chr(174)=>737,chr(175)=>333, chr(176)=>400,chr(177)=>584,chr(178)=>333,chr(179)=>333,chr(180)=>333,chr(181)=>556,chr(182)=>537,chr(183)=>278,chr(184)=>333,chr(185)=>333,chr(186)=>365,chr(187)=>556,chr(188)=>834,chr(189)=>834,chr(190)=>834,chr(191)=>611,chr(192)=>667,chr(193)=>667,chr(194)=>667,chr(195)=>667,chr(196)=>667,chr(197)=>667, chr(198)=>1000,chr(199)=>722,chr(200)=>667,chr(201)=>667,chr(202)=>667,chr(203)=>667,chr(204)=>278,chr(205)=>278,chr(206)=>278,chr(207)=>278,chr(208)=>722,chr(209)=>722,chr(210)=>778,chr(211)=>778,chr(212)=>778,chr(213)=>778,chr(214)=>778,chr(215)=>584,chr(216)=>778,chr(217)=>722,chr(218)=>722,chr(219)=>722, chr(220)=>722,chr(221)=>667,chr(222)=>667,chr(223)=>611,chr(224)=>556,chr(225)=>556,chr(226)=>556,chr(227)=>556,chr(228)=>556,chr(229)=>556,chr(230)=>889,chr(231)=>500,chr(232)=>556,chr(233)=>556,chr(234)=>556,chr(235)=>556,chr(236)=>278,chr(237)=>278,chr(238)=>278,chr(239)=>278,chr(240)=>556,chr(241)=>556, chr(242)=>556,chr(243)=>556,chr(244)=>556,chr(245)=>556,chr(246)=>556,chr(247)=>584,chr(248)=>611,chr(249)=>556,chr(250)=>556,chr(251)=>556,chr(252)=>556,chr(253)=>500,chr(254)=>556,chr(255)=>500); $enc = 'cp1252'; $uv = array(0=>array(0,128),128=>8364,130=>8218,131=>402,132=>8222,133=>8230,134=>array(8224,2),136=>710,137=>8240,138=>352,139=>8249,140=>338,142=>381,145=>array(8216,2),147=>array(8220,2),149=>8226,150=>array(8211,2),152=>732,153=>8482,154=>353,155=>8250,156=>339,158=>382,159=>376,160=>array(160,96)); ?>
php
MIT
07b0d7303c2d2563b7adfd8af1cabe389c114bac
2026-01-05T04:46:00.013344Z
false
jeffpiazza/derbynet
https://github.com/jeffpiazza/derbynet/blob/07b0d7303c2d2563b7adfd8af1cabe389c114bac/website/fpdf/font/zapfdingbats.php
website/fpdf/font/zapfdingbats.php
<?php $type = 'Core'; $name = 'ZapfDingbats'; $up = -100; $ut = 50; $cw = array( chr(0)=>0,chr(1)=>0,chr(2)=>0,chr(3)=>0,chr(4)=>0,chr(5)=>0,chr(6)=>0,chr(7)=>0,chr(8)=>0,chr(9)=>0,chr(10)=>0,chr(11)=>0,chr(12)=>0,chr(13)=>0,chr(14)=>0,chr(15)=>0,chr(16)=>0,chr(17)=>0,chr(18)=>0,chr(19)=>0,chr(20)=>0,chr(21)=>0, chr(22)=>0,chr(23)=>0,chr(24)=>0,chr(25)=>0,chr(26)=>0,chr(27)=>0,chr(28)=>0,chr(29)=>0,chr(30)=>0,chr(31)=>0,' '=>278,'!'=>974,'"'=>961,'#'=>974,'$'=>980,'%'=>719,'&'=>789,'\''=>790,'('=>791,')'=>690,'*'=>960,'+'=>939, ','=>549,'-'=>855,'.'=>911,'/'=>933,'0'=>911,'1'=>945,'2'=>974,'3'=>755,'4'=>846,'5'=>762,'6'=>761,'7'=>571,'8'=>677,'9'=>763,':'=>760,';'=>759,'<'=>754,'='=>494,'>'=>552,'?'=>537,'@'=>577,'A'=>692, 'B'=>786,'C'=>788,'D'=>788,'E'=>790,'F'=>793,'G'=>794,'H'=>816,'I'=>823,'J'=>789,'K'=>841,'L'=>823,'M'=>833,'N'=>816,'O'=>831,'P'=>923,'Q'=>744,'R'=>723,'S'=>749,'T'=>790,'U'=>792,'V'=>695,'W'=>776, 'X'=>768,'Y'=>792,'Z'=>759,'['=>707,'\\'=>708,']'=>682,'^'=>701,'_'=>826,'`'=>815,'a'=>789,'b'=>789,'c'=>707,'d'=>687,'e'=>696,'f'=>689,'g'=>786,'h'=>787,'i'=>713,'j'=>791,'k'=>785,'l'=>791,'m'=>873, 'n'=>761,'o'=>762,'p'=>762,'q'=>759,'r'=>759,'s'=>892,'t'=>892,'u'=>788,'v'=>784,'w'=>438,'x'=>138,'y'=>277,'z'=>415,'{'=>392,'|'=>392,'}'=>668,'~'=>668,chr(127)=>0,chr(128)=>390,chr(129)=>390,chr(130)=>317,chr(131)=>317, chr(132)=>276,chr(133)=>276,chr(134)=>509,chr(135)=>509,chr(136)=>410,chr(137)=>410,chr(138)=>234,chr(139)=>234,chr(140)=>334,chr(141)=>334,chr(142)=>0,chr(143)=>0,chr(144)=>0,chr(145)=>0,chr(146)=>0,chr(147)=>0,chr(148)=>0,chr(149)=>0,chr(150)=>0,chr(151)=>0,chr(152)=>0,chr(153)=>0, chr(154)=>0,chr(155)=>0,chr(156)=>0,chr(157)=>0,chr(158)=>0,chr(159)=>0,chr(160)=>0,chr(161)=>732,chr(162)=>544,chr(163)=>544,chr(164)=>910,chr(165)=>667,chr(166)=>760,chr(167)=>760,chr(168)=>776,chr(169)=>595,chr(170)=>694,chr(171)=>626,chr(172)=>788,chr(173)=>788,chr(174)=>788,chr(175)=>788, chr(176)=>788,chr(177)=>788,chr(178)=>788,chr(179)=>788,chr(180)=>788,chr(181)=>788,chr(182)=>788,chr(183)=>788,chr(184)=>788,chr(185)=>788,chr(186)=>788,chr(187)=>788,chr(188)=>788,chr(189)=>788,chr(190)=>788,chr(191)=>788,chr(192)=>788,chr(193)=>788,chr(194)=>788,chr(195)=>788,chr(196)=>788,chr(197)=>788, chr(198)=>788,chr(199)=>788,chr(200)=>788,chr(201)=>788,chr(202)=>788,chr(203)=>788,chr(204)=>788,chr(205)=>788,chr(206)=>788,chr(207)=>788,chr(208)=>788,chr(209)=>788,chr(210)=>788,chr(211)=>788,chr(212)=>894,chr(213)=>838,chr(214)=>1016,chr(215)=>458,chr(216)=>748,chr(217)=>924,chr(218)=>748,chr(219)=>918, chr(220)=>927,chr(221)=>928,chr(222)=>928,chr(223)=>834,chr(224)=>873,chr(225)=>828,chr(226)=>924,chr(227)=>924,chr(228)=>917,chr(229)=>930,chr(230)=>931,chr(231)=>463,chr(232)=>883,chr(233)=>836,chr(234)=>836,chr(235)=>867,chr(236)=>867,chr(237)=>696,chr(238)=>696,chr(239)=>874,chr(240)=>0,chr(241)=>874, chr(242)=>760,chr(243)=>946,chr(244)=>771,chr(245)=>865,chr(246)=>771,chr(247)=>888,chr(248)=>967,chr(249)=>888,chr(250)=>831,chr(251)=>873,chr(252)=>927,chr(253)=>970,chr(254)=>918,chr(255)=>0); $uv = array(32=>32,33=>array(9985,4),37=>9742,38=>array(9990,4),42=>9755,43=>9758,44=>array(9996,28),72=>9733,73=>array(10025,35),108=>9679,109=>10061,110=>9632,111=>array(10063,4),115=>9650,116=>9660,117=>9670,118=>10070,119=>9687,120=>array(10072,7),128=>array(10088,14),161=>array(10081,7),168=>9827,169=>9830,170=>9829,171=>9824,172=>array(9312,10),182=>array(10102,31),213=>8594,214=>array(8596,2),216=>array(10136,24),241=>array(10161,14)); ?>
php
MIT
07b0d7303c2d2563b7adfd8af1cabe389c114bac
2026-01-05T04:46:00.013344Z
false
jeffpiazza/derbynet
https://github.com/jeffpiazza/derbynet/blob/07b0d7303c2d2563b7adfd8af1cabe389c114bac/website/fpdf/ext/gradients.php
website/fpdf/ext/gradients.php
<?php // From http://www.fpdf.org/en/script/script72.php class PDF_Gradients extends PDF_CircularText { var $gradients = array(); function LinearGradient($x, $y, $w, $h, $col1=array(), $col2=array(), $coords=array(0,0,1,0)){ $this->Clip($x,$y,$w,$h); $this->Gradient(2,$col1,$col2,$coords); } function RadialGradient($x, $y, $w, $h, $col1=array(), $col2=array(), $coords=array(0.5,0.5,0.5,0.5,1)){ $this->Clip($x,$y,$w,$h); $this->Gradient(3,$col1,$col2,$coords); } function CoonsPatchMesh($x, $y, $w, $h, $col1=array(), $col2=array(), $col3=array(), $col4=array(), $coords=array(0.00,0.0,0.33,0.00,0.67,0.00,1.00,0.00,1.00,0.33,1.00,0.67,1.00,1.00,0.67,1.00,0.33,1.00,0.00,1.00,0.00,0.67,0.00,0.33), $coords_min=0, $coords_max=1){ $this->Clip($x,$y,$w,$h); $n = count($this->gradients)+1; $this->gradients[$n]['type']=6; //coons patch mesh //check the coords array if it is the simple array or the multi patch array if(!isset($coords[0]['f'])){ //simple array -> convert to multi patch array if(!isset($col1[1])) $col1[1]=$col1[2]=$col1[0]; if(!isset($col2[1])) $col2[1]=$col2[2]=$col2[0]; if(!isset($col3[1])) $col3[1]=$col3[2]=$col3[0]; if(!isset($col4[1])) $col4[1]=$col4[2]=$col4[0]; $patch_array[0]['f']=0; $patch_array[0]['points']=$coords; $patch_array[0]['colors'][0]['r']=$col1[0]; $patch_array[0]['colors'][0]['g']=$col1[1]; $patch_array[0]['colors'][0]['b']=$col1[2]; $patch_array[0]['colors'][1]['r']=$col2[0]; $patch_array[0]['colors'][1]['g']=$col2[1]; $patch_array[0]['colors'][1]['b']=$col2[2]; $patch_array[0]['colors'][2]['r']=$col3[0]; $patch_array[0]['colors'][2]['g']=$col3[1]; $patch_array[0]['colors'][2]['b']=$col3[2]; $patch_array[0]['colors'][3]['r']=$col4[0]; $patch_array[0]['colors'][3]['g']=$col4[1]; $patch_array[0]['colors'][3]['b']=$col4[2]; } else{ //multi patch array $patch_array=$coords; } $bpcd=65535; //16 BitsPerCoordinate //build the data stream $this->gradients[$n]['stream']=''; for($i=0;$i<count($patch_array);$i++){ $this->gradients[$n]['stream'].=chr($patch_array[$i]['f']); //start with the edge flag as 8 bit for($j=0;$j<count($patch_array[$i]['points']);$j++){ //each point as 16 bit $patch_array[$i]['points'][$j]=(($patch_array[$i]['points'][$j]-$coords_min)/($coords_max-$coords_min))*$bpcd; if($patch_array[$i]['points'][$j]<0) $patch_array[$i]['points'][$j]=0; if($patch_array[$i]['points'][$j]>$bpcd) $patch_array[$i]['points'][$j]=$bpcd; $this->gradients[$n]['stream'].=chr(floor($patch_array[$i]['points'][$j]/256)); $this->gradients[$n]['stream'].=chr(floor($patch_array[$i]['points'][$j]%256)); } for($j=0;$j<count($patch_array[$i]['colors']);$j++){ //each color component as 8 bit $this->gradients[$n]['stream'].=chr($patch_array[$i]['colors'][$j]['r']); $this->gradients[$n]['stream'].=chr($patch_array[$i]['colors'][$j]['g']); $this->gradients[$n]['stream'].=chr($patch_array[$i]['colors'][$j]['b']); } } //paint the gradient $this->_out('/Sh'.$n.' sh'); //restore previous Graphic State $this->_out('Q'); } function Clip($x,$y,$w,$h){ //save current Graphic State $s='q'; //set clipping area $s.=sprintf(' %.2F %.2F %.2F %.2F re W n', $x*$this->k, ($this->h-$y)*$this->k, $w*$this->k, -$h*$this->k); //set up transformation matrix for gradient $s.=sprintf(' %.3F 0 0 %.3F %.3F %.3F cm', $w*$this->k, $h*$this->k, $x*$this->k, ($this->h-($y+$h))*$this->k); $this->_out($s); } function Gradient($type, $col1, $col2, $coords){ $n = count($this->gradients)+1; $this->gradients[$n]['type']=$type; if(!isset($col1[1])) $col1[1]=$col1[2]=$col1[0]; $this->gradients[$n]['col1']=sprintf('%.3F %.3F %.3F',($col1[0]/255),($col1[1]/255),($col1[2]/255)); if(!isset($col2[1])) $col2[1]=$col2[2]=$col2[0]; $this->gradients[$n]['col2']=sprintf('%.3F %.3F %.3F',($col2[0]/255),($col2[1]/255),($col2[2]/255)); $this->gradients[$n]['coords']=$coords; //paint the gradient $this->_out('/Sh'.$n.' sh'); //restore previous Graphic State $this->_out('Q'); } function _putshaders(){ foreach($this->gradients as $id=>$grad){ if($grad['type']==2 || $grad['type']==3){ $this->_newobj(); $this->_out('<<'); $this->_out('/FunctionType 2'); $this->_out('/Domain [0.0 1.0]'); $this->_out('/C0 ['.$grad['col1'].']'); $this->_out('/C1 ['.$grad['col2'].']'); $this->_out('/N 1'); $this->_out('>>'); $this->_out('endobj'); $f1=$this->n; } $this->_newobj(); $this->_out('<<'); $this->_out('/ShadingType '.$grad['type']); $this->_out('/ColorSpace /DeviceRGB'); if($grad['type']=='2'){ $this->_out(sprintf('/Coords [%.3F %.3F %.3F %.3F]',$grad['coords'][0],$grad['coords'][1],$grad['coords'][2],$grad['coords'][3])); $this->_out('/Function '.$f1.' 0 R'); $this->_out('/Extend [true true] '); $this->_out('>>'); } elseif($grad['type']==3){ //x0, y0, r0, x1, y1, r1 //at this time radius of inner circle is 0 $this->_out(sprintf('/Coords [%.3F %.3F 0 %.3F %.3F %.3F]',$grad['coords'][0],$grad['coords'][1],$grad['coords'][2],$grad['coords'][3],$grad['coords'][4])); $this->_out('/Function '.$f1.' 0 R'); $this->_out('/Extend [true true] '); $this->_out('>>'); } elseif($grad['type']==6){ $this->_out('/BitsPerCoordinate 16'); $this->_out('/BitsPerComponent 8'); $this->_out('/Decode[0 1 0 1 0 1 0 1 0 1]'); $this->_out('/BitsPerFlag 8'); $this->_out('/Length '.strlen($grad['stream'])); $this->_out('>>'); $this->_putstream($grad['stream']); } $this->_out('endobj'); $this->gradients[$id]['id']=$this->n; } } function _putresourcedict(){ parent::_putresourcedict(); $this->_out('/Shading <<'); foreach($this->gradients as $id=>$grad) $this->_out('/Sh'.$id.' '.$grad['id'].' 0 R'); $this->_out('>>'); } function _putresources(){ $this->_putshaders(); parent::_putresources(); } } ?>
php
MIT
07b0d7303c2d2563b7adfd8af1cabe389c114bac
2026-01-05T04:46:00.013344Z
false
jeffpiazza/derbynet
https://github.com/jeffpiazza/derbynet/blob/07b0d7303c2d2563b7adfd8af1cabe389c114bac/website/fpdf/ext/rotation_and_centering.php
website/fpdf/ext/rotation_and_centering.php
<?php // Some utility methods for rotating text and images class PDF_RotationAndCentering extends PDF_Sequencer { // ** These are unused and untested: ** // function RotatedText($x,$y,$txt,$angle) // { // //Text rotated around its origin // $this->StartTransform(); // $this->Rotate($angle,$x,$y); // $this->Text($x,$y,$txt); // $this->StopTransform(); // } // function RotatedImage($file,$x,$y,$w,$h,$angle) // { // //Image rotated around its upper-left corner // $this->StartTransform(); // $this->Rotate($angle,$x,$y); // $this->Image($file,$x,$y,$w,$h); // $this->StopTransform(); // } // function RotatedCenteredCell($w, $h, $txt, $angle) { // $x = $this->GetX() + $h/2; // $y = $this->GetY() + $w/2; // $this->StartTransform(); // $this->Rotate($angle, $x, $y); // $this->Cell($h, $w, $txt, /* border */ 0, /* ln */ 0, "C"); // $this->StopTransform(); // } // $cx describes the horizontal center, $y the vertical text location. function RotatedCenteredText($cx, $cy, $txt) { $this->StartTransform(); $this->Rotate(90, $cx, $cy); $this->CenteredSequence($cx, $cy, array($txt)); $this->StopTransform(); } } ?>
php
MIT
07b0d7303c2d2563b7adfd8af1cabe389c114bac
2026-01-05T04:46:00.013344Z
false
jeffpiazza/derbynet
https://github.com/jeffpiazza/derbynet/blob/07b0d7303c2d2563b7adfd8af1cabe389c114bac/website/fpdf/ext/mem_image.php
website/fpdf/ext/mem_image.php
<?php // From http://www.fpdf.org/en/script/script45.php // Stream handler to read from global variables class VariableStream { private $varname; private $position; function stream_open($path, $mode, $options, &$opened_path) { $url = parse_url($path); $this->varname = $url['host']; if(!isset($GLOBALS[$this->varname])) { trigger_error('Global variable '.$this->varname.' does not exist', E_USER_WARNING); return false; } $this->position = 0; return true; } function stream_read($count) { $ret = substr($GLOBALS[$this->varname], $this->position, $count); $this->position += strlen($ret); return $ret; } function stream_eof() { return $this->position >= strlen($GLOBALS[$this->varname]); } function stream_tell() { return $this->position; } function stream_seek($offset, $whence) { if($whence==SEEK_SET) { $this->position = $offset; return true; } return false; } function stream_stat() { return array(); } } class PDF_MemImage extends PDF_Gradients { function __construct($orientation='P', $unit='mm', $format='A4') { parent::__construct($orientation, $unit, $format); // Register var stream protocol stream_wrapper_register('var', 'VariableStream'); } function MemImage($data, $x=null, $y=null, $w=0, $h=0, $link='') { // Display the image contained in $data $v = 'img'.md5($data); $GLOBALS[$v] = $data; $a = getimagesize('var://'.$v); if(!$a) $this->Error('Invalid image data'); $type = substr(strstr($a['mime'],'/'),1); $this->Image('var://'.$v, $x, $y, $w, $h, $type, $link); unset($GLOBALS[$v]); } function GDImage($im, $x=null, $y=null, $w=0, $h=0, $link='') { // Display the GD image associated with $im ob_start(); imagepng($im); $data = ob_get_clean(); $this->MemImage($data, $x, $y, $w, $h, $link); } } ?>
php
MIT
07b0d7303c2d2563b7adfd8af1cabe389c114bac
2026-01-05T04:46:00.013344Z
false
jeffpiazza/derbynet
https://github.com/jeffpiazza/derbynet/blob/07b0d7303c2d2563b7adfd8af1cabe389c114bac/website/fpdf/ext/rpdf.php
website/fpdf/ext/rpdf.php
<?php // From http://www.fpdf.org/en/script/script31.php class PDF_TextDirection extends PDF_RoundedRect { function TextWithDirection($x, $y, $txt, $direction='R') { if ($direction=='R') $s=sprintf('BT %.2F %.2F %.2F %.2F %.2F %.2F Tm (%s) Tj ET',1,0,0,1,$x*$this->k,($this->h-$y)*$this->k,$this->_escape($txt)); elseif ($direction=='L') $s=sprintf('BT %.2F %.2F %.2F %.2F %.2F %.2F Tm (%s) Tj ET',-1,0,0,-1,$x*$this->k,($this->h-$y)*$this->k,$this->_escape($txt)); elseif ($direction=='U') $s=sprintf('BT %.2F %.2F %.2F %.2F %.2F %.2F Tm (%s) Tj ET',0,1,-1,0,$x*$this->k,($this->h-$y)*$this->k,$this->_escape($txt)); elseif ($direction=='D') $s=sprintf('BT %.2F %.2F %.2F %.2F %.2F %.2F Tm (%s) Tj ET',0,-1,1,0,$x*$this->k,($this->h-$y)*$this->k,$this->_escape($txt)); else $s=sprintf('BT %.2F %.2F Td (%s) Tj ET',$x*$this->k,($this->h-$y)*$this->k,$this->_escape($txt)); if ($this->ColorFlag) $s='q '.$this->TextColor.' '.$s.' Q'; $this->_out($s); } function TextWithRotation($x, $y, $txt, $txt_angle, $font_angle=0) { $font_angle+=90+$txt_angle; $txt_angle*=M_PI/180; $font_angle*=M_PI/180; $txt_dx=cos($txt_angle); $txt_dy=sin($txt_angle); $font_dx=cos($font_angle); $font_dy=sin($font_angle); $s=sprintf('BT %.2F %.2F %.2F %.2F %.2F %.2F Tm (%s) Tj ET',$txt_dx,$txt_dy,$font_dx,$font_dy,$x*$this->k,($this->h-$y)*$this->k,$this->_escape($txt)); if ($this->ColorFlag) $s='q '.$this->TextColor.' '.$s.' Q'; $this->_out($s); } } ?>
php
MIT
07b0d7303c2d2563b7adfd8af1cabe389c114bac
2026-01-05T04:46:00.013344Z
false
jeffpiazza/derbynet
https://github.com/jeffpiazza/derbynet/blob/07b0d7303c2d2563b7adfd8af1cabe389c114bac/website/fpdf/ext/combined.php
website/fpdf/ext/combined.php
<?php // We build a "chain" of FPDF extensions, as suggested in the FPDF FAQ. require_once('fpdf/fpdf.php'); require_once('fpdf/ext/transform.php'); // PDF_Transform require_once('fpdf/ext/alphapdf.php'); // PDF_Alpha require_once('fpdf/ext/rounded_rect.php'); // PDF_RoundedRect require_once('fpdf/ext/rpdf.php'); // PDF_TextDirection require_once('fpdf/ext/circulartext.php'); // PDF_CircularText require_once('fpdf/ext/gradients.php'); // PDF_Gradients require_once('fpdf/ext/mem_image.php'); // PDF_MemImage require_once('fpdf/ext/barcode.php'); // PDF_Barcode require_once('fpdf/ext/sequencer.php'); // PDF_Sequencer require_once('fpdf/ext/rotation_and_centering.php'); // PDF_RotationAndCentering require_once('fpdf/ext/ellipse.php'); // PDF_Ellipse // We introduce this class to terminate the inheritance chain, so consumers can // be isolated from the details. class PDF_Combined extends PDF_Ellipse { }
php
MIT
07b0d7303c2d2563b7adfd8af1cabe389c114bac
2026-01-05T04:46:00.013344Z
false
jeffpiazza/derbynet
https://github.com/jeffpiazza/derbynet/blob/07b0d7303c2d2563b7adfd8af1cabe389c114bac/website/fpdf/ext/rounded_rect.php
website/fpdf/ext/rounded_rect.php
<?php // From http://www.fpdf.org/en/script/script7.php class PDF_RoundedRect extends PDF_Alpha { function RoundedRect($x, $y, $w, $h, $r, $style = '') { $k = $this->k; $hp = $this->h; if($style=='F') $op='f'; elseif($style=='FD' || $style=='DF') $op='B'; else $op='S'; $MyArc = 4/3 * (sqrt(2) - 1); $this->_out(sprintf('%.2F %.2F m',($x+$r)*$k,($hp-$y)*$k )); $xc = $x+$w-$r ; $yc = $y+$r; $this->_out(sprintf('%.2F %.2F l', $xc*$k,($hp-$y)*$k )); $this->_Arc($xc + $r*$MyArc, $yc - $r, $xc + $r, $yc - $r*$MyArc, $xc + $r, $yc); $xc = $x+$w-$r ; $yc = $y+$h-$r; $this->_out(sprintf('%.2F %.2F l',($x+$w)*$k,($hp-$yc)*$k)); $this->_Arc($xc + $r, $yc + $r*$MyArc, $xc + $r*$MyArc, $yc + $r, $xc, $yc + $r); $xc = $x+$r ; $yc = $y+$h-$r; $this->_out(sprintf('%.2F %.2F l',$xc*$k,($hp-($y+$h))*$k)); $this->_Arc($xc - $r*$MyArc, $yc + $r, $xc - $r, $yc + $r*$MyArc, $xc - $r, $yc); $xc = $x+$r ; $yc = $y+$r; $this->_out(sprintf('%.2F %.2F l',($x)*$k,($hp-$yc)*$k )); $this->_Arc($xc - $r, $yc - $r*$MyArc, $xc - $r*$MyArc, $yc - $r, $xc, $yc - $r); $this->_out($op); } function _Arc($x1, $y1, $x2, $y2, $x3, $y3) { $h = $this->h; $this->_out(sprintf('%.2F %.2F %.2F %.2F %.2F %.2F c ', $x1*$this->k, ($h-$y1)*$this->k, $x2*$this->k, ($h-$y2)*$this->k, $x3*$this->k, ($h-$y3)*$this->k)); } } ?>
php
MIT
07b0d7303c2d2563b7adfd8af1cabe389c114bac
2026-01-05T04:46:00.013344Z
false
jeffpiazza/derbynet
https://github.com/jeffpiazza/derbynet/blob/07b0d7303c2d2563b7adfd8af1cabe389c114bac/website/fpdf/ext/ellipse.php
website/fpdf/ext/ellipse.php
<?php // From http://www.fpdf.org/en/script/script6.php class PDF_Ellipse extends PDF_RotationAndCentering { function Circle($x, $y, $r, $style='D') { $this->Ellipse($x,$y,$r,$r,$style); } function Ellipse($x, $y, $rx, $ry, $style='D') { if($style=='F') $op='f'; elseif($style=='FD' || $style=='DF') $op='B'; else $op='S'; $lx=4/3*(M_SQRT2-1)*$rx; $ly=4/3*(M_SQRT2-1)*$ry; $k=$this->k; $h=$this->h; $this->_out(sprintf('%.2F %.2F m %.2F %.2F %.2F %.2F %.2F %.2F c', ($x+$rx)*$k,($h-$y)*$k, ($x+$rx)*$k,($h-($y-$ly))*$k, ($x+$lx)*$k,($h-($y-$ry))*$k, $x*$k,($h-($y-$ry))*$k)); $this->_out(sprintf('%.2F %.2F %.2F %.2F %.2F %.2F c', ($x-$lx)*$k,($h-($y-$ry))*$k, ($x-$rx)*$k,($h-($y-$ly))*$k, ($x-$rx)*$k,($h-$y)*$k)); $this->_out(sprintf('%.2F %.2F %.2F %.2F %.2F %.2F c', ($x-$rx)*$k,($h-($y+$ly))*$k, ($x-$lx)*$k,($h-($y+$ry))*$k, $x*$k,($h-($y+$ry))*$k)); $this->_out(sprintf('%.2F %.2F %.2F %.2F %.2F %.2F c %s', ($x+$lx)*$k,($h-($y+$ry))*$k, ($x+$rx)*$k,($h-($y+$ly))*$k, ($x+$rx)*$k,($h-$y)*$k, $op)); } } ?>
php
MIT
07b0d7303c2d2563b7adfd8af1cabe389c114bac
2026-01-05T04:46:00.013344Z
false
jeffpiazza/derbynet
https://github.com/jeffpiazza/derbynet/blob/07b0d7303c2d2563b7adfd8af1cabe389c114bac/website/fpdf/ext/barcode.php
website/fpdf/ext/barcode.php
<?php // Based on pdf generator from https://github.com/davidscotttufts/php-barcode // // HorizontalBarcode($x, $y, $w, $h, $text) draws a horizontal bar code (made of vertical bars) // VerticalBarcode($x, $y, $w, $h, $text) draws a vertical bar code (made of horizontal bars) class PDF_Barcode extends PDF_MemImage { function HorizontalBarcode($x, $y, $w, $h, $text) { $code_string = $this->CodeString128($text); $code_length = $this->CodeLength($code_string); $scale = $w/$code_length; $fc = $this->FillColor; $d = 10 * $scale; $this->SetFillColor(255, 255, 255); $this->Rect($x, $y - $d / 2, $w, $h + $d, 'F'); $this->FillColor = $fc; $this->_out($this->FillColor); $x += 10 * $scale; for ($i = 0; $i < strlen($code_string); ++$i) { $bar_width = $scale * substr($code_string, $i, 1); if ($i % 2 == 0) { $this->Rect($x, $y, $bar_width, $h, "F"); } $x += $bar_width; } } // A vertical barcode, made of horizontal bars function VerticalBarcode($x, $y, $w, $h, $text) { $code_string = $this->CodeString128($text); $code_length = $this->CodeLength($code_string); $scale = $h/$code_length; $fc = $this->FillColor; $d = 10 * $scale; $this->SetFillColor(255, 255, 255); $this->Rect($x - $d / 2, $y, $w + $d, $h, 'F'); $this->FillColor = $fc; $this->_out($this->FillColor); $y += $scale * 10; for ($i = 0; $i < strlen($code_string); ++$i) { $bar_width = $scale * substr($code_string, $i, 1); if ($i % 2 == 0) { $this->Rect($x, $y, $w, $bar_width, "F"); } $y += $bar_width; } } private function CodeString128($text) { $code_string = ""; $chksum = 104; // Must not change order of array elements as the checksum depends on the array's key to validate final code $code_array = array(" "=>"212222","!"=>"222122","\""=>"222221","#"=>"121223","$"=>"121322", "%"=>"131222","&"=>"122213","'"=>"122312","("=>"132212",")"=>"221213", "*"=>"221312","+"=>"231212",","=>"112232","-"=>"122132","."=>"122231", "/"=>"113222", "0"=>"123122","1"=>"123221","2"=>"223211","3"=>"221132","4"=>"221231", "5"=>"213212","6"=>"223112","7"=>"312131","8"=>"311222","9"=>"321122", ":"=>"321221",";"=>"312212","<"=>"322112","="=>"322211",">"=>"212123", "?"=>"212321","@"=>"232121", "A"=>"111323","B"=>"131123","C"=>"131321","D"=>"112313","E"=>"132113","F"=>"132311", "G"=>"211313","H"=>"231113","I"=>"231311","J"=>"112133","K"=>"112331","L"=>"132131", "M"=>"113123","N"=>"113321","O"=>"133121","P"=>"313121","Q"=>"211331","R"=>"231131", "S"=>"213113","T"=>"213311","U"=>"213131","V"=>"311123","W"=>"311321","X"=>"331121", "Y"=>"312113","Z"=>"312311", "["=>"332111","\\"=>"314111","]"=>"221411","^"=>"431111","_"=>"111224","\`"=>"111422", "a"=>"121124","b"=>"121421","c"=>"141122","d"=>"141221","e"=>"112214","f"=>"112412", "g"=>"122114","h"=>"122411","i"=>"142112","j"=>"142211","k"=>"241211","l"=>"221114", "m"=>"413111","n"=>"241112","o"=>"134111","p"=>"111242","q"=>"121142","r"=>"121241", "s"=>"114212","t"=>"124112","u"=>"124211","v"=>"411212","w"=>"421112","x"=>"421211", "y"=>"212141","z"=>"214121", "{"=>"412121","|"=>"111143","}"=>"111341","~"=>"131141", "DEL"=>"114113","FNC 3"=>"114311","FNC 2"=>"411113","SHIFT"=>"411311", "CODE C"=>"113141","FNC 4"=>"114131","CODE A"=>"311141","FNC 1"=>"411131", "Start A"=>"211412","Start B"=>"211214","Start C"=>"211232","Stop"=>"2331112"); $code_keys = array_keys($code_array); $code_values = array_flip($code_keys); for ( $X = 1; $X <= strlen($text); $X++ ) { $activeKey = substr( $text, ($X-1), 1); $code_string .= $code_array[$activeKey]; $chksum=($chksum + ($code_values[$activeKey] * $X)); } $code_string .= $code_array[$code_keys[($chksum - (intval($chksum / 103) * 103))]]; return "211214" . $code_string . "2331112"; } private function CodeLength($code_string) { // Pad the edges of the barcode $code_length = 20; for ( $i=1; $i <= strlen($code_string); $i++ ) $code_length = $code_length + (integer)(substr($code_string,($i-1),1)); return $code_length; } } ?>
php
MIT
07b0d7303c2d2563b7adfd8af1cabe389c114bac
2026-01-05T04:46:00.013344Z
false
jeffpiazza/derbynet
https://github.com/jeffpiazza/derbynet/blob/07b0d7303c2d2563b7adfd8af1cabe389c114bac/website/fpdf/ext/alphapdf.php
website/fpdf/ext/alphapdf.php
<?php class PDF_Alpha extends PDF_Transform { var $extgstates = array(); // alpha: real value from 0 (transparent) to 1 (opaque) // bm: blend mode, one of the following: // Normal, Multiply, Screen, Overlay, Darken, Lighten, ColorDodge, ColorBurn, // HardLight, SoftLight, Difference, Exclusion, Hue, Saturation, Color, Luminosity function SetAlpha($alpha, $bm='Normal') { // set alpha for stroking (CA) and non-stroking (ca) operations $gs = $this->AddExtGState(array('ca'=>$alpha, 'CA'=>$alpha, 'BM'=>'/'.$bm)); $this->SetExtGState($gs); } function AddExtGState($parms) { $n = count($this->extgstates)+1; $this->extgstates[$n]['parms'] = $parms; return $n; } function SetExtGState($gs) { $this->_out(sprintf('/GS%d gs', $gs)); } function _enddoc() { if(!empty($this->extgstates) && $this->PDFVersion<'1.4') $this->PDFVersion='1.4'; parent::_enddoc(); } function _putextgstates() { for ($i = 1; $i <= count($this->extgstates); $i++) { $this->_newobj(); $this->extgstates[$i]['n'] = $this->n; $this->_out('<</Type /ExtGState'); $parms = $this->extgstates[$i]['parms']; $this->_out(sprintf('/ca %.3F', $parms['ca'])); $this->_out(sprintf('/CA %.3F', $parms['CA'])); $this->_out('/BM '.$parms['BM']); $this->_out('>>'); $this->_out('endobj'); } } function _putresourcedict() { parent::_putresourcedict(); $this->_out('/ExtGState <<'); foreach($this->extgstates as $k=>$extgstate) $this->_out('/GS'.$k.' '.$extgstate['n'].' 0 R'); $this->_out('>>'); } function _putresources() { $this->_putextgstates(); parent::_putresources(); } } ?>
php
MIT
07b0d7303c2d2563b7adfd8af1cabe389c114bac
2026-01-05T04:46:00.013344Z
false
jeffpiazza/derbynet
https://github.com/jeffpiazza/derbynet/blob/07b0d7303c2d2563b7adfd8af1cabe389c114bac/website/fpdf/ext/circulartext.php
website/fpdf/ext/circulartext.php
<?php // From http://www.fpdf.org/en/script/script82.php class PDF_CircularText extends PDF_TextDirection { function CircularText($x, $y, $r, $text, $align='top', $kerning=120, $fontwidth=100) { $kerning/=100; $fontwidth/=100; if($kerning==0) $this->Error('Please use values unequal to zero for kerning'); if($fontwidth==0) $this->Error('Please use values unequal to zero for font width'); //get width of every letter $t=0; for($i=0; $i<strlen($text); $i++){ $w[$i]=$this->GetStringWidth($text[$i]); $w[$i]*=$kerning*$fontwidth; //total width of string $t+=$w[$i]; } //circumference $u=($r*2)*M_PI; //total width of string in degrees $d=($t/$u)*360; $this->StartTransform(); // rotate matrix for the first letter to center the text // (half of total degrees) if($align=='top'){ $this->Rotate($d/2, $x, $y); } else{ $this->Rotate(-$d/2, $x, $y); } //run through the string for($i=0; $i<strlen($text); $i++){ if($align=='top'){ //rotate matrix half of the width of current letter + half of the width of preceding letter if($i==0){ $this->Rotate(-(($w[$i]/2)/$u)*360, $x, $y); } else{ $this->Rotate(-(($w[$i]/2+$w[$i-1]/2)/$u)*360, $x, $y); } if($fontwidth!=1){ $this->StartTransform(); $this->ScaleX($fontwidth*100, $x, $y); } $this->SetXY($x-$w[$i]/2, $y-$r); } else{ //rotate matrix half of the width of current letter + half of the width of preceding letter if($i==0){ $this->Rotate((($w[$i]/2)/$u)*360, $x, $y); } else{ $this->Rotate((($w[$i]/2+$w[$i-1]/2)/$u)*360, $x, $y); } if($fontwidth!=1){ $this->StartTransform(); $this->ScaleX($fontwidth*100, $x, $y); } $this->SetXY($x-$w[$i]/2, $y+$r-($this->FontSize)); } $this->Cell($w[$i],$this->FontSize,$text[$i],0,0,'C'); if($fontwidth!=1){ $this->StopTransform(); } } $this->StopTransform(); } } ?>
php
MIT
07b0d7303c2d2563b7adfd8af1cabe389c114bac
2026-01-05T04:46:00.013344Z
false
jeffpiazza/derbynet
https://github.com/jeffpiazza/derbynet/blob/07b0d7303c2d2563b7adfd8af1cabe389c114bac/website/fpdf/ext/sequencer.php
website/fpdf/ext/sequencer.php
<?php // This sequencer class draws sequences of text interspersed with tag objects // that may adjust how drawing is performed. // // DrawSequence($x, $y, $sequence) // Renders the sequence, starting at the indicated location. // // CenteredSequence($cx, $y, $sequence) // Horizontally centers the sequence at $cx. // A Tag provides for modifying the current drawing environment interface Tag { public function Apply(&$pdf); } class PDF_Sequencer extends PDF_Barcode { function DrawSequence($x, $y, $sequence) { foreach ($sequence as $item) { if (is_string($item)) { $this->Text($x, $y, $item); $x += $this->GetStringWidth($item); } else { $item->Apply($this); } } } function SequenceWidth($sequence) { $len = 0; foreach ($sequence as $item) { if (is_string($item)) { $len += $this->GetStringWidth($item); } else { $item->Apply($this); } } return $len; } function CenteredSequence($cx, $y, $sequence) { $len = $this->SequenceWidth($sequence); $this->DrawSequence($cx - $len / 2, $y, $sequence); } function CenteredText($cx, $y, $text) { $this->CenteredSequence($cx, $y, array($text)); } } class SetFontTag implements Tag { private $font_name; private $weight; private $size; public function __construct($font_name, $weight, $size) { $this->font_name = $font_name; $this->weight = $weight; $this->size = $size; } public function Apply(&$pdf) { $pdf->SetFont($this->font_name, $this->weight, $this->size); } } ?>
php
MIT
07b0d7303c2d2563b7adfd8af1cabe389c114bac
2026-01-05T04:46:00.013344Z
false
sonata-project/SonataNotificationBundle
https://github.com/sonata-project/SonataNotificationBundle/blob/bb87afcd43c3d64e0b92404ceb0bf038c51d8b2e/.php-cs-fixer.dist.php
.php-cs-fixer.dist.php
<?php /* * DO NOT EDIT THIS FILE! * * It's auto-generated by sonata-project/dev-kit package. */ $header = <<<'HEADER' This file is part of the Sonata Project package. (c) Thomas Rabaix <thomas.rabaix@sonata-project.org> For the full copyright and license information, please view the LICENSE file that was distributed with this source code. HEADER; $rules = [ '@PHP70Migration' => true, '@PHP70Migration:risky' => true, '@PHP71Migration' => true, '@PHP71Migration:risky' => true, '@PHPUnit57Migration:risky' => true, '@PHPUnit60Migration:risky' => true, '@Symfony' => true, '@Symfony:risky' => true, 'array_syntax' => ['syntax' => 'short'], 'combine_consecutive_issets' => true, 'combine_consecutive_unsets' => true, 'compact_nullable_typehint' => true, 'global_namespace_import' => ['import_classes' => false, 'import_constants' => false, 'import_functions' => false], 'header_comment' => ['header' => $header], 'list_syntax' => ['syntax' => 'short'], 'logical_operators' => true, 'method_argument_space' => ['on_multiline' => 'ensure_fully_multiline'], 'multiline_whitespace_before_semicolons' => ['strategy' => 'no_multi_line'], 'no_extra_blank_lines' => true, 'no_php4_constructor' => true, 'no_superfluous_phpdoc_tags' => ['allow_mixed' => true], 'no_useless_else' => true, 'no_useless_return' => true, 'nullable_type_declaration_for_default_null_value' => ['use_nullable_type_declaration' => true], 'ordered_class_elements' => true, 'ordered_imports' => true, 'php_unit_method_casing' => false, 'php_unit_set_up_tear_down_visibility' => true, 'php_unit_strict' => true, 'php_unit_test_annotation' => false, 'php_unit_test_case_static_method_calls' => true, 'phpdoc_order' => true, 'phpdoc_to_comment' => ['ignored_tags' => ['psalm-suppress']], 'single_line_throw' => false, 'static_lambda' => true, 'strict_comparison' => true, 'strict_param' => true, 'types_spaces' => ['space' => 'single'], 'void_return' => false, ]; $finder = PhpCsFixer\Finder::create() ->in(__DIR__) ->exclude('node_modules') ->exclude('Resources/skeleton') ->exclude('Resources/public/vendor') ->exclude('var'); $config = new PhpCsFixer\Config(); $config ->setFinder($finder) ->setRiskyAllowed(true) ->setRules($rules) ->setUsingCache(true); return $config;
php
MIT
bb87afcd43c3d64e0b92404ceb0bf038c51d8b2e
2026-01-05T04:47:35.154999Z
false
sonata-project/SonataNotificationBundle
https://github.com/sonata-project/SonataNotificationBundle/blob/bb87afcd43c3d64e0b92404ceb0bf038c51d8b2e/src/SonataNotificationBundle.php
src/SonataNotificationBundle.php
<?php declare(strict_types=1); /* * This file is part of the Sonata Project package. * * (c) Thomas Rabaix <thomas.rabaix@sonata-project.org> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Sonata\NotificationBundle; use Sonata\CoreBundle\Form\FormHelper; use Sonata\NotificationBundle\DependencyInjection\Compiler\NotificationCompilerPass; use Sonata\NotificationBundle\Form\Type\MessageSerializationType; use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\HttpKernel\Bundle\Bundle; /** * @final since sonata-project/notification-bundle 3.13 */ class SonataNotificationBundle extends Bundle { public function build(ContainerBuilder $container) { $container->addCompilerPass(new NotificationCompilerPass()); $this->registerFormMapping(); } public function boot() { if (!\defined('AMQP_DEBUG')) { // define('AMQP_DEBUG', $this->container->getParameter('kernel.debug')); \define('AMQP_DEBUG', false); } $this->registerFormMapping(); } /** * Register form mapping information. * * NEXT_MAJOR: remove this method */ public function registerFormMapping() { if (class_exists(FormHelper::class)) { FormHelper::registerFormTypeMapping([ 'sonata_notification_api_form_message' => MessageSerializationType::class, ]); } } }
php
MIT
bb87afcd43c3d64e0b92404ceb0bf038c51d8b2e
2026-01-05T04:47:35.154999Z
false
sonata-project/SonataNotificationBundle
https://github.com/sonata-project/SonataNotificationBundle/blob/bb87afcd43c3d64e0b92404ceb0bf038c51d8b2e/src/Event/DoctrineOptimizeListener.php
src/Event/DoctrineOptimizeListener.php
<?php declare(strict_types=1); /* * This file is part of the Sonata Project package. * * (c) Thomas Rabaix <thomas.rabaix@sonata-project.org> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Sonata\NotificationBundle\Event; use Doctrine\Persistence\ManagerRegistry; /** * Doctrine context optimizer * Used to clear the doctrine context on each command iteration. * Do not use with doctrine backend, use DoctrineBackendOptimizeListener instead. * * @author Kevin Nedelec <kevin.nedelec@ekino.com> * * @final since sonata-project/notification-bundle 3.13 */ class DoctrineOptimizeListener implements IterationListener { /** * @var ManagerRegistry */ protected $doctrine; public function __construct(ManagerRegistry $doctrine) { $this->doctrine = $doctrine; } public function iterate(IterateEvent $event) { foreach ($this->doctrine->getManagers() as $name => $manager) { if (!$manager->isOpen()) { throw new \RuntimeException(sprintf('The doctrine manager: %s is closed', $name)); } $manager->getUnitOfWork()->clear(); } } }
php
MIT
bb87afcd43c3d64e0b92404ceb0bf038c51d8b2e
2026-01-05T04:47:35.154999Z
false
sonata-project/SonataNotificationBundle
https://github.com/sonata-project/SonataNotificationBundle/blob/bb87afcd43c3d64e0b92404ceb0bf038c51d8b2e/src/Event/IterationListener.php
src/Event/IterationListener.php
<?php declare(strict_types=1); /* * This file is part of the Sonata Project package. * * (c) Thomas Rabaix <thomas.rabaix@sonata-project.org> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Sonata\NotificationBundle\Event; /** * Listener for ConsumerHandlerCommand iterations event. * * @author Kevin Nedelec <kevin.nedelec@ekino.com> */ interface IterationListener { /** * @return void */ public function iterate(IterateEvent $event); }
php
MIT
bb87afcd43c3d64e0b92404ceb0bf038c51d8b2e
2026-01-05T04:47:35.154999Z
false
sonata-project/SonataNotificationBundle
https://github.com/sonata-project/SonataNotificationBundle/blob/bb87afcd43c3d64e0b92404ceb0bf038c51d8b2e/src/Event/IterateEvent.php
src/Event/IterateEvent.php
<?php declare(strict_types=1); /* * This file is part of the Sonata Project package. * * (c) Thomas Rabaix <thomas.rabaix@sonata-project.org> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Sonata\NotificationBundle\Event; use Sonata\NotificationBundle\Backend\BackendInterface; use Sonata\NotificationBundle\Iterator\MessageIteratorInterface; use Sonata\NotificationBundle\Model\MessageInterface; use Symfony\Contracts\EventDispatcher\Event; /** * Event for ConsumerHandlerCommand iterations event. * * @author Kevin Nedelec <kevin.nedelec@ekino.com> * * @final since sonata-project/notification-bundle 3.13 */ class IterateEvent extends Event { public const EVENT_NAME = 'sonata.notification.event.message_iterate_event'; /** * @var MessageIteratorInterface */ protected $iterator; /** * @var BackendInterface */ protected $backend; /** * @var MessageInterface */ protected $message; /** * @param BackendInterface $backend * @param MessageInterface $message */ public function __construct(MessageIteratorInterface $iterator, ?BackendInterface $backend = null, ?MessageInterface $message = null) { $this->iterator = $iterator; $this->backend = $backend; $this->message = $message; } /** * @return BackendInterface */ public function getBackend() { return $this->backend; } /** * @return MessageIteratorInterface */ public function getIterator() { return $this->iterator; } /** * @return MessageInterface */ public function getMessage() { return $this->message; } }
php
MIT
bb87afcd43c3d64e0b92404ceb0bf038c51d8b2e
2026-01-05T04:47:35.154999Z
false
sonata-project/SonataNotificationBundle
https://github.com/sonata-project/SonataNotificationBundle/blob/bb87afcd43c3d64e0b92404ceb0bf038c51d8b2e/src/Event/DoctrineBackendOptimizeListener.php
src/Event/DoctrineBackendOptimizeListener.php
<?php declare(strict_types=1); /* * This file is part of the Sonata Project package. * * (c) Thomas Rabaix <thomas.rabaix@sonata-project.org> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Sonata\NotificationBundle\Event; use Doctrine\Bundle\DoctrineBundle\Registry; use Doctrine\Persistence\ManagerRegistry; /** * Doctrine context optimizer * Used with doctrine backend to clear context taking care of the batch iterations. * * @author Kevin Nedelec <kevin.nedelec@ekino.com> * * @final since sonata-project/notification-bundle 3.13 */ class DoctrineBackendOptimizeListener implements IterationListener { /** * @var Registry */ protected $doctrine; public function __construct(ManagerRegistry $doctrine) { $this->doctrine = $doctrine; } public function iterate(IterateEvent $event) { if (!method_exists($event->getIterator(), 'isBufferEmpty')) { throw new \LogicException('You can\'t use DoctrineOptimizeListener with this iterator'); } if ($event->getIterator()->isBufferEmpty()) { $this->doctrine->getManager()->getUnitOfWork()->clear(); } } }
php
MIT
bb87afcd43c3d64e0b92404ceb0bf038c51d8b2e
2026-01-05T04:47:35.154999Z
false
sonata-project/SonataNotificationBundle
https://github.com/sonata-project/SonataNotificationBundle/blob/bb87afcd43c3d64e0b92404ceb0bf038c51d8b2e/src/Model/MessageInterface.php
src/Model/MessageInterface.php
<?php declare(strict_types=1); /* * This file is part of the Sonata Project package. * * (c) Thomas Rabaix <thomas.rabaix@sonata-project.org> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Sonata\NotificationBundle\Model; interface MessageInterface { public const STATE_OPEN = 0; public const STATE_IN_PROGRESS = 1; public const STATE_DONE = 2; public const STATE_ERROR = -1; public const STATE_CANCELLED = -2; /** * @return void */ public function setBody(array $body); /** * @return array */ public function getBody(); /** * @param array|string $names * @param mixed $default * * @return mixed */ public function getValue($names, $default = null); /** * @param \DateTime $completedAt */ public function setCompletedAt(?\DateTime $completedAt = null); /** * @return \DateTime */ public function getCompletedAt(); /** * @param \DateTime $createdAt */ public function setCreatedAt(?\DateTime $createdAt = null); /** * @return \DateTime */ public function getCreatedAt(); /** * @param string $group */ public function setGroup($group); /** * @return string */ public function getGroup(); /** * @param string $type */ public function setType($type); /** * @return string */ public function getType(); /** * @param int $state */ public function setState($state); /** * @return int */ public function getState(); /** * @param int $restartCount */ public function setRestartCount($restartCount); /** * @return int */ public function getRestartCount(); /** * @param \DateTime $updatedAt */ public function setUpdatedAt(?\DateTime $updatedAt = null); /** * @return \DateTime */ public function getUpdatedAt(); /** * @param \DateTime $startedAt */ public function setStartedAt(?\DateTime $startedAt = null); /** * @return \DateTime */ public function getStartedAt(); /** * @return string */ public function getStateName(); /** * @return bool */ public function isRunning(); /** * @return bool */ public function isCancelled(); /** * @return bool */ public function isError(); /** * @return bool */ public function isOpen(); }
php
MIT
bb87afcd43c3d64e0b92404ceb0bf038c51d8b2e
2026-01-05T04:47:35.154999Z
false
sonata-project/SonataNotificationBundle
https://github.com/sonata-project/SonataNotificationBundle/blob/bb87afcd43c3d64e0b92404ceb0bf038c51d8b2e/src/Model/MessageManagerInterface.php
src/Model/MessageManagerInterface.php
<?php declare(strict_types=1); /* * This file is part of the Sonata Project package. * * (c) Thomas Rabaix <thomas.rabaix@sonata-project.org> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Sonata\NotificationBundle\Model; use Sonata\DatagridBundle\Pager\PageableInterface; use Sonata\Doctrine\Model\ManagerInterface; interface MessageManagerInterface extends ManagerInterface, PageableInterface { /** * @return array */ public function countStates(); /** * @param int $maxAge */ public function cleanup($maxAge); /** * Cancels a given Message. */ public function cancel(MessageInterface $message); /** * Restarts a given message (cancels it and returns a new one, ready for publication). * * @return MessageInterface $message */ public function restart(MessageInterface $message); /** * @param int $state * @param int $batchSize * * @return MessageInterface[] */ public function findByTypes(array $types, $state, $batchSize); /** * @param int $state * @param int $batchSize * @param int|null $maxAttempts * @param int $attemptDelay * * @return mixed */ public function findByAttempts(array $types, $state, $batchSize, $maxAttempts = null, $attemptDelay = 10); }
php
MIT
bb87afcd43c3d64e0b92404ceb0bf038c51d8b2e
2026-01-05T04:47:35.154999Z
false
sonata-project/SonataNotificationBundle
https://github.com/sonata-project/SonataNotificationBundle/blob/bb87afcd43c3d64e0b92404ceb0bf038c51d8b2e/src/Model/Message.php
src/Model/Message.php
<?php declare(strict_types=1); /* * This file is part of the Sonata Project package. * * (c) Thomas Rabaix <thomas.rabaix@sonata-project.org> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Sonata\NotificationBundle\Model; class Message implements MessageInterface { /** * @var string */ protected $type; /** * @var array */ protected $body; /** * @var int */ protected $state; /** * @var int */ protected $restartCount = 0; /** * @var string */ protected $group; /** * @var \DateTime */ protected $createdAt; /** * @var \DateTime */ protected $updatedAt; /** * @var \DateTime */ protected $startedAt; /** * @var \DateTime */ protected $completedAt; public function __construct() { $this->createdAt = new \DateTime(); $this->updatedAt = new \DateTime(); $this->state = self::STATE_OPEN; } public function __clone() { $this->state = self::STATE_OPEN; $this->startedAt = null; $this->completedAt = null; $this->createdAt = new \DateTime(); $this->updatedAt = new \DateTime(); } public function setBody(array $body) { $this->body = $body; } public function getBody() { return $this->body; } public function getValue($names, $default = null) { if (!\is_array($names)) { $names = [$names]; } $body = $this->getBody(); foreach ($names as $name) { if (!isset($body[$name])) { return $default; } $body = $body[$name]; } return $body; } public function setCompletedAt(?\DateTime $completedAt = null) { $this->completedAt = $completedAt; } public function getCompletedAt() { return $this->completedAt; } public function setCreatedAt(?\DateTime $createdAt = null) { $this->createdAt = $createdAt; } public function getCreatedAt() { return $this->createdAt; } public function setGroup($group) { $this->group = $group; } public function getGroup() { return $this->group; } public function setType($type) { $this->type = $type; } public function getType() { return $this->type; } public function setState($state) { $this->state = $state; } public function getState() { return $this->state; } public function setRestartCount($restartCount) { $this->restartCount = $restartCount; } public function getRestartCount() { return $this->restartCount; } public function setUpdatedAt(?\DateTime $updatedAt = null) { $this->updatedAt = $updatedAt; } public function getUpdatedAt() { return $this->updatedAt; } /** * @return string[] */ public static function getStateList() { return [ self::STATE_OPEN => 'open', self::STATE_IN_PROGRESS => 'in_progress', self::STATE_DONE => 'done', self::STATE_ERROR => 'error', self::STATE_CANCELLED => 'cancelled', ]; } public function setStartedAt(?\DateTime $startedAt = null) { $this->startedAt = $startedAt; } public function getStartedAt() { return $this->startedAt; } public function getStateName() { $list = self::getStateList(); return isset($list[$this->getState()]) ? $list[$this->getState()] : ''; } public function isRunning() { return self::STATE_IN_PROGRESS === $this->state; } public function isCancelled() { return self::STATE_CANCELLED === $this->state; } public function isError() { return self::STATE_ERROR === $this->state; } public function isOpen() { return self::STATE_OPEN === $this->state; } }
php
MIT
bb87afcd43c3d64e0b92404ceb0bf038c51d8b2e
2026-01-05T04:47:35.154999Z
false
sonata-project/SonataNotificationBundle
https://github.com/sonata-project/SonataNotificationBundle/blob/bb87afcd43c3d64e0b92404ceb0bf038c51d8b2e/src/Iterator/AMQPMessageIterator.php
src/Iterator/AMQPMessageIterator.php
<?php declare(strict_types=1); /* * This file is part of the Sonata Project package. * * (c) Thomas Rabaix <thomas.rabaix@sonata-project.org> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Sonata\NotificationBundle\Iterator; use Interop\Amqp\AmqpConsumer; use PhpAmqpLib\Channel\AMQPChannel; use PhpAmqpLib\Message\AMQPMessage; use Sonata\NotificationBundle\Model\Message; /** * @final since sonata-project/notification-bundle 3.13 */ class AMQPMessageIterator implements MessageIteratorInterface { /** * @deprecated since 3.2, will be removed in 4.x * * @var AMQPChannel */ protected $channel; /** * @var mixed */ protected $message; /** * @deprecated since 3.2, will be removed in 4.x * * @var AMQPMessage */ protected $AMQMessage; /** * @deprecated since 3.2, will be removed in 4.x * * @var string */ protected $queue; /** * @var int */ protected $counter; /** * @var \Interop\Amqp\AmqpMessage */ private $interopMessage; /** * @var int */ private $timeout; /** * @var AmqpConsumer */ private $consumer; /** * @var bool */ private $isValid; public function __construct(AMQPChannel $channel, AmqpConsumer $consumer) { $this->consumer = $consumer; $this->counter = 0; $this->timeout = 0; $this->isValid = true; $this->channel = $channel; $this->queue = $consumer->getQueue()->getQueueName(); } public function current() { return $this->message; } public function next() { $this->isValid = false; if ($amqpMessage = $this->consumer->receive($this->timeout)) { $this->AMQMessage = $this->convertToAmqpLibMessage($amqpMessage); $data = json_decode($amqpMessage->getBody(), true); $data['body']['interopMessage'] = $amqpMessage; // @deprecated $data['body']['AMQMessage'] = $this->AMQMessage; $message = new Message(); $message->setBody($data['body']); $message->setType($data['type']); $message->setState($data['state']); $this->message = $message; ++$this->counter; $this->isValid = true; } } public function key() { $this->counter; } public function valid() { return $this->isValid; } public function rewind() { $this->isValid = true; $this->next(); } /** * @deprecated since 3.2, will be removed in 4.x * * @return AMQPMessage */ private function convertToAmqpLibMessage(\Interop\Amqp\AmqpMessage $amqpMessage) { $amqpLibProperties = $amqpMessage->getHeaders(); $amqpLibProperties['application_headers'] = $amqpMessage->getProperties(); $amqpLibMessage = new AMQPMessage($amqpMessage->getBody(), $amqpLibProperties); $amqpLibMessage->delivery_info = [ 'consumer_tag' => $this->consumer->getConsumerTag(), 'delivery_tag' => $amqpMessage->getDeliveryTag(), 'redelivered' => $amqpMessage->isRedelivered(), 'routing_key' => $amqpMessage->getRoutingKey(), 'channel' => $this->channel, ]; return $amqpLibMessage; } }
php
MIT
bb87afcd43c3d64e0b92404ceb0bf038c51d8b2e
2026-01-05T04:47:35.154999Z
false
sonata-project/SonataNotificationBundle
https://github.com/sonata-project/SonataNotificationBundle/blob/bb87afcd43c3d64e0b92404ceb0bf038c51d8b2e/src/Iterator/MessageIteratorInterface.php
src/Iterator/MessageIteratorInterface.php
<?php declare(strict_types=1); /* * This file is part of the Sonata Project package. * * (c) Thomas Rabaix <thomas.rabaix@sonata-project.org> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Sonata\NotificationBundle\Iterator; interface MessageIteratorInterface extends \Iterator { }
php
MIT
bb87afcd43c3d64e0b92404ceb0bf038c51d8b2e
2026-01-05T04:47:35.154999Z
false
sonata-project/SonataNotificationBundle
https://github.com/sonata-project/SonataNotificationBundle/blob/bb87afcd43c3d64e0b92404ceb0bf038c51d8b2e/src/Iterator/MessageManagerMessageIterator.php
src/Iterator/MessageManagerMessageIterator.php
<?php declare(strict_types=1); /* * This file is part of the Sonata Project package. * * (c) Thomas Rabaix <thomas.rabaix@sonata-project.org> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Sonata\NotificationBundle\Iterator; use Sonata\NotificationBundle\Model\MessageInterface; use Sonata\NotificationBundle\Model\MessageManagerInterface; class MessageManagerMessageIterator implements MessageIteratorInterface { /** * @var MessageManagerInterface */ protected $messageManager; /** * @var int */ protected $counter; /** * @var mixed */ protected $current; /** * @var array */ protected $types; /** * @var int */ protected $batchSize; /** * @var array */ protected $buffer = []; /** * @var int */ protected $pause; /** * @param array $types * @param int $pause * @param int $batchSize */ public function __construct(MessageManagerInterface $messageManager, $types = [], $pause = 500000, $batchSize = 10) { $this->messageManager = $messageManager; $this->counter = 0; $this->pause = $pause; $this->types = $types; $this->batchSize = $batchSize; } public function current() { return $this->current; } public function next() { $this->setCurrent(); ++$this->counter; } public function key() { return $this->counter; } public function valid() { return true; } public function rewind() { $this->setCurrent(); } /** * Return true if the internal buffer is empty. * * @return bool */ public function isBufferEmpty() { return 0 === \count($this->buffer); } /** * Assign current pointer a message. */ protected function setCurrent() { if (0 === \count($this->buffer)) { $this->bufferize($this->types); } $this->current = array_pop($this->buffer); } /** * Fill the inner messages buffer. * * @param array $types */ protected function bufferize($types = []) { while (true) { $this->buffer = $this->findNextMessages($types); if (\count($this->buffer) > 0) { break; } usleep($this->pause); } } /** * Find open messages. * * @param array $types * * @return mixed */ protected function findNextMessages($types) { return $this->messageManager->findByTypes($types, MessageInterface::STATE_OPEN, $this->batchSize); } }
php
MIT
bb87afcd43c3d64e0b92404ceb0bf038c51d8b2e
2026-01-05T04:47:35.154999Z
false
sonata-project/SonataNotificationBundle
https://github.com/sonata-project/SonataNotificationBundle/blob/bb87afcd43c3d64e0b92404ceb0bf038c51d8b2e/src/Iterator/IteratorProxyMessageIterator.php
src/Iterator/IteratorProxyMessageIterator.php
<?php declare(strict_types=1); /* * This file is part of the Sonata Project package. * * (c) Thomas Rabaix <thomas.rabaix@sonata-project.org> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Sonata\NotificationBundle\Iterator; /** * @author Toni Uebernickel <tuebernickel@gmail.com> * * @final since sonata-project/notification-bundle 3.13 */ class IteratorProxyMessageIterator implements MessageIteratorInterface { /** * @var \Iterator */ protected $iterator; public function __construct(\Iterator $iterator) { $this->iterator = $iterator; } public function current() { return $this->iterator->current(); } public function next() { $this->iterator->next(); } public function key() { return $this->iterator->key(); } public function valid() { return $this->iterator->valid(); } public function rewind() { $this->iterator->rewind(); } }
php
MIT
bb87afcd43c3d64e0b92404ceb0bf038c51d8b2e
2026-01-05T04:47:35.154999Z
false
sonata-project/SonataNotificationBundle
https://github.com/sonata-project/SonataNotificationBundle/blob/bb87afcd43c3d64e0b92404ceb0bf038c51d8b2e/src/Iterator/ErroneousMessageIterator.php
src/Iterator/ErroneousMessageIterator.php
<?php declare(strict_types=1); /* * This file is part of the Sonata Project package. * * (c) Thomas Rabaix <thomas.rabaix@sonata-project.org> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Sonata\NotificationBundle\Iterator; use Sonata\NotificationBundle\Model\MessageInterface; use Sonata\NotificationBundle\Model\MessageManagerInterface; /** * @final since sonata-project/notification-bundle 3.13 */ class ErroneousMessageIterator extends MessageManagerMessageIterator { /** * @var int */ protected $maxAttempts; /** * @var int */ protected $attemptDelay; /** * @param array $types * @param int $pause * @param int $batchSize * @param int $maxAttempts * @param int $attemptDelay */ public function __construct(MessageManagerInterface $messageManager, $types = [], $pause = 500000, $batchSize = 10, $maxAttempts = 5, $attemptDelay = 10) { parent::__construct($messageManager, $types, $pause, $batchSize); $this->maxAttempts = $maxAttempts; $this->attemptDelay = $attemptDelay; } /** * Find messages in error. * * @param array $types * * @return mixed */ protected function findNextMessages($types) { return $this->messageManager->findByAttempts( $this->types, MessageInterface::STATE_ERROR, $this->batchSize, $this->maxAttempts, $this->attemptDelay ); } }
php
MIT
bb87afcd43c3d64e0b92404ceb0bf038c51d8b2e
2026-01-05T04:47:35.154999Z
false
sonata-project/SonataNotificationBundle
https://github.com/sonata-project/SonataNotificationBundle/blob/bb87afcd43c3d64e0b92404ceb0bf038c51d8b2e/src/Selector/ErroneousMessagesSelector.php
src/Selector/ErroneousMessagesSelector.php
<?php declare(strict_types=1); /* * This file is part of the Sonata Project package. * * (c) Thomas Rabaix <thomas.rabaix@sonata-project.org> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Sonata\NotificationBundle\Selector; use Doctrine\Persistence\ManagerRegistry; use Sonata\NotificationBundle\Model\MessageInterface; /** * @final since sonata-project/notification-bundle 3.13 */ class ErroneousMessagesSelector { /** * @var string */ protected $class; /** * @var ManagerRegistry */ protected $registry; /** * @param string $class */ public function __construct(ManagerRegistry $registry, $class) { $this->registry = $registry; $this->class = $class; } /** * Retrieve messages with given type(s) and restrict to max attempts count. * * @param int $maxAttempts * * @return array */ public function getMessages(array $types, $maxAttempts = 5) { $query = $this->registry->getManagerForClass($this->class)->getRepository($this->class) ->createQueryBuilder('m') ->where('m.state = :erroneousState') ->andWhere('m.restartCount < :maxAttempts'); $parameters = [ 'erroneousState' => MessageInterface::STATE_ERROR, 'maxAttempts' => $maxAttempts, ]; if (\count($types) > 0) { $query->andWhere('m.type IN (:types)'); $parameters['types'] = $types; } $query->setParameters($parameters); return $query->getQuery()->execute(); } }
php
MIT
bb87afcd43c3d64e0b92404ceb0bf038c51d8b2e
2026-01-05T04:47:35.154999Z
false
sonata-project/SonataNotificationBundle
https://github.com/sonata-project/SonataNotificationBundle/blob/bb87afcd43c3d64e0b92404ceb0bf038c51d8b2e/src/Entity/BaseMessage.php
src/Entity/BaseMessage.php
<?php declare(strict_types=1); /* * This file is part of the Sonata Project package. * * (c) Thomas Rabaix <thomas.rabaix@sonata-project.org> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Sonata\NotificationBundle\Entity; use Sonata\NotificationBundle\Model\Message; class BaseMessage extends Message { /** * @var int */ protected $id; /** * Override clone in order to avoid duplicating entries in Doctrine. */ public function __clone() { parent::__clone(); $this->id = null; } /** * Get id. * * @return int $id */ public function getId() { return $this->id; } }
php
MIT
bb87afcd43c3d64e0b92404ceb0bf038c51d8b2e
2026-01-05T04:47:35.154999Z
false
sonata-project/SonataNotificationBundle
https://github.com/sonata-project/SonataNotificationBundle/blob/bb87afcd43c3d64e0b92404ceb0bf038c51d8b2e/src/Entity/MessageManager.php
src/Entity/MessageManager.php
<?php declare(strict_types=1); /* * This file is part of the Sonata Project package. * * (c) Thomas Rabaix <thomas.rabaix@sonata-project.org> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Sonata\NotificationBundle\Entity; use Doctrine\ORM\QueryBuilder; use Sonata\DatagridBundle\Pager\Doctrine\Pager; use Sonata\DatagridBundle\Pager\PagerInterface; use Sonata\Doctrine\Entity\BaseEntityManager; use Sonata\NotificationBundle\Model\MessageInterface; use Sonata\NotificationBundle\Model\MessageManagerInterface; /** * @final since sonata-project/notification-bundle 3.13 */ class MessageManager extends BaseEntityManager implements MessageManagerInterface { public function save($entity, $andFlush = true) { //Hack for ConsumerHandlerCommand->optimize() if ($entity->getId() && !$this->getEntityManager()->getUnitOfWork()->isInIdentityMap($entity)) { $entity = $this->getEntityManager()->getUnitOfWork()->merge($entity); } parent::save($entity, $andFlush); } public function findByTypes(array $types, $state, $batchSize) { $params = []; $query = $this->prepareStateQuery($state, $types, $batchSize, $params); $query->setParameters($params); return $query->getQuery()->execute(); } public function findByAttempts(array $types, $state, $batchSize, $maxAttempts = null, $attemptDelay = 10) { $params = []; $query = $this->prepareStateQuery($state, $types, $batchSize, $params); if ($maxAttempts) { $query ->andWhere('m.restartCount < :maxAttempts') ->andWhere('m.updatedAt < :delayDate'); $params['maxAttempts'] = $maxAttempts; $now = new \DateTime(); $params['delayDate'] = $now->add(\DateInterval::createFromDateString(($attemptDelay * -1).' second')); } $query->setParameters($params); return $query->getQuery()->execute(); } public function countStates() { $tableName = $this->getEntityManager()->getClassMetadata($this->class)->table['name']; $stm = $this->getConnection()->query( sprintf('SELECT state, count(state) as cnt FROM %s GROUP BY state', $tableName) ); $states = [ MessageInterface::STATE_DONE => 0, MessageInterface::STATE_ERROR => 0, MessageInterface::STATE_IN_PROGRESS => 0, MessageInterface::STATE_OPEN => 0, ]; while ($data = $stm->fetch()) { $states[$data['state']] = $data['cnt']; } return $states; } public function cleanup($maxAge) { $tableName = $this->getEntityManager()->getClassMetadata($this->class)->table['name']; $date = new \DateTime('now'); $date->sub(new \DateInterval(sprintf('PT%sS', $maxAge))); $qb = $this->getRepository()->createQueryBuilder('message') ->delete() ->where('message.state = :state') ->andWhere('message.completedAt < :date') ->setParameter('state', MessageInterface::STATE_DONE) ->setParameter('date', $date); $qb->getQuery()->execute(); } public function cancel(MessageInterface $message, $force = false) { if (($message->isRunning() || $message->isError()) && !$force) { return; } $message->setState(MessageInterface::STATE_CANCELLED); $this->save($message); } public function restart(MessageInterface $message) { if ($message->isOpen() || $message->isRunning() || $message->isCancelled()) { return; } $this->cancel($message, true); $newMessage = clone $message; $newMessage->setRestartCount($message->getRestartCount() + 1); $newMessage->setType($message->getType()); return $newMessage; } public function getPager(array $criteria, int $page, int $limit = 10, array $sort = []): PagerInterface { $query = $this->getRepository() ->createQueryBuilder('m') ->select('m'); $fields = $this->getEntityManager()->getClassMetadata($this->class)->getFieldNames(); foreach ($sort as $field => $direction) { if (!\in_array($field, $fields, true)) { throw new \RuntimeException(sprintf("Invalid sort field '%s' in '%s' class", $field, $this->class)); } } if (0 === \count($sort)) { $sort = ['type' => 'ASC']; } foreach ($sort as $field => $direction) { $query->orderBy(sprintf('m.%s', $field), strtoupper($direction)); } $parameters = []; if (isset($criteria['type'])) { $query->andWhere('m.type = :type'); $parameters['type'] = $criteria['type']; } if (isset($criteria['state'])) { $query->andWhere('m.state = :state'); $parameters['state'] = $criteria['state']; } $query->setParameters($parameters); return Pager::create($query, $limit, $page); } /** * @param int $state * @param array $types * @param int $batchSize * @param array $parameters * * @return QueryBuilder */ protected function prepareStateQuery($state, $types, $batchSize, &$parameters) { $query = $this->getRepository() ->createQueryBuilder('m') ->where('m.state = :state') ->orderBy('m.createdAt'); $parameters['state'] = $state; if (\count($types) > 0) { if (\array_key_exists('exclude', $types) || \array_key_exists('include', $types)) { if (\array_key_exists('exclude', $types)) { $query->andWhere('m.type NOT IN (:exclude)'); $parameters['exclude'] = $types['exclude']; } if (\array_key_exists('include', $types)) { $query->andWhere('m.type IN (:include)'); $parameters['include'] = $types['include']; } } else { // BC $query->andWhere('m.type IN (:types)'); $parameters['types'] = $types; } } $query->setMaxResults($batchSize); return $query; } }
php
MIT
bb87afcd43c3d64e0b92404ceb0bf038c51d8b2e
2026-01-05T04:47:35.154999Z
false
sonata-project/SonataNotificationBundle
https://github.com/sonata-project/SonataNotificationBundle/blob/bb87afcd43c3d64e0b92404ceb0bf038c51d8b2e/src/Controller/MessageAdminController.php
src/Controller/MessageAdminController.php
<?php declare(strict_types=1); /* * This file is part of the Sonata Project package. * * (c) Thomas Rabaix <thomas.rabaix@sonata-project.org> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Sonata\NotificationBundle\Controller; use Sonata\AdminBundle\Controller\CRUDController; use Sonata\AdminBundle\Datagrid\ProxyQueryInterface; use Sonata\NotificationBundle\Backend\BackendInterface; use Sonata\NotificationBundle\Model\MessageManagerInterface; use Symfony\Component\HttpFoundation\RedirectResponse; use Symfony\Component\Security\Core\Exception\AccessDeniedException; /** * @final since sonata-project/notification-bundle 3.13 */ class MessageAdminController extends CRUDController { /** * @throws AccessDeniedException * * @return RedirectResponse */ public function batchActionPublish(ProxyQueryInterface $query) { if (false === $this->admin->isGranted('EDIT')) { throw new AccessDeniedException(); } foreach ($query->execute() as $message) { $message = $this->getMessageManager()->restart($message); $this->getBackend()->publish($message); } return new RedirectResponse($this->admin->generateUrl('list', $this->admin->getFilterParameters())); } /** * @throws AccessDeniedException * * @return RedirectResponse */ public function batchActionCancelled(ProxyQueryInterface $query) { if (false === $this->admin->isGranted('EDIT')) { throw new AccessDeniedException(); } foreach ($query->execute() as $message) { $this->getMessageManager()->cancel($message); } return new RedirectResponse($this->admin->generateUrl('list', $this->admin->getFilterParameters())); } /** * @return MessageManagerInterface */ protected function getMessageManager() { return $this->get('sonata.notification.manager.message'); } /** * @return BackendInterface */ protected function getBackend() { return $this->get('sonata.notification.backend'); } }
php
MIT
bb87afcd43c3d64e0b92404ceb0bf038c51d8b2e
2026-01-05T04:47:35.154999Z
false
sonata-project/SonataNotificationBundle
https://github.com/sonata-project/SonataNotificationBundle/blob/bb87afcd43c3d64e0b92404ceb0bf038c51d8b2e/src/Controller/Api/MessageController.php
src/Controller/Api/MessageController.php
<?php declare(strict_types=1); /* * This file is part of the Sonata Project package. * * (c) Thomas Rabaix <thomas.rabaix@sonata-project.org> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Sonata\NotificationBundle\Controller\Api; use FOS\RestBundle\Controller\Annotations as Rest; use FOS\RestBundle\Request\ParamFetcherInterface; use Nelmio\ApiDocBundle\Annotation\Model; use Nelmio\ApiDocBundle\Annotation\Operation; use Sonata\DatagridBundle\Pager\PagerInterface; use Sonata\NotificationBundle\Form\Type\MessageSerializationType; use Sonata\NotificationBundle\Model\MessageManagerInterface; use Swagger\Annotations as SWG; use Symfony\Component\Form\FormFactoryInterface; use Symfony\Component\Form\FormInterface; use Symfony\Component\HttpFoundation\Request; /** * @author Hugo Briand <briand@ekino.com> * * @final since sonata-project/notification-bundle 3.13 */ class MessageController { /** * @var MessageManagerInterface */ protected $messageManager; /** * @var FormFactoryInterface */ protected $formFactory; public function __construct(MessageManagerInterface $messageManager, FormFactoryInterface $formFactory) { $this->messageManager = $messageManager; $this->formFactory = $formFactory; } /** * Retrieves the list of messages (paginated). * * @Operation( * tags={"/api/notification/messages"}, * summary="Retrieves the list of messages (paginated).", * @SWG\Parameter( * name="page", * in="query", * description="Page for message list pagination", * required=false, * type="string" * ), * @SWG\Parameter( * name="count", * in="query", * description="Number of messages per page", * required=false, * type="string" * ), * @SWG\Parameter( * name="type", * in="query", * description="Message type filter", * required=false, * type="string" * ), * @SWG\Parameter( * name="state", * in="query", * description="Message status filter", * required=false, * type="string" * ), * @SWG\Parameter( * name="orderBy", * in="query", * description="Query groups order by clause (key is field, value is direction)", * required=false, * type="string" * ), * @SWG\Response( * response="200", * description="Returned when successful", * @SWG\Schema(ref=@Model(type="Sonata\DatagridBundle\Pager\PagerInterface")) * ) * ) * * @Rest\QueryParam(name="page", requirements="\d+", default="1", description="Page for message list pagination") * @Rest\QueryParam(name="count", requirements="\d+", default="10", description="Number of messages per page") * @Rest\QueryParam(name="type", nullable=true, description="Message type filter") * @Rest\QueryParam(name="state", requirements="\d+", strict=true, nullable=true, description="Message status filter") * @Rest\QueryParam(name="orderBy", map=true, requirements="ASC|DESC", nullable=true, strict=true, description="Query groups order by clause (key is field, value is direction)") * * @Rest\View(serializerGroups={"sonata_api_read"}, serializerEnableMaxDepthChecks=true) * * @return PagerInterface */ public function getMessagesAction(ParamFetcherInterface $paramFetcher) { $supportedCriteria = [ 'state' => '', 'type' => '', ]; $page = $paramFetcher->get('page'); $limit = $paramFetcher->get('count'); $sort = $paramFetcher->get('orderBy'); $criteria = array_intersect_key($paramFetcher->all(), $supportedCriteria); $criteria = array_filter($criteria, static function ($value): bool { return null !== $value; }); if (!$sort) { $sort = []; } elseif (!\is_array($sort)) { $sort = [$sort => 'asc']; } return $this->getMessageManager()->getPager($criteria, $page, $limit, $sort); } /** * Adds a message. * * @Operation( * tags={"/api/notification/messages"}, * summary="Adds a message.", * @SWG\Response( * response="200", * description="Returned when successful", * @SWG\Schema(ref=@Model(type="Sonata\NotificationBundle\Model\Message")) * ), * @SWG\Response( * response="400", * description="Returned when an error has occurred while message creation" * ) * ) * * @Rest\View(serializerGroups={"sonata_api_read"}, serializerEnableMaxDepthChecks=true) * * @return FormInterface */ public function postMessageAction(Request $request) { $message = null; $form = $this->formFactory->createNamed('', MessageSerializationType::class, $message, [ 'csrf_protection' => false, ]); $form->handleRequest($request); if ($form->isSubmitted() && $form->isValid()) { $message = $form->getData(); $this->messageManager->save($message); return $message; } return $form; } /** * @return MessageManagerInterface */ protected function getMessageManager() { return $this->messageManager; } }
php
MIT
bb87afcd43c3d64e0b92404ceb0bf038c51d8b2e
2026-01-05T04:47:35.154999Z
false
sonata-project/SonataNotificationBundle
https://github.com/sonata-project/SonataNotificationBundle/blob/bb87afcd43c3d64e0b92404ceb0bf038c51d8b2e/src/Controller/Api/Legacy/MessageController.php
src/Controller/Api/Legacy/MessageController.php
<?php declare(strict_types=1); /* * This file is part of the Sonata Project package. * * (c) Thomas Rabaix <thomas.rabaix@sonata-project.org> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Sonata\NotificationBundle\Controller\Api\Legacy; use FOS\RestBundle\Controller\Annotations as Rest; use FOS\RestBundle\Request\ParamFetcherInterface; use Nelmio\ApiDocBundle\Annotation\ApiDoc; use Sonata\DatagridBundle\Pager\PagerInterface; use Sonata\NotificationBundle\Form\Type\MessageSerializationType; use Sonata\NotificationBundle\Model\MessageManagerInterface; use Symfony\Component\Form\FormFactoryInterface; use Symfony\Component\Form\FormInterface; use Symfony\Component\HttpFoundation\Request; /** * @author Hugo Briand <briand@ekino.com> */ class MessageController { /** * @var MessageManagerInterface */ protected $messageManager; /** * @var FormFactoryInterface */ protected $formFactory; public function __construct(MessageManagerInterface $messageManager, FormFactoryInterface $formFactory) { $this->messageManager = $messageManager; $this->formFactory = $formFactory; } /** * Retrieves the list of messages (paginated). * * @ApiDoc( * resource=true, * output={"class"="Sonata\DatagridBundle\Pager\PagerInterface", "groups"={"sonata_api_read"}} * ) * * @Rest\QueryParam(name="page", requirements="\d+", default="1", description="Page for message list pagination") * @Rest\QueryParam(name="count", requirements="\d+", default="10", description="Number of messages per page") * @Rest\QueryParam(name="type", nullable=true, description="Message type filter") * @Rest\QueryParam(name="state", requirements="\d+", strict=true, nullable=true, description="Message status filter") * @Rest\QueryParam(name="orderBy", map=true, requirements="ASC|DESC", nullable=true, strict=true, description="Query groups order by clause (key is field, value is direction)") * * @Rest\View(serializerGroups={"sonata_api_read"}, serializerEnableMaxDepthChecks=true) * * @return PagerInterface */ public function getMessagesAction(ParamFetcherInterface $paramFetcher) { $supportedCriteria = [ 'state' => '', 'type' => '', ]; $page = $paramFetcher->get('page'); $limit = $paramFetcher->get('count'); $sort = $paramFetcher->get('orderBy'); $criteria = array_intersect_key($paramFetcher->all(), $supportedCriteria); $criteria = array_filter($criteria, static function ($value): bool { return null !== $value; }); if (!$sort) { $sort = []; } elseif (!\is_array($sort)) { $sort = [$sort => 'asc']; } return $this->getMessageManager()->getPager($criteria, $page, $limit, $sort); } /** * Adds a message. * * @ApiDoc( * input={"class"="sonata_notification_api_form_message", "name"="", "groups"={"sonata_api_write"}}, * output={"class"="Sonata\NotificationBundle\Model\Message", "groups"={"sonata_api_read"}}, * statusCodes={ * 200="Returned when successful", * 400="Returned when an error has occurred while message creation" * } * ) * * @Rest\View(serializerGroups={"sonata_api_read"}, serializerEnableMaxDepthChecks=true) * * @param Request $request A Symfony request * * @return FormInterface */ public function postMessageAction(Request $request) { $message = null; $form = $this->formFactory->createNamed('', MessageSerializationType::class, $message, [ 'csrf_protection' => false, ]); $form->handleRequest($request); if ($form->isSubmitted() && $form->isValid()) { $message = $form->getData(); $this->messageManager->save($message); return $message; } return $form; } /** * @return MessageManagerInterface */ protected function getMessageManager() { return $this->messageManager; } }
php
MIT
bb87afcd43c3d64e0b92404ceb0bf038c51d8b2e
2026-01-05T04:47:35.154999Z
false
sonata-project/SonataNotificationBundle
https://github.com/sonata-project/SonataNotificationBundle/blob/bb87afcd43c3d64e0b92404ceb0bf038c51d8b2e/src/Admin/MessageAdmin.php
src/Admin/MessageAdmin.php
<?php declare(strict_types=1); /* * This file is part of the Sonata Project package. * * (c) Thomas Rabaix <thomas.rabaix@sonata-project.org> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Sonata\NotificationBundle\Admin; use Sonata\AdminBundle\Admin\AbstractAdmin; use Sonata\AdminBundle\Datagrid\DatagridMapper; use Sonata\AdminBundle\Datagrid\ListMapper; use Sonata\AdminBundle\Route\RouteCollection; use Sonata\AdminBundle\Show\ShowMapper; use Symfony\Component\Form\Extension\Core\Type\ChoiceType; /** * @phpstan-extends AbstractAdmin<\Sonata\NotificationBundle\Model\Message> * @final since sonata-project/notification-bundle 3.13 */ class MessageAdmin extends AbstractAdmin { protected $classnameLabel = 'Message'; public function configureRoutes(RouteCollection $collection) { $collection ->remove('edit') ->remove('create') ->remove('history'); } public function getBatchActions() { $actions = []; $actions['publish'] = [ 'label' => $this->getLabelTranslatorStrategy()->getLabel('publish', 'batch', 'message'), 'translation_domain' => $this->getTranslationDomain(), 'ask_confirmation' => false, ]; $actions['cancelled'] = [ 'label' => $this->getLabelTranslatorStrategy()->getLabel('cancelled', 'batch', 'message'), 'translation_domain' => $this->getTranslationDomain(), 'ask_confirmation' => false, ]; return $actions; } protected function configureShowFields(ShowMapper $show) { $show ->add('id') ->add('type') ->add('createdAt') ->add('startedAt') ->add('completedAt') ->add('getStateName') ->add('body') ->add('restartCount'); } protected function configureListFields(ListMapper $list) { $list ->addIdentifier('id', null, ['route' => ['name' => 'show']]) ->add('type') ->add('createdAt') ->add('startedAt') ->add('completedAt') ->add('getStateName') ->add('restartCount'); } protected function configureDatagridFilters(DatagridMapper $filter) { $class = $this->getClass(); $filter ->add('type') ->add('state', null, [ 'field_type' => ChoiceType::class, 'field_options' => ['choices' => $class::getStateList()], ]); } }
php
MIT
bb87afcd43c3d64e0b92404ceb0bf038c51d8b2e
2026-01-05T04:47:35.154999Z
false
sonata-project/SonataNotificationBundle
https://github.com/sonata-project/SonataNotificationBundle/blob/bb87afcd43c3d64e0b92404ceb0bf038c51d8b2e/src/Form/Type/MessageSerializationType.php
src/Form/Type/MessageSerializationType.php
<?php declare(strict_types=1); /* * This file is part of the Sonata Project package. * * (c) Thomas Rabaix <thomas.rabaix@sonata-project.org> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Sonata\NotificationBundle\Form\Type; use Sonata\Form\Type\BaseDoctrineORMSerializationType; /** * @final since sonata-project/notification-bundle 3.13 */ class MessageSerializationType extends BaseDoctrineORMSerializationType { }
php
MIT
bb87afcd43c3d64e0b92404ceb0bf038c51d8b2e
2026-01-05T04:47:35.154999Z
false
sonata-project/SonataNotificationBundle
https://github.com/sonata-project/SonataNotificationBundle/blob/bb87afcd43c3d64e0b92404ceb0bf038c51d8b2e/src/Backend/AMQPBackendDispatcher.php
src/Backend/AMQPBackendDispatcher.php
<?php declare(strict_types=1); /* * This file is part of the Sonata Project package. * * (c) Thomas Rabaix <thomas.rabaix@sonata-project.org> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Sonata\NotificationBundle\Backend; use Enqueue\AmqpTools\DelayStrategyAware; use Enqueue\AmqpTools\RabbitMqDlxDelayStrategy; use Guzzle\Http\Client as GuzzleClient; use Interop\Amqp\AmqpConnectionFactory; use Interop\Amqp\AmqpContext; use Laminas\Diagnostics\Result\Failure; use Laminas\Diagnostics\Result\Success; use PhpAmqpLib\Channel\AMQPChannel; use PhpAmqpLib\Connection\AMQPConnection; use Sonata\NotificationBundle\Exception\BackendNotFoundException; use Sonata\NotificationBundle\Model\MessageInterface; use Symfony\Component\EventDispatcher\EventDispatcherInterface; /** * Producer side of the rabbitmq backend. * * @final since sonata-project/notification-bundle 3.13 */ class AMQPBackendDispatcher extends QueueBackendDispatcher { /** * @var array */ protected $settings; /** * @deprecated since 3.2, will be removed in 4.x * * @var AMQPChannel */ protected $channel; /** * @deprecated since 3.2, will be removed in 4.x * * @var AMQPConnection */ protected $connection; protected $backendsInitialized = false; /** * @var AmqpConnectionFactory */ private $connectionFactory; /** * @var AmqpContext */ private $context; /** * @param string $defaultQueue */ public function __construct(array $settings, array $queues, $defaultQueue, array $backends) { parent::__construct($queues, $defaultQueue, $backends); $this->settings = $settings; } /** * @deprecated since 3.2, will be removed in 4.x * * @return AMQPChannel */ public function getChannel() { @trigger_error(sprintf('The method %s is deprecated since version 3.3 and will be removed in 4.0. Use %s::getContext() instead.', __METHOD__, __CLASS__), \E_USER_DEPRECATED); if (!$this->channel) { if (!$this->context instanceof \Enqueue\AmqpLib\AmqpContext) { throw new \LogicException('The BC layer works only if enqueue/amqp-lib lib is being used.'); } // load context $this->getContext(); /** @var \Enqueue\AmqpLib\AmqpContext $context */ $context = $this->getContext(); $this->channel = $context->getLibChannel(); $this->connection = $this->channel->getConnection(); } return $this->channel; } /** * @return AmqpContext */ final public function getContext() { if (!$this->context) { if (!\array_key_exists('factory_class', $this->settings)) { throw new \LogicException('The factory_class option is missing though it is required.'); } $factoryClass = $this->settings['factory_class']; if ( !class_exists($factoryClass) || !(new \ReflectionClass($factoryClass))->implementsInterface(AmqpConnectionFactory::class) ) { throw new \LogicException(sprintf( 'The factory_class option "%s" has to be valid class that implements "%s"', $factoryClass, AmqpConnectionFactory::class )); } /* @var AmqpConnectionFactory $factory */ $this->connectionFactory = $factory = new $factoryClass([ 'host' => $this->settings['host'], 'port' => $this->settings['port'], 'user' => $this->settings['user'], 'pass' => $this->settings['pass'], 'vhost' => $this->settings['vhost'], ]); if ($factory instanceof DelayStrategyAware) { $factory->setDelayStrategy(new RabbitMqDlxDelayStrategy()); } $this->context = $factory->createContext(); register_shutdown_function([$this, 'shutdown']); } return $this->context; } public function getBackend($type) { if (!$this->backendsInitialized) { foreach ($this->backends as $backend) { $backend['backend']->initialize(); } $this->backendsInitialized = true; } $default = null; if (0 === \count($this->queues)) { foreach ($this->backends as $backend) { if ('default' === $backend['type']) { return $backend['backend']; } } } foreach ($this->backends as $backend) { if ('all' === $type && '' === $backend['type']) { return $backend['backend']; } if ($backend['type'] === $type) { return $backend['backend']; } if ($backend['type'] === $this->defaultQueue) { $default = $backend['backend']; } } if (null === $default) { throw new BackendNotFoundException('Could not find a message backend for the type '.$type); } return $default; } public function getIterator() { throw new \RuntimeException( 'You need to use a specific rabbitmq backend supporting the selected queue to run a consumer.' ); } public function handle(MessageInterface $message, EventDispatcherInterface $dispatcher) { throw new \RuntimeException( 'You need to use a specific rabbitmq backend supporting the selected queue to run a consumer.' ); } public function getStatus() { try { $this->getContext(); $output = $this->getApiQueueStatus(); $checked = 0; $missingConsumers = []; foreach ($this->queues as $queue) { foreach ($output as $q) { if ($q['name'] === $queue['queue']) { ++$checked; if (0 === $q['consumers']) { $missingConsumers[] = $queue['queue']; } } } } if ($checked !== \count($this->queues)) { return new Failure( 'Not all queues for the available notification types registered in the rabbitmq broker. ' .'Are the consumer commands running?' ); } if (\count($missingConsumers) > 0) { return new Failure( 'There are no rabbitmq consumers running for the queues: '.implode(', ', $missingConsumers) ); } } catch (\Exception $e) { return new Failure($e->getMessage()); } return new Success('Channel is running (RabbitMQ) and consumers for all queues available.'); } public function cleanup() { throw new \RuntimeException( 'You need to use a specific rabbitmq backend supporting the selected queue to run a consumer.' ); } public function shutdown() { if ($this->context) { $this->context->close(); } } public function initialize() { } /** * Calls the rabbitmq management api /api/<vhost>/queues endpoint to list the available queues. * * @see http://hg.rabbitmq.com/rabbitmq-management/raw-file/3646dee55e02/priv/www-api/help.html * * @return array */ protected function getApiQueueStatus() { if (!class_exists(GuzzleClient::class)) { throw new \RuntimeException( 'The guzzle http client library is required to run rabbitmq health checks. ' .'Make sure to add guzzlehttp/guzzle to your composer.json.' ); } $client = new GuzzleClient(); $client->setConfig(['curl.options' => [\CURLOPT_CONNECTTIMEOUT_MS => 3000]]); $request = $client->get(sprintf('%s/queues', $this->settings['console_url'])); $request->setAuth($this->settings['user'], $this->settings['pass']); return json_decode($request->send()->getBody(true), true); } }
php
MIT
bb87afcd43c3d64e0b92404ceb0bf038c51d8b2e
2026-01-05T04:47:35.154999Z
false
sonata-project/SonataNotificationBundle
https://github.com/sonata-project/SonataNotificationBundle/blob/bb87afcd43c3d64e0b92404ceb0bf038c51d8b2e/src/Backend/MessageManagerBackend.php
src/Backend/MessageManagerBackend.php
<?php declare(strict_types=1); /* * This file is part of the Sonata Project package. * * (c) Thomas Rabaix <thomas.rabaix@sonata-project.org> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Sonata\NotificationBundle\Backend; use Laminas\Diagnostics\Result\Failure; use Laminas\Diagnostics\Result\Success; use Laminas\Diagnostics\Result\Warning; use Sonata\NotificationBundle\Consumer\ConsumerEvent; use Sonata\NotificationBundle\Exception\HandlingException; use Sonata\NotificationBundle\Iterator\MessageManagerMessageIterator; use Sonata\NotificationBundle\Model\MessageInterface; use Sonata\NotificationBundle\Model\MessageManagerInterface; use Symfony\Component\EventDispatcher\EventDispatcherInterface; /** * @final since sonata-project/notification-bundle 3.13 */ class MessageManagerBackend implements BackendInterface { /** * @var MessageManagerInterface */ protected $messageManager; /** * @var array */ protected $checkLevel; /** * @var int */ protected $pause; /** * @var int */ protected $maxAge; /** * @var MessageManagerBackendDispatcher|null */ protected $dispatcher = null; /** * @var array */ protected $types; /** * @var int */ protected $batchSize; /** * @param int $pause * @param int $maxAge * @param int $batchSize */ public function __construct(MessageManagerInterface $messageManager, array $checkLevel, $pause = 500000, $maxAge = 86400, $batchSize = 10, array $types = []) { $this->messageManager = $messageManager; $this->checkLevel = $checkLevel; $this->pause = $pause; $this->maxAge = $maxAge; $this->batchSize = $batchSize; $this->types = $types; } /** * @param array $types */ public function setTypes($types) { $this->types = $types; } public function publish(MessageInterface $message) { $this->messageManager->save($message); return $message; } public function create($type, array $body) { $message = $this->messageManager->create(); $message->setType($type); $message->setBody($body); $message->setState(MessageInterface::STATE_OPEN); return $message; } public function createAndPublish($type, array $body) { return $this->publish($this->create($type, $body)); } public function getIterator() { return new MessageManagerMessageIterator($this->messageManager, $this->types, $this->pause, $this->batchSize); } public function initialize() { } public function setDispatcher(MessageManagerBackendDispatcher $dispatcher) { $this->dispatcher = $dispatcher; } public function handle(MessageInterface $message, EventDispatcherInterface $dispatcher) { $event = new ConsumerEvent($message); try { $message->setStartedAt(new \DateTime()); $message->setState(MessageInterface::STATE_IN_PROGRESS); $this->messageManager->save($message); $dispatcher->dispatch($event, $message->getType()); $message->setCompletedAt(new \DateTime()); $message->setState(MessageInterface::STATE_DONE); $this->messageManager->save($message); return $event->getReturnInfo(); } catch (\Exception $e) { $message->setCompletedAt(new \DateTime()); $message->setState(MessageInterface::STATE_ERROR); $this->messageManager->save($message); throw new HandlingException('Error while handling a message', 0, $e); } } public function getStatus() { try { $states = $this->messageManager->countStates(); } catch (\Exception $e) { return new Failure(sprintf('Unable to retrieve message information - %s (Database)', $e->getMessage())); } if ($states[MessageInterface::STATE_IN_PROGRESS] > $this->checkLevel[MessageInterface::STATE_IN_PROGRESS]) { return new Failure('Too many messages processed at the same time (Database)'); } if ($states[MessageInterface::STATE_ERROR] > $this->checkLevel[MessageInterface::STATE_ERROR]) { return new Failure('Too many errors (Database)'); } if ($states[MessageInterface::STATE_OPEN] > $this->checkLevel[MessageInterface::STATE_OPEN]) { return new Warning('Too many messages waiting to be processed (Database)'); } if ($states[MessageInterface::STATE_DONE] > $this->checkLevel[MessageInterface::STATE_DONE]) { return new Warning('Too many processed messages, please clean the database (Database)'); } return new Success('Ok (Database)'); } public function cleanup() { $this->messageManager->cleanup($this->maxAge); } }
php
MIT
bb87afcd43c3d64e0b92404ceb0bf038c51d8b2e
2026-01-05T04:47:35.154999Z
false
sonata-project/SonataNotificationBundle
https://github.com/sonata-project/SonataNotificationBundle/blob/bb87afcd43c3d64e0b92404ceb0bf038c51d8b2e/src/Backend/BackendInterface.php
src/Backend/BackendInterface.php
<?php declare(strict_types=1); /* * This file is part of the Sonata Project package. * * (c) Thomas Rabaix <thomas.rabaix@sonata-project.org> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Sonata\NotificationBundle\Backend; use Laminas\Diagnostics\Result\ResultInterface; use Sonata\NotificationBundle\Iterator\MessageIteratorInterface; use Sonata\NotificationBundle\Model\MessageInterface; use Symfony\Component\EventDispatcher\EventDispatcherInterface; interface BackendInterface { public function publish(MessageInterface $message); /** * @param string $type * * @return MessageInterface */ public function create($type, array $body); /** * @param string $type */ public function createAndPublish($type, array $body); /** * @return MessageIteratorInterface */ public function getIterator(); /** * Initialize. * * @return void */ public function initialize(); /** * @return mixed */ public function handle(MessageInterface $message, EventDispatcherInterface $dispatcher); /** * @return ResultInterface */ public function getStatus(); /** * Clean up messages. * * @return void */ public function cleanup(); }
php
MIT
bb87afcd43c3d64e0b92404ceb0bf038c51d8b2e
2026-01-05T04:47:35.154999Z
false
sonata-project/SonataNotificationBundle
https://github.com/sonata-project/SonataNotificationBundle/blob/bb87afcd43c3d64e0b92404ceb0bf038c51d8b2e/src/Backend/QueueDispatcherInterface.php
src/Backend/QueueDispatcherInterface.php
<?php declare(strict_types=1); /* * This file is part of the Sonata Project package. * * (c) Thomas Rabaix <thomas.rabaix@sonata-project.org> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Sonata\NotificationBundle\Backend; use Sonata\NotificationBundle\Exception\BackendNotFoundException; /** * A QueueDispatcherInterface acts as a router for different * queue types. * * @see AMQPBackendDispatcher for an example implementation */ interface QueueDispatcherInterface { /** * Get a backend by message type. * * NEXT_MAJOR: Change signature to getBackend(?string $type = null); * * @param string|null $type * * @throws BackendNotFoundException * * @return BackendInterface */ public function getBackend($type); /** * Get all registered queues. * * @return array */ public function getQueues(); }
php
MIT
bb87afcd43c3d64e0b92404ceb0bf038c51d8b2e
2026-01-05T04:47:35.154999Z
false
sonata-project/SonataNotificationBundle
https://github.com/sonata-project/SonataNotificationBundle/blob/bb87afcd43c3d64e0b92404ceb0bf038c51d8b2e/src/Backend/AMQPBackend.php
src/Backend/AMQPBackend.php
<?php declare(strict_types=1); /* * This file is part of the Sonata Project package. * * (c) Thomas Rabaix <thomas.rabaix@sonata-project.org> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Sonata\NotificationBundle\Backend; use Interop\Amqp\AmqpConsumer; use Interop\Amqp\AmqpContext; use Interop\Amqp\AmqpMessage; use Interop\Amqp\AmqpQueue; use Interop\Amqp\AmqpTopic; use Interop\Amqp\Impl\AmqpBind; use Laminas\Diagnostics\Result\Failure; use Laminas\Diagnostics\Result\Success; use PhpAmqpLib\Channel\AMQPChannel; use Sonata\NotificationBundle\Consumer\ConsumerEvent; use Sonata\NotificationBundle\Exception\HandlingException; use Sonata\NotificationBundle\Iterator\AMQPMessageIterator; use Sonata\NotificationBundle\Model\Message; use Sonata\NotificationBundle\Model\MessageInterface; use Symfony\Component\EventDispatcher\EventDispatcherInterface; /** * Consumer side of the rabbitMQ backend. * * @final since sonata-project/notification-bundle 3.13 */ class AMQPBackend implements BackendInterface { /** * @var AMQPBackendDispatcher */ protected $dispatcher = null; /** * @var string */ protected $exchange; /** * @var string */ protected $queue; /** * @var string */ protected $key; /** * @var string */ protected $recover; /** * @var string|null */ protected $deadLetterExchange; /** * @var string|null */ protected $deadLetterRoutingKey; /** * @var int|null */ protected $ttl; /** * @var int|null */ private $prefetchCount; /** * @var AmqpConsumer */ private $consumer; /** * @param string $exchange * @param string $queue * @param string $recover * @param string $key * @param string $deadLetterExchange * @param string $deadLetterRoutingKey * @param int|null $ttl */ public function __construct($exchange, $queue, $recover, $key, $deadLetterExchange = null, $deadLetterRoutingKey = null, $ttl = null, $prefetchCount = null) { $this->exchange = $exchange; $this->queue = $queue; $this->recover = $recover; $this->key = $key; $this->deadLetterExchange = $deadLetterExchange; $this->deadLetterRoutingKey = $deadLetterRoutingKey; $this->ttl = $ttl; $this->prefetchCount = $prefetchCount; } public function setDispatcher(AMQPBackendDispatcher $dispatcher) { $this->dispatcher = $dispatcher; } public function initialize() { $args = []; if (null !== $this->deadLetterExchange) { $args['x-dead-letter-exchange'] = $this->deadLetterExchange; if (null !== $this->deadLetterRoutingKey) { $args['x-dead-letter-routing-key'] = $this->deadLetterRoutingKey; } } if (null !== $this->ttl) { $args['x-message-ttl'] = $this->ttl; } $queue = $this->getContext()->createQueue($this->queue); $queue->addFlag(AmqpQueue::FLAG_DURABLE); $queue->setArguments($args); $this->getContext()->declareQueue($queue); $topic = $this->getContext()->createTopic($this->exchange); $topic->setType(AmqpTopic::TYPE_DIRECT); $topic->addFlag(AmqpTopic::FLAG_DURABLE); $this->getContext()->declareTopic($topic); $this->getContext()->bind(new AmqpBind($queue, $topic, $this->key)); if (null !== $this->deadLetterExchange && null === $this->deadLetterRoutingKey) { $deadLetterTopic = $this->getContext()->createTopic($this->deadLetterExchange); $deadLetterTopic->setType(AmqpTopic::TYPE_DIRECT); $deadLetterTopic->addFlag(AmqpTopic::FLAG_DURABLE); $this->getContext()->declareTopic($deadLetterTopic); $this->getContext()->bind(new AmqpBind($queue, $deadLetterTopic, $this->key)); } } public function publish(MessageInterface $message) { $body = json_encode([ 'type' => $message->getType(), 'body' => $message->getBody(), 'createdAt' => $message->getCreatedAt()->format('U'), 'state' => $message->getState(), ]); $amqpMessage = $this->getContext()->createMessage($body); $amqpMessage->setContentType('text/plain'); // application/json ? $amqpMessage->setTimestamp($message->getCreatedAt()->getTimestamp()); $amqpMessage->setDeliveryMode(AmqpMessage::DELIVERY_MODE_PERSISTENT); $amqpMessage->setRoutingKey($this->key); $topic = $this->getContext()->createTopic($this->exchange); $this->getContext()->createProducer()->send($topic, $amqpMessage); } public function create($type, array $body) { $message = new Message(); $message->setType($type); $message->setBody($body); $message->setState(MessageInterface::STATE_OPEN); return $message; } public function createAndPublish($type, array $body) { $this->publish($this->create($type, $body)); } public function getIterator() { $context = $this->getContext(); if (null !== $this->prefetchCount) { $context->setQos(null, $this->prefetchCount, false); } $this->consumer = $this->getContext()->createConsumer($this->getContext()->createQueue($this->queue)); $this->consumer->setConsumerTag('sonata_notification_'.uniqid()); if (!$context instanceof \Enqueue\AmqpLib\AmqpContext) { throw new \LogicException('The BC layer works only if enqueue/amqp-lib lib is being used.'); } return new AMQPMessageIterator($context->getLibChannel(), $this->consumer); } public function handle(MessageInterface $message, EventDispatcherInterface $dispatcher) { $event = new ConsumerEvent($message); /** @var AmqpMessage $amqpMessage */ $amqpMessage = $message->getValue('interopMessage'); try { $dispatcher->dispatch($event, $message->getType()); $this->consumer->acknowledge($amqpMessage); $message->setCompletedAt(new \DateTime()); $message->setState(MessageInterface::STATE_DONE); } catch (HandlingException $e) { $message->setCompletedAt(new \DateTime()); $message->setState(MessageInterface::STATE_ERROR); $this->consumer->acknowledge($amqpMessage); throw new HandlingException('Error while handling a message', 0, $e); } catch (\Exception $e) { $message->setCompletedAt(new \DateTime()); $message->setState(MessageInterface::STATE_ERROR); $this->consumer->reject($amqpMessage, $this->recover); throw new HandlingException('Error while handling a message', 0, $e); } } public function getStatus() { try { $this->getContext(); } catch (\Exception $e) { return new Failure($e->getMessage()); } return new Success('Channel is running (RabbitMQ)'); } public function cleanup() { throw new \RuntimeException('Not implemented'); } /** * @deprecated since 3.2, will be removed in 4.x * * @return AMQPChannel */ protected function getChannel() { if (null === $this->dispatcher) { throw new \RuntimeException('Unable to retrieve AMQP channel without dispatcher.'); } return $this->dispatcher->getChannel(); } /** * @return AmqpContext */ private function getContext() { if (null === $this->dispatcher) { throw new \RuntimeException('Unable to retrieve AMQP context without dispatcher.'); } return $this->dispatcher->getContext(); } }
php
MIT
bb87afcd43c3d64e0b92404ceb0bf038c51d8b2e
2026-01-05T04:47:35.154999Z
false
sonata-project/SonataNotificationBundle
https://github.com/sonata-project/SonataNotificationBundle/blob/bb87afcd43c3d64e0b92404ceb0bf038c51d8b2e/src/Backend/QueueBackendDispatcher.php
src/Backend/QueueBackendDispatcher.php
<?php declare(strict_types=1); /* * This file is part of the Sonata Project package. * * (c) Thomas Rabaix <thomas.rabaix@sonata-project.org> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Sonata\NotificationBundle\Backend; use Sonata\NotificationBundle\Model\MessageInterface; /** * Base class for queue backent dispatchers. * * @author Kevin Nedelec <kevin.nedelec@ekino.com> */ abstract class QueueBackendDispatcher implements QueueDispatcherInterface, BackendInterface { /** * @var array */ protected $queues; /** * @var string */ protected $defaultQueue; /** * @var BackendInterface[] */ protected $backends; /** * @param string $defaultQueue * @param BackendInterface[] $backends */ public function __construct(array $queues, $defaultQueue, array $backends) { $this->queues = $queues; $this->backends = $backends; $this->defaultQueue = $defaultQueue; foreach ($this->backends as $backend) { $backend['backend']->setDispatcher($this); } } public function publish(MessageInterface $message) { $this->getBackend($message->getType())->publish($message); } public function create($type, array $body) { return $this->getBackend($type)->create($type, $body); } public function createAndPublish($type, array $body) { $this->getBackend($type)->createAndPublish($type, $body); } public function getQueues() { return $this->queues; } }
php
MIT
bb87afcd43c3d64e0b92404ceb0bf038c51d8b2e
2026-01-05T04:47:35.154999Z
false
sonata-project/SonataNotificationBundle
https://github.com/sonata-project/SonataNotificationBundle/blob/bb87afcd43c3d64e0b92404ceb0bf038c51d8b2e/src/Backend/PostponeRuntimeBackend.php
src/Backend/PostponeRuntimeBackend.php
<?php declare(strict_types=1); /* * This file is part of the Sonata Project package. * * (c) Thomas Rabaix <thomas.rabaix@sonata-project.org> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Sonata\NotificationBundle\Backend; use Laminas\Diagnostics\Result\Success; use Sonata\NotificationBundle\Iterator\IteratorProxyMessageIterator; use Sonata\NotificationBundle\Model\MessageInterface; use Symfony\Component\EventDispatcher\EventDispatcherInterface; /** * This backend postpones the handling of messages to a registered event. * * It's based on the asynchronous event dispatcher: * * @see https://gist.github.com/3852361 * * @author Toni Uebernickel <tuebernickel@gmail.com> * * @final since sonata-project/notification-bundle 3.13 */ class PostponeRuntimeBackend extends RuntimeBackend { /** * @var MessageInterface[] */ protected $messages = []; /** * If set to true, you have to fire an event the onEvent method is subscribed to manually! * * @var bool */ protected $postponeOnCli = false; /** * @param bool $postponeOnCli Whether to postpone the messages on the CLI, too */ public function __construct(EventDispatcherInterface $dispatcher, $postponeOnCli = false) { parent::__construct($dispatcher); $this->postponeOnCli = $postponeOnCli; } public function publish(MessageInterface $message) { // if the message is generated from the cli the message is handled // directly as there is no kernel.terminate in cli if (!$this->postponeOnCli && $this->isCommandLineInterface()) { $this->handle($message, $this->dispatcher); return; } $this->messages[] = $message; } /** * Listen on any event and handle the messages. * * Actually, an event is not necessary, you can call this method manually, to. * The event is not processed in any way. */ public function onEvent() { while (!empty($this->messages)) { $message = array_shift($this->messages); $this->handle($message, $this->dispatcher); } } public function getIterator() { return new IteratorProxyMessageIterator(new \ArrayIterator($this->messages)); } public function getStatus() { return new Success('Postpone runtime backend', 'Ok (Postpone Runtime)'); } /** * Check whether this Backend is run on the CLI. * * @return bool */ protected function isCommandLineInterface() { return 'cli' === \PHP_SAPI; } }
php
MIT
bb87afcd43c3d64e0b92404ceb0bf038c51d8b2e
2026-01-05T04:47:35.154999Z
false
sonata-project/SonataNotificationBundle
https://github.com/sonata-project/SonataNotificationBundle/blob/bb87afcd43c3d64e0b92404ceb0bf038c51d8b2e/src/Backend/MessageManagerBackendDispatcher.php
src/Backend/MessageManagerBackendDispatcher.php
<?php declare(strict_types=1); /* * This file is part of the Sonata Project package. * * (c) Thomas Rabaix <thomas.rabaix@sonata-project.org> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Sonata\NotificationBundle\Backend; use Laminas\Diagnostics\Result\Success; use Sonata\NotificationBundle\Model\MessageInterface; use Sonata\NotificationBundle\Model\MessageManagerInterface; use Symfony\Component\EventDispatcher\EventDispatcherInterface; /** * Producer side of the doctrine backend. * * @final since sonata-project/notification-bundle 3.13 */ class MessageManagerBackendDispatcher extends QueueBackendDispatcher { /** * @var array */ protected $dedicatedTypes = []; /** * @var BackendInterface */ protected $default; /** * NEXT_MAJOR: Remove $messageManager parameter. * * @param MessageManagerInterface $messageManager Only used in compiler pass * @param string $defaultQueue */ public function __construct(MessageManagerInterface $messageManager, array $queues, $defaultQueue, array $backends) { parent::__construct($queues, $defaultQueue, $backends); foreach ($this->queues as $queue) { if (true === $queue['default']) { continue; } $this->dedicatedTypes = array_merge($this->dedicatedTypes, $queue['types']); } foreach ($this->backends as $backend) { if (empty($backend['types'])) { $this->default = $backend['backend']; } } } public function getBackend($type) { $default = null; if (!$type) { return $this->getDefaultBackend(); } foreach ($this->backends as $backend) { if (\in_array($type, $backend['types'], true)) { return $backend['backend']; } } return $this->getDefaultBackend(); } public function getIterator() { throw new \RuntimeException('You need to use a specific doctrine backend supporting the selected queue to run a consumer.'); } public function handle(MessageInterface $message, EventDispatcherInterface $dispatcher) { throw new \RuntimeException('You need to use a specific doctrine backend supporting the selected queue to run a consumer.'); } public function getStatus() { return new Success('Channel is running (Database) and consumers for all queues available.'); } public function cleanup() { throw new \RuntimeException('You need to use a specific doctrine backend supporting the selected queue to run a consumer.'); } public function initialize() { } /** * @return BackendInterface */ protected function getDefaultBackend() { $types = []; if (!empty($this->dedicatedTypes)) { $types = [ 'exclude' => $this->dedicatedTypes, ]; } $this->default->setTypes($types); return $this->default; } }
php
MIT
bb87afcd43c3d64e0b92404ceb0bf038c51d8b2e
2026-01-05T04:47:35.154999Z
false
sonata-project/SonataNotificationBundle
https://github.com/sonata-project/SonataNotificationBundle/blob/bb87afcd43c3d64e0b92404ceb0bf038c51d8b2e/src/Backend/BackendHealthCheck.php
src/Backend/BackendHealthCheck.php
<?php declare(strict_types=1); /* * This file is part of the Sonata Project package. * * (c) Thomas Rabaix <thomas.rabaix@sonata-project.org> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Sonata\NotificationBundle\Backend; use Laminas\Diagnostics\Check\AbstractCheck; /** * @final since sonata-project/notification-bundle 3.13 */ class BackendHealthCheck extends AbstractCheck { /** * @var BackendInterface */ protected $backend; public function __construct(BackendInterface $backend) { $this->backend = $backend; } public function check() { return $this->backend->getStatus(); } public function getName() { return 'Sonata Notification Default Backend'; } public function getGroup() { return 'sonata'; } }
php
MIT
bb87afcd43c3d64e0b92404ceb0bf038c51d8b2e
2026-01-05T04:47:35.154999Z
false
sonata-project/SonataNotificationBundle
https://github.com/sonata-project/SonataNotificationBundle/blob/bb87afcd43c3d64e0b92404ceb0bf038c51d8b2e/src/Backend/RuntimeBackend.php
src/Backend/RuntimeBackend.php
<?php declare(strict_types=1); /* * This file is part of the Sonata Project package. * * (c) Thomas Rabaix <thomas.rabaix@sonata-project.org> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Sonata\NotificationBundle\Backend; use Laminas\Diagnostics\Result\Success; use Sonata\NotificationBundle\Consumer\ConsumerEvent; use Sonata\NotificationBundle\Exception\HandlingException; use Sonata\NotificationBundle\Model\Message; use Sonata\NotificationBundle\Model\MessageInterface; use Symfony\Component\EventDispatcher\EventDispatcherInterface; class RuntimeBackend implements BackendInterface { /** * @var EventDispatcherInterface */ protected $dispatcher; public function __construct(EventDispatcherInterface $dispatcher) { $this->dispatcher = $dispatcher; } public function publish(MessageInterface $message) { $this->handle($message, $this->dispatcher); return $message; } public function create($type, array $body) { $message = new Message(); $message->setType($type); $message->setBody($body); $message->setState(MessageInterface::STATE_OPEN); return $message; } public function createAndPublish($type, array $body) { return $this->publish($this->create($type, $body)); } public function getIterator() { return new \EmptyIterator(); } public function initialize() { } public function cleanup() { } public function handle(MessageInterface $message, EventDispatcherInterface $dispatcher) { $event = new ConsumerEvent($message); try { $dispatcher->dispatch($event, $message->getType()); $message->setCompletedAt(new \DateTime()); $message->setState(MessageInterface::STATE_DONE); } catch (\Exception $e) { $message->setCompletedAt(new \DateTime()); $message->setState(MessageInterface::STATE_ERROR); throw new HandlingException('Error while handling a message: '.$e->getMessage(), 0, $e); } } public function getStatus() { return new Success('Runtime backend health check', 'Ok (Runtime)'); } }
php
MIT
bb87afcd43c3d64e0b92404ceb0bf038c51d8b2e
2026-01-05T04:47:35.154999Z
false
sonata-project/SonataNotificationBundle
https://github.com/sonata-project/SonataNotificationBundle/blob/bb87afcd43c3d64e0b92404ceb0bf038c51d8b2e/src/DependencyInjection/SonataNotificationExtension.php
src/DependencyInjection/SonataNotificationExtension.php
<?php declare(strict_types=1); /* * This file is part of the Sonata Project package. * * (c) Thomas Rabaix <thomas.rabaix@sonata-project.org> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Sonata\NotificationBundle\DependencyInjection; use Nelmio\ApiDocBundle\Annotation\Operation; use Sonata\Doctrine\Mapper\DoctrineCollector; use Sonata\EasyExtendsBundle\Mapper\DoctrineCollector as DeprecatedDoctrineCollector; use Sonata\NotificationBundle\Backend\AMQPBackend; use Sonata\NotificationBundle\Backend\MessageManagerBackend; use Sonata\NotificationBundle\Model\MessageInterface; use Symfony\Component\Config\FileLocator; use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\DependencyInjection\Definition; use Symfony\Component\DependencyInjection\Loader; use Symfony\Component\DependencyInjection\Reference; use Symfony\Component\HttpKernel\DependencyInjection\Extension; /** * @final since sonata-project/notification-bundle 3.13 */ class SonataNotificationExtension extends Extension { /** * @var int */ protected $amqpCounter = 0; public function load(array $configs, ContainerBuilder $container) { $configuration = new Configuration(); $config = $this->processConfiguration($configuration, $configs); $loader = new Loader\XmlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config')); $this->checkConfiguration($config); $loader->load('core.xml'); $loader->load('backend.xml'); $loader->load('consumer.xml'); $loader->load('command.xml'); $bundles = $container->getParameter('kernel.bundles'); if ('sonata.notification.backend.doctrine' === $config['backend']) { $loader->load('doctrine_orm.xml'); $loader->load('selector.xml'); $loader->load('event.xml'); if (isset($bundles['FOSRestBundle'], $bundles['NelmioApiDocBundle'])) { // NEXT_MAJOR: remove legacy api if (class_exists(Operation::class)) { $loader->load('api_controllers.xml'); } else { $loader->load('api_controllers_legacy.xml'); } $loader->load('api_form.xml'); } // for now, only support for ORM if ($config['admin']['enabled'] && isset($bundles['SonataDoctrineORMAdminBundle'])) { $loader->load('admin.xml'); } } if ($config['consumers']['register_default']) { $loader->load('default_consumers.xml'); } if (isset($bundles['LiipMonitorBundle'])) { $loader->load('checkmonitor.xml'); } $container->setAlias('sonata.notification.backend', $config['backend'])->setPublic(true); $container->setParameter('sonata.notification.backend', $config['backend']); if (isset($bundles['SonataDoctrineBundle'])) { $this->registerSonataDoctrineMapping($config); } else { // NEXT MAJOR: Remove next line and throw error when not registering SonataDoctrineBundle $this->registerDoctrineMapping($config); } $this->registerParameters($container, $config); $this->configureBackends($container, $config); $this->configureClass($container, $config); $this->configureListeners($container, $config); $this->configureAdmin($container, $config); } /** * @param array $config */ public function configureClass(ContainerBuilder $container, $config) { // admin configuration $container->setParameter('sonata.notification.admin.message.entity', $config['class']['message']); // manager configuration $container->setParameter('sonata.notification.manager.message.entity', $config['class']['message']); } /** * @param array $config */ public function configureAdmin(ContainerBuilder $container, $config) { $container->setParameter('sonata.notification.admin.message.class', $config['admin']['message']['class']); $container->setParameter('sonata.notification.admin.message.controller', $config['admin']['message']['controller']); $container->setParameter('sonata.notification.admin.message.translation_domain', $config['admin']['message']['translation']); } /** * @param array $config */ public function registerParameters(ContainerBuilder $container, $config) { $container->setParameter('sonata.notification.message.class', $config['class']['message']); $container->setParameter('sonata.notification.admin.message.entity', $config['class']['message']); } /** * @param array $config */ public function configureBackends(ContainerBuilder $container, $config) { if (isset($config['backends']['rabbitmq']) && 'sonata.notification.backend.rabbitmq' === $config['backend']) { $this->configureRabbitmq($container, $config); } else { $container->removeDefinition('sonata.notification.backend.rabbitmq'); } if (isset($config['backends']['doctrine']) && 'sonata.notification.backend.doctrine' === $config['backend']) { $checkLevel = [ MessageInterface::STATE_DONE => $config['backends']['doctrine']['states']['done'], MessageInterface::STATE_ERROR => $config['backends']['doctrine']['states']['error'], MessageInterface::STATE_IN_PROGRESS => $config['backends']['doctrine']['states']['in_progress'], MessageInterface::STATE_OPEN => $config['backends']['doctrine']['states']['open'], ]; $pause = $config['backends']['doctrine']['pause']; $maxAge = $config['backends']['doctrine']['max_age']; $batchSize = $config['backends']['doctrine']['batch_size']; $container ->setAlias('sonata.notification.manager.message', $config['backends']['doctrine']['message_manager']) ->setPublic(true); $this->configureDoctrineBackends($container, $config, $checkLevel, $pause, $maxAge, $batchSize); } else { $container->removeDefinition('sonata.notification.backend.doctrine'); } } /** * NEXT_MAJOR: Remove this method. */ public function registerDoctrineMapping(array $config) { @trigger_error( 'Using SonataEasyExtendsBundle is deprecated since sonata-project/notification-bundle 3.9. Please register SonataDoctrineBundle as a bundle instead.', \E_USER_DEPRECATED ); $collector = DeprecatedDoctrineCollector::getInstance(); $collector->addIndex($config['class']['message'], 'idx_state', [ 'state', ]); $collector->addIndex($config['class']['message'], 'idx_created_at', [ 'created_at', ]); } protected function checkConfiguration(array $config) { if (isset($config['backends']) && \count($config['backends']) > 1) { throw new \RuntimeException('more than one backend configured, you can have only one backend configuration'); } if (!isset($config['backends']['rabbitmq']) && 'sonata.notification.backend.rabbitmq' === $config['backend']) { throw new \RuntimeException('Please configure the sonata_notification.backends.rabbitmq section'); } if (!isset($config['backends']['doctrine']) && 'sonata.notification.backend.doctrine' === $config['backend']) { throw new \RuntimeException('Please configure the sonata_notification.backends.doctrine section'); } } protected function configureListeners(ContainerBuilder $container, array $config) { $ids = $config['iteration_listeners']; if ('sonata.notification.backend.doctrine' === $config['backend']) { // this one clean the unit of work after every iteration $ids[] = 'sonata.notification.event.doctrine_optimize'; if ($config['backends']['doctrine']['batch_size'] > 1) { // if the backend is doctrine and the batch size > 1, then // the unit of work must be cleaned wisely to avoid any issue // while persisting entities $ids = [ 'sonata.notification.event.doctrine_backend_optimize', ]; } } $container->setParameter('sonata.notification.event.iteration_listeners', $ids); } /** * @param array $checkLevel * @param int $pause * @param int $maxAge * @param int $batchSize * * @throws \RuntimeException */ protected function configureDoctrineBackends(ContainerBuilder $container, array $config, $checkLevel, $pause, $maxAge, $batchSize) { $queues = $config['queues']; $qBackends = []; $definition = $container->getDefinition('sonata.notification.backend.doctrine'); // no queue defined, set a default one if (0 === \count($queues)) { $queues = [[ 'queue' => 'default', 'default' => true, 'types' => [], ]]; } $defaultSet = false; $declaredQueues = []; $defaultQueue = ''; foreach ($queues as $pos => &$queue) { if (\in_array($queue['queue'], $declaredQueues, true)) { throw new \RuntimeException('The doctrine backend does not support 2 identicals queue name, please rename one queue'); } $declaredQueues[] = $queue['queue']; // make the configuration compatible with old code and rabbitmq if (isset($queue['routing_key']) && '' !== $queue['routing_key']) { $queue['types'] = [$queue['routing_key']]; } if (empty($queue['types']) && false === $queue['default']) { throw new \RuntimeException('You cannot declared a doctrine queue with no type defined with default = false'); } if (!empty($queue['types']) && true === $queue['default']) { throw new \RuntimeException('You cannot declared a doctrine queue with types defined with default = true'); } $id = $this->createDoctrineQueueBackend($container, $definition->getArgument(0), $checkLevel, $pause, $maxAge, $batchSize, $queue['queue'], $queue['types']); $qBackends[$pos] = [ 'types' => $queue['types'], 'backend' => new Reference($id), ]; if (true === $queue['default']) { if (true === $defaultSet) { throw new \RuntimeException('You can only set one doctrine default queue in your sonata notification configuration.'); } $defaultSet = true; $defaultQueue = $queue['queue']; } } if (false === $defaultSet) { throw new \RuntimeException('You need to specify a valid default queue for the doctrine backend!'); } $definition ->replaceArgument(1, $queues) ->replaceArgument(2, $defaultQueue) ->replaceArgument(3, $qBackends); } /** * @param string $manager * @param array $checkLevel * @param int $pause * @param int $maxAge * @param int $batchSize * @param string $key * * @return string */ protected function createDoctrineQueueBackend(ContainerBuilder $container, $manager, $checkLevel, $pause, $maxAge, $batchSize, $key, array $types = []) { if ('' === $key) { $id = 'sonata.notification.backend.doctrine.default_'.$this->amqpCounter++; } else { $id = 'sonata.notification.backend.doctrine.'.$key; } $definition = new Definition(MessageManagerBackend::class, [$manager, $checkLevel, $pause, $maxAge, $batchSize, $types]); $definition->setPublic(false); $container->setDefinition($id, $definition); return $id; } protected function configureRabbitmq(ContainerBuilder $container, array $config) { $queues = $config['queues']; $connection = $config['backends']['rabbitmq']['connection']; $baseExchange = $config['backends']['rabbitmq']['exchange']; $amqBackends = []; if (0 === \count($queues)) { $queues = [[ 'queue' => 'default', 'default' => true, 'routing_key' => '', 'recover' => false, 'dead_letter_exchange' => null, 'dead_letter_routing_key' => null, 'ttl' => null, 'prefetch_count' => null, ]]; } $deadLetterRoutingKeys = $this->getQueuesParameters('dead_letter_routing_key', $queues); $routingKeys = $this->getQueuesParameters('routing_key', $queues); foreach ($deadLetterRoutingKeys as $key) { if (!\in_array($key, $routingKeys, true)) { throw new \RuntimeException(sprintf( 'You must configure the queue having the routing_key "%s" same as dead_letter_routing_key', $key )); } } $declaredQueues = []; $defaultQueue = ''; $defaultSet = false; foreach ($queues as $pos => $queue) { if (\in_array($queue['queue'], $declaredQueues, true)) { throw new \RuntimeException('The RabbitMQ backend does not support 2 identicals queue name, please rename one queue'); } $declaredQueues[] = $queue['queue']; if ($queue['dead_letter_routing_key']) { if (null === $queue['dead_letter_exchange']) { throw new \RuntimeException( 'dead_letter_exchange must be configured when dead_letter_routing_key is set' ); } } if (\in_array($queue['routing_key'], $deadLetterRoutingKeys, true)) { $exchange = $this->getAMQPDeadLetterExchangeByRoutingKey($queue['routing_key'], $queues); } else { $exchange = $baseExchange; } $id = $this->createAMQPBackend( $container, $exchange, $queue['queue'], $queue['recover'], $queue['routing_key'], $queue['dead_letter_exchange'], $queue['dead_letter_routing_key'], $queue['ttl'], $queue['prefetch_count'] ); $amqBackends[$pos] = [ 'type' => $queue['routing_key'], 'backend' => new Reference($id), ]; if (true === $queue['default']) { if (true === $defaultSet) { throw new \RuntimeException('You can only set one rabbitmq default queue in your sonata notification configuration.'); } $defaultSet = true; $defaultQueue = $queue['routing_key']; } } if (false === $defaultSet) { throw new \RuntimeException('You need to specify a valid default queue for the rabbitmq backend!'); } $container->getDefinition('sonata.notification.backend.rabbitmq') ->replaceArgument(0, $connection) ->replaceArgument(1, $queues) ->replaceArgument(2, $defaultQueue) ->replaceArgument(3, $amqBackends); } /** * @param string $exchange * @param string $name * @param string $recover * @param string $key * @param string $deadLetterExchange * @param string $deadLetterRoutingKey * @param int|null $ttl * @param int|null $prefetchCount * * @return string */ protected function createAMQPBackend(ContainerBuilder $container, $exchange, $name, $recover, $key = '', $deadLetterExchange = null, $deadLetterRoutingKey = null, $ttl = null, $prefetchCount = null) { $id = 'sonata.notification.backend.rabbitmq.'.$this->amqpCounter++; $definition = new Definition( AMQPBackend::class, [ $exchange, $name, $recover, $key, $deadLetterExchange, $deadLetterRoutingKey, $ttl, $prefetchCount, ] ); $definition->setPublic(false); $container->setDefinition($id, $definition); return $id; } private function registerSonataDoctrineMapping(array $config): void { $collector = DoctrineCollector::getInstance(); $collector->addIndex($config['class']['message'], 'idx_state', ['state']); $collector->addIndex($config['class']['message'], 'idx_created_at', ['created_at']); } /** * @param string $name * * @return string[] */ private function getQueuesParameters($name, array $queues) { $params = array_unique(array_map(static function ($q) use ($name) { return $q[$name]; }, $queues)); $idx = array_search(null, $params, true); if (false !== $idx) { unset($params[$idx]); } return $params; } /** * @param string $key * * @return string */ private function getAMQPDeadLetterExchangeByRoutingKey($key, array $queues) { foreach ($queues as $queue) { if ($queue['dead_letter_routing_key'] === $key) { return $queue['dead_letter_exchange']; } } throw new \InvalidArgumentException(sprintf('The key %s was not found', $key)); } }
php
MIT
bb87afcd43c3d64e0b92404ceb0bf038c51d8b2e
2026-01-05T04:47:35.154999Z
false
sonata-project/SonataNotificationBundle
https://github.com/sonata-project/SonataNotificationBundle/blob/bb87afcd43c3d64e0b92404ceb0bf038c51d8b2e/src/DependencyInjection/Configuration.php
src/DependencyInjection/Configuration.php
<?php declare(strict_types=1); /* * This file is part of the Sonata Project package. * * (c) Thomas Rabaix <thomas.rabaix@sonata-project.org> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Sonata\NotificationBundle\DependencyInjection; use Enqueue\AmqpLib\AmqpConnectionFactory; use Symfony\Component\Config\Definition\Builder\ArrayNodeDefinition; use Symfony\Component\Config\Definition\Builder\NodeDefinition; use Symfony\Component\Config\Definition\Builder\TreeBuilder; use Symfony\Component\Config\Definition\ConfigurationInterface; /** * @final since sonata-project/notification-bundle 3.13 */ class Configuration implements ConfigurationInterface { public function getConfigTreeBuilder() { $treeBuilder = new TreeBuilder('sonata_notification'); $rootNode = $treeBuilder->getRootNode()->children(); $backendInfo = <<<'EOF' Other backends you can use: sonata.notification.backend.postpone sonata.notification.backend.doctrine sonata.notification.backend.rabbitmq EOF; $iterationListenersInfo = <<<EOF Listeners attached to the IterateEvent Iterate event is thrown on each command iteration Iteration listener class must implement Sonata\NotificationBundle\Event\IterationListener EOF; $rootNode ->scalarNode('backend') ->info($backendInfo) ->defaultValue('sonata.notification.backend.runtime') ->end() ->append($this->getQueueNode()) ->arrayNode('backends') ->children() ->arrayNode('doctrine') ->children() ->scalarNode('message_manager') ->defaultValue('sonata.notification.manager.message.default') ->end() ->scalarNode('max_age') ->info('The max age in seconds') ->defaultValue(86400) ->end() ->scalarNode('pause') ->info('The delay in microseconds') ->defaultValue(500000) ->end() ->scalarNode('batch_size') ->info('The number of items on each iteration') ->defaultValue(10) ->end() ->arrayNode('states') ->info('Raising errors level') ->addDefaultsIfNotSet() ->children() ->integerNode('in_progress') ->defaultValue(10) ->end() ->integerNode('error') ->defaultValue(20) ->end() ->integerNode('open') ->defaultValue(100) ->end() ->integerNode('done') ->defaultValue(10000) ->end() ->end() ->end() ->end() ->end() ->arrayNode('rabbitmq') ->children() ->scalarNode('exchange') ->cannotBeEmpty() ->isRequired() ->end() ->arrayNode('connection') ->addDefaultsIfNotSet() ->children() ->scalarNode('host') ->defaultValue('localhost') ->end() ->scalarNode('port') ->defaultValue(5672) ->end() ->scalarNode('user') ->defaultValue('guest') ->end() ->scalarNode('pass') ->defaultValue('guest') ->end() ->scalarNode('vhost') ->defaultValue('guest') ->end() ->scalarNode('console_url') ->defaultValue('http://localhost:55672/api') ->end() ->scalarNode('factory_class') ->cannotBeEmpty() ->defaultValue(AmqpConnectionFactory::class) ->info('This option defines an AMQP connection factory to be used to establish a connection with RabbitMQ.') ->end() ->end() ->end() ->end() ->end() ->end() ->end() ->arrayNode('consumers') ->addDefaultsIfNotSet() ->children() ->booleanNode('register_default') ->info('If set to true, SwiftMailerConsumer and LoggerConsumer will be registered as services') ->defaultTrue() ->end() ->end() ->end() ->arrayNode('iteration_listeners') ->info($iterationListenersInfo) ->defaultValue([]) ->prototype('scalar')->end() ->end() ->arrayNode('class') ->addDefaultsIfNotSet() ->children() ->scalarNode('message') ->defaultValue('App\\Entity\\Message') ->end() ->end() ->end() ->arrayNode('admin') ->addDefaultsIfNotSet() ->children() ->booleanNode('enabled') ->defaultTrue() ->end() ->arrayNode('message') ->addDefaultsIfNotSet() ->children() ->scalarNode('class') ->cannotBeEmpty() ->defaultValue('Sonata\\NotificationBundle\\Admin\\MessageAdmin') ->end() ->scalarNode('controller') ->cannotBeEmpty() ->defaultValue('SonataNotificationBundle:MessageAdmin') ->end() ->scalarNode('translation') ->cannotBeEmpty() ->defaultValue('SonataNotificationBundle') ->end() ->end() ->end() ->end() ->end(); return $treeBuilder; } /** * @return ArrayNodeDefinition|NodeDefinition */ protected function getQueueNode() { $treeBuilder = new TreeBuilder('queues'); $node = $treeBuilder->getRootNode(); $queuesInfo = <<<'EOF' Example for using RabbitMQ - { queue: myQueue, recover: true, default: false, routing_key: the_routing_key, dead_letter_exchange: 'my.dead.letter.exchange' } - { queue: catchall, default: true } Example for using Doctrine - { queue: sonata_page, types: [sonata.page.create_snapshot, sonata.page.create_snapshots] } - { queue: catchall, default: true } EOF; $routingKeyInfo = <<<'EOF' Only used by RabbitMQ Direct exchange with routing_key EOF; $recoverInfo = <<<'EOF' Only used by RabbitMQ If set to true, the consumer will respond with a `basic.recover` when an exception occurs, otherwise it will not respond at all and the message will be unacknowledged EOF; $deadLetterExchangeInfo = <<<'EOF' Only used by RabbitMQ If is set, failed messages will be rejected and sent to this exchange EOF; $deadLetterRoutingKeyInfo = <<<'EOF' Only used by RabbitMQ If set, failed messages will be routed to the queue using this key by dead-letter-exchange, otherwise it will be requeued to the original queue if `dead-letter-exchange` is set. If set, the queue must be configured with this key as `routing_key`. EOF; $ttlInfo = <<<'EOF' Only used by RabbitMQ Defines the per-queue message time-to-live (milliseconds) EOF; $prefetchCountInfo = <<<'EOF' Only used by RabbitMQ Defines the number of messages which will be delivered to the customer at a time. EOF; $typesInfo = <<<'EOF' Only used by Doctrine Defines types handled by the message backend EOF; $connectionNode = $node ->info($queuesInfo) ->requiresAtLeastOneElement() ->prototype('array'); $connectionNode ->children() ->scalarNode('queue') ->info('The name of the queue') ->cannotBeEmpty() ->isRequired() ->end() ->booleanNode('default') ->info('Set the name of the default queue') ->defaultValue(false) ->end() // RabbitMQ configuration ->scalarNode('routing_key') ->info($routingKeyInfo) ->defaultValue('') ->end() ->booleanNode('recover') ->info($recoverInfo) ->defaultValue(false) ->end() ->scalarNode('dead_letter_exchange') ->info($deadLetterExchangeInfo) ->defaultValue(null) ->end() ->scalarNode('dead_letter_routing_key') ->info($deadLetterRoutingKeyInfo) ->defaultValue(null) ->end() ->integerNode('ttl') ->info($ttlInfo) ->min(0) ->defaultValue(null) ->end() ->integerNode('prefetch_count') ->info($prefetchCountInfo) ->min(0) ->max(65535) ->defaultValue(null) ->end() // Database configuration (Doctrine) ->arrayNode('types') ->info($typesInfo) ->defaultValue([]) ->prototype('scalar')->end() ->end() ->end(); return $node; } }
php
MIT
bb87afcd43c3d64e0b92404ceb0bf038c51d8b2e
2026-01-05T04:47:35.154999Z
false
sonata-project/SonataNotificationBundle
https://github.com/sonata-project/SonataNotificationBundle/blob/bb87afcd43c3d64e0b92404ceb0bf038c51d8b2e/src/DependencyInjection/Compiler/NotificationCompilerPass.php
src/DependencyInjection/Compiler/NotificationCompilerPass.php
<?php declare(strict_types=1); /* * This file is part of the Sonata Project package. * * (c) Thomas Rabaix <thomas.rabaix@sonata-project.org> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Sonata\NotificationBundle\DependencyInjection\Compiler; use Sonata\NotificationBundle\Event\IterateEvent; use Sonata\NotificationBundle\Event\IterationListener; use Symfony\Component\DependencyInjection\Argument\ServiceClosureArgument; use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface; use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\DependencyInjection\Exception\RuntimeException; use Symfony\Component\DependencyInjection\Reference; /** * @final since sonata-project/notification-bundle 3.13 * * @internal since sonata-project/notification-bundle 4.0 */ class NotificationCompilerPass implements CompilerPassInterface { public function process(ContainerBuilder $container) { if (!$container->hasDefinition('sonata.notification.dispatcher')) { return; } $definition = $container->getDefinition('sonata.notification.dispatcher'); $informations = []; foreach ($container->findTaggedServiceIds('sonata.notification.consumer') as $id => $events) { $container->getDefinition($id)->setPublic(true); foreach ($events as $event) { $priority = $event['priority'] ?? 0; if (!isset($event['type'])) { throw new \InvalidArgumentException(sprintf( 'Service "%s" must define the "type" attribute on "sonata.notification" tags.', $id )); } if (!isset($informations[$event['type']])) { $informations[$event['type']] = []; } $informations[$event['type']][] = $id; $definition->addMethodCall( 'addListener', [ $event['type'], [new ServiceClosureArgument(new Reference($id)), 'process'], $priority, ] ); } } $container->getDefinition('sonata.notification.consumer.metadata')->replaceArgument(0, $informations); if ($container->getParameter('sonata.notification.event.iteration_listeners')) { $ids = $container->getParameter('sonata.notification.event.iteration_listeners'); foreach ($ids as $serviceId) { $definition = $container->getDefinition($serviceId); $class = new \ReflectionClass($definition->getClass()); if (!$class->implementsInterface(IterationListener::class)) { throw new RuntimeException( 'Iteration listeners must implement Sonata\NotificationBundle\Event\IterationListener' ); } $definition->addTag( 'kernel.event_listener', ['event' => IterateEvent::EVENT_NAME, 'method' => 'iterate'] ); } } } }
php
MIT
bb87afcd43c3d64e0b92404ceb0bf038c51d8b2e
2026-01-05T04:47:35.154999Z
false
sonata-project/SonataNotificationBundle
https://github.com/sonata-project/SonataNotificationBundle/blob/bb87afcd43c3d64e0b92404ceb0bf038c51d8b2e/src/Exception/BackendNotFoundException.php
src/Exception/BackendNotFoundException.php
<?php declare(strict_types=1); /* * This file is part of the Sonata Project package. * * (c) Thomas Rabaix <thomas.rabaix@sonata-project.org> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Sonata\NotificationBundle\Exception; /** * @final since sonata-project/notification-bundle 3.13 */ class BackendNotFoundException extends \RuntimeException { }
php
MIT
bb87afcd43c3d64e0b92404ceb0bf038c51d8b2e
2026-01-05T04:47:35.154999Z
false
sonata-project/SonataNotificationBundle
https://github.com/sonata-project/SonataNotificationBundle/blob/bb87afcd43c3d64e0b92404ceb0bf038c51d8b2e/src/Exception/HandlingException.php
src/Exception/HandlingException.php
<?php declare(strict_types=1); /* * This file is part of the Sonata Project package. * * (c) Thomas Rabaix <thomas.rabaix@sonata-project.org> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Sonata\NotificationBundle\Exception; /** * @final since sonata-project/notification-bundle 3.13 */ class HandlingException extends \RuntimeException { }
php
MIT
bb87afcd43c3d64e0b92404ceb0bf038c51d8b2e
2026-01-05T04:47:35.154999Z
false