/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-14 01:21:42 UTC
  • Revision ID: maila@danieljohansson.nu-20130414012142-c04xkhsftldyn2dz
Restructuring filetree

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
<!DOCTYPE html>
 
2
<html>
 
3
<head>
 
4
        <title>Extreme Dating - Create User</title>
 
5
        <link rel="stylesheet" type="text/css" href="css/main.css"/>
 
6
        <meta http-equiv="Content-Type" content="text/html;charset=utf-8">
 
7
<head>
 
8
<?php
 
9
include "php/db.php";
 
10
if(isset($_POST['hiddenStuff']) && $_POST['hiddenStuff'] == "Something Strange") {
 
11
  $password = sha1($_POST['passwd']."salt");
 
12
  //If there is a $_POST that indicates that the add userscript should be run.
 
13
  $query = "";
 
14
  $output = "";
 
15
  if(isset($_FILES["image"]["tmp_name"])){
 
16
    $tmpFile = $_FILES["image"]["tmp_name"];
 
17
    //echo $_FILES["image"]["tmp_name"];
 
18
    $handle = fopen($tmpFile,"r");
 
19
    $fileSize = $_FILES['image']['size'];
 
20
    var_dump ($handle);
 
21
    //var_dump($_FILES);
 
22
    //echo $_FILES["image"]["tmp_name"];
 
23
    $output = fread($handle, filesize($tmpFile));
 
24
    $output = base64_encode ($output);
 
25
  }
 
26
  //$output = NULL;
 
27
  /*
 
28
  if ($handle) {
 
29
      while (($buffer = fgets($handle, 4096)) !== false) {
 
30
      //$buffer = str_replace("&", "&amp;", $buffer);
 
31
      //$buffer = str_replace("<", "&lt;", $buffer);
 
32
      //$buffer = str_replace(">", "&gt;", $buffer);
 
33
      $output .= $buffer;
 
34
     }
 
35
      if (!feof($handle)) {
 
36
      $output .= "Error: unexpected fgets() fail\n";
 
37
        }
 
38
    fclose($handle);
 
39
    var_dump($output);
 
40
  }
 
41
  */
 
42
  
 
43
 
 
44
  if (isset($_SESSION['userType']) && $_POST['isSuperUser'] == true && $_SESSION['userType'] == 1) {
 
45
    $query = "INSERT INTO Users (
 
46
    loginName,
 
47
    shadow,
 
48
    firstName,
 
49
    surName,
 
50
    eMail,
 
51
    city,
 
52
    profileImage,
 
53
    userType
 
54
    )
 
55
    
 
56
    VALUES(
 
57
    '{$_POST['name']}',
 
58
    '{$password}',
 
59
    '{$_POST['firstName']}',
 
60
    '{$_POST['surName']}',
 
61
    '{$_POST['eMail']}',
 
62
    '{$_POST['city']}',
 
63
    '{$output}',
 
64
    '1'
 
65
    );";
 
66
  } else {
 
67
    $query = "INSERT INTO Users (
 
68
    loginName,
 
69
    shadow,
 
70
    firstName,
 
71
    surName,
 
72
    eMail,
 
73
    city,
 
74
    profileImage
 
75
    )
 
76
    
 
77
    VALUES(
 
78
    '{$_POST['name']}',
 
79
    '{$password}',
 
80
    '{$_POST['firstName']}',
 
81
    '{$_POST['surName']}',
 
82
    '{$_POST['eMail']}',
 
83
    '{$_POST['city']}',
 
84
    '{$output}'
 
85
    );";
 
86
  }
 
87
  try {
 
88
  $db->exec($query);
 
89
  } catch (PDOException $err) {
 
90
    var_dump($err);
 
91
  }
 
92
  echo "<body> <h1> New user added! </h1> </body>";
 
93
  sleep(.5);
 
94
  header("Location:./index.php");
 
95
} else {
 
96
 
 
97
?>
 
98
  <body id="wrapper">
 
99
        <div id="profile">
 
100
        <div id="frame">
 
101
    <h1> Create a new user </h1>
 
102
    <hr />
 
103
        <form action="./adduser.php" method="POST" enctype="multipart/form-data">
 
104
          <table border="0">
 
105
            <?php
 
106
              if(isset($_SESSION['userType']) && $_SESSION['userType'] == 1 ) {
 
107
                //you are a superuser!
 
108
                //you can add other superusers.
 
109
            ?>
 
110
            <tr>
 
111
              <td> <label for="user"> Is the user a Super User? </label> </td>
 
112
              <td> <input type="checkbox" name="isSuperUser" id="super" /> </td>
 
113
            </tr>
 
114
            <?php
 
115
              }
 
116
            ?>
 
117
            <tr>
 
118
              <td> <label for="name"> User Name </label> </td>
 
119
              <td> <input type="input" name="name" id="name" /> </td>
 
120
            </tr>
 
121
            <tr>
 
122
              <td> <label for="passwd"> Password </label> </td>
 
123
              <td> <input type="password" name="passwd" id="passwd" /> </td>
 
124
            </tr>
 
125
            <tr>
 
126
              <td> <label for="firstname"> First Name </label> </td>
 
127
              <td> <input type="input" name="firstName" id="firstname" /> </td>
 
128
            </tr>
 
129
            <tr>
 
130
              <td> <label for="surname"> Sur Name </label> </td>
 
131
              <td> <input type="input" name="surName" id="surname" /> </td>
 
132
            </tr>
 
133
            <tr>
 
134
              <td> <label for="email"> E-mail </label> </td>
 
135
              <td> <input type="input" name="eMail" id="email" /> </td>
 
136
            </tr>
 
137
            <tr>
 
138
              <td> <label for="city"> City </label> </td>
 
139
              <td> <input type="input" name="city" id="city" /> </td>
 
140
            </tr>
 
141
            <tr>
 
142
              <td> <label for="file"> City </label> </td>
 
143
              <td> <input type="file" name="image" id="image" /> </td>
 
144
            </tr>
 
145
                              <tr>
 
146
              <td><input name="hiddenStuff" value="Something Strange" type="hidden"/></td>
 
147
              <td><input id="inputbutton1" type="submit" action="./adduser.php" value="Registera mig"/></td>
 
148
            </tr>
 
149
          </table>
 
150
        </form>
 
151
      <?php
 
152
}
 
153
      ?>
 
154
          </div>
 
155
    </div>
 
156
  </body>
 
157
</html>