forked from astronomersiva/Map-My-Problems
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcreateadmin.php
More file actions
84 lines (66 loc) · 2.39 KB
/
Copy pathcreateadmin.php
File metadata and controls
84 lines (66 loc) · 2.39 KB
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
<?php
ob_start();
session_start();
$liveServer = 0;
if(!isset($_POST["title"]) or !isset($_POST["name"]) or !isset($_POST["password"]) or !isset($_POST["cpass"])) {
header('Location:signup.php');
}
$name = $_POST["name"];
$title = $_POST["title"];
$pass = $_POST["password"];
$cpass = $_POST["cpassword"];
$const = $_POST["constituency"];
if(strcmp($pass, $cpass) == 0) {
$hashpass = md5($pass);
}
else {
$_SESSION['password-mismatch'] = 1;
header('Location:signup.php');
}
$m = new MongoClient();
$db = $m -> map;
$collection = $db -> users;
if($liveServer) {
$alreadyExists = (($collection -> count(array('title' => $title))) + ($collection -> count(array('constituency' => $const))));
if($alreadyExists != 2) {
$user = array('name' => $name, 'title' => $title, 'constituency' => $const, 'pass' => $hashpass, 'admin' => 1);
$collection -> insert($user);
$subject = 'Confirmation';
$message = 'Open this link to verify' . '<a href="map.com/verify.php?id='.crc32($email).'">map.com/verify.php?id='.crc32($email).'</a>';
$to = '$email';
$type = 'HTML';
$charset = 'utf-8';
$mail = 'no-reply@'.str_replace('www.', '', $_SERVER['SERVER_NAME']);
$uniqid = md5(uniqid(time()));
$headers = 'From: '.$mail."\n";
$headers .= 'Reply-to: '.$mail."\n";
$headers .= 'Return-Path: '.$mail."\n";
$headers .= 'Message-ID: <'.$uniqid.'@'.$_SERVER['SERVER_NAME'].">\n";
$headers .= 'MIME-Version: 1.0'."\n";
$headers .= 'Date: '.gmdate('D, d M Y H:i:s', time())."\n";
$headers .= 'X-Priority: 3'."\n";
$headers .= 'X-MSMail-Priority: Normal'."\n";
$headers .= 'Content-Type: multipart/mixed;boundary="----------'.$uniqid.'"'."\n\n";
$headers .= '------------'.$uniqid."\n";
$headers .= 'Content-type: text/'.$type.';charset='.$charset.''."\n";
$headers .= 'Content-transfer-encoding: 7bit';
$ma = mail($to, $subject, $message, $headers);
}
else {
$_SESSION['username-exists'] = 1;
header('Location:signup.php');
}
}
else {
$alreadyExists = (($collection -> count(array('title' => $title, 'constituency' => $const))));
if(!$alreadyExists) {
$user = array('name' => "$name", 'title' => $title, 'constituency' => $const, 'pass' => $hashpass, 'admin' => 1);
$collection -> insert($user);
header('Location:login.php');
}
else {
$_SESSION['username-exists'] = 1;
header('Location:signup.php');
}
}
?>