forked from bemosior/PHPasswordPusher
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinstall.php
29 lines (25 loc) · 1.25 KB
/
install.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
<?php
/**
* PHPasswordPusher MySQL table installer
*/
//SETUP:
$rootdbuser = 'root'; //Privileged user to perform database creation and privilege granting.
$rootdbpass = 'rootpw'; //Privileged user's password (please remove this value when finished!).
//STOP. Have you configured "pwpusher_private/config.php" yet?
require 'pwpusher_private/config.php';
//Create Database
try{
$db = new PDO("mysql:dbname=;host=localhost", $rootdbuser, $rootdbpass) or die('Connect Failed');
$db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$db->exec('CREATE DATABASE ' . $dbname . ';');
$db->exec('USE ' . $dbname .';');
$db->exec('CREATE TABLE phpasspush (seccred TEXT, id VARCHAR(128) NOT NULL PRIMARY KEY, ctime DATETIME, xtime DATETIME, views INT, xviews INT);') ;
$db->exec('CREATE EVENT phpasspush_tidy ON SCHEDULE EVERY 1 MINUTE DO DELETE FROM ' . $dbname . '.phpasspush WHERE xtime<UTC_TIMESTAMP() OR views>=xviews;');
$db->exec('SET GLOBAL event_scheduler = 1;');
$db->exec('GRANT ALL PRIVILEGES ON ' . $dbname . '.* TO \'' . $dbuser . '\'@\'localhost\' IDENTIFIED BY \'' . $dbpass . '\';') ;
$db->exec('FLUSH PRIVILEGES;');
echo "MySQL setup is successful!\n";
} catch (PDOException $e) {
echo 'Problem: ' . $e->getMessage() . "\n";
}
?>