From b0dd10f8171945e0c1f3527dd1e9d18b043e01a7 Mon Sep 17 00:00:00 2001
From: admin Directory access is forbidden.
+
+
+
+
\ No newline at end of file
diff --git a/system/helpers/security_helper.php b/system/helpers/security_helper.php
new file mode 100644
index 000000000..918e4ae90
--- /dev/null
+++ b/system/helpers/security_helper.php
@@ -0,0 +1,112 @@
+input->xss_clean($str, $charset);
+}
+
+// --------------------------------------------------------------------
+
+/**
+ * Hash encode a string
+ *
+ * @access public
+ * @param string
+ * @return string
+ */
+function hash($str, $type = 'sha1')
+{
+ if ($type == 'sha1')
+ {
+ if ( ! function_exists('sha1'))
+ {
+ if ( ! function_exists('mhash'))
+ {
+ require_once(BASEPATH.'libraries/Sha1'.EXT);
+ $SH = new CI_SHA;
+ return $SH->generate($str);
+ }
+ else
+ {
+ return bin2hex(mhash(MHASH_SHA1, $str));
+ }
+ }
+ else
+ {
+ return sha1($str);
+ }
+ }
+ else
+ {
+ return md5($str);
+ }
+}
+
+// ------------------------------------------------------------------------
+
+/**
+ * Strip Image Tags
+ *
+ * @access public
+ * @parm string
+ * @return string
+ */
+function strip_image_tags($str)
+{
+ $str = preg_replace("##", "\\1", $str);
+ $str = preg_replace("##", "\\1", $str);
+
+ return $str;
+}
+
+// ------------------------------------------------------------------------
+
+/**
+ * Convert PHP tags to entities
+ *
+ * @access public
+ * @parm string
+ * @return string
+ */
+function encode_php_tags($str)
+{
+ return str_replace(array(''), array('<?php', '<?PHP', '<?', '?>'), $str);
+}
+
+?>
\ No newline at end of file
diff --git a/system/helpers/string_helper.php b/system/helpers/string_helper.php
new file mode 100644
index 000000000..d5a3591f9
--- /dev/null
+++ b/system/helpers/string_helper.php
@@ -0,0 +1,154 @@
+
\ No newline at end of file
diff --git a/system/helpers/text_helper.php b/system/helpers/text_helper.php
new file mode 100644
index 000000000..15b5573bf
--- /dev/null
+++ b/system/helpers/text_helper.php
@@ -0,0 +1,386 @@
+= $n)
+ {
+ return trim($out).$end_char;
+ }
+ }
+}
+
+// ------------------------------------------------------------------------
+
+/**
+ * High ASCII to Entities
+ *
+ * Converts High ascii text and MS Word special characters to character entities
+ *
+ * @access public
+ * @param string
+ * @return string
+ */
+function ascii_to_entities($str)
+{
+ $count = 1;
+ $out = '';
+ $temp = array();
+
+ for ($i = 0, $s = strlen($str); $i < $s; $i++)
+ {
+ $ordinal = ord($str[$i]);
+
+ if ($ordinal < 128)
+ {
+ $out .= $str[$i];
+ }
+ else
+ {
+ if (count($temp) == 0)
+ {
+ $count = ($ordinal < 224) ? 2 : 3;
+ }
+
+ $temp[] = $ordinal;
+
+ if (count($temp) == $count)
+ {
+ $number = ($count == 3) ? (($temp['0'] % 16) * 4096) + (($temp['1'] % 64) * 64) + ($temp['2'] % 64) : (($temp['0'] % 32) * 64) + ($temp['1'] % 64);
+
+ $out .= ''.$number.';';
+ $count = 1;
+ $temp = array();
+ }
+ }
+ }
+
+ return $out;
+}
+
+// ------------------------------------------------------------------------
+
+/**
+ * Entities to ASCII
+ *
+ * Converts character entities back to ASCII
+ *
+ * @access public
+ * @param string
+ * @param bool
+ * @return string
+ */
+function entities_to_ascii($str, $all = TRUE)
+{
+ if (preg_match_all('/\(\d+)\;/', $str, $matches))
+ {
+ for ($i = 0, $s = count($matches['0']); $i < $s; $i++)
+ {
+ $digits = $matches['1'][$i];
+
+ $out = '';
+
+ if ($digits < 128)
+ {
+ $out .= chr($digits);
+
+ }
+ elseif ($digits < 2048)
+ {
+ $out .= chr(192 + (($digits - ($digits % 64)) / 64));
+ $out .= chr(128 + ($digits % 64));
+ }
+ else
+ {
+ $out .= chr(224 + (($digits - ($digits % 4096)) / 4096));
+ $out .= chr(128 + ((($digits % 4096) - ($digits % 64)) / 64));
+ $out .= chr(128 + ($digits % 64));
+ }
+
+ $str = str_replace($matches['0'][$i], $out, $str);
+ }
+ }
+
+ if ($all)
+ {
+ $str = str_replace(array("&", "<", ">", """, "'", "-"),
+ array("&","<",">","\"", "'", "-"),
+ $str);
+ }
+
+ return $str;
+}
+
+// ------------------------------------------------------------------------
+
+/**
+ * Word Censoring Function
+ *
+ * Supply a string and an array of disallowed words and any
+ * matched words will be converted to #### or to the replacement
+ * word you've submitted.
+ *
+ * @access public
+ * @param string the text string
+ * @param string the array of censoered words
+ * @param string the optional replacement value
+ * @return string
+ */
+function word_censor($str, $censored, $replacement = '')
+{
+ if ( ! is_array($censored))
+ {
+ return $str;
+ }
+
+ $str = ' '.$str.' ';
+ foreach ($censored as $badword)
+ {
+ if ($replacement != '')
+ {
+ $str = preg_replace("/\b(".str_replace('\*', '\w*?', preg_quote($badword)).")\b/i", $replacement, $str);
+ }
+ else
+ {
+ $str = preg_replace("/\b(".str_replace('\*', '\w*?', preg_quote($badword)).")\b/ie", "str_repeat('#', strlen('\\1'))", $str);
+ }
+ }
+
+ return trim($str);
+}
+
+// ------------------------------------------------------------------------
+
+/**
+ * Code Highlighter
+ *
+ * Colorizes code strings
+ *
+ * @access public
+ * @param string the text string
+ * @return string
+ */
+function highlight_code($str)
+{
+ // The highlight string function encodes and highlights
+ // brackets so we need them to start raw
+ $str = str_replace(array('<', '>'), array('<', '>'), $str);
+
+ // Replace any existing PHP tags to temporary markers so they don't accidentally
+ // break the string out of PHP, and thus, thwart the highlighting.
+
+ $str = str_replace(array('<?php', '?>', '\\'), array('phptagopen', 'phptagclose', 'backslashtmp'), $str);
+
+ // The highlight_string function requires that the text be surrounded
+ // by PHP tags. Since we don't know if A) the submitted text has PHP tags,
+ // or B) whether the PHP tags enclose the entire string, we will add our
+ // own PHP tags around the string along with some markers to make replacement easier later
+
+ $str = ''; //
+
+ // All the magic happens here, baby!
+ $str = highlight_string($str, TRUE);
+
+ // Prior to PHP 5, the highlight function used icky font tags
+ // so we'll replace them with span tags.
+ if (abs(phpversion()) < 5)
+ {
+ $str = str_replace(array(''), array(''), $str);
+ $str = preg_replace('#color="(.*?)"#', 'style="color: \\1"', $str);
+ }
+
+ // Remove our artificially added PHP
+ $str = preg_replace("#\ tags
+ var $block_elements = 'div|blockquote|pre|code|h\d|script|ol|un';
+
+ // Elements that should not have and and \n* #', "\\1", $str);
+
+ $str = str_replace(
+ array(' ', '{{{tag}}}', '{{{DQ}}}', '{{{SQ}}}'),
+ array(' ', '<', '"', "'"),
+ $str
+ );
+
+ return trim($str);
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Format Characters
+ *
+ * This function mainly converts double and single quotes
+ * to entities, but since these are directional, it does
+ * it based on some rules. It also converts em-dashes
+ * and a couple other things.
+ */
+ function format_characters($str)
+ {
+ $table = array(
+ ' "' => " “",
+ '" ' => "” ",
+ " '" => " ‘",
+ "' " => "’ ",
+
+ '>"' => ">“",
+ '"<' => "”<",
+ ">'" => ">‘",
+ "'<" => "’<",
+
+ "\"." => "”.",
+ "\"," => "”,",
+ "\";" => "”;",
+ "\":" => "”:",
+ "\"!" => "”!",
+ "\"?" => "”?",
+
+ ". " => ". ",
+ "? " => "? ",
+ "! " => "! ",
+ ": " => ": ",
+ );
+
+ // These deal with quotes within quotes, like: "'hi here'"
+ $start = 0;
+ $space = array("\n", "\t", " ");
+
+ while(TRUE)
+ {
+ $current = strpos(substr($str, $start), "\"'");
+
+ if ($current === FALSE) break;
+
+ $one_before = substr($str, $start+$current-1, 1);
+ $one_after = substr($str, $start+$current+2, 1);
+
+ if ( ! in_array($one_after, $space) && $one_after != "<")
+ {
+ $str = str_replace( $one_before."\"'".$one_after,
+ $one_before."“‘".$one_after,
+ $str);
+ }
+ elseif ( ! in_array($one_before, $space) && (in_array($one_after, $space) OR $one_after == '<'))
+ {
+ $str = str_replace( $one_before."\"'".$one_after,
+ $one_before."”’".$one_after,
+ $str);
+ }
+
+ $start = $start+$current+2;
+ }
+
+ $start = 0;
+
+ while(TRUE)
+ {
+ $current = strpos(substr($str, $start), "'\"");
+
+ if ($current === FALSE) break;
+
+ $one_before = substr($str, $start+$current-1, 1);
+ $one_after = substr($str, $start+$current+2, 1);
+
+ if ( in_array($one_before, $space) && ! in_array($one_after, $space) && $one_after != "<")
+ {
+ $str = str_replace( $one_before."'\"".$one_after,
+ $one_before."‘“".$one_after,
+ $str);
+ }
+ elseif ( ! in_array($one_before, $space) && $one_before != ">")
+ {
+ $str = str_replace( $one_before."'\"".$one_after,
+ $one_before."’”".$one_after,
+ $str);
+ }
+
+ $start = $start+$current+2;
+ }
+
+ // Are there quotes within a word, as in: ("something")
+ if (preg_match_all("/(.)\"(\S+?)\"(.)/", $str, $matches))
+ {
+ for ($i=0, $s=sizeof($matches['0']); $i < $s; ++$i)
+ {
+ if ( ! in_array($matches['1'][$i], $space) && ! in_array($matches['3'][$i], $space))
+ {
+ $str = str_replace( $matches['0'][$i],
+ $matches['1'][$i]."“".$matches['2'][$i]."”".$matches['3'][$i],
+ $str);
+ }
+ }
+ }
+
+ if (preg_match_all("/(.)\'(\S+?)\'(.)/", $str, $matches))
+ {
+ for ($i=0, $s=sizeof($matches['0']); $i < $s; ++$i)
+ {
+ if ( ! in_array($matches['1'][$i], $space) && ! in_array($matches['3'][$i], $space))
+ {
+ $str = str_replace( $matches['0'][$i],
+ $matches['1'][$i]."‘".$matches['2'][$i]."’".$matches['3'][$i],
+ $str);
+ }
+ }
+ }
+
+ // How about one apostrophe, as in Rick's
+ $start = 0;
+
+ while(TRUE)
+ {
+ $current = strpos(substr($str, $start), "'");
+
+ if ($current === FALSE) break;
+
+ $one_before = substr($str, $start+$current-1, 1);
+ $one_after = substr($str, $start+$current+1, 1);
+
+ if ( ! in_array($one_before, $space) && ! in_array($one_after, $space))
+ {
+ $str = str_replace( $one_before."'".$one_after,
+ $one_before."’".$one_after,
+ $str);
+ }
+
+ $start = $start+$current+2;
+ }
+
+ // Em-dashes
+ $start = 0;
+ while(TRUE)
+ {
+ $current = strpos(substr($str, $start), "--");
+
+ if ($current === FALSE) break;
+
+ $one_before = substr($str, $start+$current-1, 1);
+ $one_after = substr($str, $start+$current+2, 1);
+ $two_before = substr($str, $start+$current-2, 1);
+ $two_after = substr($str, $start+$current+3, 1);
+
+ if (( ! in_array($one_before, $space) && ! in_array($one_after, $space))
+ OR
+ ( ! in_array($two_before, $space) && ! in_array($two_after, $space) && $one_before == ' ' && $one_after == ' ')
+ )
+ {
+ $str = str_replace( $two_before.$one_before."--".$one_after.$two_after,
+ $two_before.trim($one_before)."—".trim($one_after).$two_after,
+ $str);
+ }
+
+ $start = $start+$current+2;
+ }
+
+ // Ellipsis
+ $str = preg_replace("#(\w)\.\.\.(\s|
", $num);
+}
+
+// ------------------------------------------------------------------------
+
+/**
+ * Generates non-breaking space entities based on number supplied
+ *
+ * @access public
+ * @param integer
+ * @return string
+ */
+function nbs($num = 1)
+{
+ return str_repeat(" ", $num);
+}
+
+
+
+?>
\ No newline at end of file
diff --git a/system/helpers/index.html b/system/helpers/index.html
new file mode 100644
index 000000000..5a1f5d6ae
--- /dev/null
+++ b/system/helpers/index.html
@@ -0,0 +1,15 @@
+
+
+
+
+.+?//tempstart\
#is", "
\\n", $str);
+ $str = preg_replace("#\
.+?//tempstart\
#is", "\n", $str);
+ $str = preg_replace("#//tempend.+#is", "\n
", $str);
+
+ // Replace our markers back to PHP tags.
+ $str = str_replace(array('phptagopen', 'phptagclose', 'backslashtmp'), array('<?php', '?>', '\\'), $str); //
+
+ return $str;
+}
+
+// ------------------------------------------------------------------------
+
+/**
+ * Phrase Highlighter
+ *
+ * Highlights a phrase within a text string
+ *
+ * @access public
+ * @param string the text string
+ * @param string the phrase you'd like to highlight
+ * @param string the openging tag to precede the phrase with
+ * @param string the closing tag to end the phrase with
+ * @return string
+ */
+function highlight_phrase($str, $phrase, $tag_open = '', $tag_close = '')
+{
+ if ($str == '')
+ {
+ return '';
+ }
+
+ if ($phrase != '')
+ {
+ return preg_replace('/('.preg_quote($phrase).')/i', $tag_open."\\1".$tag_close, $str);
+ }
+
+ return $str;
+}
+
+// ------------------------------------------------------------------------
+
+/**
+ * Word Wrap
+ *
+ * Wraps text at the specified character. Maintains the integrity of words.
+ *
+ * @access public
+ * @param string the text string
+ * @param integer the number of characters to wrap at
+ * @return string
+ */
+function word_wrap($str, $chars = '76')
+{
+ if ( ! ctype_digit($chars))
+ $chars = 76;
+
+ $str = preg_replace("/(\r\n|\r|\n)/", "\n", $str);
+ $lines = split("\n", $str);
+
+ $output = "";
+ while (list(, $thisline) = each($lines))
+ {
+ if (strlen($thisline) > $chars)
+ {
+ $line = "";
+ $words = split(" ", $thisline);
+ while(list(, $thisword) = each($words))
+ {
+ while((strlen($thisword)) > $chars)
+ {
+ $cur_pos = 0;
+ for($i=0; $i < $chars - 1; $i++)
+ {
+ $output .= $thisword[$i];
+ $cur_pos++;
+ }
+
+ $output .= "\n";
+ $thisword = substr($thisword, $cur_pos, (strlen($thisword) - $cur_pos));
+ }
+
+ if ((strlen($line) + strlen($thisword)) > $chars)
+ {
+ $output .= $line."\n";
+ $line = $thisword." ";
+ }
+ else
+ {
+ $line .= $thisword." ";
+ }
+ }
+
+ $output .= $line."\n";
+ }
+ else
+ {
+ $output .= $thisline."\n";
+ }
+ }
+
+ return $output;
+}
+
+?>
\ No newline at end of file
diff --git a/system/helpers/typography_helper.php b/system/helpers/typography_helper.php
new file mode 100644
index 000000000..6a5495239
--- /dev/null
+++ b/system/helpers/typography_helper.php
@@ -0,0 +1,490 @@
+",$str);
+ $ct = count($ex);
+
+ $newstr = "";
+ for ($i = 0; $i < $ct; $i++)
+ {
+ if (($i % 2) == 0)
+ {
+ $newstr .= nl2br($ex[$i]);
+ }
+ else
+ {
+ $newstr .= $ex[$i];
+ }
+
+ if ($ct - 1 != $i)
+ $newstr .= "pre>";
+ }
+
+ return $newstr;
+}
+
+// ------------------------------------------------------------------------
+
+/**
+ * Auto Typography Wrapper Function
+ *
+ *
+ * @access public
+ * @parm string
+ * @return string
+ */
+function auto_typography($str)
+{
+ $TYPE = new Auto_typography();
+ return $TYPE->convert($str);
+}
+
+// ------------------------------------------------------------------------
+
+/**
+ * Auto Typography Class
+ *
+ *
+ * @access private
+ * @category Helpers
+ * @author Rick Ellis
+ * @author Paul Burdick
+ * @link http://www.codeigniter.com/user_guide/helpers/
+ */
+class Auto_typography {
+
+ // Block level elements that should not be wrapped inside
tags within them.
+ var $skip_elements = 'pre|ol|ul';
+
+ // Tags we want the parser to completely ignore when splitting the string.
+ var $ignore_elements = 'a|b|i|em|strong|span|img|li';
+
+
+ /**
+ * Main Processing Function
+ *
+ */
+ function convert($str)
+ {
+ if ($str == '')
+ {
+ return '';
+ }
+
+ $str = ' '.$str.' ';
+
+ // Standardize Newlines to make matching easier
+ $str = preg_replace("/(\r\n|\r)/", "\n", $str);
+
+ /*
+ * Reduce line breaks
+ *
+ * If there are more than two consecutive line
+ * breaks we'll compress them down to a maximum
+ * of two since there's no benefit to more.
+ *
+ */
+ $str = preg_replace("/\n\n+/", "\n\n", $str);
+
+ /*
+ * Convert quotes within tags to tempoarary marker
+ *
+ * We don't want quotes converted within
+ * tags so we'll temporarily convert them to
+ * {{{DQ}}} and {{{SQ}}}
+ *
+ */
+ if (preg_match_all("#\<.+?>#si", $str, $matches))
+ {
+ for ($i = 0; $i < count($matches['0']); $i++)
+ {
+ $str = str_replace($matches['0'][$i],
+ str_replace(array("'",'"'), array('{{{SQ}}}', '{{{DQ}}}'), $matches['0'][$i]),
+ $str);
+ }
+ }
+
+ /*
+ * Convert "ignore" tags to tempoarary marker
+ *
+ * The parser splits out the string at every tag
+ * it encounters. Certain inline tags, like image
+ * tags, links, span tags, etc. will be adversely
+ * affected if they are split out so we'll convert
+ * the opening < temporarily to: {{{tag}}}
+ *
+ */
+ $str = preg_replace("#<(/*)(".$this->ignore_elements.")#i", "{{{tag}}}\\1\\2", $str);
+
+ /*
+ * Split the string at every tag
+ *
+ * This creates an array with this prototype:
+ *
+ * [array]
+ * {
+ * [0] = tags and a few other things.
+ *
+ */
+ if (preg_match("#<(/*)(".$this->block_elements.").*?\>#", $chunk, $match))
+ {
+ if (preg_match("#".$this->skip_elements."#", $match['2']))
+ {
+ $process = ($match['1'] == '/') ? TRUE : FALSE;
+ }
+
+ $str .= $chunk;
+ continue;
+ }
+
+ if ($process == FALSE)
+ {
+ $str .= $chunk;
+ continue;
+ }
+
+ // Convert Newlines into
tags
+ $str .= $this->format_newlines($chunk);
+ }
+
+ // Convert Quotes and other characters
+ $str = $this->format_characters($str);
+
+ // We'll swap our temporary markers back and do some clean up.
+ $str = preg_replace('#(
|
|
tags or
+ *
+ */
+ function format_newlines($str)
+ {
+ if ($str == '')
+ {
+ return $str;
+ }
+
+ if (strpos($str, "\n") === FALSE)
+ {
+ return '
'.$str.'
'; + } + + $str = str_replace("\n\n", "\n\n", $str);
+ $str = preg_replace("/([^\n])(\n)([^\n])/", "\\1
\\2\\3", $str);
+
+ return '
'.$str.'
'; + } +} + + +?> \ No newline at end of file diff --git a/system/helpers/url_helper.php b/system/helpers/url_helper.php new file mode 100644 index 000000000..d2d2a5985 --- /dev/null +++ b/system/helpers/url_helper.php @@ -0,0 +1,487 @@ +config->site_url($uri); +} + +// ------------------------------------------------------------------------ + +/** + * Base URL + * + * Returns the "base_url" item from your config file + * + * @access public + * @return string + */ +function base_url() +{ + $obj =& get_instance(); + return $obj->config->item('base_url', 1); +} + +// ------------------------------------------------------------------------ + +/** + * Index page + * + * Returns the "index_page" from your config file + * + * @access public + * @return string + */ +function index_page() +{ + $obj =& get_instance(); + return $obj->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 + */ +function anchor($uri = '', $title = '', $attributes = '') +{ + $site_url = site_url($uri); + + if ($title == '') + { + $title = $site_url; + } + + if ($attributes == '') + { + $attributes = ' title="'.$title.'"'; + } + else + { + if (is_array($attributes)) + { + $attributes = parse_url_attributes($attributes); + } + } + + return ''.$title.''; +} + +// ------------------------------------------------------------------------ + +/** + * Anchor Link - Pop-up version + * + * Creates an anchor based on the local URL. The link + * opens a new window based on the attributes specified. + * + * @access public + * @param string the URL + * @param string the link title + * @param mixed any attributes + * @return string + */ +function anchor_popup($uri = '', $title = '', $attributes = FALSE) +{ + $site_url = site_url($uri); + + if ($title == '') + { + $title = $site_url; + } + + if ($attributes === FALSE) + { + return "".$title.""; + } + + if ( ! is_array($attributes)) + { + $attributes = array(); + } + + foreach (array('width' => '800', 'height' => '600', 'scrollbars' => 'yes', 'status' => 'yes', 'resizable' => 'yes', 'screenx' => '0', 'screeny' => '0', ) as $key => $val) + { + $atts[$key] = ( ! isset($attributes[$key])) ? $val : $attributes[$key]; + } + + return "".$title.""; +} + +// ------------------------------------------------------------------------ + +/** + * Mailto Link + * + * @access public + * @param string the email address + * @param string the link title + * @param mixed any attributes + * @return string + */ +function mailto($email, $title = '', $attributes = '') +{ + if ($title == "") + { + $title = $email; + } + + if (is_array($attributes)) + { + $attributes = parse_url_attributes($attributes); + } + + return ''.$title.''; +} + +// ------------------------------------------------------------------------ + +/** + * Encoded Mailto Link + * + * Create a spam-protected mailto link written in Javascript + * + * @access public + * @param string the email address + * @param string the link title + * @param mixed any attributes + * @return string + */ +function safe_mailto($email, $title = '', $attributes = '') +{ + if ($title == "") + { + $title = $email; + } + + for ($i = 0; $i < 16; $i++) + { + $x[] = substr(' $val) + { + $x[] = ' '.$key.'="'; + for ($i = 0; $i < strlen($val); $i++) + { + $x[] = "|".ord(substr($val, $i, 1)); + } + $x[] = '"'; + } + } + else + { + for ($i = 0; $i < strlen($attributes); $i++) + { + $x[] = substr($attributes, $i, 1); + } + } + } + + $x[] = '>'; + + $temp = array(); + for ($i = 0; $i < strlen($title); $i++) + { + $ordinal = ord($title[$i]); + + if ($ordinal < 128) + { + $x[] = "|".$ordinal; + } + else + { + if (count($temp) == 0) + { + $count = ($ordinal < 224) ? 2 : 3; + } + + $temp[] = $ordinal; + if (count($temp) == $count) + { + $number = ($count == 3) ? (($temp['0'] % 16) * 4096) + (($temp['1'] % 64) * 64) + ($temp['2'] % 64) : (($temp['0'] % 32) * 64) + ($temp['1'] % 64); + $x[] = "|".$number; + $count = 1; + $temp = array(); + } + } + } + + $x[] = '<'; $x[] = '/'; $x[] = 'a'; $x[] = '>'; + + $x = array_reverse($x); + ob_start(); + +?>http'. + $matches['4'][$i].'://'. + $matches['5'][$i]. + $matches['6'][$i].''. + $period, $str); + } + } + } + + if ($type != 'url') + { + if (preg_match_all("/([a-zA-Z0-9_\.\-]+)@([a-zA-Z0-9\-]+)\.([a-zA-Z0-9\-\.]*)/i", $str, $matches)) + { + for ($i = 0; $i < sizeof($matches['0']); $i++) + { + $period = ''; + if (preg_match("|\.$|", $matches['3'][$i])) + { + $period = '.'; + $matches['3'][$i] = substr($matches['3'][$i], 0, -1); + } + + $str = str_replace($matches['0'][$i], safe_mailto($matches['1'][$i].'@'.$matches['2'][$i].'.'.$matches['3'][$i]).$period, $str); + } + + } + } + return $str; +} + +// ------------------------------------------------------------------------ + +/** + * Prep URL + * + * Simply adds the http:// part if missing + * + * @access public + * @param string the URL + * @return string + */ +function prep_url($str = '') +{ + if ($str == 'http://' OR $str == '') + { + return ''; + } + + if (substr($str, 0, 7) != 'http://' && substr($str, 0, 8) != 'https://') + { + $str = 'http://'.$str; + } + + return $str; +} + +// ------------------------------------------------------------------------ + +/** + * Create URL Title + * + * Takes a "title" string as input and creates a + * human-friendly URL string with either a dash + * or an underscore as the word separator. + * + * @access public + * @param string the string + * @param string the separator: dash, or underscore + * @return string + */ +function url_title($str, $separator = 'dash') +{ + if ($separator == 'dash') + { + $search = '_'; + $replace = '-'; + } + else + { + $search = '-'; + $replace = '_'; + } + + $trans = array( + $search => $replace, + "\s+" => $replace, + "[^a-z0-9".$replace."]" => '', + $replace."+" => $replace, + $replace."$" => '', + "^".$replace => '' + ); + + $str = strip_tags(strtolower($str)); + + foreach ($trans as $key => $val) + { + $str = preg_replace("#".$key."#", $val, $str); + } + + return trim(stripslashes($str)); +} + +// ------------------------------------------------------------------------ + +/** + * Header Redirect + * + * Header redirect in two flavors + * + * @access public + * @param string the URL + * @param string the method: location or redirect + * @return string + */ +function redirect($uri = '', $method = 'location') +{ + switch($method) + { + case 'refresh' : header("Refresh:0;url=".site_url($uri)); + break; + default : header("location:".site_url($uri)); + break; + } + exit; +} + +// ------------------------------------------------------------------------ + +/** + * Parse out the attributes + * + * Some of the functions use this + * + * @access private + * @param array + * @param bool + * @return string + */ +function parse_url_attributes($attributes, $javascript = FALSE) +{ + $att = ''; + foreach ($attributes as $key => $val) + { + if ($javascript == TRUE) + { + $att .= $key . '=' . $val . ','; + } + else + { + $att .= ' ' . $key . '="' . $val . '"'; + } + } + + if ($javascript == TRUE) + { + $att = substr($att, 0, -1); + } + + return $att; +} + +?> \ No newline at end of file diff --git a/system/helpers/xml_helper.php b/system/helpers/xml_helper.php new file mode 100644 index 000000000..ee3fc289b --- /dev/null +++ b/system/helpers/xml_helper.php @@ -0,0 +1,55 @@ +","\"", "'", "-"), + array("&", "<", ">", """, "'", "-"), + $str); + + $str = preg_replace("/$temp(\d+);/","\\1;",$str); + $str = preg_replace("/$temp(\w+);/","&\\1;", $str); + + return $str; +} + + +?> \ No newline at end of file -- cgit v1.2.3-24-g4f1b