-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdatabase.php
108 lines (104 loc) · 3.17 KB
/
database.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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
<?php
// BarcodeSystem for MAGFest 2.0
// Designed for MAGFest 9 and BEYOND! by gergc and LANJesus
// File: database.php
// Purpose: Sets up some global functions and static config options
//Where is the directory path accessable to this server (WITH VHOST INTACT AND TRAILING /)
$path = 'http://quasared.net/magfest/';
$_SESSION['path'] = $path;
//$_SESSION[''] = $;
//Version
$moddate = '12/10/2010';
//Returns the type of badge based on the badge number.
function calcBadgeType($badgeid)
{
$badgetype = 'Unknown';
if($badgeid<=299) $badgetype = 'Staff';
else if($badgeid<=399) $badgetype = 'Super-Supporter';
else if($badgeid<=499) $badgetype = 'Supporter';
else if($badgeid<=649) $badgetype = 'Guest';
else if($badgeid<=899) $badgetype = 'Dealer';
else if($badgeid<=2999) $badgetype = 'Attendee';
else if($badgeid<=5249) $badgetype = 'One-Day Attendee';
return $badgetype;
}
function calcShortBadgeType($badgeid)
{
$badgetype = 'Unknown';
if($badgeid<=299) $badgetype = 'Staff';
else if($badgeid<=399) $badgetype = 'S-Support';
else if($badgeid<=499) $badgetype = 'Supporter';
else if($badgeid<=649) $badgetype = 'Guest';
else if($badgeid<=899) $badgetype = 'Dealer';
else if($badgeid<=2999) $badgetype = 'Attendee';
else if($badgeid<=5249) $badgetype = 'One Day';
return $badgetype;
}
//MySQL DB info
function connectDB(){
$conn = mysql_connect("","","") or die(mysql_error()); //removed connection info
mysql_select_db('m9bs',$conn) or die(mysql_error());
return $conn;
}
function connectUber(){
$uberconn = mysql_connect("","","") or die(mysql_error());
mysql_select_db('m9',$uberconn) or die(mysql_error());
return $uberconn;
}
function socket_read_normal($socket, $end=array("\r", "\n")){
if(is_array($end)){
foreach($end as $k=>$v){
$end[$k]=$v{0};
}
$string='';
while(TRUE){
$char=socket_read($socket,1);
$string.=$char;
foreach($end as $k=>$v){
if($char==$v){
return $string;
}
}
}
}else{
$endr=str_split($end);
$try=count($endr);
$string='';
while(TRUE){
$ver=0;
foreach($endr as $k=>$v){
$char=socket_read($socket,1);
$string.=$char;
if($char==$v){
$ver++;
}else{
break;
}
if($ver==$try){
return $string;
}
}
}
}
}
function do_post_request($url, $data, $optional_headers = null)
{
$params = array('http' => array(
'method' => 'POST',
'content' => $data
));
if ($optional_headers !== null) {
$params['http']['header'] = $optional_headers;
}
$ctx = stream_context_create($params);
$fp = @fopen($url, 'rb', false, $ctx);
if (!$fp) {
throw new Exception("Problem with $url, $php_errormsg");
}
$response = @stream_get_contents($fp);
if ($response === false) {
throw new Exception("Problem reading data from $url, $php_errormsg");
}
return $response;
}
?>