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
|
<?php
/*
this file contains the first run info....
will not be abel te exec it it has already been run.
*/
$debug = false;
$formdata = $_POST;
$passwordFile = "./cfg/adminpassword.md5";
$usernameFile = "./cfg/adminusername.u";
$sitenameFile = "./cfg/sitename.u";
include "./inc/dbConnect.php";
include "./inc/head.php";
if(file_exists("./cfg/hasrun.lock")){ //looks for a lockfile
echo "You are trying to run the install scrit, but it is not permited:<br /> \n
try to delite <code> ./conf/hasrun.lock </code> <br /> \n
or the site is proporly configured... return to <a href='./'>index</a> for start using the site! \n";
} else {
if($debug == true){
echo "debug: lock file deos not exist.<br /> \n";
}
include "./inc/admin_reg_form.html";
if($formdata[password] != $formdata[password2] || $formdata[password] == null){
echo "<em>the passwords does not match... or is empty.. </em> <br />";
} else {
if($debug){
echo "debug: creating MD5 version of password <br /> \n";
}
$passmd5 = md5($formdata[password]);
if($debug){
echo "debug:md5 is: " . $passmd5 . "<br /> \n";
echo "debug: MD5 created, now wirting to file. <br /> \n";
}
$fh = fopen($passwordFile, 'w') or die("can't open file");
fwrite($fh, $passmd5);
fclose($fh);
if($formdata[Name] != null){
if($debug){
echo "debug: saving username to file. <br /> \n";
}
$fh = fopen($usernameFile, 'w') or die("can't open file");
fwrite($fh, $formdata[Name]);
fclose($fh);
if($formdata[sitename] == null) {
echo "<em>Sitename is empty.</em><br /> \n";
} else {
$fh = fopen($sitenameFile, 'w') or die("can't open file");
fwrite($fh, $formdata[sitename]);
fclose($fh);
}
echo "creating database <br /> \n";
$db->query("CREATE TABLE booking (id COUNT(4) PRIMARY KEY,
name CHAR(255), email CHAR(255), Startdate DATE, EndDate DATE);") or die("could not create DB.."); //FIXME!
fopen("./cfg/hasrun.lock", "w"); //FIXME: device a better way to lock...
} else {
echo "<em>Username can not be empty...</em> <br /> \n";
}
}
}
include "./inc/foot.php";
?>
|