This repository has been archived by the owner on Feb 10, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconn.php
54 lines (43 loc) · 1.47 KB
/
conn.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
<?php
/** SIMPLE redo of connect.php **/
/** Should, over time, move MOST scripts to this version. **/
/** In the interest of simplicity and efficiency. **/
$link = mysql_connect('localhost', 'logbook') or die("Could not connect".mysql_error());
mysql_select_db('wsbf', $link) or die("Could not select database");
function genProfileURL($username) {
if($username == '') return "#";
$url = "#";
$username = strtolower($username);
$username = str_replace(' to ', '-', $username);
$username = str_replace(' ', '-', $username);
$username = str_replace('...', '', $username); //nolan whitman
$url = "http://" . $_SERVER['HTTP_HOST'] . "/users/" . $username;
return $url;
}
function getNumConnections ($url) {
$statarr=file($url);
$nextLine = FALSE;
$lookFor = "<td>Current Listeners";
$prefix = "<td class=\"streamdata\">";
$suffix = "</td>";
$listeners = 0;
foreach ($statarr as $line) {
$where = strpos($line, $lookFor);
if($where !== FALSE) {
$nextLine = TRUE;
continue;
}
if($nextLine === TRUE) {
$content = str_replace($prefix, '', $line);
$content = str_replace($suffix, '', $content);
$listeners += (int)$content;
$nextLine = FALSE;
}
}
return $listeners;
}
function sendErrorMessage($showID, $comments){
$q = sprintf("INSERT INTO errors (showID, comments) VALUES ('%d', '%s')", $showID, mysql_real_escape_string($comments));
mysql_query($q) or die("MySQL error in file " . __FILE__ . " near line " . __LINE__ . ": " . mysql_error());
}
?>