first commit

This commit is contained in:
alazhar
2020-01-02 22:49:45 +07:00
commit 2662cbccd5
390 changed files with 81624 additions and 0 deletions

View File

@ -0,0 +1,119 @@
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/**
* CodeIgniter
*
* An open source application development framework for PHP 5.1.6 or newer
*
* @package CodeIgniter
* @author ExpressionEngine Dev Team
* @copyright Copyright (c) 2008 - 2011, EllisLab, Inc.
* @license http://codeigniter.com/user_guide/license.html
* @link http://codeigniter.com
* @since Version 1.0
* @filesource
*/
// ------------------------------------------------------------------------
/**
* CodeIgniter Array Helpers
*
* @package CodeIgniter
* @subpackage Helpers
* @category Helpers
* @author ExpressionEngine Dev Team
* @link http://codeigniter.com/user_guide/helpers/array_helper.html
*/
// ------------------------------------------------------------------------
/**
* Element
*
* Lets you determine whether an array index is set and whether it has a value.
* If the element is empty it returns FALSE (or whatever you specify as the default value.)
*
* @access public
* @param string
* @param array
* @param mixed
* @return mixed depends on what the array contains
*/
if ( ! function_exists('element'))
{
function element($item, $array, $default = FALSE)
{
if ( ! isset($array[$item]) OR $array[$item] == "")
{
return $default;
}
return $array[$item];
}
}
// ------------------------------------------------------------------------
/**
* Random Element - Takes an array as input and returns a random element
*
* @access public
* @param array
* @return mixed depends on what the array contains
*/
if ( ! function_exists('random_element'))
{
function random_element($array)
{
if ( ! is_array($array))
{
return $array;
}
return $array[array_rand($array)];
}
}
// --------------------------------------------------------------------
/**
* Elements
*
* Returns only the array items specified. Will return a default value if
* it is not set.
*
* @access public
* @param array
* @param array
* @param mixed
* @return mixed depends on what the array contains
*/
if ( ! function_exists('elements'))
{
function elements($items, $array, $default = FALSE)
{
$return = array();
if ( ! is_array($items))
{
$items = array($items);
}
foreach ($items as $item)
{
if (isset($array[$item]))
{
$return[$item] = $array[$item];
}
else
{
$return[$item] = $default;
}
}
return $return;
}
}
/* End of file array_helper.php */
/* Location: ./system/helpers/array_helper.php */

View File

@ -0,0 +1,246 @@
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/**
* CodeIgniter
*
* An open source application development framework for PHP 5.1.6 or newer
*
* @package CodeIgniter
* @author ExpressionEngine Dev Team
* @copyright Copyright (c) 2008 - 2011, EllisLab, Inc.
* @license http://codeigniter.com/user_guide/license.html
* @link http://codeigniter.com
* @since Version 1.0
* @filesource
*/
// ------------------------------------------------------------------------
/**
* CodeIgniter CAPTCHA Helper
*
* @package CodeIgniter
* @subpackage Helpers
* @category Helpers
* @author ExpressionEngine Dev Team
* @link http://codeigniter.com/user_guide/helpers/xml_helper.html
*/
// ------------------------------------------------------------------------
/**
* Create CAPTCHA
*
* @access public
* @param array array of data for the CAPTCHA
* @param string path to create the image in
* @param string URL to the CAPTCHA image folder
* @param string server path to font
* @return string
*/
if ( ! function_exists('create_captcha'))
{
function create_captcha($data = '', $img_path = '', $img_url = '', $font_path = '')
{
$defaults = array('word' => '', 'img_path' => '', 'img_url' => '', 'img_width' => '150', 'img_height' => '30', 'font_path' => '', 'expiration' => 7200);
foreach ($defaults as $key => $val)
{
if ( ! is_array($data))
{
if ( ! isset($$key) OR $$key == '')
{
$$key = $val;
}
}
else
{
$$key = ( ! isset($data[$key])) ? $val : $data[$key];
}
}
if ($img_path == '' OR $img_url == '')
{
return FALSE;
}
if ( ! @is_dir($img_path))
{
return FALSE;
}
if ( ! is_writable($img_path))
{
return FALSE;
}
if ( ! extension_loaded('gd'))
{
return FALSE;
}
// -----------------------------------
// Remove old images
// -----------------------------------
list($usec, $sec) = explode(" ", microtime());
$now = ((float)$usec + (float)$sec);
$current_dir = @opendir($img_path);
while ($filename = @readdir($current_dir))
{
if ($filename != "." and $filename != ".." and $filename != "index.html")
{
$name = str_replace(".jpg", "", $filename);
if (($name + $expiration) < $now)
{
@unlink($img_path.$filename);
}
}
}
@closedir($current_dir);
// -----------------------------------
// Do we have a "word" yet?
// -----------------------------------
if ($word == '')
{
$pool = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
$str = '';
for ($i = 0; $i < 8; $i++)
{
$str .= substr($pool, mt_rand(0, strlen($pool) -1), 1);
}
$word = $str;
}
// -----------------------------------
// Determine angle and position
// -----------------------------------
$length = strlen($word);
$angle = ($length >= 6) ? rand(-($length-6), ($length-6)) : 0;
$x_axis = rand(6, (360/$length)-16);
$y_axis = ($angle >= 0 ) ? rand($img_height, $img_width) : rand(6, $img_height);
// -----------------------------------
// Create image
// -----------------------------------
// PHP.net recommends imagecreatetruecolor(), but it isn't always available
if (function_exists('imagecreatetruecolor'))
{
$im = imagecreatetruecolor($img_width, $img_height);
}
else
{
$im = imagecreate($img_width, $img_height);
}
// -----------------------------------
// Assign colors
// -----------------------------------
$bg_color = imagecolorallocate ($im, 255, 255, 255);
$border_color = imagecolorallocate ($im, 153, 102, 102);
$text_color = imagecolorallocate ($im, 204, 153, 153);
$grid_color = imagecolorallocate($im, 255, 182, 182);
$shadow_color = imagecolorallocate($im, 255, 240, 240);
// -----------------------------------
// Create the rectangle
// -----------------------------------
ImageFilledRectangle($im, 0, 0, $img_width, $img_height, $bg_color);
// -----------------------------------
// Create the spiral pattern
// -----------------------------------
$theta = 1;
$thetac = 7;
$radius = 16;
$circles = 20;
$points = 32;
for ($i = 0; $i < ($circles * $points) - 1; $i++)
{
$theta = $theta + $thetac;
$rad = $radius * ($i / $points );
$x = ($rad * cos($theta)) + $x_axis;
$y = ($rad * sin($theta)) + $y_axis;
$theta = $theta + $thetac;
$rad1 = $radius * (($i + 1) / $points);
$x1 = ($rad1 * cos($theta)) + $x_axis;
$y1 = ($rad1 * sin($theta )) + $y_axis;
imageline($im, $x, $y, $x1, $y1, $grid_color);
$theta = $theta - $thetac;
}
// -----------------------------------
// Write the text
// -----------------------------------
$use_font = ($font_path != '' AND file_exists($font_path) AND function_exists('imagettftext')) ? TRUE : FALSE;
if ($use_font == FALSE)
{
$font_size = 5;
$x = rand(0, $img_width/($length/3));
$y = 0;
}
else
{
$font_size = 16;
$x = rand(0, $img_width/($length/1.5));
$y = $font_size+2;
}
for ($i = 0; $i < strlen($word); $i++)
{
if ($use_font == FALSE)
{
$y = rand(0 , $img_height/2);
imagestring($im, $font_size, $x, $y, substr($word, $i, 1), $text_color);
$x += ($font_size*2);
}
else
{
$y = rand($img_height/2, $img_height-3);
imagettftext($im, $font_size, $angle, $x, $y, $text_color, $font_path, substr($word, $i, 1));
$x += $font_size;
}
}
// -----------------------------------
// Create the border
// -----------------------------------
imagerectangle($im, 0, 0, $img_width-1, $img_height-1, $border_color);
// -----------------------------------
// Generate the image
// -----------------------------------
$img_name = $now.'.jpg';
ImageJPEG($im, $img_path.$img_name);
$img = "<img src=\"$img_url$img_name\" width=\"$img_width\" height=\"$img_height\" style=\"border:0;\" alt=\" \" />";
ImageDestroy($im);
return array('word' => $word, 'time' => $now, 'image' => $img);
}
}
// ------------------------------------------------------------------------
/* End of file captcha_helper.php */
/* Location: ./system/heleprs/captcha_helper.php */

View File

@ -0,0 +1,103 @@
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/**
* CodeIgniter
*
* An open source application development framework for PHP 5.1.6 or newer
*
* @package CodeIgniter
* @author ExpressionEngine Dev Team
* @copyright Copyright (c) 2008 - 2011, EllisLab, Inc.
* @license http://codeigniter.com/user_guide/license.html
* @link http://codeigniter.com
* @since Version 1.0
* @filesource
*/
// ------------------------------------------------------------------------
/**
* CodeIgniter Cookie Helpers
*
* @package CodeIgniter
* @subpackage Helpers
* @category Helpers
* @author ExpressionEngine Dev Team
* @link http://codeigniter.com/user_guide/helpers/cookie_helper.html
*/
// ------------------------------------------------------------------------
/**
* Set cookie
*
* Accepts six parameter, or you can submit an associative
* array in the first parameter containing all the values.
*
* @access public
* @param mixed
* @param string the value of the cookie
* @param string the number of seconds until expiration
* @param string the cookie domain. Usually: .yourdomain.com
* @param string the cookie path
* @param string the cookie prefix
* @return void
*/
if ( ! function_exists('set_cookie'))
{
function set_cookie($name = '', $value = '', $expire = '', $domain = '', $path = '/', $prefix = '', $secure = FALSE)
{
// Set the config file options
$CI =& get_instance();
$CI->input->set_cookie($name, $value, $expire, $domain, $path, $prefix, $secure);
}
}
// --------------------------------------------------------------------
/**
* Fetch an item from the COOKIE array
*
* @access public
* @param string
* @param bool
* @return mixed
*/
if ( ! function_exists('get_cookie'))
{
function get_cookie($index = '', $xss_clean = FALSE)
{
$CI =& get_instance();
$prefix = '';
if ( ! isset($_COOKIE[$index]) && config_item('cookie_prefix') != '')
{
$prefix = config_item('cookie_prefix');
}
return $CI->input->cookie($prefix.$index, $xss_clean);
}
}
// --------------------------------------------------------------------
/**
* Delete a COOKIE
*
* @param mixed
* @param string the cookie domain. Usually: .yourdomain.com
* @param string the cookie path
* @param string the cookie prefix
* @return void
*/
if ( ! function_exists('delete_cookie'))
{
function delete_cookie($name = '', $domain = '', $path = '/', $prefix = '')
{
set_cookie($name, '', '', $domain, $path, $prefix);
}
}
/* End of file cookie_helper.php */
/* Location: ./system/helpers/cookie_helper.php */

