/extremedating/trunk

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/extremedating/trunk

« back to all changes in this revision

Viewing changes to adduser.php

  • Committer: Daniel Johansson
  • Date: 2013-04-13 17:27:51 UTC
  • mfrom: (24.1.2 extremedating)
  • Revision ID: maila@danieljohansson.nu-20130413172751-now2qubz7gyuxi8h
merge

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
<!DOCTYPE html>
2
2
<html>
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
 
-->
22
3
<head>
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">
 
4
    <title>Extreme Dating - Create User</title>
26
5
<head>
27
6
<?php
28
7
include "php/db.php";
29
 
include "php/salt.php";
30
8
if(isset($_POST['hiddenStuff']) && $_POST['hiddenStuff'] == "Something Strange") {
31
 
  $password = sha1($_POST['passwd'].$pwd_salt);
 
9
  $password = sha1($_POST['passwd']."salt");
32
10
  //If there is a $_POST that indicates that the add userscript should be run.
33
11
  $query = "";
34
 
  $output = "";
35
 
  if(isset($_FILES["image"]["tmp_name"])){
36
 
    $tmpFile = $_FILES["image"]["tmp_name"];
37
 
    $handle = fopen($tmpFile,"r");
38
 
    $fileSize = $_FILES['image']['size'];
39
 
    $output = fread($handle, filesize($tmpFile));
40
 
    $output = base64_encode ($output);
41
 
  }
42
12
  if (isset($_SESSION['userType']) && $_POST['isSuperUser'] == true && $_SESSION['userType'] == 1) {
43
13
    $query = "INSERT INTO Users (
44
14
    loginName,
47
17
    surName,
48
18
    eMail,
49
19
    city,
50
 
    profileImage,
51
20
    userType
52
21
    )
53
22
    
58
27
    '{$_POST['surName']}',
59
28
    '{$_POST['eMail']}',
60
29
    '{$_POST['city']}',
61
 
    '{$output}',
62
30
    '1'
63
31
    );";
64
32
  } else {
68
36
    firstName,
69
37
    surName,
70
38
    eMail,
71
 
    city,
72
 
    profileImage
 
39
    city
73
40
    )
74
41
    
75
42
    VALUES(
78
45
    '{$_POST['firstName']}',
79
46
    '{$_POST['surName']}',
80
47
    '{$_POST['eMail']}',
81
 
    '{$_POST['city']}',
82
 
    '{$output}'
 
48
    '{$_POST['city']}'
83
49
    );";
84
50
  }
85
 
  try {
86
51
  $db->exec($query);
87
 
  } catch (PDOException $err) {
88
 
    var_dump($err);
89
 
  }
90
52
  echo "<body> <h1> New user added! </h1> </body>";
91
53
  sleep(.5);
92
54
  header("Location:./index.php");
94
56
 
95
57
?>
96
58
  <body id="wrapper">
97
 
        <div id="profile">
98
 
        <div id="frame">
 
59
                <div id="profile">
99
60
    <h1> Create a new user </h1>
100
 
    <hr />
101
 
        <form action="./adduser.php" method="POST" enctype="multipart/form-data">
 
61
    <hr \>
 
62
        <form action="./adduser.php" method="POST">
102
63
          <table border="0">
103
64
            <?php
104
65
              if(isset($_SESSION['userType']) && $_SESSION['userType'] == 1 ) {
107
68
            ?>
108
69
            <tr>
109
70
              <td> <label for="user"> Is the user a Super User? </label> </td>
110
 
              <td> <input type="checkbox" name="isSuperUser" id="super" /> </td>
 
71
              <td> <input type="checkbox" name="isSuperUser" id="super" \> </td>
111
72
            </tr>
112
73
            <?php
113
74
              }
136
97
              <td> <label for="city"> City </label> </td>
137
98
              <td> <input type="input" name="city" id="city" /> </td>
138
99
            </tr>
139
 
            <tr>
140
 
              <td> <label for="file"> City </label> </td>
141
 
              <td> <input type="file" name="image" id="image" /> </td>
142
 
            </tr>
143
 
                              <tr>
 
100
                        <tr>
144
101
              <td><input name="hiddenStuff" value="Something Strange" type="hidden"/></td>
145
 
              <td><input id="inputbutton1" type="submit" action="./adduser.php" value="Registera mig"/></td>
146
 
            </tr>
 
102
              <td><input id="input" type="submit" action="./adduser.php" value="Registera mig"/></td>
 
103
                        </tr>
147
104
          </table>
148
105
        </form>
149
106
      <?php
150
107
}
151
108
      ?>
152
 
          </div>
153
109
    </div>
154
110
  </body>
155
111
</html>