PageRenderTime 46ms CodeModel.GetById 19ms RepoModel.GetById 0ms app.codeStats 0ms

/ww_edit/_content/preview.php

https://github.com/justincawthorne/Wicked-Words
PHP | 159 lines | 77 code | 49 blank | 33 comment | 11 complexity | 8920da8bd112911e36078ba5184f2dc0 MD5 | raw file
Possible License(s): LGPL-2.1, GPL-3.0
  1. <?php
  2. session_start();
  3. /* check author session
  4. the author id and session_id are sent via post params to the popup
  5. using the author id we derive the cookie name - then we can check if the
  6. cookie value matches the session id that was sent via the form
  7. */
  8. $author_id = (isset($_POST['current_author_id'])) ? (int)$_POST['current_author_id'] : '' ;
  9. $sess_val = (isset($_POST['current_author_sess'])) ? htmlspecialchars_decode($_POST['current_author_sess']) : '' ;
  10. // exit if params not sent
  11. $params_check = ($author_id.$sess_val);
  12. if(empty($params_check)) {
  13. exit();
  14. }
  15. $cookie_name = (!empty($author_id)) ? 'author'.$author_id : '' ;
  16. $cookie_val = (!empty($cookie_name)) ? $_COOKIE[$cookie_name] : '' ;
  17. // exit if cookie value is empty or session/cookie values don't match
  18. if( (empty($cookie_val)) || ($cookie_val != $sess_val) ) {
  19. exit();
  20. }
  21. /*
  22. if we've gotten this far we're good to go on :)
  23. */
  24. // get root constants
  25. if(!defined('WW_ROOT')) {
  26. include_once('../../ww_config/model_functions.php');
  27. }
  28. // now bring in our functions
  29. include_once(WW_ROOT.'/ww_config/model_functions.php');
  30. include_once(WW_ROOT.'/ww_config/combined_functions.php');
  31. include_once(WW_ROOT.'/ww_config/controller_functions.php');
  32. include_once(WW_ROOT.'/ww_config/view_functions.php');
  33. // get article data
  34. // debug_array($_POST);
  35. $article = stripslashes_deep($_POST);
  36. $article['id'] = (isset($_POST['article_id'])) ? $_POST['article_id'] : 0 ;
  37. $article['url'] = (isset($_POST['url'])) ? $_POST['url'] : 'temp_url_title' ;
  38. $article['date_uploaded'] = (isset($_POST['date_uploaded'])) ? $_POST['date_uploaded'] : date('Y-m-d H:i:s') ;
  39. $article['date_ts'] = strtotime($article['date_uploaded']);
  40. // get author name
  41. $article['author_name'] = get_author_name($article['author_id']);
  42. $article['author_url'] = 'temp';
  43. // get category name
  44. $article['category_title'] = get_category_title($article['category_id']);
  45. $article['category_url'] = 'temp';
  46. // comments and other fields
  47. $article['comments_hide'] = 1;
  48. $article['comments_disable']= 1;
  49. $article['total_pages'] = 1;
  50. $article['pages'] = 1;
  51. $article['tags'] = '' ;
  52. $article['attachments'] = '' ;
  53. $article['comments'] = '' ;
  54. // page name
  55. $_GET['page_name'] = 'article';
  56. // get content partial - checking for theme versions as well
  57. $theme_content_folder = WW_ROOT.'/ww_view/themes'.$config['site']['theme'].'/_content';
  58. $content_partial = (file_exists($theme_content_folder.'/_article.php'))
  59. ? $theme_content_folder.'/_article.php'
  60. : WW_ROOT.'/ww_view/_content/_article.php';
  61. if(file_exists($theme_content_folder.'/_header.php')) {
  62. ob_start();
  63. include($theme_content_folder.'/_header.php');
  64. $body_content['header'] = ob_get_contents();
  65. ob_end_clean();
  66. }
  67. // nav content - below is just for example
  68. /* $body_content['nav'] = '<div id="nav">yeah, nav content</div>'; */
  69. if(file_exists($theme_content_folder.'/_nav.php')) {
  70. ob_start();
  71. include($theme_content_folder.'/_nav.php');
  72. $body_content['nav'] = ob_get_contents();
  73. ob_end_clean();
  74. }
  75. // footer content - below is just for example
  76. /* $body_content['footer'] = '<div id="footer">test footer</div>'; */
  77. if(file_exists($theme_content_folder.'/_footer.php')) {
  78. ob_start();
  79. include($theme_content_folder.'/_footer.php');
  80. $body_content['footer'] = ob_get_contents();
  81. ob_end_clean();
  82. }
  83. // get aside content
  84. if(file_exists($theme_content_folder.'/_aside.php')) {
  85. ob_start();
  86. include($theme_content_folder.'/_aside.php');
  87. $body_content['aside'] = ob_get_contents();
  88. ob_end_clean();
  89. }
  90. //$body_content['aside'] = insert_aside($aside_content);
  91. // buffer main content and insert into a variable
  92. ob_start();
  93. include $content_partial;
  94. $body_content['main'] = ob_get_contents();
  95. ob_end_clean();
  96. /*
  97. with a builder file we can use a different html structure
  98. */
  99. if(file_exists($theme_content_folder.'/builder.php')) {
  100. include($theme_content_folder.'/builder.php');
  101. } else {
  102. // output default head section
  103. $head_content = '';
  104. show_head($head_content, $config);
  105. // output default body section
  106. show_body($body_content, $config);
  107. }
  108. ?>