| [ Index ] |
|
Code source de XOOPS 2.0.17.1 |
1 <?php 2 // ------------------------------------------------------------------------ // 3 // XOOPS - PHP Content Management System // 4 // Copyright (c) 2000 XOOPS.org // 5 // <http://www.xoops.org/> // 6 // ------------------------------------------------------------------------ // 7 // This program 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 // You may not change or alter any portion of this comment or credits // 13 // of supporting developers from this source code or any supporting // 14 // source code which is considered copyrighted (c) material of the // 15 // original comment or credit authors. // 16 // // 17 // This program is distributed in the hope that it will be useful, // 18 // but WITHOUT ANY WARRANTY; without even the implied warranty of // 19 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // 20 // GNU General Public License for more details. // 21 // // 22 // You should have received a copy of the GNU General Public License // 23 // along with this program; if not, write to the Free Software // 24 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // 25 // ------------------------------------------------------------------------ // 26 include_once './class/textsanitizer.php'; 27 28 /** 29 * setting manager for XOOPS installer 30 * 31 * @author Haruki Setoyama <haruki@planewave.org> 32 * @version $Id: settingmanager.php 694 2006-09-04 11:33:22Z skalpa $ 33 * @access public 34 **/ 35 class setting_manager { 36 37 var $database; 38 var $dbhost; 39 var $dbuname; 40 var $dbpass; 41 var $dbname; 42 var $prefix; 43 var $db_pconnect; 44 var $root_path; 45 var $xoops_url; 46 47 var $sanitizer; 48 49 function setting_manager($post=false){ 50 51 $this->sanitizer =& TextSanitizer::getInstance(); 52 if($post){ 53 $this->readPost(); 54 }else{ 55 $this->database = 'mysql'; 56 $this->dbhost = 'localhost'; 57 $this->prefix = 'xoops'; 58 $this->db_pconnect = 0; 59 60 $this->root_path = str_replace("\\","/",getcwd()); // " 61 $this->root_path = str_replace("/install", "", $this->root_path); 62 63 $filepath = (! empty($_SERVER['REQUEST_URI'])) 64 ? dirname($_SERVER['REQUEST_URI']) 65 : dirname($_SERVER['SCRIPT_NAME']); 66 67 $filepath = str_replace("\\", "/", $filepath); // " 68 $filepath = str_replace("/install", "", $filepath); 69 if ( substr($filepath, 0, 1) == "/" ) { 70 $filepath = substr($filepath,1); 71 } 72 if ( substr($filepath, -1) == "/" ) { 73 $filepath = substr($filepath, 0, -1); 74 } 75 $protocol = (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on') ? 'https://' : 'http://'; 76 $this->xoops_url = (!empty($filepath)) ? $protocol.$_SERVER['HTTP_HOST']."/".$filepath : $protocol.$_SERVER['HTTP_HOST']; 77 } 78 } 79 80 function readPost(){ 81 if(isset($_POST['database'])) 82 $this->database = $this->sanitizer->stripSlashesGPC($_POST['database']); 83 if(isset($_POST['dbhost'])) 84 $this->dbhost = $this->sanitizer->stripSlashesGPC($_POST['dbhost']); 85 if(isset($_POST['dbuname'])) 86 $this->dbuname = $this->sanitizer->stripSlashesGPC($_POST['dbuname']); 87 if(isset($_POST['dbpass'])) 88 $this->dbpass = $this->sanitizer->stripSlashesGPC($_POST['dbpass']); 89 if(isset($_POST['dbname'])) 90 $this->dbname = $this->sanitizer->stripSlashesGPC($_POST['dbname']); 91 if(isset($_POST['prefix'])) 92 $this->prefix = $this->sanitizer->stripSlashesGPC($_POST['prefix']); 93 if(isset($_POST['db_pconnect'])) 94 $this->db_pconnect = intval($_POST['db_pconnect']) > 0 ? 1 : 0; 95 if(isset($_POST['root_path'])) 96 $this->root_path = $this->sanitizer->stripSlashesGPC($_POST['root_path']); 97 if(isset($_POST['xoops_url'])) 98 $this->xoops_url = $this->sanitizer->stripSlashesGPC($_POST['xoops_url']); 99 } 100 101 function readConstant(){ 102 if(defined('XOOPS_DB_TYPE')) 103 $this->database = XOOPS_DB_TYPE; 104 if(defined('XOOPS_DB_HOST')) 105 $this->dbhost = XOOPS_DB_HOST; 106 if(defined('XOOPS_DB_USER')) 107 $this->dbuname = XOOPS_DB_USER; 108 if(defined('XOOPS_DB_PASS')) 109 $this->dbpass = XOOPS_DB_PASS; 110 if(defined('XOOPS_DB_NAME')) 111 $this->dbname = XOOPS_DB_NAME; 112 if(defined('XOOPS_DB_PREFIX')) 113 $this->prefix = XOOPS_DB_PREFIX; 114 if(defined('XOOPS_DB_PCONNECT')) 115 $this->db_pconnect = intval(XOOPS_DB_PCONNECT) > 0 ? 1 : 0; 116 if(defined('XOOPS_ROOT_PATH')) 117 $this->root_path = XOOPS_ROOT_PATH; 118 if(defined('XOOPS_URL')) 119 $this->xoops_url = XOOPS_URL; 120 } 121 122 function checkData(){ 123 $ret = ''; 124 $error = array(); 125 126 if ( empty($this->dbhost) ) { 127 $error[] = sprintf(_INSTALL_L57, _INSTALL_L27); 128 } 129 if ( empty($this->dbname) ) { 130 $error[] = sprintf(_INSTALL_L57, _INSTALL_L29); 131 } 132 if ( empty($this->prefix) ) { 133 $error[] = sprintf(_INSTALL_L57, _INSTALL_L30); 134 } 135 if ( empty($this->root_path) ) { 136 $error[] = sprintf(_INSTALL_L57, _INSTALL_L55); 137 } 138 if ( empty($this->xoops_url) ) { 139 $error[] = sprintf(_INSTALL_L57, _INSTALL_L56); 140 } 141 142 if (!empty($error)) { 143 foreach ( $error as $err ) { 144 $ret .= "<p><span style='color:#ff0000;'><b>".$err."</b></span></p>\n"; 145 } 146 } 147 148 return $ret; 149 } 150 151 function editform(){ 152 $ret = 153 "<table width='100%' class='outer' cellspacing='5'> 154 <tr> 155 <th colspan='2'></th> 156 </tr> 157 <tr valign='top' align='left'> 158 <td class='head'> 159 <b>"._INSTALL_L51."</b><br /> 160 <span style='font-size:85%;'>"._INSTALL_L66."</span> 161 </td> 162 <td class='even'> 163 <select size='1' name='database' id='database'>"; 164 $dblist = $this->getDBList(); 165 foreach($dblist as $val){ 166 $ret .= "<option value='$val'"; 167 if($val == $this->database) $ret .= " selected='selected'"; 168 $ret .= "'>$val</option>"; 169 } 170 $ret .= "</select> 171 </td> 172 </tr> 173 "; 174 $ret .= $this->editform_sub(_INSTALL_L27, _INSTALL_L67, 'dbhost', $this->sanitizer->htmlSpecialChars($this->dbhost)); 175 $ret .= $this->editform_sub(_INSTALL_L28, _INSTALL_L65, 'dbuname', $this->sanitizer->htmlSpecialChars($this->dbuname)); 176 $ret .= $this->editform_sub(_INSTALL_L52, _INSTALL_L68, 'dbpass', $this->sanitizer->htmlSpecialChars($this->dbpass)); 177 $ret .= $this->editform_sub(_INSTALL_L29, _INSTALL_L64, 'dbname', $this->sanitizer->htmlSpecialChars($this->dbname)); 178 $ret .= $this->editform_sub(_INSTALL_L30, _INSTALL_L63, 'prefix', $this->sanitizer->htmlSpecialChars($this->prefix)); 179 180 $ret .= "<tr valign='top' align='left'> 181 <td class='head'> 182 <b>"._INSTALL_L54."</b><br /> 183 <span style='font-size:85%;'>"._INSTALL_L69."</span> 184 </td> 185 <td class='even'> 186 <input type='radio' name='db_pconnect' value='1'".($this->db_pconnect == 1 ? " checked='checked'" : "" )." />"._INSTALL_L23." 187 <input type='radio' name='db_pconnect' value='0'".($this->db_pconnect != 1 ? " checked='checked'" : "" )." />"._INSTALL_L24." 188 </td> 189 </tr> 190 "; 191 192 $ret .= $this->editform_sub(_INSTALL_L55, _INSTALL_L59, 'root_path', $this->sanitizer->htmlSpecialChars($this->root_path)); 193 $ret .= $this->editform_sub(_INSTALL_L56, _INSTALL_L58, 'xoops_url', $this->sanitizer->htmlSpecialChars($this->xoops_url)); 194 195 $ret .= "</table>"; 196 return $ret; 197 } 198 199 function editform_sub($title, $desc, $name, $value) { 200 $inputType = 'text'; 201 return "<tr valign='top' align='left'> 202 <td class='head'> 203 <b>".$title."</b><br /> 204 <span style='font-size:85%;'>".$desc."</span> 205 </td> 206 <td class='even'> 207 <input type='$inputType' name='".$name."' id='".$name."' size='30' maxlength='100' value='".htmlspecialchars($value)."' /> 208 </td> 209 </tr> 210 "; 211 } 212 213 function confirmForm(){ 214 $yesno = empty($this->db_pconnect) ? _INSTALL_L24 : _INSTALL_L23; 215 $ret = 216 "<table border='0' cellpadding='0' cellspacing='0' valign='top' width='90%'><tr><td class='bg2'> 217 <table width='100%' border='0' cellpadding='4' cellspacing='1'> 218 <tr> 219 <td class='bg3'><b>"._INSTALL_L51."</b></td> 220 <td class='bg1'>".$this->sanitizer->htmlSpecialChars($this->database)."</td> 221 </tr> 222 <tr> 223 <td class='bg3'><b>"._INSTALL_L27."</b></td> 224 <td class='bg1'>".$this->sanitizer->htmlSpecialChars($this->dbhost)."</td> 225 </tr> 226 <tr> 227 <td class='bg3'><b>"._INSTALL_L28."</b></td> 228 <td class='bg1'>".$this->sanitizer->htmlSpecialChars($this->dbuname)."</td> 229 </tr> 230 <tr> 231 <td class='bg3'><b>"._INSTALL_L52."</b></td> 232 <td class='bg1'>".$this->sanitizer->htmlSpecialChars($this->dbpass)."</td> 233 </tr> 234 <tr> 235 <td class='bg3'><b>"._INSTALL_L29."</b></td> 236 <td class='bg1'>".$this->sanitizer->htmlSpecialChars($this->dbname)."</td> 237 </tr> 238 <tr> 239 <td class='bg3'><b>"._INSTALL_L30."</b></td> 240 <td class='bg1'>".$this->sanitizer->htmlSpecialChars($this->prefix)."</td> 241 </tr> 242 <tr> 243 <td class='bg3'><b>"._INSTALL_L54."</b></td> 244 <td class='bg1'>".$yesno."</td> 245 </tr> 246 <tr> 247 <td class='bg3'><b>"._INSTALL_L55."</b></td> 248 <td class='bg1'>".$this->sanitizer->htmlSpecialChars($this->root_path)."</td> 249 </tr> 250 <tr> 251 <td class='bg3'><b>"._INSTALL_L56."</b></td> 252 <td class='bg1'>".$this->sanitizer->htmlSpecialChars($this->xoops_url)."</td> 253 </tr> 254 </table></td></tr> 255 </table> 256 <input type='hidden' name='database' value='".$this->sanitizer->htmlSpecialChars($this->database)."' /> 257 <input type='hidden' name='dbhost' value='".$this->sanitizer->htmlSpecialChars($this->dbhost)."' /> 258 <input type='hidden' name='dbuname' value='".$this->sanitizer->htmlSpecialChars($this->dbuname)."' /> 259 <input type='hidden' name='dbpass' value='".$this->sanitizer->htmlSpecialChars($this->dbpass)."' /> 260 <input type='hidden' name='dbname' value='".$this->sanitizer->htmlSpecialChars($this->dbname)."' /> 261 <input type='hidden' name='prefix' value='".$this->sanitizer->htmlSpecialChars($this->prefix)."' /> 262 <input type='hidden' name='db_pconnect' value='".intval($this->db_pconnect)."' /> 263 <input type='hidden' name='root_path' value='".$this->sanitizer->htmlSpecialChars($this->root_path)."' /> 264 <input type='hidden' name='xoops_url' value='".$this->sanitizer->htmlSpecialChars($this->xoops_url)."' /> 265 "; 266 return $ret; 267 } 268 269 270 function getDBList() 271 { 272 return array('mysql'); 273 //$dirname = '../class/database/'; 274 //$dirlist = array(); 275 //if (is_dir($dirname) && $handle = opendir($dirname)) { 276 // while (false !== ($file = readdir($handle))) { 277 // if ( !preg_match("/^[.]{1,2}$/",$file) ) { 278 // if (strtolower($file) != 'cvs' && is_dir($dirname.$file) ) { 279 // $dirlist[$file] = strtolower($file); 280 // } 281 // } 282 // } 283 // closedir($handle); 284 // asort($dirlist); 285 // reset($dirlist); 286 //} 287 //return $dirlist; 288 } 289 } 290 291 292 ?>
titre
Description
Corps
titre
Description
Corps
titre
Description
Corps
titre
Corps
| Généré le : Sun Nov 25 11:44:32 2007 | par Balluche grâce à PHPXref 0.7 |
|