Example #1
0
 /**
  * Creates the Database object and sets the database connection info based on
  * the config file.
  *
  * You can connect to another database on the server listed in the config class by passing its
  * name in the constructor
  *
  * Only supports Mysql databases.
  *
  * @see includes/walleye.config.php
  * @param string $db
  */
 private function __construct($db = null)
 {
     $dbOptions = Walleye::getInstance()->getDbOptions();
     $server = $dbOptions['SERVER'];
     $user = $dbOptions['USER'];
     $password = $dbOptions['PASS'];
     $port = $dbOptions['PORT'];
     if (is_null($db)) {
         $database = $dbOptions['DATABASE'];
     } else {
         $database = $db;
     }
     parent::mysqli($server, $user, $password, $database, $port);
 }
Example #2
0
 /**
  * Creates a mysqli instance representing a connection to a database
  *
  * @author Basilio Briceno <bbh@tlalokes.org>
  * @param array $dsn An array with DSN information
  * @return mysqli Returns a mysqli object on success
  */
 public function __construct(array &$dsn)
 {
     $conn = parent::mysqli($dsn['host'], $dsn['username'], $dsn['password'], $dsn['name']);
     if (mysqli_connect_errno($this)) {
         throw new Exception("Failed to connect: " . mysqli_connect_error());
     }
     return $conn;
 }
Example #3
0
require_once "../vendor/autoload.php";
use Configuration\Configuration;
error_reporting(0);
echo "\n<!DOCTYPE html>\n<html>\n<head>\n<meta http-equiv='Content-Type' content='text/html; charset=utf-8' />\n<meta name='viewport' content='width=device-width'/>\n<title>Login & Signup Kit Database Installation</title>\n</head>\n\n<body>\n<h1>Login & Signup Kit Database Installation</h1>\n";
if (isset($_GET["install"])) {
    $dbPassword = Configuration::DATABASE_PASSWORD;
    $dbUser = Configuration::DATABASE_USER;
    $dbHost = Configuration::DATABASE_HOST;
    $dbPort = Configuration::DATABASE_PORT;
    $dbDatabase = Configuration::DATABASE_NAME;
    $dbDatabasePrefix = Configuration::DATABASE_PREFIX;
    $completeDatabaseName = $dbDatabasePrefix . $dbDatabase;
    $dbInstall = false;
    $mysqli = new mysqli();
    $mysqli->mysqli($dbHost, $dbUser, $dbPassword, $completeDatabaseName, $dbPort);
    if ($mysqli->connect_error) {
        $cfg_result = "<p>Cant connect to MySQL server. Check MySQL configuration file (DbConnection.php)</p>";
    } else {
        $databaseCreate = "\n        CREATE DATABASE IF NOT EXISTS " . $completeDatabaseName . " DEFAULT CHARACTER SET latin1 COLLATE latin1_swedish_ci;\n        ";
        $loginAttempts = "\n\t    CREATE TABLE IF NOT EXISTS login_attempts (\n        user_id int(11) NOT NULL,\n        time varchar(30) NOT NULL,\n        attemp_id int(11) NOT NULL AUTO_INCREMENT PRIMARY KEY,\n        time_stamp timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP\n        ) ENGINE=InnoDB  DEFAULT CHARSET=latin1 AUTO_INCREMENT=1;\n\t    ";
        $membersTable = "\n        CREATE TABLE IF NOT EXISTS members (\n        id int(11) NOT NULL AUTO_INCREMENT PRIMARY KEY,\n        username varchar(30) NOT NULL,\n        email varchar(50) NOT NULL,\n        password char(128) NOT NULL\n        ) ENGINE=InnoDB  DEFAULT CHARSET=latin1 AUTO_INCREMENT=1;\n\t    ";
        $password = '$2y$15$BTm77jO53MqbZXHNCHBtsujee0BcaqLPOQTVtILGlDfhOHKEmJmzW';
        $membersData = "\n        INSERT INTO members (username, email, password) VALUES\n        ('test', 'test@test.com','" . $password . "');\n        ";
        $passwordRequest = "\n        CREATE TABLE IF NOT EXISTS password_requests (\n        id_request int(11) NOT NULL AUTO_INCREMENT PRIMARY KEY,\n        user_email varchar(50) NOT NULL,\n        time_stamp varchar(100) NOT NULL,\n        token varchar(150) NOT NULL\n        ) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;\n\n        ";
        echo '<h2>Installer Log:</h2>';
        $stmt = $mysqli->prepare($databaseCreate);
        if ($stmt->execute()) {
            $cfg_result = "<p style='color: green'>New " . $completeDatabaseName . " database created successfully</p>";
        } else {
            $cfg_result = "<p>Error creating " . $completeDatabaseName . " database</p>";
Example #4
0
 function __construct()
 {
     parent::mysqli(DBHOST, DBUSERNAME, DBPASSWORD, DBNAME);
 }