PageRenderTime 49ms CodeModel.GetById 24ms RepoModel.GetById 1ms app.codeStats 0ms

/grape/theme/side/pages/getResult.php

https://github.com/amir-noori/grape
PHP | 127 lines | 115 code | 12 blank | 0 comment | 15 complexity | 0e731313535cbaf08cff51c9bc6c1331 MD5 | raw file
  1. <?php
  2. session_start();
  3. require_once(dirname(__FILE__) . '/../tag/tag.php');
  4. require_once(dirname(__FILE__) . '/../../../src/db/DB.class.php');
  5. $dir = $_SERVER['HTTP_REFERER'];
  6. $path = array();
  7. $substr = $dir;
  8. $slashCount = substr_count($dir , '/');
  9. for($i = 0 ; $i < $slashCount + 1 ; $i++)
  10. {
  11. if($i == $slashCount)
  12. array_push($path , $dir);
  13. $substr = substr($dir , 0 , strpos($dir , '/'));
  14. $dir = substr_replace($dir , '' , 0 , strpos($dir , '/') + 1);
  15. if($i != $slashCount)
  16. array_push($path , $substr);
  17. }
  18. switch($_POST['page'])
  19. {
  20. case('about'):
  21. {
  22. $query = 'SELECT * FROM `Site` WHERE `url`="' . $path[4] . '"';
  23. $site = DB::executeQuery($query , true);
  24. ob_start(); // begin collecting output
  25. include dirname(__FILE__) . '/about.tpl';
  26. $data = ob_get_clean();
  27. $dom = new DOMDocument('1.0', 'utf-8');
  28. $dom->loadXML($data);
  29. setValue($dom , 'summary' , $site[0]['summary']);
  30. echo htmlspecialchars_decode($dom->saveHTML());
  31. break;
  32. }
  33. case('contact'):
  34. {
  35. ob_start(); // begin collecting output
  36. include dirname(__FILE__) . '/contact.tpl';
  37. $data = ob_get_clean();
  38. echo $data;
  39. break;
  40. }
  41. case('cat'):
  42. {
  43. $pages = DB::executeQuery('SELECT p.* FROM `Page` p INNER JOIN `Category_Page` c ON p.id = c.pageID WHERE c.categoryID="' . $_POST['catID'] . '"' , true);
  44. if(count($pages) > 0)
  45. {
  46. foreach($pages as $page)
  47. {
  48. if(strpos($_SERVER['HTTP_REFERER'] , '?') != null)
  49. $path4 = substr($path[4] , 0 , strpos($path[4] , '?'));
  50. else
  51. $path4 = $path[4];
  52. echo '<div class="articleBox" style="border:solid 2px;">';
  53. echo '<h3><a target="_blank" href="' . $GLOBALS['config']['siteURL'] . 'site/' . $path4 . '/page/' . $page['id'] . '">' . $page['title'] . '</a></h3>';
  54. echo '<p>' . $page['summary'] . '</p>';
  55. echo '<span style="font-family:Arial;font-size:17px;">Date Created: ' . $page['created'] . '</span>';
  56. echo '</div><br />';
  57. }
  58. }
  59. else
  60. {
  61. echo '<p style="margin-left:150px;">This Category does not have any pages yet.</p>';
  62. }
  63. if(isset($_SESSION[$path[4] . '_isAdmin']) && ($_SESSION[$path[4] . '_isAdmin'] == true))
  64. {
  65. echo '<a style="margin-left:20px;" id="addCategoryLink" class="editComment" onclick="showAddCategory()">Add Page</a>';
  66. echo '<div style="display:none;" id="addCategoryDiv">';
  67. echo '<table><tbody>';
  68. echo '<tr><td class="generalText">Title: </td><td><input class="generalInput" type="text" /></td></tr>';
  69. echo '<tr><td class="generalText">Summary: </td><td><textarea class="generalInput" cols="60" rows="10"></textarea></td></tr>';
  70. echo '<tr><td><a id="addCategoryLink" class="editComment" onclick="saveNewCategory()">Save</a></td><td><a id="addCategoryLink" class="editComment" onclick="cancelNewCategory()">Cancel</a></td></tr>';
  71. echo '</tbody></table>';
  72. echo '</div>';
  73. }
  74. break;
  75. }
  76. case('forum'):
  77. {
  78. if(strpos($_SERVER['HTTP_REFERER'] , '?') != null)
  79. $path4 = substr($path[4] , 0 , strpos($path[4] , '?'));
  80. else
  81. $path4 = $path[4];
  82. $args = array('siteURL' => $path4 , 'showForums' => true);
  83. require_once(dirname(__FILE__) . '/../../../modules/forum/main.php');
  84. ob_start(); // begin collecting output
  85. include dirname(__FILE__) . '/forum.tpl';
  86. $data = ob_get_clean();
  87. $dom = new DOMDocument('1.0', 'utf-8');
  88. $dom->loadXML($data);
  89. forum($dom , $args);
  90. echo htmlspecialchars_decode($dom->saveHTML());
  91. break;
  92. }
  93. case('forumData'):
  94. {
  95. if(strpos($_SERVER['HTTP_REFERER'] , '?') != null)
  96. $path4 = substr($path[4] , 0 , strpos($path[4] , '?'));
  97. else
  98. $path4 = $path[4];
  99. $args = array('siteURL' => $path4 , 'forumID' => $_POST['forumID'] , 'forumData' => true);
  100. require_once(dirname(__FILE__) . '/../../../modules/forum/main.php');
  101. ob_start(); // begin collecting output
  102. include dirname(__FILE__) . '/forumData.tpl';
  103. $data = ob_get_clean();
  104. $dom = new DOMDocument('1.0', 'utf-8');
  105. $dom->loadXML($data);
  106. forum($dom , $args);
  107. echo htmlspecialchars_decode($dom->saveHTML());
  108. break;
  109. }
  110. default:
  111. {
  112. echo 'Welcome';
  113. break;
  114. }
  115. }