File: lib/config/setup.php

Recommend this page to a friend!
  Classes of Luke Rotherfield  >  Nibble PHP Framework  >  lib/config/setup.php  >  Download  
File: lib/config/setup.php
Role: Application script
Content type: text/plain
Description: Install script for Nibble Framework
Class: Nibble PHP Framework
Web application framework based in plug-ins
Author: By
Last change:
Date: 9 years ago
Size: 2,553 bytes


Class file image Download
if (isset($_POST['submit'])) {
$_SESSION['sticky'] = $_POST;
$mysqli = @new mysqli($_POST['dbhost'], $_POST['dbuser'], $_POST['dbpass'], $_POST['dbname']);
  if (
$mysqli->connect_error) {
'<p style="color:red;">Sorry but the database information that you entered did not work, please try again.</p>';
  } else {
$file = @file_get_contents(ROOT . '/lib/config/config.php');
    foreach (
$_POST as $key => $val)
      if (
$key != 'submit')
$file = preg_replace('/\'' . strtoupper($key) . '\', \'.*\'/', '\'' . strtoupper($key) . '\', \'' . htmlentities($val,ENT_QUOTES,'UTF-8') . '\'', $file);
$fp = fopen(ROOT . '/lib/config/config.php', 'w');
fwrite($fp, $file);
header('Location: /');
<!doctype html>
    <title>Nibble framework installation</title>
    <style type="text/css">
      label, input{display:block;width:100%;}
    <div style="padding:10px;margin:auto;width:720px;">
      <h1>Welcome to the Nibble framework installer</h1>
        Below is a form that requires the information to install the Nibble
        framework on this server. Please fill out the information and click the
        "Install Nibble on my server" button to continue installing the Nibble
      <form action="/" method="post">
        <label for="site_name">Site name/title:</label>
        <input type="text" name="site_name" id="site_name" value="<?php echo Useful::stickyText('site_name') ?>" />
        <label for="email">Administrators email address:</label>
        <input type="text" name="email" id="email" value="<?php echo Useful::stickyText('email') ?>" />
        <label for="dbhost">Database host name</label>
        <input type="text" name="dbhost" id="dbhost" value="<?php echo Useful::stickyText('dbhost') ?>" />
        <label for="dbname">Database name</label>
        <input type="text" name="dbname" id="dbname" value="<?php echo Useful::stickyText('dbname') ?>" />
        <label for="dbuser">Database username</label>
        <input type="text" name="dbuser" id="dbuser" value="<?php echo Useful::stickyText('dbuser') ?>" />
        <label for="dbpass">Database password</label>
        <input type="text" name="dbpass" id="dbpass" value="<?php echo Useful::stickyText('dbpass') ?>" />
        <input type="submit" value="Install Nibble on my server" name="submit" />

For more information send a message to info at phpclasses dot org.