"; $input = strip_tags($input, $allowable_tags); $input = htmlspecialchars($input); return $input; } function clean_data($input){ $input = nl2br($input); $input = addslashes($input); return $input; } function reverse_data($input){ $input = str_replace("
","",$input); return $input; } function makeSlug($string,$space="-") { if (function_exists('iconv')) { $string = @iconv('UTF-8', 'ASCII//TRANSLIT', $string); } $string = preg_replace("/[^a-zA-Z0-9 -]/", "", $string); $string = strtolower($string); $string = str_replace(" ", $space, $string); return $string; } function checkEmail($email){ // Check the @ symbol and the lenghts if (!ereg("^[^@]{1,64}@[^@]{1,255}$", $email)) { // Email invalid because wrong number of characters in one section, or wrong number of @ symbols return false; } // Split it into sections $email_array = explode("@", $email); $local_array = explode(".", $email_array[0]); for ($i = 0; $i < sizeof($local_array); $i++) { if (!ereg("^(([A-Za-z0-9!#$%&'*+/=?^_`{|}~-][A-Za-z0-9!#$%&'*+/=?^_`{|}~\.-]{0,63})|(\"[^(\\|\")]{0,62}\"))$", $local_array[$i])) { return false; } } if (!ereg("^\[?[0-9\.]+\]?$", $email_array[1])) { $domain_array = explode(".", $email_array[1]); if (sizeof($domain_array) < 2) { return false; } for ($i = 0; $i < sizeof($domain_array); $i++) { if (!ereg("^(([A-Za-z0-9][A-Za-z0-9-]{0,61}[A-Za-z0-9])|([A-Za-z0-9]+))$", $domain_array[$i])) { return false; } } } return true; } function sanitize($input){ if(is_array($input)){ foreach($input as $k=>$i){ $output[$k]=sanitize($i); } } else{ if(get_magic_quotes_gpc()){ $input=stripslashes($input); } $output=mysql_real_escape_string($input); } return $output; } function sendMail($email, $subject, $body, $from = "info@kopieergigant.nl", $fromname = "Kees TM Webmanager", $attach = ''){ require_once("libraries/phpmailer/class.phpmailer.php"); $mail = new PHPMailer(); $mail->IsHTML(false); // HTML Mail $mail->From = $from; // Sender Email $mail->FromName = $fromname; // Sender Name $mail->Subject = $subject; // Subject $mail->Body = $body; // Content $mail->AddAddress($email, $email); // Add address if($attach){ $mail->AddAttachment($_SERVER['DOCUMENT_ROOT']."/media/uploads/cv/".$attach); } if($mail->Send()){ return true; } else return false; } function templateString($variable, $template){ require_once('libraries/smarty/Smarty.class.php'); $smarty = new Smarty(); $smarty->template_dir = SMARTY_TEMPLATEDIR; $smarty->compile_dir = SMARTY_COMPILEDIR; $smarty->cache_dir = SMARTY_CACHEDIR; $smarty->config_dir = SMARTY_CONFIGDIR; $smarty->assign('var', $variable); $string = $smarty->fetch($template); return $string; } function getYears($birthday){ list($year,$month,$day) = explode("-",$birthday); $year_diff = date("Y") - $year; $month_diff = date("m") - $month; $day_diff = date("d") - $day; if ($month_diff < 0) $year_diff--; elseif (($month_diff==0) && ($day_diff < 0)) $year_diff--; return $year_diff; } function generatePassword ($length = 8) { // start with a blank password $password = ""; // define possible characters $possible = "0123456789bcdfghjkmnpqrstvwxyz"; // set up a counter $i = 0; // add random characters to $password until $length is reached while ($i < $length) { // pick a random character from the possible ones $char = substr($possible, mt_rand(0, strlen($possible)-1), 1); // we don't want this character if it's already in the password if (!strstr($password, $char)) { $password .= $char; $i++; } } // done! return $password; } function getAll($sql){ $sql = mysql_query($sql); while ($row = mysql_fetch_array($sql,MYSQL_ASSOC)){ $aReturn[] = $row; } return $aReturn; } function delete_directory($dirname) { if (is_dir($dirname)) $dir_handle = opendir($dirname); if (!$dir_handle) return false; while($file = readdir($dir_handle)) { if ($file != "." && $file != "..") { if (!is_dir($dirname."/".$file)) unlink($dirname."/".$file); else delete_directory($dirname.'/'.$file); } } closedir($dir_handle); rmdir($dirname); return true; } function convertdate($datum){ $date = explode("-", $datum); $new_date = $date[2]."-".$date[1]."-".$date[0]; return $new_date; } /**** Maak een pdf als factuur var $data object met orderdata var $products array met de producten return een opgeslagen pdf ****/ function makePDF($data, $products){ require_once('models/Pdf.php'); $pdf = new PDF(); $header = array('Artikel', 'Aantal', 'Prijs'); if(BTW_ON_BILL){ foreach($products as $key => $value){ $btw = 0; $btw += $value[2]*(BTW/100); $btw_key = $key + 1; } $products[$btw_key][0] = ''; $products[$btw_key][1] = 'incl. '.BTW.'% btw'; $products[$btw_key][2] = $btw; } if(SHIPPING){ $shipping = $btw_key + 1; $products[$shipping][0] = 'Verzendkosten'; $products[$shipping][1] = ''; $products[$shipping][2] = SHIPPING; } $pdf->AddPage(); $pdf->UserData($data); $pdf->FancyTable($header,$products); $pdfname = substr(sha1($data->lastname.$data->id), 0, 6); //$pdf->Output(); //Sla de pdf op op de server $pdf->Output('media/pdf/'.$pdfname.'.pdf', 'F'); } function redirectToIdeal($order, $products){ ### is gelijk aan 'Sleutel', zie uw dashboard onder tabblad "Certificaat uploaden" $shakey = "VE1sbW6VbwDjj704"; ### is gelijk aan 'Acceptant ID', zie uw dashboard onder tabblad "Gegevens Acceptant" $merchantID = "002015787"; ### subID niet wijzigen ### $subID = "0"; ### bedrag moet geconverteerd worden naar eurocenten ### $amount = 0; $orderNumber = $order->id; $paymentType = "ideal"; ### De geldigheid van de aanbieding zetten we in dit voorbeeld op een week ### $validUntil = date("Y-m-d\TG:i:s\Z",strtotime ("+1 week")); $aantal = count($products); $i = 1; foreach($products as $key => $value){ ### Maak de bestellijst ### ${itemNumber.$i} = $key; ${itemDescription.$i} = $value[0]; ${product.$i.number} = $value[1]; ${product.$i.price} = $value[2]; ### bereken alvast een deel van de SHA string ### $partOfSha = $partOfSha . ${itemNumber.$i} . ${itemDescription.$i} . ${product.$i.number} . ${product.$i.price}; $amount = $amount + (${product.$i.price} * ${product.$i.number}); $i++; } if(SHIPPING){ //Bezorgkosten ${itemNumber.$i} = 01; ${itemDescription.$i} = "Verzendkosten"; ${product.$i.number} = 1; ${product.$i.price} = SHIPPING; ### bereken alvast een deel van de SHA string ### $partOfSha = $partOfSha . ${itemNumber.$i} . ${itemDescription.$i} . ${product.$i.number} . ${product.$i.price}; $amount = $amount + ${product.$i.price}; $aantal += 1; } ### bouw de String op waarover een SHA1 moet worden berekend ### $shastring = $shakey . $merchantID . $subID . $amount . $orderNumber . $paymentType . $validUntil . $partOfSha ; ###speciale HTML entiteiten verwijderen: $clean_shaString = HTML_entity_decode($shastring); ### De tekens "\t", "\n", "\r", " " (spaties) mogen niet voorkomen in de string $not_allowed = array("\t", "\n", "\r", " "); $clean_shaString = str_replace($not_allowed, "",$clean_shaString); $shasign = sha1($clean_shaString); $redirect = IDEAL_URL."?amount=$amount&orderNumber=$orderNumber¤cy=EUR&purchaseID=$orderNumber&paymentType=$paymentType&validUntil=$validUntil&hash=$shasign&subID=$subID&merchantID=$merchantID&key=$shakey"; for($i=1;$i<=$aantal;$i++){ $redirect = $redirect . "&itemQuantity$i=${product.$i.number}&itemNumber$i=${itemNumber.$i}&itemDescription$i=${itemDescription.$i}&itemPrice$i=${product.$i.price}"; } return $redirect; } function setMoney($price){ setlocale(LC_MONETARY, 'it_IT'); $value = money_format('%.2n',($price)); $v1 = explode (".", $value) ; $bedrag = ''; $i=0; foreach ($v1 as $t) { if($t != '00'){ $bedrag .= $t; }else{ $bedrag .= '-'; } if(!$i){ $bedrag .= ','; } $i++; } return '€ '.$bedrag; } ?>userModel = new Gebruiker(); } public function serviceForm(){ parent::addHTML('Door hieronder uw gegevens in te vullen kan u een aanvraag voor service op uw machine doen. Als de machine in het display ook een code geeft (bijvoorbeeld sc541) geeft u dat dan alstublieft (ook) op bij de omschrijving van de klacht(en). Na ontvangst van uw melding neemt de technische dienst zo spoedig mogelijk contact met u op om een afspraak te maken.

'); parent::addHTML("
"); parent::addHTML("

Uw informatie

"); parent::textField("Naam *", 'name', FH_STRING); #parent::textField("Bedrijfsnaam *", 'company', FH_STRING); parent::textField("Telefoon nummer *", 'phone', FH_STRING); parent::textField("E-mail *", 'email', FH_EMAIL); parent::addHTML("
"); parent::addHTML("
"); parent::addHTML("

Omschrijving van de klacht

"); parent::textArea("Klacht *", 'klacht', FH_TEXT); parent::addHTML("
"); parent::setErrorMessage("name", "U bent uw naam vergeten"); #parent::setErrorMessage("company", "U bent uw bedrijfsnaam vergeten"); parent::setErrorMessage("phone", "U bent uw telefoon nummer vergeten"); parent::setErrorMessage("email", "U bent uw email vergeten"); parent::setErrorMessage("klacht", "U bent uw klacht vergeten"); parent::onCorrect(array(&$this->userModel, "sendService")); parent::setMask(FH_DEFAULT_SUBMIT_MASK, false); parent::submitButton("Formulier verzenden","submit"); return parent::flush(true); } public function belmeForm(){ parent::addHTML("
"); parent::addHTML("

Uw informatie

"); parent::textField("Naam *", 'name', FH_STRING); #parent::textField("Bedrijfsnaam *", 'company', FH_STRING); parent::textField("Telefoon nummer *", 'phone', FH_STRING); parent::addHTML("
"); parent::addHTML("
"); parent::addHTML("

Wanneer bent u beschikbaar?

"); parent::textArea("Beschikbaar *", 'beschikbaar', FH_TEXT); parent::addHTML("
"); parent::setErrorMessage("name", "U bent uw naam vergeten"); #parent::setErrorMessage("company", "U bent uw bedrijfsnaam vergeten"); parent::setErrorMessage("phone", "U bent uw telefoon nummer vergeten"); #parent::setErrorMessage("email", "U bent uw email vergeten"); parent::setErrorMessage("beschikbaar", "U bent uw beschikbaarheid vergeten"); parent::onCorrect(array(&$this->userModel, "sendBelme")); parent::setMask(FH_DEFAULT_SUBMIT_MASK, false); parent::submitButton("Formulier verzenden","submit"); return parent::flush(true); } public function offerteForm(){ parent::addHTML("
"); parent::addHTML("

Uw informatie

"); parent::textField("Naam *", 'name', FH_STRING); #parent::textField("Bedrijfsnaam *", 'company', FH_STRING); parent::textField("Telefoon nummer *", 'phone', FH_STRING); parent::textField("E-mail *", 'email', FH_EMAIL); parent::addHTML("
"); parent::addHTML("
"); parent::addHTML("

Wilt u alleen met zwart/wit of ook met kleur werken? *

"); $type = array( "kleur" => "Kleur", "zwartwit" => "Zwart/wit" ); parent::setMask(FH_DEFAULT_RADIO_MASK, false); parent::radioButton("", "type", $type, FH_NOT_EMPTY, false); parent::addHTML("
"); parent::addHTML("
"); parent::addHTML("

Hoeveel afdrukken maakt u per maand? *

"); $kopieen = array( "minderdan1500" => "Minder dan 1500", "minderdan3000" => "Minder dan 3000", "minderdan5000" => "Minder dan 5000", "meerdan5000" => "Meer dan 5000", "anders" => "Anders nl.: " ); parent::setMask(FH_DEFAULT_RADIO_MASK, false); parent::radioButton("", "kopieen", $kopieen, FH_NOT_EMPTY); parent::addHTML("
"); parent::addHTML("
"); parent::addHTML("

Welke papierformaten wilt u gebruiken? *

"); $formaten = array( "a4" => "A4", "a3" => "A3", "anders" => "Anders nl.: " ); parent::setMask(FH_DEFAULT_CHECKBOX_MASK, false); parent::checkBox("", "formaten", $formaten, FH_NOT_EMPTY); parent::addHTML("
"); parent::addHTML("
"); parent::addHTML("

Welke aanvullende functionaliteiten wenst u?


Modules

"); $modules = array( "adf" => "ADF", "aantallades" => "Aantal lades", "dubbelzijdigafdrukken" => "Dubbelzijdig afdrukken", "sorteren" => "Sorteren", "onderkast" => "Onderkast" ); parent::setMask(FH_DEFAULT_CHECKBOX_MASK, false); parent::checkBox("", "modules", $modules, null, false); parent::addHTML("

Functies

"); $functies = array( "printen" => "Printen", "fax" => "Fax", "scannen" => "Scannen" ); parent::setMask(FH_DEFAULT_CHECKBOX_MASK, false); parent::checkBox("", "functies", $functies, null, false); parent::addHTML("
"); parent::addHTML("
"); parent::addHTML("

Extra informatie

"); parent::textArea("Aanvullende informatie", 'extra', _FH_TEXT); parent::addHTML("
"); parent::setErrorMessage("name", "U bent uw naam vergeten"); #parent::setErrorMessage("company", "U bent uw bedrijfsnaam vergeten"); parent::setErrorMessage("phone", "U bent uw telefoon nummer vergeten"); parent::setErrorMessage("email", "U bent uw email vergeten"); parent::setErrorMessage("type", "U bent het type vergeten"); parent::setErrorMessage("kopieen", "U bent het aantal kopieën vergeten"); parent::setErrorMessage("formaten", "U bent de formaten vergeten"); parent::onCorrect(array(&$this->userModel, "sendOfferte")); parent::setMask(FH_DEFAULT_SUBMIT_MASK, false); parent::submitButton("Formulier verzenden","submit"); return parent::flush(true); } public function bestelForm(){ parent::addHTML("
"); #parent::addHTML("

Uw informatie

"); parent::textField("Naam *", 'name', FH_STRING); #parent::textField("Bedrijfsnaam *", 'company', FH_STRING); parent::textField("Telefoon nummer *", 'phone', FH_STRING); parent::textField("E-mail *", 'email', FH_EMAIL); parent::hiddenField("machine"); parent::setValue("machine", $_GET['page2']); parent::addHTML("
"); parent::setErrorMessage("name", "U bent uw naam vergeten"); #parent::setErrorMessage("company", "U bent uw bedrijfsnaam vergeten"); parent::setErrorMessage("phone", "U bent uw telefoon nummer vergeten"); parent::setErrorMessage("email", "U bent uw email vergeten"); parent::onCorrect(array(&$this->userModel, "sendBestelling")); parent::setMask(FH_DEFAULT_SUBMIT_MASK, false); parent::submitButton("Bestel","submit"); return parent::flush(true); } } ?>result = $this->link->query("SELECT p.* FROM wm_producten p,wm_cat c WHERE p.cat_id = c.id AND c.slug = '$slug' ORDER BY p.volgorde,p.title ASC"); while($this->row = $this->result->fetch_assoc()) { $id = $this->row['id']; $item[$id] = $this->row; } return $item; } public function getProductBySlug($slug){ $this->result = $this->link->query("SELECT * FROM ".TABLE_PREFIX."producten WHERE slug = '$slug' LIMIT 1"); while($this->row = $this->result->fetch_assoc()) { $item['text'] = $this->row['text']; $item['title'] = $this->row['title']; $item['image'] = $this->row['image']; $item['prijs'] = $this->row['prijs']; $item['actieprijs'] = $this->row['actieprijs']; $item['slug'] = $this->row['slug']; } return $item; } public function getContentItems($id){ $items = array(); $this->result = $this->link->query("SELECT * FROM ".TABLE_PREFIX."partners where parent = '$id' AND hidden = 0"); while($this->row = $this->result->fetch_assoc()) { $id = $this->row['id']; $items[$id]['slug'] = $this->row['slug']; $items[$id]['page'] = $this->row['page']; $items[$id]['id'] = $this->row['id']; } return $items; } public function getContentByParentSlug($slug){ $item = array(); $this->result = $this->link->query("SELECT c.* FROM ".TABLE_PREFIX."partners c, wm_content cc where cc.slug = '$slug' AND cc.id = c.parent AND c.hidden = 0 "); while($this->row = $this->result->fetch_assoc()) { $id = $this->row['id']; $item[$id]['text'] = $this->row['text']; $item[$id]['page'] = $this->row['page']; $item[$id]['slug'] = $this->row['slug']; $item[$id]['parent'] = $this->row['parent']; } return $item; } public function Search($search) { $searchresults = array(); $sql = "SELECT p1 . *, p2.page as parentnaam, p2.slug as parentslug FROM ".TABLE_PREFIX."partners p1, ".TABLE_PREFIX."content p2 WHERE (p1.parent = p2.id || p1.parent = 0) && (p1.page LIKE '%$search%' || p1.text LIKE '%$search%') ORDER BY parentnaam,p1.page"; $this->result = $this->link->query($sql); while($this->row = $this->result->fetch_assoc()) { $id = $this->row['id']; if($this->row['parent'] != 0 && $this->row['id'] != 15 && $this->row['id'] != 22 && $this->row['id'] != 23){ $searchresults[$id]['parentnaam'] = $this->row['parentnaam']."/"; if($this->row['parentslug'] == 'koelen-en-vriezen'){ $searchresults[$id]['parentslug'] = "koelenenvriezen/"; }else{ $searchresults[$id]['parentslug'] = $this->row['parentslug']."/"; } } if($this->row['id'] == 15 || $this->row['id'] == 22 || $this->row['id'] == 23){ // als het sliders zijn moeten de zoekresultaten anders zijn. $searchresults[$id]['slug'] = ''; $searchresults[$id]['page'] = $this->row['page']; }else{ if($this->row['slug'] == 'koelen-en-vriezen'){ $searchresults[$id]['slug'] = "koelenenvriezen"; }else{ $searchresults[$id]['slug'] = $this->row['slug']; } $searchresults[$id]['page'] = $this->row['page']; } } return $searchresults; } public function SearchProducts($search) { $productsearchresults = array(); $sql = "SELECT * FROM wm_product p3 WHERE p3.title LIKE '%$search%' || p3.text LIKE '%$search%' ORDER BY title ASC"; $this->result = $this->link->query($sql); while($this->row = $this->result->fetch_assoc()) { $id = $this->row['id']; $productsearchresults[$id]['title'] = $this->row['title']; $productsearchresults[$id]['slug'] = $this->row['slug']; } return $productsearchresults; } public function getSliderItems($cat = 'home'){ $items = array(); $this->result = $this->link->query("SELECT * FROM ".TABLE_PREFIX."slider WHERE cat = '".$cat."' ORDER BY titel"); while($this->row = $this->result->fetch_assoc()) { $items[$this->row['slider_id']] = $this->row; } return $items; } public function getSliderItemBySlug($slug){ $item = array(); $this->result = $this->link->query("SELECT * FROM ".TABLE_PREFIX."slider where slug = '$slug' limit 1"); while($this->row = $this->result->fetch_assoc()) { $item[$this->row['slider_id']] = $this->row; } return $item; } }