last update: Mon, 05 Sep 2011 17:16:55 +0000
  1. <?
  2. /*
  3. CREATE TABLE `languages` (
  4. `id` INT NOT NULL ,
  5. `name` VARCHAR( 200 ) NOT NULL ,
  6. `owner` INT DEFAULT '0' NOT NULL ,
  7. `data` LONGTEXT NOT NULL
  8. ) TYPE = innodb;
  9. CREATE TABLE `styles` (
  10. `id` INT NOT NULL ,
  11. `name` VARCHAR( 200 ) NOT NULL ,
  12. `owner` INT NOT NULL ,
  13. `data` LONGTEXT NOT NULL ,
  14. `hidden` BOOL DEFAULT '1' NOT NULL ,
  15. `public` BOOL DEFAULT '0' NOT NULL ,
  16. PRIMARY KEY ( `id` )
  17. ) TYPE = innodb;
  18. */
  19. require_once('common.php');
  20. require_once('code_css.php');
  21. require_once('codetitles.php');
  22. //main template
  23. $smarty->assign('main_template', 'drawgraph.tpl');
  24. //title
  25. $pageTitle = "Online Graph Tool";
  26. //set default = nothing
  27. $smarty->assign('text', false);
  28. $smarty->assign('id', false);
  29. $additional_headers = array();
  30. function escape_string($s)
  31. {
  32. return str_replace('"', '\"', $s);
  33. }
  34. function unescape_string($s)
  35. {
  36. //return $s;
  37. return stripslashes($s);
  38. //return str_replace('\"', '"', $s);
  39. }
  40. if (isset($_POST['text']))
  41. {
  42. $text = unescape_string($_POST['text']);
  43. $engine = $_POST['engine'];
  44. $rankdir = $_POST['rankdir'];
  45. if (!in_array($engine, array("dot", "neato", "fdp", "twopi", "circo"))) {
  46. die('Hack Versuch? Diese Anfrage wurde geloggt.');
  47. }
  48. if (!in_array($rankdir, array("LR", "RL", "TB", "BT"))) {
  49. die('Hack Versuch? Diese Anfrage wurde geloggt.');
  50. }
  51. //todo
  52. // ranksep=0.5, nodesep=0.1,
  53. $options = '
  54. graph [overlap=false, start=1, splines=true]
  55. edge [len=1.5, weight=2.0]';
  56. if ($engine == "dot") {
  57. $options.= 'rankdir = '.$rankdir.';';
  58. }
  59. $text = mysql_real_escape_string($text);
  60. $options = mysql_real_escape_string($options);
  61. $engine = mysql_real_escape_string($engine);
  62. $query = 'INSERT INTO `graph` (
  63. `time` ,
  64. `userid` ,
  65. `text` ,
  66. `options`,
  67. `engine`
  68. )
  69. VALUES (NOW(), "'.session_get_userid_secure().'", "'.$text.'", "'.$options.'", "'.$engine.'" )';
  70. $temp = mysql_query($query, $mysqlconnection);
  71. echo mysql_error();
  72. $id = mysql_insert_id();
  73. /*
  74. $smarty->assign('output', $output);
  75. $smarty->assign('jass_code', strip_markup($code));
  76. */
  77. $additional_headers[] ='<script>document.location="drawgraph.php?id='.$id.'";</script>';
  78. $smarty->assign('id', $id);
  79. }
  80. elseif (isset($_GET['id']))
  81. {
  82. $id = intval($_GET['id']);
  83. ;
  84. $query = 'SELECT * FROM `graph` WHERE `id` LIKE "'.$id.'";';
  85. $data = mysql_query($query, $mysqlconnection);
  86. echo mysql_error();
  87. $row = mysql_fetch_array($data);
  88. $text = $row['text'];
  89. $smarty->assign('id', $id);
  90. $smarty->assign('text', $text);
  91. }
  92. else
  93. {
  94. }
  95. $additional_headers[] = '<script language="Javascript" type="text/javascript" src="./jquery/jquery.js"></script>';
  96. $additional_headers[] = '<script language="Javascript" type="text/javascript" src="./jquery/jquery.textarea.js"></script>';
  97. $additional_headers[] =
  98. '<script language="Javascript" type="text/javascript">
  99. jQuery(document).ready(function () {
  100. $("textarea").tabby();
  101. });
  102. </script>';
  103. finish($smarty, 'drawgraph.tpl', $additional_headers);
  104. ?>

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