From b0dd10f8171945e0c1f3527dd1e9d18b043e01a7 Mon Sep 17 00:00:00 2001
From: admin
Date: Fri, 25 Aug 2006 17:25:49 +0000
Subject: Initial Import
---
system/helpers/array_helper.php | 47 ++++
system/helpers/cookie_helper.php | 77 +++++
system/helpers/date_helper.php | 530 +++++++++++++++++++++++++++++++++++
system/helpers/directory_helper.php | 69 +++++
system/helpers/file_helper.php | 139 +++++++++
system/helpers/form_helper.php | 382 +++++++++++++++++++++++++
system/helpers/html_helper.php | 76 +++++
system/helpers/index.html | 15 +
system/helpers/security_helper.php | 112 ++++++++
system/helpers/string_helper.php | 154 ++++++++++
system/helpers/text_helper.php | 386 +++++++++++++++++++++++++
system/helpers/typography_helper.php | 490 ++++++++++++++++++++++++++++++++
system/helpers/url_helper.php | 487 ++++++++++++++++++++++++++++++++
system/helpers/xml_helper.php | 55 ++++
14 files changed, 3019 insertions(+)
create mode 100644 system/helpers/array_helper.php
create mode 100644 system/helpers/cookie_helper.php
create mode 100644 system/helpers/date_helper.php
create mode 100644 system/helpers/directory_helper.php
create mode 100644 system/helpers/file_helper.php
create mode 100644 system/helpers/form_helper.php
create mode 100644 system/helpers/html_helper.php
create mode 100644 system/helpers/index.html
create mode 100644 system/helpers/security_helper.php
create mode 100644 system/helpers/string_helper.php
create mode 100644 system/helpers/text_helper.php
create mode 100644 system/helpers/typography_helper.php
create mode 100644 system/helpers/url_helper.php
create mode 100644 system/helpers/xml_helper.php
(limited to 'system/helpers')
diff --git a/system/helpers/array_helper.php b/system/helpers/array_helper.php
new file mode 100644
index 000000000..cccde1fc4
--- /dev/null
+++ b/system/helpers/array_helper.php
@@ -0,0 +1,47 @@
+
\ No newline at end of file
diff --git a/system/helpers/cookie_helper.php b/system/helpers/cookie_helper.php
new file mode 100644
index 000000000..24e243ddd
--- /dev/null
+++ b/system/helpers/cookie_helper.php
@@ -0,0 +1,77 @@
+ 0)
+ {
+ $expire = time() + $expire;
+ }
+ else
+ {
+ $expire = 0;
+ }
+ }
+
+ setcookie($prefix.$name, $value, $expire, $path, $domain, 0);
+}
+
+?>
\ No newline at end of file
diff --git a/system/helpers/date_helper.php b/system/helpers/date_helper.php
new file mode 100644
index 000000000..2a3d50859
--- /dev/null
+++ b/system/helpers/date_helper.php
@@ -0,0 +1,530 @@
+config->item('time_reference')) == 'gmt')
+ {
+ $now = time();
+ $system_time = mktime(gmdate("H", $now), gmdate("i", $now), gmdate("s", $now), gmdate("m", $now), gmdate("d", $now), gmdate("Y", $now));
+
+ if (strlen($system_time) < 10)
+ {
+ $system_time = time();
+ log_message('error', 'The Date class could not set a proper GMT timestamp so the local time() value was used.');
+ }
+
+ return $system_time;
+ }
+ else
+ {
+ return time();
+ }
+}
+
+// ------------------------------------------------------------------------
+
+/**
+ * Convert MySQL Style Datecodes
+ *
+ * This function is identical to PHPs date() function,
+ * except that it allows date codes to be formatted using
+ * the MySQL style, where each code letter is preceded
+ * with a percent sign: %Y %m %d etc...
+ *
+ * The benefit of doing dates this way is that you don't
+ * have to worry about escaping your text letters that
+ * match the date codes.
+ *
+ * @access public
+ * @param string
+ * @param integer
+ * @return integer
+ */
+function mdate($datestr = '', $time = '')
+{
+ if ($datestr == '')
+ return '';
+
+ if ($time == '')
+ $time = now();
+
+ $datestr = str_replace('%\\', '', preg_replace("/([a-z]+?){1}/i", "\\\\\\1", $datestr));
+ return date($datestr, $time);
+}
+
+// ------------------------------------------------------------------------
+
+/**
+ * Convert MySQL Style Datecodes
+ *
+ * Returns a span of seconds in this format:
+ * 10 days 14 hours 36 minutes 47 seconds
+ *
+ * @access public
+ * @param integer a number of seconds
+ * @param integer Unix timestamp
+ * @return integer
+ */
+function timespan($seconds = 1, $time = '')
+{
+ $obj =& get_instance();
+ $obj->lang->load('date');
+
+ if ( ! is_numeric($seconds))
+ {
+ $seconds = 1;
+ }
+
+ if ( ! is_numeric($time))
+ {
+ $time = time();
+ }
+
+ if ($time <= $seconds)
+ {
+ $seconds = 1;
+ }
+ else
+ {
+ $seconds = $time - $seconds;
+ }
+
+ $str = '';
+ $years = floor($seconds / 31536000);
+
+ if ($years > 0)
+ {
+ $str .= $years.' '.$obj->lang->line((($years > 1) ? 'date_years' : 'date_year')).', ';
+ }
+
+ $seconds -= $years * 31536000;
+ $months = floor($seconds / 2628000);
+
+ if ($years > 0 OR $months > 0)
+ {
+ if ($months > 0)
+ {
+ $str .= $months.' '.$obj->lang->line((($months > 1) ? 'date_months' : 'date_month')).', ';
+ }
+
+ $seconds -= $months * 2628000;
+ }
+
+ $weeks = floor($seconds / 604800);
+
+ if ($years > 0 OR $months > 0 OR $weeks > 0)
+ {
+ if ($weeks > 0)
+ {
+ $str .= $weeks.' '.$obj->lang->line((($weeks > 1) ? 'date_weeks' : 'date_week')).', ';
+ }
+
+ $seconds -= $weeks * 604800;
+ }
+
+ $days = floor($seconds / 86400);
+
+ if ($months > 0 OR $weeks > 0 OR $days > 0)
+ {
+ if ($days > 0)
+ {
+ $str .= $days.' '.$obj->lang->line((($days > 1) ? 'date_days' : 'date_day')).', ';
+ }
+
+ $seconds -= $days * 86400;
+ }
+
+ $hours = floor($seconds / 3600);
+
+ if ($days > 0 OR $hours > 0)
+ {
+ if ($hours > 0)
+ {
+ $str .= $hours.' '.$obj->lang->line((($hours > 1) ? 'date_hours' : 'date_hour')).', ';
+ }
+
+ $seconds -= $hours * 3600;
+ }
+
+ $minutes = floor($seconds / 60);
+
+ if ($days > 0 OR $hours > 0 OR $minutes > 0)
+ {
+ if ($minutes > 0)
+ {
+ $str .= $minutes.' '.$obj->lang->line((($minutes > 1) ? 'date_minutes' : 'date_minutes')).', ';
+ }
+
+ $seconds -= $minutes * 60;
+ }
+
+ if ($str == '')
+ {
+ $str .= $seconds.' '.$obj->lang->line((($seconds > 1) ? 'date_seconds' : 'date_second')).', ';
+ }
+
+ return substr(trim($str), 0, -1);
+}
+
+// ------------------------------------------------------------------------
+
+/**
+ * Number of days in a month
+ *
+ * Takes a month/year as input and returns the number of days
+ * for the given month/year. Takes leap years into consideration.
+ *
+ * @access public
+ * @param integer a numeric month
+ * @param integer a numeric year
+ * @return integer
+ */
+function days_in_month($month = 0, $year = '')
+{
+ if ($month < 1 OR $month > 12)
+ {
+ return 0;
+ }
+
+ if ( ! ctype_digit($year) OR strlen($year) != 4)
+ {
+ $year = date('Y');
+ }
+
+ if ($month == 2)
+ {
+ if ($year % 400 == 0 OR ($year % 4 == 0 AND $year % 100 != 0))
+ {
+ return 29;
+ }
+ }
+
+ $days_in_month = array(31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31);
+ return $days_in_month[$month - 1];
+}
+
+// ------------------------------------------------------------------------
+
+/**
+ * Converts a local Unix timestamp to GMT
+ *
+ * @access public
+ * @param integer Unix timestamp
+ * @return integer
+ */
+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));
+}
+
+// ------------------------------------------------------------------------
+
+/**
+ * Converts GMT time to a localized value
+ *
+ * Takes a Unix timestamp (in GMT) as input, and returns
+ * at the local value based on the timezone and DST setting
+ * submitted
+ *
+ * @access public
+ * @param integer Unix timestamp
+ * @param string timezone
+ * @param bool whether DST is active
+ * @return integer
+ */
+function gmt_to_local($time = '', $timezone = 'UTC', $dst = FALSE)
+{
+ if ($time == '')
+ {
+ return now();
+ }
+
+ $time += timezones($timezone) * 3600;
+
+ if ($dst == TRUE)
+ {
+ $time += 3600;
+ }
+
+ return $time;
+}
+
+// ------------------------------------------------------------------------
+
+/**
+ * Converts a MySQL Timestamp to Unix
+ *
+ * @access public
+ * @param integer Unix timestamp
+ * @return integer
+ */
+function mysql_to_unix($time = '')
+{
+ // We'll remove certain characters for backward compatibility
+ // since the formatting changed with MySQL 4.1
+ // YYYY-MM-DD HH:MM:SS
+
+ $time = str_replace('-', '', $time);
+ $time = str_replace(':', '', $time);
+ $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)
+ );
+}
+
+// ------------------------------------------------------------------------
+
+/**
+ * Unix to "Human"
+ *
+ * Formats Unix timestamp to the following prototype: 2006-08-21 11:35 PM
+ *
+ * @access public
+ * @param integer Unix timestamp
+ * @param bool whether to show seconds
+ * @param string format: us or euro
+ * @return string
+ */
+function unix_to_human($time = '', $seconds = FALSE, $fmt = 'us')
+{
+ $r = date('Y', $time).'-'.date('m', $time).'-'.date('d', $time).' ';
+
+ if ($fmt == 'us')
+ {
+ $r .= date('h', $time).':'.date('i', $time);
+ }
+ else
+ {
+ $r .= date('H', $time).':'.date('i', $time);
+ }
+
+ if ($seconds)
+ {
+ $r .= ':'.date('s', $time);
+ }
+
+ if ($fmt == 'us')
+ {
+ $r .= ' '.date('A', $time);
+ }
+
+ return $r;
+}
+
+// ------------------------------------------------------------------------
+
+/**
+ * Convert "human" date to GMT
+ *
+ * Reverses the above process
+ *
+ * @access public
+ * @param string format: us or euro
+ * @return integer
+ */
+function human_to_unix($datestr = '')
+{
+ if ($datestr == '')
+ {
+ return FALSE;
+ }
+
+ $datestr = trim($datestr);
+ $datestr = preg_replace("/\040+/", "\040", $datestr);
+
+ if ( ! ereg("^[0-9]{2,4}\-[0-9]{1,2}\-[0-9]{1,2}\040[0-9]{1,2}:[0-9]{1,2}.*$", $datestr))
+ {
+ return FALSE;
+ }
+
+ $split = preg_split("/\040/", $datestr);
+
+ $ex = explode("-", $split['0']);
+
+ $year = (strlen($ex['0']) == 2) ? '20'.$ex['0'] : $ex['0'];
+ $month = (strlen($ex['1']) == 1) ? '0'.$ex['1'] : $ex['1'];
+ $day = (strlen($ex['2']) == 1) ? '0'.$ex['2'] : $ex['2'];
+
+ $ex = explode(":", $split['1']);
+
+ $hour = (strlen($ex['0']) == 1) ? '0'.$ex['0'] : $ex['0'];
+ $min = (strlen($ex['1']) == 1) ? '0'.$ex['1'] : $ex['1'];
+
+ if (isset($ex['2']) AND ereg("[0-9]{1,2}", $ex['2']))
+ {
+ $sec = (strlen($ex['2']) == 1) ? '0'.$ex['2'] : $ex['2'];
+ }
+ else
+ {
+ // Unless specified, seconds get set to zero.
+ $sec = '00';
+ }
+
+ if (isset($split['2']))
+ {
+ $ampm = strtolower($split['2']);
+
+ if (substr($ampm, 0, 1) == 'p' AND $hour < 12)
+ $hour = $hour + 12;
+
+ if (substr($ampm, 0, 1) == 'a' AND $hour == 12)
+ $hour = '00';
+
+ if (strlen($hour) == 1)
+ $hour = '0'.$hour;
+ }
+
+ return mktime($hour, $min, $sec, $month, $day, $year);
+}
+
+// ------------------------------------------------------------------------
+
+/**
+ * Timezone Menu
+ *
+ * Generates a drop-down menu of timezones.
+ *
+ * @access public
+ * @param string timezone
+ * @param string classname
+ * @param string menu name
+ * @return string
+ */
+function timezone_menu($default = 'UTC', $class = "", $name = 'timezones')
+{
+ $obj =& get_instance();
+ $obj->lang->load('date');
+
+ if ($default == 'GMT')
+ $default = 'UTC';
+
+ $menu = '";
+
+ return $menu;
+}
+
+// ------------------------------------------------------------------------
+
+/**
+ * Timezones
+ *
+ * Returns an array of timezones. This is a helper function
+ * for varios other ones in this library
+ *
+ * @access public
+ * @param string timezone
+ * @return string
+ */
+function timezones($tz = '')
+{
+ // Note: Don't change the order of these even though
+ // some items appear to be in the wrong order
+
+ $zones = array(
+ 'UM12' => -12,
+ 'UM11' => -11,
+ 'UM10' => -10,
+ 'UM9' => -9,
+ 'UM8' => -8,
+ 'UM7' => -7,
+ 'UM6' => -6,
+ 'UM5' => -5,
+ 'UM4' => -4,
+ 'UM25' => -2.5,
+ 'UM3' => -3,
+ 'UM2' => -2,
+ 'UM1' => -1,
+ 'UTC' => 0,
+ 'UP1' => +1,
+ 'UP2' => +2,
+ 'UP3' => +3,
+ 'UP25' => +2.5,
+ 'UP4' => +4,
+ 'UP35' => +3.5,
+ 'UP5' => +5,
+ 'UP45' => +4.5,
+ 'UP6' => +6,
+ 'UP7' => +7,
+ 'UP8' => +8,
+ 'UP9' => +9,
+ 'UP85' => +8.5,
+ 'UP10' => +10,
+ 'UP11' => +11,
+ 'UP12' => +12
+ );
+
+ if ($tz == '')
+ {
+ return $zones;
+ }
+
+ if ($tz == 'GMT')
+ $tz = 'UTC';
+
+ return ( ! isset($zones[$tz])) ? 0 : $zones[$tz];
+}
+
+
+?>
\ No newline at end of file
diff --git a/system/helpers/directory_helper.php b/system/helpers/directory_helper.php
new file mode 100644
index 000000000..69eb13d11
--- /dev/null
+++ b/system/helpers/directory_helper.php
@@ -0,0 +1,69 @@
+
\ No newline at end of file
diff --git a/system/helpers/file_helper.php b/system/helpers/file_helper.php
new file mode 100644
index 000000000..93bddb029
--- /dev/null
+++ b/system/helpers/file_helper.php
@@ -0,0 +1,139 @@
+ 0)
+ {
+ $data = fread($fp, filesize($file));
+ }
+
+ flock($fp, LOCK_UN);
+ fclose($fp);
+
+ return $data;
+}
+
+// ------------------------------------------------------------------------
+
+/**
+ * Write File
+ *
+ * Writes data to the file specified in the path.
+ * Creats a new file if non-existant.
+ *
+ * @access public
+ * @param string path to file
+ * @param string file data
+ * @return bool
+ */
+function write_file($path, $data)
+{
+ if ( ! $fp = @fopen($path, 'wb'))
+ {
+ return FALSE;
+ }
+
+ flock($fp, LOCK_EX);
+ fwrite($fp, $data);
+ flock($fp, LOCK_UN);
+ fclose($fp);
+
+ return TRUE;
+}
+
+// ------------------------------------------------------------------------
+
+/**
+ * Delete Files
+ *
+ * Deletes all files contained in the supplied directory path.
+ * Files must be writable or owned by the system in order to be deleted.
+ * If the second parameter is set to TRUE, any direcotries contained
+ * within the supplied base directory will be nuked as well.
+ *
+ * @access public
+ * @param string path to file
+ * @param bool whether to delete any directories found in the path
+ * @return bool
+ */
+function delete_files($path, $del_dir = FALSE)
+{
+ // Trim the trailing slahs
+ $path = preg_replace("|^(.+?)/*$|", "\\1", $path);
+
+ if ( ! $current_dir = @opendir($path))
+ return;
+
+ while(FALSE !== ($filename = @readdir($current_dir)))
+ {
+ if ($filename != "." and $filename != "..")
+ {
+ if (is_dir($path.'/'.$filename))
+ {
+ delete_files($path.'/'.$filename, $del_dir);
+ }
+ else
+ {
+ unlink($path.'/'.$filename);
+ }
+ }
+ }
+ @closedir($current_dir);
+
+ if ($del_dir == TRUE)
+ {
+ @rmdir($path);
+ }
+}
+
+
+?>
\ No newline at end of file
diff --git a/system/helpers/form_helper.php b/system/helpers/form_helper.php
new file mode 100644
index 000000000..f82ad01a0
--- /dev/null
+++ b/system/helpers/form_helper.php
@@ -0,0 +1,382 @@
+config->site_url($action).'"';
+
+ if (is_array($attributes) AND count($attributes) > 0)
+ {
+ foreach ($attributes as $key => $val)
+ {
+ $form .= ' '.$key.'="'.$val.'"';
+ }
+ }
+
+ $form .= '>';
+
+ if (is_array($hidden) AND count($hidden > 0))
+ {
+ $form .= form_hidden($hidden);
+ }
+
+ return $form;
+}
+
+// ------------------------------------------------------------------------
+
+/**
+ * Form Declaration - Multipart type
+ *
+ * Creates the opening portion of the form, but with "multipart/form-data".
+ *
+ * @access public
+ * @param string the URI segments of the form destination
+ * @param array a key/value pair of attributes
+ * @param array a key/value pair hidden data
+ * @return string
+ */
+function form_open_multipart($action, $attributes = array(), $hidden = array())
+{
+ $attributes['enctype'] = 'multipart/form-data';
+ return form_open($action, $attributes, $hidden);
+}
+
+// ------------------------------------------------------------------------
+
+/**
+ * Hidden Input Field
+ *
+ * Generates hidden fields. You can pass a simple key/value string or an associative
+ * array with multiple values.
+ *
+ * @access public
+ * @param mixed
+ * @param string
+ * @return string
+ */
+function form_hidden($name, $value = '')
+{
+ if ( ! is_array($name))
+ {
+ return '';
+ }
+
+ $form = '';
+ foreach ($name as $name => $value)
+ {
+ $form .= '';
+ }
+
+ return $form;
+}
+
+// ------------------------------------------------------------------------
+
+/**
+ * Text Input Field
+ *
+ * @access public
+ * @param mixed
+ * @param string
+ * @param string
+ * @return string
+ */
+function form_input($data = '', $value = '', $extra = '')
+{
+ $defaults = array('type' => 'text', 'name' => (( ! is_array($data)) ? $data : ''), 'value' => $value, 'maxlength' => '500', 'size' => '50');
+
+ return "\n";
+}
+
+// ------------------------------------------------------------------------
+
+/**
+ * Password Field
+ *
+ * Identical to the input function but adds the "password" type
+ *
+ * @access public
+ * @param mixed
+ * @param string
+ * @param string
+ * @return string
+ */
+function form_password($data = '', $value = '', $extra = '')
+{
+ if ( ! is_array($data))
+ {
+ $data = array('name' => $data);
+ }
+
+ $data['type'] = 'password';
+ return form_input($data, $value, $extra);
+}
+
+// ------------------------------------------------------------------------
+
+/**
+ * Upload Field
+ *
+ * Identical to the input function but adds the "file" type
+ *
+ * @access public
+ * @param mixed
+ * @param string
+ * @param string
+ * @return string
+ */
+function form_upload($data = '', $value = '', $extra = '')
+{
+ if ( ! is_array($data))
+ {
+ $data = array('name' => $data);
+ }
+
+ $data['type'] = 'file';
+ return form_input($data, $value, $extra);
+}
+
+// ------------------------------------------------------------------------
+
+/**
+ * Textarea field
+ *
+ * @access public
+ * @param mixed
+ * @param string
+ * @param string
+ * @return string
+ */
+function form_textarea($data = '', $value = '', $extra = '')
+{
+ $defaults = array('name' => (( ! is_array($data)) ? $data : ''), 'cols' => '90', 'rows' => '12');
+
+ $val = (( ! is_array($data) OR ! isset($data['value'])) ? $value : $data['value']);
+
+ return "\n";
+}
+
+// ------------------------------------------------------------------------
+
+/**
+ * Dropdown Menu
+ *
+ * @access public
+ * @param string
+ * @param array
+ * @param string
+ * @param string
+ * @return string
+ */
+function form_dropdown($name = '', $options = array(), $selected = '', $extra = '')
+{
+ if ($extra != '') $extra = ' '.$extra;
+
+ $form = '';
+
+ return $form;
+}
+
+// ------------------------------------------------------------------------
+
+/**
+ * Checkbox Field
+ *
+ * @access public
+ * @param mixed
+ * @param string
+ * @param bool
+ * @param string
+ * @return string
+ */
+function form_checkbox($data = '', $value = '', $checked = TRUE, $extra = '')
+{
+ $defaults = array('type' => 'checkbox', 'name' => (( ! is_array($data)) ? $data : ''), 'value' => $value);
+
+ if (isset($data['checked']))
+ {
+ $checked = $data['checked'];
+
+ if ($checked == FALSE)
+ unset($data['checked']);
+ }
+
+ if ($checked == TRUE)
+ $defaults['checked'] = ' checked="checked"';
+ else
+ unset($defaults['checked']);
+
+ return "\n";
+}
+
+// ------------------------------------------------------------------------
+
+/**
+ * Radio Button
+ *
+ * @access public
+ * @param mixed
+ * @param string
+ * @param bool
+ * @param string
+ * @return string
+ */
+function form_radio($data = '', $value = '', $checked = TRUE, $extra = '')
+{
+ if ( ! is_array($data))
+ {
+ $data = array('name' => $data);
+ }
+
+ $data['type'] = 'radio';
+ return form_checkbox($data, $value, $checked, $extra);
+}
+
+// ------------------------------------------------------------------------
+
+/**
+ * Submit Button
+ *
+ * @access public
+ * @param mixed
+ * @param string
+ * @param string
+ * @return string
+ */
+function form_submit($data = '', $value = '', $extra = '')
+{
+ $defaults = array('type' => 'submit', 'name' => (( ! is_array($data)) ? $data : ''), 'value' => $value);
+
+ return "\n";
+}
+
+// ------------------------------------------------------------------------
+
+/**
+ * Form Close Tag
+ *
+ * @access public
+ * @param string
+ * @return string
+ */
+function form_close($extra = '')
+{
+ return "\n".$extra;
+}
+
+// ------------------------------------------------------------------------
+
+/**
+ * Form Prep
+ *
+ * Formats text so that it can be safely placed in a form field in the event it has HTML tags.
+ *
+ * @access public
+ * @param string
+ * @return string
+ */
+function form_prep($str = '')
+{
+ if ($str == '')
+ {
+ return '';
+ }
+
+ return str_replace(array("'", '"'), array("'", """), htmlspecialchars($str));
+}
+
+// ------------------------------------------------------------------------
+
+/**
+ * Parse the form attributes
+ *
+ * Helper function used by some of the form helpers
+ *
+ * @access private
+ * @param array
+ * @parm array
+ * @return string
+ */
+function parse_form_attributes($attributes, $default)
+{
+ if (is_array($attributes))
+ {
+ foreach ($default as $key => $val)
+ {
+ if (isset($attributes[$key]))
+ {
+ $default[$key] = $attributes[$key];
+ unset($attributes[$key]);
+ }
+ }
+
+ if (count($attributes) > 0)
+ {
+ $default = array_merge($default, $attributes);
+ }
+ }
+
+ $att = '';
+ foreach ($default as $key => $val)
+ {
+ if ($key == 'value')
+ {
+ $val = form_prep($val);
+ }
+
+ $att .= $key . '="' . $val . '" ';
+ }
+
+ return $att;
+}
+
+?>
\ No newline at end of file
diff --git a/system/helpers/html_helper.php b/system/helpers/html_helper.php
new file mode 100644
index 000000000..1c97dda53
--- /dev/null
+++ b/system/helpers/html_helper.php
@@ -0,0 +1,76 @@
+".$data."";
+}
+
+// ------------------------------------------------------------------------
+
+/**
+ * Generates HTML BR tags based on number supplied
+ *
+ * @access public
+ * @param integer
+ * @return string
+ */
+function br($num = 1)
+{
+ return str_repeat(" ", $num);
+}
+
+// ------------------------------------------------------------------------
+
+/**
+ * Generates non-breaking space entities based on number supplied
+ *
+ * @access public
+ * @param integer
+ * @return string
+ */
+function nbs($num = 1)
+{
+ return str_repeat(" ", $num);
+}
+
+
+
+?>
\ No newline at end of file
diff --git a/system/helpers/index.html b/system/helpers/index.html
new file mode 100644
index 000000000..5a1f5d6ae
--- /dev/null
+++ b/system/helpers/index.html
@@ -0,0 +1,15 @@
+
+
+
+
+403 Forbidden
+
+
+
+
+
+
Directory access is forbidden.
+
+
+
+
\ No newline at end of file
diff --git a/system/helpers/security_helper.php b/system/helpers/security_helper.php
new file mode 100644
index 000000000..918e4ae90
--- /dev/null
+++ b/system/helpers/security_helper.php
@@ -0,0 +1,112 @@
+input->xss_clean($str, $charset);
+}
+
+// --------------------------------------------------------------------
+
+/**
+ * Hash encode a string
+ *
+ * @access public
+ * @param string
+ * @return string
+ */
+function hash($str, $type = 'sha1')
+{
+ if ($type == 'sha1')
+ {
+ if ( ! function_exists('sha1'))
+ {
+ if ( ! function_exists('mhash'))
+ {
+ require_once(BASEPATH.'libraries/Sha1'.EXT);
+ $SH = new CI_SHA;
+ return $SH->generate($str);
+ }
+ else
+ {
+ return bin2hex(mhash(MHASH_SHA1, $str));
+ }
+ }
+ else
+ {
+ return sha1($str);
+ }
+ }
+ else
+ {
+ return md5($str);
+ }
+}
+
+// ------------------------------------------------------------------------
+
+/**
+ * Strip Image Tags
+ *
+ * @access public
+ * @parm string
+ * @return string
+ */
+function strip_image_tags($str)
+{
+ $str = preg_replace("##", "\\1", $str);
+ $str = preg_replace("##", "\\1", $str);
+
+ return $str;
+}
+
+// ------------------------------------------------------------------------
+
+/**
+ * Convert PHP tags to entities
+ *
+ * @access public
+ * @parm string
+ * @return string
+ */
+function encode_php_tags($str)
+{
+ return str_replace(array(''), array('<?php', '<?PHP', '<?', '?>'), $str);
+}
+
+?>
\ No newline at end of file
diff --git a/system/helpers/string_helper.php b/system/helpers/string_helper.php
new file mode 100644
index 000000000..d5a3591f9
--- /dev/null
+++ b/system/helpers/string_helper.php
@@ -0,0 +1,154 @@
+
\ No newline at end of file
diff --git a/system/helpers/text_helper.php b/system/helpers/text_helper.php
new file mode 100644
index 000000000..15b5573bf
--- /dev/null
+++ b/system/helpers/text_helper.php
@@ -0,0 +1,386 @@
+= $n)
+ {
+ return trim($out).$end_char;
+ }
+ }
+}
+
+// ------------------------------------------------------------------------
+
+/**
+ * High ASCII to Entities
+ *
+ * Converts High ascii text and MS Word special characters to character entities
+ *
+ * @access public
+ * @param string
+ * @return string
+ */
+function ascii_to_entities($str)
+{
+ $count = 1;
+ $out = '';
+ $temp = array();
+
+ for ($i = 0, $s = strlen($str); $i < $s; $i++)
+ {
+ $ordinal = ord($str[$i]);
+
+ if ($ordinal < 128)
+ {
+ $out .= $str[$i];
+ }
+ else
+ {
+ if (count($temp) == 0)
+ {
+ $count = ($ordinal < 224) ? 2 : 3;
+ }
+
+ $temp[] = $ordinal;
+
+ if (count($temp) == $count)
+ {
+ $number = ($count == 3) ? (($temp['0'] % 16) * 4096) + (($temp['1'] % 64) * 64) + ($temp['2'] % 64) : (($temp['0'] % 32) * 64) + ($temp['1'] % 64);
+
+ $out .= ''.$number.';';
+ $count = 1;
+ $temp = array();
+ }
+ }
+ }
+
+ return $out;
+}
+
+// ------------------------------------------------------------------------
+
+/**
+ * Entities to ASCII
+ *
+ * Converts character entities back to ASCII
+ *
+ * @access public
+ * @param string
+ * @param bool
+ * @return string
+ */
+function entities_to_ascii($str, $all = TRUE)
+{
+ if (preg_match_all('/\(\d+)\;/', $str, $matches))
+ {
+ for ($i = 0, $s = count($matches['0']); $i < $s; $i++)
+ {
+ $digits = $matches['1'][$i];
+
+ $out = '';
+
+ if ($digits < 128)
+ {
+ $out .= chr($digits);
+
+ }
+ elseif ($digits < 2048)
+ {
+ $out .= chr(192 + (($digits - ($digits % 64)) / 64));
+ $out .= chr(128 + ($digits % 64));
+ }
+ else
+ {
+ $out .= chr(224 + (($digits - ($digits % 4096)) / 4096));
+ $out .= chr(128 + ((($digits % 4096) - ($digits % 64)) / 64));
+ $out .= chr(128 + ($digits % 64));
+ }
+
+ $str = str_replace($matches['0'][$i], $out, $str);
+ }
+ }
+
+ if ($all)
+ {
+ $str = str_replace(array("&", "<", ">", """, "'", "-"),
+ array("&","<",">","\"", "'", "-"),
+ $str);
+ }
+
+ return $str;
+}
+
+// ------------------------------------------------------------------------
+
+/**
+ * Word Censoring Function
+ *
+ * Supply a string and an array of disallowed words and any
+ * matched words will be converted to #### or to the replacement
+ * word you've submitted.
+ *
+ * @access public
+ * @param string the text string
+ * @param string the array of censoered words
+ * @param string the optional replacement value
+ * @return string
+ */
+function word_censor($str, $censored, $replacement = '')
+{
+ if ( ! is_array($censored))
+ {
+ return $str;
+ }
+
+ $str = ' '.$str.' ';
+ foreach ($censored as $badword)
+ {
+ if ($replacement != '')
+ {
+ $str = preg_replace("/\b(".str_replace('\*', '\w*?', preg_quote($badword)).")\b/i", $replacement, $str);
+ }
+ else
+ {
+ $str = preg_replace("/\b(".str_replace('\*', '\w*?', preg_quote($badword)).")\b/ie", "str_repeat('#', strlen('\\1'))", $str);
+ }
+ }
+
+ return trim($str);
+}
+
+// ------------------------------------------------------------------------
+
+/**
+ * Code Highlighter
+ *
+ * Colorizes code strings
+ *
+ * @access public
+ * @param string the text string
+ * @return string
+ */
+function highlight_code($str)
+{
+ // The highlight string function encodes and highlights
+ // brackets so we need them to start raw
+ $str = str_replace(array('<', '>'), array('<', '>'), $str);
+
+ // Replace any existing PHP tags to temporary markers so they don't accidentally
+ // break the string out of PHP, and thus, thwart the highlighting.
+
+ $str = str_replace(array('<?php', '?>', '\\'), array('phptagopen', 'phptagclose', 'backslashtmp'), $str);
+
+ // The highlight_string function requires that the text be surrounded
+ // by PHP tags. Since we don't know if A) the submitted text has PHP tags,
+ // or B) whether the PHP tags enclose the entire string, we will add our
+ // own PHP tags around the string along with some markers to make replacement easier later
+
+ $str = ''; //
+
+ // All the magic happens here, baby!
+ $str = highlight_string($str, TRUE);
+
+ // Prior to PHP 5, the highlight function used icky font tags
+ // so we'll replace them with span tags.
+ if (abs(phpversion()) < 5)
+ {
+ $str = str_replace(array(''), array(''), $str);
+ $str = preg_replace('#color="(.*?)"#', 'style="color: \\1"', $str);
+ }
+
+ // Remove our artificially added PHP
+ $str = preg_replace("#\.+?//tempstart\ \#is", "\n", $str);
+ $str = preg_replace("#\.+?//tempstart\ #is", "\n", $str);
+ $str = preg_replace("#//tempend.+#is", "\n", $str);
+
+ // Replace our markers back to PHP tags.
+ $str = str_replace(array('phptagopen', 'phptagclose', 'backslashtmp'), array('<?php', '?>', '\\'), $str); //
+
+ return $str;
+}
+
+// ------------------------------------------------------------------------
+
+/**
+ * Phrase Highlighter
+ *
+ * Highlights a phrase within a text string
+ *
+ * @access public
+ * @param string the text string
+ * @param string the phrase you'd like to highlight
+ * @param string the openging tag to precede the phrase with
+ * @param string the closing tag to end the phrase with
+ * @return string
+ */
+function highlight_phrase($str, $phrase, $tag_open = '', $tag_close = '')
+{
+ if ($str == '')
+ {
+ return '';
+ }
+
+ if ($phrase != '')
+ {
+ return preg_replace('/('.preg_quote($phrase).')/i', $tag_open."\\1".$tag_close, $str);
+ }
+
+ return $str;
+}
+
+// ------------------------------------------------------------------------
+
+/**
+ * Word Wrap
+ *
+ * Wraps text at the specified character. Maintains the integrity of words.
+ *
+ * @access public
+ * @param string the text string
+ * @param integer the number of characters to wrap at
+ * @return string
+ */
+function word_wrap($str, $chars = '76')
+{
+ if ( ! ctype_digit($chars))
+ $chars = 76;
+
+ $str = preg_replace("/(\r\n|\r|\n)/", "\n", $str);
+ $lines = split("\n", $str);
+
+ $output = "";
+ while (list(, $thisline) = each($lines))
+ {
+ if (strlen($thisline) > $chars)
+ {
+ $line = "";
+ $words = split(" ", $thisline);
+ while(list(, $thisword) = each($words))
+ {
+ while((strlen($thisword)) > $chars)
+ {
+ $cur_pos = 0;
+ for($i=0; $i < $chars - 1; $i++)
+ {
+ $output .= $thisword[$i];
+ $cur_pos++;
+ }
+
+ $output .= "\n";
+ $thisword = substr($thisword, $cur_pos, (strlen($thisword) - $cur_pos));
+ }
+
+ if ((strlen($line) + strlen($thisword)) > $chars)
+ {
+ $output .= $line."\n";
+ $line = $thisword." ";
+ }
+ else
+ {
+ $line .= $thisword." ";
+ }
+ }
+
+ $output .= $line."\n";
+ }
+ else
+ {
+ $output .= $thisline."\n";
+ }
+ }
+
+ return $output;
+}
+
+?>
\ No newline at end of file
diff --git a/system/helpers/typography_helper.php b/system/helpers/typography_helper.php
new file mode 100644
index 000000000..6a5495239
--- /dev/null
+++ b/system/helpers/typography_helper.php
@@ -0,0 +1,490 @@
+",$str);
+ $ct = count($ex);
+
+ $newstr = "";
+ for ($i = 0; $i < $ct; $i++)
+ {
+ if (($i % 2) == 0)
+ {
+ $newstr .= nl2br($ex[$i]);
+ }
+ else
+ {
+ $newstr .= $ex[$i];
+ }
+
+ if ($ct - 1 != $i)
+ $newstr .= "pre>";
+ }
+
+ return $newstr;
+}
+
+// ------------------------------------------------------------------------
+
+/**
+ * Auto Typography Wrapper Function
+ *
+ *
+ * @access public
+ * @parm string
+ * @return string
+ */
+function auto_typography($str)
+{
+ $TYPE = new Auto_typography();
+ return $TYPE->convert($str);
+}
+
+// ------------------------------------------------------------------------
+
+/**
+ * Auto Typography Class
+ *
+ *
+ * @access private
+ * @category Helpers
+ * @author Rick Ellis
+ * @author Paul Burdick
+ * @link http://www.codeigniter.com/user_guide/helpers/
+ */
+class Auto_typography {
+
+ // Block level elements that should not be wrapped inside
tags
+ var $block_elements = 'div|blockquote|pre|code|h\d|script|ol|un';
+
+ // Elements that should not have
and tags within them.
+ var $skip_elements = 'pre|ol|ul';
+
+ // Tags we want the parser to completely ignore when splitting the string.
+ var $ignore_elements = 'a|b|i|em|strong|span|img|li';
+
+
+ /**
+ * Main Processing Function
+ *
+ */
+ function convert($str)
+ {
+ if ($str == '')
+ {
+ return '';
+ }
+
+ $str = ' '.$str.' ';
+
+ // Standardize Newlines to make matching easier
+ $str = preg_replace("/(\r\n|\r)/", "\n", $str);
+
+ /*
+ * Reduce line breaks
+ *
+ * If there are more than two consecutive line
+ * breaks we'll compress them down to a maximum
+ * of two since there's no benefit to more.
+ *
+ */
+ $str = preg_replace("/\n\n+/", "\n\n", $str);
+
+ /*
+ * Convert quotes within tags to tempoarary marker
+ *
+ * We don't want quotes converted within
+ * tags so we'll temporarily convert them to
+ * {{{DQ}}} and {{{SQ}}}
+ *
+ */
+ if (preg_match_all("#\<.+?>#si", $str, $matches))
+ {
+ for ($i = 0; $i < count($matches['0']); $i++)
+ {
+ $str = str_replace($matches['0'][$i],
+ str_replace(array("'",'"'), array('{{{SQ}}}', '{{{DQ}}}'), $matches['0'][$i]),
+ $str);
+ }
+ }
+
+ /*
+ * Convert "ignore" tags to tempoarary marker
+ *
+ * The parser splits out the string at every tag
+ * it encounters. Certain inline tags, like image
+ * tags, links, span tags, etc. will be adversely
+ * affected if they are split out so we'll convert
+ * the opening < temporarily to: {{{tag}}}
+ *
+ */
+ $str = preg_replace("#<(/*)(".$this->ignore_elements.")#i", "{{{tag}}}\\1\\2", $str);
+
+ /*
+ * Split the string at every tag
+ *
+ * This creates an array with this prototype:
+ *
+ * [array]
+ * {
+ * [0] =
+ * [1] = Content contained between the tags
+ * [2] =
+ * Etc...
+ * }
+ *
+ */
+ $chunks = preg_split('/(<(?:[^<>]+(?:"[^"]*"|\'[^\']*\')?)+>)/', $str, -1, PREG_SPLIT_DELIM_CAPTURE|PREG_SPLIT_NO_EMPTY);
+
+ /*
+ * Build our finalized string
+ *
+ * We'll cycle through the array, skipping tags,
+ * and processing the contained text
+ *
+ */
+ $str = '';
+ $process = TRUE;
+ foreach ($chunks as $chunk)
+ {
+ /*
+ * Are we dealing with a tag?
+ *
+ * If so, we'll skip the processing for this cycle.
+ * Well also set the "process" flag which allows us
+ * to skip
tags and a few other things.
+ *
+ */
+ if (preg_match("#<(/*)(".$this->block_elements.").*?\>#", $chunk, $match))
+ {
+ if (preg_match("#".$this->skip_elements."#", $match['2']))
+ {
+ $process = ($match['1'] == '/') ? TRUE : FALSE;
+ }
+
+ $str .= $chunk;
+ continue;
+ }
+
+ if ($process == FALSE)
+ {
+ $str .= $chunk;
+ continue;
+ }
+
+ // Convert Newlines into
and tags
+ $str .= $this->format_newlines($chunk);
+ }
+
+ // Convert Quotes and other characters
+ $str = $this->format_characters($str);
+
+ // We'll swap our temporary markers back and do some clean up.
+ $str = preg_replace('#(
\n";
+ }
+
+ // Set the indentation for the closing tag
+ $out .= str_repeat(" ", $depth);
+
+ // Write the closing list tag
+ $out .= "".$type.">\n";
+
+ return $out;
+}
+
+// ------------------------------------------------------------------------
+
+/**
+ * Generates HTML BR tags based on number supplied
+ *
+ * @access public
+ * @param integer
+ * @return string
+ */
+function br($num = 1)
+{
+ return str_repeat(" ", $num);
+}
+
+// ------------------------------------------------------------------------
+
+/**
+ * Generates non-breaking space entities based on number supplied
+ *
+ * @access public
+ * @param integer
+ * @return string
+ */
+function nbs($num = 1)
+{
+ return str_repeat(" ", $num);
+}
+
+// ------------------------------------------------------------------------
+
+/**
+ * Generates meta tags from an array of key/values
+ *
+ * @access public
+ * @param array
+ * @return string
+ */
+function meta($meta = array(), $newline = "\n")
+{
+ $str = '';
+ foreach ($meta as $key => $val)
+ {
+ $str .= ''.$newline;
+ }
+
+ return $str;
+}
+
+
+
+
?>
\ No newline at end of file
diff --git a/system/helpers/inflector_helper.php b/system/helpers/inflector_helper.php
index 666ec40b8..fbe851f3b 100644
--- a/system/helpers/inflector_helper.php
+++ b/system/helpers/inflector_helper.php
@@ -1,140 +1,140 @@
-
\ No newline at end of file
diff --git a/system/helpers/security_helper.php b/system/helpers/security_helper.php
index 06228468f..eec04015d 100644
--- a/system/helpers/security_helper.php
+++ b/system/helpers/security_helper.php
@@ -1,112 +1,112 @@
-input->xss_clean($str, $charset);
-}
-
-// --------------------------------------------------------------------
-
-/**
- * Hash encode a string
- *
- * @access public
- * @param string
- * @return string
- */
-function dohash($str, $type = 'sha1')
-{
- if ($type == 'sha1')
- {
- if ( ! function_exists('sha1'))
- {
- if ( ! function_exists('mhash'))
- {
- require_once(BASEPATH.'libraries/Sha1'.EXT);
- $SH = new CI_SHA;
- return $SH->generate($str);
- }
- else
- {
- return bin2hex(mhash(MHASH_SHA1, $str));
- }
- }
- else
- {
- return sha1($str);
- }
- }
- else
- {
- return md5($str);
- }
-}
-
-// ------------------------------------------------------------------------
-
-/**
- * Strip Image Tags
- *
- * @access public
- * @param string
- * @return string
- */
-function strip_image_tags($str)
-{
- $str = preg_replace("##", "\\1", $str);
- $str = preg_replace("##", "\\1", $str);
-
- return $str;
-}
-
-// ------------------------------------------------------------------------
-
-/**
- * Convert PHP tags to entities
- *
- * @access public
- * @param string
- * @return string
- */
-function encode_php_tags($str)
-{
- return str_replace(array(''), array('<?php', '<?PHP', '<?', '?>'), $str);
-}
-
+input->xss_clean($str, $charset);
+}
+
+// --------------------------------------------------------------------
+
+/**
+ * Hash encode a string
+ *
+ * @access public
+ * @param string
+ * @return string
+ */
+function dohash($str, $type = 'sha1')
+{
+ if ($type == 'sha1')
+ {
+ if ( ! function_exists('sha1'))
+ {
+ if ( ! function_exists('mhash'))
+ {
+ require_once(BASEPATH.'libraries/Sha1'.EXT);
+ $SH = new CI_SHA;
+ return $SH->generate($str);
+ }
+ else
+ {
+ return bin2hex(mhash(MHASH_SHA1, $str));
+ }
+ }
+ else
+ {
+ return sha1($str);
+ }
+ }
+ else
+ {
+ return md5($str);
+ }
+}
+
+// ------------------------------------------------------------------------
+
+/**
+ * Strip Image Tags
+ *
+ * @access public
+ * @param string
+ * @return string
+ */
+function strip_image_tags($str)
+{
+ $str = preg_replace("##", "\\1", $str);
+ $str = preg_replace("##", "\\1", $str);
+
+ return $str;
+}
+
+// ------------------------------------------------------------------------
+
+/**
+ * Convert PHP tags to entities
+ *
+ * @access public
+ * @param string
+ * @return string
+ */
+function encode_php_tags($str)
+{
+ return str_replace(array(''), array('<?php', '<?PHP', '<?', '?>'), $str);
+}
+
?>
\ No newline at end of file
diff --git a/system/helpers/smiley_helper.php b/system/helpers/smiley_helper.php
index a07337246..9f16d3132 100644
--- a/system/helpers/smiley_helper.php
+++ b/system/helpers/smiley_helper.php
@@ -1,165 +1,165 @@
-
- function insert_smiley(smiley)
- {
- document.{$form_name}.{$form_field}.value += " " + smiley;
- }
-
-EOF;
-}
-
-// ------------------------------------------------------------------------
-
-/**
- * Get Clickable Smileys
- *
- * Returns an array of image tag links that can be clicked to be inserted
- * into a form field.
- *
- * @access public
- * @param string the URL to the folder containing the smiley images
- * @return array
- */
-function get_clickable_smileys($image_url = '', $smileys = NULL)
-{
- if ( ! is_array($smileys))
- {
- if (FALSE === ($smileys = _get_smiley_array()))
- {
- return $str;
- }
- }
-
- // Add a trailing slash to the file path if needed
- $image_url = preg_replace("/(.+?)\/*$/", "\\1/", $image_url);
-
- $used = array();
- foreach ($smileys as $key => $val)
- {
- // Keep duplicates from being used, which can happen if the
- // mapping array contains multiple identical replacements. For example:
- // :-) and :) might be replaced with the same image so both smileys
- // will be in the array.
- if (isset($used[$smileys[$key][0]]))
- {
- continue;
- }
-
- $link[] = "";
-
- $used[$smileys[$key][0]] = TRUE;
- }
-
- return $link;
-}
-
-// ------------------------------------------------------------------------
-
-/**
- * Parse Smileys
- *
- * Takes a string as input and swaps any contained smileys for the actual image
- *
- * @access public
- * @param string the text to be parsed
- * @param string the URL to the folder containing the smiley images
- * @return string
- */
-function parse_smileys($str = '', $image_url = '', $smileys = NULL)
-{
- if ($image_url == '')
- {
- return $str;
- }
-
- if ( ! is_array($smileys))
- {
- if (FALSE === ($smileys = _get_smiley_array()))
- {
- return $str;
- }
- }
-
- // Add a trailing slash to the file path if needed
- $image_url = preg_replace("/(.+?)\/*$/", "\\1/", $image_url);
-
- foreach ($smileys as $key => $val)
- {
- $str = str_replace($key, "", $str);
- }
-
- return $str;
-}
-
-// ------------------------------------------------------------------------
-
-/**
- * Get Smiley Array
- *
- * Fetches the config/smiley.php file
- *
- * @access private
- * @return mixed
- */
-function _get_smiley_array()
-{
- if ( ! file_exists(APPPATH.'config/smileys'.EXT))
- {
- return FALSE;
- }
-
- include(APPPATH.'config/smileys'.EXT);
-
- if ( ! isset($smileys) OR ! is_array($smileys))
- {
- return FALSE;
- }
-
- return $smileys;
-}
-
-
-
-
+
+ function insert_smiley(smiley)
+ {
+ document.{$form_name}.{$form_field}.value += " " + smiley;
+ }
+
+EOF;
+}
+
+// ------------------------------------------------------------------------
+
+/**
+ * Get Clickable Smileys
+ *
+ * Returns an array of image tag links that can be clicked to be inserted
+ * into a form field.
+ *
+ * @access public
+ * @param string the URL to the folder containing the smiley images
+ * @return array
+ */
+function get_clickable_smileys($image_url = '', $smileys = NULL)
+{
+ if ( ! is_array($smileys))
+ {
+ if (FALSE === ($smileys = _get_smiley_array()))
+ {
+ return $str;
+ }
+ }
+
+ // Add a trailing slash to the file path if needed
+ $image_url = preg_replace("/(.+?)\/*$/", "\\1/", $image_url);
+
+ $used = array();
+ foreach ($smileys as $key => $val)
+ {
+ // Keep duplicates from being used, which can happen if the
+ // mapping array contains multiple identical replacements. For example:
+ // :-) and :) might be replaced with the same image so both smileys
+ // will be in the array.
+ if (isset($used[$smileys[$key][0]]))
+ {
+ continue;
+ }
+
+ $link[] = "";
+
+ $used[$smileys[$key][0]] = TRUE;
+ }
+
+ return $link;
+}
+
+// ------------------------------------------------------------------------
+
+/**
+ * Parse Smileys
+ *
+ * Takes a string as input and swaps any contained smileys for the actual image
+ *
+ * @access public
+ * @param string the text to be parsed
+ * @param string the URL to the folder containing the smiley images
+ * @return string
+ */
+function parse_smileys($str = '', $image_url = '', $smileys = NULL)
+{
+ if ($image_url == '')
+ {
+ return $str;
+ }
+
+ if ( ! is_array($smileys))
+ {
+ if (FALSE === ($smileys = _get_smiley_array()))
+ {
+ return $str;
+ }
+ }
+
+ // Add a trailing slash to the file path if needed
+ $image_url = preg_replace("/(.+?)\/*$/", "\\1/", $image_url);
+
+ foreach ($smileys as $key => $val)
+ {
+ $str = str_replace($key, "", $str);
+ }
+
+ return $str;
+}
+
+// ------------------------------------------------------------------------
+
+/**
+ * Get Smiley Array
+ *
+ * Fetches the config/smiley.php file
+ *
+ * @access private
+ * @return mixed
+ */
+function _get_smiley_array()
+{
+ if ( ! file_exists(APPPATH.'config/smileys'.EXT))
+ {
+ return FALSE;
+ }
+
+ include(APPPATH.'config/smileys'.EXT);
+
+ if ( ! isset($smileys) OR ! is_array($smileys))
+ {
+ return FALSE;
+ }
+
+ return $smileys;
+}
+
+
+
+
?>
\ No newline at end of file
diff --git a/system/helpers/string_helper.php b/system/helpers/string_helper.php
index c0a8854dc..04c3a592a 100644
--- a/system/helpers/string_helper.php
+++ b/system/helpers/string_helper.php
@@ -1,12 +1,12 @@
= $n)
- {
- return trim($out).$end_char;
- }
- }
-}
-
-// ------------------------------------------------------------------------
-
-/**
- * High ASCII to Entities
- *
- * Converts High ascii text and MS Word special characters to character entities
- *
- * @access public
- * @param string
- * @return string
- */
-function ascii_to_entities($str)
-{
- $count = 1;
- $out = '';
- $temp = array();
-
- for ($i = 0, $s = strlen($str); $i < $s; $i++)
- {
- $ordinal = ord($str[$i]);
-
- if ($ordinal < 128)
- {
- $out .= $str[$i];
- }
- else
- {
- if (count($temp) == 0)
- {
- $count = ($ordinal < 224) ? 2 : 3;
- }
-
- $temp[] = $ordinal;
-
- if (count($temp) == $count)
- {
- $number = ($count == 3) ? (($temp['0'] % 16) * 4096) + (($temp['1'] % 64) * 64) + ($temp['2'] % 64) : (($temp['0'] % 32) * 64) + ($temp['1'] % 64);
-
- $out .= ''.$number.';';
- $count = 1;
- $temp = array();
- }
- }
- }
-
- return $out;
-}
-
-// ------------------------------------------------------------------------
-
-/**
- * Entities to ASCII
- *
- * Converts character entities back to ASCII
- *
- * @access public
- * @param string
- * @param bool
- * @return string
- */
-function entities_to_ascii($str, $all = TRUE)
-{
- if (preg_match_all('/\(\d+)\;/', $str, $matches))
- {
- for ($i = 0, $s = count($matches['0']); $i < $s; $i++)
- {
- $digits = $matches['1'][$i];
-
- $out = '';
-
- if ($digits < 128)
- {
- $out .= chr($digits);
-
- }
- elseif ($digits < 2048)
- {
- $out .= chr(192 + (($digits - ($digits % 64)) / 64));
- $out .= chr(128 + ($digits % 64));
- }
- else
- {
- $out .= chr(224 + (($digits - ($digits % 4096)) / 4096));
- $out .= chr(128 + ((($digits % 4096) - ($digits % 64)) / 64));
- $out .= chr(128 + ($digits % 64));
- }
-
- $str = str_replace($matches['0'][$i], $out, $str);
- }
- }
-
- if ($all)
- {
- $str = str_replace(array("&", "<", ">", """, "'", "-"),
- array("&","<",">","\"", "'", "-"),
- $str);
- }
-
- return $str;
-}
-
-// ------------------------------------------------------------------------
-
-/**
- * Word Censoring Function
- *
- * Supply a string and an array of disallowed words and any
- * matched words will be converted to #### or to the replacement
- * word you've submitted.
- *
- * @access public
- * @param string the text string
- * @param string the array of censoered words
- * @param string the optional replacement value
- * @return string
- */
-function word_censor($str, $censored, $replacement = '')
-{
- if ( ! is_array($censored))
- {
- return $str;
- }
-
- $str = ' '.$str.' ';
- foreach ($censored as $badword)
- {
- if ($replacement != '')
- {
- $str = preg_replace("/\b(".str_replace('\*', '\w*?', preg_quote($badword)).")\b/i", $replacement, $str);
- }
- else
- {
- $str = preg_replace("/\b(".str_replace('\*', '\w*?', preg_quote($badword)).")\b/ie", "str_repeat('#', strlen('\\1'))", $str);
- }
- }
-
- return trim($str);
-}
-
-// ------------------------------------------------------------------------
-
-/**
- * Code Highlighter
- *
- * Colorizes code strings
- *
- * @access public
- * @param string the text string
- * @return string
- */
-function highlight_code($str)
-{
- // The highlight string function encodes and highlights
- // brackets so we need them to start raw
- $str = str_replace(array('<', '>'), array('<', '>'), $str);
-
- // Replace any existing PHP tags to temporary markers so they don't accidentally
- // break the string out of PHP, and thus, thwart the highlighting.
-
- $str = str_replace(array('<?php', '?>', '\\'), array('phptagopen', 'phptagclose', 'backslashtmp'), $str);
-
- // The highlight_string function requires that the text be surrounded
- // by PHP tags. Since we don't know if A) the submitted text has PHP tags,
- // or B) whether the PHP tags enclose the entire string, we will add our
- // own PHP tags around the string along with some markers to make replacement easier later
-
- $str = '';
-
- // All the magic happens here, baby!
- $str = highlight_string($str, TRUE);
-
- // Prior to PHP 5, the highlight function used icky font tags
- // so we'll replace them with span tags.
- if (abs(phpversion()) < 5)
- {
- $str = str_replace(array(''), array(''), $str);
- $str = preg_replace('#color="(.*?)"#', 'style="color: \\1"', $str);
- }
-
- // Remove our artificially added PHP
- $str = preg_replace("#\.+?//tempstart\ \#is", "\n", $str);
- $str = preg_replace("#\.+?//tempstart\ #is", "\n", $str);
- $str = preg_replace("#//tempend.+#is", "\n", $str);
-
- // Replace our markers back to PHP tags.
- $str = str_replace(array('phptagopen', 'phptagclose', 'backslashtmp'), array('<?php', '?>', '\\'), $str); //
-
- return $str;
-}
-
-// ------------------------------------------------------------------------
-
-/**
- * Phrase Highlighter
- *
- * Highlights a phrase within a text string
- *
- * @access public
- * @param string the text string
- * @param string the phrase you'd like to highlight
- * @param string the openging tag to precede the phrase with
- * @param string the closing tag to end the phrase with
- * @return string
- */
-function highlight_phrase($str, $phrase, $tag_open = '', $tag_close = '')
-{
- if ($str == '')
- {
- return '';
- }
-
- if ($phrase != '')
- {
- return preg_replace('/('.preg_quote($phrase).')/i', $tag_open."\\1".$tag_close, $str);
- }
-
- return $str;
-}
-
-// ------------------------------------------------------------------------
-
-/**
- * Word Wrap
- *
- * Wraps text at the specified character. Maintains the integrity of words.
- * Anything placed between {unwrap}{/unwrap} will not be word wrapped, nor
- * will URLs.
- *
- * @access public
- * @param string the text string
- * @param integer the number of characters to wrap at
- * @return string
- */
-function word_wrap($str, $charlim = '76')
-{
- // Se the character limit
- if ( ! is_numeric($charlim))
- $charlim = 76;
-
- // Reduce multiple spaces
- $str = preg_replace("| +|", " ", $str);
-
- // Standardize newlines
- $str = preg_replace("/\r\n|\r/", "\n", $str);
-
- // If the current word is surrounded by {unwrap} tags we'll
- // strip the entire chunk and replace it with a marker.
- $unwrap = array();
- if (preg_match_all("|(\{unwrap\}.+?\{/unwrap\})|s", $str, $matches))
- {
- for ($i = 0; $i < count($matches['0']); $i++)
- {
- $unwrap[] = $matches['1'][$i];
- $str = str_replace($matches['1'][$i], "{{unwrapped".$i."}}", $str);
- }
- }
-
- // Use PHP's native function to do the initial wordwrap.
- // We set the cut flag to FALSE so that any individual words that are
- // too long get left alone. In the next step we'll deal with them.
- $str = wordwrap($str, $charlim, "\n", FALSE);
-
- // Split the string into individual lines of text and cycle through them
- $output = "";
- foreach (explode("\n", $str) as $line)
- {
- // Is the line within the allowed character count?
- // If so we'll join it to the output and continue
- if (strlen($line) <= $charlim)
- {
- $output .= $line."\n";
- continue;
- }
-
- $temp = '';
- while((strlen($line)) > $charlim)
- {
- // If the over-length word is a URL we won't wrap it
- if (preg_match("!\[url.+\]|://|wwww.!", $line))
- {
- break;
- }
-
- // Trim the word down
- $temp .= substr($line, 0, $charlim-1);
- $line = substr($line, $charlim-1);
- }
-
- // If $temp contains data it means we had to split up an over-length
- // word into smaller chunks so we'll add it back to our current line
- if ($temp != '')
- {
- $output .= $temp.$this->newline.$line;
- }
- else
- {
- $output .= $line;
- }
-
- $output .= "\n";
- }
-
- // Put our markers back
- if (count($unwrap) > 0)
- {
- foreach ($unwrap as $key => $val)
- {
- $output = str_replace("{{unwrapped".$key."}}", $val, $output);
- }
- }
-
- // Remove the unwrap tags
- $output = str_replace(array('{unwrap}', '{/unwrap}'), '', $output);
-
- return $output;
-}
-
-
+= $n)
+ {
+ return trim($out).$end_char;
+ }
+ }
+}
+
+// ------------------------------------------------------------------------
+
+/**
+ * High ASCII to Entities
+ *
+ * Converts High ascii text and MS Word special characters to character entities
+ *
+ * @access public
+ * @param string
+ * @return string
+ */
+function ascii_to_entities($str)
+{
+ $count = 1;
+ $out = '';
+ $temp = array();
+
+ for ($i = 0, $s = strlen($str); $i < $s; $i++)
+ {
+ $ordinal = ord($str[$i]);
+
+ if ($ordinal < 128)
+ {
+ $out .= $str[$i];
+ }
+ else
+ {
+ if (count($temp) == 0)
+ {
+ $count = ($ordinal < 224) ? 2 : 3;
+ }
+
+ $temp[] = $ordinal;
+
+ if (count($temp) == $count)
+ {
+ $number = ($count == 3) ? (($temp['0'] % 16) * 4096) + (($temp['1'] % 64) * 64) + ($temp['2'] % 64) : (($temp['0'] % 32) * 64) + ($temp['1'] % 64);
+
+ $out .= ''.$number.';';
+ $count = 1;
+ $temp = array();
+ }
+ }
+ }
+
+ return $out;
+}
+
+// ------------------------------------------------------------------------
+
+/**
+ * Entities to ASCII
+ *
+ * Converts character entities back to ASCII
+ *
+ * @access public
+ * @param string
+ * @param bool
+ * @return string
+ */
+function entities_to_ascii($str, $all = TRUE)
+{
+ if (preg_match_all('/\(\d+)\;/', $str, $matches))
+ {
+ for ($i = 0, $s = count($matches['0']); $i < $s; $i++)
+ {
+ $digits = $matches['1'][$i];
+
+ $out = '';
+
+ if ($digits < 128)
+ {
+ $out .= chr($digits);
+
+ }
+ elseif ($digits < 2048)
+ {
+ $out .= chr(192 + (($digits - ($digits % 64)) / 64));
+ $out .= chr(128 + ($digits % 64));
+ }
+ else
+ {
+ $out .= chr(224 + (($digits - ($digits % 4096)) / 4096));
+ $out .= chr(128 + ((($digits % 4096) - ($digits % 64)) / 64));
+ $out .= chr(128 + ($digits % 64));
+ }
+
+ $str = str_replace($matches['0'][$i], $out, $str);
+ }
+ }
+
+ if ($all)
+ {
+ $str = str_replace(array("&", "<", ">", """, "'", "-"),
+ array("&","<",">","\"", "'", "-"),
+ $str);
+ }
+
+ return $str;
+}
+
+// ------------------------------------------------------------------------
+
+/**
+ * Word Censoring Function
+ *
+ * Supply a string and an array of disallowed words and any
+ * matched words will be converted to #### or to the replacement
+ * word you've submitted.
+ *
+ * @access public
+ * @param string the text string
+ * @param string the array of censoered words
+ * @param string the optional replacement value
+ * @return string
+ */
+function word_censor($str, $censored, $replacement = '')
+{
+ if ( ! is_array($censored))
+ {
+ return $str;
+ }
+
+ $str = ' '.$str.' ';
+ foreach ($censored as $badword)
+ {
+ if ($replacement != '')
+ {
+ $str = preg_replace("/\b(".str_replace('\*', '\w*?', preg_quote($badword)).")\b/i", $replacement, $str);
+ }
+ else
+ {
+ $str = preg_replace("/\b(".str_replace('\*', '\w*?', preg_quote($badword)).")\b/ie", "str_repeat('#', strlen('\\1'))", $str);
+ }
+ }
+
+ return trim($str);
+}
+
+// ------------------------------------------------------------------------
+
+/**
+ * Code Highlighter
+ *
+ * Colorizes code strings
+ *
+ * @access public
+ * @param string the text string
+ * @return string
+ */
+function highlight_code($str)
+{
+ // The highlight string function encodes and highlights
+ // brackets so we need them to start raw
+ $str = str_replace(array('<', '>'), array('<', '>'), $str);
+
+ // Replace any existing PHP tags to temporary markers so they don't accidentally
+ // break the string out of PHP, and thus, thwart the highlighting.
+
+ $str = str_replace(array('<?php', '?>', '\\'), array('phptagopen', 'phptagclose', 'backslashtmp'), $str);
+
+ // The highlight_string function requires that the text be surrounded
+ // by PHP tags. Since we don't know if A) the submitted text has PHP tags,
+ // or B) whether the PHP tags enclose the entire string, we will add our
+ // own PHP tags around the string along with some markers to make replacement easier later
+
+ $str = '';
+
+ // All the magic happens here, baby!
+ $str = highlight_string($str, TRUE);
+
+ // Prior to PHP 5, the highlight function used icky font tags
+ // so we'll replace them with span tags.
+ if (abs(phpversion()) < 5)
+ {
+ $str = str_replace(array(''), array(''), $str);
+ $str = preg_replace('#color="(.*?)"#', 'style="color: \\1"', $str);
+ }
+
+ // Remove our artificially added PHP
+ $str = preg_replace("#\.+?//tempstart\ \#is", "\n", $str);
+ $str = preg_replace("#\.+?//tempstart\ #is", "\n", $str);
+ $str = preg_replace("#//tempend.+#is", "\n", $str);
+
+ // Replace our markers back to PHP tags.
+ $str = str_replace(array('phptagopen', 'phptagclose', 'backslashtmp'), array('<?php', '?>', '\\'), $str); //
+
+ return $str;
+}
+
+// ------------------------------------------------------------------------
+
+/**
+ * Phrase Highlighter
+ *
+ * Highlights a phrase within a text string
+ *
+ * @access public
+ * @param string the text string
+ * @param string the phrase you'd like to highlight
+ * @param string the openging tag to precede the phrase with
+ * @param string the closing tag to end the phrase with
+ * @return string
+ */
+function highlight_phrase($str, $phrase, $tag_open = '', $tag_close = '')
+{
+ if ($str == '')
+ {
+ return '';
+ }
+
+ if ($phrase != '')
+ {
+ return preg_replace('/('.preg_quote($phrase).')/i', $tag_open."\\1".$tag_close, $str);
+ }
+
+ return $str;
+}
+
+// ------------------------------------------------------------------------
+
+/**
+ * Word Wrap
+ *
+ * Wraps text at the specified character. Maintains the integrity of words.
+ * Anything placed between {unwrap}{/unwrap} will not be word wrapped, nor
+ * will URLs.
+ *
+ * @access public
+ * @param string the text string
+ * @param integer the number of characters to wrap at
+ * @return string
+ */
+function word_wrap($str, $charlim = '76')
+{
+ // Se the character limit
+ if ( ! is_numeric($charlim))
+ $charlim = 76;
+
+ // Reduce multiple spaces
+ $str = preg_replace("| +|", " ", $str);
+
+ // Standardize newlines
+ $str = preg_replace("/\r\n|\r/", "\n", $str);
+
+ // If the current word is surrounded by {unwrap} tags we'll
+ // strip the entire chunk and replace it with a marker.
+ $unwrap = array();
+ if (preg_match_all("|(\{unwrap\}.+?\{/unwrap\})|s", $str, $matches))
+ {
+ for ($i = 0; $i < count($matches['0']); $i++)
+ {
+ $unwrap[] = $matches['1'][$i];
+ $str = str_replace($matches['1'][$i], "{{unwrapped".$i."}}", $str);
+ }
+ }
+
+ // Use PHP's native function to do the initial wordwrap.
+ // We set the cut flag to FALSE so that any individual words that are
+ // too long get left alone. In the next step we'll deal with them.
+ $str = wordwrap($str, $charlim, "\n", FALSE);
+
+ // Split the string into individual lines of text and cycle through them
+ $output = "";
+ foreach (explode("\n", $str) as $line)
+ {
+ // Is the line within the allowed character count?
+ // If so we'll join it to the output and continue
+ if (strlen($line) <= $charlim)
+ {
+ $output .= $line."\n";
+ continue;
+ }
+
+ $temp = '';
+ while((strlen($line)) > $charlim)
+ {
+ // If the over-length word is a URL we won't wrap it
+ if (preg_match("!\[url.+\]|://|wwww.!", $line))
+ {
+ break;
+ }
+
+ // Trim the word down
+ $temp .= substr($line, 0, $charlim-1);
+ $line = substr($line, $charlim-1);
+ }
+
+ // If $temp contains data it means we had to split up an over-length
+ // word into smaller chunks so we'll add it back to our current line
+ if ($temp != '')
+ {
+ $output .= $temp.$this->newline.$line;
+ }
+ else
+ {
+ $output .= $line;
+ }
+
+ $output .= "\n";
+ }
+
+ // Put our markers back
+ if (count($unwrap) > 0)
+ {
+ foreach ($unwrap as $key => $val)
+ {
+ $output = str_replace("{{unwrapped".$key."}}", $val, $output);
+ }
+ }
+
+ // Remove the unwrap tags
+ $output = str_replace(array('{unwrap}', '{/unwrap}'), '', $output);
+
+ return $output;
+}
+
+
?>
\ No newline at end of file
diff --git a/system/helpers/typography_helper.php b/system/helpers/typography_helper.php
index 1681fa37c..131358c6a 100644
--- a/system/helpers/typography_helper.php
+++ b/system/helpers/typography_helper.php
@@ -1,540 +1,540 @@
-",$str);
- $ct = count($ex);
-
- $newstr = "";
- for ($i = 0; $i < $ct; $i++)
- {
- if (($i % 2) == 0)
- {
- $newstr .= nl2br($ex[$i]);
- }
- else
- {
- $newstr .= $ex[$i];
- }
-
- if ($ct - 1 != $i)
- $newstr .= "pre>";
- }
-
- return $newstr;
-}
-
-// ------------------------------------------------------------------------
-
-/**
- * Auto Typography Wrapper Function
- *
- *
- * @access public
- * @param string
- * @return string
- */
-function auto_typography($str)
-{
- $TYPE = new Auto_typography();
- return $TYPE->convert($str);
-}
-
-// ------------------------------------------------------------------------
-
-/**
- * Auto Typography Class
- *
- *
- * @access private
- * @category Helpers
- * @author Rick Ellis
- * @author Paul Burdick
- * @link http://www.codeigniter.com/user_guide/helpers/
- */
-class Auto_typography {
-
- // Block level elements that should not be wrapped inside
tags
- var $block_elements = 'div|blockquote|pre|code|h\d|script|ol|un';
-
- // Elements that should not have
and tags within them.
- var $skip_elements = 'pre|ol|ul';
-
- // Tags we want the parser to completely ignore when splitting the string.
- var $ignore_elements = 'a|b|i|em|strong|span|img|li';
-
-
- /**
- * Main Processing Function
- *
- */
- function convert($str)
- {
- if ($str == '')
- {
- return '';
- }
-
- $str = ' '.$str.' ';
-
- // Standardize Newlines to make matching easier
- $str = preg_replace("/(\r\n|\r)/", "\n", $str);
-
- /*
- * Reduce line breaks
- *
- * If there are more than two consecutive line
- * breaks we'll compress them down to a maximum
- * of two since there's no benefit to more.
- *
- */
- $str = preg_replace("/\n\n+/", "\n\n", $str);
-
- /*
- * Convert quotes within tags to temporary marker
- *
- * We don't want quotes converted within
- * tags so we'll temporarily convert them to
- * {@DQ} and {@SQ}
- *
- */
- if (preg_match_all("#\<.+?>#si", $str, $matches))
- {
- for ($i = 0; $i < count($matches['0']); $i++)
- {
- $str = str_replace($matches['0'][$i],
- str_replace(array("'",'"'), array('{@SQ}', '{@DQ}'), $matches['0'][$i]),
- $str);
- }
- }
-
-
- /*
- * Add closing/opening paragraph tags before/after "block" elements
- *
- * Since block elements (like ,
, etc.) do not get
- * wrapped in paragraph tags we will add a closing
tag just before
- * each block element starts and an opening
tag right after the block element
- * ends. Later on we'll do some further clean up.
- *
- */
- $str = preg_replace("#(<.*?)(".$this->block_elements.")(.*?>)#", "
", $str);
-
- /*
- * Convert "ignore" tags to temporary marker
- *
- * The parser splits out the string at every tag
- * it encounters. Certain inline tags, like image
- * tags, links, span tags, etc. will be adversely
- * affected if they are split out so we'll convert
- * the opening < temporarily to: {@TAG}
- *
- */
- $str = preg_replace("#<(/*)(".$this->ignore_elements.")#i", "{@TAG}\\1\\2", $str);
-
- /*
- * Split the string at every tag
- *
- * This creates an array with this prototype:
- *
- * [array]
- * {
- * [0] =
- * [1] = Content contained between the tags
- * [2] =
- * Etc...
- * }
- *
- */
- $chunks = preg_split('/(<(?:[^<>]+(?:"[^"]*"|\'[^\']*\')?)+>)/', $str, -1, PREG_SPLIT_DELIM_CAPTURE|PREG_SPLIT_NO_EMPTY);
-
- /*
- * Build our finalized string
- *
- * We'll cycle through the array, skipping tags,
- * and processing the contained text
- *
- */
- $str = '';
- $process = TRUE;
- foreach ($chunks as $chunk)
- {
- /*
- * Are we dealing with a tag?
- *
- * If so, we'll skip the processing for this cycle.
- * Well also set the "process" flag which allows us
- * to skip
tags and a few other things.
- *
- */
- if (preg_match("#<(/*)(".$this->block_elements.").*?\>#", $chunk, $match))
- {
- if (preg_match("#".$this->skip_elements."#", $match['2']))
- {
- $process = ($match['1'] == '/') ? TRUE : FALSE;
- }
-
- $str .= $chunk;
- continue;
- }
-
- if ($process == FALSE)
- {
- $str .= $chunk;
- continue;
- }
-
- // Convert Newlines into
and tags
- $str .= $this->format_newlines($chunk);
- }
-
- // FINAL CLEAN UP
- // IMPORTANT: DO NOT ALTER THE ORDER OF THE ITEMS BELOW!
-
- /*
- * Clean up paragraph tags before/after "block" elements
- *
- * Earlier we added
tags before/after block level elements.
- * Then, we added paragraph tags around double line breaks. This
- * potentially created incorrectly formatted paragraphs so we'll
- * clean it up here.
- *
- */
- $str = preg_replace("#
#", "\\1\\2\\3", $str);
-
- // Convert Quotes and other characters
- $str = $this->format_characters($str);
-
- // Fix an artifact that happens during the paragraph replacement
- $str = preg_replace('#(
\n*
)#', '', $str);
-
- // If the user submitted their own paragraph tags with class data
- // in them we will retain them instead of using our tags.
- $str = preg_replace('#()
#', "\\1", $str);
-
- // Final clean up
- $str = str_replace(
- array(
- '
tags
+ var $block_elements = 'div|blockquote|pre|code|h\d|script|ol|un';
+
+ // Elements that should not have
and tags within them.
+ var $skip_elements = 'pre|ol|ul';
+
+ // Tags we want the parser to completely ignore when splitting the string.
+ var $ignore_elements = 'a|b|i|em|strong|span|img|li';
+
+
+ /**
+ * Main Processing Function
+ *
+ */
+ function convert($str)
+ {
+ if ($str == '')
+ {
+ return '';
+ }
+
+ $str = ' '.$str.' ';
+
+ // Standardize Newlines to make matching easier
+ $str = preg_replace("/(\r\n|\r)/", "\n", $str);
+
+ /*
+ * Reduce line breaks
+ *
+ * If there are more than two consecutive line
+ * breaks we'll compress them down to a maximum
+ * of two since there's no benefit to more.
+ *
+ */
+ $str = preg_replace("/\n\n+/", "\n\n", $str);
+
+ /*
+ * Convert quotes within tags to temporary marker
+ *
+ * We don't want quotes converted within
+ * tags so we'll temporarily convert them to
+ * {@DQ} and {@SQ}
+ *
+ */
+ if (preg_match_all("#\<.+?>#si", $str, $matches))
+ {
+ for ($i = 0; $i < count($matches['0']); $i++)
+ {
+ $str = str_replace($matches['0'][$i],
+ str_replace(array("'",'"'), array('{@SQ}', '{@DQ}'), $matches['0'][$i]),
+ $str);
+ }
+ }
+
+
+ /*
+ * Add closing/opening paragraph tags before/after "block" elements
+ *
+ * Since block elements (like ,
, etc.) do not get
+ * wrapped in paragraph tags we will add a closing
tag just before
+ * each block element starts and an opening
tag right after the block element
+ * ends. Later on we'll do some further clean up.
+ *
+ */
+ $str = preg_replace("#(<.*?)(".$this->block_elements.")(.*?>)#", "
", $str);
+
+ /*
+ * Convert "ignore" tags to temporary marker
+ *
+ * The parser splits out the string at every tag
+ * it encounters. Certain inline tags, like image
+ * tags, links, span tags, etc. will be adversely
+ * affected if they are split out so we'll convert
+ * the opening < temporarily to: {@TAG}
+ *
+ */
+ $str = preg_replace("#<(/*)(".$this->ignore_elements.")#i", "{@TAG}\\1\\2", $str);
+
+ /*
+ * Split the string at every tag
+ *
+ * This creates an array with this prototype:
+ *
+ * [array]
+ * {
+ * [0] =
+ * [1] = Content contained between the tags
+ * [2] =
+ * Etc...
+ * }
+ *
+ */
+ $chunks = preg_split('/(<(?:[^<>]+(?:"[^"]*"|\'[^\']*\')?)+>)/', $str, -1, PREG_SPLIT_DELIM_CAPTURE|PREG_SPLIT_NO_EMPTY);
+
+ /*
+ * Build our finalized string
+ *
+ * We'll cycle through the array, skipping tags,
+ * and processing the contained text
+ *
+ */
+ $str = '';
+ $process = TRUE;
+ foreach ($chunks as $chunk)
+ {
+ /*
+ * Are we dealing with a tag?
+ *
+ * If so, we'll skip the processing for this cycle.
+ * Well also set the "process" flag which allows us
+ * to skip
tags and a few other things.
+ *
+ */
+ if (preg_match("#<(/*)(".$this->block_elements.").*?\>#", $chunk, $match))
+ {
+ if (preg_match("#".$this->skip_elements."#", $match['2']))
+ {
+ $process = ($match['1'] == '/') ? TRUE : FALSE;
+ }
+
+ $str .= $chunk;
+ continue;
+ }
+
+ if ($process == FALSE)
+ {
+ $str .= $chunk;
+ continue;
+ }
+
+ // Convert Newlines into
and tags
+ $str .= $this->format_newlines($chunk);
+ }
+
+ // FINAL CLEAN UP
+ // IMPORTANT: DO NOT ALTER THE ORDER OF THE ITEMS BELOW!
+
+ /*
+ * Clean up paragraph tags before/after "block" elements
+ *
+ * Earlier we added
tags before/after block level elements.
+ * Then, we added paragraph tags around double line breaks. This
+ * potentially created incorrectly formatted paragraphs so we'll
+ * clean it up here.
+ *
+ */
+ $str = preg_replace("#
#", "\\1\\2\\3", $str);
+
+ // Convert Quotes and other characters
+ $str = $this->format_characters($str);
+
+ // Fix an artifact that happens during the paragraph replacement
+ $str = preg_replace('#(
\n*
)#', '', $str);
+
+ // If the user submitted their own paragraph tags with class data
+ // in them we will retain them instead of using our tags.
+ $str = preg_replace('#()
#', "\\1", $str);
+
+ // Final clean up
+ $str = str_replace(
+ array(
+ '
-
\ No newline at end of file
--
cgit v1.2.3-24-g4f1b
From cc1be0f6fbf032896b5b1f6373cb247df648f6c8 Mon Sep 17 00:00:00 2001
From: Derek Jones
Date: Fri, 27 Jun 2008 17:14:46 +0000
Subject: Moved the
\n".$extra;
+ return "
".$extra;
}
}
@@ -503,7 +508,7 @@ if ( ! function_exists('form_close'))
{
function form_close($extra = '')
{
- return "
\n".$extra;
+ return "".$extra;
}
}
diff --git a/system/helpers/html_helper.php b/system/helpers/html_helper.php
index 7a61055f7..c3f0fbc29 100644
--- a/system/helpers/html_helper.php
+++ b/system/helpers/html_helper.php
@@ -274,7 +274,7 @@ if ( ! function_exists('link_tag'))
}
}
- $link .= "/>\n";
+ $link .= "/>";
}
else
{
@@ -303,7 +303,7 @@ if ( ! function_exists('link_tag'))
$link .= 'title="'.$title.'" ';
}
- $link .= '/>'."\n";
+ $link .= '/>'."";
}
--
cgit v1.2.3-24-g4f1b
From 8b5d42b3fc1eb9bb7ef5133220340a1418501460 Mon Sep 17 00:00:00 2001
From: Derek Allard
Date: Mon, 21 Jul 2008 12:02:57 +0000
Subject: removing stray quotes
---
system/helpers/html_helper.php | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
(limited to 'system/helpers')
diff --git a/system/helpers/html_helper.php b/system/helpers/html_helper.php
index c3f0fbc29..6d74c6d19 100644
--- a/system/helpers/html_helper.php
+++ b/system/helpers/html_helper.php
@@ -303,7 +303,7 @@ if ( ! function_exists('link_tag'))
$link .= 'title="'.$title.'" ';
}
- $link .= '/>'."";
+ $link .= '/>';
}
--
cgit v1.2.3-24-g4f1b
From 17756a07a877436d520edb87813e13b860ace169 Mon Sep 17 00:00:00 2001
From: Derek Jones
Date: Thu, 7 Aug 2008 00:01:09 +0000
Subject: tightened human time stamp validation regex
---
system/helpers/date_helper.php | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
(limited to 'system/helpers')
diff --git a/system/helpers/date_helper.php b/system/helpers/date_helper.php
index 095e460a9..a82450aa1 100644
--- a/system/helpers/date_helper.php
+++ b/system/helpers/date_helper.php
@@ -442,7 +442,7 @@ if ( ! function_exists('human_to_unix'))
$datestr = trim($datestr);
$datestr = preg_replace("/\040+/", "\040", $datestr);
- if ( ! ereg("^[0-9]{2,4}\-[0-9]{1,2}\-[0-9]{1,2}\040[0-9]{1,2}:[0-9]{1,2}.*$", $datestr))
+ if ( ! preg_match('/^[0-9]{2,4}\-[0-9]{1,2}\-[0-9]{1,2}\s[0-9]{1,2}:[0-9]{1,2}(?::[0-9]{1,2})?(?:\s[AP]M)?$/i', $datestr))
{
return FALSE;
}
--
cgit v1.2.3-24-g4f1b
From f388511b8596558ef560eca6a99bd435805e2d59 Mon Sep 17 00:00:00 2001
From: Rick Ellis
Date: Tue, 12 Aug 2008 05:32:25 +0000
Subject: Added newline character in between hidden fields
---
system/helpers/form_helper.php | 1 +
1 file changed, 1 insertion(+)
(limited to 'system/helpers')
diff --git a/system/helpers/form_helper.php b/system/helpers/form_helper.php
index 21b7df42f..0ad57d532 100644
--- a/system/helpers/form_helper.php
+++ b/system/helpers/form_helper.php
@@ -114,6 +114,7 @@ if ( ! function_exists('form_hidden'))
foreach ($name as $name => $value)
{
+ $form .= "\n";
$form .= '';
}
--
cgit v1.2.3-24-g4f1b
From c9a4f2800a7d21e338ddd755e111f4c85a09ff79 Mon Sep 17 00:00:00 2001
From: Derek Jones
Date: Wed, 13 Aug 2008 20:42:56 +0000
Subject: updated time zone list and offsets to match the world's current time
zones
---
system/helpers/date_helper.php | 72 ++++++++++++++++++++++++------------------
1 file changed, 41 insertions(+), 31 deletions(-)
(limited to 'system/helpers')
diff --git a/system/helpers/date_helper.php b/system/helpers/date_helper.php
index a82450aa1..401d64306 100644
--- a/system/helpers/date_helper.php
+++ b/system/helpers/date_helper.php
@@ -551,37 +551,47 @@ if ( ! function_exists('timezones'))
// Note: Don't change the order of these even though
// some items appear to be in the wrong order
- $zones = array(
- 'UM12' => -12,
- 'UM11' => -11,
- 'UM10' => -10,
- 'UM9' => -9,
- 'UM8' => -8,
- 'UM7' => -7,
- 'UM6' => -6,
- 'UM5' => -5,
- 'UM4' => -4,
- 'UM25' => -2.5,
- 'UM3' => -3,
- 'UM2' => -2,
- 'UM1' => -1,
- 'UTC' => 0,
- 'UP1' => +1,
- 'UP2' => +2,
- 'UP3' => +3,
- 'UP25' => +2.5,
- 'UP4' => +4,
- 'UP35' => +3.5,
- 'UP5' => +5,
- 'UP45' => +4.5,
- 'UP6' => +6,
- 'UP7' => +7,
- 'UP8' => +8,
- 'UP9' => +9,
- 'UP85' => +8.5,
- 'UP10' => +10,
- 'UP11' => +11,
- 'UP12' => +12
+ $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
);
if ($tz == '')
--
cgit v1.2.3-24-g4f1b
From 9e2c04cf14fe8fb27d5ac520c95c68336255b2db Mon Sep 17 00:00:00 2001
From: Rick Ellis
Date: Tue, 19 Aug 2008 22:12:26 +0000
Subject: Added current_url() and uri_string() functions to the URL helper
---
system/helpers/url_helper.php | 42 ++++++++++++++++++++++++++++++++++++++++--
1 file changed, 40 insertions(+), 2 deletions(-)
(limited to 'system/helpers')
diff --git a/system/helpers/url_helper.php b/system/helpers/url_helper.php
index 16dd3e021..e5b02972d 100644
--- a/system/helpers/url_helper.php
+++ b/system/helpers/url_helper.php
@@ -45,7 +45,7 @@ if ( ! function_exists('site_url'))
return $CI->config->site_url($uri);
}
}
-
+
// ------------------------------------------------------------------------
/**
@@ -64,7 +64,45 @@ if ( ! function_exists('base_url'))
return $CI->config->slash_item('base_url');
}
}
-
+
+// ------------------------------------------------------------------------
+
+/**
+ * Current URL
+ *
+ * Returns the full URL (including segments) of the page where this
+ * function is placed
+ *
+ * @access public
+ * @return string
+ */
+if ( ! function_exists('current_url'))
+{
+ function current_url()
+ {
+ $CI =& get_instance();
+ return $CI->config->site_url($CI->uri->uri_string());
+ }
+}
+
+// ------------------------------------------------------------------------
+/**
+ * URL String
+ *
+ * Returns the URI segments.
+ *
+ * @access public
+ * @return string
+ */
+if ( ! function_exists('uri_string'))
+{
+ function uri_string()
+ {
+ $CI =& get_instance();
+ return $CI->uri->uri_string();
+ }
+}
+
// ------------------------------------------------------------------------
/**
--
cgit v1.2.3-24-g4f1b
From 993925b47a0bfb08e79961c47bcc3d247a03a5dd Mon Sep 17 00:00:00 2001
From: Derek Allard
Date: Thu, 21 Aug 2008 12:43:31 +0000
Subject: whitespace fixes a minor re-ordering of the changelog
---
system/helpers/file_helper.php | 104 ++++++++++++++++++------------------
system/helpers/form_helper.php | 12 ++---
system/helpers/inflector_helper.php | 84 ++++++++++++++---------------
system/helpers/smiley_helper.php | 34 ++++++------
system/helpers/string_helper.php | 4 +-
5 files changed, 119 insertions(+), 119 deletions(-)
(limited to 'system/helpers')
diff --git a/system/helpers/file_helper.php b/system/helpers/file_helper.php
index 86c5c09db..b59443c0e 100644
--- a/system/helpers/file_helper.php
+++ b/system/helpers/file_helper.php
@@ -262,60 +262,60 @@ if ( ! function_exists('get_dir_file_info'))
* Options are: name, server_path, size, date, readable, writable, executable, fileperms
* Returns FALSE if the file cannot be found.
*
-* @access public
-* @param string path to file
-* @param mixed array or comma separated string of information returned
-* @return array
-*/
+* @access public
+* @param string path to file
+* @param mixed array or comma separated string of information returned
+* @return array
+*/
if ( ! function_exists('get_file_info'))
{
- function get_file_info($file, $returned_values = array('name', 'server_path', 'size', 'date'))
- {
-
- if ( ! file_exists($file))
- {
- return FALSE;
- }
-
- if (is_string($returned_values))
- {
- $returned_values = explode(',', $returned_values);
- }
-
- foreach ($returned_values as $key)
- {
- switch ($key)
- {
- case 'name':
- $fileinfo['name'] = substr(strrchr($file, '/'), 1);
- break;
- case 'server_path':
- $fileinfo['server_path'] = $file;
- break;
- case 'size':
- $fileinfo['size'] = filesize($file);
- break;
- case 'date':
- $fileinfo['date'] = filectime($file);
- break;
- case 'readable':
- $fileinfo['readable'] = is_readable($file);
- break;
- case 'writable':
- // There are known problems using is_weritable on IIS. It may not be reliable - consider fileperms()
- $fileinfo['writable'] = is_writable($file);
- break;
- case 'executable':
- $fileinfo['executable'] = is_executable($file);
- break;
- case 'fileperms':
- $fileinfo['fileperms'] = fileperms($file);
- break;
- }
- }
-
- return $fileinfo;
- }
+ function get_file_info($file, $returned_values = array('name', 'server_path', 'size', 'date'))
+ {
+
+ if ( ! file_exists($file))
+ {
+ return FALSE;
+ }
+
+ if (is_string($returned_values))
+ {
+ $returned_values = explode(',', $returned_values);
+ }
+
+ foreach ($returned_values as $key)
+ {
+ switch ($key)
+ {
+ case 'name':
+ $fileinfo['name'] = substr(strrchr($file, '/'), 1);
+ break;
+ case 'server_path':
+ $fileinfo['server_path'] = $file;
+ break;
+ case 'size':
+ $fileinfo['size'] = filesize($file);
+ break;
+ case 'date':
+ $fileinfo['date'] = filectime($file);
+ break;
+ case 'readable':
+ $fileinfo['readable'] = is_readable($file);
+ break;
+ case 'writable':
+ // There are known problems using is_weritable on IIS. It may not be reliable - consider fileperms()
+ $fileinfo['writable'] = is_writable($file);
+ break;
+ case 'executable':
+ $fileinfo['executable'] = is_executable($file);
+ break;
+ case 'fileperms':
+ $fileinfo['fileperms'] = fileperms($file);
+ break;
+ }
+ }
+
+ return $fileinfo;
+ }
}
// --------------------------------------------------------------------
diff --git a/system/helpers/form_helper.php b/system/helpers/form_helper.php
index 0ad57d532..0c74ac0ff 100644
--- a/system/helpers/form_helper.php
+++ b/system/helpers/form_helper.php
@@ -53,7 +53,7 @@ if ( ! function_exists('form_open'))
$form = '
(( ! is_array($data)) ? $data : ''), 'cols' => '90', 'rows' => '12');
- if ( ! is_array($data) OR ! isset($data['value']))
+ if ( ! is_array($data) OR ! isset($data['value']))
{
$val = $value;
}
- else
+ else
{
$val = $data['value'];
unset($data['value']); // textareas don't use the value attribute
@@ -466,7 +466,7 @@ if ( ! function_exists('form_fieldset'))
{
$fieldset = "
0)
diff --git a/system/helpers/inflector_helper.php b/system/helpers/inflector_helper.php
index 49ba542a1..e362a3fd7 100644
--- a/system/helpers/inflector_helper.php
+++ b/system/helpers/inflector_helper.php
@@ -41,28 +41,28 @@ if ( ! function_exists('singular'))
{
function singular($str)
{
- $str = strtolower(trim($str));
- $end = substr($str, -3);
-
- if ($end == 'ies')
- {
- $str = substr($str, 0, strlen($str)-3).'y';
- }
- elseif ($end == 'ses')
- {
- $str = substr($str, 0, strlen($str)-2);
- }
- else
- {
- $end = substr($str, -1);
-
- if ($end == 's')
- {
- $str = substr($str, 0, strlen($str)-1);
- }
- }
-
- return $str;
+ $str = strtolower(trim($str));
+ $end = substr($str, -3);
+
+ if ($end == 'ies')
+ {
+ $str = substr($str, 0, strlen($str)-3).'y';
+ }
+ elseif ($end == 'ses')
+ {
+ $str = substr($str, 0, strlen($str)-2);
+ }
+ else
+ {
+ $end = substr($str, -1);
+
+ if ($end == 's')
+ {
+ $str = substr($str, 0, strlen($str)-1);
+ }
+ }
+
+ return $str;
}
}
@@ -82,26 +82,26 @@ if ( ! function_exists('plural'))
{
function plural($str, $force = FALSE)
{
- $str = strtolower(trim($str));
- $end = substr($str, -1);
-
- if ($end == 'y')
- {
- $str = substr($str, 0, strlen($str)-1).'ies';
- }
- elseif ($end == 's')
- {
- if ($force == TRUE)
- {
- $str .= 'es';
- }
- }
- else
- {
- $str .= 's';
- }
-
- return $str;
+ $str = strtolower(trim($str));
+ $end = substr($str, -1);
+
+ if ($end == 'y')
+ {
+ $str = substr($str, 0, strlen($str)-1).'ies';
+ }
+ elseif ($end == 's')
+ {
+ if ($force == TRUE)
+ {
+ $str .= 'es';
+ }
+ }
+ else
+ {
+ $str .= 's';
+ }
+
+ return $str;
}
}
diff --git a/system/helpers/smiley_helper.php b/system/helpers/smiley_helper.php
index 8f7543746..efa338467 100644
--- a/system/helpers/smiley_helper.php
+++ b/system/helpers/smiley_helper.php
@@ -36,7 +36,7 @@
* @param string form name
* @param string field name
* @return string
- */
+ */
if ( ! function_exists('js_insert_smiley'))
{
function js_insert_smiley($form_name = '', $form_field = '')
@@ -49,7 +49,7 @@ if ( ! function_exists('js_insert_smiley'))
}
EOF;
- }
+ }
}
// ------------------------------------------------------------------------
@@ -62,7 +62,7 @@ EOF;
* @access public
* @param string the URL to the folder containing the smiley images
* @return array
- */
+ */
if ( ! function_exists('get_clickable_smileys'))
{
function get_clickable_smileys($image_url = '', $smileys = NULL)
@@ -72,12 +72,12 @@ if ( ! function_exists('get_clickable_smileys'))
if (FALSE === ($smileys = _get_smiley_array()))
{
return $smileys;
- }
+ }
}
// Add a trailing slash to the file path if needed
$image_url = preg_replace("/(.+?)\/*$/", "\\1/", $image_url);
-
+
$used = array();
foreach ($smileys as $key => $val)
{
@@ -89,12 +89,12 @@ if ( ! function_exists('get_clickable_smileys'))
{
continue;
}
-
- $link[] = "";
-
+
+ $link[] = "";
+
$used[$smileys[$key][0]] = TRUE;
}
-
+
return $link;
}
}
@@ -110,7 +110,7 @@ if ( ! function_exists('get_clickable_smileys'))
* @param string the text to be parsed
* @param string the URL to the folder containing the smiley images
* @return string
- */
+ */
if ( ! function_exists('parse_smileys'))
{
function parse_smileys($str = '', $image_url = '', $smileys = NULL)
@@ -125,17 +125,17 @@ if ( ! function_exists('parse_smileys'))
if (FALSE === ($smileys = _get_smiley_array()))
{
return $str;
- }
+ }
}
-
+
// Add a trailing slash to the file path if needed
$image_url = preg_replace("/(.+?)\/*$/", "\\1/", $image_url);
foreach ($smileys as $key => $val)
- {
+ {
$str = str_replace($key, "", $str);
}
-
+
return $str;
}
}
@@ -149,7 +149,7 @@ if ( ! function_exists('parse_smileys'))
*
* @access private
* @return mixed
- */
+ */
if ( ! function_exists('_get_smiley_array'))
{
function _get_smiley_array()
@@ -160,12 +160,12 @@ if ( ! function_exists('_get_smiley_array'))
}
include(APPPATH.'config/smileys'.EXT);
-
+
if ( ! isset($smileys) OR ! is_array($smileys))
{
return FALSE;
}
-
+
return $smileys;
}
}
diff --git a/system/helpers/string_helper.php b/system/helpers/string_helper.php
index 7b6becffe..d85d76ca4 100644
--- a/system/helpers/string_helper.php
+++ b/system/helpers/string_helper.php
@@ -46,7 +46,7 @@ if ( ! function_exists('trim_slashes'))
{
function trim_slashes($str)
{
- return trim($str, '/');
+ return trim($str, '/');
}
}
@@ -173,7 +173,7 @@ if ( ! function_exists('reduce_multiples'))
{
$str = trim($str, $character);
}
-
+
return $str;
}
}
--
cgit v1.2.3-24-g4f1b
From 43e0fbb650d05466cd2568b8a2cc1c38849a6b52 Mon Sep 17 00:00:00 2001
From: Rick Ellis
Date: Tue, 26 Aug 2008 19:22:31 +0000
Subject: Added some new functions that work with the new form validation class
---
system/helpers/form_helper.php | 335 +++++++++++++++++++++++++++++++++++++++--
1 file changed, 321 insertions(+), 14 deletions(-)
(limited to 'system/helpers')
diff --git a/system/helpers/form_helper.php b/system/helpers/form_helper.php
index 0c74ac0ff..a96adb97d 100644
--- a/system/helpers/form_helper.php
+++ b/system/helpers/form_helper.php
@@ -53,7 +53,7 @@ if ( ! function_exists('form_open'))
$form = '
'text', 'name' => (( ! is_array($data)) ? $data : ''), 'value' => $value);
- return "";
+ return "";
}
}
@@ -214,17 +214,17 @@ if ( ! function_exists('form_textarea'))
{
$defaults = array('name' => (( ! is_array($data)) ? $data : ''), 'cols' => '90', 'rows' => '12');
- if ( ! is_array($data) OR ! isset($data['value']))
+ if ( ! is_array($data) OR ! isset($data['value']))
{
$val = $value;
}
- else
+ else
{
$val = $data['value'];
unset($data['value']); // textareas don't use the value attribute
}
- return "";
+ return "";
}
}
@@ -248,6 +248,16 @@ if ( ! function_exists('form_dropdown'))
{
$selected = array($selected);
}
+
+ // If no selected state was submitted we will attempt to set it automatically
+ if (count($selected) === 0)
+ {
+ // If the form name appears in the $_POST array we have a winner!
+ if (isset($_POST[$name]))
+ {
+ $selected = array($_POST[$name]);
+ }
+ }
if ($extra != '') $extra = ' '.$extra;
@@ -312,7 +322,7 @@ if ( ! function_exists('form_checkbox'))
unset($defaults['checked']);
}
- return "";
+ return "";
}
}
@@ -359,7 +369,7 @@ if ( ! function_exists('form_submit'))
{
$defaults = array('type' => 'submit', 'name' => (( ! is_array($data)) ? $data : ''), 'value' => $value);
- return "";
+ return "";
}
}
@@ -380,7 +390,7 @@ if ( ! function_exists('form_reset'))
{
$defaults = array('type' => 'reset', 'name' => (( ! is_array($data)) ? $data : ''), 'value' => $value);
- return "";
+ return "";
}
}
@@ -407,7 +417,7 @@ if ( ! function_exists('form_button'))
unset($data['content']); // content is not an attribute
}
- return "";
+ return "";
}
}
@@ -466,7 +476,7 @@ if ( ! function_exists('form_fieldset'))
{
$fieldset = "
$val)
+ {
+ $str[$key] = form_prep($val);
+ }
+
+ return $str;
+ }
+
if ($str === '')
{
return '';
@@ -552,7 +573,256 @@ if ( ! function_exists('form_prep'))
return $str;
}
}
+
+// ------------------------------------------------------------------------
+
+/**
+ * Form Value
+ *
+ * Grabs a value from the POST array for the specified field so you can
+ * re-populate an input field or textarea. If Form Validation
+ * is active it retrieves the info from the validation class
+ *
+ * @access public
+ * @param string
+ * @return mixed
+ */
+if ( ! function_exists('set_value'))
+{
+ function set_value($field = '', $default = '')
+ {
+ if (FALSE === ($OBJ =& _get_validation_object()))
+ {
+ if ( ! isset($_POST[$field]))
+ {
+ return $default;
+ }
+
+ return $_POST[$field];
+ }
+
+ return $OBJ->set_value($field, $default);
+ }
+}
+
+// ------------------------------------------------------------------------
+
+/**
+ * Set Select
+ *
+ * Let's you set the selected value of a ';
-
+
return $form;
}
}
-
+
// ------------------------------------------------------------------------
/**
@@ -292,17 +292,17 @@ if ( ! function_exists('form_dropdown'))
* @param bool
* @param string
* @return string
- */
+ */
if ( ! function_exists('form_checkbox'))
{
function form_checkbox($data = '', $value = '', $checked = FALSE, $extra = '')
{
$defaults = array('type' => 'checkbox', 'name' => (( ! is_array($data)) ? $data : ''), 'value' => $value);
-
+
if (is_array($data) AND array_key_exists('checked', $data))
{
$checked = $data['checked'];
-
+
if ($checked == FALSE)
{
unset($data['checked']);
@@ -312,7 +312,7 @@ if ( ! function_exists('form_checkbox'))
$data['checked'] = 'checked';
}
}
-
+
if ($checked == TRUE)
{
$defaults['checked'] = 'checked';
@@ -325,7 +325,7 @@ if ( ! function_exists('form_checkbox'))
return "";
}
}
-
+
// ------------------------------------------------------------------------
/**
@@ -337,7 +337,7 @@ if ( ! function_exists('form_checkbox'))
* @param bool
* @param string
* @return string
- */
+ */
if ( ! function_exists('form_radio'))
{
function form_radio($data = '', $value = '', $checked = FALSE, $extra = '')
@@ -351,7 +351,7 @@ if ( ! function_exists('form_radio'))
return form_checkbox($data, $value, $checked, $extra);
}
}
-
+
// ------------------------------------------------------------------------
/**
@@ -383,7 +383,7 @@ if ( ! function_exists('form_submit'))
* @param string
* @param string
* @return string
- */
+ */
if ( ! function_exists('form_reset'))
{
function form_reset($data = '', $value = '', $extra = '')
@@ -404,19 +404,19 @@ if ( ! function_exists('form_reset'))
* @param string
* @param string
* @return string
- */
+ */
if ( ! function_exists('form_button'))
{
function form_button($data = '', $content = '', $extra = '')
{
$defaults = array('name' => (( ! is_array($data)) ? $data : ''), 'type' => 'submit');
-
+
if ( is_array($data) AND isset($data['content']))
{
$content = $data['content'];
unset($data['content']); // content is not an attribute
}
-
+
return "";
}
}
@@ -431,19 +431,19 @@ if ( ! function_exists('form_button'))
* @param string The id the label applies to
* @param string Additional attributes
* @return string
- */
+ */
if ( ! function_exists('form_label'))
{
function form_label($label_text = '', $id = '', $attributes = array())
{
$label = ' 0)
{
foreach ($attributes as $key => $val)
@@ -469,7 +469,7 @@ if ( ! function_exists('form_label'))
* @param string The legend text
* @param string Additional attributes
* @return string
- */
+ */
if ( ! function_exists('form_fieldset'))
{
function form_fieldset($legend_text = '', $attributes = array())
@@ -477,9 +477,9 @@ if ( ! function_exists('form_fieldset'))
$fieldset = "
".$extra;
}
}
-
+
// ------------------------------------------------------------------------
/**
@@ -514,7 +514,7 @@ if ( ! function_exists('form_fieldset_close'))
* @access public
* @param string
* @return string
- */
+ */
if ( ! function_exists('form_close'))
{
function form_close($extra = '')
@@ -522,7 +522,7 @@ if ( ! function_exists('form_close'))
return "
".$extra;
}
}
-
+
// ------------------------------------------------------------------------
/**
@@ -533,7 +533,7 @@ if ( ! function_exists('form_close'))
* @access public
* @param string
* @return string
- */
+ */
if ( ! function_exists('form_prep'))
{
function form_prep($str = '')
@@ -545,17 +545,17 @@ if ( ! function_exists('form_prep'))
{
$str[$key] = form_prep($val);
}
-
+
return $str;
}
-
+
if ($str === '')
{
return '';
}
$temp = '__TEMP_AMPERSANDS__';
-
+
// Replace entities to temporary markers so that
// htmlspecialchars won't mess them up
$str = preg_replace("/(\d+);/", "$temp\\1;", $str);
@@ -564,13 +564,13 @@ if ( ! function_exists('form_prep'))
$str = htmlspecialchars($str);
// In case htmlspecialchars misses these.
- $str = str_replace(array("'", '"'), array("'", """), $str);
-
+ $str = str_replace(array("'", '"'), array("'", """), $str);
+
// Decode the temp markers back to entities
$str = preg_replace("/$temp(\d+);/","\\1;",$str);
- $str = preg_replace("/$temp(\w+);/","&\\1;",$str);
-
- return $str;
+ $str = preg_replace("/$temp(\w+);/","&\\1;",$str);
+
+ return $str;
}
}
@@ -586,7 +586,7 @@ if ( ! function_exists('form_prep'))
* @access public
* @param string
* @return mixed
- */
+ */
if ( ! function_exists('set_value'))
{
function set_value($field = '', $default = '')
@@ -597,10 +597,10 @@ if ( ! function_exists('set_value'))
{
return $default;
}
-
+
return $_POST[$field];
}
-
+
return $OBJ->set_value($field, $default);
}
}
@@ -618,7 +618,7 @@ if ( ! function_exists('set_value'))
* @param string
* @param bool
* @return string
- */
+ */
if ( ! function_exists('set_select'))
{
function set_select($field = '', $value = '', $default = FALSE)
@@ -635,9 +635,9 @@ if ( ! function_exists('set_select'))
}
return '';
}
-
+
$field = $_POST[$field];
-
+
if (is_array($field))
{
if ( ! in_array($value, $field))
@@ -652,10 +652,10 @@ if ( ! function_exists('set_select'))
return '';
}
}
-
+
return ' selected="selected"';
}
-
+
return $OBJ->set_select($field, $value, $default);
}
}
@@ -673,7 +673,7 @@ if ( ! function_exists('set_select'))
* @param string
* @param bool
* @return string
- */
+ */
if ( ! function_exists('set_checkbox'))
{
function set_checkbox($field = '', $value = '', $default = FALSE)
@@ -690,7 +690,7 @@ if ( ! function_exists('set_checkbox'))
}
return '';
}
-
+
$field = $_POST[$field];
if (is_array($field))
@@ -707,10 +707,10 @@ if ( ! function_exists('set_checkbox'))
return '';
}
}
-
+
return ' checked="checked"';
}
-
+
return $OBJ->set_checkbox($field, $value, $default);
}
}
@@ -728,7 +728,7 @@ if ( ! function_exists('set_checkbox'))
* @param string
* @param bool
* @return string
- */
+ */
if ( ! function_exists('set_radio'))
{
function set_radio($field = '', $value = '', $default = FALSE)
@@ -745,7 +745,7 @@ if ( ! function_exists('set_radio'))
}
return '';
}
-
+
$field = $_POST[$field];
if (is_array($field))
@@ -762,10 +762,10 @@ if ( ! function_exists('set_radio'))
return '';
}
}
-
+
return ' checked="checked"';
}
-
+
return $OBJ->set_radio($field, $value, $default);
}
}
@@ -783,7 +783,7 @@ if ( ! function_exists('set_radio'))
* @param string
* @param string
* @return string
- */
+ */
if ( ! function_exists('form_error'))
{
function form_error($field = '', $prefix = '', $suffix = '')
@@ -792,7 +792,7 @@ if ( ! function_exists('form_error'))
{
return '';
}
-
+
return $OBJ->error($field, $prefix, $suffix);
}
}
@@ -809,7 +809,7 @@ if ( ! function_exists('form_error'))
* @param string
* @param string
* @return string
- */
+ */
if ( ! function_exists('validation_errors'))
{
function validation_errors($prefix = '', $suffix = '')
@@ -818,7 +818,7 @@ if ( ! function_exists('validation_errors'))
{
return '';
}
-
+
return $OBJ->error_string($prefix, $suffix);
}
}
@@ -834,7 +834,7 @@ if ( ! function_exists('validation_errors'))
* @param array
* @param array
* @return string
- */
+ */
if ( ! function_exists('_parse_form_attributes'))
{
function _parse_form_attributes($attributes, $default)
@@ -849,21 +849,22 @@ if ( ! function_exists('_parse_form_attributes'))
unset($attributes[$key]);
}
}
-
+
if (count($attributes) > 0)
- {
+ {
$default = array_merge($default, $attributes);
}
}
-
+
$att = '';
+
foreach ($default as $key => $val)
{
if ($key == 'value')
{
$val = form_prep($val);
}
-
+
$att .= $key . '="' . $val . '" ';
}
@@ -882,43 +883,43 @@ if ( ! function_exists('_parse_form_attributes'))
* @param mixed
* @param bool
* @return string
- */
+ */
if ( ! function_exists('_attributes_to_string'))
{
function _attributes_to_string($attributes, $formtag = FALSE)
{
- if (is_string($attributes) AND strlen($attributes) > 0)
- {
- if ($formtag == TRUE AND strpos($attributes, 'method=') === FALSE)
- {
- $attributes .= ' method="post"';
- }
-
- return ' '.$attributes;
- }
-
- if (is_object($attributes) AND count($attributes) > 0)
- {
- $attributes = (array)$attributes;
- }
-
- if (is_array($attributes) AND count($attributes) > 0)
- {
- $atts = '';
-
- if ( ! isset($attributes['method']) AND $formtag === TRUE)
- {
- $atts .= ' method="post"';
- }
+ if (is_string($attributes) AND strlen($attributes) > 0)
+ {
+ if ($formtag == TRUE AND strpos($attributes, 'method=') === FALSE)
+ {
+ $attributes .= ' method="post"';
+ }
+
+ return ' '.$attributes;
+ }
- foreach ($attributes as $key => $val)
- {
- $atts .= ' '.$key.'="'.$val.'"';
- }
-
- return $atts;
- }
- }
+ if (is_object($attributes) AND count($attributes) > 0)
+ {
+ $attributes = (array)$attributes;
+ }
+
+ if (is_array($attributes) AND count($attributes) > 0)
+ {
+ $atts = '';
+
+ if ( ! isset($attributes['method']) AND $formtag === TRUE)
+ {
+ $atts .= ' method="post"';
+ }
+
+ foreach ($attributes as $key => $val)
+ {
+ $atts .= ' '.$key.'="'.$val.'"';
+ }
+
+ return $atts;
+ }
+ }
}
// ------------------------------------------------------------------------
@@ -931,28 +932,28 @@ if ( ! function_exists('_attributes_to_string'))
*
* @access private
* @return mixed
- */
+ */
if ( ! function_exists('_get_validation_object'))
-{
+{
function &_get_validation_object()
{
$CI =& get_instance();
-
+
// We set this as a variable since we're returning by reference
$return = FALSE;
-
+
if ( ! isset($CI->load->_ci_classes) OR ! isset($CI->load->_ci_classes['form_validation']))
{
return $return;
}
-
+
$object = $CI->load->_ci_classes['form_validation'];
-
+
if ( ! isset($CI->$object) OR ! is_object($CI->$object))
{
return $return;
}
-
+
return $CI->$object;
}
}
--
cgit v1.2.3-24-g4f1b
From 69db8efaffadfc93ff0eec3a9733793e8b358dfb Mon Sep 17 00:00:00 2001
From: Derek Allard
Date: Thu, 25 Sep 2008 13:04:12 +0000
Subject: Fixed incorrect parenthesis in form_open() function. (#5135) A few
doc typo fixes
---
system/helpers/form_helper.php | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
(limited to 'system/helpers')
diff --git a/system/helpers/form_helper.php b/system/helpers/form_helper.php
index fc2592241..a45faf631 100644
--- a/system/helpers/form_helper.php
+++ b/system/helpers/form_helper.php
@@ -57,7 +57,7 @@ if ( ! function_exists('form_open'))
$form .= '>';
- if (is_array($hidden) AND count($hidden > 0))
+ if (is_array($hidden) AND count($hidden) > 0)
{
$form .= form_hidden($hidden);
}
--
cgit v1.2.3-24-g4f1b
From c0e72b0609827484dc822ded7fcd0a312ed4eb98 Mon Sep 17 00:00:00 2001
From: Derek Jones
Date: Fri, 3 Oct 2008 18:56:06 +0000
Subject: modified how we're performing text highlighting to prevent extra or
missing span tags.
Namely, removed the start and ending markers, as if the code being highlighted would be styled the same, PHP would put it all in the same , so when we removed our own additions, it would remove the needed opening span style
---
system/helpers/text_helper.php | 30 +++++++++++++++---------------
1 file changed, 15 insertions(+), 15 deletions(-)
(limited to 'system/helpers')
diff --git a/system/helpers/text_helper.php b/system/helpers/text_helper.php
index 954eb797a..54ef1b580 100644
--- a/system/helpers/text_helper.php
+++ b/system/helpers/text_helper.php
@@ -274,27 +274,27 @@ if ( ! function_exists('highlight_code'))
array('phptagopen', 'phptagclose', 'asptagopen', 'asptagclose', 'backslashtmp', 'scriptclose'), $str);
// The highlight_string function requires that the text be surrounded
- // by PHP tags. Since we don't know if A) the submitted text has PHP tags,
- // or B) whether the PHP tags enclose the entire string, we will add our
- // own PHP tags around the string along with some markers to make replacement easier later
-
- $str = '';
-
- // All the magic happens here, baby!
+ // by PHP tags, which we will remove later
+ $str = ''; //
+
+ // All the magic happens here, baby!
$str = highlight_string($str, TRUE);
- // Prior to PHP 5, the highlight function used icky font tags
- // so we'll replace them with span tags.
- if (abs(phpversion()) < 5)
+ // Prior to PHP 5, the highligh function used icky tags
+ // so we'll replace them with tags.
+
+ if (abs(PHP_VERSION) < 5)
{
$str = str_replace(array(''), array(''), $str);
$str = preg_replace('#color="(.*?)"#', 'style="color: \\1"', $str);
+ $str = str_replace('<?php ', '', $str);
}
-
- // Remove our artificially added PHP
- $str = preg_replace("#\.+?tempstart\ (?:\)?#is", "\n", $str);
- $str = preg_replace("#tempend.+#is", "\n
", $str);
-
+
+ // Remove our artificially added PHP, and the syntax highlighting that came with it
+ $str = str_replace('<?php ', '', $str);
+ $str = preg_replace('/(.*?)\?><\/span>\n<\/span>\n<\/code>/is', "$1\n\n", $str);
+ $str = preg_replace('/<\/span>/i', '', $str);
+
// Replace our markers back to PHP tags.
$str = str_replace(array('phptagopen', 'phptagclose', 'asptagopen', 'asptagclose', 'backslashtmp', 'scriptclose'),
array('<?', '?>', '<%', '%>', '\\', '</script>'), $str);
--
cgit v1.2.3-24-g4f1b
From 337c74ab2af0dec69659f8c68c82b12c878c1b88 Mon Sep 17 00:00:00 2001
From: Derek Jones
Date: Fri, 3 Oct 2008 19:09:53 +0000
Subject: tweak of temp tag and highlighting replacement to accommodate
environments with different colors specified for highlight_string()
---
system/helpers/text_helper.php | 7 +++----
1 file changed, 3 insertions(+), 4 deletions(-)
(limited to 'system/helpers')
diff --git a/system/helpers/text_helper.php b/system/helpers/text_helper.php
index 54ef1b580..9f13896ae 100644
--- a/system/helpers/text_helper.php
+++ b/system/helpers/text_helper.php
@@ -287,12 +287,11 @@ if ( ! function_exists('highlight_code'))
{
$str = str_replace(array(''), array(''), $str);
$str = preg_replace('#color="(.*?)"#', 'style="color: \\1"', $str);
- $str = str_replace('<?php ', '', $str);
}
-
+
// Remove our artificially added PHP, and the syntax highlighting that came with it
- $str = str_replace('<?php ', '', $str);
- $str = preg_replace('/(.*?)\?><\/span>\n<\/span>\n<\/code>/is', "$1\n\n", $str);
+ $str = preg_replace('/<\?php( | )/i', '', $str);
+ $str = preg_replace('/(.*?)\?><\/span>\n<\/span>\n<\/code>/is', "$1\n\n", $str);
$str = preg_replace('/<\/span>/i', '', $str);
// Replace our markers back to PHP tags.
--
cgit v1.2.3-24-g4f1b
From dbc9e15c814ad2fc8a3fb10fbd1350d42b1f7f9c Mon Sep 17 00:00:00 2001
From: Derek Allard
Date: Mon, 6 Oct 2008 14:41:47 +0000
Subject: Altered auto_link() in the URL helper so that email addresses with
"+" included will be linked.
---
system/helpers/url_helper.php | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
(limited to 'system/helpers')
diff --git a/system/helpers/url_helper.php b/system/helpers/url_helper.php
index 121b36b97..acf889007 100644
--- a/system/helpers/url_helper.php
+++ b/system/helpers/url_helper.php
@@ -400,7 +400,7 @@ if ( ! function_exists('auto_link'))
if ($type != 'url')
{
- if (preg_match_all("/([a-zA-Z0-9_\.\-]+)@([a-zA-Z0-9\-]+)\.([a-zA-Z0-9\-\.]*)/i", $str, $matches))
+ if (preg_match_all("/([a-zA-Z0-9_\.\-\+Ã…]+)@([a-zA-Z0-9\-]+)\.([a-zA-Z0-9\-\.]*)/i", $str, $matches))
{
for ($i = 0; $i < sizeof($matches['0']); $i++)
{
--
cgit v1.2.3-24-g4f1b
From b4a6cf35fe8c637cec5be811f109f6f841456283 Mon Sep 17 00:00:00 2001
From: Rick Ellis
Date: Mon, 6 Oct 2008 18:39:36 +0000
Subject: Added some code to ignore empty folders when deleting directories
---
system/helpers/file_helper.php | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
(limited to 'system/helpers')
diff --git a/system/helpers/file_helper.php b/system/helpers/file_helper.php
index 58951823b..6378784f4 100644
--- a/system/helpers/file_helper.php
+++ b/system/helpers/file_helper.php
@@ -132,7 +132,11 @@ if ( ! function_exists('delete_files'))
{
if (is_dir($path.'/'.$filename))
{
- delete_files($path.'/'.$filename, $del_dir, $level + 1);
+ // Ignore empty folders
+ if (substr($filename, 0, 1) != '.')
+ {
+ delete_files($path.'/'.$filename, $del_dir, $level + 1);
+ }
}
else
{
--
cgit v1.2.3-24-g4f1b
From fd275707f6c1a5a63feb8708731d7c97683df765 Mon Sep 17 00:00:00 2001
From: Derek Jones
Date: Fri, 10 Oct 2008 22:37:06 +0000
Subject: modifications to url_title()
---
system/helpers/url_helper.php | 19 ++++++++++---------
1 file changed, 10 insertions(+), 9 deletions(-)
(limited to 'system/helpers')
diff --git a/system/helpers/url_helper.php b/system/helpers/url_helper.php
index acf889007..002090df1 100644
--- a/system/helpers/url_helper.php
+++ b/system/helpers/url_helper.php
@@ -479,19 +479,20 @@ if ( ! function_exists('url_title'))
}
$trans = array(
- $search => $replace,
- "\s+" => $replace,
- "[^a-z0-9".$replace."]" => '',
- $replace."+" => $replace,
- $replace."$" => '',
- "^".$replace => ''
- );
+ '&\#\d+?;' => '',
+ '&\S+?;' => '',
+ '\s+' => $replace,
+ '[^a-z0-9\-\._]' => '',
+ $replace.'+' => $replace,
+ $replace.'$' => $replace,
+ '^'.$replace => $replace
+ );
- $str = strip_tags(strtolower($str));
+ $str = strip_tags($str);
foreach ($trans as $key => $val)
{
- $str = preg_replace("#".$key."#", $val, $str);
+ $str = preg_replace("#".$key."#i", $val, $str);
}
return trim(stripslashes($str));
--
cgit v1.2.3-24-g4f1b
From 42597a107d799fa86ebc706bf8cbac4f9471d08c Mon Sep 17 00:00:00 2001
From: Derek Allard
Date: Wed, 15 Oct 2008 14:10:44 +0000
Subject: Added support for arbitrary attributes in anchor_popup() of the URL
helper.
---
system/helpers/url_helper.php | 112 ++++++++++++++++++++++--------------------
1 file changed, 59 insertions(+), 53 deletions(-)
(limited to 'system/helpers')
diff --git a/system/helpers/url_helper.php b/system/helpers/url_helper.php
index 002090df1..744295f4c 100644
--- a/system/helpers/url_helper.php
+++ b/system/helpers/url_helper.php
@@ -36,7 +36,7 @@
* @access public
* @param string
* @return string
- */
+ */
if ( ! function_exists('site_url'))
{
function site_url($uri = '')
@@ -55,7 +55,7 @@ if ( ! function_exists('site_url'))
*
* @access public
* @return string
- */
+ */
if ( ! function_exists('base_url'))
{
function base_url()
@@ -75,7 +75,7 @@ if ( ! function_exists('base_url'))
*
* @access public
* @return string
- */
+ */
if ( ! function_exists('current_url'))
{
function current_url()
@@ -89,11 +89,11 @@ if ( ! function_exists('current_url'))
/**
* URL String
*
- * Returns the URI segments.
+ * Returns the URI segments.
*
* @access public
* @return string
- */
+ */
if ( ! function_exists('uri_string'))
{
function uri_string()
@@ -112,7 +112,7 @@ if ( ! function_exists('uri_string'))
*
* @access public
* @return string
- */
+ */
if ( ! function_exists('index_page'))
{
function index_page()
@@ -121,7 +121,7 @@ if ( ! function_exists('index_page'))
return $CI->config->item('index_page');
}
}
-
+
// ------------------------------------------------------------------------
/**
@@ -134,13 +134,13 @@ if ( ! function_exists('index_page'))
* @param string the link title
* @param mixed any attributes
* @return string
- */
+ */
if ( ! function_exists('anchor'))
{
function anchor($uri = '', $title = '', $attributes = '')
{
$title = (string) $title;
-
+
if ( ! is_array($uri))
{
$site_url = ( ! preg_match('!^\w+://! i', $uri)) ? site_url($uri) : $uri;
@@ -149,7 +149,7 @@ if ( ! function_exists('anchor'))
{
$site_url = site_url($uri);
}
-
+
if ($title == '')
{
$title = $site_url;
@@ -163,7 +163,7 @@ if ( ! function_exists('anchor'))
return ''.$title.'';
}
}
-
+
// ------------------------------------------------------------------------
/**
@@ -181,35 +181,41 @@ if ( ! function_exists('anchor'))
if ( ! function_exists('anchor_popup'))
{
function anchor_popup($uri = '', $title = '', $attributes = FALSE)
- {
+ {
$title = (string) $title;
-
+
$site_url = ( ! preg_match('!^\w+://! i', $uri)) ? site_url($uri) : $uri;
-
+
if ($title == '')
{
$title = $site_url;
}
-
+
if ($attributes === FALSE)
{
return "".$title."";
}
-
+
if ( ! is_array($attributes))
{
$attributes = array();
}
-
+
foreach (array('width' => '800', 'height' => '600', 'scrollbars' => 'yes', 'status' => 'yes', 'resizable' => 'yes', 'screenx' => '0', 'screeny' => '0', ) as $key => $val)
{
$atts[$key] = ( ! isset($attributes[$key])) ? $val : $attributes[$key];
+ unset($attributes[$key]);
+ }
+
+ if ($attributes != '')
+ {
+ $attributes = _parse_attributes($attributes);
}
- return "".$title."";
+ return "".$title."";
}
}
-
+
// ------------------------------------------------------------------------
/**
@@ -226,18 +232,18 @@ if ( ! function_exists('mailto'))
function mailto($email, $title = '', $attributes = '')
{
$title = (string) $title;
-
+
if ($title == "")
{
$title = $email;
}
-
+
$attributes = _parse_attributes($attributes);
-
+
return ''.$title.'';
}
}
-
+
// ------------------------------------------------------------------------
/**
@@ -256,17 +262,17 @@ if ( ! function_exists('safe_mailto'))
function safe_mailto($email, $title = '', $attributes = '')
{
$title = (string) $title;
-
+
if ($title == "")
{
$title = $email;
}
-
+
for ($i = 0; $i < 16; $i++)
{
$x[] = substr('';
-
+
$temp = array();
for ($i = 0; $i < strlen($title); $i++)
{
$ordinal = ord($title[$i]);
-
+
if ($ordinal < 128)
{
$x[] = "|".$ordinal;
@@ -314,7 +320,7 @@ if ( ! function_exists('safe_mailto'))
{
$count = ($ordinal < 224) ? 2 : 3;
}
-
+
$temp[] = $ordinal;
if (count($temp) == $count)
{
@@ -325,12 +331,12 @@ if ( ! function_exists('safe_mailto'))
}
}
}
-
+
$x[] = '<'; $x[] = '/'; $x[] = 'a'; $x[] = '>';
-
+
$x = array_reverse($x);
ob_start();
-
+
?>
-EOF;
- }
-}
-// ------------------------------------------------------------------------
-
-/**
- * Get Clickable Smileys
- *
- * Returns an array of image tag links that can be clicked to be inserted
- * into a form field.
- *
- * @access public
- * @param string the URL to the folder containing the smiley images
- * @return array
- */
-if ( ! function_exists('get_clickable_smileys'))
-{
- function get_clickable_smileys($image_url = '', $smileys = NULL)
- {
- if ( ! is_array($smileys))
- {
- if (FALSE === ($smileys = _get_smiley_array()))
- {
- return $smileys;
- }
- }
-
- // Add a trailing slash to the file path if needed
- $image_url = preg_replace("/(.+?)\/*$/", "\\1/", $image_url);
-
- $used = array();
- foreach ($smileys as $key => $val)
- {
- // Keep duplicates from being used, which can happen if the
- // mapping array contains multiple identical replacements. For example:
- // :-) and :) might be replaced with the same image so both smileys
- // will be in the array.
- if (isset($used[$smileys[$key][0]]))
- {
- continue;
- }
-
- $link[] = "";
-
- $used[$smileys[$key][0]] = TRUE;
- }
-
- return $link;
- }
-}
-
-// ------------------------------------------------------------------------
-
-/**
- * Parse Smileys
- *
- * Takes a string as input and swaps any contained smileys for the actual image
- *
- * @access public
- * @param string the text to be parsed
- * @param string the URL to the folder containing the smiley images
- * @return string
- */
-if ( ! function_exists('parse_smileys'))
-{
- function parse_smileys($str = '', $image_url = '', $smileys = NULL)
- {
- if ($image_url == '')
- {
- return $str;
- }
-
- if ( ! is_array($smileys))
- {
- if (FALSE === ($smileys = _get_smiley_array()))
- {
- return $str;
- }
- }
-
- // Add a trailing slash to the file path if needed
- $image_url = preg_replace("/(.+?)\/*$/", "\\1/", $image_url);
-
- foreach ($smileys as $key => $val)
- {
- $str = str_replace($key, "", $str);
- }
-
- return $str;
- }
-}
-
-// ------------------------------------------------------------------------
-
-/**
- * Get Smiley Array
- *
- * Fetches the config/smiley.php file
- *
- * @access private
- * @return mixed
- */
-if ( ! function_exists('_get_smiley_array'))
-{
- function _get_smiley_array()
- {
- if ( ! file_exists(APPPATH.'config/smileys'.EXT))
- {
- return FALSE;
- }
-
- include(APPPATH.'config/smileys'.EXT);
-
- if ( ! isset($smileys) OR ! is_array($smileys))
- {
- return FALSE;
- }
-
- return $smileys;
- }
-}
-
-
-/* End of file smiley_helper.php */
+
+ function insert_smiley(smiley)
+ {
+ document.{$form_name}.{$form_field}.value += " " + smiley;
+ }
+
+EOF;
+ }
+}
+// ------------------------------------------------------------------------
+
+/**
+ * Get Clickable Smileys
+ *
+ * Returns an array of image tag links that can be clicked to be inserted
+ * into a form field.
+ *
+ * @access public
+ * @param string the URL to the folder containing the smiley images
+ * @return array
+ */
+if ( ! function_exists('get_clickable_smileys'))
+{
+ function get_clickable_smileys($image_url = '', $smileys = NULL)
+ {
+ if ( ! is_array($smileys))
+ {
+ if (FALSE === ($smileys = _get_smiley_array()))
+ {
+ return $smileys;
+ }
+ }
+
+ // Add a trailing slash to the file path if needed
+ $image_url = preg_replace("/(.+?)\/*$/", "\\1/", $image_url);
+
+ $used = array();
+ foreach ($smileys as $key => $val)
+ {
+ // Keep duplicates from being used, which can happen if the
+ // mapping array contains multiple identical replacements. For example:
+ // :-) and :) might be replaced with the same image so both smileys
+ // will be in the array.
+ if (isset($used[$smileys[$key][0]]))
+ {
+ continue;
+ }
+
+ $link[] = "";
+
+ $used[$smileys[$key][0]] = TRUE;
+ }
+
+ return $link;
+ }
+}
+
+// ------------------------------------------------------------------------
+
+/**
+ * Parse Smileys
+ *
+ * Takes a string as input and swaps any contained smileys for the actual image
+ *
+ * @access public
+ * @param string the text to be parsed
+ * @param string the URL to the folder containing the smiley images
+ * @return string
+ */
+if ( ! function_exists('parse_smileys'))
+{
+ function parse_smileys($str = '', $image_url = '', $smileys = NULL)
+ {
+ if ($image_url == '')
+ {
+ return $str;
+ }
+
+ if ( ! is_array($smileys))
+ {
+ if (FALSE === ($smileys = _get_smiley_array()))
+ {
+ return $str;
+ }
+ }
+
+ // Add a trailing slash to the file path if needed
+ $image_url = preg_replace("/(.+?)\/*$/", "\\1/", $image_url);
+
+ foreach ($smileys as $key => $val)
+ {
+ $str = str_replace($key, "", $str);
+ }
+
+ return $str;
+ }
+}
+
+// ------------------------------------------------------------------------
+
+/**
+ * Get Smiley Array
+ *
+ * Fetches the config/smiley.php file
+ *
+ * @access private
+ * @return mixed
+ */
+if ( ! function_exists('_get_smiley_array'))
+{
+ function _get_smiley_array()
+ {
+ if ( ! file_exists(APPPATH.'config/smileys'.EXT))
+ {
+ return FALSE;
+ }
+
+ include(APPPATH.'config/smileys'.EXT);
+
+ if ( ! isset($smileys) OR ! is_array($smileys))
+ {
+ return FALSE;
+ }
+
+ return $smileys;
+ }
+}
+
+
+/* End of file smiley_helper.php */
/* Location: ./system/helpers/smiley_helper.php */
\ No newline at end of file
diff --git a/system/helpers/string_helper.php b/system/helpers/string_helper.php
index 4e376a88c..319002ea7 100644
--- a/system/helpers/string_helper.php
+++ b/system/helpers/string_helper.php
@@ -1,273 +1,273 @@
- $val)
- {
- $str[$key] = strip_slashes($val);
- }
- }
- else
- {
- $str = stripslashes($str);
- }
-
- return $str;
- }
-}
-
-// ------------------------------------------------------------------------
-
-/**
- * Strip Quotes
- *
- * Removes single and double quotes from a string
- *
- * @access public
- * @param string
- * @return string
- */
-if ( ! function_exists('strip_quotes'))
-{
- function strip_quotes($str)
- {
- return str_replace(array('"', "'"), '', $str);
- }
-}
-
-// ------------------------------------------------------------------------
-
-/**
- * Quotes to Entities
- *
- * Converts single and double quotes to entities
- *
- * @access public
- * @param string
- * @return string
- */
-if ( ! function_exists('quotes_to_entities'))
-{
- function quotes_to_entities($str)
- {
- return str_replace(array("\'","\"","'",'"'), array("'",""","'","""), $str);
- }
-}
-
-// ------------------------------------------------------------------------
-/**
- * Reduce Double Slashes
- *
- * Converts double slashes in a string to a single slash,
- * except those found in http://
- *
- * http://www.some-site.com//index.php
- *
- * becomes:
- *
- * http://www.some-site.com/index.php
- *
- * @access public
- * @param string
- * @return string
- */
-if ( ! function_exists('reduce_double_slashes'))
-{
- function reduce_double_slashes($str)
- {
- return preg_replace("#([^:])//+#", "\\1/", $str);
- }
-}
-
-// ------------------------------------------------------------------------
-
-/**
- * Reduce Multiples
- *
- * Reduces multiple instances of a particular character. Example:
- *
- * Fred, Bill,, Joe, Jimmy
- *
- * becomes:
- *
- * Fred, Bill, Joe, Jimmy
- *
- * @access public
- * @param string
- * @param string the character you wish to reduce
- * @param bool TRUE/FALSE - whether to trim the character from the beginning/end
- * @return string
- */
-if ( ! function_exists('reduce_multiples'))
-{
- function reduce_multiples($str, $character = ',', $trim = FALSE)
- {
- $str = preg_replace('#'.preg_quote($character, '#').'{2,}#', $character, $str);
-
- if ($trim === TRUE)
- {
- $str = trim($str, $character);
- }
-
- return $str;
- }
-}
-
-// ------------------------------------------------------------------------
-
-/**
- * Create a Random String
- *
- * Useful for generating passwords or hashes.
- *
- * @access public
- * @param string type of random string. Options: alunum, numeric, nozero, unique
- * @param integer number of characters
- * @return string
- */
-if ( ! function_exists('random_string'))
-{
- function random_string($type = 'alnum', $len = 8)
- {
- switch($type)
- {
- case 'alnum' :
- case 'numeric' :
- case 'nozero' :
-
- switch ($type)
- {
- case 'alnum' : $pool = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
- break;
- case 'numeric' : $pool = '0123456789';
- break;
- case 'nozero' : $pool = '123456789';
- break;
- }
-
- $str = '';
- for ($i=0; $i < $len; $i++)
- {
- $str .= substr($pool, mt_rand(0, strlen($pool) -1), 1);
- }
- return $str;
- break;
- case 'unique' : return md5(uniqid(mt_rand()));
- break;
- }
- }
-}
-
-// ------------------------------------------------------------------------
-
-/**
- * Alternator
- *
- * Allows strings to be alternated. See docs...
- *
- * @access public
- * @param string (as many parameters as needed)
- * @return string
- */
-if ( ! function_exists('alternator'))
-{
- function alternator()
- {
- static $i;
-
- if (func_num_args() == 0)
- {
- $i = 0;
- return '';
- }
- $args = func_get_args();
- return $args[($i++ % count($args))];
- }
-}
-
-// ------------------------------------------------------------------------
-
-/**
- * Repeater function
- *
- * @access public
- * @param string
- * @param integer number of repeats
- * @return string
- */
-if ( ! function_exists('repeater'))
-{
- function repeater($data, $num = 1)
- {
- return (($num > 0) ? str_repeat($data, $num) : '');
- }
-}
-
-
-/* End of file string_helper.php */
+ $val)
+ {
+ $str[$key] = strip_slashes($val);
+ }
+ }
+ else
+ {
+ $str = stripslashes($str);
+ }
+
+ return $str;
+ }
+}
+
+// ------------------------------------------------------------------------
+
+/**
+ * Strip Quotes
+ *
+ * Removes single and double quotes from a string
+ *
+ * @access public
+ * @param string
+ * @return string
+ */
+if ( ! function_exists('strip_quotes'))
+{
+ function strip_quotes($str)
+ {
+ return str_replace(array('"', "'"), '', $str);
+ }
+}
+
+// ------------------------------------------------------------------------
+
+/**
+ * Quotes to Entities
+ *
+ * Converts single and double quotes to entities
+ *
+ * @access public
+ * @param string
+ * @return string
+ */
+if ( ! function_exists('quotes_to_entities'))
+{
+ function quotes_to_entities($str)
+ {
+ return str_replace(array("\'","\"","'",'"'), array("'",""","'","""), $str);
+ }
+}
+
+// ------------------------------------------------------------------------
+/**
+ * Reduce Double Slashes
+ *
+ * Converts double slashes in a string to a single slash,
+ * except those found in http://
+ *
+ * http://www.some-site.com//index.php
+ *
+ * becomes:
+ *
+ * http://www.some-site.com/index.php
+ *
+ * @access public
+ * @param string
+ * @return string
+ */
+if ( ! function_exists('reduce_double_slashes'))
+{
+ function reduce_double_slashes($str)
+ {
+ return preg_replace("#([^:])//+#", "\\1/", $str);
+ }
+}
+
+// ------------------------------------------------------------------------
+
+/**
+ * Reduce Multiples
+ *
+ * Reduces multiple instances of a particular character. Example:
+ *
+ * Fred, Bill,, Joe, Jimmy
+ *
+ * becomes:
+ *
+ * Fred, Bill, Joe, Jimmy
+ *
+ * @access public
+ * @param string
+ * @param string the character you wish to reduce
+ * @param bool TRUE/FALSE - whether to trim the character from the beginning/end
+ * @return string
+ */
+if ( ! function_exists('reduce_multiples'))
+{
+ function reduce_multiples($str, $character = ',', $trim = FALSE)
+ {
+ $str = preg_replace('#'.preg_quote($character, '#').'{2,}#', $character, $str);
+
+ if ($trim === TRUE)
+ {
+ $str = trim($str, $character);
+ }
+
+ return $str;
+ }
+}
+
+// ------------------------------------------------------------------------
+
+/**
+ * Create a Random String
+ *
+ * Useful for generating passwords or hashes.
+ *
+ * @access public
+ * @param string type of random string. Options: alunum, numeric, nozero, unique
+ * @param integer number of characters
+ * @return string
+ */
+if ( ! function_exists('random_string'))
+{
+ function random_string($type = 'alnum', $len = 8)
+ {
+ switch($type)
+ {
+ case 'alnum' :
+ case 'numeric' :
+ case 'nozero' :
+
+ switch ($type)
+ {
+ case 'alnum' : $pool = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
+ break;
+ case 'numeric' : $pool = '0123456789';
+ break;
+ case 'nozero' : $pool = '123456789';
+ break;
+ }
+
+ $str = '';
+ for ($i=0; $i < $len; $i++)
+ {
+ $str .= substr($pool, mt_rand(0, strlen($pool) -1), 1);
+ }
+ return $str;
+ break;
+ case 'unique' : return md5(uniqid(mt_rand()));
+ break;
+ }
+ }
+}
+
+// ------------------------------------------------------------------------
+
+/**
+ * Alternator
+ *
+ * Allows strings to be alternated. See docs...
+ *
+ * @access public
+ * @param string (as many parameters as needed)
+ * @return string
+ */
+if ( ! function_exists('alternator'))
+{
+ function alternator()
+ {
+ static $i;
+
+ if (func_num_args() == 0)
+ {
+ $i = 0;
+ return '';
+ }
+ $args = func_get_args();
+ return $args[($i++ % count($args))];
+ }
+}
+
+// ------------------------------------------------------------------------
+
+/**
+ * Repeater function
+ *
+ * @access public
+ * @param string
+ * @param integer number of repeats
+ * @return string
+ */
+if ( ! function_exists('repeater'))
+{
+ function repeater($data, $num = 1)
+ {
+ return (($num > 0) ? str_repeat($data, $num) : '');
+ }
+}
+
+
+/* End of file string_helper.php */
/* Location: ./system/helpers/string_helper.php */
\ No newline at end of file
diff --git a/system/helpers/text_helper.php b/system/helpers/text_helper.php
index 8a4460825..6e61f776a 100644
--- a/system/helpers/text_helper.php
+++ b/system/helpers/text_helper.php
@@ -1,443 +1,443 @@
-= $n)
- {
- return trim($out).$end_char;
- }
- }
- }
-}
-
-// ------------------------------------------------------------------------
-
-/**
- * High ASCII to Entities
- *
- * Converts High ascii text and MS Word special characters to character entities
- *
- * @access public
- * @param string
- * @return string
- */
-if ( ! function_exists('ascii_to_entities'))
-{
- function ascii_to_entities($str)
- {
- $count = 1;
- $out = '';
- $temp = array();
-
- for ($i = 0, $s = strlen($str); $i < $s; $i++)
- {
- $ordinal = ord($str[$i]);
-
- if ($ordinal < 128)
- {
- $out .= $str[$i];
- }
- else
- {
- if (count($temp) == 0)
- {
- $count = ($ordinal < 224) ? 2 : 3;
- }
-
- $temp[] = $ordinal;
-
- if (count($temp) == $count)
- {
- $number = ($count == 3) ? (($temp['0'] % 16) * 4096) + (($temp['1'] % 64) * 64) + ($temp['2'] % 64) : (($temp['0'] % 32) * 64) + ($temp['1'] % 64);
-
- $out .= ''.$number.';';
- $count = 1;
- $temp = array();
- }
- }
- }
-
- return $out;
- }
-}
-
-// ------------------------------------------------------------------------
-
-/**
- * Entities to ASCII
- *
- * Converts character entities back to ASCII
- *
- * @access public
- * @param string
- * @param bool
- * @return string
- */
-if ( ! function_exists('entities_to_ascii'))
-{
- function entities_to_ascii($str, $all = TRUE)
- {
- if (preg_match_all('/\(\d+)\;/', $str, $matches))
- {
- for ($i = 0, $s = count($matches['0']); $i < $s; $i++)
- {
- $digits = $matches['1'][$i];
-
- $out = '';
-
- if ($digits < 128)
- {
- $out .= chr($digits);
-
- }
- elseif ($digits < 2048)
- {
- $out .= chr(192 + (($digits - ($digits % 64)) / 64));
- $out .= chr(128 + ($digits % 64));
- }
- else
- {
- $out .= chr(224 + (($digits - ($digits % 4096)) / 4096));
- $out .= chr(128 + ((($digits % 4096) - ($digits % 64)) / 64));
- $out .= chr(128 + ($digits % 64));
- }
-
- $str = str_replace($matches['0'][$i], $out, $str);
- }
- }
-
- if ($all)
- {
- $str = str_replace(array("&", "<", ">", """, "'", "-"),
- array("&","<",">","\"", "'", "-"),
- $str);
- }
-
- return $str;
- }
-}
-
-// ------------------------------------------------------------------------
-
-/**
- * Word Censoring Function
- *
- * Supply a string and an array of disallowed words and any
- * matched words will be converted to #### or to the replacement
- * word you've submitted.
- *
- * @access public
- * @param string the text string
- * @param string the array of censoered words
- * @param string the optional replacement value
- * @return string
- */
-if ( ! function_exists('word_censor'))
-{
- function word_censor($str, $censored, $replacement = '')
- {
- if ( ! is_array($censored))
- {
- return $str;
- }
-
- $str = ' '.$str.' ';
- foreach ($censored as $badword)
- {
- if ($replacement != '')
- {
- $str = preg_replace("/\b(".str_replace('\*', '\w*?', preg_quote($badword, '/')).")\b/i", $replacement, $str);
- }
- else
- {
- $str = preg_replace("/\b(".str_replace('\*', '\w*?', preg_quote($badword, '/')).")\b/ie", "str_repeat('#', strlen('\\1'))", $str);
- }
- }
-
- return trim($str);
- }
-}
-
-// ------------------------------------------------------------------------
-
-/**
- * Code Highlighter
- *
- * Colorizes code strings
- *
- * @access public
- * @param string the text string
- * @return string
- */
-if ( ! function_exists('highlight_code'))
-{
- function highlight_code($str)
- {
- // The highlight string function encodes and highlights
- // brackets so we need them to start raw
- $str = str_replace(array('<', '>'), array('<', '>'), $str);
-
- // Replace any existing PHP tags to temporary markers so they don't accidentally
- // break the string out of PHP, and thus, thwart the highlighting.
-
- $str = str_replace(array('', '?>', '<%', '%>', '\\', ''),
- array('phptagopen', 'phptagclose', 'asptagopen', 'asptagclose', 'backslashtmp', 'scriptclose'), $str);
-
- // The highlight_string function requires that the text be surrounded
- // by PHP tags, which we will remove later
- $str = ''; //
-
- // All the magic happens here, baby!
- $str = highlight_string($str, TRUE);
-
- // Prior to PHP 5, the highligh function used icky tags
- // so we'll replace them with tags.
-
- if (abs(PHP_VERSION) < 5)
- {
- $str = str_replace(array(''), array(''), $str);
- $str = preg_replace('#color="(.*?)"#', 'style="color: \\1"', $str);
- }
-
- // Remove our artificially added PHP, and the syntax highlighting that came with it
- $str = preg_replace('/<\?php( | )/i', '', $str);
- $str = preg_replace('/(.*?)\?><\/span>\n<\/span>\n<\/code>/is', "$1\n\n", $str);
- $str = preg_replace('/<\/span>/i', '', $str);
-
- // Replace our markers back to PHP tags.
- $str = str_replace(array('phptagopen', 'phptagclose', 'asptagopen', 'asptagclose', 'backslashtmp', 'scriptclose'),
- array('<?', '?>', '<%', '%>', '\\', '</script>'), $str);
-
- return $str;
- }
-}
-
-// ------------------------------------------------------------------------
-
-/**
- * Phrase Highlighter
- *
- * Highlights a phrase within a text string
- *
- * @access public
- * @param string the text string
- * @param string the phrase you'd like to highlight
- * @param string the openging tag to precede the phrase with
- * @param string the closing tag to end the phrase with
- * @return string
- */
-if ( ! function_exists('highlight_phrase'))
-{
- function highlight_phrase($str, $phrase, $tag_open = '', $tag_close = '')
- {
- if ($str == '')
- {
- return '';
- }
-
- if ($phrase != '')
- {
- return preg_replace('/('.preg_quote($phrase, '/').')/i', $tag_open."\\1".$tag_close, $str);
- }
-
- return $str;
- }
-}
-
-// ------------------------------------------------------------------------
-
-/**
- * Word Wrap
- *
- * Wraps text at the specified character. Maintains the integrity of words.
- * Anything placed between {unwrap}{/unwrap} will not be word wrapped, nor
- * will URLs.
- *
- * @access public
- * @param string the text string
- * @param integer the number of characters to wrap at
- * @return string
- */
-if ( ! function_exists('word_wrap'))
-{
- function word_wrap($str, $charlim = '76')
- {
- // Se the character limit
- if ( ! is_numeric($charlim))
- $charlim = 76;
-
- // Reduce multiple spaces
- $str = preg_replace("| +|", " ", $str);
-
- // Standardize newlines
- if (strpos($str, "\r") !== FALSE)
- {
- $str = str_replace(array("\r\n", "\r"), "\n", $str);
- }
-
- // If the current word is surrounded by {unwrap} tags we'll
- // strip the entire chunk and replace it with a marker.
- $unwrap = array();
- if (preg_match_all("|(\{unwrap\}.+?\{/unwrap\})|s", $str, $matches))
- {
- for ($i = 0; $i < count($matches['0']); $i++)
- {
- $unwrap[] = $matches['1'][$i];
- $str = str_replace($matches['1'][$i], "{{unwrapped".$i."}}", $str);
- }
- }
-
- // Use PHP's native function to do the initial wordwrap.
- // We set the cut flag to FALSE so that any individual words that are
- // too long get left alone. In the next step we'll deal with them.
- $str = wordwrap($str, $charlim, "\n", FALSE);
-
- // Split the string into individual lines of text and cycle through them
- $output = "";
- foreach (explode("\n", $str) as $line)
- {
- // Is the line within the allowed character count?
- // If so we'll join it to the output and continue
- if (strlen($line) <= $charlim)
- {
- $output .= $line."\n";
- continue;
- }
-
- $temp = '';
- while((strlen($line)) > $charlim)
- {
- // If the over-length word is a URL we won't wrap it
- if (preg_match("!\[url.+\]|://|wwww.!", $line))
- {
- break;
- }
-
- // Trim the word down
- $temp .= substr($line, 0, $charlim-1);
- $line = substr($line, $charlim-1);
- }
-
- // If $temp contains data it means we had to split up an over-length
- // word into smaller chunks so we'll add it back to our current line
- if ($temp != '')
- {
- $output .= $temp . "\n" . $line;
- }
- else
- {
- $output .= $line;
- }
-
- $output .= "\n";
- }
-
- // Put our markers back
- if (count($unwrap) > 0)
- {
- foreach ($unwrap as $key => $val)
- {
- $output = str_replace("{{unwrapped".$key."}}", $val, $output);
- }
- }
-
- // Remove the unwrap tags
- $output = str_replace(array('{unwrap}', '{/unwrap}'), '', $output);
-
- return $output;
- }
-}
-
-
-/* End of file text_helper.php */
+= $n)
+ {
+ return trim($out).$end_char;
+ }
+ }
+ }
+}
+
+// ------------------------------------------------------------------------
+
+/**
+ * High ASCII to Entities
+ *
+ * Converts High ascii text and MS Word special characters to character entities
+ *
+ * @access public
+ * @param string
+ * @return string
+ */
+if ( ! function_exists('ascii_to_entities'))
+{
+ function ascii_to_entities($str)
+ {
+ $count = 1;
+ $out = '';
+ $temp = array();
+
+ for ($i = 0, $s = strlen($str); $i < $s; $i++)
+ {
+ $ordinal = ord($str[$i]);
+
+ if ($ordinal < 128)
+ {
+ $out .= $str[$i];
+ }
+ else
+ {
+ if (count($temp) == 0)
+ {
+ $count = ($ordinal < 224) ? 2 : 3;
+ }
+
+ $temp[] = $ordinal;
+
+ if (count($temp) == $count)
+ {
+ $number = ($count == 3) ? (($temp['0'] % 16) * 4096) + (($temp['1'] % 64) * 64) + ($temp['2'] % 64) : (($temp['0'] % 32) * 64) + ($temp['1'] % 64);
+
+ $out .= ''.$number.';';
+ $count = 1;
+ $temp = array();
+ }
+ }
+ }
+
+ return $out;
+ }
+}
+
+// ------------------------------------------------------------------------
+
+/**
+ * Entities to ASCII
+ *
+ * Converts character entities back to ASCII
+ *
+ * @access public
+ * @param string
+ * @param bool
+ * @return string
+ */
+if ( ! function_exists('entities_to_ascii'))
+{
+ function entities_to_ascii($str, $all = TRUE)
+ {
+ if (preg_match_all('/\(\d+)\;/', $str, $matches))
+ {
+ for ($i = 0, $s = count($matches['0']); $i < $s; $i++)
+ {
+ $digits = $matches['1'][$i];
+
+ $out = '';
+
+ if ($digits < 128)
+ {
+ $out .= chr($digits);
+
+ }
+ elseif ($digits < 2048)
+ {
+ $out .= chr(192 + (($digits - ($digits % 64)) / 64));
+ $out .= chr(128 + ($digits % 64));
+ }
+ else
+ {
+ $out .= chr(224 + (($digits - ($digits % 4096)) / 4096));
+ $out .= chr(128 + ((($digits % 4096) - ($digits % 64)) / 64));
+ $out .= chr(128 + ($digits % 64));
+ }
+
+ $str = str_replace($matches['0'][$i], $out, $str);
+ }
+ }
+
+ if ($all)
+ {
+ $str = str_replace(array("&", "<", ">", """, "'", "-"),
+ array("&","<",">","\"", "'", "-"),
+ $str);
+ }
+
+ return $str;
+ }
+}
+
+// ------------------------------------------------------------------------
+
+/**
+ * Word Censoring Function
+ *
+ * Supply a string and an array of disallowed words and any
+ * matched words will be converted to #### or to the replacement
+ * word you've submitted.
+ *
+ * @access public
+ * @param string the text string
+ * @param string the array of censoered words
+ * @param string the optional replacement value
+ * @return string
+ */
+if ( ! function_exists('word_censor'))
+{
+ function word_censor($str, $censored, $replacement = '')
+ {
+ if ( ! is_array($censored))
+ {
+ return $str;
+ }
+
+ $str = ' '.$str.' ';
+ foreach ($censored as $badword)
+ {
+ if ($replacement != '')
+ {
+ $str = preg_replace("/\b(".str_replace('\*', '\w*?', preg_quote($badword, '/')).")\b/i", $replacement, $str);
+ }
+ else
+ {
+ $str = preg_replace("/\b(".str_replace('\*', '\w*?', preg_quote($badword, '/')).")\b/ie", "str_repeat('#', strlen('\\1'))", $str);
+ }
+ }
+
+ return trim($str);
+ }
+}
+
+// ------------------------------------------------------------------------
+
+/**
+ * Code Highlighter
+ *
+ * Colorizes code strings
+ *
+ * @access public
+ * @param string the text string
+ * @return string
+ */
+if ( ! function_exists('highlight_code'))
+{
+ function highlight_code($str)
+ {
+ // The highlight string function encodes and highlights
+ // brackets so we need them to start raw
+ $str = str_replace(array('<', '>'), array('<', '>'), $str);
+
+ // Replace any existing PHP tags to temporary markers so they don't accidentally
+ // break the string out of PHP, and thus, thwart the highlighting.
+
+ $str = str_replace(array('', '?>', '<%', '%>', '\\', ''),
+ array('phptagopen', 'phptagclose', 'asptagopen', 'asptagclose', 'backslashtmp', 'scriptclose'), $str);
+
+ // The highlight_string function requires that the text be surrounded
+ // by PHP tags, which we will remove later
+ $str = ''; //
+
+ // All the magic happens here, baby!
+ $str = highlight_string($str, TRUE);
+
+ // Prior to PHP 5, the highligh function used icky tags
+ // so we'll replace them with tags.
+
+ if (abs(PHP_VERSION) < 5)
+ {
+ $str = str_replace(array(''), array(''), $str);
+ $str = preg_replace('#color="(.*?)"#', 'style="color: \\1"', $str);
+ }
+
+ // Remove our artificially added PHP, and the syntax highlighting that came with it
+ $str = preg_replace('/<\?php( | )/i', '', $str);
+ $str = preg_replace('/(.*?)\?><\/span>\n<\/span>\n<\/code>/is', "$1\n\n", $str);
+ $str = preg_replace('/<\/span>/i', '', $str);
+
+ // Replace our markers back to PHP tags.
+ $str = str_replace(array('phptagopen', 'phptagclose', 'asptagopen', 'asptagclose', 'backslashtmp', 'scriptclose'),
+ array('<?', '?>', '<%', '%>', '\\', '</script>'), $str);
+
+ return $str;
+ }
+}
+
+// ------------------------------------------------------------------------
+
+/**
+ * Phrase Highlighter
+ *
+ * Highlights a phrase within a text string
+ *
+ * @access public
+ * @param string the text string
+ * @param string the phrase you'd like to highlight
+ * @param string the openging tag to precede the phrase with
+ * @param string the closing tag to end the phrase with
+ * @return string
+ */
+if ( ! function_exists('highlight_phrase'))
+{
+ function highlight_phrase($str, $phrase, $tag_open = '', $tag_close = '')
+ {
+ if ($str == '')
+ {
+ return '';
+ }
+
+ if ($phrase != '')
+ {
+ return preg_replace('/('.preg_quote($phrase, '/').')/i', $tag_open."\\1".$tag_close, $str);
+ }
+
+ return $str;
+ }
+}
+
+// ------------------------------------------------------------------------
+
+/**
+ * Word Wrap
+ *
+ * Wraps text at the specified character. Maintains the integrity of words.
+ * Anything placed between {unwrap}{/unwrap} will not be word wrapped, nor
+ * will URLs.
+ *
+ * @access public
+ * @param string the text string
+ * @param integer the number of characters to wrap at
+ * @return string
+ */
+if ( ! function_exists('word_wrap'))
+{
+ function word_wrap($str, $charlim = '76')
+ {
+ // Se the character limit
+ if ( ! is_numeric($charlim))
+ $charlim = 76;
+
+ // Reduce multiple spaces
+ $str = preg_replace("| +|", " ", $str);
+
+ // Standardize newlines
+ if (strpos($str, "\r") !== FALSE)
+ {
+ $str = str_replace(array("\r\n", "\r"), "\n", $str);
+ }
+
+ // If the current word is surrounded by {unwrap} tags we'll
+ // strip the entire chunk and replace it with a marker.
+ $unwrap = array();
+ if (preg_match_all("|(\{unwrap\}.+?\{/unwrap\})|s", $str, $matches))
+ {
+ for ($i = 0; $i < count($matches['0']); $i++)
+ {
+ $unwrap[] = $matches['1'][$i];
+ $str = str_replace($matches['1'][$i], "{{unwrapped".$i."}}", $str);
+ }
+ }
+
+ // Use PHP's native function to do the initial wordwrap.
+ // We set the cut flag to FALSE so that any individual words that are
+ // too long get left alone. In the next step we'll deal with them.
+ $str = wordwrap($str, $charlim, "\n", FALSE);
+
+ // Split the string into individual lines of text and cycle through them
+ $output = "";
+ foreach (explode("\n", $str) as $line)
+ {
+ // Is the line within the allowed character count?
+ // If so we'll join it to the output and continue
+ if (strlen($line) <= $charlim)
+ {
+ $output .= $line."\n";
+ continue;
+ }
+
+ $temp = '';
+ while((strlen($line)) > $charlim)
+ {
+ // If the over-length word is a URL we won't wrap it
+ if (preg_match("!\[url.+\]|://|wwww.!", $line))
+ {
+ break;
+ }
+
+ // Trim the word down
+ $temp .= substr($line, 0, $charlim-1);
+ $line = substr($line, $charlim-1);
+ }
+
+ // If $temp contains data it means we had to split up an over-length
+ // word into smaller chunks so we'll add it back to our current line
+ if ($temp != '')
+ {
+ $output .= $temp . "\n" . $line;
+ }
+ else
+ {
+ $output .= $line;
+ }
+
+ $output .= "\n";
+ }
+
+ // Put our markers back
+ if (count($unwrap) > 0)
+ {
+ foreach ($unwrap as $key => $val)
+ {
+ $output = str_replace("{{unwrapped".$key."}}", $val, $output);
+ }
+ }
+
+ // Remove the unwrap tags
+ $output = str_replace(array('{unwrap}', '{/unwrap}'), '', $output);
+
+ return $output;
+ }
+}
+
+
+/* End of file text_helper.php */
/* Location: ./system/helpers/text_helper.php */
\ No newline at end of file
diff --git a/system/helpers/typography_helper.php b/system/helpers/typography_helper.php
index d3cc7f175..46fe6bf36 100644
--- a/system/helpers/typography_helper.php
+++ b/system/helpers/typography_helper.php
@@ -1,71 +1,71 @@
-load->library('typography');
-
- return $CI->typography->nl2br_except_pre($str);
- }
-}
-
-// ------------------------------------------------------------------------
-
-/**
- * Auto Typography Wrapper Function
- *
- *
- * @access public
- * @param string
- * @param bool whether to reduce multiple instances of double newlines to two
- * @return string
- */
-if ( ! function_exists('auto_typography'))
-{
- function auto_typography($str, $reduce_linebreaks = FALSE)
- {
- $CI =& get_instance();
- $CI->load->library('typography');
- return $CI->typography->auto_typography($str, $reduce_linebreaks);
- }
-}
-
-/* End of file typography_helper.php */
+load->library('typography');
+
+ return $CI->typography->nl2br_except_pre($str);
+ }
+}
+
+// ------------------------------------------------------------------------
+
+/**
+ * Auto Typography Wrapper Function
+ *
+ *
+ * @access public
+ * @param string
+ * @param bool whether to reduce multiple instances of double newlines to two
+ * @return string
+ */
+if ( ! function_exists('auto_typography'))
+{
+ function auto_typography($str, $reduce_linebreaks = FALSE)
+ {
+ $CI =& get_instance();
+ $CI->load->library('typography');
+ return $CI->typography->auto_typography($str, $reduce_linebreaks);
+ }
+}
+
+/* End of file typography_helper.php */
/* Location: ./system/helpers/typography_helper.php */
\ No newline at end of file
diff --git a/system/helpers/url_helper.php b/system/helpers/url_helper.php
index 744295f4c..fd13dc2d4 100644
--- a/system/helpers/url_helper.php
+++ b/system/helpers/url_helper.php
@@ -1,582 +1,582 @@
-config->site_url($uri);
- }
-}
-
-// ------------------------------------------------------------------------
-
-/**
- * Base URL
- *
- * Returns the "base_url" item from your config file
- *
- * @access public
- * @return string
- */
-if ( ! function_exists('base_url'))
-{
- function base_url()
- {
- $CI =& get_instance();
- return $CI->config->slash_item('base_url');
- }
-}
-
-// ------------------------------------------------------------------------
-
-/**
- * Current URL
- *
- * Returns the full URL (including segments) of the page where this
- * function is placed
- *
- * @access public
- * @return string
- */
-if ( ! function_exists('current_url'))
-{
- function current_url()
- {
- $CI =& get_instance();
- return $CI->config->site_url($CI->uri->uri_string());
- }
-}
-
-// ------------------------------------------------------------------------
-/**
- * URL String
- *
- * Returns the URI segments.
- *
- * @access public
- * @return string
- */
-if ( ! function_exists('uri_string'))
-{
- function uri_string()
- {
- $CI =& get_instance();
- return $CI->uri->uri_string();
- }
-}
-
-// ------------------------------------------------------------------------
-
-/**
- * Index page
- *
- * Returns the "index_page" from your config file
- *
- * @access public
- * @return string
- */
-if ( ! function_exists('index_page'))
-{
- function index_page()
- {
- $CI =& get_instance();
- return $CI->config->item('index_page');
- }
-}
-
-// ------------------------------------------------------------------------
-
-/**
- * Anchor Link
- *
- * Creates an anchor based on the local URL.
- *
- * @access public
- * @param string the URL
- * @param string the link title
- * @param mixed any attributes
- * @return string
- */
-if ( ! function_exists('anchor'))
-{
- function anchor($uri = '', $title = '', $attributes = '')
- {
- $title = (string) $title;
-
- if ( ! is_array($uri))
- {
- $site_url = ( ! preg_match('!^\w+://! i', $uri)) ? site_url($uri) : $uri;
- }
- else
- {
- $site_url = site_url($uri);
- }
-
- if ($title == '')
- {
- $title = $site_url;
- }
-
- if ($attributes != '')
- {
- $attributes = _parse_attributes($attributes);
- }
-
- return ''.$title.'';
- }
-}
-
-// ------------------------------------------------------------------------
-
-/**
- * Anchor Link - Pop-up version
- *
- * Creates an anchor based on the local URL. The link
- * opens a new window based on the attributes specified.
- *
- * @access public
- * @param string the URL
- * @param string the link title
- * @param mixed any attributes
- * @return string
- */
-if ( ! function_exists('anchor_popup'))
-{
- function anchor_popup($uri = '', $title = '', $attributes = FALSE)
- {
- $title = (string) $title;
-
- $site_url = ( ! preg_match('!^\w+://! i', $uri)) ? site_url($uri) : $uri;
-
- if ($title == '')
- {
- $title = $site_url;
- }
-
- if ($attributes === FALSE)
- {
- return "".$title."";
- }
-
- if ( ! is_array($attributes))
- {
- $attributes = array();
- }
-
- foreach (array('width' => '800', 'height' => '600', 'scrollbars' => 'yes', 'status' => 'yes', 'resizable' => 'yes', 'screenx' => '0', 'screeny' => '0', ) as $key => $val)
- {
- $atts[$key] = ( ! isset($attributes[$key])) ? $val : $attributes[$key];
- unset($attributes[$key]);
- }
-
- if ($attributes != '')
- {
- $attributes = _parse_attributes($attributes);
- }
-
- return "".$title."";
- }
-}
-
-// ------------------------------------------------------------------------
-
-/**
- * Mailto Link
- *
- * @access public
- * @param string the email address
- * @param string the link title
- * @param mixed any attributes
- * @return string
- */
-if ( ! function_exists('mailto'))
-{
- function mailto($email, $title = '', $attributes = '')
- {
- $title = (string) $title;
-
- if ($title == "")
- {
- $title = $email;
- }
-
- $attributes = _parse_attributes($attributes);
-
- return ''.$title.'';
- }
-}
-
-// ------------------------------------------------------------------------
-
-/**
- * Encoded Mailto Link
- *
- * Create a spam-protected mailto link written in Javascript
- *
- * @access public
- * @param string the email address
- * @param string the link title
- * @param mixed any attributes
- * @return string
- */
-if ( ! function_exists('safe_mailto'))
-{
- function safe_mailto($email, $title = '', $attributes = '')
- {
- $title = (string) $title;
-
- if ($title == "")
- {
- $title = $email;
- }
-
- for ($i = 0; $i < 16; $i++)
- {
- $x[] = substr(' $val)
- {
- $x[] = ' '.$key.'="';
- for ($i = 0; $i < strlen($val); $i++)
- {
- $x[] = "|".ord(substr($val, $i, 1));
- }
- $x[] = '"';
- }
- }
- else
- {
- for ($i = 0; $i < strlen($attributes); $i++)
- {
- $x[] = substr($attributes, $i, 1);
- }
- }
- }
-
- $x[] = '>';
-
- $temp = array();
- for ($i = 0; $i < strlen($title); $i++)
- {
- $ordinal = ord($title[$i]);
-
- if ($ordinal < 128)
- {
- $x[] = "|".$ordinal;
- }
- else
- {
- if (count($temp) == 0)
- {
- $count = ($ordinal < 224) ? 2 : 3;
- }
-
- $temp[] = $ordinal;
- if (count($temp) == $count)
- {
- $number = ($count == 3) ? (($temp['0'] % 16) * 4096) + (($temp['1'] % 64) * 64) + ($temp['2'] % 64) : (($temp['0'] % 32) * 64) + ($temp['1'] % 64);
- $x[] = "|".$number;
- $count = 1;
- $temp = array();
- }
- }
- }
-
- $x[] = '<'; $x[] = '/'; $x[] = 'a'; $x[] = '>';
-
- $x = array_reverse($x);
- ob_start();
-
- ?>http'.
- $matches['4'][$i].'://'.
- $matches['5'][$i].
- $matches['6'][$i].''.
- $period, $str);
- }
- }
- }
-
- if ($type != 'url')
- {
- if (preg_match_all("/([a-zA-Z0-9_\.\-\+Ã…]+)@([a-zA-Z0-9\-]+)\.([a-zA-Z0-9\-\.]*)/i", $str, $matches))
- {
- for ($i = 0; $i < sizeof($matches['0']); $i++)
- {
- $period = '';
- if (preg_match("|\.$|", $matches['3'][$i]))
- {
- $period = '.';
- $matches['3'][$i] = substr($matches['3'][$i], 0, -1);
- }
-
- $str = str_replace($matches['0'][$i], safe_mailto($matches['1'][$i].'@'.$matches['2'][$i].'.'.$matches['3'][$i]).$period, $str);
- }
- }
- }
-
- return $str;
- }
-}
-
-// ------------------------------------------------------------------------
-
-/**
- * Prep URL
- *
- * Simply adds the http:// part if missing
- *
- * @access public
- * @param string the URL
- * @return string
- */
-if ( ! function_exists('prep_url'))
-{
- function prep_url($str = '')
- {
- if ($str == 'http://' OR $str == '')
- {
- return '';
- }
-
- if (substr($str, 0, 7) != 'http://' && substr($str, 0, 8) != 'https://')
- {
- $str = 'http://'.$str;
- }
-
- return $str;
- }
-}
-
-// ------------------------------------------------------------------------
-
-/**
- * Create URL Title
- *
- * Takes a "title" string as input and creates a
- * human-friendly URL string with either a dash
- * or an underscore as the word separator.
- *
- * @access public
- * @param string the string
- * @param string the separator: dash, or underscore
- * @return string
- */
-if ( ! function_exists('url_title'))
-{
- function url_title($str, $separator = 'dash')
- {
- if ($separator == 'dash')
- {
- $search = '_';
- $replace = '-';
- }
- else
- {
- $search = '-';
- $replace = '_';
- }
-
- $trans = array(
- '&\#\d+?;' => '',
- '&\S+?;' => '',
- '\s+' => $replace,
- '[^a-z0-9\-\._]' => '',
- $replace.'+' => $replace,
- $replace.'$' => $replace,
- '^'.$replace => $replace
- );
-
- $str = strip_tags($str);
-
- foreach ($trans as $key => $val)
- {
- $str = preg_replace("#".$key."#i", $val, $str);
- }
-
- return trim(stripslashes($str));
- }
-}
-
-// ------------------------------------------------------------------------
-
-/**
- * Header Redirect
- *
- * Header redirect in two flavors
- * For very fine grained control over headers, you could use the Output
- * Library's set_header() function.
- *
- * @access public
- * @param string the URL
- * @param string the method: location or redirect
- * @return string
- */
-if ( ! function_exists('redirect'))
-{
- function redirect($uri = '', $method = 'location', $http_response_code = 302)
- {
- switch($method)
- {
- case 'refresh' : header("Refresh:0;url=".site_url($uri));
- break;
- default : header("Location: ".site_url($uri), TRUE, $http_response_code);
- break;
- }
- exit;
- }
-}
-
-// ------------------------------------------------------------------------
-
-/**
- * Parse out the attributes
- *
- * Some of the functions use this
- *
- * @access private
- * @param array
- * @param bool
- * @return string
- */
-if ( ! function_exists('_parse_attributes'))
-{
- function _parse_attributes($attributes, $javascript = FALSE)
- {
- if (is_string($attributes))
- {
- return ($attributes != '') ? ' '.$attributes : '';
- }
-
- $att = '';
- foreach ($attributes as $key => $val)
- {
- if ($javascript == TRUE)
- {
- $att .= $key . '=' . $val . ',';
- }
- else
- {
- $att .= ' ' . $key . '="' . $val . '"';
- }
- }
-
- if ($javascript == TRUE AND $att != '')
- {
- $att = substr($att, 0, -1);
- }
-
- return $att;
- }
-}
-
-
-/* End of file url_helper.php */
+config->site_url($uri);
+ }
+}
+
+// ------------------------------------------------------------------------
+
+/**
+ * Base URL
+ *
+ * Returns the "base_url" item from your config file
+ *
+ * @access public
+ * @return string
+ */
+if ( ! function_exists('base_url'))
+{
+ function base_url()
+ {
+ $CI =& get_instance();
+ return $CI->config->slash_item('base_url');
+ }
+}
+
+// ------------------------------------------------------------------------
+
+/**
+ * Current URL
+ *
+ * Returns the full URL (including segments) of the page where this
+ * function is placed
+ *
+ * @access public
+ * @return string
+ */
+if ( ! function_exists('current_url'))
+{
+ function current_url()
+ {
+ $CI =& get_instance();
+ return $CI->config->site_url($CI->uri->uri_string());
+ }
+}
+
+// ------------------------------------------------------------------------
+/**
+ * URL String
+ *
+ * Returns the URI segments.
+ *
+ * @access public
+ * @return string
+ */
+if ( ! function_exists('uri_string'))
+{
+ function uri_string()
+ {
+ $CI =& get_instance();
+ return $CI->uri->uri_string();
+ }
+}
+
+// ------------------------------------------------------------------------
+
+/**
+ * Index page
+ *
+ * Returns the "index_page" from your config file
+ *
+ * @access public
+ * @return string
+ */
+if ( ! function_exists('index_page'))
+{
+ function index_page()
+ {
+ $CI =& get_instance();
+ return $CI->config->item('index_page');
+ }
+}
+
+// ------------------------------------------------------------------------
+
+/**
+ * Anchor Link
+ *
+ * Creates an anchor based on the local URL.
+ *
+ * @access public
+ * @param string the URL
+ * @param string the link title
+ * @param mixed any attributes
+ * @return string
+ */
+if ( ! function_exists('anchor'))
+{
+ function anchor($uri = '', $title = '', $attributes = '')
+ {
+ $title = (string) $title;
+
+ if ( ! is_array($uri))
+ {
+ $site_url = ( ! preg_match('!^\w+://! i', $uri)) ? site_url($uri) : $uri;
+ }
+ else
+ {
+ $site_url = site_url($uri);
+ }
+
+ if ($title == '')
+ {
+ $title = $site_url;
+ }
+
+ if ($attributes != '')
+ {
+ $attributes = _parse_attributes($attributes);
+ }
+
+ return ''.$title.'';
+ }
+}
+
+// ------------------------------------------------------------------------
+
+/**
+ * Anchor Link - Pop-up version
+ *
+ * Creates an anchor based on the local URL. The link
+ * opens a new window based on the attributes specified.
+ *
+ * @access public
+ * @param string the URL
+ * @param string the link title
+ * @param mixed any attributes
+ * @return string
+ */
+if ( ! function_exists('anchor_popup'))
+{
+ function anchor_popup($uri = '', $title = '', $attributes = FALSE)
+ {
+ $title = (string) $title;
+
+ $site_url = ( ! preg_match('!^\w+://! i', $uri)) ? site_url($uri) : $uri;
+
+ if ($title == '')
+ {
+ $title = $site_url;
+ }
+
+ if ($attributes === FALSE)
+ {
+ return "".$title."";
+ }
+
+ if ( ! is_array($attributes))
+ {
+ $attributes = array();
+ }
+
+ foreach (array('width' => '800', 'height' => '600', 'scrollbars' => 'yes', 'status' => 'yes', 'resizable' => 'yes', 'screenx' => '0', 'screeny' => '0', ) as $key => $val)
+ {
+ $atts[$key] = ( ! isset($attributes[$key])) ? $val : $attributes[$key];
+ unset($attributes[$key]);
+ }
+
+ if ($attributes != '')
+ {
+ $attributes = _parse_attributes($attributes);
+ }
+
+ return "".$title."";
+ }
+}
+
+// ------------------------------------------------------------------------
+
+/**
+ * Mailto Link
+ *
+ * @access public
+ * @param string the email address
+ * @param string the link title
+ * @param mixed any attributes
+ * @return string
+ */
+if ( ! function_exists('mailto'))
+{
+ function mailto($email, $title = '', $attributes = '')
+ {
+ $title = (string) $title;
+
+ if ($title == "")
+ {
+ $title = $email;
+ }
+
+ $attributes = _parse_attributes($attributes);
+
+ return ''.$title.'';
+ }
+}
+
+// ------------------------------------------------------------------------
+
+/**
+ * Encoded Mailto Link
+ *
+ * Create a spam-protected mailto link written in Javascript
+ *
+ * @access public
+ * @param string the email address
+ * @param string the link title
+ * @param mixed any attributes
+ * @return string
+ */
+if ( ! function_exists('safe_mailto'))
+{
+ function safe_mailto($email, $title = '', $attributes = '')
+ {
+ $title = (string) $title;
+
+ if ($title == "")
+ {
+ $title = $email;
+ }
+
+ for ($i = 0; $i < 16; $i++)
+ {
+ $x[] = substr(' $val)
+ {
+ $x[] = ' '.$key.'="';
+ for ($i = 0; $i < strlen($val); $i++)
+ {
+ $x[] = "|".ord(substr($val, $i, 1));
+ }
+ $x[] = '"';
+ }
+ }
+ else
+ {
+ for ($i = 0; $i < strlen($attributes); $i++)
+ {
+ $x[] = substr($attributes, $i, 1);
+ }
+ }
+ }
+
+ $x[] = '>';
+
+ $temp = array();
+ for ($i = 0; $i < strlen($title); $i++)
+ {
+ $ordinal = ord($title[$i]);
+
+ if ($ordinal < 128)
+ {
+ $x[] = "|".$ordinal;
+ }
+ else
+ {
+ if (count($temp) == 0)
+ {
+ $count = ($ordinal < 224) ? 2 : 3;
+ }
+
+ $temp[] = $ordinal;
+ if (count($temp) == $count)
+ {
+ $number = ($count == 3) ? (($temp['0'] % 16) * 4096) + (($temp['1'] % 64) * 64) + ($temp['2'] % 64) : (($temp['0'] % 32) * 64) + ($temp['1'] % 64);
+ $x[] = "|".$number;
+ $count = 1;
+ $temp = array();
+ }
+ }
+ }
+
+ $x[] = '<'; $x[] = '/'; $x[] = 'a'; $x[] = '>';
+
+ $x = array_reverse($x);
+ ob_start();
+
+ ?>http'.
+ $matches['4'][$i].'://'.
+ $matches['5'][$i].
+ $matches['6'][$i].''.
+ $period, $str);
+ }
+ }
+ }
+
+ if ($type != 'url')
+ {
+ if (preg_match_all("/([a-zA-Z0-9_\.\-\+Ã…]+)@([a-zA-Z0-9\-]+)\.([a-zA-Z0-9\-\.]*)/i", $str, $matches))
+ {
+ for ($i = 0; $i < sizeof($matches['0']); $i++)
+ {
+ $period = '';
+ if (preg_match("|\.$|", $matches['3'][$i]))
+ {
+ $period = '.';
+ $matches['3'][$i] = substr($matches['3'][$i], 0, -1);
+ }
+
+ $str = str_replace($matches['0'][$i], safe_mailto($matches['1'][$i].'@'.$matches['2'][$i].'.'.$matches['3'][$i]).$period, $str);
+ }
+ }
+ }
+
+ return $str;
+ }
+}
+
+// ------------------------------------------------------------------------
+
+/**
+ * Prep URL
+ *
+ * Simply adds the http:// part if missing
+ *
+ * @access public
+ * @param string the URL
+ * @return string
+ */
+if ( ! function_exists('prep_url'))
+{
+ function prep_url($str = '')
+ {
+ if ($str == 'http://' OR $str == '')
+ {
+ return '';
+ }
+
+ if (substr($str, 0, 7) != 'http://' && substr($str, 0, 8) != 'https://')
+ {
+ $str = 'http://'.$str;
+ }
+
+ return $str;
+ }
+}
+
+// ------------------------------------------------------------------------
+
+/**
+ * Create URL Title
+ *
+ * Takes a "title" string as input and creates a
+ * human-friendly URL string with either a dash
+ * or an underscore as the word separator.
+ *
+ * @access public
+ * @param string the string
+ * @param string the separator: dash, or underscore
+ * @return string
+ */
+if ( ! function_exists('url_title'))
+{
+ function url_title($str, $separator = 'dash')
+ {
+ if ($separator == 'dash')
+ {
+ $search = '_';
+ $replace = '-';
+ }
+ else
+ {
+ $search = '-';
+ $replace = '_';
+ }
+
+ $trans = array(
+ '&\#\d+?;' => '',
+ '&\S+?;' => '',
+ '\s+' => $replace,
+ '[^a-z0-9\-\._]' => '',
+ $replace.'+' => $replace,
+ $replace.'$' => $replace,
+ '^'.$replace => $replace
+ );
+
+ $str = strip_tags($str);
+
+ foreach ($trans as $key => $val)
+ {
+ $str = preg_replace("#".$key."#i", $val, $str);
+ }
+
+ return trim(stripslashes($str));
+ }
+}
+
+// ------------------------------------------------------------------------
+
+/**
+ * Header Redirect
+ *
+ * Header redirect in two flavors
+ * For very fine grained control over headers, you could use the Output
+ * Library's set_header() function.
+ *
+ * @access public
+ * @param string the URL
+ * @param string the method: location or redirect
+ * @return string
+ */
+if ( ! function_exists('redirect'))
+{
+ function redirect($uri = '', $method = 'location', $http_response_code = 302)
+ {
+ switch($method)
+ {
+ case 'refresh' : header("Refresh:0;url=".site_url($uri));
+ break;
+ default : header("Location: ".site_url($uri), TRUE, $http_response_code);
+ break;
+ }
+ exit;
+ }
+}
+
+// ------------------------------------------------------------------------
+
+/**
+ * Parse out the attributes
+ *
+ * Some of the functions use this
+ *
+ * @access private
+ * @param array
+ * @param bool
+ * @return string
+ */
+if ( ! function_exists('_parse_attributes'))
+{
+ function _parse_attributes($attributes, $javascript = FALSE)
+ {
+ if (is_string($attributes))
+ {
+ return ($attributes != '') ? ' '.$attributes : '';
+ }
+
+ $att = '';
+ foreach ($attributes as $key => $val)
+ {
+ if ($javascript == TRUE)
+ {
+ $att .= $key . '=' . $val . ',';
+ }
+ else
+ {
+ $att .= ' ' . $key . '="' . $val . '"';
+ }
+ }
+
+ if ($javascript == TRUE AND $att != '')
+ {
+ $att = substr($att, 0, -1);
+ }
+
+ return $att;
+ }
+}
+
+
+/* End of file url_helper.php */
/* Location: ./system/helpers/url_helper.php */
\ No newline at end of file
diff --git a/system/helpers/xml_helper.php b/system/helpers/xml_helper.php
index 83e2bb3a0..90cce3dda 100644
--- a/system/helpers/xml_helper.php
+++ b/system/helpers/xml_helper.php
@@ -1,62 +1,62 @@
-","\"", "'", "-"),
- array("&", "<", ">", """, "'", "-"),
- $str);
-
- // Decode the temp markers back to entities
- $str = preg_replace("/$temp(\d+);/","\\1;",$str);
- $str = preg_replace("/$temp(\w+);/","&\\1;", $str);
-
- return $str;
- }
-}
-
-
-/* End of file xml_helper.php */
+","\"", "'", "-"),
+ array("&", "<", ">", """, "'", "-"),
+ $str);
+
+ // Decode the temp markers back to entities
+ $str = preg_replace("/$temp(\d+);/","\\1;",$str);
+ $str = preg_replace("/$temp(\w+);/","&\\1;", $str);
+
+ return $str;
+ }
+}
+
+
+/* End of file xml_helper.php */
/* Location: ./system/helpers/xml_helper.php */
\ No newline at end of file
--
cgit v1.2.3-24-g4f1b
From 40a2fc8ab781130761237a29455718d24cb23821 Mon Sep 17 00:00:00 2001
From: Derek Jones
Date: Tue, 9 Dec 2008 19:41:25 +0000
Subject: added $lowercase parameter to url_title() to allow forced lowercase
---
system/helpers/url_helper.php | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
(limited to 'system/helpers')
diff --git a/system/helpers/url_helper.php b/system/helpers/url_helper.php
index fd13dc2d4..9b449ea9e 100644
--- a/system/helpers/url_helper.php
+++ b/system/helpers/url_helper.php
@@ -471,7 +471,7 @@ if ( ! function_exists('prep_url'))
*/
if ( ! function_exists('url_title'))
{
- function url_title($str, $separator = 'dash')
+ function url_title($str, $separator = 'dash', $lowercase = FALSE)
{
if ($separator == 'dash')
{
@@ -501,6 +501,11 @@ if ( ! function_exists('url_title'))
$str = preg_replace("#".$key."#i", $val, $str);
}
+ if ($lowercase === TRUE)
+ {
+ $str = strtolower($str);
+ }
+
return trim(stripslashes($str));
}
}
--
cgit v1.2.3-24-g4f1b
From f1b721a3559e8eb95bc580a3f79c5c2e896c9932 Mon Sep 17 00:00:00 2001
From: Derek Jones
Date: Wed, 21 Jan 2009 17:52:13 +0000
Subject: Fixed a bug affecting some locales where word censoring would not
work on words beginning or ending with an accented character.
---
system/helpers/text_helper.php | 17 ++++++++++++-----
1 file changed, 12 insertions(+), 5 deletions(-)
(limited to 'system/helpers')
diff --git a/system/helpers/text_helper.php b/system/helpers/text_helper.php
index 6e61f776a..e79a2419d 100644
--- a/system/helpers/text_helper.php
+++ b/system/helpers/text_helper.php
@@ -230,21 +230,28 @@ if ( ! function_exists('word_censor'))
{
return $str;
}
+
+ $str = ' '.$str.' ';
+
+ // \w, \b and a few others do not match on a unicode character
+ // set for performance reasons. As a result words like über
+ // will not match on a word boundary. Instead, we'll assume that
+ // a bad word will be bookeneded by any of these characters.
+ $delim = '[-_\'\"`(){}<>\[\]|!?@#%&,.:;^~*+=\/ 0-9\n\r\t]';
- $str = ' '.$str.' ';
foreach ($censored as $badword)
{
if ($replacement != '')
{
- $str = preg_replace("/\b(".str_replace('\*', '\w*?', preg_quote($badword, '/')).")\b/i", $replacement, $str);
+ $str = preg_replace("/({$delim})(".str_replace('\*', '\w*?', preg_quote($badword, '/')).")({$delim})/i", "\\1{$replacement}\\3", $str);
}
else
{
- $str = preg_replace("/\b(".str_replace('\*', '\w*?', preg_quote($badword, '/')).")\b/ie", "str_repeat('#', strlen('\\1'))", $str);
+ $str = preg_replace("/({$delim})(".str_replace('\*', '\w*?', preg_quote($badword, '/')).")({$delim})/ie", "'\\1'.str_repeat('#', strlen('\\2')).'\\3'", $str);
}
}
-
- return trim($str);
+
+ return trim($str);
}
}
--
cgit v1.2.3-24-g4f1b
From 33559103ddf02648837c85ed72425ac06c06080c Mon Sep 17 00:00:00 2001
From: Derek Jones
Date: Mon, 2 Feb 2009 18:50:38 +0000
Subject: replaced all sizeof() in favor of count() - aliases are teh sux0r
---
system/helpers/url_helper.php | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
(limited to 'system/helpers')
diff --git a/system/helpers/url_helper.php b/system/helpers/url_helper.php
index 9b449ea9e..6c3bc837a 100644
--- a/system/helpers/url_helper.php
+++ b/system/helpers/url_helper.php
@@ -382,7 +382,7 @@ if ( ! function_exists('auto_link'))
{
$pop = ($popup == TRUE) ? " target=\"_blank\" " : "";
- for ($i = 0; $i < sizeof($matches['0']); $i++)
+ for ($i = 0; $i < count($matches['0']); $i++)
{
$period = '';
if (preg_match("|\.$|", $matches['6'][$i]))
@@ -408,7 +408,7 @@ if ( ! function_exists('auto_link'))
{
if (preg_match_all("/([a-zA-Z0-9_\.\-\+Ã…]+)@([a-zA-Z0-9\-]+)\.([a-zA-Z0-9\-\.]*)/i", $str, $matches))
{
- for ($i = 0; $i < sizeof($matches['0']); $i++)
+ for ($i = 0; $i < count($matches['0']); $i++)
{
$period = '';
if (preg_match("|\.$|", $matches['3'][$i]))
--
cgit v1.2.3-24-g4f1b
From 01d6b4f663588e80ca43deafc40090c910eb4b35 Mon Sep 17 00:00:00 2001
From: Derek Jones
Date: Tue, 3 Feb 2009 14:51:00 +0000
Subject: Fixed a bug where the end character was being added when the
character limit's limit intersected the last word of the string.
http://expressionengine.com/forums/viewthread/103748/
---
system/helpers/text_helper.php | 10 ++++++----
1 file changed, 6 insertions(+), 4 deletions(-)
(limited to 'system/helpers')
diff --git a/system/helpers/text_helper.php b/system/helpers/text_helper.php
index e79a2419d..fa1de8bc6 100644
--- a/system/helpers/text_helper.php
+++ b/system/helpers/text_helper.php
@@ -87,14 +87,16 @@ if ( ! function_exists('character_limiter'))
{
return $str;
}
-
+
$out = "";
foreach (explode(' ', trim($str)) as $val)
{
- $out .= $val.' ';
+ $out .= $val.' ';
+
if (strlen($out) >= $n)
{
- return trim($out).$end_char;
+ $out = trim($out);
+ return (strlen($out) == strlen($str)) ? $out : $out.$end_char;
}
}
}
@@ -236,7 +238,7 @@ if ( ! function_exists('word_censor'))
// \w, \b and a few others do not match on a unicode character
// set for performance reasons. As a result words like über
// will not match on a word boundary. Instead, we'll assume that
- // a bad word will be bookeneded by any of these characters.
+ // a bad word will be bookended by any of these characters.
$delim = '[-_\'\"`(){}<>\[\]|!?@#%&,.:;^~*+=\/ 0-9\n\r\t]';
foreach ($censored as $badword)
--
cgit v1.2.3-24-g4f1b
From 1978e12d4221fe7e61749a3206b086e5d4158f77 Mon Sep 17 00:00:00 2001
From: Derek Jones
Date: Tue, 3 Feb 2009 14:54:43 +0000
Subject: tweak to ascii_to_entities() for low ascii entities
---
system/helpers/text_helper.php | 12 +++++++++++-
1 file changed, 11 insertions(+), 1 deletion(-)
(limited to 'system/helpers')
diff --git a/system/helpers/text_helper.php b/system/helpers/text_helper.php
index fa1de8bc6..ad051cd76 100644
--- a/system/helpers/text_helper.php
+++ b/system/helpers/text_helper.php
@@ -127,7 +127,17 @@ if ( ! function_exists('ascii_to_entities'))
if ($ordinal < 128)
{
- $out .= $str[$i];
+ /*
+ If the $temp array has a value but we have moved on, then it seems only
+ fair that we output that entity and restart $temp before continuing. -Paul
+ */
+ if (count($temp) == 1)
+ {
+ $out .= ''.array_shift($temp).';';
+ $count = 1;
+ }
+
+ $out .= $str[$i];
}
else
{
--
cgit v1.2.3-24-g4f1b
From 78a5fc973844c64fe9ead260948b85efaf680da9 Mon Sep 17 00:00:00 2001
From: Derek Allard
Date: Thu, 5 Feb 2009 16:34:35 +0000
Subject: Added the ability to have optgroups in form_dropdown() within the
form helper.
---
system/helpers/form_helper.php | 21 ++++++++++++++++++---
1 file changed, 18 insertions(+), 3 deletions(-)
(limited to 'system/helpers')
diff --git a/system/helpers/form_helper.php b/system/helpers/form_helper.php
index c002c6fc0..01d0ea76d 100644
--- a/system/helpers/form_helper.php
+++ b/system/helpers/form_helper.php
@@ -268,11 +268,26 @@ if ( ! function_exists('form_dropdown'))
foreach ($options as $key => $val)
{
$key = (string) $key;
- $val = (string) $val;
- $sel = (in_array($key, $selected))?' selected="selected"':'';
+ if (is_array($val))
+ {
+ $form .= ''."\n";
+ }
+ else
+ {
+ $sel = (in_array($key, $selected)) ? ' selected="selected"' : '';
+
+ $form .= '\n";
+ }
}
$form .= '';
--
cgit v1.2.3-24-g4f1b
From 86a840cc46ec3f0b8a83938e665a52e625b9f3c7 Mon Sep 17 00:00:00 2001
From: Derek Allard
Date: Thu, 5 Feb 2009 17:31:58 +0000
Subject: wrong var fix
---
system/helpers/form_helper.php | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
(limited to 'system/helpers')
diff --git a/system/helpers/form_helper.php b/system/helpers/form_helper.php
index 01d0ea76d..8cae91a41 100644
--- a/system/helpers/form_helper.php
+++ b/system/helpers/form_helper.php
@@ -275,7 +275,7 @@ if ( ! function_exists('form_dropdown'))
foreach ($val as $optgroup_key => $optgroup_val)
{
- $sel = (in_array($key, $selected)) ? ' selected="selected"' : '';
+ $sel = (in_array($optgroup_key, $selected)) ? ' selected="selected"' : '';
$form .= '\n";
}
--
cgit v1.2.3-24-g4f1b
From 904094a177488edeacbe8e184d788c286c3e3d9f Mon Sep 17 00:00:00 2001
From: Derek Allard
Date: Tue, 10 Feb 2009 14:00:34 +0000
Subject: Changed the default "type" of form_button() to "button" from "submit"
in the form helper.
---
system/helpers/form_helper.php | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
(limited to 'system/helpers')
diff --git a/system/helpers/form_helper.php b/system/helpers/form_helper.php
index 8cae91a41..4a62cdb5e 100644
--- a/system/helpers/form_helper.php
+++ b/system/helpers/form_helper.php
@@ -424,7 +424,7 @@ if ( ! function_exists('form_button'))
{
function form_button($data = '', $content = '', $extra = '')
{
- $defaults = array('name' => (( ! is_array($data)) ? $data : ''), 'type' => 'submit');
+ $defaults = array('name' => (( ! is_array($data)) ? $data : ''), 'type' => 'button');
if ( is_array($data) AND isset($data['content']))
{
--
cgit v1.2.3-24-g4f1b
From a6aabaff9a396436d36b57df84eec77ee72e70ed Mon Sep 17 00:00:00 2001
From: Derek Jones
Date: Tue, 10 Feb 2009 17:37:52 +0000
Subject: Fixed a bug in plural() with words that end in y
http://codeigniter.com/bug_tracker/bug/6342/
---
system/helpers/inflector_helper.php | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
(limited to 'system/helpers')
diff --git a/system/helpers/inflector_helper.php b/system/helpers/inflector_helper.php
index 9393f11e4..39db5d4af 100644
--- a/system/helpers/inflector_helper.php
+++ b/system/helpers/inflector_helper.php
@@ -87,7 +87,9 @@ if ( ! function_exists('plural'))
if ($end == 'y')
{
- $str = substr($str, 0, strlen($str)-1).'ies';
+ // Y preceded by vowel => regular plural
+ $vowels = array('a', 'e', 'i', 'o', 'u');
+ $str = in_array(substr($str, -2, 1), $vowels) ? $str.'s' : substr($str, 0, -1).'ies';
}
elseif ($end == 's')
{
--
cgit v1.2.3-24-g4f1b
From f0bcb3c9c41ba4a7236908e2997eb56109ad9592 Mon Sep 17 00:00:00 2001
From: Derek Jones
Date: Tue, 10 Feb 2009 18:40:21 +0000
Subject: udpated xss_clean() in the security helper to pass $is_image instead
of the deprecated $charset
http://codeigniter.com/bug_tracker/bug/6706/
---
system/helpers/security_helper.php | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
(limited to 'system/helpers')
diff --git a/system/helpers/security_helper.php b/system/helpers/security_helper.php
index 0e2ba788d..4dbbf728a 100644
--- a/system/helpers/security_helper.php
+++ b/system/helpers/security_helper.php
@@ -32,15 +32,15 @@
*
* @access public
* @param string
- * @param string the character set of your data
+ * @param bool whether or not the content is an image file
* @return string
*/
if ( ! function_exists('xss_clean'))
{
- function xss_clean($str, $charset = 'ISO-8859-1')
+ function xss_clean($str, $is_image = FALSE)
{
$CI =& get_instance();
- return $CI->input->xss_clean($str, $charset);
+ return $CI->input->xss_clean($str, $is_image);
}
}
--
cgit v1.2.3-24-g4f1b
From 534be03fdc52bdaeb48ffe89cb6aa042ad1890ad Mon Sep 17 00:00:00 2001
From: Derek Jones
Date: Tue, 10 Feb 2009 18:47:47 +0000
Subject: changed redirect() to only force site_url() when the supplied URL
doesn't start with an http protocol, allowing you to use the helper for
external URLs.
---
system/helpers/url_helper.php | 9 +++++++--
1 file changed, 7 insertions(+), 2 deletions(-)
(limited to 'system/helpers')
diff --git a/system/helpers/url_helper.php b/system/helpers/url_helper.php
index 6c3bc837a..5be43300e 100644
--- a/system/helpers/url_helper.php
+++ b/system/helpers/url_helper.php
@@ -528,11 +528,16 @@ if ( ! function_exists('redirect'))
{
function redirect($uri = '', $method = 'location', $http_response_code = 302)
{
+ if ( ! preg_match('#^https?://#i', $uri))
+ {
+ $uri = site_url($uri);
+ }
+
switch($method)
{
- case 'refresh' : header("Refresh:0;url=".site_url($uri));
+ case 'refresh' : header("Refresh:0;url=".$uri);
break;
- default : header("Location: ".site_url($uri), TRUE, $http_response_code);
+ default : header("Location: ".$uri, TRUE, $http_response_code);
break;
}
exit;
--
cgit v1.2.3-24-g4f1b
From 0b2145f96b6c05aefb51cccb643d203b83a0d761 Mon Sep 17 00:00:00 2001
From: Derek Jones
Date: Tue, 10 Feb 2009 18:56:01 +0000
Subject: Added trailing periods as characters to be removed in url_title()
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Removed an extraneous Ã… character from the file that crept in from somewhere
---
system/helpers/url_helper.php | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
(limited to 'system/helpers')
diff --git a/system/helpers/url_helper.php b/system/helpers/url_helper.php
index 5be43300e..958c16c4b 100644
--- a/system/helpers/url_helper.php
+++ b/system/helpers/url_helper.php
@@ -406,7 +406,7 @@ if ( ! function_exists('auto_link'))
if ($type != 'url')
{
- if (preg_match_all("/([a-zA-Z0-9_\.\-\+Ã…]+)@([a-zA-Z0-9\-]+)\.([a-zA-Z0-9\-\.]*)/i", $str, $matches))
+ if (preg_match_all("/([a-zA-Z0-9_\.\-\+]+)@([a-zA-Z0-9\-]+)\.([a-zA-Z0-9\-\.]*)/i", $str, $matches))
{
for ($i = 0; $i < count($matches['0']); $i++)
{
@@ -491,7 +491,8 @@ if ( ! function_exists('url_title'))
'[^a-z0-9\-\._]' => '',
$replace.'+' => $replace,
$replace.'$' => $replace,
- '^'.$replace => $replace
+ '^'.$replace => $replace,
+ '\.+$' => ''
);
$str = strip_tags($str);
--
cgit v1.2.3-24-g4f1b
From 2c8dc585dd4134e71a7356f99b6a0dac12bf9d1a Mon Sep 17 00:00:00 2001
From: Derek Jones
Date: Tue, 10 Feb 2009 20:15:49 +0000
Subject: added global cookie prefix to get_cookie() unless the cookie exists
as-requested
---
system/helpers/cookie_helper.php | 10 ++++++++--
1 file changed, 8 insertions(+), 2 deletions(-)
(limited to 'system/helpers')
diff --git a/system/helpers/cookie_helper.php b/system/helpers/cookie_helper.php
index d906882ae..77f86e489 100644
--- a/system/helpers/cookie_helper.php
+++ b/system/helpers/cookie_helper.php
@@ -107,8 +107,14 @@ if ( ! function_exists('get_cookie'))
{
function get_cookie($index = '', $xss_clean = FALSE)
{
- $CI =& get_instance();
- return $CI->input->cookie($index, $xss_clean);
+ $prefix = '';
+
+ if ( ! isset($_COOKIE[$index]) && config_item('cookie_prefix') != '')
+ {
+ $prefix = config_item('cookie_prefix');
+ }
+
+ return $CI->input->cookie($prefix.$index, $xss_clean);
}
}
--
cgit v1.2.3-24-g4f1b
From a04cfa77a3b113e5a9d858466bc9ae9f674081fb Mon Sep 17 00:00:00 2001
From: Derek Jones
Date: Tue, 10 Feb 2009 20:16:57 +0000
Subject: didn't mean to completely remove the CI superobject from
get_cookie...
---
system/helpers/cookie_helper.php | 2 ++
1 file changed, 2 insertions(+)
(limited to 'system/helpers')
diff --git a/system/helpers/cookie_helper.php b/system/helpers/cookie_helper.php
index 77f86e489..8d892a5d6 100644
--- a/system/helpers/cookie_helper.php
+++ b/system/helpers/cookie_helper.php
@@ -107,6 +107,8 @@ if ( ! function_exists('get_cookie'))
{
function get_cookie($index = '', $xss_clean = FALSE)
{
+ $CI =& get_instance();
+
$prefix = '';
if ( ! isset($_COOKIE[$index]) && config_item('cookie_prefix') != '')
--
cgit v1.2.3-24-g4f1b
From 63dc27f30ed9327060e7e423a99b67a2f19b8f36 Mon Sep 17 00:00:00 2001
From: Derek Jones
Date: Tue, 10 Feb 2009 21:59:20 +0000
Subject: declared $_filedata as static so it can work properly with recursion
through subdirectories
http://codeigniter.com/bug_tracker/bug/6592/
---
system/helpers/file_helper.php | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
(limited to 'system/helpers')
diff --git a/system/helpers/file_helper.php b/system/helpers/file_helper.php
index 8078d96fa..b0c554658 100644
--- a/system/helpers/file_helper.php
+++ b/system/helpers/file_helper.php
@@ -223,7 +223,7 @@ if ( ! function_exists('get_dir_file_info'))
{
function get_dir_file_info($source_dir, $include_path = FALSE, $_recursion = FALSE)
{
- $_filedata = array();
+ static $_filedata = array();
$relative_path = $source_dir;
if ($fp = @opendir($source_dir))
--
cgit v1.2.3-24-g4f1b
From 28e5c8fc0ed79017a67b896613698e98fa7da8b3 Mon Sep 17 00:00:00 2001
From: Rick Ellis
Date: Mon, 9 Mar 2009 22:36:48 +0000
Subject: Fixed a bug that was not setting the default checkbox/radio/pull-down
value correctly
---
system/helpers/form_helper.php | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
(limited to 'system/helpers')
diff --git a/system/helpers/form_helper.php b/system/helpers/form_helper.php
index 4a62cdb5e..05616f707 100644
--- a/system/helpers/form_helper.php
+++ b/system/helpers/form_helper.php
@@ -644,7 +644,7 @@ if ( ! function_exists('set_select'))
{
if ( ! isset($_POST[$field]))
{
- if (count($_POST) === 0)
+ if (count($_POST) === 0 AND $default == TRUE)
{
return ' selected="selected"';
}
@@ -699,7 +699,7 @@ if ( ! function_exists('set_checkbox'))
{
if ( ! isset($_POST[$field]))
{
- if (count($_POST) === 0)
+ if (count($_POST) === 0 AND $default == TRUE)
{
return ' checked="checked"';
}
@@ -754,7 +754,7 @@ if ( ! function_exists('set_radio'))
{
if ( ! isset($_POST[$field]))
{
- if (count($_POST) === 0)
+ if (count($_POST) === 0 AND $default == TRUE)
{
return ' checked="checked"';
}
--
cgit v1.2.3-24-g4f1b
From 1322ec54289f09f7e176924902d5642f269aec48 Mon Sep 17 00:00:00 2001
From: Derek Jones
Date: Wed, 11 Mar 2009 17:01:14 +0000
Subject: ereg eradication
---
system/helpers/date_helper.php | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
(limited to 'system/helpers')
diff --git a/system/helpers/date_helper.php b/system/helpers/date_helper.php
index dbd7e0ecc..7f6073427 100644
--- a/system/helpers/date_helper.php
+++ b/system/helpers/date_helper.php
@@ -460,7 +460,7 @@ if ( ! function_exists('human_to_unix'))
$hour = (strlen($ex['0']) == 1) ? '0'.$ex['0'] : $ex['0'];
$min = (strlen($ex['1']) == 1) ? '0'.$ex['1'] : $ex['1'];
- if (isset($ex['2']) AND ereg("[0-9]{1,2}", $ex['2']))
+ if (isset($ex['2']) && preg_match('/[0-9]{1,2}/', $ex['2']))
{
$sec = (strlen($ex['2']) == 1) ? '0'.$ex['2'] : $ex['2'];
}
--
cgit v1.2.3-24-g4f1b
From 57fe41072c9d97d3cba2cd5faef529ac94571bfb Mon Sep 17 00:00:00 2001
From: Robin Sowell
Date: Thu, 26 Mar 2009 18:58:46 +0000
Subject: Modified form_hidden() to accept multi-dimensional arrays.
---
system/helpers/form_helper.php | 32 ++++++++++++++++++++++++--------
1 file changed, 24 insertions(+), 8 deletions(-)
(limited to 'system/helpers')
diff --git a/system/helpers/form_helper.php b/system/helpers/form_helper.php
index 05616f707..0173340c5 100644
--- a/system/helpers/form_helper.php
+++ b/system/helpers/form_helper.php
@@ -103,19 +103,35 @@ if ( ! function_exists('form_open_multipart'))
*/
if ( ! function_exists('form_hidden'))
{
- function form_hidden($name, $value = '')
+ function form_hidden($name, $value = '', $recursing = FALSE)
{
- if ( ! is_array($name))
+ static $form;
+
+ if ($recursing === FALSE)
{
- return '';
+ $form = "\n";
}
- $form = '';
+ if (is_array($name))
+ {
+ foreach ($name as $key => $val)
+ {
+ form_hidden($key, $val, TRUE);
+ }
+ return $form;
+ }
- foreach ($name as $name => $value)
+ if ( ! is_array($value))
+ {
+ $form .= ''."\n";
+ }
+ else
{
- $form .= "\n";
- $form .= '';
+ foreach ($value as $k => $v)
+ {
+ $k = (is_int($k)) ? '' : $k;
+ form_hidden($name.'['.$k.']', $v, TRUE);
+ }
}
return $form;
@@ -264,7 +280,7 @@ if ( ! function_exists('form_dropdown'))
$multiple = (count($selected) > 1 && strpos($extra, 'multiple') === FALSE) ? ' multiple="multiple"' : '';
$form = '