|
Alle PHP Schnipsel anzeigen | Alle PHP Schnipsel verbergen
|
CODE:
<?php
$banner = array(
//Deine Banner
array("Banner" => "<img src=\"banner1.gif\">"),
array("Banner" => "<img src=\"banner2.gif\">"),
array("Banner" => "<img src=\"banner3.gif\">")
);
function Ausgabe ($banner) {
echo "$banner";
}
function zufall($min,$max) {
srand ((double)microtime()*10000);
return (rand($min,$max));
}
$maxwert = count($banner)-1;
$nr = zufall(0,$maxwert);
$ausgabe = $banner[$nr][Banner];
Ausgabe ($ausgabe);
?>
|
|
CODE:
<?php
//Deine Datei
$file_last_modified = getlastmod("datei.php");
echo "Letztes Update ";
echo date("d.m.Y - h:i", $file_last_modified);
?>
|
|
CODE:
<?php
//Dein Ordner
$home_pfad = "ordner";
$i = 0;
$dh = opendir($home_pfad);
while ($datei = readdir($dh)) {
if($datei !== "" &&
$datei !== "." &&
$datei !== ".." &&
!is_dir($datei)) {
$i++;
}
}
echo "$i Dateien gefunden";
?>
|
|
CODE:
<?php
//IP bestimmen
$ip = getenv("REMOTE_ADDR");
//IP aufloesen und Host bestimmen
$host = gethostbyaddr($ip);
echo "Ihre IP lautet: $ip<br>\n";
echo "Ihre Hostadresse lautet: $host\n";
?>
|
|
CODE:
<?php
//Deine Grafik
$daten = getimagesize("grafik.gif");
//Grafik Formate
$formate = array("","gif","jpg","png","swf");
echo "Breite: ".$daten[0]." Pixel<br>";
echo "Hoehe: ".$daten[1]." Pixel<br>";
echo "Format: ".$formate[$daten[2]]." (".$daten[2].")<br>";
echo "HTML-Code: ".$daten[3];
?>
|
|
CODE:
<?php
//Host der Datenbank
$host = "localhost";
//Benutzername
$user = "root";
//Passwort
$password = "passwort";
//Datenbankname
$datenbank = "db";
//Verbindung zur DB
mysql_connect($host, $user, $password);
//Auswaehlen der DB
mysql_select_db($datenbank);
?>
|
|
CODE:
<?php
//Deine Datei
$fn="datei";
$fp=fopen($fn, "r");
$inhalt=fread($fp, filesize($fn));
fclose($fp);
echo $inhalt;
?>
|
|
CODE:
<?php
//IP des Servers
$ip = "127.0.0.1";
$fp = @fsockopen ("$ip", 80, $errno, $errstr, 30);
if (!$fp) {
echo "<font color=red><b>Offline</b></font>";
} else {
echo "<font color=green><b>Online</b></font>";
fclose($fp);
}
?>
|
|
CODE:
<?php
//Am Anfang der Seite
function mymicrotime() {
list($usec, $sec) = explode(" ",microtime());
return ((float)$usec + (float)$sec);
}
$time_start = mymicrotime();
/*
-> Seiten Inhalt
*/
//Am Ende der Seite
$time_end = mymicrotime();
$time = round($time_end - $time_start,4);
echo "Seite wurde in ".$time."
Sekunden generiert";
?>
|
|
CODE:
<?php
header("Location: http://www.nonegeld.de");
?>
|
|
CODE:
<?php
//Dein Verzeichnis
$verz = dir("verzeichnis");
while ($entry=$verz->read())
{
if (($entry != ".") and ($entry != ".."))
{
echo $entry . "<br>";
}
}
$verz->close();
?>
|
|
CODE:
<?php
$wochentage = array(
"Sonntag",
"Montag",
"Dienstag",
"Mittwoch",
"Donnerstag",
"Freitag",
"Samstag"
);
echo $wochentage[date("w")].", ".date("d.m.Y - H:i:s");
?>
|
|
CODE:
<b>Besucher:</b>
<br>
<?php
//counter.txt -> CHMOD 777
$datei = fopen("counter.txt","r+");
$counterstand = fgets($datei, 10);
if($counterstand == "")
{
$counterstand = 0;
}
$counterstand++;
echo $counterstand;
rewind($datei);
fwrite($datei, $counterstand);
fclose($datei);
?>
|
|