/extremedating/trunk

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/extremedating/trunk
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
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
<!DOCTYPE html>
<html>
<head>
	<title>Extreme Dating - Create User</title>
	<link rel="stylesheet" type="text/css" href="css/main.css"/>
	<meta http-equiv="Content-Type" content="text/html;charset=utf-8">
<head>
<?php
include "php/db.php";
if(isset($_POST['hiddenStuff']) && $_POST['hiddenStuff'] == "Something Strange") {
  $password = sha1($_POST['passwd']."salt");
  //If there is a $_POST that indicates that the add userscript should be run.
  $query = "";
  $output = "";
  if(isset($_FILES["image"]["tmp_name"])){
    $tmpFile = $_FILES["image"]["tmp_name"];
    //echo $_FILES["image"]["tmp_name"];
    $handle = fopen($tmpFile,"r");
    $fileSize = $_FILES['image']['size'];
    var_dump ($handle);
    //var_dump($_FILES);
    //echo $_FILES["image"]["tmp_name"];
    $output = fread($handle, filesize($tmpFile));
    $output = base64_encode ($output);
  }
  //$output = NULL;
  /*
  if ($handle) {
      while (($buffer = fgets($handle, 4096)) !== false) {
      //$buffer = str_replace("&", "&amp;", $buffer);
      //$buffer = str_replace("<", "&lt;", $buffer);
      //$buffer = str_replace(">", "&gt;", $buffer);
      $output .= $buffer;
     }
      if (!feof($handle)) {
      $output .= "Error: unexpected fgets() fail\n";
   	}
    fclose($handle);
    var_dump($output);
  }
  */
  

  if (isset($_SESSION['userType']) && $_POST['isSuperUser'] == true && $_SESSION['userType'] == 1) {
    $query = "INSERT INTO Users (
    loginName,
    shadow,
    firstName,
    surName,
    eMail,
    city,
    profileImage,
    userType
    )
    
    VALUES(
    '{$_POST['name']}',
    '{$password}',
    '{$_POST['firstName']}',
    '{$_POST['surName']}',
    '{$_POST['eMail']}',
    '{$_POST['city']}',
    '{$output}',
    '1'
    );";
  } else {
    $query = "INSERT INTO Users (
    loginName,
    shadow,
    firstName,
    surName,
    eMail,
    city,
    profileImage
    )
    
    VALUES(
    '{$_POST['name']}',
    '{$password}',
    '{$_POST['firstName']}',
    '{$_POST['surName']}',
    '{$_POST['eMail']}',
    '{$_POST['city']}',
    '{$output}'
    );";
  }
  try {
  $db->exec($query);
  } catch (PDOException $err) {
    var_dump($err);
  }
  echo "<body> <h1> New user added! </h1> </body>";
  sleep(.5);
  header("Location:./index.php");
} else {

?>
  <body id="wrapper">
	<div id="profile">
	<div id="frame">
    <h1> Create a new user </h1>
    <hr />
        <form action="./adduser.php" method="POST" enctype="multipart/form-data">
          <table border="0">
            <?php
              if(isset($_SESSION['userType']) && $_SESSION['userType'] == 1 ) {
                //you are a superuser!
                //you can add other superusers.
            ?>
            <tr>
              <td> <label for="user"> Is the user a Super User? </label> </td>
              <td> <input type="checkbox" name="isSuperUser" id="super" /> </td>
            </tr>
            <?php
              }
            ?>
            <tr>
              <td> <label for="name"> User Name </label> </td>
              <td> <input type="input" name="name" id="name" /> </td>
            </tr>
            <tr>
              <td> <label for="passwd"> Password </label> </td>
              <td> <input type="password" name="passwd" id="passwd" /> </td>
            </tr>
            <tr>
              <td> <label for="firstname"> First Name </label> </td>
              <td> <input type="input" name="firstName" id="firstname" /> </td>
            </tr>
            <tr>
              <td> <label for="surname"> Sur Name </label> </td>
              <td> <input type="input" name="surName" id="surname" /> </td>
            </tr>
            <tr>
              <td> <label for="email"> E-mail </label> </td>
              <td> <input type="input" name="eMail" id="email" /> </td>
            </tr>
            <tr>
              <td> <label for="city"> City </label> </td>
              <td> <input type="input" name="city" id="city" /> </td>
            </tr>
            <tr>
              <td> <label for="file"> City </label> </td>
              <td> <input type="file" name="image" id="image" /> </td>
            </tr>
			      <tr>
              <td><input name="hiddenStuff" value="Something Strange" type="hidden"/></td>
              <td><input id="inputbutton1" type="submit" action="./adduser.php" value="Registera mig"/></td>
            </tr>
          </table>
        </form>
      <?php
}
      ?>
	  </div>
    </div>
  </body>
</html>