View File

@ -0,0 +1,611 @@
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/**
* CodeIgniter
*
* An open source application development framework for PHP 5.1.6 or newer
*
* @package CodeIgniter
* @author ExpressionEngine Dev Team
* @copyright Copyright (c) 2008 - 2011, EllisLab, Inc.
* @license http://codeigniter.com/user_guide/license.html
* @link http://codeigniter.com
* @since Version 1.0
* @filesource
*/
// ------------------------------------------------------------------------
/**
* CodeIgniter Date Helpers
*
* @package CodeIgniter
* @subpackage Helpers
* @category Helpers
* @author ExpressionEngine Dev Team
* @link http://codeigniter.com/user_guide/helpers/date_helper.html
*/
// ------------------------------------------------------------------------
/**
* Get "now" time
*
* Returns time() or its GMT equivalent based on the config file preference
*
* @access public
* @return integer
*/
if ( ! function_exists('now'))
{
function now()
{
$CI =& get_instance();
if (strtolower($CI->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
*/
if ( ! function_exists('mdate'))
{
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);
}
}
// ------------------------------------------------------------------------
/**
* Standard Date
*
* Returns a date formatted according to the submitted standard.
*
* @access public
* @param string the chosen format
* @param integer Unix timestamp
* @return string
*/
if ( ! function_exists('standard_date'))
{
function standard_date($fmt = 'DATE_RFC822', $time = '')
{
$formats = array(
'DATE_ATOM' => '%Y-%m-%dT%H:%i:%s%Q',
'DATE_COOKIE' => '%l, %d-%M-%y %H:%i:%s UTC',
'DATE_ISO8601' => '%Y-%m-%dT%H:%i:%s%Q',
'DATE_RFC822' => '%D, %d %M %y %H:%i:%s %O',
'DATE_RFC850' => '%l, %d-%M-%y %H:%i:%s UTC',
'DATE_RFC1036' => '%D, %d %M %y %H:%i:%s %O',
'DATE_RFC1123' => '%D, %d %M %Y %H:%i:%s %O',
'DATE_RSS' => '%D, %d %M %Y %H:%i:%s %O',
'DATE_W3C' => '%Y-%m-%dT%H:%i:%s%Q'
);
if ( ! isset($formats[$fmt]))
{
return FALSE;
}
return mdate($formats[$fmt], $time);
}
}
// ------------------------------------------------------------------------
/**
* Timespan
*
* 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
*/
if ( ! function_exists('timespan'))
{
function timespan($seconds = 1, $time = '')
{
$CI =& get_instance();
$CI->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.' '.$CI->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.' '.$CI->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.' '.$CI->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.' '.$CI->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.' '.$CI->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.' '.$CI->lang->line((($minutes > 1) ? 'date_minutes' : 'date_minute')).', ';
}
$seconds -= $minutes * 60;
}
if ($str == '')
{
$str .= $seconds.' '.$CI->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
*/
if ( ! function_exists('days_in_month'))
{
function days_in_month($month = 0, $year = '')
{
if ($month < 1 OR $month > 12)
{
return 0;
}
if ( ! is_numeric($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
*/
if ( ! function_exists('local_to_gmt'))
{
function local_to_gmt($time = '')
{
if ($time == '')
$time = time();
return mktime( gmdate("H", $time), gmdate("i", $time), gmdate("s", $time), gmdate("m", $time), gmdate("d", $time), gmdate("Y", $time));
}
}
// ------------------------------------------------------------------------
/**
* 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
*/
if ( ! function_exists('gmt_to_local'))
{
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
*/
if ( ! function_exists('mysql_to_unix'))
{
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
*/
if ( ! function_exists('unix_to_human'))
{
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
*/
if ( ! function_exists('human_to_unix'))
{
function human_to_unix($datestr = '')
{
if ($datestr == '')
{
return FALSE;
}
$datestr = trim($datestr);
$datestr = preg_replace("/\040+/", ' ', $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;
}
$split = explode(' ', $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']) && preg_match('/[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
*/
if ( ! function_exists('timezone_menu'))
{
function timezone_menu($default = 'UTC', $class = "", $name = 'timezones')
{
$CI =& get_instance();
$CI->lang->load('date');
if ($default == 'GMT')
$default = 'UTC';
$menu = '<select name="'.$name.'"';
if ($class != '')
{
$menu .= ' class="'.$class.'"';
}
$menu .= ">\n";
foreach (timezones() as $key => $val)
{
$selected = ($default == $key) ? " selected='selected'" : '';
$menu .= "<option value='{$key}'{$selected}>".$CI->lang->line($key)."</option>\n";
}
$menu .= "</select>";
return $menu;
}
}
// ------------------------------------------------------------------------
/**
* Timezones
*
* Returns an array of timezones. This is a helper function
* for various other ones in this library
*
* @access public
* @param string timezone
* @return string
*/
if ( ! function_exists('timezones'))
{
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,
'UM95' => -9.5,
'UM9' => -9,
'UM8' => -8,
'UM7' => -7,
'UM6' => -6,
'UM5' => -5,
'UM45' => -4.5,
'UM4' => -4,
'UM35' => -3.5,
'UM3' => -3,
'UM2' => -2,
'UM1' => -1,
'UTC' => 0,
'UP1' => +1,
'UP2' => +2,
'UP3' => +3,
'UP35' => +3.5,
'UP4' => +4,
'UP45' => +4.5,
'UP5' => +5,
'UP55' => +5.5,
'UP575' => +5.75,
'UP6' => +6,
'UP65' => +6.5,
'UP7' => +7,
'UP8' => +8,
'UP875' => +8.75,
'UP9' => +9,
'UP95' => +9.5,
'UP10' => +10,
'UP105' => +10.5,
'UP11' => +11,
'UP115' => +11.5,
'UP12' => +12,
'UP1275' => +12.75,
'UP13' => +13,
'UP14' => +14
);
if ($tz == '')
{
return $zones;
}
if ($tz == 'GMT')
$tz = 'UTC';
return ( ! isset($zones[$tz])) ? 0 : $zones[$tz];
}
}
/* End of file date_helper.php */
/* Location: ./system/helpers/date_helper.php */

View File

@ -0,0 +1,80 @@
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/**
* CodeIgniter
*
* An open source application development framework for PHP 5.1.6 or newer
*
* @package CodeIgniter
* @author ExpressionEngine Dev Team
* @copyright Copyright (c) 2008 - 2011, EllisLab, Inc.
* @license http://codeigniter.com/user_guide/license.html
* @link http://codeigniter.com
* @since Version 1.0
* @filesource
*/
// ------------------------------------------------------------------------
/**
* CodeIgniter Directory Helpers
*
* @package CodeIgniter
* @subpackage Helpers
* @category Helpers
* @author ExpressionEngine Dev Team
* @link http://codeigniter.com/user_guide/helpers/directory_helper.html
*/
// ------------------------------------------------------------------------
/**
* Create a Directory Map
*
* Reads the specified directory and builds an array
* representation of it. Sub-folders contained with the
* directory will be mapped as well.
*
* @access public
* @param string path to source
* @param int depth of directories to traverse (0 = fully recursive, 1 = current dir, etc)
* @return array
*/
if ( ! function_exists('directory_map'))
{
function directory_map($source_dir, $directory_depth = 0, $hidden = FALSE)
{
if ($fp = @opendir($source_dir))
{
$filedata = array();
$new_depth = $directory_depth - 1;
$source_dir = rtrim($source_dir, DIRECTORY_SEPARATOR).DIRECTORY_SEPARATOR;
while (FALSE !== ($file = readdir($fp)))
{
// Remove '.', '..', and hidden files [optional]
if ( ! trim($file, '.') OR ($hidden == FALSE && $file[0] == '.'))
{
continue;
}
if (($directory_depth < 1 OR $new_depth > 0) && @is_dir($source_dir.$file))
{
$filedata[$file] = directory_map($source_dir.$file.DIRECTORY_SEPARATOR, $new_depth, $hidden);
}
else
{
$filedata[] = $file;
}
}
closedir($fp);
return $filedata;
}
return FALSE;
}
}
/* End of file directory_helper.php */
/* Location: ./system/helpers/directory_helper.php */

View File

@ -0,0 +1,107 @@
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/**
* CodeIgniter
*
* An open source application development framework for PHP 5.1.6 or newer
*
* @package CodeIgniter
* @author ExpressionEngine Dev Team
* @copyright Copyright (c) 2008 - 2011, EllisLab, Inc.
* @license http://codeigniter.com/user_guide/license.html
* @link http://codeigniter.com
* @since Version 1.0
* @filesource
*/
// ------------------------------------------------------------------------
/**
* CodeIgniter Download Helpers
*
* @package CodeIgniter
* @subpackage Helpers
* @category Helpers
* @author ExpressionEngine Dev Team
* @link http://codeigniter.com/user_guide/helpers/download_helper.html
*/
// ------------------------------------------------------------------------
/**
* Force Download
*
* Generates headers that force a download to happen
*
* @access public
* @param string filename
* @param mixed the data to be downloaded
* @return void
*/
if ( ! function_exists('force_download'))
{
function force_download($filename = '', $data = '')
{
if ($filename == '' OR $data == '')
{
return FALSE;
}
// Try to determine if the filename includes a file extension.
// We need it in order to set the MIME type
if (FALSE === strpos($filename, '.'))
{
return FALSE;
}
// Grab the file extension
$x = explode('.', $filename);
$extension = end($x);
// Load the mime types
if (defined('ENVIRONMENT') AND is_file(APPPATH.'config/'.ENVIRONMENT.'/mimes.php'))
{
include(APPPATH.'config/'.ENVIRONMENT.'/mimes.php');
}
elseif (is_file(APPPATH.'config/mimes.php'))
{
include(APPPATH.'config/mimes.php');
}
// Set a default mime if we can't find it
if ( ! isset($mimes[$extension]))
{
$mime = 'application/octet-stream';
}
else
{
$mime = (is_array($mimes[$extension])) ? $mimes[$extension][0] : $mimes[$extension];
}
// Generate the server headers
if (strpos($_SERVER['HTTP_USER_AGENT'], "MSIE") !== FALSE)
{
header('Content-Type: "'.$mime.'"');
header('Content-Disposition: attachment; filename="'.$filename.'"');
header('Expires: 0');
header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
header("Content-Transfer-Encoding: binary");
header('Pragma: public');
header("Content-Length: ".strlen($data));
}
else
{
header('Content-Type: "'.$mime.'"');
header('Content-Disposition: attachment; filename="'.$filename.'"');
header("Content-Transfer-Encoding: binary");
header('Expires: 0');
header('Pragma: no-cache');
header("Content-Length: ".strlen($data));
}
exit($data);
}
}
/* End of file download_helper.php */
/* Location: ./system/helpers/download_helper.php */

View File

@ -0,0 +1,62 @@
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/**
* CodeIgniter
*
* An open source application development framework for PHP 5.1.6 or newer
*
* @package CodeIgniter
* @author ExpressionEngine Dev Team
* @copyright Copyright (c) 2008 - 2011, EllisLab, Inc.
* @license http://codeigniter.com/user_guide/license.html
* @link http://codeigniter.com
* @since Version 1.0
* @filesource
*/
// ------------------------------------------------------------------------
/**
* CodeIgniter Email Helpers
*
* @package CodeIgniter
* @subpackage Helpers
* @category Helpers
* @author ExpressionEngine Dev Team
* @link http://codeigniter.com/user_guide/helpers/email_helper.html
*/
// ------------------------------------------------------------------------
/**
* Validate email address
*
* @access public
* @return bool
*/
if ( ! function_exists('valid_email'))
{
function valid_email($address)
{
return ( ! preg_match("/^([a-z0-9\+_\-]+)(\.[a-z0-9\+_\-]+)*@([a-z0-9\-]+\.)+[a-z]{2,6}$/ix", $address)) ? FALSE : TRUE;
}
}
// ------------------------------------------------------------------------
/**
* Send an email
*
* @access public
* @return bool
*/
if ( ! function_exists('send_email'))
{
function send_email($recipient, $subject = 'Test email', $message = 'Hello World')
{
return mail($recipient, $subject, $message);
}
}
/* End of file email_helper.php */
/* Location: ./system/helpers/email_helper.php */

View File

@ -0,0 +1,479 @@
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/**
* CodeIgniter
*
* An open source application development framework for PHP 5.1.6 or newer
*
* @package CodeIgniter
* @author ExpressionEngine Dev Team
* @copyright Copyright (c) 2008 - 2011, EllisLab, Inc.
* @license http://codeigniter.com/user_guide/license.html
* @link http://codeigniter.com
* @since Version 1.0
* @filesource
*/
// ------------------------------------------------------------------------
/**
* CodeIgniter File Helpers
*
* @package CodeIgniter
* @subpackage Helpers
* @category Helpers
* @author ExpressionEngine Dev Team
* @link http://codeigniter.com/user_guide/helpers/file_helpers.html
*/
// ------------------------------------------------------------------------
/**
* Read File
*
* Opens the file specfied in the path and returns it as a string.
*
* @access public
* @param string path to file
* @return string
*/
if ( ! function_exists('read_file'))
{
function read_file($file)
{
if ( ! file_exists($file))
{
return FALSE;
}
if (function_exists('file_get_contents'))
{
return file_get_contents($file);
}
if ( ! $fp = @fopen($file, FOPEN_READ))
{
return FALSE;
}
flock($fp, LOCK_SH);
$data = '';
if (filesize($file) > 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.
* Creates a new file if non-existent.
*
* @access public
* @param string path to file
* @param string file data
* @return bool
*/
if ( ! function_exists('write_file'))
{
function write_file($path, $data, $mode = FOPEN_WRITE_CREATE_DESTRUCTIVE)
{
if ( ! $fp = @fopen($path, $mode))
{
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 directories 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
*/
if ( ! function_exists('delete_files'))
{
function delete_files($path, $del_dir = FALSE, $level = 0)
{
// Trim the trailing slash
$path = rtrim($path, DIRECTORY_SEPARATOR);
if ( ! $current_dir = @opendir($path))
{
return FALSE;
}
while (FALSE !== ($filename = @readdir($current_dir)))
{
if ($filename != "." and $filename != "..")
{
if (is_dir($path.DIRECTORY_SEPARATOR.$filename))
{
// Ignore empty folders
if (substr($filename, 0, 1) != '.')
{
delete_files($path.DIRECTORY_SEPARATOR.$filename, $del_dir, $level + 1);
}
}
else
{
unlink($path.DIRECTORY_SEPARATOR.$filename);
}
}
}
@closedir($current_dir);
if ($del_dir == TRUE AND $level > 0)
{
return @rmdir($path);
}
return TRUE;
}
}
// ------------------------------------------------------------------------
/**
* Get Filenames
*
* Reads the specified directory and builds an array containing the filenames.
* Any sub-folders contained within the specified path are read as well.
*
* @access public
* @param string path to source
* @param bool whether to include the path as part of the filename
* @param bool internal variable to determine recursion status - do not use in calls
* @return array
*/
if ( ! function_exists('get_filenames'))
{
function get_filenames($source_dir, $include_path = FALSE, $_recursion = FALSE)
{
static $_filedata = array();
if ($fp = @opendir($source_dir))
{
// reset the array and make sure $source_dir has a trailing slash on the initial call
if ($_recursion === FALSE)
{
$_filedata = array();
$source_dir = rtrim(realpath($source_dir), DIRECTORY_SEPARATOR).DIRECTORY_SEPARATOR;
}
while (FALSE !== ($file = readdir($fp)))
{
if (@is_dir($source_dir.$file) && strncmp($file, '.', 1) !== 0)
{
get_filenames($source_dir.$file.DIRECTORY_SEPARATOR, $include_path, TRUE);
}
elseif (strncmp($file, '.', 1) !== 0)
{
$_filedata[] = ($include_path == TRUE) ? $source_dir.$file : $file;
}
}
return $_filedata;
}
else
{
return FALSE;
}
}
}
// --------------------------------------------------------------------
/**
* Get Directory File Information
*
* Reads the specified directory and builds an array containing the filenames,
* filesize, dates, and permissions
*
* Any sub-folders contained within the specified path are read as well.
*
* @access public
* @param string path to source
* @param bool Look only at the top level directory specified?
* @param bool internal variable to determine recursion status - do not use in calls
* @return array
*/
if ( ! function_exists('get_dir_file_info'))
{
function get_dir_file_info($source_dir, $top_level_only = TRUE, $_recursion = FALSE)
{
static $_filedata = array();
$relative_path = $source_dir;
if ($fp = @opendir($source_dir))
{
// reset the array and make sure $source_dir has a trailing slash on the initial call
if ($_recursion === FALSE)
{
$_filedata = array();
$source_dir = rtrim(realpath($source_dir), DIRECTORY_SEPARATOR).DIRECTORY_SEPARATOR;
}
// foreach (scandir($source_dir, 1) as $file) // In addition to being PHP5+, scandir() is simply not as fast
while (FALSE !== ($file = readdir($fp)))
{
if (@is_dir($source_dir.$file) AND strncmp($file, '.', 1) !== 0 AND $top_level_only === FALSE)
{
get_dir_file_info($source_dir.$file.DIRECTORY_SEPARATOR, $top_level_only, TRUE);
}
elseif (strncmp($file, '.', 1) !== 0)
{
$_filedata[$file] = get_file_info($source_dir.$file);
$_filedata[$file]['relative_path'] = $relative_path;
}
}
return $_filedata;
}
else
{
return FALSE;
}
}
}
// --------------------------------------------------------------------
/**
* Get File Info
*
* Given a file and path, returns the name, path, size, date modified
* Second parameter allows you to explicitly declare what information you want returned
* 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
*/
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, DIRECTORY_SEPARATOR), 1);
break;
case 'server_path':
$fileinfo['server_path'] = $file;
break;
case 'size':
$fileinfo['size'] = filesize($file);
break;
case 'date':
$fileinfo['date'] = filemtime($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;
}
}
// --------------------------------------------------------------------
/**
* Get Mime by Extension
*
* Translates a file extension into a mime type based on config/mimes.php.
* Returns FALSE if it can't determine the type, or open the mime config file
*
* Note: this is NOT an accurate way of determining file mime types, and is here strictly as a convenience
* It should NOT be trusted, and should certainly NOT be used for security
*
* @access public
* @param string path to file
* @return mixed
*/
if ( ! function_exists('get_mime_by_extension'))
{
function get_mime_by_extension($file)
{
$extension = strtolower(substr(strrchr($file, '.'), 1));
global $mimes;
if ( ! is_array($mimes))
{
if (defined('ENVIRONMENT') AND is_file(APPPATH.'config/'.ENVIRONMENT.'/mimes.php'))
{
include(APPPATH.'config/'.ENVIRONMENT.'/mimes.php');
}
elseif (is_file(APPPATH.'config/mimes.php'))
{
include(APPPATH.'config/mimes.php');
}
if ( ! is_array($mimes))
{
return FALSE;
}
}
if (array_key_exists($extension, $mimes))
{
if (is_array($mimes[$extension]))
{
// Multiple mime types, just give the first one
return current($mimes[$extension]);
}
else
{
return $mimes[$extension];
}
}
else
{
return FALSE;
}
}
}
// --------------------------------------------------------------------
/**
* Symbolic Permissions
*
* Takes a numeric value representing a file's permissions and returns
* standard symbolic notation representing that value
*
* @access public
* @param int
* @return string
*/
if ( ! function_exists('symbolic_permissions'))
{
function symbolic_permissions($perms)
{
if (($perms & 0xC000) == 0xC000)
{
$symbolic = 's'; // Socket
}
elseif (($perms & 0xA000) == 0xA000)
{
$symbolic = 'l'; // Symbolic Link
}
elseif (($perms & 0x8000) == 0x8000)
{
$symbolic = '-'; // Regular
}
elseif (($perms & 0x6000) == 0x6000)
{
$symbolic = 'b'; // Block special
}
elseif (($perms & 0x4000) == 0x4000)
{
$symbolic = 'd'; // Directory
}
elseif (($perms & 0x2000) == 0x2000)
{
$symbolic = 'c'; // Character special
}
elseif (($perms & 0x1000) == 0x1000)
{
$symbolic = 'p'; // FIFO pipe
}
else
{
$symbolic = 'u'; // Unknown
}
// Owner
$symbolic .= (($perms & 0x0100) ? 'r' : '-');
$symbolic .= (($perms & 0x0080) ? 'w' : '-');
$symbolic .= (($perms & 0x0040) ? (($perms & 0x0800) ? 's' : 'x' ) : (($perms & 0x0800) ? 'S' : '-'));
// Group
$symbolic .= (($perms & 0x0020) ? 'r' : '-');
$symbolic .= (($perms & 0x0010) ? 'w' : '-');
$symbolic .= (($perms & 0x0008) ? (($perms & 0x0400) ? 's' : 'x' ) : (($perms & 0x0400) ? 'S' : '-'));
// World
$symbolic .= (($perms & 0x0004) ? 'r' : '-');
$symbolic .= (($perms & 0x0002) ? 'w' : '-');
$symbolic .= (($perms & 0x0001) ? (($perms & 0x0200) ? 't' : 'x' ) : (($perms & 0x0200) ? 'T' : '-'));
return $symbolic;
}
}
// --------------------------------------------------------------------
/**
* Octal Permissions
*
* Takes a numeric value representing a file's permissions and returns
* a three character string representing the file's octal permissions
*
* @access public
* @param int
* @return string
*/
if ( ! function_exists('octal_permissions'))
{
function octal_permissions($perms)
{
return substr(sprintf('%o', $perms), -3);
}
}
/* End of file file_helper.php */
/* Location: ./system/helpers/file_helper.php */

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,436 @@
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/**
* CodeIgniter
*
* An open source application development framework for PHP 5.1.6 or newer
*
* @package CodeIgniter
* @author ExpressionEngine Dev Team
* @copyright Copyright (c) 2008 - 2011, EllisLab, Inc.
* @license http://codeigniter.com/user_guide/license.html
* @link http://codeigniter.com
* @since Version 1.0
* @filesource
*/
// ------------------------------------------------------------------------
/**
* CodeIgniter HTML Helpers
*
* @package CodeIgniter
* @subpackage Helpers
* @category Helpers
* @author ExpressionEngine Dev Team
* @link http://codeigniter.com/user_guide/helpers/html_helper.html
*/
// ------------------------------------------------------------------------
/**
* Heading
*
* Generates an HTML heading tag. First param is the data.
* Second param is the size of the heading tag.
*
* @access public
* @param string
* @param integer
* @return string
*/
if ( ! function_exists('heading'))
{
function heading($data = '', $h = '1', $attributes = '')
{
$attributes = ($attributes != '') ? ' '.$attributes : $attributes;
return "<h".$h.$attributes.">".$data."</h".$h.">";
}
}
// ------------------------------------------------------------------------
/**
* Unordered List
*
* Generates an HTML unordered list from an single or multi-dimensional array.
*
* @access public
* @param array
* @param mixed
* @return string
*/
if ( ! function_exists('ul'))
{
function ul($list, $attributes = '')
{
return _list('ul', $list, $attributes);
}
}
// ------------------------------------------------------------------------
/**
* Ordered List
*
* Generates an HTML ordered list from an single or multi-dimensional array.
*
* @access public
* @param array
* @param mixed
* @return string
*/
if ( ! function_exists('ol'))
{
function ol($list, $attributes = '')
{
return _list('ol', $list, $attributes);
}
}
// ------------------------------------------------------------------------
/**
* Generates the list
*
* Generates an HTML ordered list from an single or multi-dimensional array.
*
* @access private
* @param string
* @param mixed
* @param mixed
* @param integer
* @return string
*/
if ( ! function_exists('_list'))
{
function _list($type = 'ul', $list, $attributes = '', $depth = 0)
{
// If an array wasn't submitted there's nothing to do...
if ( ! is_array($list))
{
return $list;
}
// Set the indentation based on the depth
$out = str_repeat(" ", $depth);
// Were any attributes submitted? If so generate a string
if (is_array($attributes))
{
$atts = '';
foreach ($attributes as $key => $val)
{
$atts .= ' ' . $key . '="' . $val . '"';
}
$attributes = $atts;
}
elseif (is_string($attributes) AND strlen($attributes) > 0)
{
$attributes = ' '. $attributes;
}
// Write the opening list tag
$out .= "<".$type.$attributes.">\n";
// Cycle through the list elements. If an array is
// encountered we will recursively call _list()
static $_last_list_item = '';
foreach ($list as $key => $val)
{
$_last_list_item = $key;
$out .= str_repeat(" ", $depth + 2);
$out .= "<li>";
if ( ! is_array($val))
{
$out .= $val;
}
else
{
$out .= $_last_list_item."\n";
$out .= _list($type, $val, '', $depth + 4);
$out .= str_repeat(" ", $depth + 2);
}
$out .= "</li>\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
*/
if ( ! function_exists('br'))
{
function br($num = 1)
{
return str_repeat("<br />", $num);
}
}
// ------------------------------------------------------------------------
/**
* Image
*
* Generates an <img /> element
*
* @access public
* @param mixed
* @return string
*/
if ( ! function_exists('img'))
{
function img($src = '', $index_page = FALSE)
{
if ( ! is_array($src) )
{
$src = array('src' => $src);
}
// If there is no alt attribute defined, set it to an empty string
if ( ! isset($src['alt']))
{
$src['alt'] = '';
}
$img = '<img';
foreach ($src as $k=>$v)
{
if ($k == 'src' AND strpos($v, '://') === FALSE)
{
$CI =& get_instance();
if ($index_page === TRUE)
{
$img .= ' src="'.$CI->config->site_url($v).'"';
}
else
{
$img .= ' src="'.$CI->config->slash_item('base_url').$v.'"';
}
}
else
{
$img .= " $k=\"$v\"";
}
}
$img .= '/>';
return $img;
}
}
// ------------------------------------------------------------------------
/**
* Doctype
*
* Generates a page document type declaration
*
* Valid options are xhtml-11, xhtml-strict, xhtml-trans, xhtml-frame,
* html4-strict, html4-trans, and html4-frame. Values are saved in the
* doctypes config file.
*
* @access public
* @param string type The doctype to be generated
* @return string
*/
if ( ! function_exists('doctype'))
{
function doctype($type = 'xhtml1-strict')
{
global $_doctypes;
if ( ! is_array($_doctypes))
{
if (defined('ENVIRONMENT') AND is_file(APPPATH.'config/'.ENVIRONMENT.'/doctypes.php'))
{
include(APPPATH.'config/'.ENVIRONMENT.'/doctypes.php');
}
elseif (is_file(APPPATH.'config/doctypes.php'))
{
include(APPPATH.'config/doctypes.php');
}
if ( ! is_array($_doctypes))
{
return FALSE;
}
}
if (isset($_doctypes[$type]))
{
return $_doctypes[$type];
}
else
{
return FALSE;
}
}
}
// ------------------------------------------------------------------------
/**
* Link
*
* Generates link to a CSS file
*
* @access public
* @param mixed stylesheet hrefs or an array
* @param string rel
* @param string type
* @param string title
* @param string media
* @param boolean should index_page be added to the css path
* @return string
*/
if ( ! function_exists('link_tag'))
{
function link_tag($href = '', $rel = 'stylesheet', $type = 'text/css', $title = '', $media = '', $index_page = FALSE)
{
$CI =& get_instance();
$link = '<link ';
if (is_array($href))
{
foreach ($href as $k=>$v)
{
if ($k == 'href' AND strpos($v, '://') === FALSE)
{
if ($index_page === TRUE)
{
$link .= 'href="'.$CI->config->site_url($v).'" ';
}
else
{
$link .= 'href="'.$CI->config->slash_item('base_url').$v.'" ';
}
}
else
{
$link .= "$k=\"$v\" ";
}
}
$link .= "/>";
}
else
{
if ( strpos($href, '://') !== FALSE)
{
$link .= 'href="'.$href.'" ';
}
elseif ($index_page === TRUE)
{
$link .= 'href="'.$CI->config->site_url($href).'" ';
}
else
{
$link .= 'href="'.$CI->config->slash_item('base_url').$href.'" ';
}
$link .= 'rel="'.$rel.'" type="'.$type.'" ';
if ($media != '')
{
$link .= 'media="'.$media.'" ';
}
if ($title != '')
{
$link .= 'title="'.$title.'" ';
}
$link .= '/>';
}
return $link;
}
}
// ------------------------------------------------------------------------
/**
* Generates meta tags from an array of key/values
*
* @access public
* @param array
* @return string
*/
if ( ! function_exists('meta'))
{
function meta($name = '', $content = '', $type = 'name', $newline = "\n")
{
// Since we allow the data to be passes as a string, a simple array
// or a multidimensional one, we need to do a little prepping.
if ( ! is_array($name))
{
$name = array(array('name' => $name, 'content' => $content, 'type' => $type, 'newline' => $newline));
}
else
{
// Turn single array into multidimensional
if (isset($name['name']))
{
$name = array($name);
}
}
$str = '';
foreach ($name as $meta)
{
$type = ( ! isset($meta['type']) OR $meta['type'] == 'name') ? 'name' : 'http-equiv';
$name = ( ! isset($meta['name'])) ? '' : $meta['name'];
$content = ( ! isset($meta['content'])) ? '' : $meta['content'];
$newline = ( ! isset($meta['newline'])) ? "\n" : $meta['newline'];
$str .= '<meta '.$type.'="'.$name.'" content="'.$content.'" />'.$newline;
}
return $str;
}
}
// ------------------------------------------------------------------------
/**
* Generates non-breaking space entities based on number supplied
*
* @access public
* @param integer
* @return string
*/
if ( ! function_exists('nbs'))
{
function nbs($num = 1)
{
return str_repeat("&nbsp;", $num);
}
}
/* End of file html_helper.php */
/* Location: ./system/helpers/html_helper.php */

10
system/helpers/index.html Normal file
View File

@ -0,0 +1,10 @@
<html>
<head>
<title>403 Forbidden</title>
</head>
<body>
<p>Directory access is forbidden.</p>
</body>
</html>

View File

@ -0,0 +1,203 @@
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/**
* CodeIgniter
*
* An open source application development framework for PHP 5.1.6 or newer
*
* @package CodeIgniter
* @author ExpressionEngine Dev Team
* @copyright Copyright (c) 2008 - 2011, EllisLab, Inc.
* @license http://codeigniter.com/user_guide/license.html
* @link http://codeigniter.com
* @since Version 1.0
* @filesource
*/
// ------------------------------------------------------------------------
/**
* CodeIgniter Inflector Helpers
*
* @package CodeIgniter
* @subpackage Helpers
* @category Helpers
* @author ExpressionEngine Dev Team
* @link http://codeigniter.com/user_guide/helpers/directory_helper.html
*/
// --------------------------------------------------------------------
/**
* Singular
*
* Takes a plural word and makes it singular
*
* @access public
* @param string
* @return str
*/
if ( ! function_exists('singular'))
{
function singular($str)
{
$result = strval($str);
$singular_rules = array(
'/(matr)ices$/' => '\1ix',
'/(vert|ind)ices$/' => '\1ex',
'/^(ox)en/' => '\1',
'/(alias)es$/' => '\1',
'/([octop|vir])i$/' => '\1us',
'/(cris|ax|test)es$/' => '\1is',
'/(shoe)s$/' => '\1',
'/(o)es$/' => '\1',
'/(bus|campus)es$/' => '\1',
'/([m|l])ice$/' => '\1ouse',
'/(x|ch|ss|sh)es$/' => '\1',
'/(m)ovies$/' => '\1\2ovie',
'/(s)eries$/' => '\1\2eries',
'/([^aeiouy]|qu)ies$/' => '\1y',
'/([lr])ves$/' => '\1f',
'/(tive)s$/' => '\1',
'/(hive)s$/' => '\1',
'/([^f])ves$/' => '\1fe',
'/(^analy)ses$/' => '\1sis',
'/((a)naly|(b)a|(d)iagno|(p)arenthe|(p)rogno|(s)ynop|(t)he)ses$/' => '\1\2sis',
'/([ti])a$/' => '\1um',
'/(p)eople$/' => '\1\2erson',
'/(m)en$/' => '\1an',
'/(s)tatuses$/' => '\1\2tatus',
'/(c)hildren$/' => '\1\2hild',
'/(n)ews$/' => '\1\2ews',
'/([^u])s$/' => '\1',
);
foreach ($singular_rules as $rule => $replacement)
{
if (preg_match($rule, $result))
{
$result = preg_replace($rule, $replacement, $result);
break;
}
}
return $result;
}
}
// --------------------------------------------------------------------
/**
* Plural
*
* Takes a singular word and makes it plural
*
* @access public
* @param string
* @param bool
* @return str
*/
if ( ! function_exists('plural'))
{
function plural($str, $force = FALSE)
{
$result = strval($str);
$plural_rules = array(
'/^(ox)$/' => '\1\2en', // ox
'/([m|l])ouse$/' => '\1ice', // mouse, louse
'/(matr|vert|ind)ix|ex$/' => '\1ices', // matrix, vertex, index
'/(x|ch|ss|sh)$/' => '\1es', // search, switch, fix, box, process, address
'/([^aeiouy]|qu)y$/' => '\1ies', // query, ability, agency
'/(hive)$/' => '\1s', // archive, hive
'/(?:([^f])fe|([lr])f)$/' => '\1\2ves', // half, safe, wife
'/sis$/' => 'ses', // basis, diagnosis
'/([ti])um$/' => '\1a', // datum, medium
'/(p)erson$/' => '\1eople', // person, salesperson
'/(m)an$/' => '\1en', // man, woman, spokesman
'/(c)hild$/' => '\1hildren', // child
'/(buffal|tomat)o$/' => '\1\2oes', // buffalo, tomato
'/(bu|campu)s$/' => '\1\2ses', // bus, campus
'/(alias|status|virus)/' => '\1es', // alias
'/(octop)us$/' => '\1i', // octopus
'/(ax|cris|test)is$/' => '\1es', // axis, crisis
'/s$/' => 's', // no change (compatibility)
'/$/' => 's',
);
foreach ($plural_rules as $rule => $replacement)
{
if (preg_match($rule, $result))
{
$result = preg_replace($rule, $replacement, $result);
break;
}
}
return $result;
}
}
// --------------------------------------------------------------------
/**
* Camelize
*
* Takes multiple words separated by spaces or underscores and camelizes them
*
* @access public
* @param string
* @return str
*/
if ( ! function_exists('camelize'))
{
function camelize($str)
{
$str = 'x'.strtolower(trim($str));
$str = ucwords(preg_replace('/[\s_]+/', ' ', $str));
return substr(str_replace(' ', '', $str), 1);
}
}
// --------------------------------------------------------------------
/**
* Underscore
*
* Takes multiple words separated by spaces and underscores them
*
* @access public
* @param string
* @return str
*/
if ( ! function_exists('underscore'))
{
function underscore($str)
{
return preg_replace('/[\s]+/', '_', strtolower(trim($str)));
}
}
// --------------------------------------------------------------------
/**
* Humanize
*
* Takes multiple words separated by underscores and changes them to spaces
*
* @access public
* @param string
* @return str
*/
if ( ! function_exists('humanize'))
{
function humanize($str)
{
return ucwords(preg_replace('/[_]+/', ' ', strtolower(trim($str))));
}
}
/* End of file inflector_helper.php */
/* Location: ./system/helpers/inflector_helper.php */

View File

@ -0,0 +1,58 @@
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/**
* CodeIgniter
*
* An open source application development framework for PHP 5.1.6 or newer
*
* @package CodeIgniter
* @author ExpressionEngine Dev Team
* @copyright Copyright (c) 2008 - 2011, EllisLab, Inc.
* @license http://codeigniter.com/user_guide/license.html
* @link http://codeigniter.com
* @since Version 1.0
* @filesource
*/
// ------------------------------------------------------------------------
/**
* CodeIgniter Language Helpers
*
* @package CodeIgniter
* @subpackage Helpers
* @category Helpers
* @author ExpressionEngine Dev Team
* @link http://codeigniter.com/user_guide/helpers/language_helper.html
*/
// ------------------------------------------------------------------------
/**
* Lang
*
* Fetches a language variable and optionally outputs a form label
*
* @access public
* @param string the language line
* @param string the id of the form element
* @return string
*/
if ( ! function_exists('lang'))
{
function lang($line, $id = '')
{
$CI =& get_instance();
$line = $CI->lang->line($line);
if ($id != '')
{
$line = '<label for="'.$id.'">'.$line."</label>";
}
return $line;
}
}
// ------------------------------------------------------------------------
/* End of file language_helper.php */
/* Location: ./system/helpers/language_helper.php */

View File

@ -0,0 +1,76 @@
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/**
* CodeIgniter
*
* An open source application development framework for PHP 5.1.6 or newer
*
* @package CodeIgniter
* @author ExpressionEngine Dev Team
* @copyright Copyright (c) 2008 - 2011, EllisLab, Inc.
* @license http://codeigniter.com/user_guide/license.html
* @link http://codeigniter.com
* @since Version 1.0
* @filesource
*/
// ------------------------------------------------------------------------
/**
* CodeIgniter Number Helpers
*
* @package CodeIgniter
* @subpackage Helpers
* @category Helpers
* @author ExpressionEngine Dev Team
* @link http://codeigniter.com/user_guide/helpers/number_helper.html
*/
// ------------------------------------------------------------------------
/**
* Formats a numbers as bytes, based on size, and adds the appropriate suffix
*
* @access public
* @param mixed // will be cast as int
* @return string
*/
if ( ! function_exists('byte_format'))
{
function byte_format($num, $precision = 1)
{
$CI =& get_instance();
$CI->lang->load('number');
if ($num >= 1000000000000)
{
$num = round($num / 1099511627776, $precision);
$unit = $CI->lang->line('terabyte_abbr');
}
elseif ($num >= 1000000000)
{
$num = round($num / 1073741824, $precision);
$unit = $CI->lang->line('gigabyte_abbr');
}
elseif ($num >= 1000000)
{
$num = round($num / 1048576, $precision);
$unit = $CI->lang->line('megabyte_abbr');
}
elseif ($num >= 1000)
{
$num = round($num / 1024, $precision);
$unit = $CI->lang->line('kilobyte_abbr');
}
else
{
$unit = $CI->lang->line('bytes');
return number_format($num).' '.$unit;
}
return number_format($num, $precision).' '.$unit;
}
}
/* End of file number_helper.php */
/* Location: ./system/helpers/number_helper.php */

View File

@ -0,0 +1,72 @@
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/**
* CodeIgniter
*
* An open source application development framework for PHP 5.1.6 or newer
*
* @package CodeIgniter
* @author ExpressionEngine Dev Team
* @copyright Copyright (c) 2008 - 2011, EllisLab, Inc.
* @license http://codeigniter.com/user_guide/license.html
* @link http://codeigniter.com
* @since Version 1.0
* @filesource
*/
// ------------------------------------------------------------------------
/**
* CodeIgniter Path Helpers
*
* @package CodeIgniter
* @subpackage Helpers
* @category Helpers
* @author ExpressionEngine Dev Team
* @link http://codeigniter.com/user_guide/helpers/xml_helper.html
*/
// ------------------------------------------------------------------------
/**
* Set Realpath
*
* @access public
* @param string
* @param bool checks to see if the path exists
* @return string
*/
if ( ! function_exists('set_realpath'))
{
function set_realpath($path, $check_existance = FALSE)
{
// Security check to make sure the path is NOT a URL. No remote file inclusion!
if (preg_match("#^(http:\/\/|https:\/\/|www\.|ftp|[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3})#i", $path))
{
show_error('The path you submitted must be a local server path, not a URL');
}
// Resolve the path
if (function_exists('realpath') AND @realpath($path) !== FALSE)
{
$path = realpath($path).'/';
}
// Add a trailing slash
$path = preg_replace("#([^/])/*$#", "\\1/", $path);
// Make sure the path exists
if ($check_existance == TRUE)
{
if ( ! is_dir($path))
{
show_error('Not a valid path: '.$path);
}
}
return $path;
}
}
/* End of file path_helper.php */
/* Location: ./system/helpers/path_helper.php */

View File

@ -0,0 +1,128 @@
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/**
* CodeIgniter
*
* An open source application development framework for PHP 5.1.6 or newer
*
* @package CodeIgniter
* @author ExpressionEngine Dev Team
* @copyright Copyright (c) 2008 - 2011, EllisLab, Inc.
* @license http://codeigniter.com/user_guide/license.html
* @link http://codeigniter.com
* @since Version 1.0
* @filesource
*/
// ------------------------------------------------------------------------
/**
* CodeIgniter Security Helpers
*
* @package CodeIgniter
* @subpackage Helpers
* @category Helpers
* @author ExpressionEngine Dev Team
* @link http://codeigniter.com/user_guide/helpers/security_helper.html
*/
// ------------------------------------------------------------------------
/**
* XSS Filtering
*
* @access public
* @param string
* @param bool whether or not the content is an image file
* @return string
*/
if ( ! function_exists('xss_clean'))
{
function xss_clean($str, $is_image = FALSE)
{
$CI =& get_instance();
return $CI->security->xss_clean($str, $is_image);
}
}
// ------------------------------------------------------------------------
/**
* Sanitize Filename
*
* @access public
* @param string
* @return string
*/
if ( ! function_exists('sanitize_filename'))
{
function sanitize_filename($filename)
{
$CI =& get_instance();
return $CI->security->sanitize_filename($filename);
}
}
// --------------------------------------------------------------------
/**
* Hash encode a string
*
* @access public
* @param string
* @return string
*/
if ( ! function_exists('do_hash'))
{
function do_hash($str, $type = 'sha1')
{
if ($type == 'sha1')
{
return sha1($str);
}
else
{
return md5($str);
}
}
}
// ------------------------------------------------------------------------
/**
* Strip Image Tags
*
* @access public
* @param string
* @return string
*/
if ( ! function_exists('strip_image_tags'))
{
function strip_image_tags($str)
{
$str = preg_replace("#<img\s+.*?src\s*=\s*[\"'](.+?)[\"'].*?\>#", "\\1", $str);
$str = preg_replace("#<img\s+.*?src\s*=\s*(.+?).*?\>#", "\\1", $str);
return $str;
}
}
// ------------------------------------------------------------------------
/**
* Convert PHP tags to entities
*
* @access public
* @param string
* @return string
*/
if ( ! function_exists('encode_php_tags'))
{
function encode_php_tags($str)
{
return str_replace(array('<?php', '<?PHP', '<?', '?>'), array('&lt;?php', '&lt;?PHP', '&lt;?', '?&gt;'), $str);
}
}
/* End of file security_helper.php */
/* Location: ./system/helpers/security_helper.php */

View File

@ -0,0 +1,281 @@
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/**
* CodeIgniter
*
* An open source application development framework for PHP 5.1.6 or newer
*
* @package CodeIgniter
* @author ExpressionEngine Dev Team
* @copyright Copyright (c) 2008 - 2011, EllisLab, Inc.
* @license http://codeigniter.com/user_guide/license.html
* @link http://codeigniter.com
* @since Version 1.0
* @filesource
*/
// ------------------------------------------------------------------------
/**
* CodeIgniter Smiley Helpers
*
* @package CodeIgniter
* @subpackage Helpers
* @category Helpers
* @author ExpressionEngine Dev Team
* @link http://codeigniter.com/user_guide/helpers/smiley_helper.html
*/
// ------------------------------------------------------------------------
/**
* Smiley Javascript
*
* Returns the javascript required for the smiley insertion. Optionally takes
* an array of aliases to loosely couple the smiley array to the view.
*
* @access public
* @param mixed alias name or array of alias->field_id pairs
* @param string field_id if alias name was passed in
* @return array
*/
if ( ! function_exists('smiley_js'))
{
function smiley_js($alias = '', $field_id = '', $inline = TRUE)
{
static $do_setup = TRUE;
$r = '';
if ($alias != '' && ! is_array($alias))
{
$alias = array($alias => $field_id);
}
if ($do_setup === TRUE)
{
$do_setup = FALSE;
$m = array();
if (is_array($alias))
{
foreach ($alias as $name => $id)
{
$m[] = '"'.$name.'" : "'.$id.'"';
}
}
$m = '{'.implode(',', $m).'}';
$r .= <<<EOF
var smiley_map = {$m};
function insert_smiley(smiley, field_id) {
var el = document.getElementById(field_id), newStart;
if ( ! el && smiley_map[field_id]) {
el = document.getElementById(smiley_map[field_id]);
if ( ! el)
return false;
}
el.focus();
smiley = " " + smiley;
if ('selectionStart' in el) {
newStart = el.selectionStart + smiley.length;
el.value = el.value.substr(0, el.selectionStart) +
smiley +
el.value.substr(el.selectionEnd, el.value.length);
el.setSelectionRange(newStart, newStart);
}
else if (document.selection) {
document.selection.createRange().text = smiley;
}
}
EOF;
}
else
{
if (is_array($alias))
{
foreach ($alias as $name => $id)
{
$r .= 'smiley_map["'.$name.'"] = "'.$id.'";'."\n";
}
}
}
if ($inline)
{
return '<script type="text/javascript" charset="utf-8">/*<![CDATA[ */'.$r.'// ]]></script>';
}
else
{
return $r;
}
}
}
// ------------------------------------------------------------------------
/**
* 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, $alias = '', $smileys = NULL)
{
// For backward compatibility with js_insert_smiley
if (is_array($alias))
{
$smileys = $alias;
}
if ( ! is_array($smileys))
{
if (FALSE === ($smileys = _get_smiley_array()))
{
return $smileys;
}
}
// Add a trailing slash to the file path if needed
$image_url = rtrim($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[] = "<a href=\"javascript:void(0);\" onclick=\"insert_smiley('".$key."', '".$alias."')\"><img src=\"".$image_url.$smileys[$key][0]."\" width=\"".$smileys[$key][1]."\" height=\"".$smileys[$key][2]."\" alt=\"".$smileys[$key][3]."\" style=\"border:0;\" /></a>";
$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, "<img src=\"".$image_url.$smileys[$key][0]."\" width=\"".$smileys[$key][1]."\" height=\"".$smileys[$key][2]."\" alt=\"".$smileys[$key][3]."\" style=\"border:0;\" />", $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 (defined('ENVIRONMENT') AND file_exists(APPPATH.'config/'.ENVIRONMENT.'/smileys.php'))
{
include(APPPATH.'config/'.ENVIRONMENT.'/smileys.php');
}
elseif (file_exists(APPPATH.'config/smileys.php'))
{
include(APPPATH.'config/smileys.php');
}
if (isset($smileys) AND is_array($smileys))
{
return $smileys;
}
return FALSE;
}
}
// ------------------------------------------------------------------------
/**
* JS Insert Smiley
*
* Generates the javascript function needed to insert smileys into a form field
*
* DEPRECATED as of version 1.7.2, use smiley_js instead
*
* @access public
* @param string form name
* @param string field name
* @return string
*/
if ( ! function_exists('js_insert_smiley'))
{
function js_insert_smiley($form_name = '', $form_field = '')
{
return <<<EOF
<script type="text/javascript">
function insert_smiley(smiley)
{
document.{$form_name}.{$form_field}.value += " " + smiley;
}
</script>
EOF;
}
}
/* End of file smiley_helper.php */
/* Location: ./system/helpers/smiley_helper.php */

View File

@ -0,0 +1,307 @@
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/**
* CodeIgniter
*
* An open source application development framework for PHP 5.1.6 or newer
*
* @package CodeIgniter
* @author ExpressionEngine Dev Team
* @copyright Copyright (c) 2008 - 2011, EllisLab, Inc.
* @license http://codeigniter.com/user_guide/license.html
* @link http://codeigniter.com
* @since Version 1.0
* @filesource
*/
// ------------------------------------------------------------------------
/**
* CodeIgniter String Helpers
*
* @package CodeIgniter
* @subpackage Helpers
* @category Helpers
* @author ExpressionEngine Dev Team
* @link http://codeigniter.com/user_guide/helpers/string_helper.html
*/
// ------------------------------------------------------------------------
/**
* Trim Slashes
*
* Removes any leading/trailing slashes from a string:
*
* /this/that/theother/
*
* becomes:
*
* this/that/theother
*
* @access public
* @param string
* @return string
*/
if ( ! function_exists('trim_slashes'))
{
function trim_slashes($str)
{
return trim($str, '/');
}
}
// ------------------------------------------------------------------------
/**
* Strip Slashes
*
* Removes slashes contained in a string or in an array
*
* @access public
* @param mixed string or array
* @return mixed string or array
*/
if ( ! function_exists('strip_slashes'))
{
function strip_slashes($str)
{
if (is_array($str))
{
foreach ($str as $key => $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("&#39;","&quot;","&#39;","&quot;"), $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. basic, alpha, alunum, numeric, nozero, unique, md5, encrypt and sha1
* @param integer number of characters
* @return string
*/
if ( ! function_exists('random_string'))
{
function random_string($type = 'alnum', $len = 8)
{
switch($type)
{
case 'basic' : return mt_rand();
break;
case 'alnum' :
case 'numeric' :
case 'nozero' :
case 'alpha' :
switch ($type)
{
case 'alpha' : $pool = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
break;
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' :
case 'md5' :
return md5(uniqid(mt_rand()));
break;
case 'encrypt' :
case 'sha1' :
$CI =& get_instance();
$CI->load->helper('security');
return do_hash(uniqid(mt_rand(), TRUE), 'sha1');
break;
}
}
}
// ------------------------------------------------------------------------
/**
* Add's _1 to a string or increment the ending number to allow _2, _3, etc
*
* @param string $str required
* @param string $separator What should the duplicate number be appended with
* @param string $first Which number should be used for the first dupe increment
* @return string
*/
function increment_string($str, $separator = '_', $first = 1)
{
preg_match('/(.+)'.$separator.'([0-9]+)$/', $str, $match);
return isset($match[2]) ? $match[1].$separator.($match[2] + 1) : $str.$separator.$first;
}
// ------------------------------------------------------------------------
/**
* 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 */

View File

@ -0,0 +1,535 @@
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/**
* CodeIgniter
*
* An open source application development framework for PHP 5.1.6 or newer
*
* @package CodeIgniter
* @author ExpressionEngine Dev Team
* @copyright Copyright (c) 2008 - 2011, EllisLab, Inc.
* @license http://codeigniter.com/user_guide/license.html
* @link http://codeigniter.com
* @since Version 1.0
* @filesource
*/
// ------------------------------------------------------------------------
/**
* CodeIgniter Text Helpers
*
* @package CodeIgniter
* @subpackage Helpers
* @category Helpers
* @author ExpressionEngine Dev Team
* @link http://codeigniter.com/user_guide/helpers/text_helper.html
*/
// ------------------------------------------------------------------------
/**
* Word Limiter
*
* Limits a string to X number of words.
*
* @access public
* @param string
* @param integer
* @param string the end character. Usually an ellipsis
* @return string
*/
if ( ! function_exists('word_limiter'))
{
function word_limiter($str, $limit = 100, $end_char = '&#8230;')
{
if (trim($str) == '')
{
return $str;
}
preg_match('/^\s*+(?:\S++\s*+){1,'.(int) $limit.'}/', $str, $matches);
if (strlen($str) == strlen($matches[0]))
{
$end_char = '';
}
return rtrim($matches[0]).$end_char;
}
}
// ------------------------------------------------------------------------
/**
* Character Limiter
*
* Limits the string based on the character count. Preserves complete words
* so the character count may not be exactly as specified.
*
* @access public
* @param string
* @param integer
* @param string the end character. Usually an ellipsis
* @return string
*/
if ( ! function_exists('character_limiter'))
{
function character_limiter($str, $n = 500, $end_char = '&#8230;')
{
if (strlen($str) < $n)
{
return $str;
}
$str = preg_replace("/\s+/", ' ', str_replace(array("\r\n", "\r", "\n"), ' ', $str));
if (strlen($str) <= $n)
{
return $str;
}
$out = "";
foreach (explode(' ', trim($str)) as $val)
{
$out .= $val.' ';
if (strlen($out) >= $n)
{
$out = trim($out);
return (strlen($out) == strlen($str)) ? $out : $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)
{
/*
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
{
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("&amp;", "&lt;", "&gt;", "&quot;", "&apos;", "&#45;"),
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.' ';
// \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]';
foreach ($censored as $badword)
{
if ($replacement != '')
{
$str = preg_replace("/({$delim})(".str_replace('\*', '\w*?', preg_quote($badword, '/')).")({$delim})/i", "\\1{$replacement}\\3", $str);
}
else
{
$str = preg_replace("/({$delim})(".str_replace('\*', '\w*?', preg_quote($badword, '/')).")({$delim})/ie", "'\\1'.str_repeat('#', strlen('\\2')).'\\3'", $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('&lt;', '&gt;'), 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('<?', '?>', '<%', '%>', '\\', '</script>'),
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 = '<?php '.$str.' ?>'; // <?
// All the magic happens here, baby!
$str = highlight_string($str, TRUE);
// Prior to PHP 5, the highligh function used icky <font> tags
// so we'll replace them with <span> tags.
if (abs(PHP_VERSION) < 5)
{
$str = str_replace(array('<font ', '</font>'), array('<span ', '</span>'), $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('/<span style="color: #([A-Z0-9]+)">&lt;\?php(&nbsp;| )/i', '<span style="color: #$1">', $str);
$str = preg_replace('/(<span style="color: #[A-Z0-9]+">.*?)\?&gt;<\/span>\n<\/span>\n<\/code>/is', "$1</span>\n</span>\n</code>", $str);
$str = preg_replace('/<span style="color: #[A-Z0-9]+"\><\/span>/i', '', $str);
// Replace our markers back to PHP tags.
$str = str_replace(array('phptagopen', 'phptagclose', 'asptagopen', 'asptagclose', 'backslashtmp', 'scriptclose'),
array('&lt;?', '?&gt;', '&lt;%', '%&gt;', '\\', '&lt;/script&gt;'), $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 = '<strong>', $tag_close = '</strong>')
{
if ($str == '')
{
return '';
}
if ($phrase != '')
{
return preg_replace('/('.preg_quote($phrase, '/').')/i', $tag_open."\\1".$tag_close, $str);
}
return $str;
}
}
// ------------------------------------------------------------------------
/**
* Convert Accented Foreign Characters to ASCII
*
* @access public
* @param string the text string
* @return string
*/
if ( ! function_exists('convert_accented_characters'))
{
function convert_accented_characters($str)
{
if (defined('ENVIRONMENT') AND is_file(APPPATH.'config/'.ENVIRONMENT.'/foreign_chars.php'))
{
include(APPPATH.'config/'.ENVIRONMENT.'/foreign_chars.php');
}
elseif (is_file(APPPATH.'config/foreign_chars.php'))
{
include(APPPATH.'config/foreign_chars.php');
}
if ( ! isset($foreign_characters))
{
return $str;
}
return preg_replace(array_keys($foreign_characters), array_values($foreign_characters), $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;
}
}
// ------------------------------------------------------------------------
/**
* Ellipsize String
*
* This function will strip tags from a string, split it at its max_length and ellipsize
*
* @param string string to ellipsize
* @param integer max length of string
* @param mixed int (1|0) or float, .5, .2, etc for position to split
* @param string ellipsis ; Default '...'
* @return string ellipsized string
*/
if ( ! function_exists('ellipsize'))
{
function ellipsize($str, $max_length, $position = 1, $ellipsis = '&hellip;')
{
// Strip tags
$str = trim(strip_tags($str));
// Is the string long enough to ellipsize?
if (strlen($str) <= $max_length)
{
return $str;
}
$beg = substr($str, 0, floor($max_length * $position));
$position = ($position > 1) ? 1 : $position;
if ($position === 1)
{
$end = substr($str, 0, -($max_length - strlen($beg)));
}
else
{
$end = substr($str, -($max_length - strlen($beg)));
}
return $beg.$ellipsis.$end;
}
}
/* End of file text_helper.php */
/* Location: ./system/helpers/text_helper.php */

View File

@ -0,0 +1,93 @@
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/**
* CodeIgniter
*
* An open source application development framework for PHP 5.1.6 or newer
*
* @package CodeIgniter
* @author ExpressionEngine Dev Team
* @copyright Copyright (c) 2008 - 2011, EllisLab, Inc.
* @license http://codeigniter.com/user_guide/license.html
* @link http://codeigniter.com
* @since Version 1.0
* @filesource
*/
// ------------------------------------------------------------------------
/**
* CodeIgniter Typography Helpers
*
* @package CodeIgniter
* @subpackage Helpers
* @category Helpers
* @author ExpressionEngine Dev Team
* @link http://codeigniter.com/user_guide/helpers/typography_helper.html
*/
// ------------------------------------------------------------------------
/**
* Convert newlines to HTML line breaks except within PRE tags
*
* @access public
* @param string
* @return string
*/
if ( ! function_exists('nl2br_except_pre'))
{
function nl2br_except_pre($str)
{
$CI =& get_instance();
$CI->load->library('typography');
return $CI->typography->nl2br_except_pre($str);
}
}
// ------------------------------------------------------------------------
/**
* Auto Typography Wrapper Function
*
*
* @access public
* @param string
* @param bool whether to allow javascript event handlers
* @param bool whether to reduce multiple instances of double newlines to two
* @return string
*/
if ( ! function_exists('auto_typography'))
{
function auto_typography($str, $strip_js_event_handlers = TRUE, $reduce_linebreaks = FALSE)
{
$CI =& get_instance();
$CI->load->library('typography');
return $CI->typography->auto_typography($str, $strip_js_event_handlers, $reduce_linebreaks);
}
}
// --------------------------------------------------------------------
/**
* HTML Entities Decode
*
* This function is a replacement for html_entity_decode()
*
* @access public
* @param string
* @return string
*/
if ( ! function_exists('entity_decode'))
{
function entity_decode($str, $charset='UTF-8')
{
global $SEC;
return $SEC->entity_decode($str, $charset);
}
}
/* End of file typography_helper.php */
/* Location: ./system/helpers/typography_helper.php */

View File

@ -0,0 +1,594 @@
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/**
* CodeIgniter
*
* An open source application development framework for PHP 5.1.6 or newer
*
* @package CodeIgniter
* @author ExpressionEngine Dev Team
* @copyright Copyright (c) 2008 - 2011, EllisLab, Inc.
* @license http://codeigniter.com/user_guide/license.html
* @link http://codeigniter.com
* @since Version 1.0
* @filesource
*/
// ------------------------------------------------------------------------
/**
* CodeIgniter URL Helpers
*
* @package CodeIgniter
* @subpackage Helpers
* @category Helpers
* @author ExpressionEngine Dev Team
* @link http://codeigniter.com/user_guide/helpers/url_helper.html
*/
// ------------------------------------------------------------------------
/**
* Site URL
*
* Create a local URL based on your basepath. Segments can be passed via the
* first parameter either as a string or an array.
*
* @access public
* @param string
* @return string
*/
if ( ! function_exists('site_url'))
{
function site_url($uri = '')
{
$CI =& get_instance();
return $CI->config->site_url($uri);
}
}
// ------------------------------------------------------------------------
/**
* Base URL
*
* Create a local URL based on your basepath.
* Segments can be passed in as a string or an array, same as site_url
* or a URL to a file can be passed in, e.g. to an image file.
*
* @access public
* @param string
* @return string
*/
if ( ! function_exists('base_url'))
{
function base_url($uri = '')
{
$CI =& get_instance();
return $CI->config->base_url($uri);
}
}
// ------------------------------------------------------------------------
/**
* 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 '<a href="'.$site_url.'"'.$attributes.'>'.$title.'</a>';
}
}
// ------------------------------------------------------------------------
/**
* 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 "<a href='javascript:void(0);' onclick=\"window.open('".$site_url."', '_blank');\">".$title."</a>";
}
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 "<a href='javascript:void(0);' onclick=\"window.open('".$site_url."', '_blank', '"._parse_attributes($atts, TRUE)."');\"$attributes>".$title."</a>";
}
}
// ------------------------------------------------------------------------
/**
* 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 '<a href="mailto:'.$email.'"'.$attributes.'>'.$title.'</a>';
}
}
// ------------------------------------------------------------------------
/**
* 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('<a href="mailto:', $i, 1);
}
for ($i = 0; $i < strlen($email); $i++)
{
$x[] = "|".ord(substr($email, $i, 1));
}
$x[] = '"';
if ($attributes != '')
{
if (is_array($attributes))
{
foreach ($attributes as $key => $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();
?><script type="text/javascript">
//<![CDATA[
var l=new Array();
<?php
$i = 0;
foreach ($x as $val){ ?>l[<?php echo $i++; ?>]='<?php echo $val; ?>';<?php } ?>
for (var i = l.length-1; i >= 0; i=i-1){
if (l[i].substring(0, 1) == '|') document.write("&#"+unescape(l[i].substring(1))+";");
else document.write(unescape(l[i]));}
//]]>
</script><?php
$buffer = ob_get_contents();
ob_end_clean();
return $buffer;
}
}
// ------------------------------------------------------------------------
/**
* Auto-linker
*
* Automatically links URL and Email addresses.
* Note: There's a bit of extra code here to deal with
* URLs or emails that end in a period. We'll strip these
* off and add them after the link.
*
* @access public
* @param string the string
* @param string the type: email, url, or both
* @param bool whether to create pop-up links
* @return string
*/
if ( ! function_exists('auto_link'))
{
function auto_link($str, $type = 'both', $popup = FALSE)
{
if ($type != 'email')
{
if (preg_match_all("#(^|\s|\()((http(s?)://)|(www\.))(\w+[^\s\)\<]+)#i", $str, $matches))
{
$pop = ($popup == TRUE) ? " target=\"_blank\" " : "";
for ($i = 0; $i < count($matches['0']); $i++)
{
$period = '';
if (preg_match("|\.$|", $matches['6'][$i]))
{
$period = '.';
$matches['6'][$i] = substr($matches['6'][$i], 0, -1);
}
$str = str_replace($matches['0'][$i],
$matches['1'][$i].'<a href="http'.
$matches['4'][$i].'://'.
$matches['5'][$i].
$matches['6'][$i].'"'.$pop.'>http'.
$matches['4'][$i].'://'.
$matches['5'][$i].
$matches['6'][$i].'</a>'.
$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 < count($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 no scheme is included
*
* @access public
* @param string the URL
* @return string
*/
if ( ! function_exists('prep_url'))
{
function prep_url($str = '')
{
if ($str == 'http://' OR $str == '')
{
return '';
}
$url = parse_url($str);
if ( ! $url OR ! isset($url['scheme']))
{
$str = 'http://'.$str;
}
return $str;
}
}
// ------------------------------------------------------------------------
/**
* Create URL Title
*
* Takes a "title" string as input and creates a
* human-friendly URL string with a "separator" string
* as the word separator.
*
* @access public
* @param string the string
* @param string the separator
* @return string
*/
if ( ! function_exists('url_title'))
{
function url_title($str, $separator = '-', $lowercase = FALSE)
{
if ($separator == 'dash')
{
$separator = '-';
}
else if ($separator == 'underscore')
{
$separator = '_';
}
$q_separator = preg_quote($separator);
$trans = array(
'&.+?;' => '',
'[^a-z0-9 _-]' => '',
'\s+' => $separator,
'('.$q_separator.')+' => $separator
);
$str = strip_tags($str);
foreach ($trans as $key => $val)
{
$str = preg_replace("#".$key."#i", $val, $str);
}
if ($lowercase === TRUE)
{
$str = strtolower($str);
}
return trim($str, $separator);
}
}
// ------------------------------------------------------------------------
/**
* 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)
{
if ( ! preg_match('#^https?://#i', $uri))
{
$uri = site_url($uri);
}
switch($method)
{
case 'refresh' : header("Refresh:0;url=".$uri);
break;
default : header("Location: ".$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 */

View File

@ -0,0 +1,71 @@
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/**
* CodeIgniter
*
* An open source application development framework for PHP 5.1.6 or newer
*
* @package CodeIgniter
* @author ExpressionEngine Dev Team
* @copyright Copyright (c) 2008 - 2011, EllisLab, Inc.
* @license http://codeigniter.com/user_guide/license.html
* @link http://codeigniter.com
* @since Version 1.0
* @filesource
*/
// ------------------------------------------------------------------------
/**
* CodeIgniter XML Helpers
*
* @package CodeIgniter
* @subpackage Helpers
* @category Helpers
* @author ExpressionEngine Dev Team
* @link http://codeigniter.com/user_guide/helpers/xml_helper.html
*/
// ------------------------------------------------------------------------
/**
* Convert Reserved XML characters to Entities
*
* @access public
* @param string
* @return string
*/
if ( ! function_exists('xml_convert'))
{
function xml_convert($str, $protect_all = FALSE)
{
$temp = '__TEMP_AMPERSANDS__';
// Replace entities to temporary markers so that
// ampersands won't get messed up
$str = preg_replace("/&#(\d+);/", "$temp\\1;", $str);
if ($protect_all === TRUE)
{
$str = preg_replace("/&(\w+);/", "$temp\\1;", $str);
}
$str = str_replace(array("&","<",">","\"", "'", "-"),
array("&amp;", "&lt;", "&gt;", "&quot;", "&apos;", "&#45;"),
$str);
// Decode the temp markers back to entities
$str = preg_replace("/$temp(\d+);/","&#\\1;",$str);
if ($protect_all === TRUE)
{
$str = preg_replace("/$temp(\w+);/","&\\1;", $str);
}
return $str;
}
}
// ------------------------------------------------------------------------
/* End of file xml_helper.php */
/* Location: ./system/helpers/xml_helper.php */