Bry Man
04-24-2005, 07:19 AM
Hey,
Im trying to get back into php lately because ive fallen in love with it again and came across an old script that I and a friend had made that was used as one of those Ip telling signature pictures that everyone had a while back. Anyways since it was written to cut the excess jargin out of the client info etc and just give plain results that anyone could understand, like Operationg system = windows xp, I figured itd be a good piece to a user information logging system, I modified it so that 'its supposed' to write the info into a text file in the same directory but when its ran it gives me this error,
Parse error: parse error, unexpected T_VARIABLE in c:\phpdev5\www\logs\logwriter.php on line 99
Here is the entire code for the scipt incase it may have something to do with something above the line specified.
<?php
//browser type
$agent = $HTTP_USER_AGENT;
if ( strstr($agent, "MSIE 5") ) $browser = "using IE 5";
elseif ( strstr($agent, "MSIE 6") ) $browser = "using IE 6";
elseif ( strstr($agent, "MSIE 4") ) $browser = "using IE 4";
elseif ( strstr($agent, "Firebird") ) $browser = "using Firebird";
elseif ( strstr($agent, "Safari") ) $browser = "using Safari";
elseif ( strstr($agent, "Mozilla/5") ) $browser = "using Mozilla/Netscape 5";
elseif ( strstr($agent, "Mozilla/6") ) $browser = "using Netscape 6";
elseif ( strstr($agent, "Mozilla/4") ) $browser = "using Netscape 4";
elseif ( strstr($agent, "Opera") ) $browser = "using Opera";
else $browser = "";
// get IP and resolve IP
$ip = $REMOTE_ADDR;
$resolved = gethostbyaddr ($REMOTE_ADDR);
// check for non resolve of IP and rip domain if resolved
if ($resolved == $ip) {
$isp = ".. Can't Resolve IP";
}
else
{
$str = preg_split("/\./", $resolved);
$i = count($str);
$x = $i - 1;
$n = $i - 2;
$isp = $str[$n] . "." . $str[$x];
}
// Simple OS Detection
$os = $HTTP_USER_AGENT;
$oslist = Array (
// Windows
"Win|Windows",
"Win16|Windows",
"Win95|Windows 95",
"Win98|Windows 98",
"WinME|Windows ME",
"Win32|Windows",
"WinNT|Windows NT",
"Windows 3.1|Windows 3.1",
"Windows 95|Windows 95",
"Windows CE|Windows CE",
"Windows 98|Windows 98",
"Windows ME|Windows ME",
"Windows NT|Windows NT",
"Windows NT 5.0|Windows 2000",
"Windows NT 5.1|Windows XP",
// Macintosh
"Mac_68000|MacOS m68K",
"Mac_68K|MacOS m68K",
"Mac_PowerPC|MacOS PPC",
"Mac_PPC|MacOS PPC",
"Macintosh|MacOS",
// Unices
"X11|UNIX",
"BSD|BSD",
"SunOS|SunOS",
"IRIX|IRIX",
"HP-UX|HP-UX",
"AIX|AIX",
"QNX|QNX",
"SCO_SV|SCO UNIX",
"FreeBSD|FreeBSD",
"NetBSD|NetBSD",
// Linux
"Linux|Linux",
"Debian|Debian GNU/Linux",
// Other
"BeOS|BeOS",
"OS/2|OS/2",
"AmigaOS|AmigaOS",
);
foreach ($oslist as $osnow) {
$osnow = explode ("|", $osnow);
if (eregi ($osnow[0], $os)) {
$endos = $osnow[1];
$check = "No";
} elseif ($check != "No") {
$endos = "Unknown";
}
}
// Opens the log file for writing and writes
$start = "-------------------------------------------------------------------------------------------";
$content1 = "Visitors Ip - " $ip;
$content2 = "Visitors ISP - " $isp;
$content3 = "Visitors Operating System - " $os;
$content4 = "Visitors Browser - " $browser;
$end = "-------------------------------------------------------------------------------------------";
$fp = fopen("log.txt","a");
fwrite($fp,"$start content1 $content2 $content3 $content4 $end");
fclose($fp);
?>
Line 99 is the line at the botton that starts with the $content1 variable, im a bit rusty on my php but I thought that the unexpected T_variable was caused by an important character or something missing from the script but I didnt leave anything out?
Hopefully its not too much trouble and It will start working, this could be pretty useful for me and maybe other people even though its a bit dated ( no detection for firefox ), from here im trying to learn how to get this stuff put into a mysql database, but thatll be for another day.
Thanks to those who reply in advance cuz im low on sleep and wont be able to reply for about 12 hours, as ill be sleeping.
Im trying to get back into php lately because ive fallen in love with it again and came across an old script that I and a friend had made that was used as one of those Ip telling signature pictures that everyone had a while back. Anyways since it was written to cut the excess jargin out of the client info etc and just give plain results that anyone could understand, like Operationg system = windows xp, I figured itd be a good piece to a user information logging system, I modified it so that 'its supposed' to write the info into a text file in the same directory but when its ran it gives me this error,
Parse error: parse error, unexpected T_VARIABLE in c:\phpdev5\www\logs\logwriter.php on line 99
Here is the entire code for the scipt incase it may have something to do with something above the line specified.
<?php
//browser type
$agent = $HTTP_USER_AGENT;
if ( strstr($agent, "MSIE 5") ) $browser = "using IE 5";
elseif ( strstr($agent, "MSIE 6") ) $browser = "using IE 6";
elseif ( strstr($agent, "MSIE 4") ) $browser = "using IE 4";
elseif ( strstr($agent, "Firebird") ) $browser = "using Firebird";
elseif ( strstr($agent, "Safari") ) $browser = "using Safari";
elseif ( strstr($agent, "Mozilla/5") ) $browser = "using Mozilla/Netscape 5";
elseif ( strstr($agent, "Mozilla/6") ) $browser = "using Netscape 6";
elseif ( strstr($agent, "Mozilla/4") ) $browser = "using Netscape 4";
elseif ( strstr($agent, "Opera") ) $browser = "using Opera";
else $browser = "";
// get IP and resolve IP
$ip = $REMOTE_ADDR;
$resolved = gethostbyaddr ($REMOTE_ADDR);
// check for non resolve of IP and rip domain if resolved
if ($resolved == $ip) {
$isp = ".. Can't Resolve IP";
}
else
{
$str = preg_split("/\./", $resolved);
$i = count($str);
$x = $i - 1;
$n = $i - 2;
$isp = $str[$n] . "." . $str[$x];
}
// Simple OS Detection
$os = $HTTP_USER_AGENT;
$oslist = Array (
// Windows
"Win|Windows",
"Win16|Windows",
"Win95|Windows 95",
"Win98|Windows 98",
"WinME|Windows ME",
"Win32|Windows",
"WinNT|Windows NT",
"Windows 3.1|Windows 3.1",
"Windows 95|Windows 95",
"Windows CE|Windows CE",
"Windows 98|Windows 98",
"Windows ME|Windows ME",
"Windows NT|Windows NT",
"Windows NT 5.0|Windows 2000",
"Windows NT 5.1|Windows XP",
// Macintosh
"Mac_68000|MacOS m68K",
"Mac_68K|MacOS m68K",
"Mac_PowerPC|MacOS PPC",
"Mac_PPC|MacOS PPC",
"Macintosh|MacOS",
// Unices
"X11|UNIX",
"BSD|BSD",
"SunOS|SunOS",
"IRIX|IRIX",
"HP-UX|HP-UX",
"AIX|AIX",
"QNX|QNX",
"SCO_SV|SCO UNIX",
"FreeBSD|FreeBSD",
"NetBSD|NetBSD",
// Linux
"Linux|Linux",
"Debian|Debian GNU/Linux",
// Other
"BeOS|BeOS",
"OS/2|OS/2",
"AmigaOS|AmigaOS",
);
foreach ($oslist as $osnow) {
$osnow = explode ("|", $osnow);
if (eregi ($osnow[0], $os)) {
$endos = $osnow[1];
$check = "No";
} elseif ($check != "No") {
$endos = "Unknown";
}
}
// Opens the log file for writing and writes
$start = "-------------------------------------------------------------------------------------------";
$content1 = "Visitors Ip - " $ip;
$content2 = "Visitors ISP - " $isp;
$content3 = "Visitors Operating System - " $os;
$content4 = "Visitors Browser - " $browser;
$end = "-------------------------------------------------------------------------------------------";
$fp = fopen("log.txt","a");
fwrite($fp,"$start content1 $content2 $content3 $content4 $end");
fclose($fp);
?>
Line 99 is the line at the botton that starts with the $content1 variable, im a bit rusty on my php but I thought that the unexpected T_variable was caused by an important character or something missing from the script but I didnt leave anything out?
Hopefully its not too much trouble and It will start working, this could be pretty useful for me and maybe other people even though its a bit dated ( no detection for firefox ), from here im trying to learn how to get this stuff put into a mysql database, but thatll be for another day.
Thanks to those who reply in advance cuz im low on sleep and wont be able to reply for about 12 hours, as ill be sleeping.