last update: Mon, 05 Sep 2011 17:17:04 +0000
  1. <?
  2. require_once('add_smarty.php');
  3. require_once("session.php");
  4. require_once('mysql_cfg.php');
  5. require_once('code_css.php');
  6. require_once('filterhtml.php');
  7. //main template
  8. $smarty->assign('main_template', 'html.tpl');
  9. //title
  10. $smarty->assign('title', 'Html-peqpaste');
  11. //set default = nothing
  12. $smarty->assign('html_code', false);
  13. $smarty->assign('id', false);
  14. function escape_string($s)
  15. {
  16. //$result = $s;
  17. //$result = str_replace('\\', '\\\\', $result);
  18. //$result = str_replace('"', '###anfuehrunszeichen###', $result);
  19. //return $result;
  20. return mysql_real_escape_string($s);
  21. }
  22. function unescape_string($s)
  23. {
  24. $result = $s;
  25. $result = str_replace('\"', '"', $result);
  26. $result = str_replace('\\\'', "'", $result);
  27. return $result;
  28. }
  29. if (isset($_POST['html']))
  30. {
  31. $query = 'SELECT `id` as x FROM `mapping_nopaste_html` ORDER BY `id` DESC;';
  32. $count = mysql_fetch_array(mysql_query($query, $mysqlconnection));
  33. $id = $count['x'] + 1;
  34. //$html = "<pre>".htmlspecialchars($_POST['html'])."</pre>";
  35. $query = 'INSERT INTO
  36. `mapping_nopaste_html` (`id`, `html`, `datum` )
  37. VALUES ("'.$id.'", "'.escape_string($_POST['html']).'", NOW())
  38. ';
  39. $temp = mysql_query($query, $mysqlconnection);
  40. echo mysql_error();
  41. if (mysql_error())
  42. {
  43. echo "<pre>$query</pre><br />";
  44. }
  45. $smarty->assign('id', $id);
  46. $smarty->assign('html_code', FilterHTML(unescape_string($_POST['html'])));
  47. }
  48. elseif (isset($_GET['id']))
  49. {
  50. $id = $_GET['id'];
  51. $smarty->assign('title', 'Html-peqpaste #'.$id);
  52. $query = 'SELECT * FROM `mapping_nopaste_html` WHERE `id` LIKE "'.$id.'";';
  53. //echo "$query<br>";
  54. $data = mysql_query($query, $mysqlconnection);
  55. echo mysql_error();
  56. $row = mysql_fetch_array($data);
  57. if (isset($_GET['interface']))
  58. {
  59. $smarty->assign('id', $id);
  60. $smarty->assign('html_code', FilterHTML(unescape_string($row['html'])));
  61. }
  62. else
  63. {
  64. echo unescape_string(FilterHTML($row['html']));
  65. unset($smarty);
  66. }
  67. }
  68. if (isset($smarty))
  69. {
  70. $smarty->assign("compileTime",sprintf("%.4f",(microtime(true) - $sript_start_time))); $smarty->display('site.tpl');
  71. }
  72. ?>

goto line:
Compare with:
text copy window edit this code post new code