[ Index ] |
|
Code source de Dotclear 1.2.5 |
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 23 $dc_ini_file = dirname(__FILE__).'/../../../conf/dotclear.ini'; 24 25 $err = ''; 26 27 $url = 'tools.php?p=blogconf'; 28 $is_writable = false; 29 30 31 if (!is_writable($dc_ini_file)) { 32 $err = '<p>'.sprintf(__('Config file %s, is not writable.'),'<strong>conf/dotclear.ini</strong>').'</p>'; 33 } else { 34 $is_writable = true; 35 36 # Modification du fichier 37 if (!empty($_POST)) 38 { 39 $p_blog_name = trim($_POST['p_blog_name']); 40 $p_blog_desc = trim($_POST['p_blog_desc']); 41 $p_blog_url = trim($_POST['p_blog_url']); 42 $p_app_url = trim($_POST['p_app_url']); 43 $p_img_url = trim($_POST['p_img_url']); 44 $p_blog_rss = trim($_POST['p_blog_rss']); 45 $p_blog_atom = trim($_POST['p_blog_atom']); 46 $p_trackback_uri = trim($_POST['p_trackback_uri']); 47 $p_url_scan = trim($_POST['p_url_scan']); 48 $p_nb_post_per_page = trim($_POST['p_nb_post_per_page']); 49 $p_show_previews = trim($_POST['p_show_previews']); 50 $p_date_format = trim($_POST['p_date_format']); 51 $p_time_format = trim($_POST['p_time_format']); 52 $p_default_lang = trim($_POST['p_default_lang']); 53 $p_theme = trim($_POST['p_theme']); 54 $p_allow_comments = trim($_POST['p_allow_comments']); 55 $p_allow_trackbacks = trim($_POST['p_allow_trackbacks']); 56 $p_comments_pub = trim($_POST['p_comments_pub']); 57 $p_comments_ttl = trim($_POST['p_comments_ttl']); 58 $p_comment_notification = trim($_POST['p_comment_notification']); 59 $p_use_smilies = trim($_POST['p_use_smilies']); 60 $p_short_feeds = trim($_POST['p_short_feeds']); 61 $p_http_cache = trim($_POST['p_http_cache']); 62 63 $arry_err = array(); 64 65 if ($p_blog_name == '') { 66 $arry_err[] = __('You must give a blog name'); 67 } 68 if ($p_blog_url == '') { 69 $arry_err[] = __('You must give a blog URL'); 70 } 71 if ($p_img_url == '') { 72 $arry_err[] = __('You must give an images location'); 73 } 74 if ($p_blog_rss == '') { 75 $arry_err[] = __('You must give a RSS location'); 76 } 77 if ($p_blog_atom == '') { 78 $arry_err[] = __('You must give an Atom location'); 79 } 80 if (!preg_match('/^[0-9]+$/',$p_nb_post_per_page) || $p_nb_post_per_page < 1) { 81 $arry_err[] = __('You must give a valid number of entries per page'); 82 } 83 84 if (count($arry_err) > 0) 85 { 86 $err .= '<ul>'; 87 foreach ($arry_err as $v) { $err .= '<li>'.$v.'</li>'; } 88 $err .= '</ul>'; 89 } 90 else 91 { 92 $p_blog_url = preg_replace('|^/+|','',$p_blog_url); 93 $p_blog_url = '/'.$p_blog_url; 94 95 $p_img_url = preg_replace('|/+$|','',$p_img_url); 96 $p_img_url = preg_replace('|^/+|','',$p_img_url); 97 $p_img_url = '/'.$p_img_url.'/'; 98 99 $objIni = new iniFile($dc_ini_file); 100 $objIni->editVar('dc_blog_name',$p_blog_name); 101 $objIni->editVar('dc_blog_desc',$p_blog_desc); 102 $objIni->editVar('dc_blog_url',$p_blog_url); 103 $objIni->editVar('dc_app_url',$p_app_url); 104 $objIni->editVar('dc_img_url',$p_img_url); 105 $objIni->editVar('dc_blog_rss',$p_blog_rss); 106 $objIni->editVar('dc_blog_atom',$p_blog_atom); 107 $objIni->editVar('dc_trackback_uri',$p_trackback_uri); 108 $objIni->editVar('dc_url_scan',$p_url_scan); 109 $objIni->editVar('dc_nb_post_per_page',(integer) $p_nb_post_per_page); 110 $objIni->editVar('dc_show_previews',(integer) $p_show_previews); 111 $objIni->editVar('dc_date_format',$p_date_format); 112 $objIni->editVar('dc_time_format',$p_time_format); 113 $objIni->editVar('dc_default_lang',$p_default_lang); 114 $objIni->editVar('dc_theme',$p_theme); 115 $objIni->editVar('dc_allow_comments',(integer) $p_allow_comments); 116 $objIni->editVar('dc_allow_trackbacks',(integer) $p_allow_trackbacks); 117 $objIni->editVar('dc_comments_pub',(integer) $p_comments_pub); 118 $objIni->editVar('dc_comments_ttl',(integer) $p_comments_ttl); 119 $objIni->editVar('dc_comment_notification',(integer) $p_comment_notification); 120 $objIni->editVar('dc_use_smilies',(integer) $p_use_smilies); 121 $objIni->editVar('dc_short_feeds',(integer) $p_short_feeds); 122 $objIni->editVar('dc_http_cache',(integer) $p_http_cache); 123 124 if ($objIni->saveFile() !== false) { 125 header('Location: '.$url.'&done=1'); 126 exit; 127 } else { 128 $err = __('An error occured while writing the file.'); 129 } 130 } 131 } 132 } 133 134 135 /* Affichage 136 -------------------------------------------------------- */ 137 buffer::str('<h2>'.__('DotClear configuration').'</h2>'); 138 139 if($err != '') 140 { 141 buffer::str('<div class="erreur"><p><strong>'.__('Error(s)').' :</strong></p>'.$err.'</div>'); 142 } 143 144 if ($is_writable) 145 { 146 # Liste des thèmes 147 $themes = new plugins(dirname(__FILE__).'/../../../themes/','theme'); 148 $themes->getPlugins(true); 149 $themes_list = $themes->getPluginsList(); 150 151 array_walk($themes_list,create_function('&$v','$v=$v["label"];')); 152 $themes_list = array_flip($themes_list); 153 154 # Liste des modes de scan 155 $scan_modes = array( 156 'Query string' => 'query_string', 157 'Path info' => 'path_info' 158 ); 159 160 if (!empty($_GET['done'])) { 161 buffer::str( 162 '<p class="message">'.__('Configuration file successfully updated.').'</p>' 163 ); 164 } 165 166 buffer::str( 167 '<form action="'.$url.'" method="post">'. 168 169 '<fieldset class="clear">'. 170 '<legend>'.__('Base configuration').'</legend>'. 171 '<p class="field"><label for="p_blog_name"><strong>'.__('Blog name').' :</strong> '. 172 helpLink('index&plugin=blogconf','blog_name').'</label>'. 173 form::field('p_blog_name',40,'',htmlspecialchars(dc_blog_name)).'</p>'. 174 175 '<p class="field"><label for="p_blog_desc"><strong>'.__('Blog description').' :</strong> '. 176 helpLink('index&plugin=blogconf','blog_desc').'</label>'. 177 form::field('p_blog_desc',40,'',htmlspecialchars(dc_blog_desc)).'</p>'. 178 179 '<p class="field"><label for="p_blog_url"><strong>'.__('Blog URL').' :</strong> '. 180 '('.sprintf(__('From %s'),'http://'.$_SERVER['HTTP_HOST']).') '. 181 helpLink('index&plugin=blogconf','blog_url').'</label>'. 182 form::field('p_blog_url',40,'',htmlspecialchars(dc_blog_url)).'</p>'. 183 184 '<p class="field"><label for="p_nb_post_per_page"><strong>'.__('Number of entries per page').' :</strong> '. 185 '('.__('first page and categories').') '. 186 helpLink('index&plugin=blogconf','nb_post_per_page').'</label>'. 187 form::field('p_nb_post_per_page',3,'',dc_nb_post_per_page).'</p>'. 188 189 '<p class="field"><label for="p_default_lang"><strong>'.__('Default language').' :</strong> '. 190 helpLink('index&plugin=blogconf','default_lang').'</label>'. 191 form::combo('p_default_lang',l10n::getISOcodes(1),dc_default_lang).'</p>'. 192 193 '<p class="field"><label for="p_theme"><strong>'.__('Blog theme').' :</strong> '. 194 helpLink('index&plugin=blogconf','theme').'</label>'. 195 form::combo('p_theme',$themes_list,dc_theme).'</p>'. 196 197 '<p class="field"><label for="p_allow_comments"><strong>'. 198 __('Allow comments').' :</strong> '. 199 helpLink('index&plugin=blogconf','allow_comments').'</label>'. 200 form::combo('p_allow_comments',array(__('yes')=>1,__('no')=>0),(integer) dc_allow_comments). 201 '</p>'. 202 203 '<p class="field"><label for="p_allow_trackbacks"><strong>'. 204 __('Allow trackbacks').' :</strong> '. 205 helpLink('index&plugin=blogconf','allow_trackbacks').'</label>'. 206 form::combo('p_allow_trackbacks',array(__('yes')=>1,__('no')=>0),(integer) dc_allow_trackbacks). 207 '</p>'. 208 209 '<p class="field"><label for="p_comments_pub"><strong>'. 210 __('Publish comments immediately').' :</strong> '. 211 helpLink('index&plugin=blogconf','comments_pub').'</label>'. 212 form::combo('p_comments_pub',array(__('yes')=>1,__('no')=>0),(integer) dc_comments_pub). 213 '</p>'. 214 '</fieldset>'. 215 216 '<fieldset><legend>'.__('Advanced configuration').'</legend>'. 217 218 '<p class="field"><label for="p_app_url"><strong>'.__('Application location').' :</strong> '. 219 '('.sprintf(__('From %s'),'http://'.$_SERVER['HTTP_HOST']).') '. 220 helpLink('index&plugin=blogconf','app_url').'</label>'. 221 form::field('p_app_url',40,'',htmlspecialchars(dc_app_url)).'</p>'. 222 223 '<p class="field"><label for="p_img_url"><strong>'.__('Images location').' :</strong> '. 224 '('.sprintf(__('From %s'),'http://'.$_SERVER['HTTP_HOST']).') '. 225 helpLink('index&plugin=blogconf','img_url').'</label>'. 226 form::field('p_img_url',40,'',htmlspecialchars(dc_img_url)).'</p>'. 227 228 '<p class="field"><label for="p_blog_rss"><strong>'.__('RSS feed location').' :</strong> '. 229 '('.sprintf(__('From %s'),'http://'.$_SERVER['HTTP_HOST']).') '. 230 helpLink('index&plugin=blogconf','blog_rss').'</label>'. 231 form::field('p_blog_rss',40,'',htmlspecialchars(dc_blog_rss)).'</p>'. 232 233 '<p class="field"><label for="p_blog_atom"><strong>'.__('Atom feed location').' :</strong> '. 234 '('.sprintf(__('From %s'),'http://'.$_SERVER['HTTP_HOST']).') '. 235 helpLink('index&plugin=blogconf','blog_atom').'</label>'. 236 form::field('p_blog_atom',40,'',htmlspecialchars(dc_blog_atom)).'</p>'. 237 238 '<p class="field"><label for="p_trackback_uri"><strong>'.__('Trackback URL').' :</strong> '. 239 '('.sprintf(__('From %s'),'http://'.$_SERVER['HTTP_HOST']).') '. 240 helpLink('index&plugin=blogconf','trackback_uri').'</label>'. 241 form::field('p_trackback_uri',40,'',htmlspecialchars(dc_trackback_uri)).'</p>'. 242 243 '<p class="field"><label for="p_url_scan"><strong>'. 244 __('URL type').' :</strong> '. 245 helpLink('index&plugin=blogconf','url_scan').'</label>'. 246 form::combo('p_url_scan',$scan_modes,dc_url_scan). 247 '</p>'. 248 249 '<p class="field"><label for="p_show_previews"><strong>'. 250 __('Preview entries in backend').' :</strong> '. 251 helpLink('index&plugin=blogconf','show_previews').'</label>'. 252 form::combo('p_show_previews',array(__('yes')=>1,__('no')=>0),(integer) dc_show_previews). 253 '</p>'. 254 255 '<p class="field"><label for="p_date_format"><strong>'.__('Date format').' :</strong> '. 256 helpLink('index&plugin=blogconf','time_format').'</label>'. 257 form::field('p_date_format',40,'',htmlspecialchars(dc_date_format)).'</p>'. 258 259 '<p class="field"><label for="p_time_format"><strong>'.__('Time format').' :</strong> '. 260 helpLink('index&plugin=blogconf','time_format').'</label>'. 261 form::field('p_time_format',40,'',htmlspecialchars(dc_time_format)).'</p>'. 262 263 '<p class="field"><label for="p_comments_ttl"><strong>'. 264 __('Time to live of comments and trackbacks').' :</strong> '. 265 helpLink('index&plugin=blogconf','comments_ttl').'</label>'. 266 form::field('p_comments_ttl',3,'',(string) dc_comments_ttl).'</p>'. 267 268 '<p class="field"><label for="p_use_smilies"><strong>'. 269 __('Show smileys in blog entries and comments').' :</strong> '. 270 helpLink('index&plugin=blogconf','use_smilies').'</label>'. 271 form::combo('p_use_smilies',array(__('yes')=>1,__('no')=>0),(integer) dc_use_smilies). 272 '</p>'. 273 274 '<p class="field"><label for="p_comment_notification"><strong>'. 275 __('Notify each new comment by email').' :</strong> '. 276 helpLink('index&plugin=blogconf','comment_notification').'</label>'. 277 form::combo('p_comment_notification',array(__('yes')=>1,__('no')=>0),(integer) dc_comment_notification). 278 '</p>'. 279 280 '<p class="field"><label for="p_short_feeds"><strong>'. 281 __('Short RSS and Atom feeds').' :</strong> '. 282 helpLink('index&plugin=blogconf','short_feeds').'</label>'. 283 form::combo('p_short_feeds',array(__('yes')=>1,__('no')=>0),(integer) dc_short_feeds). 284 '</p>'. 285 286 '<p class="field"><label for="p_http_cache"><strong>'. 287 __('Activate HTTP cache').' :</strong> '. 288 helpLink('index&plugin=blogconf','http_cache').'</label>'. 289 form::combo('p_http_cache',array(__('yes')=>1,__('no')=>0),(integer) dc_http_cache). 290 '</p>'. 291 '</fieldset>'. 292 293 '<p class="field"><input class="submit" type="submit" value="'.__('save').'" /></p>'. 294 '</form>' 295 ); 296 } 297 ?>
titre
Description
Corps
titre
Description
Corps
titre
Description
Corps
titre
Corps
Généré le : Fri Feb 23 21:40:15 2007 | par Balluche grâce à PHPXref 0.7 |