Guest User

Untitled

a guest
Jul 20th, 2018
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.56 KB | None | 0 0
  1. <?php
  2.  
  3. include_once '../ennui-cms/config/config.inc.php';
  4. include_once '../ennui-cms/config/database.inc.php';
  5. include_once '../ennui-cms/config/menu.inc.php';
  6. include_once '../ennui-cms/core/class.page.inc.php';
  7.  
  8. $menu = $GLOBALS['menuPages'];
  9.  
  10. if(isset($_POST['page'])) {
  11.  
  12. // Make sure the posted page exists
  13. $p = strtolower($_POST['page']);
  14. if($p=='admin')
  15. {
  16. $class = 'admin';
  17. }
  18.  
  19. else if(isset($p))
  20. {
  21. $class = Utilities::getPageType($menu, $p);
  22. if($class === FALSE)
  23. {
  24. header('Location: /');
  25. exit;
  26. }
  27. }
  28.  
  29. // If not, send the user to the home page
  30. else
  31. {
  32. header("Location: /");
  33. exit;
  34. }
  35.  
  36. include_once '../ennui-cms/inc/class.'.$class.'.inc.php';
  37. $obj = new $class(NULL, array(strtolower($_POST['page'])));
  38.  
  39. /*
  40. * Standard page action handlers
  41. */
  42. $obj->url0 = $p;
  43. $id = (isset($_POST['id'])) ? $_POST['id'] : NULL;
  44. if ( $_POST['action'] == 'showoptions' ) {
  45. echo $obj->displayAdmin($id);
  46. exit;
  47. }
  48. if($_POST['action'] == 'galleryEdit') {
  49. echo $obj->displayGalleryAdmin($id);
  50. exit;
  51. }
  52. if($_POST['action'] == 'galleryOrder') {
  53. $obj->reorderGallery($_POST['image'], $id);
  54. echo $obj->displayPublic($id);
  55. exit;
  56. }
  57. if ( $_POST['action'] == 'write' ) {
  58. $loc = str_replace('-image', '', $obj->url0);
  59.  
  60. if( $obj->write($_POST,$_FILES) ) {
  61. $header = "Location: /$loc/";
  62. } else {
  63. $header = "Location: /{$obj->url0}/error/";
  64. }
  65. }
  66. if ( $_POST['action'] == 'contact_form' ) {
  67. $loc = str_replace('-image', '', $obj->url0);
  68.  
  69. if( $obj->sendMessage($_POST) ) {
  70. $header = "Location: /$loc?send=successful";
  71. } else {
  72. $header = "Location: /$loc?send=error";
  73. }
  74. }
  75. if ( $_POST['action'] == 'reorderEntry' ) {
  76. echo $obj->reorderEntries($_POST['id'], $_POST['pos'], $_POST['direction']);
  77. exit;
  78. }
  79. if ( $_POST['action'] == 'nl_subscribe' ) {
  80. $loc = $obj->url0;
  81.  
  82. if($obj->saveSubscription($_POST)) {
  83. $header = "Location: /$loc/";
  84. } else {
  85. $header = "Location: /$loc/error/";
  86. }
  87. }
  88. if ( $_POST['action'] == 'nl_viewsubs' ) {
  89. echo $obj->displaySubs();
  90. exit;
  91. }
  92. if ( $_POST['action'] == 'nl_preview' ) {
  93. echo $obj->newsletterHTML($_POST['body'], $_POST['subject']);
  94. exit;
  95. }
  96. if ( $_POST['action'] == 'deletepost' ) {
  97. $url = array(0=>$obj->url0,1=>'',2=>'');
  98. if ( $obj->delete($id) ) {
  99. echo $obj->displayPublic($url);
  100. exit;
  101. }
  102. exit("Couldn't delete the post.\n");
  103. }
  104. if ( $_POST['action'] == 'galleryAddCaption' ) {
  105. if ( $obj->addPhotoCaption() ) {
  106. echo $obj->displayGalleryAdmin($_POST['album_id']);
  107. exit;
  108. }
  109. exit("Couldn't update the image caption.\n");
  110. }
  111. if ( $_POST['action'] == 'galleryDeletePhoto' ) {
  112. $img = $_POST['image'];
  113. if ( $obj->deleteImage($img) ) {
  114. echo $obj->displayGalleryAdmin($id);
  115. exit;
  116. }
  117. exit("Couldn't delete the image.\n");
  118. }
  119.  
  120. /*
  121. * AJAX Calls
  122. */
  123. if ( $_POST['action'] == 'swapcontent' ) {
  124. $url = array(0=>$obj->url0,1=>$_POST['title'],2=>'');
  125. echo $obj->ajax_public($url);
  126. exit;
  127. }
  128.  
  129. /*
  130. * Admin class handlers.
  131. */
  132. else if ( $obj->url0 == 'admin' ) {
  133. switch($_POST['action']) {
  134. case 'create':
  135. $check = $obj->createUser($_POST['admin_u'], $_POST['admin_e']);
  136. break;
  137. case 'login':
  138. $check = $obj->login($_POST);
  139. break;
  140. case 'verify':
  141. $check = $obj->verifyUser($_POST);
  142. break;
  143. default:
  144. $check = false;
  145. break;
  146. }
  147. $header = $check === true ? 'Location: ../admin/' : "Location: ../{$obj->url0}/error/";
  148. }
  149. }
  150.  
  151. /*
  152. * Comment handlers.
  153. */
  154. else if ( $_POST['action'] == 'cmnt_post' ) {
  155. require_once '../ennui-cms/inc/class.comments.inc.php';
  156. $cmnt = new comments();
  157. $header = $cmnt->postComment($_POST);
  158. }
  159.  
  160. else if ( $_GET['action'] == 'cmnt_delete' ) {
  161. require_once '../ennui-cms/inc/class.comments.inc.php';
  162. $cmnt = new comments();
  163. $header = $cmnt->deleteComment($_GET['bid'],$_GET['cmntid']);
  164. }
  165.  
  166. /*
  167. * Remove newsletter cookies
  168. */
  169. else if($_GET['action'] == 'nl_cookie')
  170. {
  171. require_once '../ennui-cms/inc/class.newsletter.inc.php';
  172. Newsletter::removeCookies();
  173. $header = "Location: ../" . htmlentities(strip_tags($_GET['page'])) . '/';
  174. }
  175.  
  176. /*
  177. * Log out the user
  178. */
  179. else if ( $_GET['action'] == 'logout' ) {
  180. include '../ennui-cms/inc/class.admin.inc.php';
  181. $admin = new admin();
  182. $check = $admin->logout();
  183. $header = $check === true ? 'Location: ../': 'Location: ../admin/error/';
  184. }
  185.  
  186. header($header);
  187. ?>
Add Comment
Please, Sign In to add comment