-
Notifications
You must be signed in to change notification settings - Fork 6
/
regcode.php
executable file
·67 lines (48 loc) · 1.58 KB
/
regcode.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
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Ingress Inventory by Chazz</title>
<link href='http://fonts.googleapis.com/css?family=Coda:400,700' rel='stylesheet' type='text/css' />
<link href="css/bootstrap.min.css" rel='stylesheet' type='text/css' />
<link href="css/bootstrap-theme.css " rel='stylesheet' type='text/css' />
</head>
<body>
<div class="container">
<h1 class="title text-center"><a href="index.php">Ingress Inventory</a></h1>
<?php
require 'config.php';
require 'functions.php';
$errors = array();
if(isSubmit('SACSID')){
if(!isSACSID(getValue('SACSID'))){
$errors[] = 'Invalid authentication!';
}
if(!count($errors)){
$res = mysql_query('SELECT * FROM regcodes WHERE sacsid = \''.getValue('SACSID').'\'');
if(mysql_num_rows($res)==0){
$chars = 'abcdefghijkmnpqrstuvwxyz123456789ABCDEFGHJKLMNPQRSTUVWXYZ';
$code ='';
do{
srand ();
for($i=0; $i<7;$i++){
$code .= $chars[rand (0,(strlen($chars)-1))];
}
} while (mysql_num_rows(mysql_query('SELECT * FROM regcodes WHERE code = \''.$code.'\''))!=0);
mysql_query('INSERT INTO regcodes (code,sacsid,date_add) VALUES (\''.$code.'\', \''. getValue('SACSID').'\',NOW())');
} else {
$regcode = mysql_fetch_assoc($res);
$code = $regcode['code'];
}
}
if(count($errors)>0){
showErrors($errors);
} else {
?>
<h3 class="subtitle text-center">Your authentication code is:</h3>
<h2 class="subtitle text-center"><?php echo $code?></h2>
<?php }
}?>
</div>
</body>
</html>