Commit 9323dd8e authored by François Jacquet's avatar François Jacquet
Browse files

Multibyte strings (2)

stripos => mb_stripos
strlen => mb_strlen
strpos => mb_strpos
strrchr =>
mb_strrchr
strrpos => mb_strrpos
strstr => mb_strstr
strtolower =>
mb_strtolower
strtoupper => mb_strtoupper
substr_count =>
mb_substr_count
substr => mb_substr
parent 112fe431
......@@ -12,15 +12,15 @@ if($_REQUEST['modfunc']=='print')
$_REQUEST = $_SESSION['_REQUEST_vars'];
$_REQUEST['_ROSARIO_PDF'] = true;
//modif Francois: replaced ? with & in modname
/*if(strpos($_REQUEST['modname'],'?')!==false)
$modname = substr($_REQUEST['modname'],0,strpos($_REQUEST['modname'],'?'));
/*if(mb_strpos($_REQUEST['modname'],'?')!==false)
$modname = mb_substr($_REQUEST['modname'],0,mb_strpos($_REQUEST['modname'],'?'));
else*/
$modname = $_REQUEST['modname'];
if(!$wkhtmltopdfPath)
$_ROSARIO['allow_edit'] = false;
//modif Francois: security fix, cf http://www.securiteam.com/securitynews/6S02U1P6BI.html
if (substr($modname, -4, 4)!='.php' || strpos($modname, '..')!==false || !is_file('modules/'.$modname))
if (mb_substr($modname, -4, 4)!='.php' || mb_strpos($modname, '..')!==false || !is_file('modules/'.$modname))
HackingLog();
else
include('modules/'.$modname);
......@@ -33,7 +33,7 @@ else
//modif Francois: fix bug Internet Explorer Quirks Mode, add DOCTYPE
?>
<!DOCTYPE html>
<HTML lang="<?php echo substr($locale,0,2); ?>" <?php echo (substr($locale,0,2)=='he' || substr($locale,0,2)=='ar'?' dir="RTL"':''); ?>>
<HTML lang="<?php echo mb_substr($locale,0,2); ?>" <?php echo (mb_substr($locale,0,2)=='he' || mb_substr($locale,0,2)=='ar'?' dir="RTL"':''); ?>>
<HEAD><TITLE><?php echo Config('TITLE'); ?></TITLE>
<meta charset="UTF-8" />
<script type="text/javascript">
......@@ -76,8 +76,8 @@ function expandFrame(){
echo '<TD><A HREF="#" onclick="expandFrame();return false;"><IMG SRC="assets/help.png" height="24" /></A></TD><TD class="BottomButton"><A HREF="#" onclick="expandFrame();return false;">'._('Help').'</A></TD>';
echo '<TD><A HREF="index.php?modfunc=logout" target="_top"><IMG SRC="assets/logout.png" height="24" /></A></TD><TD class="BottomButton"><A HREF="index.php?modfunc=logout" target="_top">'._('Logout').'</A></TD></TR></TABLE>';
if (file_exists('Help_'.substr($locale, 0, 2).'.php')) //modif Francois: translated help
include 'Help_'.substr($locale, 0, 2).'.php';
if (file_exists('Help_'.mb_substr($locale, 0, 2).'.php')) //modif Francois: translated help
include 'Help_'.mb_substr($locale, 0, 2).'.php';
else
include 'Help.php';
// include 'Menu.php';
......
......@@ -149,7 +149,7 @@ else
}
if(strpos($_SERVER['PHP_SELF'],'Help.php'))
if(mb_strpos($_SERVER['PHP_SELF'],'Help.php'))
{
switch(User('PROFILE'))
{
......@@ -175,9 +175,9 @@ if(strpos($_SERVER['PHP_SELF'],'Help.php'))
foreach($help as $program=>$value)
{
if(strpos($program,'/'))
if(mb_strpos($program,'/'))
{
$modcat = str_replace('_',' ',substr($program,0,strpos($program,'/')));
$modcat = str_replace('_',' ',mb_substr($program,0,mb_strpos($program,'/')));
if($modcat!=$old_modcat && $RosarioModules[str_replace(' ','_',$modcat)]) //if module activated
echo '<div style="page-break-after: always;"></div><TABLE><TR><TD><IMG SRC="assets/icons/'.str_replace(' ','_',$modcat).'.png" height="48"></TD><TD><h1>'.$modcat.'</h1></TD></TR></TABLE><HR>';
$old_modcat = $modcat;
......
......@@ -146,7 +146,7 @@ else
$help['Eligibility/StudentList.php'] = '<p><i>Lista de Estudiante</i> es un reporte que muestra todas las calificaciones y las notas de elegibilidad de su estudiante.</p><p>Usted puede especificar el transcurso de elegibilidad que quiere ver escogiendo las fechas en el menú desplegable en la parte superior de la pantalla y presionando el botón «Ir». La elegibilidad esta entrada cada semana.</p>';
}
if(strpos($_SERVER['PHP_SELF'],'Help_es.php'))
if(mb_strpos($_SERVER['PHP_SELF'],'Help_es.php'))
{
switch(User('PROFILE'))
{
......@@ -172,9 +172,9 @@ if(strpos($_SERVER['PHP_SELF'],'Help_es.php'))
foreach($help as $program=>$value)
{
if(strpos($program,'/'))
if(mb_strpos($program,'/'))
{
$modcat = str_replace('_',' ',substr($program,0,strpos($program,'/')));
$modcat = str_replace('_',' ',mb_substr($program,0,mb_strpos($program,'/')));
if($modcat!=$old_modcat && $RosarioModules[str_replace(' ','_',$modcat)]) //if module activated
echo '<div style="page-break-after: always;"></div><TABLE><TR><TD><IMG SRC="assets/icons/'.str_replace(' ','_',$modcat).'.png" height="48"></TD><TD><h1>'._($modcat).'</h1></TD></TR></TABLE><HR>';
$old_modcat = $modcat;
......
......@@ -2,15 +2,14 @@
error_reporting(E_ALL ^ E_NOTICE);
//error_reporting(E_ERROR);
include 'Warehouse.php';
//array_rwalk($_REQUEST,'DBEscapeString');
//modif Francois: add TinyMCE to the textarea (see modules/Students/Letters.php & modules/Grades/HonorRollSubject.php & modules/Grades/HonorRoll.php)
/*if (($_REQUEST['modname']=='Students/Letters.php' && isset($_REQUEST['letter_text'])) || (($_REQUEST['modname']=='Grades/HonorRollSubject.php' || $_REQUEST['modname']=='Grades/HonorRoll.php') && isset($_REQUEST['honor_roll_text'])))
if (($_REQUEST['modname']=='Students/Letters.php' && isset($_REQUEST['letter_text'])) || (($_REQUEST['modname']=='Grades/HonorRollSubject.php' || $_REQUEST['modname']=='Grades/HonorRoll.php') && isset($_REQUEST['honor_roll_text'])))
{
$REQUEST_letter_text = $_REQUEST['letter_text'];
$REQUEST_honor_roll_text = $_REQUEST['honor_roll_text'];
}*/
}
if ((!$_REQUEST['modname']=='Students/Letters.php' || !isset($_REQUEST['letter_text'])) && (!$_REQUEST['modname']=='Grades/HonorRollSubject.php' || !isset($_REQUEST['honor_roll_text'])) && (!$_REQUEST['modname']=='Grades/HonorRoll.php' || !isset($_REQUEST['honor_roll_text'])))
if(!get_magic_quotes_gpc())
array_rwalk($_REQUEST,'addslashes');
......@@ -23,7 +22,7 @@ if(!isset($_REQUEST['_ROSARIO_PDF']))
//modif Francois: security fix, cf http://www.securiteam.com/securitynews/6S02U1P6BI.html
//allow PHP scripts in misc/ one by one in place of the whole folder
//if(strpos($_REQUEST['modname'],'misc/')===false)
//if(mb_strpos($_REQUEST['modname'],'misc/')===false)
if (!in_array($_REQUEST['modname'], array('misc/ChooseRequest.php', 'misc/ChooseCourse.php', 'misc/ViewContact.php')))
echo '<script type="text/javascript">if(window == top && (!window.opener || window.opener.location.href.substring(0,(window.opener.location.href.indexOf("&")!=-1?window.opener.location.href.indexOf("&"):window.opener.location.href.replace("#","").length))!=window.location.href.substring(0,(window.location.href.indexOf("&")!=-1?window.location.href.indexOf("&"):window.location.href.replace("#","").length)))) window.location.href = "index.php";</script>';
echo '</HEAD><BODY id="modulesBody">';
......@@ -35,10 +34,10 @@ if($_REQUEST['modname'])
if(isset($_REQUEST['_ROSARIO_PDF']) && $_REQUEST['_ROSARIO_PDF']=='true')
ob_start();
//modif Francois: replaced ? with & in modname
/*if(strpos($_REQUEST['modname'],'?')!==false)
/*if(mb_strpos($_REQUEST['modname'],'?')!==false)
{
$modname = substr($_REQUEST['modname'],0,strpos($_REQUEST['modname'],'?'));
$vars = substr($_REQUEST['modname'],(strpos($_REQUEST['modname'],'?')+1));
$modname = mb_substr($_REQUEST['modname'],0,mb_strpos($_REQUEST['modname'],'?'));
$vars = mb_substr($_REQUEST['modname'],(mb_strpos($_REQUEST['modname'],'?')+1));
$vars = explode('?',$vars);
foreach($vars as $code)
......@@ -50,7 +49,7 @@ if($_REQUEST['modname'])
else*/
$modname = $_REQUEST['modname'];
if(empty($_REQUEST['LO_save']) && !isset($_REQUEST['_ROSARIO_PDF']) && (strpos($modname,'misc/')===false || $modname=='misc/Registration.php' || $modname=='misc/Export.php' || $modname=='misc/Portal.php'))
if(empty($_REQUEST['LO_save']) && !isset($_REQUEST['_ROSARIO_PDF']) && (mb_strpos($modname,'misc/')===false || $modname=='misc/Registration.php' || $modname=='misc/Export.php' || $modname=='misc/Portal.php'))
$_SESSION['_REQUEST_vars'] = $_REQUEST;
$allowed = false;
......@@ -65,7 +64,7 @@ if($_REQUEST['modname'])
foreach($programs as $program=>$title)
{
//modif Francois: fix bug URL Modules.php?modname=Student_Billing/Statements.php&_ROSARIO_PDF
if($_REQUEST['modname']==$program || (strpos($program, $_REQUEST['modname'])=== 0 && strpos($_SERVER['QUERY_STRING'], $program)=== 8))
if($_REQUEST['modname']==$program || (mb_strpos($program, $_REQUEST['modname'])=== 0 && mb_strpos($_SERVER['QUERY_STRING'], $program)=== 8))
{
$allowed = true;
break;
......@@ -74,7 +73,7 @@ if($_REQUEST['modname'])
}
//modif Francois: security fix, cf http://www.securiteam.com/securitynews/6S02U1P6BI.html
//allow PHP scripts in misc/ one by one in place of the whole folder
//if(substr($_REQUEST['modname'],0,5)=='misc/')
//if(mb_substr($_REQUEST['modname'],0,5)=='misc/')
if (!$allowed && in_array($_REQUEST['modname'], array('misc/ChooseRequest.php', 'misc/ChooseCourse.php', 'misc/Portal.php', 'misc/ViewContact.php')))
$allowed = true;
......
......@@ -14,7 +14,7 @@ function PortalPollsVote($poll_id, $votes_array)
$user_id = $_POST['user_id'];
$excluded_user = '|'.$profile_id.':'.$user_id;
if (strpos($poll_RET[1]['EXCLUDED_USERS'], $excluded_user) !== false)//!!
if (mb_strpos($poll_RET[1]['EXCLUDED_USERS'], $excluded_user) !== false)//!!
return ErrorMessage(array('User excluded from this poll'));//should never be displayed, so do not translate
$excluded_users = $poll_RET[1]['EXCLUDED_USERS'].$excluded_user;
......@@ -79,7 +79,7 @@ function PortalPollsDisplay($value,$name)
$user_id = User('STUDENT_ID');
$excluded_user = '|'.$profile_id.':'.$user_id;
if (strpos($poll_RET[1]['EXCLUDED_USERS'], $excluded_user) !== false)
if (mb_strpos($poll_RET[1]['EXCLUDED_USERS'], $excluded_user) !== false)
return PortalPollsVotesDisplay($poll_id, $poll_RET[1]['DISPLAY_VOTES'], $poll_questions_RET, $poll_RET[1]['VOTES_NUMBER']); //user already voted, display votes
$PollForm = '';
......@@ -182,7 +182,7 @@ if (isset($_POST['votes']) && is_array($_POST['votes']))
foreach ($functions as $function)
{
//filter PHP files
if ( strrchr($function, '.') == '.php' )
if ( mb_strrchr($function, '.') == '.php' )
require_once('functions/'.$function);
}
......
......@@ -224,7 +224,7 @@ function _makeMultipleInput($column,$name,$request)
if($i%2==0)
$table .= '</TR><TR>';
//modif Francois: add <label> on checkbox
$table .= '<TD><label><INPUT type="checkbox" name="'.$request.'['.$column.'][]" value="'.str_replace(array("'",'"'),array('&#39;','&quot;'),$option).'"'.(strpos($value[$column],'||'.$option.'||')!==false?' checked':'').'> '.str_replace(array("'",'"'),array('&#39;','&quot;'),$option).'</label></TD>';
$table .= '<TD><label><INPUT type="checkbox" name="'.$request.'['.$column.'][]" value="'.str_replace(array("'",'"'),array('&#39;','&quot;'),$option).'"'.(mb_strpos($value[$column],'||'.$option.'||')!==false?' checked':'').'> '.str_replace(array("'",'"'),array('&#39;','&quot;'),$option).'</label></TD>';
$i++;
}
$table .= '</TR><TR><TD colspan="2">';
......@@ -237,14 +237,14 @@ function _makeMultipleInput($column,$name,$request)
{
echo str_replace('"', '\"', $table);
echo '","div'.$request.'['.$column.']",true);\' >';
echo '<span class="underline-dots">'.($value[$column]!=''?str_replace('||',', ',substr($value[$column],2,-2)):'-').'</span>';
echo '<span class="underline-dots">'.($value[$column]!=''?str_replace('||',', ',mb_substr($value[$column],2,-2)):'-').'</span>';
echo '</div></DIV>';
}
else
echo $table;
}
else
echo ($value[$column]!=''?str_replace('||',', ',substr($value[$column],2,-2)):'-').'<BR />';
echo ($value[$column]!=''?str_replace('||',', ',mb_substr($value[$column],2,-2)):'-').'<BR />';
echo '<span class="legend-gray">'.$name.'</span>';
}
......
......@@ -30,7 +30,7 @@ function _makePercentGrade($grade_id,$course_period_id=0,$staff_id=0)
{
$prev = $crnt;
$crnt = ($does_breakoff=='Y' ? $programconfig[$staff_id][$course_period_id.'-'.$grade['ID']] : $grade['BREAK_OFF']);
if(is_numeric($grade_id) ? $grade_id==$grade['ID'] : strtoupper($grade_id)==strtoupper($grade['TITLE']))
if(is_numeric($grade_id) ? $grade_id==$grade['ID'] : mb_strtoupper($grade_id)==mb_strtoupper($grade['TITLE']))
return ($crnt + ($crnt>$prev ? 100 : $prev)) / 2;
}
return 0;
......
......@@ -23,8 +23,8 @@ function _makeCalendar($value,$column)
function _makeTeachers($value,$column)
{
foreach(explode('","',substr($value,2,-2)) as $row)
foreach(explode('","',mb_substr($value,2,-2)) as $row)
$return .= $row.'<BR />';
return substr($return,0,-4);
return mb_substr($return,0,-4);
}
?>
......@@ -51,7 +51,7 @@ if(!$_SESSION['staff_id'] && User('PROFILE')=='parent')
if(!$_SESSION['UserSchool'])
{
if((User('PROFILE')=='admin' || User('PROFILE')=='teacher') && (!User('SCHOOLS') || strpos(User('SCHOOLS'),','.User('CURRENT_SCHOOL_ID').',')!==false))
if((User('PROFILE')=='admin' || User('PROFILE')=='teacher') && (!User('SCHOOLS') || mb_strpos(User('SCHOOLS'),','.User('CURRENT_SCHOOL_ID').',')!==false))
$_SESSION['UserSchool'] = User('CURRENT_SCHOOL_ID');
elseif(User('PROFILE')=='student')
$_SESSION['UserSchool'] = trim(User('SCHOOLS'),',');
......@@ -86,7 +86,7 @@ unset($_REQUEST['modfunc']);
//modif Francois: fix bug Internet Explorer Quirks Mode, add DOCTYPE
?>
<!DOCTYPE html>
<HTML lang="<?php echo substr($locale,0,2); ?>" <?php echo (substr($locale,0,2)=='he' || substr($locale,0,2)=='ar'?' dir="RTL"':''); ?>>
<HTML lang="<?php echo mb_substr($locale,0,2); ?>" <?php echo (mb_substr($locale,0,2)=='he' || mb_substr($locale,0,2)=='ar'?' dir="RTL"':''); ?>>
<head>
<meta charset="UTF-8" />
<link rel="stylesheet" type="text/css" href="assets/themes/<?php echo Preferences('THEME'); ?>/stylesheet.css" />
......@@ -108,7 +108,7 @@ echo '<TD class="width-100p valign-top">
&nbsp;".mb_convert_case(iconv('','UTF-8',strftime('%A %B %d, %Y')), MB_CASE_TITLE, "UTF-8")."<BR />";
if(User('PROFILE')=='admin' || User('PROFILE')=='teacher')
{
$schools = substr(str_replace(",","','",User('SCHOOLS')),2,-2);
$schools = mb_substr(str_replace(",","','",User('SCHOOLS')),2,-2);
$QI = DBQuery("SELECT ID,TITLE,SHORT_NAME FROM SCHOOLS WHERE SYEAR='".UserSyear()."'".($schools?" AND ID IN ($schools)":''));
$RET = DBGet($QI);
......@@ -236,11 +236,11 @@ if(User('PROFILE')=='teacher')
$days_convert = array('U'=>'7','M'=>'1','T'=>'2','W'=>'3','H'=>'4','F'=>'5','S'=>'6');
$period_days = '';
for ($i=0; $i<strlen($period['DAYS']); $i++)
for ($i=0; $i<mb_strlen($period['DAYS']); $i++)
{
$period_days .= mb_substr($days_convert[$period['DAYS'][$i]],0,3,'UTF-8').'.';
$period_days .= mb_substr($days_convert[$period['DAYS'][$i]],0,3).'.';
}
echo '<OPTION value="'.$period['COURSE_PERIOD_ID'].'.'.$period['COURSE_PERIOD_SCHOOL_PERIODS_ID'].'"'.$selected.'>'.$period['TITLE'].(strlen($period['DAYS'])<5?(strlen($period['DAYS'])<2?' '._('Day').' '.$period_days.' - ':' '._('Days').' '.$period_days.' - '):' - ').($period['MARKING_PERIOD_ID']!=$fy_RET[1]['MARKING_PERIOD_ID']?GetMP($period['MARKING_PERIOD_ID'],'SHORT_NAME').' - ':'').$period['CP_SHORT_NAME'].'</OPTION>';
echo '<OPTION value="'.$period['COURSE_PERIOD_ID'].'.'.$period['COURSE_PERIOD_SCHOOL_PERIODS_ID'].'"'.$selected.'>'.$period['TITLE'].(mb_strlen($period['DAYS'])<5?(mb_strlen($period['DAYS'])<2?' '._('Day').' '.$period_days.' - ':' '._('Days').' '.$period_days.' - '):' - ').($period['MARKING_PERIOD_ID']!=$fy_RET[1]['MARKING_PERIOD_ID']?GetMP($period['MARKING_PERIOD_ID'],'SHORT_NAME').' - ':'').$period['CP_SHORT_NAME'].'</OPTION>';
}
if(!$found)
{
......@@ -285,7 +285,7 @@ foreach($_ROSARIO['Menu'] as $modcat=>$programs)
foreach($keys as $key_index=>$file)
{
$title = $_ROSARIO['Menu'][$modcat][$file];
if(stripos($file,'http://') !== false)
if(mb_stripos($file,'http://') !== false)
echo '<TR><TD><A HREF="'.$file.'" target="_blank">'.$title.'</A></TD></TR>';
elseif(!is_numeric($file))
echo '<TR><TD><A HREF="Modules.php?modname='.$file.'" target="body" onclick="javascript:parent.help.location=\'Bottom.php?modname='.$file.'\'; selectedMenuLink(this);">'.$title.'</A></TD></TR>';
......
......@@ -28,7 +28,7 @@ if(!defined('WAREHOUSE_PHP'))
foreach ($functions as $function)
{
//filter PHP files
if ( strrchr($function, '.') == '.php' )
if ( mb_strrchr($function, '.') == '.php' )
require_once('functions/'.$function);
}
......@@ -39,7 +39,7 @@ if(!defined('WAREHOUSE_PHP'))
if ($_SERVER['SCRIPT_NAME']!='/index.php')
session_set_cookie_params(0,dirname($_SERVER['SCRIPT_NAME']).'/'); //,'',$false,$true);
session_start();
if(!$_SESSION['STAFF_ID'] && !$_SESSION['STUDENT_ID'] && strpos($_SERVER['PHP_SELF'],'index.php')===false)
if(!$_SESSION['STAFF_ID'] && !$_SESSION['STUDENT_ID'] && mb_strpos($_SERVER['PHP_SELF'],'index.php')===false)
{
header('Location: index.php');
exit;
......@@ -68,7 +68,7 @@ if(!defined('WAREHOUSE_PHP'))
//modif Francois: fix bug Internet Explorer Quirks Mode, add DOCTYPE
?>
<!DOCTYPE html>
<HTML lang="<?php echo substr($locale,0,2); ?>" <?php echo (substr($locale,0,2)=='he' || substr($locale,0,2)=='ar'?' dir="RTL"':''); ?>>
<HTML lang="<?php echo mb_substr($locale,0,2); ?>" <?php echo (mb_substr($locale,0,2)=='he' || mb_substr($locale,0,2)=='ar'?' dir="RTL"':''); ?>>
<HEAD><TITLE><?php echo Config('TITLE'); ?></TITLE>
<meta charset="UTF-8" />
<?php if(basename($_SERVER['PHP_SELF'])!='index.php'): ?>
......@@ -91,7 +91,7 @@ if(!defined('WAREHOUSE_PHP'))
if (isset($_ROSARIO['PrepareDate'])): ?>
<link rel="stylesheet" type="text/css" media="all" href="assets/js/jscalendar/calendar-blue.css" />
<script type="text/javascript" src="assets/js/jscalendar/calendar.js"></script>
<script type="text/javascript" src="assets/js/jscalendar/lang/calendar-<?php echo substr($locale, 0, 2); ?>.js"></script>
<script type="text/javascript" src="assets/js/jscalendar/lang/calendar-<?php echo mb_substr($locale, 0, 2); ?>.js"></script>
<script type="text/javascript" src="assets/js/jscalendar/calendar-setup.js"></script>
<?php
for($i=1;$i<=$_ROSARIO['PrepareDate'];$i++)
......
......@@ -644,7 +644,7 @@ class Wkhtmltopdf
$content = $this->_exec(str_replace('%input%', $input, $this->_getCommand()));
if (strpos(mb_strtolower($content['stderr']), 'error'))
if (mb_strpos(mb_strtolower($content['stderr']), 'error'))
throw new Exception("System error <pre>" . $content['stderr'] . "</pre>");
if (mb_strlen($content['stdout'], 'utf-8') === 0)
......@@ -678,7 +678,7 @@ class Wkhtmltopdf
header("Content-Type: application/pdf", false);
header('Content-Disposition: attachment; filename="' . basename($filename) .'";');
header("Content-Transfer-Encoding: binary");
header("Content-Length: " . strlen($result));
header("Content-Length: " . mb_strlen($result));
echo $result;
$filepath = $this->getFilePath();
if (!empty($filepath))
......@@ -699,7 +699,7 @@ class Wkhtmltopdf
header("Pragme: public");
header("Expires: Sat, 26 Jul 1997 05:00:00 GMT");
header("Last-Modified: " . gmdate('D, d m Y H:i:s') . " GMT");
header("Content-Length: " . strlen($result));
header("Content-Length: " . mb_strlen($result));
header('Content-Disposition: inline; filename="' . basename($filename) .'";');
echo $result;
$filepath = $this->getFilePath();
......
......@@ -232,7 +232,7 @@ function db_case($array)
$string=" decode( ";
foreach($array as $value)
$string.="$value,";
$string[strlen($string)-1]=")";
$string[mb_strlen($string)-1]=")";
$string.=" ";
break;
case 'postgres':
......@@ -245,10 +245,10 @@ function db_case($array)
{
$value = $array[$i];
if($value=="''" && substr($string,-1)=='=')
if($value=="''" && mb_substr($string,-1)=='=')
{
$value = ' IS NULL';
$string = substr($string,0,-1);
$string = mb_substr($string,0,-1);
}
$string.="$value";
......@@ -268,17 +268,17 @@ function db_case($array)
}
// String position.
function db_strpos($args)
function db_mb_strpos($args)
{ global $DatabaseType;
if($DatabaseType=='postgres')
$ret = 'strpos(';
$ret = 'mb_strpos(';
else
$ret = 'instr(';
foreach($args as $value)
$ret .= $value . ',';
$ret = substr($ret,0,-1) . ')';
$ret = mb_substr($ret,0,-1) . ')';
return $ret;
}
......@@ -322,8 +322,8 @@ function db_properties($table)
case 'oracle':
$sql="SELECT COLUMN_NAME, DATA_TYPE, DATA_LENGTH, DATA_PRECISION,
DATA_SCALE, NULLABLE, DATA_DEFAULT
FROM ALL_TAB_COLUMNS WHERE TABLE_NAME='".strtoupper($table)."'
AND OWNER='".strtoupper($DatabaseUsername)."' ORDER BY COLUMN_ID";
FROM ALL_TAB_COLUMNS WHERE TABLE_NAME='".mb_strtoupper($table)."'
AND OWNER='".mb_strtoupper($DatabaseUsername)."' ORDER BY COLUMN_ID";
$result = DBQuery($sql);
while($row=db_fetch_row($result))
{
......@@ -352,47 +352,47 @@ function db_properties($table)
a.attlen AS length,a.atttypmod AS lengthvar,
a.attnotnull AS notnull
FROM pg_class c, pg_attribute a, pg_type t
WHERE c.relname = '".strtolower($table)."'
WHERE c.relname = '".mb_strtolower($table)."'
and a.attnum > 0 and a.attrelid = c.oid
and a.atttypid = t.oid ORDER BY a.attnum";
$result = DBQuery($sql);
while($row = db_fetch_row($result))
{
$properties[strtoupper($row['FIELD'])]['TYPE'] = strtoupper($row['TYPE']);
if(strtoupper($row['TYPE'])=="NUMERIC")
$properties[mb_strtoupper($row['FIELD'])]['TYPE'] = mb_strtoupper($row['TYPE']);
if(mb_strtoupper($row['TYPE'])=="NUMERIC")
{
$properties[strtoupper($row['FIELD'])]['SIZE'] = ($row['LENGTHVAR'] >> 16) & 0xffff;
$properties[strtoupper($row['FIELD'])]['SCALE'] = ($row['LENGTHVAR'] -4) & 0xffff;
$properties[mb_strtoupper($row['FIELD'])]['SIZE'] = ($row['LENGTHVAR'] >> 16) & 0xffff;
$properties[mb_strtoupper($row['FIELD'])]['SCALE'] = ($row['LENGTHVAR'] -4) & 0xffff;
}
else
{
if($row['LENGTH']>0)
$properties[strtoupper($row['FIELD'])]['SIZE'] = $row['LENGTH'];
$properties[mb_strtoupper($row['FIELD'])]['SIZE'] = $row['LENGTH'];
elseif($row['LENGTHVAR']>0)
$properties[strtoupper($row['FIELD'])]['SIZE'] = $row['LENGTHVAR']-4;
$properties[mb_strtoupper($row['FIELD'])]['SIZE'] = $row['LENGTHVAR']-4;
}
if ($row['NOTNULL']=='t')
$properties[strtoupper($row['FIELD'])]['NULL'] = "N";
$properties[mb_strtoupper($row['FIELD'])]['NULL'] = "N";
else
$properties[strtoupper($row['FIELD'])]['NULL'] = "Y";
$properties[mb_strtoupper($row['FIELD'])]['NULL'] = "Y";
}
break;
case 'mysql':
$result = DBQuery("SHOW COLUMNS FROM $table");
while($row = db_fetch_row($result))
{
$properties[strtoupper($row['FIELD'])]['TYPE'] = strtoupper($row['TYPE'],strpos($row['TYPE'],'('));
if(!$pos = strpos($row['TYPE'],','))
$pos = strpos($row['TYPE'],')');
$properties[mb_strtoupper($row['FIELD'])]['TYPE'] = mb_strtoupper($row['TYPE'],mb_strpos($row['TYPE'],'('));
if(!$pos = mb_strpos($row['TYPE'],','))
$pos = mb_strpos($row['TYPE'],')');
else
$properties[strtoupper($row['FIELD'])]['SCALE'] = substr($row['TYPE'],$pos+1);
$properties[mb_strtoupper($row['FIELD'])]['SCALE'] = mb_substr($row['TYPE'],$pos+1);
$properties[strtoupper($row['FIELD'])]['SIZE'] = substr($row['TYPE'],strpos($row['TYPE'],'(')+1,$pos);
$properties[mb_strtoupper($row['FIELD'])]['SIZE'] = mb_substr($row['TYPE'],mb_strpos($row['TYPE'],'(')+1,$pos);
if($row['NULL']!='')
$properties[strtoupper($row['FIELD'])]['NULL'] = "Y";
$properties[mb_strtoupper($row['FIELD'])]['NULL'] = "Y";
else
$properties[strtoupper($row['FIELD'])]['NULL'] = "N";
$properties[mb_strtoupper($row['FIELD'])]['NULL'] = "N";
}
break;
}
......@@ -450,6 +450,7 @@ function db_show_error($sql,$failnote,$additional='')
function DBEscapeString($input)
{
//return pg_escape_string($input);
return str_replace("'","''",$input);
}
?>
\ No newline at end of file
......@@ -37,9 +37,9 @@ else
if($result===false)
$errstring = pg_last_error($connection);
if(strpos($errstring,'config: permission denied')!==false)
if(mb_strpos($errstring,'config: permission denied')!==false)
$error[] = 'The database was created with the wrong permissions. The user specified in the config.inc.php file does not have permission to access the rosario database. Use the super-user (postgres) or recreate the database adding \connect - YOUR_USERNAME to the top of the rosario.sql file.';
elseif(strpos($errstring,'elation "config" does not exist')!==false)
elseif(mb_strpos($errstring,'elation "config" does not exist')!==false)
$error[] = 'At least one of the tables does not exist. Make sure you ran the rosario.sql file as described in the INSTALL file.';
elseif($errstring)
$error[] = $errstring;
......
......@@ -5,12 +5,12 @@
//'Subject area|Course Title'
//This function simply returns the course title
function CourseTitle ($courseTitle, $title='') {
return (strrchr($courseTitle, '|') ? substr(strrchr($courseTitle, '|'),1) : $courseTitle);
return (mb_strrchr($courseTitle, '|') ? mb_substr(mb_strrchr($courseTitle, '|'),1) : $courseTitle);
}
//This function simply returns the subject area
function CourseTitleArea ($courseTitle, $title='') {
return (strstr($courseTitle, '|', true) ? strstr($courseTitle, '|', true) : '');
return (mb_strstr($courseTitle, '|', true) ? mb_strstr($courseTitle, '|', true) : '');
}
?>
\ No newline at end of file
......@@ -52,11 +52,11 @@ function CustomFields($location,$type='student',$extra=array())
{
if($value!='')
{
switch($fields[substr($field_name,7)][1]['TYPE'])
switch($fields[mb_substr($field_name,7)][1]['TYPE'])
{
case 'radio':
if(!$extra['NoSearchTerms'])
$_ROSARIO['SearchTerms'] .= '<span style="color:gray"><b>'.$fields[substr($field_name,7)][1]['TITLE'].': </b></span>';
$_ROSARIO['SearchTerms'] .= '<span style="color:gray"><b>'.$fields[mb_substr($field_name,7)][1]['TITLE'].': </b></span>';
if($value=='Y')
{
$string .= " AND s.$field_name='$value' ";
......@@ -75,7 +75,7 @@ function CustomFields($location,$type='student',$extra=array())
case 'codeds':
if(!$extra['NoSearchTerms'])
$_ROSARIO['SearchTerms'] .= '<span style="color:gray"><b>'.$fields[substr($field_name,7)][1]['TITLE'].': </b></span>';
$_ROSARIO['SearchTerms'] .= '<span style="color:gray"><b>'.$fields[mb_substr($field_name,7)][1]['TITLE'].': </b></span>';
if($value=='!')
{
$string .= " AND (s.$field_name='' OR s.$field_name IS NULL) ";
......@@ -87,7 +87,7 @@ function CustomFields($location,$type='student',$extra=array())
$string .= " AND s.$field_name='$value' ";
if(!$extra['NoSearchTerms'])
{
$select_options = str_replace("\n","\r",str_replace("\r\n","\r",$fields[substr($field_name,7)][1]['SELECT_OPTIONS']));
$select_options = str_replace("\n","\r",str_replace("\r\n","\r",$fields[mb_substr($field_name,7)][1]['SELECT_OPTIONS']));
$select_options = explode("\r",$select_options);
foreach($select_options as $option)
{
......@@ -107,7 +107,7 @@ function CustomFields($location,$type='student',$extra=array())
case 'exports':
if(!$extra['NoSearchTerms'])
$_ROSARIO['SearchTerms'] .= '<span style="color:gray"><b>'.$fields[substr($field_name,7)][1]['TITLE'].': </b></span>';
$_ROSARIO['SearchTerms'] .= '<span style="color:gray"><b>'.$fields[mb_substr($field_name,7)][1]['TITLE'].': </b></span>';
if($value=='!')
{
$string .= " AND (s.$field_name='' OR s.$field_name IS NULL) ";
......@@ -119,7 +119,7 @@ function CustomFields($location,$type='student',$extra=array())
$string .= " AND s.$field_name='$value' ";
if(!$extra['NoSearchTerms'])
{
$select_options = str_replace("\n","\r",str_replace("\r\n","\r",$fields[substr($field_name,7)][1]['SELECT_OPTIONS']));
$select_options = str_replace("\n","\r",str_replace("\r\n","\r",$fields[mb_substr($field_name,7)][1]['SELECT_OPTIONS']));
$select_options = explode("\r",$select_options);
foreach($select_options as $option)
{
......@@ -139,7 +139,7 @@ function CustomFields($location,$type='student',$extra=array())
case 'select':
if(!$extra['NoSearchTerms'])
$_ROSARIO['SearchTerms'] .= '<span style="color:gray"><b>'.$fields[substr($field_name,7)][1]['TITLE'].': </b></span>';
$_ROSARIO['SearchTerms'] .= '<span style="color:gray"><b>'.$fields[mb_substr($field_name,7)][1]['TITLE'].': </b></span>';
if($value=='!')
{
$string .= " AND (s.$field_name='' OR s.$field_name IS NULL) ";
......@@ -158,7 +158,7 @@ function CustomFields($location,$type='student',$extra=array())
case 'autos':
if(!$extra['NoSearchTerms'])
$_ROSARIO['SearchTerms'] .= '<span style="color:gray"><b>'.$fields[substr($field_name,7)][1]['TITLE'].': </b></span>';
$_ROSARIO['SearchTerms'] .= '<span style="color:gray"><b>'.$fields[mb_substr($field_name,7)][1]['TITLE'].': </b></span>';
if($value=='!')
{
$string .= " AND (s.$field_name='' OR s.$field_name IS NULL) ";
......@@ -177,7 +177,7 @@ function CustomFields($location,$type='student',$extra=array())
case 'edits':
if(!$extra['NoSearchTerms'])
$_ROSARIO['SearchTerms'] .= '<span style="color:gray"><b>'.$fields[substr($field_name,7)][1]['TITLE'].': </b></span>';
$_ROSARIO['SearchTerms'] .= '<span style="color:gray"><b>'.$fields[mb_substr($field_name,7)][1]['TITLE'].': </b></span>';
if($value=='!')
{
$string .= " AND (s.$field_name='' OR s.$field_name IS NULL) ";
......@@ -186,7 +186,7 @@ function CustomFields($location,$type='student',$extra=array())