This repository has been archived by the owner on Oct 26, 2018. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 3
/
install.php
101 lines (91 loc) · 4.41 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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
<?php
if (file_exists('config.php')) {
header("Location: ./");
} else {
if (isset($_POST['submit'])) {
rename("./config.example.php", "./config.php");
// Modify Config file
$data = file_get_contents("./config.php");
$fields = array("mysql-url", "mysql-user", "mysql-password", "mysql-db", "mysql-table");
foreach ($fields as $field) {
$data = preg_replace('#\$conf\[\'' . $field . '\'\] ?= ?([^;]*);#', '$conf[\'' . $field . '\'] = ' . var_export($_POST[$field], true) . ';', $data);
}
file_put_contents("./config.php", $data);
// Include the new File
// TODO: What if config does not work?
include 'config.php';
// Init Database
$query = 'CREATE TABLE IF NOT EXISTS `' . $conf['mysql-table'] . '` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`name` varchar(30) NOT NULL,
`type` varchar(30) NOT NULL,
`size` int(11) NOT NULL,
`content` mediumblob NOT NULL,
`file-name` text,
`removalcode` text,
`encryption` text,
`salt` text,
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=25 DEFAULT CHARSET=latin1';
$con = mysqli_connect($conf['mysql-url'], $conf['mysql-user'], $conf['mysql-password'], $conf['mysql-db']) or header('Location: ./mysql-error.php');
$query = $con->query($query);
} else {
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="description" content="Simple way to upload files">
<meta name="author" content="carlgo11">
<META HTTP-EQUIV="Pragma" CONTENT="no-cache">
<META HTTP-EQUIV="Expires" CONTENT="-1">
<link rel="shortcut icon" type="image/icon" href="./resources/media/logo.png"/>
<title>
<?php
include './config.php';
echo $conf['title'];
?>
</title>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.2/css/bootstrap.min.css">
<link href="./css/insallation.css" rel="stylesheet">
<script src="./js/bootstrap.file-input.js"></script>
</head>
<body>
<div class="container" style="margin-top: 100px">
<div class="jumbotron">
<h1>Welcome to your UpLoadMe!</h1>
<p>To begin using UpLoadMe you need to set up a few things.</p>
<p>This page will help you with that.</p>
</div>
<form action="" method="post" enctype="multipart/form-data">
<div class="panel panel-default">
<div class="panel-heading"><b class="panel-title">Mysql</b></div>
<div class="panel-body">
<p>UpLoadMe uses mysql to store the files and it's accessories.</p>
<p>If you haven't installed mysql yet please do so now.</p>
<input type='text' class="form-control" placeholder="Mysql url" name='mysql-url' required="">
<input type='text' class="form-control" placeholder="Mysql username" name='mysql-user' required="">
<input type='password' class='form-control' placeholder="Mysql password" name='mysql-password'
required="">
<input type="text" class='form-control' placeholder="Mysql database" name="mysql-db" required="">
<input type='text' class="form-control" placeholder="Mysql table" name="mysql-table" required="">
</div>
</div>
<div class="panel panel-default">
<div class="panel-heading"><b class="panel-title">Other</b></div>
<div class="panel-body">
<i>Contact email is used for contact.php's contact form.</i>
<input type='email' class="form-control" placeholder="Contact email" name="email-receiver">
<input type='text' class='form-control' placeholder="Page title" name="title" required="">
</div>
</div>
<button class='btn btn-lg btn-success' type="submit" name="submit">Install<span
class="glyphicon glyphicon-download-alt" aria-hidden='true'></span></button>
</form>
</div>
</body>
<?php
}
}