bzr branch
http://gegoxaren.bato24.eu/bzr/booka/trunk
|
1
by Gustav Hartvigsson
initial code... |
1 |
<?php
|
2 |
/*
|
|
3 |
this file contains the first run info....
|
|
4 |
will not be abel te exec it it has already been run.
|
|
5 |
*/
|
|
6 |
||
7 |
$debug = false; |
|
8 |
$formdata = $_POST; |
|
9 |
$passwordFile = "./cfg/adminpassword.md5"; |
|
10 |
$usernameFile = "./cfg/adminusername.u"; |
|
11 |
$sitenameFile = "./cfg/sitename.u"; |
|
12 |
include "./inc/dbConnect.php"; |
|
13 |
||
14 |
include "./inc/head.php"; |
|
15 |
if(file_exists("./cfg/hasrun.lock")){ //looks for a lockfile |
|
16 |
||
17 |
echo "You are trying to run the install scrit, but it is not permited:<br /> \n |
|
18 |
try to delite <code> ./conf/hasrun.lock </code> <br /> \n |
|
19 |
or the site is proporly configured... return to <a href='./'>index</a> for start using the site! \n"; |
|
20 |
||
21 |
} else { |
|
22 |
if($debug == true){ |
|
23 |
||
24 |
echo "debug: lock file deos not exist.<br /> \n"; |
|
25 |
||
26 |
}
|
|
27 |
||
28 |
include "./inc/admin_reg_form.html"; |
|
29 |
||
30 |
if($formdata[password] != $formdata[password2] || $formdata[password] == null){ |
|
31 |
||
32 |
echo "<em>the passwords does not match... or is empty.. </em> <br />"; |
|
33 |
||
34 |
} else { |
|
35 |
||
36 |
if($debug){ |
|
37 |
echo "debug: creating MD5 version of password <br /> \n"; |
|
38 |
}
|
|
39 |
||
40 |
$passmd5 = md5($formdata[password]); |
|
41 |
||
42 |
if($debug){ |
|
43 |
echo "debug:md5 is: " . $passmd5 . "<br /> \n"; |
|
44 |
echo "debug: MD5 created, now wirting to file. <br /> \n"; |
|
45 |
}
|
|
46 |
||
47 |
$fh = fopen($passwordFile, 'w') or die("can't open file"); |
|
48 |
fwrite($fh, $passmd5); |
|
49 |
fclose($fh); |
|
50 |
||
51 |
||
52 |
if($formdata[Name] != null){ |
|
53 |
||
54 |
||
55 |
if($debug){ |
|
56 |
||
57 |
echo "debug: saving username to file. <br /> \n"; |
|
58 |
||
59 |
}
|
|
60 |
||
61 |
$fh = fopen($usernameFile, 'w') or die("can't open file"); |
|
62 |
fwrite($fh, $formdata[Name]); |
|
63 |
fclose($fh); |
|
64 |
||
65 |
if($formdata[sitename] == null) { |
|
66 |
||
67 |
echo "<em>Sitename is empty.</em><br /> \n"; |
|
68 |
||
69 |
} else { |
|
70 |
||
71 |
$fh = fopen($sitenameFile, 'w') or die("can't open file"); |
|
72 |
fwrite($fh, $formdata[sitename]); |
|
73 |
fclose($fh); |
|
74 |
||
75 |
}
|
|
76 |
||
77 |
||
78 |
echo "creating database <br /> \n"; |
|
79 |
||
80 |
$db->query("CREATE TABLE booking (id COUNT(4) PRIMARY KEY, |
|
81 |
name CHAR(255), email CHAR(255), Startdate DATE, EndDate DATE);") or die("could not create DB.."); //FIXME! |
|
82 |
fopen("./cfg/hasrun.lock", "w"); //FIXME: device a better way to lock... |
|
83 |
||
84 |
} else { |
|
85 |
||
86 |
echo "<em>Username can not be empty...</em> <br /> \n"; |
|
87 |
||
88 |
}
|
|
89 |
||
90 |
||
91 |
||
92 |
}
|
|
93 |
||
94 |
}
|
|
95 |
||
96 |
include "./inc/foot.php"; |
|
97 |
?>
|