-
Notifications
You must be signed in to change notification settings - Fork 0
/
register.php
executable file
·67 lines (36 loc) · 1.03 KB
/
register.php
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
<?php //register.php
header('Content-type: application/json');
include_once('config.php');
include_once(ARC_DIR . 'ARC2.php');
if( isset($_SESSION['userURI'] ) ) {
echo "{status:'loggedIn', message:'Looks like you are logged in as someone'}";
exit;
}
$store = ARC2::getStore($config);
$nick = $_POST['nick'] ;
$pwdHash = md5($_POST['pwd']) ;
$email = $_POST['email'] ;
//ASK if email is already registered
$q = " ASK {
?u a sioc:User ;
sioc:email '" . $email ."' .
}
";
$result = $store->query($q, 'raw');
if( (bool) $result ) {
//fail message
echo "{ message : 'Looks like a user with that email is already registered.' }";
} else {
//mint user URI
$userURI = 'http://data.rubrick-jetpack.org/Users/' . sha1( $email );
$q = " INSERT INTO <http://data.rubrick-jetpack.org/Users> {
<$userURI> a sioc:User ;
sioc:email '$email' ;
sioc:name '$nick' ;
r:pwd '$pwdHash' .
}";
$rs = $store->query($q);
$_SESSION['userURI'] = $userURI;
echo "{ message: 'Successfully registered!' }";
}
?>