A Ninja Funerals


/ Published in: PHP
Save to your folder(s)



Copy this code and paste it in your HTML
  1. preg_match_all("/\{\{IF ((?:[^\\?]|\\.)*)\?((?:[^\\:]|\\.)*):(.*)\}\}[^<\/]/", $template, $m, PREG_SET_ORDER);
  2. if (count($m)) {
  3. foreach ($m as $o) {
  4. if (preg_match("/(.*)\s+(==|!=)\s+(.*)/", $o[1], $x)) {
  5. if (preg_match("/^\"(.*)\"/", $x[1], $cx)) $e1 = $cx[1];
  6. else $e1 = is_numeric($x[1])?$x[1]:$data[$x[1]];
  7. if (preg_match("/^\"(.*)\"/", $x[3], $cx)) $e2 = $cx[1];
  8. else $e2 = is_numeric($x[3])?$x[3]:$data[$x[3]];
  9. if (preg_match("/^\"(.*)\"/", $o[2], $ox)) $er[0] = $ox[1];
  10. else $er[0] = addslashes(htmlspecialchars($data[$o[2]]));
  11. if (preg_match("/^\"(.*)\"/", $o[3], $ox)) $er[1] = $ox[1];
  12. else $er[1] = addslashes(htmlspecialchars($data[$o[3]]));
  13. $eval = "\$od = (\"$e1\" $x[2] \"$e2\")?\"$er[0]\":\"$er[1]\";";
  14. eval($eval);
  15. } else {
  16. $od = $data[$o[1]]?$o[2]:$o[3];
  17. if (preg_match("/^\"(.*)\"/", $od, $x)) $od = $x[1];
  18. else $od = $data[$od];
  19. }
  20. $template = str_replace($o[0], $od, $template);
  21. }
  22. }

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.