forked from science-ation/science-ation
Remove warnings for undefined variables on main pages
This commit is contained in:
parent
86a521ca80
commit
f8adb23910
@ -1,12 +1,14 @@
|
||||
<?
|
||||
|
||||
include_once("helper.inc.php");
|
||||
|
||||
function committee_auth_has_access($access="")
|
||||
{
|
||||
|
||||
switch($access) {
|
||||
case 'config': return ($_SESSION['access_config'] == 'yes') ? true : false;
|
||||
case 'admin': return ($_SESSION['access_admin'] == 'yes') ? true : false;
|
||||
case 'super': return ($_SESSION['access_super'] == 'yes') ? true : false;
|
||||
case 'config': return (get_value_from_array($_SESSION, 'access_config') == 'yes') ? true : false;
|
||||
case 'admin': return (get_value_from_array($_SESSION, 'access_admin') == 'yes') ? true : false;
|
||||
case 'super': return (get_value_from_array($_SESSION, 'access_super') == 'yes') ? true : false;
|
||||
}
|
||||
|
||||
return false;
|
||||
|
@ -22,6 +22,7 @@
|
||||
*/
|
||||
?>
|
||||
<?
|
||||
include_once("helper.inc.php");
|
||||
//////echo phpinfo();
|
||||
header("Content-Type: text/html; charset=utf8");
|
||||
|
||||
@ -195,8 +196,6 @@ require_once("theme/{$config['theme_icons']}/icons.php");
|
||||
|
||||
require_once("committee.inc.php");
|
||||
|
||||
|
||||
|
||||
if($config['SFIABDIRECTORY'] == '') {
|
||||
session_name("SFIABSESSID");
|
||||
session_set_cookie_params(0,'/');
|
||||
@ -244,10 +243,10 @@ if(!$_SESSION['lang'])
|
||||
|
||||
//only allow debug to get set if we're using a development version (odd numbered ending)
|
||||
if(substr($config['version'], -1) % 2 != 0)
|
||||
if($_GET['debug']) $_SESSION['debug']=$_GET['debug'];
|
||||
if(get_value_from_array($_GET, 'debug')) $_SESSION['debug']=$_GET['debug'];
|
||||
|
||||
//if the user has switched languages, go ahead and switch the session variable
|
||||
if($_GET['switchlanguage'])
|
||||
if(get_value_from_array($_GET, 'switchlanguage'))
|
||||
{
|
||||
//first, make sure its a valid language:
|
||||
if($config['languages'][$_GET['switchlanguage']])
|
||||
@ -518,7 +517,7 @@ if(is_array($nav)) {
|
||||
<br />
|
||||
<ul class="mainnav">
|
||||
<?
|
||||
if($_SESSION['users_type'] == 'committee') {
|
||||
if(get_value_from_session('users_type') == 'committee') {
|
||||
echo "<li><a href=\"{$config['SFIABDIRECTORY']}/user_personal.php\">".i18n("My Profile").'</a></li>';
|
||||
echo "<li><a href=\"{$config['SFIABDIRECTORY']}/committee_main.php\">".i18n("Committee Home").'</a></li>';
|
||||
if(committee_auth_has_access("admin")){
|
||||
@ -528,23 +527,23 @@ if($_SESSION['users_type'] == 'committee') {
|
||||
echo "<li><a href=\"{$config['SFIABDIRECTORY']}/config/\">".i18n("Configuration").'</a></li>';
|
||||
}
|
||||
echo "<li><a href=\"{$config['SFIABDIRECTORY']}/user_login.php?action=logout\">".i18n("Logout").'</a></li>';
|
||||
} else if($_SESSION['users_type']=="judge") {
|
||||
} else if(get_value_from_session('users_type') == "judge") {
|
||||
echo "<li><a href=\"{$config['SFIABDIRECTORY']}/user_personal.php\">".i18n("My Profile").'</a></li>';
|
||||
echo "<li><a href=\"{$config['SFIABDIRECTORY']}/judge_main.php\">".i18n("Judge Home").'</a></li>';
|
||||
echo "<li><a href=\"{$config['SFIABDIRECTORY']}/user_login.php?action=logout\">".i18n("Logout").'</a></li>';
|
||||
} else if($_SESSION['users_type']=="volunteer") {
|
||||
} else if(get_value_from_session('users_type') == "volunteer") {
|
||||
echo "<li><a href=\"{$config['SFIABDIRECTORY']}/user_personal.php\">".i18n("My Profile").'</a></li>';
|
||||
echo "<li><a href=\"{$config['SFIABDIRECTORY']}/volunteer_main.php\">".i18n("Volunteer Home").'</a></li>';
|
||||
echo "<li><a href=\"{$config['SFIABDIRECTORY']}/user_login.php?action=logout\">".i18n("Logout").'</a></li>';
|
||||
} else if($_SESSION['users_type']=="sponsor") {
|
||||
} else if(get_value_from_session('users_type') == "sponsor") {
|
||||
echo "<li><a href=\"{$config['SFIABDIRECTORY']}/user_personal.php\">".i18n("My Profile").'</a></li>';
|
||||
echo "<li><a href=\"{$config['SFIABDIRECTORY']}/sponsor_main.php\">".i18n("Sponsor Home").'</a></li>';
|
||||
echo "<li><a href=\"{$config['SFIABDIRECTORY']}/user_login.php?action=logout\">".i18n("Logout").'</a></li>';
|
||||
} else if($_SESSION['schoolid'] && $_SESSION['schoolaccesscode']) {
|
||||
} else if(get_value_from_session('schoolid') && get_value_from_session('schoolaccesscode')) {
|
||||
echo "<li><a href=\"{$config['SFIABDIRECTORY']}/schoolaccess.php\">".i18n("School Home").'</a></li>';
|
||||
echo "<li><a href=\"{$config['SFIABDIRECTORY']}/schoolaccess.php?action=logout\">".i18n("Logout").'</a></li>';
|
||||
}
|
||||
else if($_SESSION['registration_number'] && $_SESSION['registration_id']) {
|
||||
else if(get_value_from_session('registration_number') && get_value_from_session('registration_id')) {
|
||||
echo "<li><a href=\"{$config['SFIABDIRECTORY']}/register_participants_main.php\">".i18n("Participant Home").'</a></li>';
|
||||
echo "<li><a href=\"{$config['SFIABDIRECTORY']}/register_participants.php?action=logout\">".i18n("Logout")."</a></li>\n";
|
||||
} else {
|
||||
@ -651,13 +650,15 @@ if(substr($config['version'], -1) % 2 != 0)
|
||||
$revision=exec("svn info |grep Revision");
|
||||
}
|
||||
$extra=" (Development $revision)";
|
||||
if($_SESSION['debug']=="true")
|
||||
if(get_value_from_array($_SESSION, 'debug') == "true")
|
||||
$extra.=" DEBUG: ".print_r($_SESSION,true);
|
||||
}
|
||||
echo "<a target=\"blank\" href=\"http://www.sfiab.ca\">SFIAB Version ".$config['version']."{$extra}</a>";
|
||||
|
||||
// FIX ME
|
||||
echo "<a target=\"blank\" href=\"http://www.sfiab.ca\">SFIAB Version ".$config['version']."{$extra}</a>";
|
||||
?>
|
||||
</div>
|
||||
<div id="debug" style="display:<?=($_SESSION['debug']=='true')?'block':'none'?>; font-family:monospace; white-space:pre; " >Debug...</div>
|
||||
<div id="debug" style="display:<?=(get_value_from_array($_SESSION, 'debug') == 'true')?'block':'none'?>; font-family:monospace; white-space:pre;">Debug...</div>
|
||||
<iframe id="content" src="" style="visibility:hidden; width:0px; height:0px"></iframe>
|
||||
|
||||
</body>
|
||||
@ -1105,16 +1106,16 @@ function output_page_cms($filename)
|
||||
if($q->rowCount())
|
||||
{
|
||||
$r = $q->fetch();
|
||||
send_header($r->title,null,null,true);
|
||||
send_header($r['title'],null,null,true);
|
||||
|
||||
if(file_exists("data/logo-200.gif") && $r->showlogo==1)
|
||||
echo "<img align=\"right\" src=\"".$config['SFIABDIRECTORY']."/data/logo-200.gif\" border=\"0\">";
|
||||
|
||||
//if it looks like we have HTML content, dont do a nl2br, if there's no html, then do the nl2br
|
||||
if($r->text !== null and strlen($r->text)==strlen(strip_tags($r->text)))
|
||||
echo nl2br($r->text);
|
||||
if($r['text'] !== null and strlen($r['text'])==strlen(strip_tags($r['text'])))
|
||||
echo nl2br($r['text']);
|
||||
else
|
||||
echo $r->text;
|
||||
echo $r['text'];
|
||||
}
|
||||
else {
|
||||
send_header("Error: File not found");
|
||||
|
@ -30,9 +30,9 @@
|
||||
return trim($lines[0]);
|
||||
}
|
||||
|
||||
if($_POST['action']=="send") {
|
||||
if($_POST['to'] && $_POST['subject'] && $_POST['message'] && $_POST['from'] && $_POST['fromemail']) {
|
||||
if(isEmailAddress($_POST['fromemail'])) {
|
||||
if(get_value_from_array($_POST, 'action') == "send") {
|
||||
if(get_value_from_array($_POST, 'to') && get_value_from_array($_POST, 'subject') && get_value_from_array($_POST, 'message') && get_value_from_array($_POST, 'from') && get_value_from_array($_POST, 'fromemail')) {
|
||||
if(isEmailAddress(get_value_from_array($_POST, 'fromemail'))) {
|
||||
list($id,$md5email)=explode(":",$_POST['to']);
|
||||
|
||||
$q=pdo->prepare("SELECT * FROM users WHERE uid=.?. ORDER BY year DESC LIMIT 1");
|
||||
|
18
helper.inc.php
Normal file
18
helper.inc.php
Normal file
@ -0,0 +1,18 @@
|
||||
<?
|
||||
|
||||
function get_value_from_session(string $key, mixed $default = null) : mixed
|
||||
{
|
||||
return isset($_SESSION[$key]) ? $_SESSION[$key] : $default;
|
||||
}
|
||||
|
||||
function get_value_from_array(array $ar, string $key, mixed $default = null) : mixed
|
||||
{
|
||||
return isset($ar[$key]) ? $ar[$key] : $default;
|
||||
}
|
||||
|
||||
function get_value(mixed $var) : mixed
|
||||
{
|
||||
return isset($var) ? $var : null;
|
||||
}
|
||||
|
||||
?>
|
@ -23,6 +23,7 @@
|
||||
?>
|
||||
<?
|
||||
include "common.inc.php";
|
||||
|
||||
send_header("Important Dates",null,"important_dates");
|
||||
|
||||
echo "<table>";
|
||||
@ -31,14 +32,18 @@
|
||||
$q->execute([
|
||||
':year' => $config['FAIRYEAR']
|
||||
]);
|
||||
|
||||
$trclass = null;
|
||||
while($r = $q->fetch(PDO::FETCH_OBJ))
|
||||
{
|
||||
$trclass = ($trclass == 'odd') ? 'even' : 'odd';
|
||||
$trclass = (get_value($trclass) == 'odd') ? 'even' : 'odd';
|
||||
|
||||
if($r->date != '0000-00-00 00:00:00') {
|
||||
$d = format_datetime($r->udate);
|
||||
echo "<tr class=\"$trclass\"><td>".i18n($r->description)."</td><td>$d</td></tr>";
|
||||
}
|
||||
}
|
||||
|
||||
echo "</table>";
|
||||
|
||||
send_footer();
|
||||
|
10
winners.php
10
winners.php
@ -27,13 +27,13 @@
|
||||
|
||||
send_header("Winners");
|
||||
|
||||
if($_GET['edit']) $edit=$_GET['edit'];
|
||||
if($_POST['edit']) $edit=$_POST['edit'];
|
||||
if(get_value_from_array($_GET, 'edit')) $edit=$_GET['edit'];
|
||||
if(get_value_from_array($_POST, 'edit')) $edit=$_POST['edit'];
|
||||
|
||||
if($_GET['action']) $action=$_GET['action'];
|
||||
if($_POST['action']) $action=$_POST['action'];
|
||||
if(get_value_from_array($_GET, 'action')) $action=$_GET['action'];
|
||||
if(get_value_from_array($_POST, 'action')) $action=$_POST['action'];
|
||||
|
||||
if($_GET['year'] && $_GET['type']) {
|
||||
if(get_value_from_array($_GET, 'year') && get_value_from_array($_GET, 'type')) {
|
||||
$show_unawarded_awards="no";
|
||||
$show_unawarded_prizes="no";
|
||||
$year=intval($_GET['year']);
|
||||
|
Loading…
Reference in New Issue
Block a user