/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 22:28:08 UTC
  • mfrom: (39.1.2 extremedating)
  • Revision ID: maila@danieljohansson.nu-20130413222808-29gpdi8s30rhed4g
merging

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
4
        <title>Extreme Dating - Create User</title>
24
5
        <link rel="stylesheet" type="text/css" href="css/main.css"/>
25
6
        <meta http-equiv="Content-Type" content="text/html;charset=utf-8">
26
7
<head>
27
8
<?php
28
 
set_time_limit(0);
29
9
include "php/db.php";
30
 
include "php/salt.php";
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
 
 
37
10
if(isset($_POST['hiddenStuff']) && $_POST['hiddenStuff'] == "Something Strange") {
38
 
  $password = sha1($_POST['passwd'].$pwd_salt);
 
11
  $password = sha1($_POST['passwd']."salt");
39
12
  //If there is a $_POST that indicates that the add userscript should be run.
40
13
  $query = "";
41
 
  $output = "";
42
 
  if(isset($_FILES["image"]["tmp_name"])){
43
 
    $tmpFile = $_FILES["image"]["tmp_name"];
44
 
    $handle = fopen($tmpFile,"r");
45
 
    $fileSize = $_FILES['image']['size'];
46
 
    $output = fread($handle, filesize($tmpFile));
47
 
    $image = new Imagick();
48
 
    $image->readImageBlob($output);
49
 
    $image = stupid_convert_and_rescale($image, 280, 280, 'png');
50
 
    $output = base64_encode ($image);
 
14
  $handle = @fopen($_FILES["image"]["tmp_name"]);
 
15
  $output = "NULL";
 
16
  if ($handle) {
 
17
      while (($buffer = fgets($handle, 4096)) !== false) {
 
18
        $buffer = str_replace("&", "&amp;", $buffer);
 
19
        $buffer = str_replace("<", "&lt;", $buffer);
 
20
        $buffer = str_replace(">", "&gt;", $buffer);
 
21
      $output .= $buffer;
 
22
     }
 
23
      if (!feof($handle)) {
 
24
      $output .= "Error: unexpected fgets() fail\n";
 
25
        }
 
26
    fclose($handle);
51
27
  }
 
28
 
52
29
  if (isset($_SESSION['userType']) && $_POST['isSuperUser'] == true && $_SESSION['userType'] == 1) {
53
30
    $query = "INSERT INTO Users (
54
31
    loginName,
92
69
    '{$output}'
93
70
    );";
94
71
  }
95
 
  $success = NULL;
96
 
  try {
97
 
    $db->exec($query);
98
 
    $success = true;
99
 
  } catch (PDOException $err) {
100
 
    echo "<pre>";
101
 
    var_dump($err);
102
 
    var_dump($query);
103
 
    echo "</pre>";
104
 
    $db->rollBack();
105
 
    $success = false;
106
 
  } if ($success) {
107
 
    echo "<body> <h1> New user added! </h1> </body>";
108
 
    sleep(1);
109
 
    header("Location:./index.php");
110
 
  }
 
72
  $db->exec($query);
 
73
  echo "<body> <h1> New user added! </h1> </body>";
 
74
  sleep(.5);
 
75
  header("Location:./index.php");
111
76
} else {
112
77
 
113
78
?>
116
81
        <div id="frame">
117
82
    <h1> Create a new user </h1>
118
83
    <hr />
119
 
        <form action="./adduser.php" method="POST" enctype="multipart/form-data">
 
84
        <form action="./adduser.php" method="POST">
120
85
          <table border="0">
121
86
            <?php
122
87
              if(isset($_SESSION['userType']) && $_SESSION['userType'] == 1 ) {
155
120
              <td> <input type="input" name="city" id="city" /> </td>
156
121
            </tr>
157
122
            <tr>
158
 
              <td> <label for="file"> Profile Image </label> </td>
 
123
              <td> <label for="file"> City </label> </td>
159
124
              <td> <input type="file" name="image" id="image" /> </td>
160
125
            </tr>
161
126
                              <tr>