summaryrefslogtreecommitdiffstats
path: root/system/helpers
diff options
context:
space:
mode:
Diffstat (limited to 'system/helpers')
-rw-r--r--system/helpers/captcha_helper.php2
-rw-r--r--system/helpers/date_helper.php172
-rw-r--r--system/helpers/form_helper.php7
-rw-r--r--system/helpers/html_helper.php2
-rw-r--r--system/helpers/string_helper.php9
-rw-r--r--system/helpers/typography_helper.php5
-rwxr-xr-x[-rw-r--r--]system/helpers/url_helper.php2
7 files changed, 101 insertions, 98 deletions
diff --git a/system/helpers/captcha_helper.php b/system/helpers/captcha_helper.php
index 19ec0c778..2bbb9d3a5 100644
--- a/system/helpers/captcha_helper.php
+++ b/system/helpers/captcha_helper.php
@@ -243,4 +243,4 @@ if ( ! function_exists('create_captcha'))
// ------------------------------------------------------------------------
/* End of file captcha_helper.php */
-/* Location: ./system/heleprs/captcha_helper.php */ \ No newline at end of file
+/* Location: ./system/helpers/captcha_helper.php */ \ No newline at end of file
diff --git a/system/helpers/date_helper.php b/system/helpers/date_helper.php
index 6c559bb25..e14bc2f94 100644
--- a/system/helpers/date_helper.php
+++ b/system/helpers/date_helper.php
@@ -54,10 +54,8 @@ if ( ! function_exists('now'))
return $system_time;
}
- else
- {
- return time();
- }
+
+ return time();
}
}
@@ -85,12 +83,18 @@ if ( ! function_exists('mdate'))
function mdate($datestr = '', $time = '')
{
if ($datestr == '')
- return '';
+ {
+ return '';
+ }
- if ($time == '')
- $time = now();
+ $time = ($time == '') ? now() : $time;
+
+ $datestr = str_replace(
+ '%\\',
+ '',
+ preg_replace("/([a-z]+?){1}/i", "\\\\\\1", $datestr)
+ );
- $datestr = str_replace('%\\', '', preg_replace("/([a-z]+?){1}/i", "\\\\\\1", $datestr));
return date($datestr, $time);
}
}
@@ -162,14 +166,7 @@ if ( ! function_exists('timespan'))
$time = time();
}
- if ($time <= $seconds)
- {
- $seconds = 1;
- }
- else
- {
- $seconds = $time - $seconds;
- }
+ $seconds = ($time <= $seconds) ? 1 : $time - $seconds;
$str = '';
$years = floor($seconds / 31536000);
@@ -303,9 +300,18 @@ if ( ! function_exists('local_to_gmt'))
function local_to_gmt($time = '')
{
if ($time == '')
+ {
$time = time();
-
- return mktime( gmdate("H", $time), gmdate("i", $time), gmdate("s", $time), gmdate("m", $time), gmdate("d", $time), gmdate("Y", $time));
+ }
+
+ return mktime(
+ gmdate("H", $time),
+ gmdate("i", $time),
+ gmdate("s", $time),
+ gmdate("m", $time),
+ gmdate("d", $time),
+ gmdate("Y", $time)
+ );
}
}
@@ -366,14 +372,14 @@ if ( ! function_exists('mysql_to_unix'))
$time = str_replace(' ', '', $time);
// YYYYMMDDHHMMSS
- return mktime(
- substr($time, 8, 2),
- substr($time, 10, 2),
- substr($time, 12, 2),
- substr($time, 4, 2),
- substr($time, 6, 2),
- substr($time, 0, 4)
- );
+ return mktime(
+ substr($time, 8, 2),
+ substr($time, 10, 2),
+ substr($time, 12, 2),
+ substr($time, 4, 2),
+ substr($time, 6, 2),
+ substr($time, 0, 4)
+ );
}
}
@@ -475,13 +481,19 @@ if ( ! function_exists('human_to_unix'))
$ampm = strtolower($split['2']);
if (substr($ampm, 0, 1) == 'p' AND $hour < 12)
- $hour = $hour + 12;
+ {
+ $hour = $hour + 12;
+ }
if (substr($ampm, 0, 1) == 'a' AND $hour == 12)
+ {
$hour = '00';
-
+ }
+
if (strlen($hour) == 1)
- $hour = '0'.$hour;
+ {
+ $hour = '0'.$hour;
+ }
}
return mktime($hour, $min, $sec, $month, $day, $year);
@@ -501,16 +513,16 @@ if ( ! function_exists('human_to_unix'))
*/
if ( ! function_exists('nice_date'))
{
- function nice_date($bad_date='', $format=false)
+ function nice_date($bad_date = '', $format = FALSE)
{
if (empty($bad_date))
{
return 'Unknown';
}
+
// Date like: YYYYMM
- if (preg_match('/^\d{6}$/',$bad_date))
+ if (preg_match('/^\d{6}$/', $bad_date))
{
- //echo $bad_date." ";
if (in_array(substr($bad_date, 0, 2),array('19', '20')))
{
$year = substr($bad_date, 0, 4);
@@ -521,8 +533,8 @@ if ( ! function_exists('nice_date'))
$month = substr($bad_date, 0, 2);
$year = substr($bad_date, 2, 4);
}
+
return date($format, strtotime($year . '-' . $month . '-01'));
-
}
// Date Like: YYYYMMDD
@@ -531,6 +543,7 @@ if ( ! function_exists('nice_date'))
$month = substr($bad_date, 0, 2);
$day = substr($bad_date, 2, 2);
$year = substr($bad_date, 4, 4);
+
return date($format, strtotime($month . '/01/' . $year));
}
@@ -574,8 +587,7 @@ if ( ! function_exists('timezone_menu'))
$CI =& get_instance();
$CI->lang->load('date');
- if ($default == 'GMT')
- $default = 'UTC';
+ $default = ($default == 'GMT') ? 'UTC' : $default;
$menu = '<select name="'.$name.'"';
@@ -618,60 +630,58 @@ if ( ! function_exists('timezones'))
// some items appear to be in the wrong order
$zones = array(
- 'UM12' => -12,
- 'UM11' => -11,
- 'UM10' => -10,
- 'UM95' => -9.5,
- 'UM9' => -9,
- 'UM8' => -8,
- 'UM7' => -7,
- 'UM6' => -6,
- 'UM5' => -5,
- 'UM45' => -4.5,
- 'UM4' => -4,
- 'UM35' => -3.5,
- 'UM3' => -3,
- 'UM2' => -2,
- 'UM1' => -1,
- 'UTC' => 0,
- 'UP1' => +1,
- 'UP2' => +2,
- 'UP3' => +3,
- 'UP35' => +3.5,
- 'UP4' => +4,
- 'UP45' => +4.5,
- 'UP5' => +5,
- 'UP55' => +5.5,
- 'UP575' => +5.75,
- 'UP6' => +6,
- 'UP65' => +6.5,
- 'UP7' => +7,
- 'UP8' => +8,
- 'UP875' => +8.75,
- 'UP9' => +9,
- 'UP95' => +9.5,
- 'UP10' => +10,
- 'UP105' => +10.5,
- 'UP11' => +11,
- 'UP115' => +11.5,
- 'UP12' => +12,
- 'UP1275' => +12.75,
- 'UP13' => +13,
- 'UP14' => +14
- );
+ 'UM12' => -12,
+ 'UM11' => -11,
+ 'UM10' => -10,
+ 'UM95' => -9.5,
+ 'UM9' => -9,
+ 'UM8' => -8,
+ 'UM7' => -7,
+ 'UM6' => -6,
+ 'UM5' => -5,
+ 'UM45' => -4.5,
+ 'UM4' => -4,
+ 'UM35' => -3.5,
+ 'UM3' => -3,
+ 'UM2' => -2,
+ 'UM1' => -1,
+ 'UTC' => 0,
+ 'UP1' => +1,
+ 'UP2' => +2,
+ 'UP3' => +3,
+ 'UP35' => +3.5,
+ 'UP4' => +4,
+ 'UP45' => +4.5,
+ 'UP5' => +5,
+ 'UP55' => +5.5,
+ 'UP575' => +5.75,
+ 'UP6' => +6,
+ 'UP65' => +6.5,
+ 'UP7' => +7,
+ 'UP8' => +8,
+ 'UP875' => +8.75,
+ 'UP9' => +9,
+ 'UP95' => +9.5,
+ 'UP10' => +10,
+ 'UP105' => +10.5,
+ 'UP11' => +11,
+ 'UP115' => +11.5,
+ 'UP12' => +12,
+ 'UP1275' => +12.75,
+ 'UP13' => +13,
+ 'UP14' => +14
+ );
if ($tz == '')
{
return $zones;
}
-
- if ($tz == 'GMT')
- $tz = 'UTC';
-
+
+ $tz = ($tz == 'GMT') ? 'UTC' : $tz;
+
return ( ! isset($zones[$tz])) ? 0 : $zones[$tz];
}
}
-
/* End of file date_helper.php */
/* Location: ./system/helpers/date_helper.php */ \ No newline at end of file
diff --git a/system/helpers/form_helper.php b/system/helpers/form_helper.php
index d9305c00b..130daee6a 100644
--- a/system/helpers/form_helper.php
+++ b/system/helpers/form_helper.php
@@ -642,11 +642,8 @@ if ( ! function_exists('form_prep'))
{
return $str;
}
-
- $str = htmlspecialchars($str);
-
- // In case htmlspecialchars misses these.
- $str = str_replace(array("'", '"'), array("&#39;", "&quot;"), $str);
+
+ $str = html_escape($str);
if ($field_name != '')
{
diff --git a/system/helpers/html_helper.php b/system/helpers/html_helper.php
index b64b60650..10a288e6a 100644
--- a/system/helpers/html_helper.php
+++ b/system/helpers/html_helper.php
@@ -365,7 +365,7 @@ if ( ! function_exists('link_tag'))
$link .= '/>';
}
-
+ $link .= "\n";
return $link;
}
diff --git a/system/helpers/string_helper.php b/system/helpers/string_helper.php
index 9fa69f46c..dd8ffaddb 100644
--- a/system/helpers/string_helper.php
+++ b/system/helpers/string_helper.php
@@ -215,12 +215,9 @@ if ( ! function_exists('random_string'))
case 'nozero' : $pool = '123456789';
break;
}
-
- $str = '';
- for ($i=0; $i < $len; $i++)
- {
- $str .= substr($pool, mt_rand(0, strlen($pool) -1), 1);
- }
+
+ $str = substr(str_shuffle(str_repeat($pool, ceil($len/strlen($pool)))),0,$len);
+
return $str;
break;
case 'unique' :
diff --git a/system/helpers/typography_helper.php b/system/helpers/typography_helper.php
index 19b4eec03..e8cb037a8 100644
--- a/system/helpers/typography_helper.php
+++ b/system/helpers/typography_helper.php
@@ -39,9 +39,7 @@ if ( ! function_exists('nl2br_except_pre'))
function nl2br_except_pre($str)
{
$CI =& get_instance();
-
$CI->load->library('typography');
-
return $CI->typography->nl2br_except_pre($str);
}
}
@@ -78,11 +76,12 @@ if ( ! function_exists('auto_typography'))
*
* @access public
* @param string
+ * @param string
* @return string
*/
if ( ! function_exists('entity_decode'))
{
- function entity_decode($str, $charset='UTF-8')
+ function entity_decode($str, $charset = NULL)
{
global $SEC;
return $SEC->entity_decode($str, $charset);
diff --git a/system/helpers/url_helper.php b/system/helpers/url_helper.php
index 09d975621..c524dddd1 100644..100755
--- a/system/helpers/url_helper.php
+++ b/system/helpers/url_helper.php
@@ -512,7 +512,7 @@ if ( ! function_exists('url_title'))
$str = strtolower($str);
}
- return trim(stripslashes($str));
+ return trim(trim(stripslashes($str)), $replace);
}
}