[ Index ] |
PHP Cross Reference of phpwcms V1.4.3 _r380 (23.11.09) |
[Summary view] [Print] [Text view]
1 <?php 2 /************************************************************************************* 3 Copyright notice 4 5 (c) 2002-2009 Oliver Georgi (oliver@phpwcms.de) // All rights reserved. 6 7 This script is part of PHPWCMS. The PHPWCMS web content management system is 8 free software; you can redistribute it and/or modify it under the terms of 9 the GNU General Public License as published by the Free Software Foundation; 10 either version 2 of the License, or (at your option) any later version. 11 12 The GNU General Public License can be found at http://www.gnu.org/copyleft/gpl.html 13 A copy is found in the textfile GPL.txt and important notices to the license 14 from the author is found in LICENSE.txt distributed with these scripts. 15 16 This script is distributed in the hope that it will be useful, but WITHOUT ANY 17 WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A 18 PARTICULAR PURPOSE. See the GNU General Public License for more details. 19 20 This copyright notice MUST APPEAR in all copies of the script! 21 *************************************************************************************/ 22 23 ?> 24 <h1><span class="number">3.</span> MySQL database settings </h1> 25 <?php 26 if(isset($_POST["dbsavesubmit"]) && $err) { 27 echo errorWarning('Please proof your database settings!'); 28 $_SESSION['admin_set'] = false; 29 } 30 ?> 31 <form action="setup.php?step=1" method="post" autocomplete="off"> 32 <table border="0" cellpadding="0" cellspacing="0" summary=""> 33 <tr> 34 <td align="right" class="v10" width="120">MySQL host: </td> 35 <td width="270"><input name="db_host" type="text" class="v12" id="db_host" value="<?php echo html_specialchars($phpwcms["db_host"]) ?>" size="30" style="width:250px" /></td> 36 <td class="chatlist"><em>default: localhost</em></td> 37 </tr> 38 <tr><td colspan="3"><img src="../img/leer.gif" alt="" width="1" height="4" /></td> 39 </tr> 40 <tr> 41 <td align="right" class="v10">DB user: </td> 42 <td><input name="db_user" type="text" class="v12" id="db_user" style="width:250px" value="<?php echo html_specialchars($phpwcms["db_user"]) ?>" size="30" /></td> 43 <td class="chatlist"> </td> 44 </tr> 45 <tr><td colspan="3"><img src="../img/leer.gif" alt="" width="1" height="4" /></td> 46 </tr> 47 <tr> 48 <td align="right" class="v10">DB password: </td> 49 <td><input name="db_pass" type="text" class="v12" id="db_pass" style="width:250px" value="<?php echo html_specialchars($phpwcms["db_pass"]) ?>" size="30" /></td> 50 <td class="chatlist"> </td> 51 </tr> 52 <tr><td colspan="3"><img src="../img/leer.gif" alt="" width="1" height="4" /></td> 53 </tr> 54 <tr> 55 <td align="right" class="v10">DB database: </td> 56 <td><input name="db_table" type="text" class="v12" id="db_table" style="width:250px" value="<?php echo html_specialchars($phpwcms["db_table"]) ?>" size="30" maxlength="255" /></td> 57 <td class="chatlist"><em>you have to create it <strong>before</strong> setup!!!</em></td> 58 </tr> 59 <tr><td colspan="3"><img src="../img/leer.gif" alt="" width="1" height="4" /></td> 60 </tr> 61 <tr> 62 <td align="right" class="v10">DB table prefix: </td> 63 <td><input name="db_prepend" type="text" class="v12" id="db_prepend" style="width:250px" value="<?php echo html_specialchars($prepend) ?>" size="30" maxlength="10" /></td> 64 <td class="chatlist"><em>default: none (""), if filled 65 in it will be <strong>prefix</strong>+<strong>_</strong></em></td> 66 </tr> 67 <tr><td colspan="3"><img src="../img/leer.gif" alt="" width="1" height="6" /></td> 68 </tr> 69 <tr> 70 <td align="right" class="v10"> </td> 71 <td><table border="0" cellpadding="0" cellspacing="0" summary=""> 72 <tr> 73 <td><input name="db_pers" type="checkbox" id="db_pers" value="1" <?php echo ($phpwcms["db_pers"]) ? "checked" : ""; ?> /></td> 74 <td><label for="db_pers" class="v12"> use persistent database connection </label></td> 75 </tr> 76 </table></td> 77 <td class="chatlist"><em>recommend setting is to enable it</em></td> 78 </tr> 79 80 <?php 81 if(!empty($db_additional)) { 82 83 ?> 84 <tr><td colspan="3" style="padding: 10px 0 10px 0;"><h1><span class="number">4.</span> Charset & MySQL <span class="v11">(v<?php echo html_specialchars($row[0]) ?>)</span> collation 85 settings <a href="http://dev.mysql.com/doc/refman/4.1/en/charset.html" target="_blank" title="MySQL information"><img src="../img/famfamfam/icon_info.gif" alt="Info" border="0" class="icon" /></a></h1></td></tr> 86 <tr> 87 <td align="right" class="v10"><a href="http://www.w3.org/International/O-HTTP-charset" target="_blank" title="HTTP charset"><img src="../img/famfamfam/icon_info.gif" alt="Info" border="0" class="icon1" /></a>Charset: </td> 88 <td colspan="2"><select name="charset"> 89 90 <?php 91 92 if($phpwcms['db_version'] < 40100) { 93 $_availableCharsets = _dbQuery("SHOW VARIABLES LIKE 'character_sets'", 'ROW'); 94 if(isset($_availableCharsets[0][1])) { 95 $_availableCharsets = $_availableCharsets[0][1]; 96 $_availableCharsets = str_replace('_', '', $_availableCharsets); 97 $_availableCharsets = strtolower($_availableCharsets); 98 $_availableCharsets = explode(' ', $_availableCharsets); 99 } 100 } 101 102 103 foreach($available_languages as $key => $value) { 104 105 list(, $_lang_charset) = explode('-', $value[1], 2); 106 list(, $_lang_en) = explode('|', $value[0]); 107 108 if($phpwcms['db_version'] < 40100 && !in_array($mysql_charset_map[$_lang_charset], $_availableCharsets)) continue; 109 110 echo '<option value="'.$key.'"'; 111 112 if($key == strtolower(str_replace('-', '', $phpwcms['default_lang']) .'-'. $phpwcms['charset'])) { 113 echo ' selected="selected"'; 114 } 115 116 echo '>'; 117 echo empty($value[3]) ? '' : $value[3].' - '; 118 echo ucfirst($_lang_en); 119 echo ' ['.$_lang_charset; 120 if(!empty($mysql_charset_map[$_lang_charset])) { 121 echo ' / '.$mysql_charset_map[$_lang_charset]; 122 } 123 echo ']'; 124 echo "</option>\n"; 125 126 127 } 128 129 ?> 130 </select></td> 131 </tr> 132 <?php 133 134 // collation setting 135 if($phpwcms['db_version'] > 40100) { 136 137 $_collation = array(); 138 $_collation_selected = false; 139 140 echo '<tr><td colspan="3"><img src="../img/leer.gif" alt="" width="1" height="6"></td></tr>'; 141 142 143 // make db connect 144 if(empty($db)) { 145 $db = @mysql_connect($phpwcms["db_host"], $phpwcms["db_user"], $phpwcms["db_pass"]); 146 @mysql_select_db($phpwcms["db_table"], $db); 147 } 148 if($result = mysql_query("SHOW COLLATION", $db)) { 149 150 while($row = mysql_fetch_assoc($result)) { 151 152 if(in_array($row['Charset'], $mysql_charset_map)) { 153 if($phpwcms['db_collation']==$row['Collation']) { 154 $_collation_selected = true; 155 $_collation[ $row['Charset'] ][ $row['Collation'] ] = true; 156 } else { 157 $_collation[ $row['Charset'] ][ $row['Collation'] ] = false; 158 } 159 } 160 161 } 162 163 ksort($_collation); 164 165 } 166 167 168 // warn again 169 if(isset($_collation_warning) && $_collation_warning === true) { 170 171 echo '<tr><td> </td><td colspan="2">'.errorWarning('Proof collation again!').'</td></tr>'; 172 $_SESSION['admin_set'] = false; 173 174 } 175 176 177 ?> 178 179 <tr> 180 <td align="right" class="v10">MySQL Collation: </td> 181 <td colspan="2"><select name="collation"> 182 <?php 183 184 foreach($_collation as $key => $value) { 185 186 ksort($value); 187 188 echo ' <optgroup label="'.$key.'" style="margin-bottom:5px;">'. "\n"; 189 190 foreach($value as $colkey => $status) { 191 192 echo ' <option value="'.$colkey.'"'; 193 if($status) { 194 echo ' selected="selected" style="color:#009900;font-weight:bold;"'; 195 } 196 echo '>'.$colkey.'</option>'. "\n"; 197 198 } 199 200 echo ' </optgroup>' . "\n"; 201 202 } 203 204 205 206 ?> 207 </select></td> 208 </tr> 209 210 211 212 <?php 213 214 } 215 216 } 217 218 // now show setting which enables creating database 219 if(!empty($db_init)) { 220 221 ?> 222 <tr><td colspan="3" style="padding: 10px 0 10px 0;"><h1><span class="number">5.</span> Default phpwcms database 223 schema</h1></td></tr> 224 <?php 225 226 227 228 if(empty($db_no_create) && !empty($_db_prepend_error) && isset($_POST['db_sql_hidden'])) { 229 echo '<tr><td> </td><td colspan="2">'; 230 echo errorWarning('phpwcms tables still exists in choosen database. Rename table prefix might help!'); 231 echo "</td></tr>\n"; 232 $_SESSION['admin_set'] = false; 233 } 234 if(isset($db_create_err) && count($db_create_err)) { 235 echo '<tr><td> </td><td colspan="2">'; 236 echo errorWarning('Errors while creating initial phpwcms tables. Solve it manually:</b></p><pre class="errorBox">'.html_specialchars(implode(";\n\n", $db_create_err).';').'</pre><p><b> '); 237 echo "</td></tr>\n"; 238 239 $_SESSION['admin_set'] = false; 240 $sql_data = false; 241 $db_sql = false; 242 243 } elseif(isset($db_create_err) || !empty($db_no_create)) { 244 245 // OK fine - initial tables were created without error 246 $_db_prepend = ($phpwcms["db_prepend"] ? $phpwcms["db_prepend"].'_' : ''); 247 $check = _dbQuery("SHOW TABLES LIKE '".$_db_prepend."phpwcms_%'"); 248 249 if($check && count($check)) { 250 251 $sql_data = false; 252 $db_sql = false; 253 $db_fine = true; 254 255 ?> 256 <tr> 257 <td align="right" class="v10"> </td> 258 <td colspan="2"><img src="../img/famfamfam/icon_accept.gif" alt="Juchu" class="icon1" /><strong>Fine!</strong> All initial phpwcms tables were created or still exists.<input type="hidden" name="db_sql_hidden" value="1" /></td> 259 </tr> 260 <?php 261 262 } else { 263 264 $_SESSION['admin_set'] = false; 265 266 $sql_data = false; 267 $db_sql = false; 268 269 echo '<tr><td> </td><td colspan="2">'; 270 echo errorWarning('No phpwcms database table exists. Check before you continue!'); 271 echo '<input type="hidden" name="db_sql_hidden" value="1" />'; 272 echo "</td></tr>\n"; 273 274 } 275 276 } 277 278 279 if(empty($db_fine)) { 280 // show info 281 282 ?> 283 <tr> 284 <td align="right" class="v10"> </td> 285 <td><table border="0" cellpadding="0" cellspacing="0" summary=""> 286 <tr> 287 <td><input name="db_sql" type="checkbox" id="db_sql" value="1"<?php if(!empty($db_sql)) echo ' checked="checked"' ?> /></td> 288 <td><label for="db_sql" class="v12"> create phpwcms db tables </label><input type="hidden" name="db_sql_hidden" value="1" /></td> 289 </tr> 290 </table></td> 291 <td class="chatlist"> </td> 292 </tr> 293 294 <?php 295 296 } 297 298 if(!empty($sql_data)) { 299 300 $sql_data = explode(';', $sql_data); 301 $c = 0; 302 foreach($sql_data as $key => $value) { 303 304 $value = trim($value); 305 306 if(empty($value)) { 307 unset($sql_data[$key]); 308 continue; 309 } 310 311 $value = html_specialchars($value); 312 $value = str_replace(' ', ' ', $value); 313 $value = nl2br($value); 314 315 $sql_data[$key] = '<div style="margin:0;padding:0 5px 0 5px;'; 316 if($c % 2) { 317 $sql_data[$key] .= ';background-color:#F6F8FA;'; 318 } 319 $sql_data[$key] .= '"><p>'.$value; 320 321 if($phpwcms['db_version'] > 40100 && strpos(strtoupper(trim($value)), 'INSERT') !== 0) { 322 $sql_data[$key] .= ' DEFAULT'; 323 $sql_data[$key] .= ' CHARACTER SET '.$phpwcms['db_charset']; 324 $sql_data[$key] .= ' COLLATE '.$phpwcms['db_collation']; 325 } 326 327 $sql_data[$key] .= ' ;</p></div>'; 328 $c++; 329 } 330 331 $sql_data = implode("\n", $sql_data); 332 333 echo '<tr><td> '; 334 if(empty($_db_prepend_error) && isset($_POST['db_sql_hidden'])) { 335 echo '<input type="hidden" name="db_create" value="1" />'; 336 } 337 echo '</td><td colspan="2">'; 338 echo '<div id="license" style="width:550px">'; 339 echo $sql_data; 340 echo "</div></td></tr>\n"; 341 342 } 343 } 344 345 346 // OK now lets create superuser 347 if(!empty($_SESSION['admin_set'])) { 348 349 ?> 350 <tr><td colspan="3" style="padding: 10px 0 10px 0;"><h1><span class="number">6.</span> Superuser settings</h1></td></tr> 351 <?php 352 353 // as long as admin info wasn't written 354 if(empty($_SESSION['admin_save'])) { 355 356 ?> 357 <tr> 358 <td align="right" class="v10">Name: </td> 359 <td><input name="admin_name" type="text" id="admin_name" class="v12" style="width:250px" value="<?php echo empty($phpwcms["admin_name"]) ? "Webmaster" : html_specialchars($phpwcms["admin_name"]) ?>" size="30" /></td> 360 <td class="chatlist"><em> default: Webmaster</em></td> 361 </tr> 362 363 <tr><td colspan="3"><img src="../img/leer.gif" alt="" width="1" height="4" /></td> 364 </tr> 365 366 <tr> 367 <td align="right" class="v10">Admin login: </td> 368 <td><input name="admin_user" type="text" id="admin_user" class="v12" style="width:250px" value="<?php echo empty($phpwcms["admin_user"]) ? "webmaster" : html_specialchars($phpwcms["admin_user"]) ?>" size="30" /></td> 369 <td class="chatlist"><em> default: admin </em></td> 370 </tr> 371 372 <tr><td colspan="3"><img src="../img/leer.gif" alt="" width="1" height="4" /></td></tr> 373 374 <?php 375 if(!empty($admin_err_pass)) { 376 echo '<tr><td> </td><td colspan="2">'; 377 echo errorWarning('Invalid password! Password is case senitive, empty password not allowed.'); 378 echo "</td></tr>\n"; 379 } 380 ?> 381 382 <tr> 383 <td align="right" class="v10">Admin password: </td> 384 <td><input name="admin_pass" type="password" id="admin_pass" class="v12" style="width:250px" size="30" autocomplete="off" /></td> 385 <td class="chatlist"><em> default: phpwcms </em></td> 386 </tr> 387 388 <tr><td colspan="3"><img src="../img/leer.gif" alt="" width="1" height="4" /></td> 389 </tr> 390 391 <tr> 392 <td align="right" class="v10">Repeat password: </td> 393 <td><input name="admin_passrepeat" type="password" id="admin_passrepeat" class="v12" style="width:250px" size="30" autocomplete="off" /></td> 394 <td class="chatlist"><em> </em></td> 395 </tr> 396 397 <tr><td colspan="3"><img src="../img/leer.gif" alt="" width="1" height="4" /></td> 398 </tr> 399 400 <tr> 401 <td align="right" class="v10">Admin email: </td> 402 <td><input name="admin_email" type="text" id="admin_email" class="v12" style="width:250px" value="<?php echo html_specialchars($phpwcms["admin_email"]) ?>" size="30" /></td> 403 <td class="chatlist"><em> is used site wide</em></td> 404 </tr> 405 <?php 406 407 } else { 408 409 $_db_prepend = ($phpwcms["db_prepend"] ? $phpwcms["db_prepend"].'_' : ''); 410 411 //show Info that admin info was saved 412 //and also if stored in database 413 414 $user_check = _dbQuery('SELECT * FROM '.$_db_prepend."phpwcms_user WHERE usr_login='".aporeplace($phpwcms['admin_user'])."'"); 415 416 if($user_check !== false && count($user_check)) { 417 418 //hm user still exists - so try to update 419 $sql = "UPDATE ".$_db_prepend."phpwcms_user SET "; 420 $sql .= "usr_login = '".aporeplace($phpwcms['admin_user'])."', "; 421 $sql .= "usr_pass = '".aporeplace($phpwcms["admin_pass"])."', "; 422 $sql .= "usr_email = '".aporeplace($phpwcms["admin_email"])."', "; 423 $sql .= "usr_admin = 1, "; 424 $sql .= "usr_aktiv = 1, "; 425 $sql .= "usr_name = '".aporeplace($phpwcms['admin_name'])."', "; 426 $sql .= "usr_lang = '".aporeplace($phpwcms['default_lang'])."', "; 427 $sql .= "usr_wysiwyg = 2, "; 428 $sql .= "usr_fe = 2 "; 429 $sql .= "WHERE usr_login='".aporeplace($phpwcms['admin_user'])."' LIMIT 1"; 430 431 $update_user = _dbQuery($sql, 'UPDATE'); 432 433 434 } elseif($user_check !== false) { 435 436 //fine lets create new user 437 $sql = "INSERT INTO ".$_db_prepend."phpwcms_user ("; 438 $sql .= "usr_login, usr_pass, usr_email, "; 439 $sql .= "usr_admin, usr_aktiv, usr_name, "; 440 $sql .= "usr_lang, usr_wysiwyg, usr_fe"; 441 $sql .= ") VALUES ("; 442 $sql .= "'".aporeplace($phpwcms['admin_user'])."', "; 443 $sql .= "'".aporeplace($phpwcms["admin_pass"])."', "; 444 $sql .= "'".aporeplace($phpwcms["admin_email"])."', "; 445 $sql .= "1, 1, "; 446 $sql .= "'".aporeplace($phpwcms['admin_name'])."', "; 447 $sql .= "'".aporeplace($phpwcms['default_lang'])."', "; 448 $sql .= "2, 2"; 449 $sql .= ")"; 450 451 $create_user = _dbQuery($sql, 'INSERT'); 452 453 454 } 455 456 echo '<tr><td> </td><td colspan="2">'; 457 458 if(!empty($create_user)) { 459 460 // update 461 echo '<img src="../img/famfamfam/icon_accept.gif" alt="Juchu" class="icon1" />'; 462 echo '<strong>Done!</strong> Account for user <b>'.html_specialchars($phpwcms['admin_user']).'</b> was created.'; 463 echo '<input type="hidden" name="user_account" value="1" />'; 464 465 } 466 467 if(!empty($update_user)) { 468 469 // update 470 echo '<img src="../img/famfamfam/icon_accept.gif" alt="Juchu" class="icon1" />'; 471 echo '<strong>Done!</strong> Account of user <b>'.html_specialchars($phpwcms['admin_user']).'</b> was updated.'; 472 echo '<input type="hidden" name="user_account" value="1" />'; 473 474 } 475 476 if($user_check === false) { 477 478 // db error 479 echo errorWarning('There is a database problem!'); 480 echo '<p>Account for user <b>'.html_specialchars($phpwcms['admin_user']).'</b> was not created or updated.<br />Click <b>continue</b> to try again.</p>'; 481 $_SESSION['admin_save'] = false; 482 483 } 484 485 486 echo '</td></tr>'; 487 488 489 490 } 491 492 } 493 494 495 ?> 496 <tr><td colspan="3"><img src="../img/leer.gif" alt="" width="1" height="15" /></td> 497 </tr> 498 <tr> 499 <td align="right" class="v10"> </td> 500 <td colspan="2"><input name="dbsavesubmit" type="submit" value="Continue" /></td> 501 </tr> 502 </table><input name="do" type="hidden" value="1" /></form>
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Wed Dec 30 05:55:15 2009 | Cross-referenced by PHPXref 0.7 |