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

/ww.admin/siteoptions/general.php

http://kv-webme.googlecode.com/
PHP | 257 lines | 219 code | 1 blank | 37 comment | 30 complexity | d45b62ca06769604b2262cb082f1ba6f MD5 | raw file
Possible License(s): LGPL-3.0, GPL-2.0, BSD-3-Clause, BSD-2-Clause, Apache-2.0, MIT, LGPL-2.1
  1. <?php
  2. /**
  3. * general details for the site
  4. *
  5. * PHP version 5.3
  6. *
  7. * @category None
  8. * @package None
  9. * @author Kae Verens <kae@kvsites.ie>
  10. * @license GPL 2.0
  11. * @link http://kvsites.ie/
  12. */
  13. echo '<h2>'.__('General').'</h2>';
  14. // { handle actions
  15. if ($action=='Save') {
  16. $DBVARS['f_cache']=$_REQUEST['f_cache'];
  17. $DBVARS['maintenance-mode']=$_REQUEST['maintenance-mode'];
  18. $DBVARS['maintenance-mode-message']=$_REQUEST['maintenance-mode-message'];
  19. if (@$_REQUEST['disable-hidden-sitemap']) {
  20. $DBVARS['disable-hidden-sitemap']=1;
  21. }
  22. else {
  23. unset($DBVARS['disable-hidden-sitemap']);
  24. }
  25. if (@$_REQUEST['disable-jqueryui-css']) {
  26. $DBVARS['disable-jqueryui-css']=(int)$_REQUEST['disable-jqueryui-css'];
  27. }
  28. else {
  29. unset($DBVARS['disable-jqueryui-css']);
  30. }
  31. $DBVARS['site_title']=$_REQUEST['site_title'];
  32. if (@$_REQUEST['canonical_name']) {
  33. $DBVARS['canonical_name']=$_REQUEST['canonical_name'];
  34. }
  35. else {
  36. unset($DBVARS['canonical_name']);
  37. }
  38. if (@$_REQUEST['cdn']) {
  39. $DBVARS['cdn']=preg_replace(
  40. '/^https?:\/\/([^\/]*)/',
  41. '\1',
  42. $_REQUEST['cdn']
  43. );
  44. }
  45. else {
  46. unset($DBVARS['cdn']);
  47. }
  48. $DBVARS['site_subtitle']=$_REQUEST['site_subtitle'];
  49. $DBVARS['site_thousands_sep']=$_REQUEST['site_thousands_sep'];
  50. $DBVARS['site_dec_point']=$_REQUEST['site_dec_point'];
  51. if (isset($_FILES['site_favicon'])
  52. && file_exists($_FILES['site_favicon']['tmp_name'])
  53. ) {
  54. $tmpname=addslashes($_FILES['site_favicon']['tmp_name']);
  55. $newdir=USERBASE.'/f/skin_files';
  56. if (!file_exists(USERBASE.'/f/skin_files')) {
  57. mkdir(USERBASE.'/f/skin_files');
  58. }
  59. $files=glob($newdir.'/favicon-*');
  60. foreach ($files as $f) {
  61. unlink($f);
  62. }
  63. $from=addslashes($_FILES['site_favicon']['tmp_name']);
  64. $to=addslashes($newdir.'/favicon.png');
  65. CoreGraphics::resize($from, $to, 32, 32);
  66. }
  67. if (isset($_FILES['site_logo'])
  68. && file_exists($_FILES['site_logo']['tmp_name'])
  69. ) {
  70. $tmpname=addslashes($_FILES['site_logo']['tmp_name']);
  71. $newdir=USERBASE.'/f/skin_files';
  72. if (!file_exists($newdir)) {
  73. mkdir($newdir);
  74. }
  75. $files=glob($newdir.'/logo-*');
  76. foreach ($files as $f) {
  77. unlink($f);
  78. }
  79. CoreGraphics::convert($_FILES['site_logo']['tmp_name'], $newdir.'/logo.png');
  80. }
  81. $pageLengthLimit = $_REQUEST['site_page_length_limit'];
  82. if (!empty($pageLengthLimit)&&is_numeric($pageLengthLimit)) {
  83. $DBVARS['site_page_length_limit'] = $pageLengthLimit;
  84. }
  85. else if (isset($DBVARS['site_page_length_limit'])) {
  86. unset($DBVARS['site_page_length_limit']);
  87. }
  88. Core_configRewrite();
  89. Core_cacheClear();
  90. echo '<em>'.__('options updated').'</em>';
  91. }
  92. if ($action=='remove_logo') {
  93. unlink(USERBASE.'/f/skin_files/logo.png');
  94. }
  95. // }
  96. // { form
  97. echo '<form method="post" action="siteoptions.php?page=general" enctype="mu'
  98. .'ltipart/form-data"><input type="hidden" name="MAX_FILE_SIZE" value="999'
  99. .'9999" /><table>';
  100. // { website title and subtitle
  101. echo '<tr><th>'.__('Website Title').'</th><td><input name="site_title" value="'
  102. .htmlspecialchars($DBVARS['site_title']).'" /></td></tr>'
  103. .'<tr><th>'.__('Website Subtitle')
  104. .'</th><td><input name="site_subtitle" value="'
  105. .htmlspecialchars($DBVARS['site_subtitle']).'" /></td></tr>';
  106. // }
  107. // { canonical domain name
  108. $canonical_name=@$DBVARS['canonical_name']
  109. ?' value="'.htmlspecialchars($DBVARS['canonical_name']).'"'
  110. :'';
  111. echo '<tr><th>'.__('Canonical Domain Name')
  112. .'</th><td><input name="canonical_name" '
  113. .'placeholder="'.__('leave blank to accept multiple domain names').'"'
  114. .$canonical_name.' /></td></tr>';
  115. // }
  116. // { logo
  117. echo '<tr><th>'.__('Logo').'</th><td><input type="file" name="site_logo" />'
  118. .'<br />';
  119. if (file_exists(USERBASE.'/f/skin_files/logo.png')) {
  120. echo '<img src="/f/skin_files/logo.png?rand='.mt_rand(0, 9999).'" /><a hre'
  121. .'f="/ww.admin/siteoptions.php?action=remove_logo" onclick="return conf'
  122. .'irm(\''.__('are you sure you want to remove the logo?').'\')" title="'
  123. .__('remove logo').'">[x]</a>';
  124. }
  125. echo '</td></tr>';
  126. // }
  127. // { favicon
  128. echo '<tr><th>'.__('Favicon').'</th><td>'
  129. .'<input type="file" name="site_favicon" /><br />';
  130. if (file_exists(USERBASE.'/f/skin_files/favicon.ico')) {
  131. echo '<img src="/f/skin_files/favicon.ico?rand='.mt_rand(0, 9999)
  132. .'" /><a href="/ww.admin/siteoptions.php?action=remove_favicon" '
  133. .'onclick="return confirm(\''
  134. .__('are you sure you want to remove the favicon?')
  135. .'\')" title="'.__('remove favicon').'">[x]</a>';
  136. }
  137. echo '</td></tr>';
  138. // }
  139. // { page length limit
  140. echo '<tr><th>'.__('Page Length Limit').'</th>';
  141. echo '<td><input type="text" name="site_page_length_limit"';
  142. if (isset($DBVARS['site_page_length_limit'])) {
  143. echo ' value="'.$DBVARS['site_page_length_limit'].'"';
  144. }
  145. echo ' /></td></tr>';
  146. // }
  147. // { uploaded files cache
  148. echo '<tr><th>'.__('How long browsers should cache uploaded files for')
  149. .'</th><td><select name="f_cache"><option value="0">forever</option>';
  150. $arr=array(
  151. '1 hour'=>1,
  152. '1 day'=>24,
  153. '1 week'=>168,
  154. '1 month'=>672
  155. );
  156. foreach ($arr as $k=>$v) {
  157. echo '<option value="'.$v.'"';
  158. if (isset($DBVARS['f_cache']) && $v==$DBVARS['f_cache']) {
  159. echo ' selected="selected"';
  160. }
  161. echo '>'.__($k).'</option>';
  162. }
  163. echo '</select></td></tr>';
  164. // }
  165. // { disable hidden menu sitemap
  166. echo '<tr><th>'.__('Disable the hidden sitemap').' (<a href="/Home?webmespe'
  167. .'cial=sitemap">'.__('this').'</a>)</th><td>'
  168. .'<select name="disable-hidden-sitemap"><option value="0">'.__('No')
  169. .'</option>';
  170. echo '<option value="1"';
  171. if (@$DBVARS['disable-hidden-sitemap']) {
  172. echo ' selected="selected"';
  173. }
  174. echo '>'.__('Yes').'</option>';
  175. echo '</select></td></tr>';
  176. // }
  177. // { maintenance mode
  178. $script='$(function(){
  179. $("select[name=\'maintenance-mode\']").change(function(){
  180. $(".maintenance-message").toggle();
  181. });
  182. $( "#add-ip" ).click( function( ){
  183. var test=prompt("'.__('Please enter the IP Address').'");
  184. alert(test);
  185. });
  186. });';
  187. WW_addInlineScript($script);
  188. $display=' style="display:none"';
  189. echo '<tr><th>Enable maintenance mode</th><td>
  190. <select name="maintenance-mode">
  191. <option value="No">'.__('No').'</option>
  192. <option value="yes"';
  193. if (@$DBVARS['maintenance-mode']=='yes') {
  194. echo ' selected="selected"';
  195. $display='';
  196. }
  197. if (!isset($DBVARS['maintenance-mode-ips'])
  198. || $DBVARS['maintenance-mode-ips']==''
  199. ) {
  200. $DBVARS['maintenance-mode-ips']=$_SERVER['REMOTE_ADDR'];
  201. }
  202. echo '>'.__('Yes').'</option>
  203. </select></td></tr>
  204. <tr class="maintenance-message" '.$display.'>
  205. <th>'.__('IP Addresses').'</th>
  206. <td><textarea name="maintenance-mode-ips" style="width:200px;height:50px">'
  207. .htmlspecialchars(@$DBVARS['maintenance-mode-ips'])
  208. .'</textarea></td></tr>';
  209. $message=(@$DBVARS['maintenance-mode-message']=='')
  210. ?'<h1>'.__('Temporarily Unavailable').'</h1><p>'
  211. .__('This website is undergoing maintenance and is temporarily unavailable')
  212. .'.</p>'
  213. :$DBVARS['maintenance-mode-message'];
  214. echo '<tr '.$display.' class="maintenance-message">
  215. <th>'.__('Maintenance mode message').':</th>
  216. <td>'.ckeditor('maintenance-mode-message', $message).'</td>
  217. </tr>';
  218. // }
  219. // { disable jquery-ui css
  220. $values=array(
  221. 'Load jQuery UI CSS normally', 'Load only in admin area',
  222. 'Load only in front-end', 'Do not load at all'
  223. );
  224. echo '<tr><th>'.__('Don\'t load the jQuery-UI CSS').'</th><td>'
  225. .'<select name="disable-jqueryui-css">';
  226. foreach ($values as $k=>$v) {
  227. echo '<option value="'.$k.'"';
  228. if ($k==(int)@$DBVARS['disable-jqueryui-css']) {
  229. echo ' selected="selected"';
  230. }
  231. echo '>'.$v.'</option>';
  232. }
  233. echo '</select></td></tr>';
  234. // }
  235. // { number format
  236. echo '<tr><th>'.__('Number Format').'</th><td>'
  237. .'999<input name="site_thousands_sep"'
  238. .' value="'.htmlspecialchars($DBVARS['site_thousands_sep']).'"'
  239. .' style="width:10px;height:1em;text-align:center" />'
  240. .'999<input name="site_dec_point"'
  241. .' value="'.htmlspecialchars($DBVARS['site_dec_point']).'"'
  242. .' style="width:10px;height:1em;text-align:center" />'
  243. .'99</td></tr>';
  244. // }
  245. // { CDN
  246. echo '<tr><th>'.__('Content Delivery Network').'</th>';
  247. echo '<td><input type="text" name="cdn"';
  248. if (isset($DBVARS['cdn'])) {
  249. echo ' value="'.$DBVARS['cdn'].'"';
  250. }
  251. echo ' /></td></tr>';
  252. // }
  253. echo '</table><input type="hidden" name="action" value="Save"/>'
  254. .'<input type="submit" value="'.__('Save').'" /></form>';
  255. // }