| [ PHPXref.com ] | [ Generated: Sun Jul 20 16:35:25 2008 ] | [ bBlog 0.7.6 ] |
| [ Index ] [ Variables ] [ Functions ] [ Classes ] [ Constants ] [ Statistics ] | ||
[Summary view] [Print] [Text view]
1 <?php 2 /* 3 ** bBlog Weblog http://www.bblog.com/ 4 ** Copyright (C) 2003 Eaden McKee <email@eadz.co.nz> 5 ** 6 ** This program is free software; you can redistribute it and/or modify 7 ** it under the terms of the GNU General Public License as published by 8 ** the Free Software Foundation; either version 2 of the License, or 9 ** (at your option) any later version. 10 ** 11 ** This program is distributed in the hope that it will be useful, 12 ** but WITHOUT ANY WARRANTY; without even the implied warranty of 13 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 ** GNU General Public License for more details. 15 ** 16 ** You should have received a copy of the GNU General Public License 17 ** along with this program; if not, write to the Free Software 18 ** Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 19 */ 20 21 function identify_admin_options () { 22 return array ( 23 'name' =>'options', 24 'type' =>'builtin', 25 'nicename' =>'Options', 26 'description' =>'Allows you to change options', 27 'authors' =>'Eaden McKee', 28 'licence' =>'GPL', 29 'help' =>'' 30 ); 31 } 32 33 34 function get_options () { 35 $options = array(); 36 37 $options = array( 38 array( 39 "name" => "EMAIL", 40 "label" => "Email Address", 41 "value" => C_EMAIL, 42 "type" => "email" 43 ), 44 45 array( 46 "name" => "BLOGNAME", 47 "label" => "Blog Name", 48 "value" => C_BLOGNAME, 49 "type" => "text" 50 ), 51 52 array( 53 "name" => "BLOG_DESCRIPTION", 54 "label" => "Blog Description", 55 "value" => C_BLOG_DESCRIPTION, 56 "type" => "text" 57 ), 58 59 array( 60 "name" => "TEMPLATE", 61 "label" => "Template", 62 "value" => C_TEMPLATE, 63 "type" => "templateselect" 64 ), 65 66 array( 67 "name" => "DEFAULT_MODIFIER", 68 "label" => "Default Modifier", 69 "value" => C_DEFAULT_MODIFIER, 70 "type" => "modifierselect" 71 ), 72 73 array( 74 "name" => "DEFAULT_STATUS", 75 "label" => "Default Post Status", 76 "value" => C_DEFAULT_STATUS, 77 "type" => "statusselect" 78 ), 79 array( 80 "name" => "CHARSET", 81 "label" => "Character Set", 82 "value" => C_CHARSET, 83 "type" => "charsetselect" 84 ), 85 86 array( 87 "name" => "DIRECTION", 88 "label" => "Writing/reading direction", 89 "value" => C_DIRECTION, 90 "type" => "directionselect" 91 ), 92 93 array( 94 "name" => "PING", 95 "label" => "Notify websites of new posts. seperate with comma, e.g. weblogs.com/RPC2,www.bblog.com/ping.php,blo.gs/", 96 "value" => C_PING, 97 "type" => "text" 98 ), 99 100 array( 101 "name" => "COMMENT_MODERATION", 102 "label" => "Require your approval before comments appear", 103 "value" => C_COMMENT_MODERATION, 104 "type" => "commentmoderation" 105 ), 106 107 array( 108 "name" => "NOTIFY", 109 "label" => "Send notifications via email for new comments", 110 "value" => C_NOTIFY, 111 "type" => "truefalse" 112 ), 113 array( 114 "name" => "META_KEYWORDS", 115 "label" => "META Keywords for search engines", 116 "value" => C_META_KEYWORDS, 117 "type" => "text" 118 ), 119 array( 120 "name" => "META_DESCRIPTION", 121 "label" => "META Description for search engines", 122 "value" => C_META_DESCRIPTION, 123 "type" => "text" 124 ), 125 array( 126 "name" => "COMMENT_TIME_LIMIT", 127 "label" => "Comment Flood Protection ( minutes ) Set to 0 to disable.", 128 "value" => C_COMMENT_TIME_LIMIT, 129 "type" => "text" 130 ) 131 132 133 ); 134 135 return $options; 136 } 137 138 $bBlog->get_modifiers(); 139 140 $optionformrows = array(); 141 142 $options = get_options(); 143 144 if ((isset($_POST['submit'])) && ($_POST['submit'] == 'Save Options')) { // saving options.. 145 $updatevars = array(); 146 foreach($options as $option) { 147 148 if(!isset($_POST[$option['name']])) break; 149 150 switch ($option['type']) { 151 case "text" : 152 case "email" : 153 case "url" : 154 $updatevars[] = array( 155 "name" =>$option['name'], 156 "value" => my_addslashes($_POST[$option['name']]) 157 ); 158 break; 159 case "password" : 160 if($_POST[$option['name']] != '') 161 162 $updatevars[] = array( 163 "name" => $option['name'], 164 "value" => md5($_POST[$option['name']]) 165 ); 166 break; 167 168 case "templateselect" : 169 // make sure we're not being poked. 170 if(ereg('^[[:alnum:]]+$',$_POST[$option['name']])) { 171 $updatevars[] = array( 172 "name" => $option['name'], 173 "value" => strtolower($_POST[$option['name']]) 174 ); 175 176 } 177 break; 178 179 case "statusselect" : 180 if($_POST[$option['name']] == 'live') 181 $updatevars[]= array( 182 "name" => $option['name'], 183 "value" => 'live' 184 ); 185 186 if($_POST[$option['name']] == 'draft') 187 $updatevars[]= array( 188 "name" => $option['name'], 189 "value" => 'draft' 190 ); 191 break; 192 193 case "charsetselect" : 194 //check all charsets 195 foreach ($charsets as $charset){ 196 //if submitted is one of our valid charsets 197 if ( $_POST[$option['name']] == $charset['value'] ){ 198 199 $updatevars[] = array( 200 "name" => $option['name'], 201 "value" => $charset['value'] 202 ); 203 204 }//if 205 }//foreach 206 break; 207 208 case "directionselect": 209 if($_POST[$option['name']] == 'LTR') 210 $updatevars[]= array( 211 "name" => $option['name'], 212 "value" => 'LTR' 213 ); 214 if($_POST[$option['name']] == 'RTL') 215 $updatevars[]= array( 216 "name" => $option['name'], 217 "value" => 'RTL' 218 ); 219 220 break; 221 222 223 case "commentmoderation" : 224 if($_POST[$option['name']] == 'none') 225 $updatevars[]= array( 226 "name" => $option['name'], 227 "value" => 'none' 228 ); 229 230 if($_POST[$option['name']] == 'all') 231 $updatevars[]= array( 232 "name" => $option['name'], 233 "value" => 'all' 234 ); 235 if($_POST[$option['name']] == 'urlonly') 236 $updatevars[]= array( 237 "name" => $option['name'], 238 "value" => 'urlonly' 239 ); 240 break; 241 242 case "modifierselect" : 243 if(ereg('^[[:alnum:]]+$',$_POST[$option['name']])) 244 $updatevars[] = array( 245 "name"=>$option['name'], 246 "value"=>$_POST[$option['name']] 247 ); 248 249 break; 250 case "truefalse" : 251 $updatevars[] = array( 252 "name"=>$option['name'], 253 "value"=>$_POST[$option['name']] 254 ); 255 break; 256 default: break; 257 258 259 } // switch 260 } // foreach 261 262 263 } // if 264 if ((isset($_POST['submit'])) && ($_POST['submit'] == 'Save Options')) { 265 foreach($updatevars as $update) { 266 $sql = "UPDATE ".T_CONFIG." SET VALUE='".$update['value']."' WHERE `name`='".$update['name']."'"; 267 /*echo "<pre>"; 268 var_dump($sql); 269 //var_dump($update); 270 echo "</pre>";*/ 271 $bBlog->query($sql); 272 } // foreach 273 $bBlog->assign("showmessage",TRUE); 274 $bBlog->assign("showoptions",'no'); 275 $bBlog->assign("message_title","Options Updated"); 276 $bBlog->assign("message_content","Your changes have been saved.<br><a href='index.php?b=options&r=".rand(20,214142124)."'>Click here to continue</a>"); 277 278 } else { 279 280 foreach($options as $option) { 281 $formleft = $option['label']; 282 switch ($option['type']) { 283 case "text" : 284 case "email" : 285 case "url" : 286 $formright = '<input type="text" name="'.$option['name'].'" 287 class="bf" value="'.$option['value'].'">'; 288 break; 289 290 case "password" : 291 $formright = '<input type="password" name="'.$option['name'].'" 292 class="bf" value="'.$option['value'].'">'; 293 break; 294 295 case "templateselect" : 296 $formright = '<select name="'.$option['name'].'" class="bf">'; 297 $d = dir("templates"); 298 while (false !== ($entry = $d->read())) { 299 if(ereg("^[a-z]{3,20}$",$entry)){ 300 $formright .= "<option value=\"$entry\""; 301 if($option['value'] == $entry) $formright .=" selected"; 302 $formright .= ">$entry</option>"; 303 } 304 } 305 $d->close(); 306 $formright .= '</select>'; 307 break; 308 309 case "charsetselect": 310 $formright = '<select name="'.$option['name'].'" class="bf">'; 311 foreach ($charsets as $charset){ 312 $formright .='<option value="'.$charset[value].'" '; 313 if ($charset[value] == C_CHARSET) $formright .='selected'; 314 $formright .='>'.$charset[description].'</option>'; 315 } 316 $formright .= '</select>'; 317 break; 318 319 case "directionselect": 320 $formright = '<select name="'.$option['name'].'" class="bf">'; 321 $formright .= '<option value="LTR"'; 322 if(C_DIRECTION == 'LTR') $formright .= 'selected'; 323 $formright .= '>LTR (default)</option>'; 324 325 $formright .='<option value="RTL"'; 326 if(C_DIRECTION == 'RTL') $formright .= 'selected'; 327 $formright .='>RTL (if supported by template)</option>'; 328 $formright .='</select>'; 329 330 break; 331 332 333 case "statusselect" : 334 $formright = '<select name="'.$option['name'].'" class="bf">'; 335 $formright .= '<option value="live" '; 336 if(C_DEFAULT_STATUS == 'live') $formright .= 'selected'; 337 $formright .= '>Live'.'</option>'; 338 $formright .= '<option value="draft" '; 339 if(C_DEFAULT_STATUS == 'draft') $formright .= 'selected'; 340 $formright .= '>Draft'.'</option>'; 341 $formright .= '</select>'; 342 break; 343 344 case "truefalse" : 345 $formright = '<select name="'.$option['name'].'" class="bf">'; 346 $formright .= '<option value="true" '; 347 if($option['value'] == 'true') $formright .= 'selected'; 348 $formright .= '>Yes'.'</option>'; 349 $formright .= '<option value="false" '; 350 if($option['value'] == 'false') $formright .= 'selected'; 351 $formright .= '>No'.'</option>'; 352 $formright .= '</select>'; 353 break; 354 355 case "modifierselect" : 356 $formright = '<select name="'.$option['name'].'" class="bf">'; 357 foreach($bBlog->modifiers as $mod) { 358 $formright .= '<option value="'.$mod->name.'" '; 359 if(C_DEFAULT_MODIFIER == $mod->name) $formright .= 'selected'; 360 $formright .= '>'.$mod->nicename.'</option>'; 361 } 362 $formright .= '</select>'; 363 break; 364 365 case "commentmoderation" : 366 $formright = '<select name="'.$option['name'].'" class="bf">'; 367 368 $formright .= '<option value="none" '; 369 if(C_COMMENT_MODERATION == 'none') $formright .= 'selected'; 370 $formright .= '>No Moderation (not recommended!)</option>'; 371 372 $formright .= '<option value="urlonly" '; 373 if(C_COMMENT_MODERATION == 'urlonly') $formright .= 'selected'; 374 $formright .= '>Only for comments with links (recommended)</option>'; 375 376 $formright .= '<option value="all" '; 377 if(C_COMMENT_MODERATION == 'all') $formright .= 'selected'; 378 $formright .= '>Moderate All Comments</option>'; 379 380 381 $formright .= '</select>'; 382 break; 383 384 default: $formright = ''; break; 385 386 } 387 $optionrows[] = array("left" => $formleft,"right" => $formright); 388 // have help here too someday :) 389 390 391 } 392 $bBlog->assign("optionrows",$optionrows); 393 } // end of else 394 $bBlog->display("options.html"); 395 396 397 398 399 400 401 402 403 ?>
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
| [ Powered by PHPXref - Served by Debian GNU/Linux ] |