index.php 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297
  1. <?php
  2. # ***** BEGIN LICENSE BLOCK *****
  3. # This file is part of DotClear.
  4. # Copyright (c) 2004 Olivier Meunier and contributors. All rights
  5. # reserved.
  6. #
  7. # DotClear is free software; you can redistribute it and/or modify
  8. # it under the terms of the GNU General Public License as published by
  9. # the Free Software Foundation; either version 2 of the License, or
  10. # (at your option) any later version.
  11. #
  12. # DotClear is distributed in the hope that it will be useful,
  13. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. # GNU General Public License for more details.
  16. #
  17. # You should have received a copy of the GNU General Public License
  18. # along with DotClear; if not, write to the Free Software
  19. # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  20. #
  21. # ***** END LICENSE BLOCK *****
  22. $dc_ini_file = dirname(__FILE__).'/../../../conf/dotclear.ini';
  23. $err = '';
  24. $url = 'tools.php?p=blogconf';
  25. $is_writable = false;
  26. if (!is_writable($dc_ini_file)) {
  27. $err = '<p>'.sprintf(__('Config file %s, is not writable.'),'<strong>conf/dotclear.ini</strong>').'</p>';
  28. } else {
  29. $is_writable = true;
  30. # Modification du fichier
  31. if (!empty($_POST))
  32. {
  33. $p_blog_name = trim($_POST['p_blog_name']);
  34. $p_blog_desc = trim($_POST['p_blog_desc']);
  35. $p_blog_url = trim($_POST['p_blog_url']);
  36. $p_app_url = trim($_POST['p_app_url']);
  37. $p_img_url = trim($_POST['p_img_url']);
  38. $p_blog_rss = trim($_POST['p_blog_rss']);
  39. $p_blog_atom = trim($_POST['p_blog_atom']);
  40. $p_trackback_uri = trim($_POST['p_trackback_uri']);
  41. $p_url_scan = trim($_POST['p_url_scan']);
  42. $p_nb_post_per_page = trim($_POST['p_nb_post_per_page']);
  43. $p_show_previews = trim($_POST['p_show_previews']);
  44. $p_date_format = trim($_POST['p_date_format']);
  45. $p_time_format = trim($_POST['p_time_format']);
  46. $p_default_lang = trim($_POST['p_default_lang']);
  47. $p_theme = trim($_POST['p_theme']);
  48. $p_allow_comments = trim($_POST['p_allow_comments']);
  49. $p_allow_trackbacks = trim($_POST['p_allow_trackbacks']);
  50. $p_comments_pub = trim($_POST['p_comments_pub']);
  51. $p_comments_ttl = trim($_POST['p_comments_ttl']);
  52. $p_comment_notification = trim($_POST['p_comment_notification']);
  53. $p_use_smilies = trim($_POST['p_use_smilies']);
  54. $p_short_feeds = trim($_POST['p_short_feeds']);
  55. $p_http_cache = trim($_POST['p_http_cache']);
  56. $arry_err = array();
  57. if ($p_blog_name == '') {
  58. $arry_err[] = __('You must give a blog name');
  59. }
  60. if ($p_blog_url == '') {
  61. $arry_err[] = __('You must give a blog URL');
  62. }
  63. if ($p_img_url == '') {
  64. $arry_err[] = __('You must give an images location');
  65. }
  66. if ($p_blog_rss == '') {
  67. $arry_err[] = __('You must give a RSS location');
  68. }
  69. if ($p_blog_atom == '') {
  70. $arry_err[] = __('You must give an Atom location');
  71. }
  72. if (!preg_match('/^[0-9]+$/',$p_nb_post_per_page) || $p_nb_post_per_page < 1) {
  73. $arry_err[] = __('You must give a valid number of entries per page');
  74. }
  75. if (count($arry_err) > 0)
  76. {
  77. $err .= '<ul>';
  78. foreach ($arry_err as $v) { $err .= '<li>'.$v.'</li>'; }
  79. $err .= '</ul>';
  80. }
  81. else
  82. {
  83. $p_blog_url = preg_replace('|^/+|','',$p_blog_url);
  84. $p_blog_url = '/'.$p_blog_url;
  85. $p_img_url = preg_replace('|/+$|','',$p_img_url);
  86. $p_img_url = preg_replace('|^/+|','',$p_img_url);
  87. $p_img_url = '/'.$p_img_url.'/';
  88. $objIni = new iniFile($dc_ini_file);
  89. $objIni->editVar('dc_blog_name',$p_blog_name);
  90. $objIni->editVar('dc_blog_desc',$p_blog_desc);
  91. $objIni->editVar('dc_blog_url',$p_blog_url);
  92. $objIni->editVar('dc_app_url',$p_app_url);
  93. $objIni->editVar('dc_img_url',$p_img_url);
  94. $objIni->editVar('dc_blog_rss',$p_blog_rss);
  95. $objIni->editVar('dc_blog_atom',$p_blog_atom);
  96. $objIni->editVar('dc_trackback_uri',$p_trackback_uri);
  97. $objIni->editVar('dc_url_scan',$p_url_scan);
  98. $objIni->editVar('dc_nb_post_per_page',(integer) $p_nb_post_per_page);
  99. $objIni->editVar('dc_show_previews',(integer) $p_show_previews);
  100. $objIni->editVar('dc_date_format',$p_date_format);
  101. $objIni->editVar('dc_time_format',$p_time_format);
  102. $objIni->editVar('dc_default_lang',$p_default_lang);
  103. $objIni->editVar('dc_theme',$p_theme);
  104. $objIni->editVar('dc_allow_comments',(integer) $p_allow_comments);
  105. $objIni->editVar('dc_allow_trackbacks',(integer) $p_allow_trackbacks);
  106. $objIni->editVar('dc_comments_pub',(integer) $p_comments_pub);
  107. $objIni->editVar('dc_comments_ttl',(integer) $p_comments_ttl);
  108. $objIni->editVar('dc_comment_notification',(integer) $p_comment_notification);
  109. $objIni->editVar('dc_use_smilies',(integer) $p_use_smilies);
  110. $objIni->editVar('dc_short_feeds',(integer) $p_short_feeds);
  111. $objIni->editVar('dc_http_cache',(integer) $p_http_cache);
  112. if ($objIni->saveFile() !== false) {
  113. header('Location: '.$url.'&done=1');
  114. exit;
  115. } else {
  116. $err = __('An error occured while writing the file.');
  117. }
  118. }
  119. }
  120. }
  121. /* Affichage
  122. -------------------------------------------------------- */
  123. buffer::str('<h2>'.__('DotClear configuration').'</h2>');
  124. if($err != '')
  125. {
  126. buffer::str('<div class="erreur"><p><strong>'.__('Error(s)').' :</strong></p>'.$err.'</div>');
  127. }
  128. if ($is_writable)
  129. {
  130. # Liste des thèmes
  131. $themes = new plugins(dirname(__FILE__).'/../../../themes/','theme');
  132. $themes->getPlugins(true);
  133. $themes_list = $themes->getPluginsList();
  134. array_walk($themes_list,create_function('&$v','$v=$v["label"];'));
  135. $themes_list = array_flip($themes_list);
  136. # Liste des modes de scan
  137. $scan_modes = array(
  138. 'Query string' => 'query_string',
  139. 'Path info' => 'path_info'
  140. );
  141. if (!empty($_GET['done'])) {
  142. buffer::str(
  143. '<p class="message">'.__('Configuration file successfully updated.').'</p>'
  144. );
  145. }
  146. buffer::str(
  147. '<form action="'.$url.'" method="post">'.
  148. '<fieldset class="clear">'.
  149. '<legend>'.__('Base configuration').'</legend>'.
  150. '<p class="field"><label for="p_blog_name"><strong>'.__('Blog name').'&nbsp;:</strong> '.
  151. helpLink('index&amp;plugin=blogconf','blog_name').'</label>'.
  152. form::field('p_blog_name',40,'',htmlspecialchars(dc_blog_name)).'</p>'.
  153. '<p class="field"><label for="p_blog_desc"><strong>'.__('Blog description').'&nbsp;:</strong> '.
  154. helpLink('index&amp;plugin=blogconf','blog_desc').'</label>'.
  155. form::field('p_blog_desc',40,'',htmlspecialchars(dc_blog_desc)).'</p>'.
  156. '<p class="field"><label for="p_blog_url"><strong>'.__('Blog URL').'&nbsp;:</strong> '.
  157. '('.sprintf(__('From %s'),'http://'.$_SERVER['HTTP_HOST']).') '.
  158. helpLink('index&amp;plugin=blogconf','blog_url').'</label>'.
  159. form::field('p_blog_url',40,'',htmlspecialchars(dc_blog_url)).'</p>'.
  160. '<p class="field"><label for="p_nb_post_per_page"><strong>'.__('Number of entries per page').'&nbsp;:</strong> '.
  161. '('.__('first page and categories').') '.
  162. helpLink('index&amp;plugin=blogconf','nb_post_per_page').'</label>'.
  163. form::field('p_nb_post_per_page',3,'',dc_nb_post_per_page).'</p>'.
  164. '<p class="field"><label for="p_default_lang"><strong>'.__('Default language').'&nbsp;:</strong> '.
  165. helpLink('index&amp;plugin=blogconf','default_lang').'</label>'.
  166. form::combo('p_default_lang',l10n::getISOcodes(1),dc_default_lang).'</p>'.
  167. '<p class="field"><label for="p_theme"><strong>'.__('Blog theme').'&nbsp;:</strong> '.
  168. helpLink('index&amp;plugin=blogconf','theme').'</label>'.
  169. form::combo('p_theme',$themes_list,dc_theme).'</p>'.
  170. '<p class="field"><label for="p_allow_comments"><strong>'.
  171. __('Allow comments').'&nbsp;:</strong> '.
  172. helpLink('index&amp;plugin=blogconf','allow_comments').'</label>'.
  173. form::combo('p_allow_comments',array(__('yes')=>1,__('no')=>0),(integer) dc_allow_comments).
  174. '</p>'.
  175. '<p class="field"><label for="p_allow_trackbacks"><strong>'.
  176. __('Allow trackbacks').'&nbsp;:</strong> '.
  177. helpLink('index&amp;plugin=blogconf','allow_trackbacks').'</label>'.
  178. form::combo('p_allow_trackbacks',array(__('yes')=>1,__('no')=>0),(integer) dc_allow_trackbacks).
  179. '</p>'.
  180. '<p class="field"><label for="p_comments_pub"><strong>'.
  181. __('Publish comments immediately').'&nbsp;:</strong> '.
  182. helpLink('index&amp;plugin=blogconf','comments_pub').'</label>'.
  183. form::combo('p_comments_pub',array(__('yes')=>1,__('no')=>0),(integer) dc_comments_pub).
  184. '</p>'.
  185. '</fieldset>'.
  186. '<fieldset><legend>'.__('Advanced configuration').'</legend>'.
  187. '<p class="field"><label for="p_app_url"><strong>'.__('Application location').'&nbsp;:</strong> '.
  188. '('.sprintf(__('From %s'),'http://'.$_SERVER['HTTP_HOST']).') '.
  189. helpLink('index&amp;plugin=blogconf','app_url').'</label>'.
  190. form::field('p_app_url',40,'',htmlspecialchars(dc_app_url)).'</p>'.
  191. '<p class="field"><label for="p_img_url"><strong>'.__('Images location').'&nbsp;:</strong> '.
  192. '('.sprintf(__('From %s'),'http://'.$_SERVER['HTTP_HOST']).') '.
  193. helpLink('index&amp;plugin=blogconf','img_url').'</label>'.
  194. form::field('p_img_url',40,'',htmlspecialchars(dc_img_url)).'</p>'.
  195. '<p class="field"><label for="p_blog_rss"><strong>'.__('RSS feed location').'&nbsp;:</strong> '.
  196. '('.sprintf(__('From %s'),'http://'.$_SERVER['HTTP_HOST']).') '.
  197. helpLink('index&amp;plugin=blogconf','blog_rss').'</label>'.
  198. form::field('p_blog_rss',40,'',htmlspecialchars(dc_blog_rss)).'</p>'.
  199. '<p class="field"><label for="p_blog_atom"><strong>'.__('Atom feed location').'&nbsp;:</strong> '.
  200. '('.sprintf(__('From %s'),'http://'.$_SERVER['HTTP_HOST']).') '.
  201. helpLink('index&amp;plugin=blogconf','blog_atom').'</label>'.
  202. form::field('p_blog_atom',40,'',htmlspecialchars(dc_blog_atom)).'</p>'.
  203. '<p class="field"><label for="p_trackback_uri"><strong>'.__('Trackback URL').'&nbsp;:</strong> '.
  204. '('.sprintf(__('From %s'),'http://'.$_SERVER['HTTP_HOST']).') '.
  205. helpLink('index&amp;plugin=blogconf','trackback_uri').'</label>'.
  206. form::field('p_trackback_uri',40,'',htmlspecialchars(dc_trackback_uri)).'</p>'.
  207. '<p class="field"><label for="p_url_scan"><strong>'.
  208. __('URL type').'&nbsp;:</strong> '.
  209. helpLink('index&amp;plugin=blogconf','url_scan').'</label>'.
  210. form::combo('p_url_scan',$scan_modes,dc_url_scan).
  211. '</p>'.
  212. '<p class="field"><label for="p_show_previews"><strong>'.
  213. __('Preview entries in backend').'&nbsp;:</strong> '.
  214. helpLink('index&amp;plugin=blogconf','show_previews').'</label>'.
  215. form::combo('p_show_previews',array(__('yes')=>1,__('no')=>0),(integer) dc_show_previews).
  216. '</p>'.
  217. '<p class="field"><label for="p_date_format"><strong>'.__('Date format').'&nbsp;:</strong> '.
  218. helpLink('index&amp;plugin=blogconf','time_format').'</label>'.
  219. form::field('p_date_format',40,'',htmlspecialchars(dc_date_format)).'</p>'.
  220. '<p class="field"><label for="p_time_format"><strong>'.__('Time format').'&nbsp;:</strong> '.
  221. helpLink('index&amp;plugin=blogconf','time_format').'</label>'.
  222. form::field('p_time_format',40,'',htmlspecialchars(dc_time_format)).'</p>'.
  223. '<p class="field"><label for="p_comments_ttl"><strong>'.
  224. __('Time to live of comments and trackbacks').'&nbsp;:</strong> '.
  225. helpLink('index&amp;plugin=blogconf','comments_ttl').'</label>'.
  226. form::field('p_comments_ttl',3,'',(string) dc_comments_ttl).'</p>'.
  227. '<p class="field"><label for="p_use_smilies"><strong>'.
  228. __('Show smileys in blog entries and comments').'&nbsp;:</strong> '.
  229. helpLink('index&amp;plugin=blogconf','use_smilies').'</label>'.
  230. form::combo('p_use_smilies',array(__('yes')=>1,__('no')=>0),(integer) dc_use_smilies).
  231. '</p>'.
  232. '<p class="field"><label for="p_comment_notification"><strong>'.
  233. __('Notify each new comment by email').'&nbsp;:</strong> '.
  234. helpLink('index&amp;plugin=blogconf','comment_notification').'</label>'.
  235. form::combo('p_comment_notification',array(__('yes')=>1,__('no')=>0),(integer) dc_comment_notification).
  236. '</p>'.
  237. '<p class="field"><label for="p_short_feeds"><strong>'.
  238. __('Short RSS and Atom feeds').'&nbsp;:</strong> '.
  239. helpLink('index&amp;plugin=blogconf','short_feeds').'</label>'.
  240. form::combo('p_short_feeds',array(__('yes')=>1,__('no')=>0),(integer) dc_short_feeds).
  241. '</p>'.
  242. '<p class="field"><label for="p_http_cache"><strong>'.
  243. __('Activate HTTP cache').'&nbsp;:</strong> '.
  244. helpLink('index&amp;plugin=blogconf','http_cache').'</label>'.
  245. form::combo('p_http_cache',array(__('yes')=>1,__('no')=>0),(integer) dc_http_cache).
  246. '</p>'.
  247. '</fieldset>'.
  248. '<p class="field"><input class="submit" type="submit" value="'.__('save').'" /></p>'.
  249. '</form>'
  250. );
  251. }
  252. ?>