morbiuswilters
By: a guest | Apr 30th, 2008 | Syntax:
PHP | Size: 7.10 KB | Hits: 215 | Expires: Never
#!/usr/bin/php
<?php
$night_int = 20;
if (in_array($day, array(0
, 6
)) || ($hour < 9
) || ($hour > 17
)) {
if ($min % $night_int) {
echo("off-hours, skipping..\n");
}
}
$q = "SELECT * FROM prefs WHERE (name IN ('site_pass', 'site_cookie'))";
$prefs[$a['name']] = $a['value'];
}
$sfd = fsockopen('www.coldfusioncoderz.com', 80
);
$resp = http('/users/list.php');
$tmp = explode('<div class="content_area">', $resp);
for ($i = 1; $i < count($tmp); $i++) {
$pos1 = strpos($tmp[$i], '<a href="/users/') + 18;
$pos2 = strpos($tmp[$i], '.php">', $pos1);
$pos3 = strpos($tmp[$i], 'uid=', $pos2) + 7;
$pos4 = strpos($tmp[$i], '&', $pos3);
$pos5 = strpos($tmp[$i], '"', $pos3);
if (!$pos4 || ($pos5 < $pos4)) {
$pos4 = $pos5;
}
$name = substr($tmp[$i], $pos1, ($pos2 - $pos1));
$id = substr($tmp[$i], $pos3, ($pos4 - $pos3));
$users[$name] = $id;
}
echo("could not find any users, bailing..\n");
}
$q = "SELECT * FROM user_alerts";
if (isset($users[$a['user']])) {
unset($users[$a['user']]);
$tmp[] = $a;
} else {
}
}
foreach ($users as $user => $uid) {
$tmp[] = array('user' => $user, 'user_id' => $uid, 'last_activity' => 0
);
}
$users = $tmp;
foreach ($users as $user) {
$url = '/activity.php&uid=' . $user['user_id'];
$data = http($url);
$data = explode('<div class="user_activity_class"><a href="', $data);
$last_act = 0;
for ($i = 1; $i < count($data); $i++) {
$pos = strpos($data[$i], '"');
$tmp = substr($data[$i], 0
, $pos);
if (!$last_act) {
$last_act = $act_id;
}
if (!$user['last_activity'] || ($act_id == $user['last_activity'])) {
break;
}
activity_alert($user['user'], $tmp);
}
if ($user['last_activity'] != $last_act) {
}
}
function activity_alert($user, $act)
{
static $sfd;
}
$msg = "RAW PRIVMSG #ColdFusionCoderz :Activity Alert! $user has done $act\r\n";
echo($msg);
}
function http
($url, $post = array(), $is_login = false)
{
if (!isset($GLOBALS['prefs']['site_cookie']) && !$is_login) {
login();
}
$type = count($post) ?
'POST' : 'GET';
$type . ' ' . $url . ' HTTP/1.1',
'Host: www.coldfusioncoderz.com',
'Keep-Alive: 300',
'Connection: keep-alive',
);
if (isset($GLOBALS['prefs']['site_cookie'])) {
$req[] = 'Cookie: ' . $GLOBALS['prefs']['site_cookie'];
}
$post_data = '';
foreach ($post as $k => $v) {
}
$post_data = substr($post_data, 0
, -1
);
$req[] = 'Content-Type: application/x-www-form-urlencoded';
$req[] = 'Content-length: ' . strlen($post_data);
$req[] = "\r\n" . $post_data;
}
$req = implode("\r\n", $req) . "\r\n\r\n";
fwrite($GLOBALS['sfd'], $req);
$resp = '';
$chunked = false;
$length = 0;
while (1) {
$tmp = fgets($GLOBALS['sfd']);
$resp .= $tmp;
if (!$length && !$chunked) {
if (strpos($lower, 'content-length') !== false) {
} else if (strpos($lower, 'transfer-encoding: chunked')) {
$chunked = true;
}
}
break;
}
}
$read = 0;
$to_read = 65000;
while (1) {
if ($length) {
while ($read < $length) {
$t = $length - $read;
if ($t < $to_read) {
$to_read = $t;
}
$s = fread($GLOBALS['sfd'], $to_read);
$resp .= $s;
}
$length = 0;
} else if ($chunked) {
$read = 0;
$to_read = 65000;
} else {
fwrite($GLOBALS['sfd'], "\r\n");
return $resp;
}
}
}
function login()
{
'username' => 'cold_fusion_rockz',
'password' => $GLOBALS['prefs']['site_pass'],
);
$login = http('/login.php', $post, true);
if (!strpos($login, 'PHPSESSID=')) {
echo("no cookie got on login!\n");
}
$tmp = explode('Set-Cookie: PHPSESSID=', $login);
$cookie = "PHPSESSID=" . $tmp2[0];
$del = "DELETE FROM prefs WHERE (name = 'site_cookie')";
$ins = "INSERT INTO prefs (name, value) VALUES ('site_cookie', '" . mysql_escape_string($cookie) . "')";
$GLOBALS['prefs']['site_cookie'] = $cookie;
}