last update: Mon, 05 Sep 2011 17:21:15 +0000
  1. <?
  2. require_once("common.php");
  3. function escape_string($s)
  4. {
  5. return str_replace('"', '\"', $s);
  6. }
  7. function unescape_string($s)
  8. {
  9. return str_replace('\"', '"', $s);
  10. }
  11. function strip_markup($s)
  12. {
  13. return str_replace('##', '', str_replace('', '', $s));
  14. }
  15. function get_firtst_line ($_text)
  16. {
  17. $text = nl2br(trim($_text));
  18. $pos = strpos($text,"<br />");
  19. if ($pos)
  20. {
  21. return strip_markup(substr($text,0, $pos));
  22. }
  23. else
  24. {
  25. return strip_markup($text);
  26. }
  27. }
  28. $additional_headers = array();
  29. if (isset($_GET['oldparser']))
  30. {
  31. require_once("GuiParser2.php");
  32. }
  33. else
  34. {
  35. require_once("GuiParser3.php");
  36. }
  37. //main template
  38. $smarty->assign('main_template', 'gui.tpl');
  39. //Title
  40. $pageTitle = 'GUI Trigger';
  41. //set default = nothing
  42. $smarty->assign('html_code', false);
  43. $smarty->assign('id', false);
  44. $game = "wc3";
  45. if ($_GET['game'] == "sc2") {
  46. $game = "sc2";
  47. }
  48. if (isset($_POST['trigger']))
  49. {
  50. //neuen Trigger Posten (Verarbeitung)
  51. $query = 'SELECT `id` as x FROM `mapping_nopaste_gui` ORDER BY `id` DESC;';
  52. $count = mysql_fetch_array(mysql_query($query, $mysqlconnection));
  53. $id = $count['x'] + 1;
  54. $gui_code = unescape_string($_POST['trigger']);
  55. $game = "wc3";
  56. if ($_POST['game'] == "sc2") {
  57. $game = "sc2";
  58. }
  59. //check if code contains url:
  60. if (strpos($gui_code, "http://") !== false) {
  61. if (session_get_userid_secure() <= 0) {
  62. die('Um Spam zu vermeiden dürfen Posts, die Internet-Addressen enthalten nur von angemeldeten Benutzerstellt werden.');
  63. }
  64. }
  65. //Gui-Parser Objekt erstellen
  66. $gui_parser = new GuiParser;
  67. //Aufruf
  68. // 1. Parameter = Code der umgewandelt wird
  69. //2. Parameter = Pfad zu den Bildern
  70. //$html_code = $gui_parser->convert_gui($gui_code, "GuiParserPics/" );
  71. //$html_code = $gui_parser->ParseGui($gui_code, array(), true, "html");
  72. $html_code = $gui_parser->ParseGui($gui_code, array(), false, "html");
  73. $smarty->assign('html_code', $html_code);
  74. $smarty->assign('id', $id);
  75. $query = 'INSERT INTO
  76. `mapping_nopaste_gui` (`id`, `gui_code`, `datum`, `userid`, `game`)
  77. VALUES ("'.$id.'", "'.escape_string($gui_code).'", NOW(), "'.session_get_userid_secure().'", "'.$game.'")
  78. ';
  79. $temp = mysql_query($query, $mysqlconnection);
  80. echo mysql_error();
  81. $additional_headers[] ='<script>document.location="gui.php?id='.$id.'";</script>';
  82. }
  83. elseif (isset($_GET['id']))
  84. {
  85. //Trigger anzeigen
  86. $id = intval($_GET['id']);
  87. $query = 'SELECT * FROM `mapping_nopaste_gui` WHERE `id` LIKE "'.$id.'";';
  88. $data = mysql_query($query, $mysqlconnection);
  89. echo mysql_error();
  90. $row = mysql_fetch_array($data);
  91. $html_code = "";
  92. if (isset ($_GET['bb']))
  93. {
  94. //Gui-Parser Objekt erstellen
  95. $gui_parser = new GuiParser;
  96. $html_code = $gui_parser->ParseGui($row['gui_code'], array(), false, "bb");
  97. }
  98. elseif (isset ($_GET['text']))
  99. {
  100. $html_code = "<pre>{$row['gui_code']}</pre>";
  101. }
  102. else
  103. {
  104. if ($row['game'] == "sc2" ) {
  105. $code = nl2br(htmlspecialchars($row['gui_code']));
  106. $html_code = '<pre class="GuiCode">'.$code.'</pre>
  107. <script type="text/javascript" src="./js/jquery-1.3.2.min.js"></script>
  108. <script type="text/javascript" src="./js/GuiParser.js"></script>';
  109. } else { // wc3
  110. $gui_parser = new GuiParser;
  111. $html_code = $gui_parser->ParseGui($row['gui_code'], array(), false, "html");
  112. }
  113. }
  114. $pageTitle = 'GUI Trigger #'.$id.' '.get_firtst_line($row['gui_code']);
  115. $smarty->assign('html_code', $html_code);
  116. $smarty->assign('id', $id);
  117. }
  118. $smarty->assign('game', htmlspecialchars($game));
  119. finish($smarty, "gui.tpl", $additional_headers);
  120. ?>

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