mirror of
https://github.com/e107inc/e107.git
synced 2025-08-03 21:27:25 +02:00
ctype_*() replacement
This commit is contained in:
27
class2.php
27
class2.php
@@ -9,9 +9,9 @@
|
|||||||
* General purpose file
|
* General purpose file
|
||||||
*
|
*
|
||||||
* $Source: /cvs_backup/e107_0.8/class2.php,v $
|
* $Source: /cvs_backup/e107_0.8/class2.php,v $
|
||||||
* $Revision: 1.121 $
|
* $Revision: 1.122 $
|
||||||
* $Date: 2009-08-06 22:39:36 $
|
* $Date: 2009-08-08 23:09:08 $
|
||||||
* $Author: secretr $
|
* $Author: marj_nl_fr $
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
//
|
//
|
||||||
@@ -1316,24 +1316,25 @@ function check_class($var, $userclass = USERCLASS_LIST, $uid = 0)
|
|||||||
|
|
||||||
if ($userclass == '')
|
if ($userclass == '')
|
||||||
{
|
{
|
||||||
return false;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
$class_array = explode(',', $userclass);
|
$class_array = explode(',', $userclass);
|
||||||
|
|
||||||
$varList = explode(',', trim($var));
|
$varList = explode(',', $var);
|
||||||
$latchedAccess = FALSE;
|
$latchedAccess = FALSE;
|
||||||
|
|
||||||
foreach($varList as $v)
|
foreach($varList as $v)
|
||||||
{
|
{
|
||||||
|
$v = trim($v);
|
||||||
$invert = FALSE;
|
$invert = FALSE;
|
||||||
if(!is_numeric($v)) //value to test is a userclass name (or garbage, of course), go get the id
|
//value to test is a userclass name (or garbage, of course), go get the id
|
||||||
|
if( ! is_numeric($v))
|
||||||
{
|
{
|
||||||
$v = trim($v);
|
if (substr($v, 0, 1) == '-')
|
||||||
if (substr($v,0,1) == '-')
|
|
||||||
{
|
{
|
||||||
$invert = TRUE;
|
$invert = TRUE;
|
||||||
$v = substr($v,1);
|
$v = substr($v, 1);
|
||||||
}
|
}
|
||||||
$v = $e107->user_class->ucGetClassIDFromName($v);
|
$v = $e107->user_class->ucGetClassIDFromName($v);
|
||||||
}
|
}
|
||||||
@@ -1343,8 +1344,9 @@ function check_class($var, $userclass = USERCLASS_LIST, $uid = 0)
|
|||||||
$v = -$v;
|
$v = -$v;
|
||||||
}
|
}
|
||||||
if ($v !== FALSE)
|
if ($v !== FALSE)
|
||||||
{ // Ignore non-valid userclass names
|
{
|
||||||
if ((in_array($v, $class_array) || (ctype_digit($v) && ($v == 0))))
|
// Ignore non-valid userclass names
|
||||||
|
if (in_array($v, $class_array) || ($v === '0') || ($v === 0))
|
||||||
{
|
{
|
||||||
if ($invert)
|
if ($invert)
|
||||||
{
|
{
|
||||||
@@ -1354,7 +1356,8 @@ function check_class($var, $userclass = USERCLASS_LIST, $uid = 0)
|
|||||||
}
|
}
|
||||||
elseif ($invert && count($varList) == 1)
|
elseif ($invert && count($varList) == 1)
|
||||||
{
|
{
|
||||||
$latchedAccess = TRUE; // Handle scenario where only an 'exclude' class is passed
|
// Handle scenario where only an 'exclude' class is passed
|
||||||
|
$latchedAccess = TRUE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -11,9 +11,9 @@
|
|||||||
| GNU General Public License (http://gnu.org).
|
| GNU General Public License (http://gnu.org).
|
||||||
|
|
|
|
||||||
| $Source: /cvs_backup/e107_0.8/e107_handlers/plugin_class.php,v $
|
| $Source: /cvs_backup/e107_0.8/e107_handlers/plugin_class.php,v $
|
||||||
| $Revision: 1.72 $
|
| $Revision: 1.73 $
|
||||||
| $Date: 2009-08-06 22:29:34 $
|
| $Date: 2009-08-08 23:09:08 $
|
||||||
| $Author: e107coders $
|
| $Author: marj_nl_fr $
|
||||||
+----------------------------------------------------------------------------+
|
+----------------------------------------------------------------------------+
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@@ -442,11 +442,11 @@ class e107plugin
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
function manage_link($action, $link_url, $link_name, $link_class=0)
|
function manage_link($action, $link_url, $link_name, $link_class = 0)
|
||||||
{
|
{
|
||||||
global $sql, $tp;
|
global $sql, $tp;
|
||||||
|
|
||||||
if(!ctype_digit($link_class))
|
if( ! is_numeric($link_class))
|
||||||
{
|
{
|
||||||
$link_class = strtolower($link_class);
|
$link_class = strtolower($link_class);
|
||||||
$plug_perm['everyone'] = e_UC_PUBLIC;
|
$plug_perm['everyone'] = e_UC_PUBLIC;
|
||||||
|
@@ -9,9 +9,9 @@
|
|||||||
* Handler - user-related functions
|
* Handler - user-related functions
|
||||||
*
|
*
|
||||||
* $Source: /cvs_backup/e107_0.8/e107_handlers/user_handler.php,v $
|
* $Source: /cvs_backup/e107_0.8/e107_handlers/user_handler.php,v $
|
||||||
* $Revision: 1.10 $
|
* $Revision: 1.11 $
|
||||||
* $Date: 2009-06-12 20:41:34 $
|
* $Date: 2009-08-08 23:09:08 $
|
||||||
* $Author: e107steved $
|
* $Author: marj_nl_fr $
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@@ -277,50 +277,83 @@ class UserHandler
|
|||||||
// * - an alphanumeric character
|
// * - an alphanumeric character
|
||||||
// ^ - next character from seed
|
// ^ - next character from seed
|
||||||
// alphanumerics are included 'as is'
|
// alphanumerics are included 'as is'
|
||||||
function generateRandomString($pattern, $seed='')
|
function generateRandomString($pattern, $seed = '')
|
||||||
{
|
{
|
||||||
if (strlen($pattern) < 6) $pattern = '##....';
|
if (strlen($pattern) < 6)
|
||||||
$newname = '';
|
$pattern = '##....';
|
||||||
$seed_ptr = 0; // Next character of seed (if used)
|
|
||||||
for ($i = 0; $i < strlen($pattern); $i++)
|
$newname = '';
|
||||||
{
|
|
||||||
$c = $pattern[$i];
|
// Create alpha [A-Z][a-z]
|
||||||
switch ($c)
|
$alpha = '';
|
||||||
|
for($i = 65; $i < 91; $i++)
|
||||||
{
|
{
|
||||||
case '#' : // Alpha only (upper and lower case)
|
$alpha .= chr($i).chr($i+32);
|
||||||
do
|
|
||||||
{
|
|
||||||
$t = chr(rand(65,122));
|
|
||||||
} while (!ctype_alpha($t));
|
|
||||||
$newname .= $t;
|
|
||||||
break;
|
|
||||||
case '.' : // Numeric only
|
|
||||||
do
|
|
||||||
{
|
|
||||||
$t = chr(rand(48,57));
|
|
||||||
} while (!ctype_digit($t));
|
|
||||||
$newname .= $t;
|
|
||||||
break;
|
|
||||||
case '*' : // Alphanumeric
|
|
||||||
do
|
|
||||||
{
|
|
||||||
$t = chr(rand(48,122));
|
|
||||||
} while (!ctype_alnum($t));
|
|
||||||
$newname .= $t;
|
|
||||||
break;
|
|
||||||
case '^' : // Next character from seed
|
|
||||||
if ($seed_ptr < strlen($seed))
|
|
||||||
{
|
|
||||||
$newname .= $seed[$seed_ptr];
|
|
||||||
$seed_ptr++;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
default :
|
|
||||||
if (ctype_alnum($c)) $newname .= $c;
|
|
||||||
// (else just ignore other characters in pattern)
|
|
||||||
}
|
}
|
||||||
}
|
$alphaLength = strlen($alpha) - 1;
|
||||||
return $newname;
|
|
||||||
|
// Create digit [0-9]
|
||||||
|
$digit = '';
|
||||||
|
for($i = 48; $i < 57; $i++)
|
||||||
|
{
|
||||||
|
$digit .= chr($i);
|
||||||
|
}
|
||||||
|
$digitLength = strlen($digit) - 1;
|
||||||
|
|
||||||
|
// Create alpha numeric [A-Z][a-z]
|
||||||
|
$alphaNum = $alpha.$digit;
|
||||||
|
$alphaNumLength = strlen($alphaNum) - 1;
|
||||||
|
|
||||||
|
// Next character of seed (if used)
|
||||||
|
$seed_ptr = 0;
|
||||||
|
for ($i = 0, $patternLength = strlen($pattern); $i < $patternLength; $i++)
|
||||||
|
{
|
||||||
|
$c = $pattern[$i];
|
||||||
|
switch ($c)
|
||||||
|
{
|
||||||
|
// Alpha only (upper and lower case)
|
||||||
|
case '#' :
|
||||||
|
$t = rand(0, $alphaLength);
|
||||||
|
$newname .= $alpha[$t];
|
||||||
|
break;
|
||||||
|
|
||||||
|
// Numeric only - [0-9]
|
||||||
|
case '.' :
|
||||||
|
$t = rand(0, $digitLength);
|
||||||
|
$newname .= $digit[$t];
|
||||||
|
break;
|
||||||
|
|
||||||
|
// Alphanumeric
|
||||||
|
case '*' :
|
||||||
|
$t = rand(0, $alphaNumLength);
|
||||||
|
$newname .= $alphaNum[$t];
|
||||||
|
break;
|
||||||
|
|
||||||
|
// Next character from seed
|
||||||
|
case '^' :
|
||||||
|
if ($seed_ptr < strlen($seed))
|
||||||
|
{
|
||||||
|
$newname .= $seed[$seed_ptr];
|
||||||
|
$seed_ptr++;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
// (else just ignore other characters in pattern)
|
||||||
|
default :
|
||||||
|
if (strrpos($alphaNum, $c) !== FALSE)
|
||||||
|
{
|
||||||
|
$newname .= $c;
|
||||||
|
}
|
||||||
|
/*
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$t = rand(0, $alphaNumLength);
|
||||||
|
$newname .= $alphaNum[$t];
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return $newname;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@@ -9,9 +9,9 @@
|
|||||||
* Handler - general purpose validation functions
|
* Handler - general purpose validation functions
|
||||||
*
|
*
|
||||||
* $Source: /cvs_backup/e107_0.8/e107_handlers/validator_class.php,v $
|
* $Source: /cvs_backup/e107_0.8/e107_handlers/validator_class.php,v $
|
||||||
* $Revision: 1.8 $
|
* $Revision: 1.9 $
|
||||||
* $Date: 2009-07-31 16:14:51 $
|
* $Date: 2009-08-08 23:09:08 $
|
||||||
* $Author: secretr $
|
* $Author: marj_nl_fr $
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@@ -175,15 +175,19 @@ class validatorClass
|
|||||||
{
|
{
|
||||||
switch ($defs['dataType'])
|
switch ($defs['dataType'])
|
||||||
{
|
{
|
||||||
case 1 : // Assumes we're passed an array variable to be turned into a comma-separated list of integers
|
case 1 : // Assumes we've passed an array variable to be turned into a comma-separated list of integers
|
||||||
if (is_array($value))
|
if (is_array($value))
|
||||||
{
|
{
|
||||||
$temp = array();
|
$temp = array();
|
||||||
foreach ($value as $v)
|
foreach ($value as $v)
|
||||||
{
|
{
|
||||||
if (ctype_digit(trim($v))) { $temp[] = intval($v); }
|
$v = trim($v);
|
||||||
|
if (is_numeric($v))
|
||||||
|
{
|
||||||
|
$temp[] = intval($v);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
$value = implode(',',array_unique($temp));
|
$value = implode(',', array_unique($temp));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@@ -11,9 +11,9 @@
|
|||||||
| GNU General Public License (http://gnu.org).
|
| GNU General Public License (http://gnu.org).
|
||||||
|
|
|
|
||||||
| $Source: /cvs_backup/e107_0.8/e107_plugins/calendar_menu/ec_pf_page.php,v $
|
| $Source: /cvs_backup/e107_0.8/e107_plugins/calendar_menu/ec_pf_page.php,v $
|
||||||
| $Revision: 1.2 $
|
| $Revision: 1.3 $
|
||||||
| $Date: 2007-12-26 18:30:13 $
|
| $Date: 2009-08-08 23:09:08 $
|
||||||
| $Author: e107steved $
|
| $Author: marj_nl_fr $
|
||||||
|
|
|
|
||||||
| Generate a printer-friendly page of calendar events
|
| Generate a printer-friendly page of calendar events
|
||||||
| Query is: ec_pf_page.php?ssssss.eeeeee[[[.cat].template].output]
|
| Query is: ec_pf_page.php?ssssss.eeeeee[[[.cat].template].output]
|
||||||
@@ -333,59 +333,73 @@ switch ($ec_output_type)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function decode_date($date_string,$last_day = FALSE)
|
// We're assuming $date_string is a string of digits
|
||||||
|
// Which could begin with 'now' or 'now+'
|
||||||
|
function decode_date($date_string, $last_day = FALSE)
|
||||||
{ // Decode a date string
|
{ // Decode a date string
|
||||||
if (strpos($date_string,'now') === 0)
|
if (strpos($date_string, 'now') === 0)
|
||||||
{ // decode special dates
|
|
||||||
$today = getdate();
|
|
||||||
$date_string = trim(substr($date_string,3)); // Knock off the 'now'
|
|
||||||
if (($date_string != '') && ($date_string[0] == '+'))
|
|
||||||
{
|
{
|
||||||
$date_string = trim(substr($date_string,1)); // Knock off the '+'
|
// decode special dates
|
||||||
if (is_numeric($date_string) && ($date_string >= 0) && ($date_string <= 12))
|
$today = getdate();
|
||||||
{
|
// Knock off the 'now'
|
||||||
$today['mon'] += $date_string;
|
$date_string = trim(substr($date_string, 3));
|
||||||
if ($today['mon'] > 12)
|
if (($date_string != '') && ($date_string[0] == '+'))
|
||||||
{
|
{
|
||||||
$today['mon'] -= 12;
|
// Knock off the '+'
|
||||||
$today['year'] += 1;
|
$date_string = trim(substr($date_string, 1));
|
||||||
|
if (is_numeric($date_string) && ($date_string >= 0) && ($date_string <= 12))
|
||||||
|
{
|
||||||
|
$today['mon'] += $date_string;
|
||||||
|
if ($today['mon'] > 12)
|
||||||
|
{
|
||||||
|
$today['mon'] -= 12;
|
||||||
|
$today['year'] += 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return EC_LAN_149;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
$date_string = $today['year'].$today['mon'];
|
||||||
else
|
}
|
||||||
{
|
|
||||||
return EC_LAN_149;
|
// Here, $date_string is a string of 5, 6 or 8 digits
|
||||||
}
|
// use preg_match()
|
||||||
|
if(preg_match('/^\d{5,8}$/D', $date_string))
|
||||||
|
{
|
||||||
|
$month = 0;
|
||||||
|
$day = 1;
|
||||||
|
if (strlen($date_string) == 5)
|
||||||
|
$date_string = substr_replace($date_string, '0', -1, 0);
|
||||||
|
if (strlen($date_string) == 8)
|
||||||
|
{
|
||||||
|
$day = substr($date_string, -2, 2);
|
||||||
|
if ($last_day)
|
||||||
|
$day += 1;
|
||||||
|
}
|
||||||
|
elseif (strlen($date_string) == 6)
|
||||||
|
{
|
||||||
|
if ($last_day)
|
||||||
|
$month = 1;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// Error
|
||||||
|
return EC_LAN_149;
|
||||||
|
}
|
||||||
|
$month += substr($date_string, 4, 2);
|
||||||
|
$year = substr($date_string, 0, 4);
|
||||||
|
$temp = mktime(0, 0, 0, $month, $day, $year);
|
||||||
|
// Always do this to get whole of last day
|
||||||
|
if ($last_day)
|
||||||
|
$temp -= 1;
|
||||||
|
return $temp;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{ // Error
|
||||||
|
return EC_LAN_149;
|
||||||
}
|
}
|
||||||
$date_string = $today['year'].$today['mon'];
|
|
||||||
}
|
|
||||||
if (ctype_digit($date_string))
|
|
||||||
{
|
|
||||||
$month = 0;
|
|
||||||
$day = 1;
|
|
||||||
if (strlen($date_string) == 5) $date_string = substr_replace($date_string,'0',-1,0);
|
|
||||||
if (strlen($date_string) == 8)
|
|
||||||
{
|
|
||||||
$day = substr($date_string,-2,2);
|
|
||||||
if ($last_day) $day += 1;
|
|
||||||
}
|
|
||||||
elseif (strlen($date_string) == 6)
|
|
||||||
{
|
|
||||||
if ($last_day) $month = 1;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{ // Error
|
|
||||||
return EC_LAN_149;
|
|
||||||
}
|
|
||||||
$month += substr($date_string,4,2);
|
|
||||||
$year = substr($date_string,0,4);
|
|
||||||
$temp = mktime(0,0,0,$month,$day,$year);
|
|
||||||
if ($last_day) $temp -= 1; // Always do this to get whole of last day
|
|
||||||
return $temp;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{ // Error
|
|
||||||
return EC_LAN_149;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user