PageRenderTime 112ms CodeModel.GetById 1ms RepoModel.GetById 0ms app.codeStats 1ms

/ xvweb/write.php

http://xvweb.googlecode.com/
PHP | 297 lines | 239 code | 34 blank | 24 comment | 68 complexity | 1ed5fb30a26fa5e66be7900f92459704 MD5 | raw file
Possible License(s): GPL-2.0, GPL-3.0, LGPL-3.0
  1. <?php
  2. /***************************************************************************
  3. **************** Bordeux.NET Project *************************
  4. **************** File name : write.php *************************
  5. **************** Start : 22.05.2007 r. *************************
  6. **************** License : LGPL *************************
  7. **************** Version : 1.0 *************************
  8. **************** Authors : XVweb team *************************
  9. *************************XVweb Team*****************************************
  10. Krzyszof Bednarczyk, meybe you
  11. /////////////////////////////////////////////////////////////////////////////
  12. Klasa XVweb jest na licencji LGPL v3.0 ( GNU LESSER GENERAL PUBLIC LICENSE)
  13. ****************http://www.gnu.org/licenses/lgpl-3.0.txt********************
  14. Pe?na dokumentacja znajduje si? na stronie domowej projektu:
  15. *********************http://www.bordeux.NET/Xvweb***************************
  16. ***************************************************************************/
  17. header("Cache-Control: no-cache, must-revalidate");
  18. if(!isset($XVwebEngine)){
  19. header("location: http://".$_SERVER['HTTP_HOST']."/");
  20. exit;
  21. }
  22. /*
  23. if(!($XVwebEngine->Session->Session('Logged_Logged'))){ // przekierowanie, jak nie zalogowany
  24. header("location: ".$URLS['Script'].'System/LogIn/');
  25. exit;
  26. }
  27. */
  28. $XVwebEngine->Date['EngineVars'] = array_merge_recursive((is_array($XVwebEngine->Date['EngineVars']) ? $XVwebEngine->Date['EngineVars'] : array()), (is_array($XVwebEngine->Plugins()->Menager()->enginevars()) ? $XVwebEngine->Plugins()->Menager()->enginevars() : array()));
  29. $XVwebEngine->Date['EngineFunctions'] = $XVwebEngine->Plugins()->Menager()->enginefunctions(); // zmienne z plugina :D
  30. LoadLang('edit');
  31. if(isset($_GET['PreView'])){
  32. exit($XVwebEngine->TextParser()->set("Blocked", false)->SetText($_POST['EditArtPost'])->Parse()->ToHTML());
  33. }
  34. if(isset($_GET['UrlCheck'])){
  35. $result = true;
  36. if(empty($_GET['xv-path']))
  37. $result = false;
  38. else{
  39. $URLArticlePrefix = $XVwebEngine->ReadPrefix($_GET['xv-path']);
  40. if($XVwebEngine->Plugins()->Menager()->prefix(($URLArticlePrefix)))
  41. $result = false;
  42. if($XVwebEngine->ReadArticle($_GET['xv-path']))
  43. $result = false;
  44. }
  45. header('Cache-Control: no-cache, must-revalidate');
  46. header('Content-type: application/json;');
  47. exit(json_encode(array("result"=>$result)));
  48. }
  49. if(isset($_GET['settings']) && is_numeric($_GET['settings'])){
  50. $XVwebEngine->ArticleFooIDinArticleIndex = $_GET['settings'];
  51. if(!$XVwebEngine->ReadArticle()){
  52. header("location: ".$URLS['Script'].'System/ArticleDoesNotExist/');
  53. exit;
  54. }
  55. $ResultOperation = false;
  56. if((xvPerm('AdminPanel'))){
  57. $SaveSettings = array();
  58. foreach($_POST['settings'] as $key=> $value)
  59. $SaveSettings[$key] = ifsetor($_POST['settings'][$key] , 0);
  60. unset($value);
  61. $IndexToChange = $_POST['articleindex'];
  62. $IndexToChange['Options'] = serialize($SaveSettings);
  63. $ResultOperation = $XVwebEngine->EditArticle()->EditIndexArticle($_GET['settings'], $IndexToChange);
  64. }
  65. if(!empty($_POST['urlpath']) && (xvPerm('MoveArticle'))){
  66. $URLFrom = $XVwebEngine->IDtoURL($_GET['settings']);
  67. $URLTo = $XVwebEngine->AddSlashesStartAndEnd($_POST['urlpath']);
  68. if ( $URLTo != $URLFrom){
  69. $ResultOperation = $XVwebEngine->EditArticle()->ChangeURL($URLFrom,$URLTo);
  70. }
  71. }
  72. if(!empty($_POST['alias']) && $_POST['alias'] != $XVwebEngine->ReadArticleIndexOut['URL'] && (xvPerm('CreateAlias'))){
  73. $ResultOperation = $XVwebEngine->EditArticle()->AddAlias($_POST['alias'],$_GET['settings']);
  74. }
  75. if(!empty($_POST['accept']) && (xvPerm('AcceptArticles'))){
  76. $AcceptResult = ($_POST['accept']['Accept'] == "yes" ? "yes" : "no");
  77. if($XVwebEngine->ReadArticleIndexOut['Accepted'] != $AcceptResult)
  78. $XVwebEngine->EditArticle()->AcceptArticle($_GET['settings'], $AcceptResult, (isset($_POST['accept']['SubArticles']) ? "yes": "no" ));
  79. }
  80. if(xvPerm('BlockArticles')){
  81. $BlockResult = $_POST['block']['Article'];
  82. if($XVwebEngine->ReadArticleIndexOut['Blocked'] != $BlockResult)
  83. $XVwebEngine->EditArticle()->BlockArticle($_GET['settings'], $BlockResult, (isset($_POST['block']['SubArticles']) ? "yes" : "no" ));
  84. }
  85. $XVwebEngine->EditArticle()->ClearArticleCache($_GET['settings']);
  86. if($ResultOperation == false){
  87. header("location: ".$URLS['Script'].'System/Error/?line='.(__LINE__).'&file='.urlencode(__FILE__));
  88. }else{
  89. header("location: ".$URLS['Script'].substr($ResultOperation,1).'?Save=true');
  90. }
  91. exit;
  92. }
  93. //Modyfication save
  94. if(isset($_GET['save']) && isset($_POST['xv-description'])){
  95. if($XVwebEngine->Config("config")->find("config disable edit")->text() == "true" && !xvPerm('AdminPanel')){
  96. header("location: ".$URLS['Script'].'System/AccessDenied/');
  97. exit;
  98. }
  99. if(!(xvPerm('EditArticle'))){ // przekierowanie, jak nie zalogowany
  100. header("location: ".$URLS['Script'].'System/AccessDenied/');
  101. exit;
  102. }
  103. if(!is_numeric($_GET['save'])){
  104. header("location: ".$URLS['Script'].'System/AccessDenied/');
  105. exit;
  106. }
  107. if(trim(ifsetor($_POST['xv-captcha'], "")) != substr($XVwebEngine->Session->GetSID(), 0, 5)){
  108. header("location: ".$URLS['Script'].'System/SpamBot/');
  109. exit;
  110. }
  111. if(isset($_POST['amendment']) && $_POST['amendment'] == "true"){
  112. if($XVwebEngine->EditArticle()->SaveAmendment($_GET['save'], $_POST['EditArtPost'], $_POST['arttitle'])){
  113. header("location: ".$URLS['Script'].substr($XVwebEngine->URLRepair($XVwebEngine->AddSlashesStartAndEnd($XVwebEngine->ReadArticleIndexOut['URL'])), 1));
  114. }else{
  115. header("location: ".$URLS['Script'].'System/Error/');
  116. }
  117. exit;
  118. }else{
  119. $XVwebEngine->SaveModificationArticle['Topic'] = htmlspecialchars($_POST['arttitle']);
  120. if($XVwebEngine->EditArticle()->Edit($_GET['save'], $_POST['EditArtPost'], $_POST['xv-description'])){
  121. header("location: ".$URLS['Script'].substr($XVwebEngine->URLRepair($XVwebEngine->AddSlashesStartAndEnd($XVwebEngine->ReadArticleIndexOut['URL'])), 1));
  122. exit;
  123. }
  124. }
  125. header("location: ?".http_build_query(array(
  126. "msg"=> (isset($Language[$XVwebEngine->SaveModificationArticleError]) ? $Language[$XVwebEngine->SaveModificationArticleError] : $XVwebEngine->SaveModificationArticleError ),
  127. "error"=> true,
  128. "title"=> $Language['Error'],
  129. "Edit"=> true,
  130. "id"=> $_GET['save'],
  131. )));
  132. exit;
  133. }
  134. if(isset($_GET['save']) && isset($_POST['xv-path'])){
  135. if($XVwebEngine->Config("config")->find("config disable write")->text() == "true" && !xvPerm('AdminPanel')){
  136. header("location: ".$URLS['Script'].'System/AccessDenied/');
  137. exit;
  138. }
  139. if(!(xvPerm('WriteArticle'))) {// Brak dostepu
  140. header("location: ".$URLS['Script'].'System/AccessDenied/');
  141. exit;
  142. }
  143. if(trim(ifsetor($_POST['xv-captcha'], "")) != substr($XVwebEngine->Session->GetSID(), 0, 5)){
  144. header("location: ".$URLS['Script'].'System/SpamBot/');
  145. exit;
  146. }
  147. $URLArticlePrefix = $XVwebEngine->ReadPrefix($_POST['xv-path']);
  148. if($XVwebEngine->Plugins()->Menager()->prefix(($URLArticlePrefix))){
  149. $XVwebEngine->Session->Session('CategoryBlockedPost', serialize($_POST));
  150. header("location: ".$URLS['Script'].'System/CategoryBlocked/');
  151. exit;
  152. }
  153. $TopicArticle = (empty($_POST['arttitle']) ? $XVwebEngine->ReadTopicArticleFromUrl($XVwebEngine->AddSlashesStartAndEnd($_POST['xv-path'])) : htmlspecialchars($_POST['arttitle']));
  154. $XVwebEngine->EditArticle()->Add($XVwebEngine->AddSlashesStartAndEnd($_POST['xv-path']), $_POST['EditArtPost'], null, $TopicArticle, $XVwebEngine->ReadCategoryArticle($_POST['xv-path'], true));
  155. if($XVwebEngine->SaveArticleError){
  156. $XVwebEngine->Session->Session('CategoryBlockedPost', serialize($_POST));
  157. switch($XVwebEngine->SaveArticleError)
  158. {
  159. case 1:
  160. header("location: ".$URLS['Script'].substr($XVwebEngine->URLRepair($XVwebEngine->AddSlashesStartAndEnd($_POST['xv-path'])), 1));
  161. exit;
  162. break;
  163. case "ArticleIsset":
  164. header("location: ".$URLS['Script'].'System/IssetArticle/');
  165. exit;
  166. break;
  167. case "CategoryDoesNotExist":
  168. header("location: ".$URLS['Script'].'System/CategoryDoesNotExist/');
  169. exit;
  170. break;
  171. case "IllegalCharacters":
  172. header("location: ".$URLS['Script'].'System/IllegalCharacters/');
  173. exit;
  174. break;
  175. case "Antyflood":
  176. header("location: ".$URLS['Script'].'System/Antyflood/?Time='.$XVwebEngine->AntyFlood()->Date['TimeOut']);
  177. exit;
  178. case "CategoryBlocked":
  179. header("location: ".$URLS['Script'].'System/CategoryBlocked/');
  180. exit;
  181. break;
  182. case "Error":
  183. header("location: ".$URLS['Script'].'System/Error/?line='.(__LINE__).'&file='.urlencode(__FILE__));
  184. exit;
  185. break;
  186. default:
  187. header("location: ".$URLS['Script'].'System/Error/');
  188. exit;
  189. }
  190. }
  191. header("location: ".$URLS['Script'].substr($XVwebEngine->AddSlashesStartAndEnd($_POST['xv-path']),1));
  192. exit;
  193. }
  194. if(isset($_GET['Edit']) && is_numeric($_GET['id'])){
  195. if($XVwebEngine->Config("config")->find("config disable edit")->text() == "true" && !xvPerm('AdminPanel')){
  196. header("location: ".$URLS['Script'].'System/AccessDenied/');
  197. exit;
  198. }
  199. if(!(xvPerm('EditArticle'))){ // przekierowanie, jak nie zalogowany
  200. header("location: ".$URLS['Script'].'System/AccessDenied/');
  201. exit;
  202. }
  203. $XVwebEngine->ArticleFooIDinArticleIndex = $_GET['id'];
  204. if(!$XVwebEngine->ReadArticle()){
  205. header("location: ".$URLS['Script'].'System/ArticleDoesNotExist/');
  206. exit;
  207. }
  208. if(($XVwebEngine->ReadArticleIndexOut['Blocked'] == "yes") && !(xvPerm('BlockArticles'))){
  209. header("location: ".$URLS['Script'].'System/ArticleBlocked/');
  210. exit;
  211. }
  212. if(xvPerm('AcceptArticles')){
  213. $SettingsInputs['AcceptArticle'] = array("tag"=>"select", "attr"=>array("name"=>"accept[Accept]"), "options"=>array("yes"=>$Language['Yes'], "no"=>$Language['No']), "checked"=>array($XVwebEngine->ReadArticleIndexOut['Accepted'] => true));
  214. $SettingsInputs['AcceptSubArticles'] = array("tag"=>"input" , "attr"=>array("name"=>"accept[SubArticles]", "value"=>"1", "type"=>"checkbox", "class"=>"xv-checkbox"));
  215. }
  216. if(xvPerm('BlockArticles')){
  217. $SettingsInputs['BlockArticle'] = array("tag"=>"select", "attr"=>array("name"=>"block[Article]"), "options"=>array("yes"=>$Language['Yes'], "no"=>$Language['No']), "checked"=>array($XVwebEngine->ReadArticleIndexOut['Blocked'] => true));
  218. $SettingsInputs['BlockSubArticles'] = array("tag"=>"input" , "attr"=>array("name"=>"block[SubArticles]", "value"=>"1", "type"=>"checkbox", "class"=>"xv-checkbox"));
  219. }
  220. if(xvPerm('AdminPanel')){
  221. $SettingsInputs['DisableCache'] = array("tag"=>"input" , "attr"=>array("name"=>"settings[DisableCache]", "value"=>"1", "type"=>"checkbox", "class"=>"xv-checkbox", "checked"=>(ifsetor($XVwebEngine->ReadArticleIndexOut['Options']['DisableCache'], 0) ? "checked" : "unchecked")));
  222. $SettingsInputs['DisableUI'] = array("tag"=>"input" , "attr"=>array("name"=>"settings[DisableUI]", "value"=>"1", "type"=>"checkbox", "class"=>"xv-checkbox", "checked"=>(ifsetor($XVwebEngine->ReadArticleIndexOut['Options']['DisableUI'], 0) ? "checked" : "unchecked")));
  223. $SettingsInputs['DisableDivisions'] = array("tag"=>"input" , "attr"=>array("name"=>"settings[DisableDivisions]", "value"=>"1", "type"=>"checkbox", "class"=>"xv-checkbox", "checked"=>(ifsetor($XVwebEngine->ReadArticleIndexOut['Options']['DisableDivisions'], 0) ? "checked" : "unchecked")));
  224. $SettingsInputs['DisableQuickSearch'] = array("tag"=>"input" , "attr"=>array("name"=>"settings[DisableQuickSearch]", "value"=>"1", "type"=>"checkbox", "class"=>"xv-checkbox", "checked"=>(ifsetor($XVwebEngine->ReadArticleIndexOut['Options']['DisableQuickSearch'], 0) ? "checked" : "unchecked")));
  225. $SettingsInputs['DisableAds'] = array("tag"=>"input" , "attr"=>array("name"=>"settings[DisableAds]", "value"=>"1", "type"=>"checkbox", "class"=>"xv-checkbox", "checked"=>(ifsetor($XVwebEngine->ReadArticleIndexOut['Options']['DisableAds'], 0) ? "checked" : "unchecked")));
  226. $SettingsInputs['EnablePHP'] = array("tag"=>"input" , "attr"=>array("name"=>"settings[EnablePHP]", "value"=>"1", "type"=>"checkbox", "class"=>"xv-checkbox", "checked"=>(ifsetor($XVwebEngine->ReadArticleIndexOut['Options']['EnablePHP'], 0) ? "checked" : "unchecked")));
  227. $SettingsInputs['EnableHTML'] = array("tag"=>"input" , "attr"=>array("name"=>"settings[EnableHTML]", "value"=>"1", "type"=>"checkbox", "class"=>"xv-checkbox" , "checked"=>(ifsetor($XVwebEngine->ReadArticleIndexOut['Options']['EnableHTML'], 0) ? "checked" : "unchecked")));
  228. $SettingsInputs['DisableParser'] = array("tag"=>"input" , "attr"=>array("name"=>"settings[DisableParser]", "value"=>"1", "type"=>"checkbox", "class"=>"xv-checkbox", "checked"=>(ifsetor($XVwebEngine->ReadArticleIndexOut['Options']['DisableParser'], 0) ? "checked" : "unchecked")));
  229. $SettingsInputs['IncludeArticle'] = array("tag"=>"input" , "attr"=>array("name"=>"settings[IncludeArticle]", "value"=>"1", "type"=>"checkbox", "class"=>"xv-checkbox", "checked"=>(ifsetor($XVwebEngine->ReadArticleIndexOut['Options']['IncludeArticle'], true) ? "checked" : "unchecked")));
  230. $SettingsInputs['DisableGeshi'] = array("tag"=>"input" , "attr"=>array("name"=>"settings[DisableGeshi]", "value"=>"1", "type"=>"checkbox", "class"=>"xv-checkbox", "checked"=>(ifsetor($XVwebEngine->ReadArticleIndexOut['Options']['DisableGeshi'], 0) ? "checked" : "unchecked")));
  231. $SettingsInputs['DisableFiles'] = array("tag"=>"input" , "attr"=>array("name"=>"settings[DisableFiles]", "value"=>"1", "type"=>"checkbox", "class"=>"xv-checkbox", "checked"=>(ifsetor($XVwebEngine->ReadArticleIndexOut['Options']['DisableFiles'], 0) ? "checked" : "unchecked")));
  232. $SettingsInputs['DisableComments'] = array("tag"=>"input" , "attr"=>array("name"=>"settings[DisableComments]", "value"=>"1", "type"=>"checkbox", "class"=>"xv-checkbox", "checked"=>(ifsetor($XVwebEngine->ReadArticleIndexOut['Options']['DisableComments'], 0) ? "checked" : "unchecked")));
  233. $SettingsInputs['DisableInfo'] = array("tag"=>"input" , "attr"=>array("name"=>"settings[DisableInfo]", "value"=>"1", "type"=>"checkbox", "class"=>"xv-checkbox", "checked"=>(ifsetor($XVwebEngine->ReadArticleIndexOut['Options']['DisableInfo'], 0) ? "checked" : "unchecked")));
  234. $SettingsInputs['MainTopic'] = array("tag"=>"input" , "attr"=>array("type"=>"text", "name"=>"articleindex[Topic]", "value"=> ifsetor($XVwebEngine->ReadArticleIndexOut['Topic'], '')));
  235. $SettingsInputs['MainViews'] = array("tag"=>"input" , "attr"=>array("type"=>"text", "name"=>"articleindex[Views]", "value"=> ifsetor($XVwebEngine->ReadArticleIndexOut['Views'], '')));
  236. $SettingsInputs['MainDate'] = array("tag"=>"input" , "attr"=>array("type"=>"text", "name"=>"articleindex[Date]", "value"=> ifsetor($XVwebEngine->ReadArticleIndexOut['Date'], '')));
  237. $SettingsInputs['MainTags'] = array("tag"=>"input" , "attr"=>array("type"=>"text", "name"=>"articleindex[Tag]", "value"=> ifsetor($XVwebEngine->ReadArticleIndexOut['Tag'], '')));
  238. $SettingsInputs['MainURL'] = array("tag"=>"input" , "attr"=>array("type"=>"text", "name"=>"articleindex[URL]", "value"=> ifsetor($XVwebEngine->ReadArticleIndexOut['URL'], '')));
  239. $SettingsInputs['Headers'] = array("tag"=>"textarea" , "attr"=>array("name"=>"settings[Headers]"), "text"=> ifsetor($XVwebEngine->ReadArticleIndexOut['Options']['Headers'], ''));
  240. $SettingsInputs['CSS'] = array("tag"=>"textarea" , "attr"=>array("name"=>"settings[CSS]"), "text"=> ifsetor($XVwebEngine->ReadArticleIndexOut['Options']['CSS'], ''));
  241. }
  242. if((xvPerm('MoveArticle')))
  243. $SettingsInputs['URLPath'] = array("tag"=>"input" , "attr"=>array("name"=>"urlpath", "type"=>"text", "value"=>(ifsetor($XVwebEngine->ReadArticleIndexOut['URL'], '/'))));
  244. if((xvPerm('CreateAlias')))
  245. $SettingsInputs['Alias'] = array("tag"=>"input" , "attr"=>array("name"=>"alias", "type"=>"text", "value"=>(ifsetor($XVwebEngine->ReadArticleIndexOut['URL'], '/'))));
  246. eval($XVwebEngine->Plugins()->Menager()->event("onButtonsSettings"));
  247. $Smarty->assign('SettingsInputs', $SettingsInputs);
  248. $ContextEdit = htmlspecialchars($XVwebEngine->ReadArticleOut['Contents']);
  249. $Smarty->assign('TitleArt', $XVwebEngine->ReadArticleOut['Topic']);
  250. $Smarty->assign('WriteDescription', true);
  251. $Smarty->assign('IDArticle', $XVwebEngine->ArticleFooIDinArticleIndex);
  252. }else{
  253. $Smarty->assign('WriteUrlArticle', true);
  254. if(!(xvPerm('WriteArticle'))){ // Brak dostepu
  255. header("location: ".$URLS['Script'].'System/AccessDenied/');
  256. exit;
  257. }
  258. }
  259. $Smarty->assign('ContextEdit', $ContextEdit);
  260. ////////Uzupe?nianie sta?ymi szablonu
  261. /**************************THEME*******************/
  262. $Smarty->display('write_show.tpl');
  263. ?>