2011-06-02 00:48:29 +02:00
|
|
|
<?php
|
2011-06-02 23:41:50 +02:00
|
|
|
|
2011-12-21 22:20:06 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Leitet den Browser an die übergebene URL weiter und hält das Script an.
|
|
|
|
*/
|
|
|
|
function redirect($to) {
|
|
|
|
header("Location: " . $to, true, 302);
|
|
|
|
die();
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Gibt den gefilterten REQUEST Wert ohne Zeilenumbrüche zurück
|
|
|
|
*/
|
2011-06-02 23:41:50 +02:00
|
|
|
function strip_request_item($name) {
|
2011-12-21 22:20:06 +01:00
|
|
|
return strip_item($_REQUEST[$name]);
|
2011-06-02 23:41:50 +02:00
|
|
|
}
|
|
|
|
|
2011-12-21 22:20:06 +01:00
|
|
|
/**
|
|
|
|
* Testet, ob der angegebene REQUEST Wert ein Integer ist, bzw. eine ID sein könnte.
|
|
|
|
*/
|
|
|
|
function test_request_int($name) {
|
|
|
|
if (isset ($_REQUEST[$name]))
|
|
|
|
return preg_match("/^[0-9]*$/", $_REQUEST[$name]);
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Gibt den gefilterten REQUEST Wert mit Zeilenumbrüchen zurück
|
|
|
|
*/
|
2011-06-03 11:09:25 +02:00
|
|
|
function strip_request_item_nl($name) {
|
2012-05-19 15:59:19 +02:00
|
|
|
return preg_replace("/([^\p{L}\p{S}\p{P}\p{Z}\p{N}+\n]{1,})/ui", '', strip_tags($_REQUEST[$name]));
|
2011-12-21 22:20:06 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Entfernt unerwünschte Zeichen
|
|
|
|
*/
|
|
|
|
function strip_item($item) {
|
2012-05-19 15:59:19 +02:00
|
|
|
return preg_replace("/([^\p{L}\p{S}\p{P}\p{Z}\p{N}+]{1,})/ui", '', strip_tags($item));
|
2011-12-21 22:20:06 +01:00
|
|
|
}
|
|
|
|
|
2011-12-26 15:55:17 +01:00
|
|
|
/**
|
|
|
|
* Überprüft eine E-Mail-Adresse.
|
|
|
|
*/
|
|
|
|
function check_email($email) {
|
2012-05-19 17:08:08 +02:00
|
|
|
return (bool) preg_match("#^([a-zA-Z0-9_+\-])+(\.([a-zA-Z0-9_+\-])+)*@((\[(((([0-1])?([0-9])?[0-9])|(2[0-4][0-9])|(2[0-5][0-5])))\.(((([0-1])?([0-9])?[0-9])|(2[0-4][0-9])|(2[0-5][0-5])))\.(((([0-1])?([0-9])?[0-9])|(2[0-4][0-9])|(2[0-5][0-5])))\.(((([0-1])?([0-9])?[0-9])|(2[0-4][0-9])|(2[0-5][0-5]))\]))|((([\p{L}0-9])+(([\-])+([\p{L}0-9])+)*\.)+([\p{L}])+(([\-])+([\p{L}0-9])+)*))$#u", $email);
|
2011-12-26 15:55:17 +01:00
|
|
|
}
|
|
|
|
|
2011-12-21 22:20:06 +01:00
|
|
|
/**
|
|
|
|
* Gibt zwischengespeicherte Fehlermeldungen zurück und löscht den Zwischenspeicher
|
|
|
|
*/
|
|
|
|
function msg() {
|
|
|
|
if (!isset ($_SESSION['msg']))
|
|
|
|
return "";
|
|
|
|
$msg = $_SESSION['msg'];
|
|
|
|
$_SESSION['msg'] = "";
|
|
|
|
return $msg;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Rendert eine Information
|
|
|
|
*/
|
|
|
|
function info($msg, $immediatly = false) {
|
|
|
|
if ($immediatly) {
|
|
|
|
if ($msg == "")
|
|
|
|
return "";
|
|
|
|
return '<p class="info">' . $msg . '</p>';
|
|
|
|
} else {
|
|
|
|
if (!isset ($_SESSION['msg']))
|
|
|
|
$_SESSION['msg'] = "";
|
|
|
|
$_SESSION['msg'] .= info($msg, true);
|
|
|
|
}
|
2011-06-03 11:09:25 +02:00
|
|
|
}
|
|
|
|
|
2011-12-21 22:20:06 +01:00
|
|
|
/**
|
|
|
|
* Rendert eine Fehlermeldung
|
|
|
|
*/
|
|
|
|
function error($msg, $immediatly = false) {
|
|
|
|
if ($immediatly) {
|
|
|
|
if ($msg == "")
|
|
|
|
return "";
|
|
|
|
return '<p class="error">' . $msg . '</p>';
|
|
|
|
} else {
|
|
|
|
if (!isset ($_SESSION['msg']))
|
|
|
|
$_SESSION['msg'] = "";
|
|
|
|
$_SESSION['msg'] .= error($msg, true);
|
|
|
|
}
|
2011-06-02 00:48:29 +02:00
|
|
|
}
|
|
|
|
|
2011-12-21 22:20:06 +01:00
|
|
|
/**
|
|
|
|
* Rendert eine Erfolgsmeldung
|
|
|
|
*/
|
|
|
|
function success($msg, $immediatly = false) {
|
|
|
|
if ($immediatly) {
|
|
|
|
if ($msg == "")
|
|
|
|
return "";
|
|
|
|
return '<p class="success">' . $msg . '</p>';
|
|
|
|
} else {
|
|
|
|
if (!isset ($_SESSION['msg']))
|
|
|
|
$_SESSION['msg'] = "";
|
|
|
|
$_SESSION['msg'] .= success($msg, true);
|
|
|
|
}
|
2011-06-02 00:48:29 +02:00
|
|
|
}
|
2011-06-02 23:41:50 +02:00
|
|
|
?>
|