Diese kleine Funktion garantiert, dass Besucher zu einer URL weitergeleitet werden. Zuerst versucht die Funktion, den Benutzer mit der header() Funktion weiterzuleiten, geht das nicht, wird Javascript und META-Refresh versucht. Wenn auch das nicht geht, wird ein Link angezeigt.
function safe_redirect($url, $exit=true) {
// Only use the header redirection if headers are not already sent
if (!headers_sent()){
header('HTTP/1.1 301 Moved Permanently');
header('Location: ' . $url);
// Optional workaround for an IE bug (thanks Olav)
header("Connection: close");
}
// HTML/JS Fallback:
// If the header redirection did not work, try to use various methods other methods
print '';
print 'Redirecting you...';
print '';
print '';
print '';
// If the javascript and meta redirect did not work,
// the user can still click this link
print 'You should be redirected to this URL:
';
print "<a href="$url">$url</a>
";
print 'If you are not, please click on the link above.
';
print '';
print '';
// Stop the script here (optional)
if ($exit) exit;
}
Quelle: jonasjohn.de
Das kleine PHP-Script zeigt, wie man das EXIF Thumbnail aus einem Bild extrahieren kann.
// file to read
$file = 'test.jpg';
$image = exif_thumbnail($file, $width, $height, $type);
// width, height and type get filled with data
// after calling "exif_thumbnail"
if ($image) {
// send header and image data to the browser:
header('Content-type: ' .image_type_to_mime_type($type));
print $image;
}
else {
// there is no thumbnail available, handle the error:
print 'No thumbnail available';
}
Quelle: jonasjohn.de
Das Perfect Quotes Widget für WordPress von Brandon Ferens von der Perfect Space, Inc. ermöglicht es Quotes einzugeben und diese dann in zufälliger Reihenfolge in einem speziellen Widget, mit Hilfe eines Shortcodes oder basiert auf Custom Post Types anzuzeigen.
Eine weitere kleine Routine zum Checken ob HTTPS auf einem Server zur Verfügung ist. Eine andere Routine zum gleichen Zweck ist unter diesem Link zu finden.
if (isset($_SERVER['HTTPS']) &&
strtolower($_SERVER['HTTPS']) == 'on') {
$protokoll = 'https://';
} else {
$protokoll = 'http://';
}
Das Upload to Dropbox Plugin für WordPress ermöglicht es Dateien direkt von WordPress aus in der Dropbox (Cloud Service) abzulegen.
Diese PHP Funktion verwandelt einen als Text eingefügten Link automatisch zu einem anklickbaren Link.
function dolink($subject) {
$muster = "/(http:\/\/)?([a-zA-Z0-9\-.]+\.[a-zA-Z0-9\-]+([\/]([a-zA-Z0-9_\/\-.?&%=+])*)*)/";
$ersetzen = "<a href="\"http://$2\"">$2</a>";
return preg_replace($muster, $ersetzen, $subject);
}