summaryrefslogtreecommitdiffstats
path: root/system/helpers
diff options
context:
space:
mode:
Diffstat (limited to 'system/helpers')
-rw-r--r--system/helpers/email_helper.php11
-rw-r--r--system/helpers/file_helper.php72
-rw-r--r--system/helpers/form_helper.php74
-rw-r--r--system/helpers/html_helper.php70
-rw-r--r--system/helpers/inflector_helper.php30
-rw-r--r--system/helpers/language_helper.php9
-rw-r--r--system/helpers/number_helper.php9
-rw-r--r--system/helpers/path_helper.php20
-rw-r--r--system/helpers/security_helper.php23
9 files changed, 113 insertions, 205 deletions
diff --git a/system/helpers/email_helper.php b/system/helpers/email_helper.php
index e6a9003e2..f184031a9 100644
--- a/system/helpers/email_helper.php
+++ b/system/helpers/email_helper.php
@@ -1,13 +1,13 @@
-<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
+<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/**
* CodeIgniter
*
* An open source application development framework for PHP 5.1.6 or newer
*
* NOTICE OF LICENSE
- *
+ *
* Licensed under the Open Software License version 3.0
- *
+ *
* This source file is subject to the Open Software License (OSL 3.0) that is
* bundled with this package in the files license.txt / license.rst. It is
* also available through the world wide web at this URL:
@@ -49,7 +49,7 @@ 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;
+ return (bool) preg_match('/^([a-z0-9\+_\-]+)(\.[a-z0-9\+_\-]+)*@([a-z0-9\-]+\.)+[a-z]{2,6}$/ix', $address);
}
}
@@ -69,6 +69,5 @@ if ( ! function_exists('send_email'))
}
}
-
/* End of file email_helper.php */
-/* Location: ./system/helpers/email_helper.php */ \ No newline at end of file
+/* Location: ./system/helpers/email_helper.php */
diff --git a/system/helpers/file_helper.php b/system/helpers/file_helper.php
index cc9dea22a..9b39b8c20 100644
--- a/system/helpers/file_helper.php
+++ b/system/helpers/file_helper.php
@@ -1,13 +1,13 @@
-<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
+<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/**
* CodeIgniter
*
* An open source application development framework for PHP 5.1.6 or newer
*
* NOTICE OF LICENSE
- *
+ *
* Licensed under the Open Software License version 3.0
- *
+ *
* This source file is subject to the Open Software License (OSL 3.0) that is
* bundled with this package in the files license.txt / license.rst. It is
* also available through the world wide web at this URL:
@@ -142,15 +142,11 @@ if ( ! function_exists('delete_files'))
while (FALSE !== ($filename = @readdir($current_dir)))
{
- if ($filename != "." and $filename != "..")
+ if ($filename !== '.' and $filename !== '..')
{
- if (is_dir($path.DIRECTORY_SEPARATOR.$filename))
+ if (is_dir($path.DIRECTORY_SEPARATOR.$filename) && $filename[0] !== '.')
{
- // Ignore empty folders
- if (substr($filename, 0, 1) != '.')
- {
- delete_files($path.DIRECTORY_SEPARATOR.$filename, $del_dir, $level + 1);
- }
+ delete_files($path.DIRECTORY_SEPARATOR.$filename, $del_dir, $level + 1);
}
else
{
@@ -209,12 +205,12 @@ if ( ! function_exists('get_filenames'))
$_filedata[] = ($include_path == TRUE) ? $source_dir.$file : $file;
}
}
+ closedir($source_dir);
+
return $_filedata;
}
- else
- {
- return FALSE;
- }
+
+ return FALSE;
}
}
@@ -263,13 +259,12 @@ if ( ! function_exists('get_dir_file_info'))
$_filedata[$file]['relative_path'] = $relative_path;
}
}
+ closedir($source_dir);
return $_filedata;
}
- else
- {
- return FALSE;
- }
+
+ return FALSE;
}
}
@@ -391,10 +386,8 @@ if ( ! function_exists('get_mime_by_extension'))
return $mimes[$extension];
}
}
- else
- {
- return FALSE;
- }
+
+ return FALSE;
}
}
@@ -414,31 +407,31 @@ if ( ! function_exists('symbolic_permissions'))
{
function symbolic_permissions($perms)
{
- if (($perms & 0xC000) == 0xC000)
+ if (($perms & 0xC000) === 0xC000)
{
$symbolic = 's'; // Socket
}
- elseif (($perms & 0xA000) == 0xA000)
+ elseif (($perms & 0xA000) === 0xA000)
{
$symbolic = 'l'; // Symbolic Link
}
- elseif (($perms & 0x8000) == 0x8000)
+ elseif (($perms & 0x8000) === 0x8000)
{
$symbolic = '-'; // Regular
}
- elseif (($perms & 0x6000) == 0x6000)
+ elseif (($perms & 0x6000) === 0x6000)
{
$symbolic = 'b'; // Block special
}
- elseif (($perms & 0x4000) == 0x4000)
+ elseif (($perms & 0x4000) === 0x4000)
{
$symbolic = 'd'; // Directory
}
- elseif (($perms & 0x2000) == 0x2000)
+ elseif (($perms & 0x2000) === 0x2000)
{
$symbolic = 'c'; // Character special
}
- elseif (($perms & 0x1000) == 0x1000)
+ elseif (($perms & 0x1000) === 0x1000)
{
$symbolic = 'p'; // FIFO pipe
}
@@ -448,19 +441,19 @@ if ( ! function_exists('symbolic_permissions'))
}
// Owner
- $symbolic .= (($perms & 0x0100) ? 'r' : '-');
- $symbolic .= (($perms & 0x0080) ? 'w' : '-');
- $symbolic .= (($perms & 0x0040) ? (($perms & 0x0800) ? 's' : 'x' ) : (($perms & 0x0800) ? 'S' : '-'));
+ $symbolic .= (($perms & 0x0100) ? 'r' : '-')
+ . (($perms & 0x0080) ? 'w' : '-')
+ . (($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' : '-'));
+ $symbolic .= (($perms & 0x0020) ? 'r' : '-')
+ . (($perms & 0x0010) ? 'w' : '-')
+ . (($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' : '-'));
+ $symbolic .= (($perms & 0x0004) ? 'r' : '-')
+ . (($perms & 0x0002) ? 'w' : '-')
+ . (($perms & 0x0001) ? (($perms & 0x0200) ? 't' : 'x' ) : (($perms & 0x0200) ? 'T' : '-'));
return $symbolic;
}
@@ -486,6 +479,5 @@ if ( ! function_exists('octal_permissions'))
}
}
-
/* End of file file_helper.php */
-/* Location: ./system/helpers/file_helper.php */ \ No newline at end of file
+/* Location: ./system/helpers/file_helper.php */
diff --git a/system/helpers/form_helper.php b/system/helpers/form_helper.php
index 3a7f8fe3e..bed2cb297 100644
--- a/system/helpers/form_helper.php
+++ b/system/helpers/form_helper.php
@@ -1,13 +1,13 @@
-<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
+<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/**
* CodeIgniter
*
* An open source application development framework for PHP 5.1.6 or newer
*
* NOTICE OF LICENSE
- *
+ *
* Licensed under the Open Software License version 3.0
- *
+ *
* This source file is subject to the Open Software License (OSL 3.0) that is
* bundled with this package in the files license.txt / license.rst. It is
* also available through the world wide web at this URL:
@@ -70,14 +70,10 @@ if ( ! function_exists('form_open'))
// If no action is provided then set to the current url
$action OR $action = $CI->config->site_url($CI->uri->uri_string());
- $form = '<form action="'.$action.'"';
-
- $form .= _attributes_to_string($attributes, TRUE);
+ $form = '<form action="'.$action.'"'._attributes_to_string($attributes, TRUE).">\n";
- $form .= '>';
-
- // Add CSRF field if enabled, but leave it out for GET requests and requests to external websites
- if ($CI->config->item('csrf_protection') === TRUE AND ! (strpos($action, $CI->config->site_url()) === FALSE OR strpos($form, 'method="get"')))
+ // Add CSRF field if enabled, but leave it out for GET requests and requests to external websites
+ if ($CI->config->item('csrf_protection') === TRUE AND ! (strpos($action, $CI->config->site_url()) === FALSE OR strpos($form, 'method="get"')))
{
$hidden[$CI->security->get_csrf_token_name()] = $CI->security->get_csrf_hash();
}
@@ -156,7 +152,7 @@ if ( ! function_exists('form_hidden'))
if ( ! is_array($value))
{
- $form .= '<input type="hidden" name="'.$name.'" value="'.form_prep($value, $name).'" />'."\n";
+ $form .= '<input type="hidden" name="'.$name.'" value="'.form_prep($value, $name)."\" />\n";
}
else
{
@@ -188,7 +184,7 @@ if ( ! function_exists('form_input'))
{
$defaults = array('type' => 'text', 'name' => (( ! is_array($data)) ? $data : ''), 'value' => $value);
- return "<input "._parse_form_attributes($data, $defaults).$extra." />";
+ return '<input '._parse_form_attributes($data, $defaults).$extra." />\n";
}
}
@@ -274,7 +270,7 @@ if ( ! function_exists('form_textarea'))
}
$name = (is_array($data)) ? $data['name'] : $data;
- return "<textarea "._parse_form_attributes($data, $defaults).$extra.">".form_prep($val, $name)."</textarea>";
+ return '<textarea '._parse_form_attributes($data, $defaults).$extra.'>'.form_prep($val, $name)."</textarea>\n";
}
}
@@ -325,13 +321,9 @@ if ( ! function_exists('form_dropdown'))
}
// If no selected state was submitted we will attempt to set it automatically
- if (count($selected) === 0)
+ if (count($selected) === 0 && isset($_POST[$name]))
{
- // If the form name appears in the $_POST array we have a winner!
- if (isset($_POST[$name]))
- {
- $selected = array($_POST[$name]);
- }
+ $selected = array($_POST[$name]);
}
if ($extra != '') $extra = ' '.$extra;
@@ -346,12 +338,11 @@ if ( ! function_exists('form_dropdown'))
if (is_array($val) && ! empty($val))
{
- $form .= '<optgroup label="'.$key.'">'."\n";
+ $form .= '<optgroup label="'.$key."\">\n";
foreach ($val as $optgroup_key => $optgroup_val)
{
$sel = (in_array($optgroup_key, $selected)) ? ' selected="selected"' : '';
-
$form .= '<option value="'.$optgroup_key.'"'.$sel.'>'.(string) $optgroup_val."</option>\n";
}
@@ -359,13 +350,11 @@ if ( ! function_exists('form_dropdown'))
}
else
{
- $sel = (in_array($key, $selected)) ? ' selected="selected"' : '';
-
- $form .= '<option value="'.$key.'"'.$sel.'>'.(string) $val."</option>\n";
+ $form .= '<option value="'.$key.'"'.(in_array($key, $selected) ? ' selected="selected"' : '').'>'.(string) $val."</option>\n";
}
}
- $form .= '</select>';
+ $form .= "</select>\n";
return $form;
}
@@ -412,7 +401,7 @@ if ( ! function_exists('form_checkbox'))
unset($defaults['checked']);
}
- return "<input "._parse_form_attributes($data, $defaults).$extra." />";
+ return '<input '._parse_form_attributes($data, $defaults).$extra." />\n";
}
}
@@ -458,8 +447,7 @@ if ( ! function_exists('form_submit'))
function form_submit($data = '', $value = '', $extra = '')
{
$defaults = array('type' => 'submit', 'name' => (( ! is_array($data)) ? $data : ''), 'value' => $value);
-
- return "<input "._parse_form_attributes($data, $defaults).$extra." />";
+ return '<input '._parse_form_attributes($data, $defaults).$extra." />\n";
}
}
@@ -479,8 +467,7 @@ if ( ! function_exists('form_reset'))
function form_reset($data = '', $value = '', $extra = '')
{
$defaults = array('type' => 'reset', 'name' => (( ! is_array($data)) ? $data : ''), 'value' => $value);
-
- return "<input "._parse_form_attributes($data, $defaults).$extra." />";
+ return '<input '._parse_form_attributes($data, $defaults).$extra." />\n";
}
}
@@ -500,14 +487,13 @@ if ( ! function_exists('form_button'))
function form_button($data = '', $content = '', $extra = '')
{
$defaults = array('name' => (( ! is_array($data)) ? $data : ''), 'type' => 'button');
-
if ( is_array($data) AND isset($data['content']))
{
$content = $data['content'];
unset($data['content']); // content is not an attribute
}
- return "<button "._parse_form_attributes($data, $defaults).$extra.">".$content."</button>";
+ return '<button '._parse_form_attributes($data, $defaults).$extra.'>'.$content."</button>\n";
}
}
@@ -542,9 +528,7 @@ if ( ! function_exists('form_label'))
}
}
- $label .= ">$label_text</label>";
-
- return $label;
+ return $label .= ">$label_text</label>";
}
}
@@ -564,12 +548,7 @@ if ( ! function_exists('form_fieldset'))
{
function form_fieldset($legend_text = '', $attributes = array())
{
- $fieldset = "<fieldset";
-
- $fieldset .= _attributes_to_string($attributes, FALSE);
-
- $fieldset .= ">\n";
-
+ $fieldset = '<fieldset'._attributes_to_string($attributes, FALSE).">\n";
if ($legend_text != '')
{
$fieldset .= "<legend>$legend_text</legend>\n";
@@ -654,15 +633,13 @@ if ( ! function_exists('form_prep'))
{
return $str;
}
-
- $str = html_escape($str);
if ($field_name != '')
{
$prepped_fields[$field_name] = $field_name;
}
- return $str;
+ return html_escape($str);
}
}
@@ -992,7 +969,7 @@ if ( ! function_exists('_attributes_to_string'))
$attributes .= ' accept-charset="'.strtolower(config_item('charset')).'"';
}
- return ' '.$attributes;
+ return ' '.$attributes;
}
if (is_object($attributes) AND count($attributes) > 0)
@@ -1043,21 +1020,20 @@ if ( ! function_exists('_get_validation_object'))
// We set this as a variable since we're returning by reference.
$return = FALSE;
-
+
if (FALSE !== ($object = $CI->load->is_loaded('form_validation')))
{
if ( ! isset($CI->$object) OR ! is_object($CI->$object))
{
return $return;
}
-
+
return $CI->$object;
}
-
+
return $return;
}
}
-
/* End of file form_helper.php */
/* Location: ./system/helpers/form_helper.php */
diff --git a/system/helpers/html_helper.php b/system/helpers/html_helper.php
index 2a603a607..72970d9ca 100644
--- a/system/helpers/html_helper.php
+++ b/system/helpers/html_helper.php
@@ -1,13 +1,13 @@
-<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
+<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/**
* CodeIgniter
*
* An open source application development framework for PHP 5.1.6 or newer
*
* NOTICE OF LICENSE
- *
+ *
* Licensed under the Open Software License version 3.0
- *
+ *
* This source file is subject to the Open Software License (OSL 3.0) that is
* bundled with this package in the files license.txt / license.rst. It is
* also available through the world wide web at this URL:
@@ -54,8 +54,7 @@ if ( ! function_exists('heading'))
{
function heading($data = '', $h = '1', $attributes = '')
{
- $attributes = ($attributes != '') ? ' '.$attributes : $attributes;
- return "<h".$h.$attributes.">".$data."</h".$h.">";
+ return '<h'.$h.($attributes != '' ? ' ' : '').$attributes.'>'.$data.'</h'.$h.'>';
}
}
@@ -124,7 +123,7 @@ if ( ! function_exists('_list'))
}
// Set the indentation based on the depth
- $out = str_repeat(" ", $depth);
+ $out = str_repeat(' ', $depth);
// Were any attributes submitted? If so generate a string
if (is_array($attributes))
@@ -142,7 +141,7 @@ if ( ! function_exists('_list'))
}
// Write the opening list tag
- $out .= "<".$type.$attributes.">\n";
+ $out .= '<'.$type.$attributes.">\n";
// Cycle through the list elements. If an array is
// encountered we will recursively call _list()
@@ -152,8 +151,7 @@ if ( ! function_exists('_list'))
{
$_last_list_item = $key;
- $out .= str_repeat(" ", $depth + 2);
- $out .= "<li>";
+ $out .= str_repeat(' ', $depth + 2).'<li>';
if ( ! is_array($val))
{
@@ -161,21 +159,14 @@ if ( ! function_exists('_list'))
}
else
{
- $out .= $_last_list_item."\n";
- $out .= _list($type, $val, '', $depth + 4);
- $out .= str_repeat(" ", $depth + 2);
+ $out .= $_last_list_item."\n"._list($type, $val, '', $depth + 4).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;
+ // Set the indentation for the closing tag and apply it
+ return $out.str_repeat(' ', $depth).'</'.$type.">\n";
}
}
@@ -192,7 +183,7 @@ if ( ! function_exists('br'))
{
function br($num = 1)
{
- return str_repeat("<br />", $num);
+ return str_repeat('<br />', $num);
}
}
@@ -224,10 +215,9 @@ if ( ! function_exists('img'))
$img = '<img';
- foreach ($src as $k=>$v)
+ foreach ($src as $k => $v)
{
-
- if ($k == 'src' AND strpos($v, '://') === FALSE)
+ if ($k === 'src' AND strpos($v, '://') === FALSE)
{
$CI =& get_instance();
@@ -246,9 +236,7 @@ if ( ! function_exists('img'))
}
}
- $img .= '/>';
-
- return $img;
+ return $img.'/>';
}
}
@@ -290,14 +278,7 @@ if ( ! function_exists('doctype'))
}
}
- if (isset($_doctypes[$type]))
- {
- return $_doctypes[$type];
- }
- else
- {
- return FALSE;
- }
+ return (isset($_doctypes[$type])) ? $_doctypes[$type] : FALSE;
}
}
@@ -322,14 +303,13 @@ 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)
+ foreach ($href as $k => $v)
{
- if ($k == 'href' AND strpos($v, '://') === FALSE)
+ if ($k === 'href' AND strpos($v, '://') === FALSE)
{
if ($index_page === TRUE)
{
@@ -346,11 +326,11 @@ if ( ! function_exists('link_tag'))
}
}
- $link .= "/>";
+ $link .= '/>';
}
else
{
- if ( strpos($href, '://') !== FALSE)
+ if (strpos($href, '://') !== FALSE)
{
$link .= 'href="'.$href.'" ';
}
@@ -365,21 +345,20 @@ if ( ! function_exists('link_tag'))
$link .= 'rel="'.$rel.'" type="'.$type.'" ';
- if ($media != '')
+ if ($media != '')
{
$link .= 'media="'.$media.'" ';
}
- if ($title != '')
+ if ($title != '')
{
$link .= 'title="'.$title.'" ';
}
$link .= '/>';
}
- $link .= "\n";
- return $link;
+ return $link."\n";
}
}
@@ -439,10 +418,9 @@ if ( ! function_exists('nbs'))
{
function nbs($num = 1)
{
- return str_repeat("&nbsp;", $num);
+ return str_repeat('&nbsp;', $num);
}
}
-
/* End of file html_helper.php */
-/* Location: ./system/helpers/html_helper.php */ \ No newline at end of file
+/* Location: ./system/helpers/html_helper.php */
diff --git a/system/helpers/inflector_helper.php b/system/helpers/inflector_helper.php
index f093dd921..0bd1e112f 100644
--- a/system/helpers/inflector_helper.php
+++ b/system/helpers/inflector_helper.php
@@ -1,4 +1,4 @@
-<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
+<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/**
* CodeIgniter
*
@@ -85,16 +85,7 @@ if ( ! function_exists('singular'))
'/([^u])s$/' => '\1',
);
- foreach ($singular_rules as $rule => $replacement)
- {
- if (preg_match($rule, $result))
- {
- $result = preg_replace($rule, $replacement, $result);
- break;
- }
- }
-
- return $result;
+ return preg_replace(array_keys($singular_values), $singular_values, $result);
}
}
@@ -138,16 +129,7 @@ if ( ! function_exists('plural'))
'/$/' => 's',
);
- foreach ($plural_rules as $rule => $replacement)
- {
- if (preg_match($rule, $result))
- {
- $result = preg_replace($rule, $replacement, $result);
- break;
- }
- }
-
- return $result;
+ return preg_replace(array_keys($plural_rules), $plural_rules, $result);
}
}
@@ -166,9 +148,7 @@ if ( ! function_exists('camelize'))
{
function camelize($str)
{
- $str = 'x'.strtolower(trim($str));
- $str = ucwords(preg_replace('/[\s_]+/', ' ', $str));
- return substr(str_replace(' ', '', $str), 1);
+ return substr(str_replace(' ', '', ucwords(preg_replace('/[\s_]+/', ' ', $str))), 1);
}
}
@@ -212,4 +192,4 @@ if ( ! function_exists('humanize'))
}
/* End of file inflector_helper.php */
-/* Location: ./system/helpers/inflector_helper.php */ \ No newline at end of file
+/* Location: ./system/helpers/inflector_helper.php */
diff --git a/system/helpers/language_helper.php b/system/helpers/language_helper.php
index ed17bfa4c..a83580a97 100644
--- a/system/helpers/language_helper.php
+++ b/system/helpers/language_helper.php
@@ -1,13 +1,13 @@
-<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
+<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/**
* CodeIgniter
*
* An open source application development framework for PHP 5.1.6 or newer
*
* NOTICE OF LICENSE
- *
+ *
* Licensed under the Open Software License version 3.0
- *
+ *
* This source file is subject to the Open Software License (OSL 3.0) that is
* bundled with this package in the files license.txt / license.rst. It is
* also available through the world wide web at this URL:
@@ -65,6 +65,5 @@ if ( ! function_exists('lang'))
}
}
-// ------------------------------------------------------------------------
/* End of file language_helper.php */
-/* Location: ./system/helpers/language_helper.php */ \ No newline at end of file
+/* Location: ./system/helpers/language_helper.php */
diff --git a/system/helpers/number_helper.php b/system/helpers/number_helper.php
index 71d39df1f..331b468c6 100644
--- a/system/helpers/number_helper.php
+++ b/system/helpers/number_helper.php
@@ -1,13 +1,13 @@
-<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
+<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/**
* CodeIgniter
*
* An open source application development framework for PHP 5.1.6 or newer
*
* NOTICE OF LICENSE
- *
+ *
* Licensed under the Open Software License version 3.0
- *
+ *
* This source file is subject to the Open Software License (OSL 3.0) that is
* bundled with this package in the files license.txt / license.rst. It is
* also available through the world wide web at this URL:
@@ -83,6 +83,5 @@ if ( ! function_exists('byte_format'))
}
}
-
/* End of file number_helper.php */
-/* Location: ./system/helpers/number_helper.php */ \ No newline at end of file
+/* Location: ./system/helpers/number_helper.php */
diff --git a/system/helpers/path_helper.php b/system/helpers/path_helper.php
index da2b8d307..cd87a73eb 100644
--- a/system/helpers/path_helper.php
+++ b/system/helpers/path_helper.php
@@ -1,13 +1,13 @@
-<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
+<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/**
* CodeIgniter
*
* An open source application development framework for PHP 5.1.6 or newer
*
* NOTICE OF LICENSE
- *
+ *
* Licensed under the Open Software License version 3.0
- *
+ *
* This source file is subject to the Open Software License (OSL 3.0) that is
* bundled with this package in the files license.txt / license.rst. It is
* also available through the world wide web at this URL:
@@ -60,25 +60,21 @@ if ( ! function_exists('set_realpath'))
// Resolve the path
if (function_exists('realpath') AND @realpath($path) !== FALSE)
{
- $path = realpath($path).'/';
+ $path = realpath($path);
}
// Add a trailing slash
- $path = preg_replace("#([^/])/*$#", "\\1/", $path);
+ $path = rtrim($path, DIRECTORY_SEPARATOR).DIRECTORY_SEPARATOR;
// Make sure the path exists
- if ($check_existance == TRUE)
+ if ($check_existance == TRUE && ! is_dir($path))
{
- if ( ! is_dir($path))
- {
- show_error('Not a valid path: '.$path);
- }
+ show_error('Not a valid path: '.$path);
}
return $path;
}
}
-
/* End of file path_helper.php */
-/* Location: ./system/helpers/path_helper.php */ \ No newline at end of file
+/* Location: ./system/helpers/path_helper.php */
diff --git a/system/helpers/security_helper.php b/system/helpers/security_helper.php
index d64bd12e1..99fda561a 100644
--- a/system/helpers/security_helper.php
+++ b/system/helpers/security_helper.php
@@ -1,13 +1,13 @@
-<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
+<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/**
* CodeIgniter
*
* An open source application development framework for PHP 5.1.6 or newer
*
* NOTICE OF LICENSE
- *
+ *
* Licensed under the Open Software License version 3.0
- *
+ *
* This source file is subject to the Open Software License (OSL 3.0) that is
* bundled with this package in the files license.txt / license.rst. It is
* also available through the world wide web at this URL:
@@ -87,14 +87,7 @@ if ( ! function_exists('do_hash'))
{
function do_hash($str, $type = 'sha1')
{
- if ($type == 'sha1')
- {
- return sha1($str);
- }
- else
- {
- return md5($str);
- }
+ return ($type === 'sha1') ? sha1($str) : md5($str);
}
}
@@ -111,10 +104,7 @@ 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;
+ return preg_replace(array("#<img\s+.*?src\s*=\s*[\"'](.+?)[\"'].*?\>#", "#<img\s+.*?src\s*=\s*(.+?).*?\>#"), "\\1", $str);
}
}
@@ -135,6 +125,5 @@ if ( ! function_exists('encode_php_tags'))
}
}
-
/* End of file security_helper.php */
-/* Location: ./system/helpers/security_helper.php */ \ No newline at end of file
+/* Location: ./system/helpers/security_helper.php */