#require_once $webroot."includes/functions.image.php";
#
# remove an element from an array using key value
#
function array_remove($array, $key_index)
{
if (is_array($array)) {
unset($array[$key_index]);
if(gettype($key_index)!="string") {
$temparray=array();
$i=0;
foreach ($array as $value) {
$temparray[$i]=$value;
$i++;
}
$array=$temparray;
}
return $array;
}
else {
return false;
}
}
function calendarPopup($field_id) {
return "";
}
function checkAdmin() {
if (!verifyAdmin()) {
$host = $_SERVER['HTTP_HOST'];
$page = 'vineyards/';
$thisPage = $_SERVER['PHP_SELF'];
$thisPage .= ($_SERVER['QUERY_STRING'] == "" ? "" : "?".$_SERVER['QUERY_STRING']);
setMessage("error", "Unauthorized Access");
header("Location: http://$host/$page?redirect=".urlencode($thisPage));
die();
}
}
#
# This function checks if email is valid
#
function checkEmail($email) {
#
# Simplified checking
#
$email_regular_expression = "^([-\d\w][-.\d\w]*)?[-\d\w]@([-!#\$%&*+\\/=?\w\d^_`{|}~]+\.)+[a-zA-Z]{2,6}$";
#
# Full checking according to RFC 822
# Uncomment the line below to use it
# $email_regular_expression = "^[^.]{1}([-!#\$%&'*+.\\/0-9=?A-Z^_`a-z{|}~])+[^.]{1}@([-!#\$%&'*+\\/0-9=?A-Z^_`a-z{|}~]+\\.)+[a-zA-Z]{2,6}$";
return preg_match("/".$email_regular_expression."/iS", safe_email(stripslashes($email)));
}
function checkRequiredFields($reqFields)
{
// usage: $errMsg = checkRequiredFields($arrRequiredFields)
$retVal = array();
foreach($reqFields as $fldName=>$fldText) {
if (trim($_POST[$fldName]) == "") {
$retVal[] = $fldText ." is required.";
}
}
return $retVal;
}
function debug($text) {
if (!isset($_SESSION["messages"]["notify"])) {
$_SESSION["messages"]["notify"] = "";
}
$text = is_array($text) ? print_r($text, true) : wordwrap(print_r($text, true), 110, "
");
$_SESSION["messages"]["notify"] .= "
".$text.""; } function error_die($message = "unspecified error") { //only redirect if headers are not already sent. Otherwise show crude error message if (headers_sent()) { echo '