PageRenderTime 69ms CodeModel.GetById 32ms RepoModel.GetById 1ms app.codeStats 0ms

/modules/pn_bbcode/pnadmin.php

https://gitlab.com/bulwye/reliquerunt
PHP | 219 lines | 160 code | 16 blank | 43 comment | 38 complexity | 1c3e1866d3fb35c66bcb8b739b3d3ca9 MD5 | raw file
  1. <?php
  2. // $Id: pnadmin.php 83 2005-10-07 12:06:29Z landseer $
  3. // ----------------------------------------------------------------------
  4. // PostNuke Content Management System
  5. // Copyright (C) 2001 by the PostNuke Development Team.
  6. // http://www.postnuke.com/
  7. // ----------------------------------------------------------------------
  8. // Based on:
  9. // PHP-NUKE Web Portal System - http://phpnuke.org/
  10. // Thatware - http://thatware.org/
  11. // ----------------------------------------------------------------------
  12. // LICENSE
  13. //
  14. // This program is free software; you can redistribute it and/or
  15. // modify it under the terms of the GNU General Public License (GPL)
  16. // as published by the Free Software Foundation; either version 2
  17. // of the License, or (at your option) any later version.
  18. //
  19. // This program is distributed in the hope that it will be useful,
  20. // but WITHOUT ANY WARRANTY; without even the implied warranty of
  21. // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  22. // GNU General Public License for more details.
  23. //
  24. // To read the license please visit http://www.gnu.org/copyleft/gpl.html
  25. // ----------------------------------------------------------------------
  26. // Original Author of file: Hinrich Donner
  27. // changed to pn_bbcode: larsneo
  28. // ----------------------------------------------------------------------
  29. function pn_bbcode_admin_main()
  30. {
  31. if (!pnSecAuthAction(0, 'pn_bbcode::', "::", ACCESS_ADMIN)) {
  32. return pnVarPrepForDisplay(_PNBBCODE_NOAUTH);
  33. }
  34. $pnr =&new pnRender('pn_bbcode');
  35. $pnr->caching = false;
  36. $pnr->add_core_data();
  37. return $pnr->fetch('pn_bbcode_admin_main.html');
  38. }
  39. /**
  40. * codeconfig
  41. *
  42. */
  43. function pn_bbcode_admin_codeconfig()
  44. {
  45. if (!pnSecAuthAction(0, 'pn_bbcode::', "::", ACCESS_ADMIN)) {
  46. return pnVarPrepForDisplay(_PNBBCODE_NOAUTH);
  47. }
  48. $submit = pnVarCleanFromInput('submit');
  49. if(!$submit) {
  50. $pnr =&new pnRender('pn_bbcode');
  51. $pnr->caching = false;
  52. $pnr->assign('code', pnModGetVar('pn_bbcode', 'code'));
  53. if (pnModGetVar('pn_bbcode', 'linenumbers') == "yes") {
  54. $linenumberonchecked = " checked=\"checked\" ";
  55. $linenumberoffchecked = " ";
  56. } else {
  57. $linenumberonchecked = " ";
  58. $linenumberoffchecked = " checked=\"checked\" ";
  59. }
  60. if (pnModGetVar('pn_bbcode', 'syntaxhilite') == "yes") {
  61. $syntaxhiliteonchecked = " checked=\"checked\" ";
  62. $syntaxhiliteoffchecked = " ";
  63. } else {
  64. $syntaxhiliteonchecked = " ";
  65. $syntaxhiliteoffchecked = " checked=\"checked\" ";
  66. }
  67. $pnr->assign('linenumberonchecked', $linenumberonchecked);
  68. $pnr->assign('linenumberoffchecked', $linenumberoffchecked);
  69. $pnr->assign('syntaxhiliteonchecked', $syntaxhiliteonchecked);
  70. $pnr->assign('syntaxhiliteoffchecked', $syntaxhiliteoffchecked);
  71. $pnr->assign('code_preview', nl2br(pnModAPIFunc('pn_bbcode', 'user', 'transform',
  72. array('objectid' => 1,
  73. 'extrainfo' => "[code]<?php\n\necho 'test';\n\n?>[/code]"))));
  74. return $pnr->fetch('pn_bbcode_admin_codeconfig.html');
  75. } else {
  76. pnModSetVar('pn_bbcode', 'code', stripslashes(pnVarPrepForStore(pnVarCleanFromInput('code'))));
  77. pnModSetVar('pn_bbcode', 'linenumbers', pnVarCleanFromInput('linenumbers'));
  78. pnModSetVar('pn_bbcode', 'syntaxhilite', pnVarCleanFromInput('syntaxhilite'));
  79. pnSessionSetVar('statusmsg', pnVarPrepForDisplay(_PNBBCODE_CONFIGCHANGED));
  80. pnRedirect(pnModURL('pn_bbcode', 'admin', 'main'));
  81. }
  82. }
  83. /**
  84. * quoteconfig
  85. *
  86. */
  87. function pn_bbcode_admin_quoteconfig()
  88. {
  89. if (!pnSecAuthAction(0, 'pn_bbcode::', "::", ACCESS_ADMIN)) {
  90. return pnVarPrepForDisplay(_PNBBCODE_NOAUTH);
  91. }
  92. $submit = pnVarCleanFromInput('submit');
  93. if(!$submit) {
  94. global $additional_header;
  95. $stylesheet = "modules/pn_bbcode/pnstyle/style.css";
  96. $stylesheetlink = "<link rel=\"stylesheet\" href=\"$stylesheet\" type=\"text/css\" />";
  97. global $additional_header;
  98. if(is_array($additional_header)) {
  99. $values = array_flip($additional_header);
  100. if(!array_key_exists($stylesheetlink, $values) && file_exists($stylesheet) && is_readable($stylesheet)) {
  101. $additional_header[] = $stylesheetlink;
  102. }
  103. } else {
  104. if(file_exists($stylesheet) && is_readable($stylesheet)) {
  105. $additional_header[] = $stylesheetlink;
  106. }
  107. }
  108. $pnr =&new pnRender('pn_bbcode');
  109. $pnr->caching = false;
  110. $pnr->assign('quote', pnModGetVar('pn_bbcode', 'quote'));
  111. $pnr->assign('quote_preview', nl2br(pnModAPIFunc('pn_bbcode', 'user', 'transform',
  112. array('objectid' => 1,
  113. 'extrainfo' => "[quote=username]test\ntest test\n\n[/quote]"))));
  114. return $pnr->fetch('pn_bbcode_admin_quoteconfig.html');
  115. } else {
  116. pnModSetVar('pn_bbcode', 'quote', stripslashes(pnVarPrepForStore(pnVarCleanFromInput('quote'))));
  117. pnSessionSetVar('statusmsg', pnVarPrepForDisplay(_PNBBCODE_CONFIGCHANGED));
  118. pnRedirect(pnModURL('pn_bbcode', 'admin', 'main'));
  119. }
  120. }
  121. /**
  122. * sizeconfig
  123. *
  124. */
  125. function pn_bbcode_admin_sizeconfig()
  126. {
  127. if (!pnSecAuthAction(0, 'pn_bbcode::', "::", ACCESS_ADMIN)) {
  128. return pnVarPrepForDisplay(_PNBBCODE_NOAUTH);
  129. }
  130. $submit = pnVarCleanFromInput('submit');
  131. if(!$submit) {
  132. $pnr =&new pnRender('pn_bbcode');
  133. $pnr->caching = false;
  134. if (pnModGetVar('pn_bbcode', 'allow_usersize') == "yes") {
  135. $usersizeonchecked = " checked=\"checked\" ";
  136. $usersizeoffchecked = " ";
  137. } else {
  138. $usersizeonchecked = " ";
  139. $usersizeoffchecked = " checked=\"checked\" ";
  140. }
  141. if (pnModGetVar('pn_bbcode', 'size_enabled') == "yes") {
  142. $sizeenabled = " checked=\"checked\" ";
  143. } else {
  144. $sizeenabled = " ";
  145. }
  146. $pnr->assign('size_tiny', pnModGetVar('pn_bbcode', 'size_tiny'));
  147. $pnr->assign('size_small', pnModGetVar('pn_bbcode', 'size_small'));
  148. $pnr->assign('size_normal', pnModGetVar('pn_bbcode', 'size_normal'));
  149. $pnr->assign('size_large', pnModGetVar('pn_bbcode', 'size_large'));
  150. $pnr->assign('size_huge', pnModGetVar('pn_bbcode', 'size_huge'));
  151. $pnr->assign('usersizeonchecked', $usersizeonchecked);
  152. $pnr->assign('usersizeoffchecked', $usersizeoffchecked);
  153. $pnr->assign('sizeenabled', $sizeenabled);
  154. return $pnr->fetch('pn_bbcode_admin_sizeconfig.html');
  155. } else {
  156. pnModSetVar('pn_bbcode', 'size_tiny', stripslashes(pnVarPrepForStore(pnVarCleanFromInput('size_tiny'))));
  157. pnModSetVar('pn_bbcode', 'size_small', stripslashes(pnVarPrepForStore(pnVarCleanFromInput('size_small'))));
  158. pnModSetVar('pn_bbcode', 'size_normal', stripslashes(pnVarPrepForStore(pnVarCleanFromInput('size_normal'))));
  159. pnModSetVar('pn_bbcode', 'size_large', stripslashes(pnVarPrepForStore(pnVarCleanFromInput('size_large'))));
  160. pnModSetVar('pn_bbcode', 'size_huge', stripslashes(pnVarPrepForStore(pnVarCleanFromInput('size_huge'))));
  161. pnModSetVar('pn_bbcode', 'allow_usersize', pnVarPrepForStore(pnVarCleanFromInput('allow_usersize')));
  162. pnModSetVar('pn_bbcode', 'size_enabled', pnVarPrepForStore(pnVarCleanFromInput('size_enabled')));
  163. pnSessionSetVar('statusmsg', pnVarPrepForDisplay(_PNBBCODE_CONFIGCHANGED));
  164. pnRedirect(pnModURL('pn_bbcode', 'admin', 'main'));
  165. }
  166. }
  167. /**
  168. * colorconfig
  169. *
  170. */
  171. function pn_bbcode_admin_colorconfig()
  172. {
  173. if (!pnSecAuthAction(0, 'pn_bbcode::', "::", ACCESS_ADMIN)) {
  174. return pnVarPrepForDisplay(_PNBBCODE_NOAUTH);
  175. }
  176. $submit = pnVarCleanFromInput('submit');
  177. if(!$submit) {
  178. $pnr =&new pnRender('pn_bbcode');
  179. $pnr->caching = false;
  180. if (pnModGetVar('pn_bbcode', 'allow_usercolor') == "yes") {
  181. $usercoloronchecked = " checked=\"checked\" ";
  182. $usercoloroffchecked = " ";
  183. } else {
  184. $usercoloronchecked = " ";
  185. $usercoloroffchecked = " checked=\"checked\" ";
  186. }
  187. if (pnModGetVar('pn_bbcode', 'color_enabled') == "yes") {
  188. $colorenabled = " checked=\"checked\" ";
  189. } else {
  190. $colorenabled = " ";
  191. }
  192. $pnr->assign('usercoloronchecked', $usercoloronchecked);
  193. $pnr->assign('usercoloroffchecked', $usercoloroffchecked);
  194. $pnr->assign('colorenabled', $colorenabled);
  195. return $pnr->fetch('pn_bbcode_admin_colorconfig.html');
  196. } else {
  197. pnModSetVar('pn_bbcode', 'color_enabled', pnVarPrepForStore(pnVarCleanFromInput('color_enabled')));
  198. pnModSetVar('pn_bbcode', 'allow_usercolor', pnVarPrepForStore(pnVarCleanFromInput('allow_usercolor')));
  199. pnSessionSetVar('statusmsg', pnVarPrepForDisplay(_PNBBCODE_CONFIGCHANGED));
  200. pnRedirect(pnModURL('pn_bbcode', 'admin', 'main'));
  201. }
  202. }
  203. ?>