/booka/newlayout

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/booka/newlayout
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
$formdata = $_POST;
8
$passwordFile = "./cfg/adminpassword.md5";
9
$usernameFile = "./cfg/adminusername.u";
10
$sitenameFile = "./cfg/sitename.u";
11
include "./inc/dbConnect.php";
12
13
include "./inc/head.php";
14
	if(file_exists("./cfg/hasrun.lock")){ //looks for a lockfile
15
		
16
		echo "You are trying to run the install scrit, but it is not permited:<br /> \n
17
		 try to delite <code> ./conf/hasrun.lock </code> <br /> \n
18
		 or the site is proporly configured... return to <a href='./'>index</a> for start using the site! \n";
19
		
20
	} else {
21
				
22
		include "./inc/admin_reg_form.html";
23
		
24
		if($formdata[password] != $formdata[password2] || $formdata[password] == null){
25
			
26
			echo "<em>the passwords does not match... or is empty.. </em> <br />";
27
			
28
		} else {
29
			
30
			
31
			$passmd5 = md5($formdata[password]);
32
			
33
			
34
			$fh = fopen($passwordFile, 'w') or die("can't open file");
35
			fwrite($fh, $passmd5);
36
			fclose($fh);
37
			
38
			
39
			if($formdata[Name] != null){
40
				
41
				
42
				$fh = fopen($usernameFile, 'w') or die("can't open file");
43
				fwrite($fh, $formdata[Name]);
44
				fclose($fh);
45
				
46
				if($formdata[sitename] == null) {
47
					
48
					echo "<em>Sitename is empty.</em><br /> \n";
49
					
50
				} else {
51
					
52
					$fh = fopen($sitenameFile, 'w') or die("can't open file");
53
					fwrite($fh, $formdata[sitename]);
54
					fclose($fh);
55
					
56
				}
57
				
58
				
59
				echo "creating database <br /> \n";
60
				
61
				$db->query("CREATE TABLE booking (id COUNT(4) PRIMARY KEY,
62
name CHAR(255), email CHAR(255), Startdate DATE, EndDate DATE);") or die("could not create DB.."); //FIXME!
63
				fopen("./cfg/hasrun.lock", "w"); //FIXME: device a better way to lock...
64
				
65
			} else {
66
				
67
				echo "<em>Username can not be empty...</em> <br />  \n";
68
				
69
			}
70
			
71
			
72
			
73
		}	
74
		
75
	}
76
	
77
include "./inc/foot.php";
78
?>