Advertisement
arijulianto

Content Parser

Jun 10th, 2014
318
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 3.45 KB | None | 0 0
  1. <?php
  2. if (!defined('BASEPATH')){
  3.     exit('No direct script access allowed');
  4. }
  5.  
  6. // ------------------------------------------------------------------------
  7.  
  8. /**
  9.  * mencetak ke layar dan mengubah format URL + emo
  10.  *
  11.  * @access  public
  12.  * @param   string
  13.  * @param   number (1 or 0)
  14.  * @return  echo string
  15.  */
  16. if (!function_exists('__e')){
  17. function __e($input,$compress=1){
  18.     $cdnURL = "http://".domainCDN;
  19.     // replace key URL to URL
  20.     $output = str_replace("http://imgURL/","$cdnURL/images/", $input); // IMG for CDN
  21.     $output = str_replace("http://emoURL/","$cdnURL/smiles/", $output); // EMOTICON
  22.     $output = str_replace("http://photoURL/","$cdnURL/photos/", $output); // PHOTO
  23.     $output = str_replace("http://fileURL/","$cdnURL/file/get/", $output); // file download
  24.     $output = str_replace("http://avaURL/","$cdnURL/ava/", $output); // avatar (profile photo)
  25.     $output = str_replace("http://demoURL/","http://".domainDEMO.'/', $output); // demo
  26.     // replace key domain to domain name
  27.     $output = str_replace("domainWWW",domainWWW, $output);
  28.     $output = str_replace("domainBLOG",domainBLOG, $output);
  29.     $output = str_replace("domainFACEBOOK",domainFACEBOOK, $output);
  30.     $output = str_replace("domainPERSONALWEB",domainPERSONALWEB, $output);
  31.     $output = str_replace("domainCDN",domainCDN, $output);
  32.     // replace smile
  33.     $emoURL = "$cdnURL/smiles";
  34.     $output = str_replace("[^_^]"," <img src=\"$emoURL/fb_squint.gif\" title=\"^_^\" alt=\"^_^\" height=14 />", $output);
  35.     $output = str_replace("[:)]"," <img src=\"$emoURL/smile.gif\" title=\":)\" alt=\":)\" height=14 />", $output);
  36.     $output = str_replace("[;)]"," <img src=\"$emoURL/wink.gif\" title=\";)\" alt=\";)\" height=14 />", $output);
  37.     $output = str_replace("[:(]"," <img src=\"$emoURL/sad.gif\" title=\":(\" alt=\":(\" height=14 />", $output);
  38.     $output = str_replace(array("[:D]","[:d]")," <img src=\"$emoURL/grin.gif\" title=\":D\" alt=\":D\" height=14 />", $output);
  39.     $output = str_replace(array("[:P]","[:p]")," <img src=\"$emoURL/tongue.gif\" title=\":p\" alt=\":p\" height=14 />", $output);
  40.     $output = str_replace(array("[O.o]","[o.O]")," <img src=\"$emoURL/fb_confused.gif\" title=\"o.O\" alt=\"o.O\" height=14 />", $output);
  41.     $output = str_replace("[<3]"," <img src=\"$emoURL/loveface.gif\" title=\"<3\" alt=\"<3\" height=14 />", $output);
  42.     $output = str_replace("[:'(]"," <img src=\"$emoURL/cry.gif\" title=\":'(\" alt=\":'(\" height=14 />", $output);
  43.     $output = str_replace("[8)]"," <img src=\"$emoURL/cool.gif\" title=\"8)\" alt=\"8)\" height=14 />", $output);
  44.     $output = str_replace(array("[:o]","[:O]")," <img src=\"$emoURL/shock.gif\" title=\":O\" alt=\":O\" height=14 />", $output);
  45.     $output = str_replace("[:*]"," <img src=\"$emoURL/kissing.gif\" title=\":*\" alt=\":*\" height=14 />", $output);
  46.     $output = str_replace("[LOL]"," <img src=\"$emoURL/LOL.gif\" title=\"LOL\" alt=\"LOL\" height=14 />", $output);
  47.     $output = str_replace("[WOW]"," <img src=\"h$emoURL/wow.gif\" title=\"WOW\" alt=\"WOW\" height=14 />", $output);
  48.     $output = str_replace("[hehe]"," <img src=\"$emoURL/hehe.gif\" title=\"hehe\" alt=\"hehe\" height=14 />", $output);
  49.     if($compress==1){
  50.             $output = str_replace(array("\r\n\r\n","\r\n","\r","\n","\t","\v"),"",$output);
  51.             $output = trim(str_replace("    "," ",$output));
  52.             $output = trim(str_replace("  "," ",$output));
  53.             $output = str_replace(array(">  <","> <"),"><",$output);
  54.     }
  55.     echo $output;
  56. }
  57. }
  58.  
  59.  
  60.  
  61. /* End of file string_parser_helper.php */
  62. /* Location: app/helpers/string_parser_helper.php */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement