File: D:/HostingSpaces/SBogers10/promic.komma.pro/wwwroot/functions.php
<?php
function checkData($variable)
{
$variable = trim($variable);
$variable = htmlspecialchars(stripslashes($variable));
$variable = mysql_real_escape_string($variable);
return $variable;
}
function date_dutch($datum)
{
$datum_array = explode("-", $datum);
$datum = $datum_array[2]."-".$datum_array[1]."-".$datum_array[0];
return $datum;
}
function loadVideo($videoId, $width, $height)
{
$params = array();
$params['showinfo'] = 0; // do not show info
$params['autohide'] = 1; // automatically hide controls
$params['autoplay'] = 0; // automatically start playing
$params['rel'] = 0; // do not show related videos when video ends
$params['theme'] = 'light'; // player skin
$params['color'] = 'white'; // progress bar color
$params['iv_load_policy'] = 3; // video annotations not to be shown by default
$output = '<iframe id="video" width="'.$width.'" height="'.$height.'" src="https://www.youtube.com/embed/' . $videoId;
$output .= '?';
$i = 0;
foreach($params as $param => $value)
{
if($i>0) $output .= '&';
$output .= $param . '=' . $value;
$i++;
}
$output .= '" frameborder="0" allowfullscreen></iframe>';
echo $output;
}
function maand2tekst($maand)
{
$month = intval($maand) - 1;
$months = array("januari","februari","maart","april","mei","juni","juli","augustus","september","oktober","november","december");
$maand = $months[$month];
return $maand;
}
function bedrag($bedrag)
{
$bedrag = number_format($bedrag, 2, ',', '.');
return $bedrag;
}
function datum2tekst($datum){
$datum_array = explode("-", $datum);
$maand = $datum_array[1];
$maand = maand2tekst($maand);
$datum = $datum_array[2]." ".$maand." ".$datum_array[0];
return $datum;
}
function formatPrice($price) {
$price = preg_replace("/[^0-9\.]/", "", str_replace(',','.',$price));
if (substr($price,-3,1)=='.') {
$sents = '.'.substr($price,-2);
$price = substr($price,0,strlen($price)-3);
} elseif (substr($price,-2,1)=='.') {
$sents = '.'.substr($price,-1);
$price = substr($price,0,strlen($price)-2);
} else {
$sents = '.00';
}
$price = preg_replace("/[^0-9]/", "", $price);
return number_format($price.$sents,2,'.','');
}
function searchFriendly($string){
$string = preg_replace("`\[.*\]`U","",$string);
$string = str_replace('&','-en-',$string);
$string = preg_replace('`&(amp;)?#?[a-z0-9]+;`i','-',$string);
$string = htmlentities($string, ENT_COMPAT, 'utf-8');
$string = preg_replace( "`&([a-z])(acute|uml|circ|grave|ring|cedil|slash|tilde|caron|lig|quot|rsquo);`i","\\1", $string );
$string = preg_replace( array("`[^a-z0-9]`i","`[-]+`") , "-", $string);
$string = str_replace('--','-',$string);
$string = strtolower(trim($string, '-'));
return $string;
}
function weekdagAfkortingDatum($datum){
$dag = date('l', strtotime($datum));
switch ($dag) {
case "Monday":
$dagAfkorting = "Ma";
break;
case "Tuesday":
$dagAfkorting = "Di";
break;
case "Wednesday":
$dagAfkorting = "Wo";
break;
case "Thursday":
$dagAfkorting = "Do";
break;
case "Friday":
$dagAfkorting = "Vr";
break;
case "Saturday":
$dagAfkorting = "Za";
break;
case "Sunday":
$dagAfkorting = "Zo";
break;
}
return $dagAfkorting;
}
function specialCharToChar($string){
$string = preg_replace("`\[.*\]`U","",$string);
$string = preg_replace( "`&([a-z])(acute|uml|circ|grave|ring|cedil|slash|tilde|caron|lig|quot|rsquo);`i","\\1", $string );
$string = preg_replace( array("`[^a-z0-9]`i","`[-]+`") , "-", $string);
$string = str_replace('--','-',$string);
$string = strtolower(trim($string, '-'));
$string = str_replace('-',' ',$string);
return $string;
}
?>