Warnung: file_put_contents(/home/www/web1/html/php_dev/test.txt) [function.file-put-contents]: failed to open stream: Permission denied in /home/www/web1/html/php_dev/sys/lib.activity.php (Zeile 58)
Bild-Problem.. [Archiv] - PHP-Scripte PHP-Tutorials PHP-Jobs und vieles mehr
ebiz-webhosting
- Ad -
php-resource




Archiv verlassen und diese Seite im Standarddesign anzeigen :
Bild-Problem..


 
c-r-y
19-02-2006, 16:04 
 
Heyho,

ich moechte ein Content-Napping machen, wo die Daten des Users stehen => Sprich IP, Betriebssystem, Hostname, ...

Der Code fuer das Erstellen des Bildes:

<?php
error_reporting(E_ALL);

//what we want the image to say.
function getip() {
if (getenv("HTTP_X_FORWARDED_FOR")) {
$realip = getenv("HTTP_X_FORWARDED_FOR");
} else {
$realip = getenv("REMOTE_ADDR");
}
return $realip;
}

$ip = "IP: ".$realip;
$host = "Hostname: ".gethostbyaddr($ip);

if (strstr($HTTP_USER_AGENT, "Windows 95")) {
$bs = "Win95"; }
else if (strstr($HTTP_USER_AGENT, "Windows 98")) {
$bs = "Win98"; }
else if (strstr($HTTP_USER_AGENT, "NT 4.0")) {
$bs = "NT"; }
else if (strstr($HTTP_USER_AGENT, "NT 5.0")) {
$bs = "Win2k"; }
else if (strstr($HTTP_USER_AGENT, "NT 5.1")) {
$bs = "WinXP"; }
else if (strstr($HTTP_USER_AGENT, "Win")) {
$bs = "Win"; }
else if (strstr($HTTP_USER_AGENT, "Mac")) {
$bs = "Mac"; }
else if (strstr($HTTP_USER_AGENT, "Linux")) {
$bs = "Linux"; }
else if (strstr($HTTP_USER_AGENT, "Unix")) {
$bs = "Unix"; }
else {
$bs = "Other"; }
$betriebssystem = "Betriebssystem: ".$bs;

if (ereg("MSIE", $HTTP_USER_AGENT)) {
if (strstr($HTTP_USER_AGENT, "MSIE 5.0")) {
$browser = "IE5";
} else if (strstr($HTTP_USER_AGENT,'MSIE 5.5')) {
$browser ="IE55";
} else if (strstr($HTTP_USER_AGENT,'MSIE 6.0')) {
$browser ="IE6";
} else {
$browser ="IE";
}
} else if (ereg("Opera", $HTTP_USER_AGENT)) {
$browser ="Opera";
} else if (ereg("Mozilla/([0-9].[0-9]{1,2})", $HTTP_USER_AGENT)) {
$browser = "Mozilla";
} else {
$browser = "Other";
}
$browsers = "Browser: ".$browser;

$pic=ImageCreateFromGif("sig1.gif"); //(width, height)

//colour1
$col1=ImageColorAllocate($pic,0,0,0);

//Add the string to the image
ImageString($pic, 2, 0, 0, $ip."\n".$host."\n".$betriebssystem."\n".$browsers, $col1);

// Date in the past, so that the image is not cached by the browser
Header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");

//tell the browser what it's about to recieve
Header("Content-type: image/gif");

//actually create the GIF
ImageGIF($pic);

//clean up!
ImageDestroy($pic);

?>


Wenn ich aber nun die "index.php" aufrufe kommt:
Die Grafik "[URL meiner Seite]" kann nicht angezeigt werden, weil sie Fehler enthält.

 
derHund
19-02-2006, 18:56 
 
mach die header-zeilen weg, und sieh dir die fehlermeldung an.

 
c-r-y
19-02-2006, 19:22 
 
Heyho,

danke erstmal fuer deine Antwort! :)

Es kommt folgender Fehler:

Warning: gethostbyaddr(): Address is not a valid IPv4 or IPv6 address in /var/www/virtual/c-r-y.de/htdocs/detail/index.php on line 15

Ich hab' den Fehler, das Script muss so lauten:

<?php
error_reporting(E_ALL);

//what we want the image to say.
function getip() {
if (getenv("HTTP_X_FORWARDED_FOR")) {
$realip = getenv("HTTP_X_FORWARDED_FOR");
} else {
$realip = getenv("REMOTE_ADDR");
}
return $realip;
}

$ip = "IP: ".getip();
$host = "Hostname: ".gethostbyaddr(getip());

if (strstr($HTTP_USER_AGENT, "Windows 95")) {
$bs = "Win95"; }
else if (strstr($HTTP_USER_AGENT, "Windows 98")) {
$bs = "Win98"; }
else if (strstr($HTTP_USER_AGENT, "NT 4.0")) {
$bs = "NT"; }
else if (strstr($HTTP_USER_AGENT, "NT 5.0")) {
$bs = "Win2k"; }
else if (strstr($HTTP_USER_AGENT, "NT 5.1")) {
$bs = "WinXP"; }
else if (strstr($HTTP_USER_AGENT, "Win")) {
$bs = "Win"; }
else if (strstr($HTTP_USER_AGENT, "Mac")) {
$bs = "Mac"; }
else if (strstr($HTTP_USER_AGENT, "Linux")) {
$bs = "Linux"; }
else if (strstr($HTTP_USER_AGENT, "Unix")) {
$bs = "Unix"; }
else {
$bs = "Other"; }
$betriebssystem = "Betriebssystem: ".$bs;

if (ereg("MSIE", $HTTP_USER_AGENT)) {
if (strstr($HTTP_USER_AGENT, "MSIE 5.0")) {
$browser = "IE5";
} else if (strstr($HTTP_USER_AGENT,'MSIE 5.5')) {
$browser ="IE55";
} else if (strstr($HTTP_USER_AGENT,'MSIE 6.0')) {
$browser ="IE6";
} else {
$browser ="IE";
}
} else if (ereg("Opera", $HTTP_USER_AGENT)) {
$browser ="Opera";
} else if (ereg("Mozilla/([0-9].[0-9]{1,2})", $HTTP_USER_AGENT)) {
$browser = "Mozilla";
} else {
$browser = "Other";
}
$browsers = "Browser: ".$browser;

$pic=ImageCreateFromGif("sig1.gif"); //(width, height)

//colour1
$col1=ImageColorAllocate($pic,0,0,0);

//Add the string to the image
ImageString($pic, 2, 0, 0, $ip."".$host."".$betriebssystem."".$browsers, $col1);

// Date in the past, so that the image is not cached by the browser
Header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");

//tell the browser what it's about to recieve
Header("Content-type: image/gif");

//actually create the GIF
ImageGIF($pic);

//clean up!
ImageDestroy($pic);

?>


Ich hatte dieses falsch:

function getip() {
if (getenv("HTTP_X_FORWARDED_FOR")) {
$realip = getenv("HTTP_X_FORWARDED_FOR");
} else {
$realip = getenv("REMOTE_ADDR");
}
return $realip;
}

$ip = "IP: ".getip(); // Hier hatte ich $realip
$host = "Hostname: ".gethostbyaddr(getip()); // hier hatte ich gehostbyaddr($ip);

Kein wunder das es net ging! :|

Danke!

- -

Alle Zeitangaben in WEZ +2. Es ist jetzt 19:11 Uhr.