bzr branch
http://gegoxaren.bato24.eu/bzr/extremedating/trunk
14.1.1
by Gustav Hatvigsson
Started work on the add user form. |
1 |
<!DOCTYPE html>
|
2 |
<html> |
|
49.1.1
by Gustav Hatvigsson
Added licensing information to some files |
3 |
<!--
|
4 |
ExtremeDating - a Hackathon 2013 project.
|
|
5 |
Copyright (C) 2013 Gustav Hartvigsson <gustav.hartvigsson@gmail.com>
|
|
6 |
Copyright (C) 2013 Daniel Johansson <maila@danieljohansson.nu>
|
|
7 |
||
8 |
||
9 |
This program is free software: you can redistribute it and/or modify
|
|
10 |
it under the terms of the GNU Affero General Public License as
|
|
11 |
published by the Free Software Foundation, either version 3 of the
|
|
12 |
License, or (at your option) any later version.
|
|
13 |
||
14 |
This program is distributed in the hope that it will be useful,
|
|
15 |
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
16 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
17 |
GNU Affero General Public License for more details.
|
|
18 |
||
19 |
You should have received a copy of the GNU Affero General Public License
|
|
20 |
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
21 |
-->
|
|
14.1.1
by Gustav Hatvigsson
Started work on the add user form. |
22 |
<head> |
30
by Daniel Johansson
Derping around |
23 |
<title>Extreme Dating - Create User</title> |
24 |
<link rel="stylesheet" type="text/css" href="css/main.css"/> |
|
25 |
<meta http-equiv="Content-Type" content="text/html;charset=utf-8"> |
|
72
by Gustav Hartvigsson
* Opitimised add user code |
26 |
</head> |
14.1.1
by Gustav Hatvigsson
Started work on the add user form. |
27 |
<?php
|
68
by Gustav Hartvigsson
Made the uploaded files take less space in the databas, though the use of |
28 |
set_time_limit(0); |
14.1.1
by Gustav Hatvigsson
Started work on the add user form. |
29 |
include "php/db.php"; |
52.1.2
by Gustav Hatvigsson
Seperated out the salt into its own file. |
30 |
include "php/salt.php"; |
68
by Gustav Hartvigsson
Made the uploaded files take less space in the databas, though the use of |
31 |
include "php/stupid_image.php"; |
32 |
set_time_limit(60); |
|
33 |
ini_set("post_max_size","16M"); |
|
34 |
ini_set("upload_max_filesize","16M"); |
|
35 |
ini_set("memory_limit","64M"); |
|
36 |
||
20.1.1
by Daniel Johansson
Fixed stuffz in adduser.php |
37 |
if(isset($_POST['hiddenStuff']) && $_POST['hiddenStuff'] == "Something Strange") { |
52.1.2
by Gustav Hatvigsson
Seperated out the salt into its own file. |
38 |
$password = sha1($_POST['passwd'].$pwd_salt); |
14.1.1
by Gustav Hatvigsson
Started work on the add user form. |
39 |
//If there is a $_POST that indicates that the add userscript should be run.
|
40 |
$query = ""; |
|
39.1.6
by Gustav Hatvigsson
Fixed the gawd damn get_image.php thingies... |
41 |
$output = ""; |
72
by Gustav Hartvigsson
* Opitimised add user code |
42 |
if(isset($_FILES["image"]["tmp_name"]) && $_FILES['image']['size'] != 0 ){ |
39.1.6
by Gustav Hatvigsson
Fixed the gawd damn get_image.php thingies... |
43 |
$tmpFile = $_FILES["image"]["tmp_name"]; |
44 |
$handle = fopen($tmpFile,"r"); |
|
45 |
$fileSize = $_FILES['image']['size']; |
|
45.1.1
by Gustav Hatvigsson
Fixed it again... |
46 |
$output = fread($handle, filesize($tmpFile)); |
68
by Gustav Hartvigsson
Made the uploaded files take less space in the databas, though the use of |
47 |
$image = new Imagick(); |
48 |
$image->readImageBlob($output); |
|
49 |
$image = stupid_convert_and_rescale($image, 280, 280, 'png'); |
|
72
by Gustav Hartvigsson
* Opitimised add user code |
50 |
$output = $image; |
39.1.6
by Gustav Hatvigsson
Fixed the gawd damn get_image.php thingies... |
51 |
}
|
72
by Gustav Hartvigsson
* Opitimised add user code |
52 |
$query = "INSERT INTO Users ( |
14.1.1
by Gustav Hatvigsson
Started work on the add user form. |
53 |
loginName,
|
54 |
shadow,
|
|
55 |
firstName,
|
|
56 |
surName,
|
|
57 |
eMail,
|
|
58 |
city,
|
|
29.1.1
by Gustav Hatvigsson
Added profile image to the adduser.php file. |
59 |
profileImage,
|
14.1.1
by Gustav Hatvigsson
Started work on the add user form. |
60 |
userType
|
61 |
)
|
|
62 |
|
|
63 |
VALUES(
|
|
64 |
'{$_POST['name']}', |
|
65 |
'{$password}', |
|
66 |
'{$_POST['firstName']}', |
|
67 |
'{$_POST['surName']}', |
|
68 |
'{$_POST['eMail']}', |
|
24
by Daniel Johansson
Fixed gegos errors |
69 |
'{$_POST['city']}', |
72
by Gustav Hartvigsson
* Opitimised add user code |
70 |
? ,
|
71 |
?
|
|
14.1.1
by Gustav Hatvigsson
Started work on the add user form. |
72 |
);"; |
72
by Gustav Hartvigsson
* Opitimised add user code |
73 |
$q = null; |
74 |
try{ |
|
75 |
$q = $db->prepare($query); |
|
76 |
} catch (PDOException $err) { |
|
77 |
echo "<pre>"; |
|
78 |
var_dump($err); |
|
79 |
echo "</pre>"; |
|
80 |
||
81 |
}
|
|
82 |
if (isset($_SESSION['userType']) && $_POST['isSuperUser'] == true && $_SESSION['userType'] == 1) { |
|
83 |
$q->bindValue(2, '1'); |
|
14.1.1
by Gustav Hatvigsson
Started work on the add user form. |
84 |
} else { |
72
by Gustav Hartvigsson
* Opitimised add user code |
85 |
$q->bindValue(2, '0'); |
14.1.1
by Gustav Hatvigsson
Started work on the add user form. |
86 |
}
|
68
by Gustav Hartvigsson
Made the uploaded files take less space in the databas, though the use of |
87 |
$success = NULL; |
39.1.4
by Gustav Hatvigsson
fixed the user images! that only took a fow houres -_-... |
88 |
try { |
72
by Gustav Hartvigsson
* Opitimised add user code |
89 |
$q->bindValue(1,$output, PDO::PARAM_LOB); |
90 |
$q->execute(); |
|
68
by Gustav Hartvigsson
Made the uploaded files take less space in the databas, though the use of |
91 |
$success = true; |
39.1.4
by Gustav Hatvigsson
fixed the user images! that only took a fow houres -_-... |
92 |
} catch (PDOException $err) { |
68
by Gustav Hartvigsson
Made the uploaded files take less space in the databas, though the use of |
93 |
echo "<pre>"; |
39.1.4
by Gustav Hatvigsson
fixed the user images! that only took a fow houres -_-... |
94 |
var_dump($err); |
68
by Gustav Hartvigsson
Made the uploaded files take less space in the databas, though the use of |
95 |
var_dump($query); |
72
by Gustav Hartvigsson
* Opitimised add user code |
96 |
var_dump($q); |
68
by Gustav Hartvigsson
Made the uploaded files take less space in the databas, though the use of |
97 |
echo "</pre>"; |
98 |
$success = false; |
|
99 |
} if ($success) { |
|
72
by Gustav Hartvigsson
* Opitimised add user code |
100 |
/*echo "<pre>";
|
101 |
var_dump($query);
|
|
102 |
var_dump($q);
|
|
103 |
echo "</pre>";
|
|
104 |
*/
|
|
105 |
echo "<body> <h1> New user added! </h1>"; |
|
68
by Gustav Hartvigsson
Made the uploaded files take less space in the databas, though the use of |
106 |
sleep(1); |
107 |
header("Location:./index.php"); |
|
39.1.4
by Gustav Hatvigsson
fixed the user images! that only took a fow houres -_-... |
108 |
}
|
14.1.1
by Gustav Hatvigsson
Started work on the add user form. |
109 |
} else { |
110 |
||
111 |
?>
|
|
112 |
<body id="wrapper"> |
|
30
by Daniel Johansson
Derping around |
113 |
<div id="profile"> |
114 |
<div id="frame"> |
|
14.1.1
by Gustav Hatvigsson
Started work on the add user form. |
115 |
<h1> Create a new user </h1> |
29.1.1
by Gustav Hatvigsson
Added profile image to the adduser.php file. |
116 |
<hr /> |
45.1.1
by Gustav Hatvigsson
Fixed it again... |
117 |
<form action="./adduser.php" method="POST" enctype="multipart/form-data"> |
14.1.1
by Gustav Hatvigsson
Started work on the add user form. |
118 |
<table border="0"> |
119 |
<?php
|
|
18.1.1
by Gustav Hatvigsson
fixed a few things. |
120 |
if(isset($_SESSION['userType']) && $_SESSION['userType'] == 1 ) { |
14.1.1
by Gustav Hatvigsson
Started work on the add user form. |
121 |
//you are a superuser!
|
122 |
//you can add other superusers.
|
|
123 |
?>
|
|
124 |
<tr> |
|
125 |
<td> <label for="user"> Is the user a Super User? </label> </td> |
|
29.1.1
by Gustav Hatvigsson
Added profile image to the adduser.php file. |
126 |
<td> <input type="checkbox" name="isSuperUser" id="super" /> </td> |
14.1.1
by Gustav Hatvigsson
Started work on the add user form. |
127 |
</tr> |
128 |
<?php
|
|
129 |
}
|
|
130 |
?>
|
|
131 |
<tr> |
|
132 |
<td> <label for="name"> User Name </label> </td> |
|
133 |
<td> <input type="input" name="name" id="name" /> </td> |
|
134 |
</tr> |
|
135 |
<tr> |
|
136 |
<td> <label for="passwd"> Password </label> </td> |
|
137 |
<td> <input type="password" name="passwd" id="passwd" /> </td> |
|
138 |
</tr> |
|
139 |
<tr> |
|
140 |
<td> <label for="firstname"> First Name </label> </td> |
|
141 |
<td> <input type="input" name="firstName" id="firstname" /> </td> |
|
142 |
</tr> |
|
143 |
<tr> |
|
144 |
<td> <label for="surname"> Sur Name </label> </td> |
|
145 |
<td> <input type="input" name="surName" id="surname" /> </td> |
|
146 |
</tr> |
|
147 |
<tr> |
|
148 |
<td> <label for="email"> E-mail </label> </td> |
|
149 |
<td> <input type="input" name="eMail" id="email" /> </td> |
|
150 |
</tr> |
|
151 |
<tr> |
|
152 |
<td> <label for="city"> City </label> </td> |
|
153 |
<td> <input type="input" name="city" id="city" /> </td> |
|
154 |
</tr> |
|
29.1.1
by Gustav Hatvigsson
Added profile image to the adduser.php file. |
155 |
<tr> |
57.1.2
by Gustav Hatvigsson
fixed the "city" bug. |
156 |
<td> <label for="file"> Profile Image </label> </td> |
32
by Gustav Hatvigsson
Fixed a few things... |
157 |
<td> <input type="file" name="image" id="image" /> </td> |
29.1.1
by Gustav Hatvigsson
Added profile image to the adduser.php file. |
158 |
</tr> |
159 |
<tr> |
|
20.1.1
by Daniel Johansson
Fixed stuffz in adduser.php |
160 |
<td><input name="hiddenStuff" value="Something Strange" type="hidden"/></td> |
30
by Daniel Johansson
Derping around |
161 |
<td><input id="inputbutton1" type="submit" action="./adduser.php" value="Registera mig"/></td> |
33
by Gustav Hatvigsson
fixed merge errors, and indentation. |
162 |
</tr> |
14.1.1
by Gustav Hatvigsson
Started work on the add user form. |
163 |
</table> |
164 |
</form> |
|
72
by Gustav Hartvigsson
* Opitimised add user code |
165 |
</div> |
166 |
</div> |
|
167 |
<?php
|
|
14.1.1
by Gustav Hatvigsson
Started work on the add user form. |
168 |
}
|
72
by Gustav Hartvigsson
* Opitimised add user code |
169 |
?>
|
170 |
||
14.1.1
by Gustav Hatvigsson
Started work on the add user form. |
171 |
</body> |
172 |
</html> |