<?php
$url = stripslashes($_GET['url']);
$user_id = stripslashes($_GET['user_id']);
$tag_id = $_GET['tag_id'];
$self = 'http://' . $_SERVER['HTTP_HOST'] . $_SERVER['PHP_SELF'];
if ($url && $tag_id)
{
$content = '';
function local_url($s)
{
if (file_exists(ereg_replace("\?.*", '', $s)))
{
$s = 'http://' . $_SERVER['HTTP_HOST'] . dirname($_SERVER['PHP_SELF']) . '/'. $s;
}
return $s;
}
function prepare($s)
{
$s = addslashes($s);
$s = str_replace("\r", '\r', $s);
$s = str_replace("\n", '\n', $s);
return $s;
}
if ($fp = @fopen(local_url($url), 'rb'))
{
while (strlen($buf = fread($fp, 8192))) $content .= $buf;
fclose($fp);
?>
if (window.hgObj && hgObj.onrecv) {
hgObj.onrecv('<?php echo prepare($content); ?>', '<?php echo prepare($user_id); ?>', '<?php echo prepare($url); ?>')
setTimeout("document.getElementsByTagName('head').item(0).removeChild(document.getElementById('<?php echo $tag_id; ?>'))",1)
}
<?php
}
else
{
?>
if (window.hgObj && hgObj.onerror) {
hgObj.onerror('<?php echo prepare($user_id); ?>', '<?php echo prepare($url); ?>')
setTimeout("document.getElementsByTagName('head').item(0).removeChild(document.getElementById('<?php echo $tag_id; ?>'))",1)
}
<?php
}
}
if (!$url && !$tag_id && !$id)
{
?>
function httpGetObject() {
this.onrecv = null
this.onerror = null
this.get = function(url, userId) {
var getScript = document.createElement('script')
with (getScript) {
id = (new Date()).getTime() + Math.random()
type = 'text/javascript'
src = '<?php echo $self; ?>?url=' + escape(url) + '&user_id=' + escape(userId) + '&tag_id=' + id
}
document.getElementsByTagName('head').item(0).appendChild(getScript)
}
return this
}
window.hgObj = new httpGetObject()
<?php
}
?>