with('count', $data['count']) ->with('thema', $thema) ->with('content', $data) ->with('afbeelding', Cache::get('afbeelding')) ->render(); } } public static function shop ($choice) { $input = Input::all(); // Check if ((!isset($input['id']) || !is_numeric($input['id'])) && ($choice != 'none' && $choice != 'aflevermethode' && $choice != 'algemene_voorwaarden')) { return; } if ((!isset($input['aantal']) || !is_numeric($input['aantal']) || ($input['aantal'] > 20)) && ($choice != 'none' && $choice != 'aflevermethode' && $choice != 'algemene_voorwaarden')) { return; } if (Session::has('producten')) { $producten = Session::get('producten'); } else { $producten = array(); } // Uniek id van het product // $id = $input['id'] . '-' . $input['eigenschappen']; if (isset($input['id'])) { $id = $input['id']; } switch ($choice) { case 'order' : // Log order if (isset($input['log'])) { // Allow mass assignment (Input::all) Eloquent::unguard(); Logger::create(array( 'id_product' => $input['id'], 'ip' => $_SERVER['REMOTE_ADDR'], 'aantal' => $input['aantal'] )); } if (isset($input['type']) && $input['type'] == 'landingspagina') { $results = DB::table('v3_landingspagina') ->select(array('v3_landingspagina.*')) ->where('v3_landingspagina.id', '=' , $input['id']) ->get(); $id = 'l-' . $id; } else { $results = DB::table('v3_product') ->select(array('v3_product.*', 'v3_categorie.id AS categorie_id', 'v3_categorie.naam AS categorie_naam', 'v3_shop.id AS shop_id', 'v3_shop.naam AS shop_naam', 'v3_shop.id_site AS shop_id_site')) ->join('v3_categorie', 'v3_product.id_categorie', '=', 'v3_categorie.id') ->join('v3_shop', 'v3_categorie.id_shop', '=', 'v3_shop.id') ->where('v3_product.id', '=' , $input['id']) ->get(); } // print_r(Site::toArray($results)); exit; $results = Site::toArray($results); if (!$results) { return; } $result = $results['0']; if (!isset($producten[$id])) { $producten[$id] = array( 'aantal' => $input['aantal'], 'product' => $result ); } else { $producten[$id]['aantal'] += $input['aantal']; } break; case 'more' : if (isset($producten[$id])) { $producten[$id]['aantal'] ++; } break; case 'less' : if (isset($producten[$id])) { $producten[$id]['aantal'] --; } if (!$producten[$id]['aantal']) { unset($producten[$id]); } break; case 'none' : if (isset($producten[$id])) { unset($producten[$id]); } break; case 'aflevermethode' : $opties = array('bezorgen', 'ophalen'); if (in_array($input['aflevermethode'], $opties)) { Session::put('aflevermethode', $input['aflevermethode']); if ($input['aflevermethode'] == 'bezorgen') { $verzendkosten_overzicht = Verzendkosten::find(1)->toArray(); Session::put('verzendkosten', $verzendkosten_overzicht['ideal_prijs']); } else { Session::put('verzendkosten', 0); } } break; case 'algemene_voorwaarden' : $opties = array(1, 0); if (in_array($input['algemene_voorwaarden'], $opties)) { Session::put('algemene_voorwaarden_checked', $input['algemene_voorwaarden']); } break; } // print_r($producten); exit; Session::put('producten', $producten); } public static function facebook ($url = '') { if (Cache::has('facebook' . $url)) { return Cache::get('facebook' . $url); } else { // include the facebook sdk include_once(SOURCE_PATH_PHP . 'facebook/facebook.php'); /* Switch on url choice */ switch ($url) { case 'https://www.facebook.com/BosveldRooibos/' : // bosveld - rooi­b­o­s­thee // connect to app $config = array(); $config['appId'] = '680973728738168'; $config['secret'] = '84fa78c26b65326d1b2c9d6404253532'; $config['fileUpload'] = false; // optional // instantiate $facebook = new Facebook($config); // set page id $pageid = "1743694339249846"; break; case 'https://www.facebook.com/BosveldBiltong/' : // bosveld - rooi­b­o­s­thee // connect to app $config = array(); $config['appId'] = '162935880821444'; $config['secret'] = '83729cd3665d6793161b95027a0034ee'; $config['fileUpload'] = false; // optional // instantiate $facebook = new Facebook($config); // set page id $pageid = "1400476073505750"; break; case 'https://www.facebook.com/BosveldCoffee/' : // bosveld - 100-africa-coffee // connect to app $config = array(); $config['appId'] = '287715151613690'; $config['secret'] = 'a06d918a3db6f73c8ec47724fc248f8f'; $config['fileUpload'] = false; // optional // instantiate $facebook = new Facebook($config); // set page id $pageid = "1682296765431497"; break; default: echo ''; return; } // now we can access various parts of the graph, starting with the feed $pagefeed = $facebook->api("/" . $pageid . "/feed"); $count = 0; $posts = array(); $html = ''; foreach($pagefeed['data'] as $post) { if (isset($post['message'])) { // array_push($posts, Site::wrap($post['message'], 60)); $html .= '
  • Française

    ' . wrap($post['message'], 100) . '
    Lees verder...

  • '; } else { // print_r($post); exit; } $count ++; if ($count > 2) { break; } } Cache::put('facebook' . $url, $html, 60); echo $html; } } public static function autocomplete () { $input = Input::all(); $results = DB::table('v3_product') ->select(array('v3_product.*', 'v3_categorie.id AS categorie_id', 'v3_categorie.naam AS categorie_naam', 'v3_shop.id AS shop_id', 'v3_shop.naam AS shop_naam', 'v3_shop.id_site AS shop_id_site')) ->join('v3_categorie', 'v3_product.id_categorie', '=', 'v3_categorie.id') ->join('v3_shop', 'v3_categorie.id_shop', '=', 'v3_shop.id') ->where(DB::raw('length(v3_product.prijs_consument)'), '>' , 0) // consumenten // ->where('v3_shop.id_site', '=' , ID_SITE) ->whereRaw('(v3_product.naam LIKE "' . utf8_encode($input['term']) . '%") OR (v3_product.eigenschap1 LIKE "' . utf8_encode($input['term']) . '%") OR (v3_product.eigenschap2 LIKE "' . utf8_encode($input['term']) . '%") OR (v3_product.eigenschap3 LIKE "' . utf8_encode($input['term']) . '%") OR (v3_product.eigenschap4 LIKE "' . utf8_encode($input['term']) . '%") OR (v3_product.eigenschap5 LIKE "' . utf8_encode($input['term']) . '%")') ->orderBy('v3_product.naam', 'asc') ->take(20) ->get(); $results = Site::toArray($results); $output = array(); if ($results) { foreach ($results as $key => $result) { array_push($output, array( 'label' => Encoding::fixUTF8(html_entity_decode($result['naam'])), 'value' => 'webshop/' . Site::sanitize(($result['categorie_naam'])) . '/' . ($result['url']) ) ); } } // print_r($output); exit; return json_encode($output); } public static function autocompleteVerkooppunt () { $input = Input::all(); $verkooppunten = Cache::get('artikel-verkooppunten'); $output = array(); if ($verkooppunten) { foreach ($verkooppunten as $verkooppunt) { if (stristr($verkooppunt['naam'], utf8_encode($input['term'])) || stristr($verkooppunt['kop'], utf8_encode($input['term']))) { array_push($output, array( 'label' => Encoding::fixUTF8(html_entity_decode($verkooppunt['naam'])), 'value' => $verkooppunt['id'] ) ); } } } return json_encode($output); } public static function mail ($form, $input) { switch ($form) { case 'contact' : if (isset($input['voornaam']) && isset($input['achternaam']) && isset($input['emailadres']) && filter_var($input['emailadres'], FILTER_VALIDATE_EMAIL)) { // reCAPTCHA check $keys = array( 'secret' => '6Lf_vCoUAAAAAENcZYmrFT__HQbXlnhMtRPSRgPk', 'response' => $_POST['g-recaptcha-response'] ); $URL = 'https://www.google.com/recaptcha/api/siteverify'; $c = curl_init($URL); curl_setopt($c, CURLOPT_RETURNTRANSFER, true); curl_setopt($c, CURLOPT_POST, true); curl_setopt($c, CURLOPT_POSTFIELDS, $keys); curl_setopt($c, CURLOPT_TIMEOUT, 10); curl_setopt($c, CURLOPT_ENCODING, 1); curl_setopt($c, CURLOPT_USERAGENT, 'CURL/1.1'); // curl_setopt($c, CURLOPT_ENCODING , "gzip"); $response = curl_exec($c); curl_close($c); $response = json_decode($response, true); if ($response['success']) { $header = 'contact-bedankt'; $template = 'contact'; $data = array( 'voornaam' => $input['voornaam'], 'achternaam' => $input['achternaam'], 'emailadres' => $input['emailadres'], 'onderwerp' => AFZENDER . ' - contact', 'afzender_emailadres' => AFZENDER_EMAILADRES_CONTACT ); } } break; } // echo AFZENDER_EMAILADRES; exit; if (isset($header)) { Mail::send('emails.' . $template, $input, function($message) use ($data, $input, $template, $form) { $account = 'Bosveld Nederland'; $message->getHeaders()->addTextHeader('X-SMTPAPI', '{"category": "' . $account . '"}'); $message->from(AFZENDER_EMAILADRES_CONTACT, AFZENDER)->subject($data['onderwerp']); $message->to($data['emailadres']); // print_r($input); exit; $message->bcc(AFZENDER_EMAILADRES_CONTACT, AFZENDER); /* Sla remote op */ // if (isset($data['voornaam']) && isset($data['achternaam'])) { if ($input) { $template = View::make('emails.' . $template); foreach ($input as $key => $value) { $template = $template->with($key, $value); } $template = $template->render(); } Connect::set('relatie_email', array( array( 'created_at' => date("Y-m-d H:i:s"), 'updated_at' => date("Y-m-d H:i:s"), 'emailadres' => $data['emailadres'], 'voornaam' => isset($data['voornaam']) ? $data['voornaam'] : '', 'achternaam' => isset($data['achternaam']) ? $data['achternaam'] : '', 'type' => $form, 'email' => serialize(isset($template) ? $template : '') ) )); // } }); return $header; } else { return ''; } } /* Inloggen met e-mailadres en wachtwoord. */ public static function inloggen ($input) { $response = Site::curl(array( 'action' => 'inloggen', 'emailadres' => $input['inloggen_emailadres'], 'wachtwoord' => $input['inloggen_wachtwoord'] // 'debug' => 1 )); // print_r($response); exit; /* Probeer inlog */ if ($response['relatie']) { $_SESSION['panel'] = $response; $header = 'panel'; return $header; } else { return false; } } /* Update account vanuit panel. */ public static function updateAccount ($input) { /* Update in Mimmic */ $response = Site::curl(array( 'action' => 'update_account', 'id_relatie' => Session::get('panel.relatie.id'), 'post' => serialize(Input::all()), // 'debug' => 1 )); /* Update opgeslagen accountgegevens */ Session::put('panel.relatie.voornaam', Input::get('voornaam')); Session::put('panel.relatie.achternaam', Input::get('achternaam')); Session::put('panel.relatie.straat', Input::get('straat')); Session::put('panel.relatie.huisnummer', Input::get('huisnummer')); Session::put('panel.relatie.postcode', Input::get('postcode')); Session::put('panel.relatie.plaats', Input::get('plaats')); Session::put('panel.relatie.telefoonnummer', Input::get('telefoonnummer')); Session::put('panel.relatie.emailadres', Input::get('emailadres')); } public static function pdf ($id_factuur) { /* Haal factuur en op */ $facturen = Session::get('panel.facturen'); if ($facturen) { foreach ($facturen as $factuur) { if ($factuur['id'] == $id_factuur) { // include mpdf require_once(SOURCE_PATH_PHP . 'mpdf/mpdf.php'); $filename = 'PDF ' . date('d.m.Y H:i'); $mpdf = new mPDF(); $style = ' '; // $email = str_replace('', $style, $email); // print_r($factuur); exit; $mpdf->WriteHTML(unserialize($factuur['email'])); $mpdf->Output($factuur['factuurnummer'] . '.pdf', 'D'); } } } } public static function cron () { $bestellingen = Bestelling::withTrashed()->where('created_at', '>', date("Y-m-d H:i:s", strtotime('-3 days')))->where('status', '=', 'Open')->get()->toArray(); print_r($bestellingen); exit; if ($bestellingen) { // Allow mass assignment (Input::all) Eloquent::unguard(); // Main Include require_once(SOURCE_PATH_PHP . "ideal/Connector/iDEALConnector.php"); foreach ($bestellingen as $bestelling) { // Check if (!$bestelling['transaction_id']) { continue; } /* iDeal */ if ($bestelling['type'] == 'iDeal') { // Various vars $config = new DefaultConfiguration(SOURCE_PATH_PHP . "ideal/Connector/config.conf"); $iDEALConnector = iDEALConnector::getDefaultInstance(SOURCE_PATH_PHP . "ideal/Connector/config.conf"); $response = $iDEALConnector->getTransactionStatus($bestelling['transaction_id']); /* @var $response AcquirerStatusResponse */ $acquirerID = $response->getAcquirerID(); $consumerName = $response->getConsumerName(); $consumerIBAN = $response->getConsumerIBAN(); $consumerBIC = $response->getConsumerBIC(); $amount = $response->getAmount(); $currency = $response->getCurrency(); $statusDateTime = $response->getStatusTimestamp(); $transactionID = $response->getTransactionID(); $status = $response->getStatus(); echo $bestelling['factuurnummer'] . ': ' . $status . '
    '; // Status update if (strtolower($status) != 'open') { /* Pas status aan */ Bestelling::withTrashed()->find($bestelling['id'])->update(array( 'status' => $status )); try { $result = Site::curl(array( 'action' => 'bestelling_update', 'factuurnummer' => $bestelling['factuurnummer'], 'status' => $status//, //'debug' => 1 )); } catch (Exception $ex) { // handle other exceptions (eg: InvalidArgument) } } /* Paypal */ } else if ($bestelling['type'] == 'Paypal') { // Main Include require SOURCE_PATH_PHP . 'paypal/paypalfunctions.php'; // Get details $resArray = GetShippingDetails($bestelling['transaction_id']); $ack = strtoupper($resArray["ACK"]); if ($ack == "SUCCESS" || $ack == "SUCESSWITHWARNING") { // Check payment $resArray = ConfirmPayment ($resArray); $ack = strtoupper($resArray["ACK"]); if ($ack == "SUCCESS" || $ack == "SUCCESSWITHWARNING") { $paymentStatus = $resArray["PAYMENTINFO_0_PAYMENTSTATUS"]; $pendingReason = $resArray["PAYMENTINFO_0_PENDINGREASON"]; $reasonCode = $resArray["PAYMENTINFO_0_REASONCODE"]; // Completed if (strtolower($paymentStatus) == 'completed') { /* Pas status aan */ Bestelling::withTrashed()->find($bestelling['id'])->update(array( 'status' => 'completed' )); /* Update status in Mimmic */ try { $result = Site::curl(array( 'action' => 'bestelling_update', 'factuurnummer' => $bestelling['factuurnummer'], 'status' => 'completed' //'debug' => 1 )); } catch (Exception $ex) { // handle other exceptions (eg: InvalidArgument) } // Pending } else { /* Pas status aan */ Bestelling::withTrashed()->find($bestelling['id'])->update(array( 'status' => 'pending' )); try { $result = Site::curl(array( 'action' => 'bestelling_update', 'factuurnummer' => $bestelling['factuurnummer'], 'status' => 'pending' //'debug' => 1 )); } catch (Exception $ex) { // handle other exceptions (eg: InvalidArgument) } } } else { } } else { } } } } } public static function setTicket ($data, $relatie) { // Allow mass assignment (Input::all) Eloquent::unguard(); // Add data $data['voornaam'] = $relatie['voornaam']; $data['achternaam'] = $relatie['achternaam']; $data['emailadres'] = $relatie['emailadres']; // print_r($data); print_r($relatie); exit; /* Send mail notification */ Mail::send('emails.ticket', $data, function($message) use ($data, $relatie) { $message->getHeaders()->addTextHeader('X-MC-Subaccount', 'Worldwide Ageless'); // - See more at: http://devendraverma.com/adding-smtp-header-in-laravel-4/#sthash.fl5Cx7uG.dpuf $message->from(AFZENDER_EMAILADRES_CONTACT, AFZENDER)->subject(AFZENDER . ' - ticket'); $message->to($relatie['emailadres']); $message->bcc('bestelling@worldwideageless.com', AFZENDER); $message->bcc('tech@equix.nl', 'Equix'); /* Maak een ticket aan */ $keys = array( 'created_at' => date("Y-m-d H:i:s"), 'id_relatie' => $relatie['id'], 'onderwerp' => $data['onderwerp'], 'bericht' => $data['bericht'], 'status' => 'open' ); $result = Ticket::create($keys)->toArray(); $response = Site::curl(array( 'action' => 'set_ticket', 'created_at' => date("Y-m-d H:i:s"), 'id_relatie' => $relatie['id'], 'onderwerp' => $data['onderwerp'], 'bericht' => $data['bericht'], 'status' => 'open' // 'debug' => 1 )); }); } public static function closeTicket ($data) { // Allow mass assignment (Input::all) Eloquent::unguard(); /* Send mail notification */ Mail::send('emails.ticket-antwoord', $data, function($message) use ($data) { $message->getHeaders()->addTextHeader('X-MC-Subaccount', 'Worldwide Ageless'); // - See more at: http://devendraverma.com/adding-smtp-header-in-laravel-4/#sthash.fl5Cx7uG.dpuf $message->from(AFZENDER_EMAILADRES_CONTACT, AFZENDER)->subject(AFZENDER . ' - ticket antwoord'); $message->to($data['emailadres']); $message->bcc('bestelling@worldwideageless.com', AFZENDER); $message->bcc('tech@equix.nl', 'Equix'); /* Update ticket */ Ticket::withTrashed()->where('id', '=', $data['id'])->update(array( 'updated_at' => date("Y-m-d H:i:s"), 'onderwerp' => $data['onderwerp'], 'bericht' => $data['bericht'], 'status' => 'gesloten' )); }); } public static function getTickets ($relatie) { return Ticket::where('id_relatie', '=', $relatie['id'])->orderBy('id', 'desc')->get()->toArray(); } public static function verzonden ($data) { // Allow mass assignment (Input::all) Eloquent::unguard(); /* Send mail notification */ Mail::send('emails.bestelling-verzonden', $data, function($message) use ($data) { $message->getHeaders()->addTextHeader('X-MC-Subaccount', 'Worldwide Ageless'); // - See more at: http://devendraverma.com/adding-smtp-header-in-laravel-4/#sthash.fl5Cx7uG.dpuf $message->from(AFZENDER_EMAILADRES_CONTACT, AFZENDER)->subject(AFZENDER . ' - bestelling verzonden'); $message->to($data['emailadres']); $message->bcc('bestelling@worldwideageless.com', AFZENDER); // $message->bcc('tech@equix.nl', 'Equix'); // Pas status aan Bestelling::withTrashed()->where('factuurnummer', '=', $data['factuurnummer'])->update(array( 'verzonden' => 1 )); }); } /* Generic methods */ public static function toArray($input) { return json_decode(json_encode($input), true); } public static function wrap($input, $max) { $length = 0; $words = explode(' ', $input); foreach ($words as $word) { $length += strlen($word) + 1; if ($length >= $max) { return substr($input, 0, $length) . ' …'; } } return $input; } public static function getPrice ($data, $format = false, $original = false) { /* Er is een actie gedefinieerd */ if (!$original && ($data['actie_consumenten_prijs'] != "" || $data['actie_consumenten_percentage'] != "" || $data['actie_consumenten_aantal'] != "") && /* Check op looptijd of geen looptijd */ ( ($data['actie_consumenten_datum1'] != "0000-00-00" && $data['actie_consumenten_datum2'] = "0000-00-00" && $data['actie_consumenten_datum1'] <= date('Y-m-d')) || ($data['actie_consumenten_datum1'] != "0000-00-00" && $data['actie_consumenten_datum2'] != "0000-00-00" && $data['actie_consumenten_datum1'] <= date('Y-m-d') && $data['actie_consumenten_datum2'] >= date('Y-m-d')) || ($data['actie_consumenten_datum1'] = "0000-00-00" && $data['actie_consumenten_datum2'] != "0000-00-00" && $data['actie_consumenten_datum2'] >= date('Y-m-d')) || ($data['actie_consumenten_datum1'] = "0000-00-00" && $data['actie_consumenten_datum2'] = "0000-00-00") ) ) { /* Pas actie toe */ if ($data['actie_consumenten_prijs']) { /* Prijs korting */ $prijs = $data['actie_consumenten_prijs']; $prijs = number_format(str_replace(array(','), array('.'), $prijs), 2, '.', ''); } else if ($data['actie_consumenten_percentage']) { /* Percentage korting */ $prijs = ($data['prijs_consument'] * ((100 - $data['actie_consumenten_percentage']) / 100)); $prijs = number_format(str_replace(array(','), array('.'), $prijs), 2, '.', ''); } else if ($data['actie_consumenten_aantal']) { /* Aantal korting */ /* */ /* Standaard prijs */ $prijs = $data['prijs_consument']; /* Aantal wordt in het overzicht berekent */ } else { /* Standaard prijs */ $prijs = $data['prijs_consument']; $prijs = number_format(str_replace(array(','), array('.'), $prijs), 2, '.', ''); } } else { /* Standaard prijs */ $prijs = $data['prijs_consument']; $prijs = number_format(str_replace(array(','), array('.'), $prijs), 2, '.', ''); } /* Formateren */ if ($format) { $prijs = number_format((float) $prijs, 2, ',', '.'); } return $prijs; } /* In overzicht prijs indicatie voor een hairextensions product */ public static function getPriceHairextensions ($product) { $eigenschappen_data = array(); if ($product['hairextensions']) { $eigenschappen_data = unserialize($product['hairextensions']); } $soort = 'hairextensions'; $afbeelding = Cache::get('afbeelding'); if ($eigenschappen_data[$soort]) { foreach ($eigenschappen_data[$soort] as $key => $eigenschappen) { // Eigenschappen if ($eigenschappen) { foreach ($eigenschappen as $key_eigenschap => $eigenschap) { if (($eigenschap['id_afbeelding'] && $eigenschap['prijs']) && isset($afbeelding[$eigenschap['id_afbeelding']])) { $first = $eigenschap; break 2; } } } } } if (isset($first)) { return number_format($first['prijs'], 2, ',', ''); } else { return '0,00'; } } public static function sanitize ($str) { // include URLify $str = URLify::filter($str); return $str; } public static function unsanitize ($str) { $str = str_replace('_', ' ', $str); $str = rawurldecode($str); return $str; } public static function curl ($data) { $URL = CURL_URL; $c = curl_init($URL); curl_setopt($c, CURLOPT_RETURNTRANSFER, true); curl_setopt($c, CURLOPT_POST, true); curl_setopt($c, CURLOPT_POSTFIELDS, $data); curl_setopt($c, CURLOPT_TIMEOUT, 10); curl_setopt($c, CURLOPT_ENCODING, 1); curl_setopt($c, CURLOPT_USERAGENT, 'CURL/1.1'); curl_setopt($c, CURLOPT_ENCODING , "gzip"); $contents = curl_exec($c); curl_close($c); if (isset($data['debug'])) { print_r($contents); exit; } return unserialize($contents); } public static function download ($id) { // Check $bestand = Cache::get('bestand'); if (!isset($bestand[$id])) { return; } $bestand = $bestand[$id]; // Bestand $file = BESTAND_REMOTE_PATH . $bestand['id'] . '/' . rawurlencode(Encoding::fixUTF8($bestand['naam'])); /* $url_parts = @parse_url( $file ); $documentpath = $url_parts["path"]; $host = $url_parts["host"]; $port = "80"; $socket = @fsockopen( $host, $port, $errno, $errstr, 30 ); fwrite ($socket, "HEAD ".$documentpath." HTTP/1.0\r\nHost: $host\r\n\r\n"); $http_response = fgets( $socket, 22 ); */ $headers = self::curlMimeCheck($file); // print_r($headers); exit; header("Content-Disposition: attachment; filename=\"" . basename(Encoding::fixUTF8($bestand['naam'])) . "\""); header("Content-Transfer-Encoding: binary"); header('Content-type: ' . $headers['content-type']); header("Content-Length: " . $headers['content-length']); header("Connection: close"); $ch = curl_init(); curl_setopt($ch, CURLOPT_BINARYTRANSFER, 1); curl_setopt($ch, CURLOPT_HEADER, 0); curl_setopt($ch, CURLOPT_URL, $file); $response = curl_exec ($ch); curl_close($ch); echo $response; exit; } public static function downloadDocument ($id) { // Check $bestand = Cache::get('document'); if (!isset($bestand[$id])) { return; } $bestand = $bestand[$id]; // Bestand $file = DOCUMENT_REMOTE_PATH . $bestand['id'] . '/' . rawurlencode(Encoding::fixUTF8($bestand['naam'])); /* $url_parts = @parse_url( $file ); $documentpath = $url_parts["path"]; $host = $url_parts["host"]; $port = "80"; $socket = @fsockopen( $host, $port, $errno, $errstr, 30 ); fwrite ($socket, "HEAD ".$documentpath." HTTP/1.0\r\nHost: $host\r\n\r\n"); $http_response = fgets( $socket, 22 ); */ $headers = self::curlMimeCheck($file); // print_r($headers); exit; header("Content-Disposition: attachment; filename=\"" . basename(Encoding::fixUTF8($bestand['naam'])) . "\""); header("Content-Transfer-Encoding: binary"); header('Content-type: ' . $headers['content-type']); header("Content-Length: " . $headers['content-length']); header("Connection: close"); $ch = curl_init(); curl_setopt($ch, CURLOPT_BINARYTRANSFER, 1); curl_setopt($ch, CURLOPT_HEADER, 0); curl_setopt($ch, CURLOPT_URL, $file); $response = curl_exec ($ch); curl_close($ch); echo $response; exit; } public static function curlMimeCheck($url) { $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_USERAGENT, "Mimmic File Reader"); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 0); curl_setopt($ch, CURLOPT_RETURNTRANSFER,1); curl_setopt($ch, CURLOPT_HEADER, 1); curl_setopt($ch, CURLOPT_NOBODY, true); $buffer = curl_exec($ch); $curl_info = curl_getinfo($ch); curl_close($ch); $header_size = $curl_info['header_size']; $header = substr($buffer, 0, $header_size); $headerData = array(); $headers = explode("\n", $header); if (!empty($headers)){ foreach ($headers as $header){ if (strpos($header,':') !== false){ list($key, $value) = explode(':', $header); $headerData[trim($key)] = trim($value); } else if (!empty($header)) { $headerData[] = trim($header); } } } $headerData = array_change_key_case($headerData); return $headerData; } public static function prepareContent ($cache) { $content = unserialize($cache['content']); // Afbeelding if ($content) { foreach ($content as $blok => $array) { if ($array) { foreach ($array as $key => $value) { // echo $key . ' '; if (strstr($key, 'tinymce')) { $value = str_replace(array('src="app/media/afbeelding/'), array('src="' . AFBEELDING_REMOTE_PATH), $value); $content[$blok][$key] = $value; } else if (strstr($key, 'tekst')) { $value = str_replace(array('src="app/media/afbeelding/'), array('src="' . AFBEELDING_REMOTE_PATH), $value); $content[$blok][$key] = $value; } } } } } return $content; } }