From 8630024655a969ae39e922adf6b55dcd033c8eac Mon Sep 17 00:00:00 2001 From: Armanveer Gill Date: Fri, 13 Dec 2024 01:49:54 -0500 Subject: [PATCH] Fixed depreacated issues and warnings --- common.inc.php | 15 +++++++++------ config/backuprestore.php | 2 +- config/categories.php | 2 +- config/divisions.php | 2 +- config/languagepacks.php | 1 + config/variables.php | 6 +++--- config/versionchecker.php | 1 + config_editor.inc.php | 20 ++++++++++++-------- questions.inc.php | 12 ++++++------ 9 files changed, 35 insertions(+), 26 deletions(-) diff --git a/common.inc.php b/common.inc.php index 04a4a9b..5ec4de9 100644 --- a/common.inc.php +++ b/common.inc.php @@ -27,8 +27,8 @@ header("Content-Type: text/html; charset=utf8"); //set error reporting to not show notices, for some reason some people's installation dont set this by default //so we will set it in the code instead just to make sure -#error_reporting(E_ALL); -error_reporting( E_ALL ^ E_WARNING ); +error_reporting(E_ALL); +#error_reporting( E_ALL ^ E_WARNING ); #error_reporting( E_ALL ^ E_WARNING ^ E_NOTICE ^ E_DEPRECATED ); define('REQUIREDFIELD','*'); @@ -86,7 +86,7 @@ else $dsn = "mysql:host=db;dbname=sfiab;charset=utf8mb4"; -$pdo = new PDO($dsn,$DBUSER,$DBPASS,$dsn_options); +$pdo = new PDO($dsn,$DBUSER,$DBPASS); if(!$pdo) { @@ -195,7 +195,7 @@ require_once("theme/{$config['theme_icons']}/icons.php"); require_once("committee.inc.php"); -session_start(); + if($config['SFIABDIRECTORY'] == '') { session_name("SFIABSESSID"); @@ -205,6 +205,8 @@ if($config['SFIABDIRECTORY'] == '') { session_set_cookie_params(0,$config['SFIABDIRECTORY']); } +session_start(); + //detect the browser first, so we know what icons to use - we store this in the config array as well //even though its not configurable by the fair if(stristr($_SERVER['HTTP_USER_AGENT'],"MSIE")) @@ -230,6 +232,7 @@ else } } //now if no language has been set yet, lets set it to the default language + if(!$_SESSION['lang']) { //first try the default language, if that doesnt work, use "en" @@ -1086,7 +1089,7 @@ function output_page_text($textname) } //if it looks like we have HTML content, dont do a nl2br, if there's no html, then do the nl2br - if(strlen($r->text)==strlen(strip_tags($r->text))) + if($r->text !== null and strlen($r->text)==strlen(strip_tags($r->text))) echo nl2br($r->text); else echo $r->text; @@ -1108,7 +1111,7 @@ function output_page_cms($filename) echo ""; //if it looks like we have HTML content, dont do a nl2br, if there's no html, then do the nl2br - if(strlen($r->text)==strlen(strip_tags($r->text))) + if($r->text !== null and strlen($r->text)==strlen(strip_tags($r->text))) echo nl2br($r->text); else echo $r->text; diff --git a/config/backuprestore.php b/config/backuprestore.php index 4dc3d05..b219120 100644 --- a/config/backuprestore.php +++ b/config/backuprestore.php @@ -50,7 +50,7 @@ while($tr=$tableq->fetch(PDO::FETCH_NUM)) { $str="INSERT INTO `$table` ("; unset($fields); $fields=array(); - while($cr=$columnq->fetch(PDO:;FETCH_OBJ)) { + while($cr=$columnq->fetch(PDO:FETCH_OBJ)) { $str.="`".$cr->Field."`,"; $fields[]=$cr->Field; } diff --git a/config/categories.php b/config/categories.php index 0f71f64..15668ab 100644 --- a/config/categories.php +++ b/config/categories.php @@ -31,7 +31,7 @@ array('Committee Main' => 'committee_main.php', 'SFIAB Configuration' => 'config/index.php', 'Age Categories' => 'config/categories.php'),"project_age_categories"); - } else + } else { send_header("Age Categories", array('Committee Main' => 'committee_main.php', 'SFIAB Configuration' => 'config/index.php'),"project_age_categories"); diff --git a/config/divisions.php b/config/divisions.php index 3414c51..86bfd9b 100644 --- a/config/divisions.php +++ b/config/divisions.php @@ -218,7 +218,7 @@ if($_GET['action']=="edit" || $_GET['action']=="new") { $tempcat=" "; }else{ $tempcat=""; - while($categoryr=$c->fetch(PDO::FETCH_OBJ){ + while($categoryr=$c->fetch(PDO::FETCH_OBJ)){ $tempcat.=",".$categoryr->category; } $tempcat=substr($tempcat,1); diff --git a/config/languagepacks.php b/config/languagepacks.php index c166009..21c377a 100644 --- a/config/languagepacks.php +++ b/config/languagepacks.php @@ -39,6 +39,7 @@ function loadLanguagePacks() { $ret=array(); + //// FIXME Replace! if($packs=file("http://www.sfiab.ca/languages/langpacklist.txt")) { $num=count($packs); diff --git a/config/variables.php b/config/variables.php index 46b6796..b0943a7 100644 --- a/config/variables.php +++ b/config/variables.php @@ -81,10 +81,10 @@ $q->execute(); $trclass = ($trclass == 'odd') ? 'even' : 'odd'; echo ""; echo ""; - if($r->cat==$category) - echo "".i18n($r->cat).""; + if($r['cat']==$category) + echo "".i18n($r['cat']).""; else - echo "cat)."\">".i18n($r->cat).""; + echo "".i18n($r['cat']).""; echo ""; echo "\n"; } diff --git a/config/versionchecker.php b/config/versionchecker.php index f500e27..64a4517 100644 --- a/config/versionchecker.php +++ b/config/versionchecker.php @@ -41,6 +41,7 @@ function loadVersions() { $ret=array(); + // FIXME Replace if($v=file("http://www.sfiab.ca/version.txt")) { list($version,$date)=split("\t",trim($v[0])); diff --git a/config_editor.inc.php b/config_editor.inc.php index db8dfef..6511534 100644 --- a/config_editor.inc.php +++ b/config_editor.inc.php @@ -24,19 +24,22 @@ prepare($query); - print($pdo->errorInfo()); + $q->execute(); + //print_r($pdo->errorInfo()); + $var = array(); while($r=$q->fetch()) { - $var[$r->var]['val'] = $r->val; - $var[$r->var]['desc'] = $r->description; - $var[$r->var]['category'] = $r->category; - $var[$r->var]['ord'] = $r->ord; - $var[$r->var]['type'] = $r->type; - $var[$r->var]['type_values'] = $r->type_values; + $var[$r['var']]['val'] = $r['val']; + $var[$r['var']]['desc'] = $r['description']; + $var[$r['var']]['category'] = $r['category']; + $var[$r['var']]['ord'] = $r['ord']; + $var[$r['var']]['type'] = $r['type']; + $var[$r['var']]['type_values'] = $r['type_values']; } return $var; } @@ -200,6 +203,7 @@ function config_editor($category, $year, $array_name, $self) if($biggest>30) $size=30; else $size=$biggest+1; + //make sure size is at minimum 8, this way if all fields are empty you dont end up with 1 character long text boxes if($size<8) $size=8; diff --git a/questions.inc.php b/questions.inc.php index 5fd98d6..78102e4 100644 --- a/questions.inc.php +++ b/questions.inc.php @@ -174,7 +174,7 @@ function questions_update_question($qs) `db_heading`='".$qs['db_heading']."', `required`='".$qs['required']."', `ord`=".intval($qs['ord']." - WHERE id='{$qs['id']}' "); + WHERE id='{$qs['id']}' ")); $stmt->execute(); echo $pdo->errorInfo(); } @@ -369,17 +369,17 @@ function questions_editor($section, $year, $array_name, $self) echo error(i18n("Invalid question")); } } - if($showform) + if($showform and headers_sent()) { echo ""; echo ""; echo ""; echo ""; echo "
".i18n("Question").""; - echo "\n"; + echo "\n"; echo "
".i18n("Table Heading").""; - echo "\n"; + echo "\n"; echo "
".i18n("Type").""; - echo ""; if($q['type']=="check") $sel="selected=\"selected\""; else $sel=""; echo "\n"; if($q['type']=="yesno") $sel="selected=\"selected\""; else $sel=""; @@ -392,7 +392,7 @@ function questions_editor($section, $year, $array_name, $self) echo ""; echo "
".i18n("Required?").""; - echo ""; if($q['required']=="yes") $sel="selected=\"selected\""; else $sel=""; echo "\n"; if($q['required']=="no") $sel="selected=\"selected\""; else $sel="";