File: D:/HostingSpaces/SBogers10/promic.komma-mediadesign.nl/wwwroot/downloaden.php
<?php
session_start();
// maak een connectie:
$conn=mysql_connect('YDAWBH119', 'promic_kms_user', '49Iodd&3kd)3sWq!p') or die("<h1>Promic website is not available</h1><p>It's not possible to connect to the website<br />
Please try again later.<br/><br/>Our apologies for the inconvenience</p>" .
mysql_error() ) ;
//open de database:
mysql_select_db('promic_kms') or die("<hr/>Het spijt me, database niet gevonden: <br/>" .
mysql_error());
include("functions.php");
if($_SESSION['valid_login']){
if (isset($_GET["file"]) && isset($_GET["ext"])){
$bestandsnaam = $_GET["file"];
$ext = $_GET["ext"];
$product = $_GET["product"];
$id = $_SESSION['login']['id'];
$datum = date("d.m.y");
$tijd = date("H:i:s");
$taal_input = $_SESSION['taal_table']['language'];
if(!empty($product)){
$filename = "product_data/downloads/".$product."/".$bestandsnaam.".".$ext;
$database_bestand = $product."/".$bestandsnaam.".".$ext;
}else{
$filename = "product_data/downloads/". $bestandsnaam.".".$ext;
$database_bestand = $bestandsnaam.".".$ext;
}
if($bestandsnaam == 'pricelist_print'){
$filename = "downloads/data/brochure-02-2017/1702_prints_price_list_web.pdf"; //TODO when new catelog change to location
$database_bestand = $bestandsnaam.".".$ext;
}
if($bestandsnaam == 'pricelist'){
$filename = "downloads/data/brochure-02-2017/1702_pricelist_systems_web.pdf"; //TODO when new catelog change to location
$database_bestand = $bestandsnaam.".".$ext;
}
if($bestandsnaam == 'catalog'){
$filename = "downloads/data/brochure-02-2017/1702_brochure_web.pdf"; //TODO when new catelog change to location
$database_bestand = $bestandsnaam.".".$ext;
}
if($bestandsnaam == 'catalog_neutral'){
$filename = "downloads/data/brochure-02-2017/1702_neutral_brochure_web.pdf";
$database_bestand = $bestandsnaam.".".$ext;
}
//error mail gegevens
$headers = "From: Promic Website <info@promic.com>";
$emailadres2 = "info@komma-mediadesign.nl";
$subject = "Error Downloaden Promic";
$subject2 = "Verkeerde extensie Promic";
if($ext == "zip" || $ext == "pdf"){//alleen extensie zip en pdf toestaan.
if ( ! file_exists( $filename ) ){
if($taal_input == "nl"){ echo("Dit bestand bestaat niet."); }else{ echo("This file doesn't exists."); }
$message = "
Beste Stef,
Er is een fout opgetreden op promic.nl
De klant met id $id probeert in het $taal_input het volgdende bestand: $filename
Te downloaden op $datum om $tijd.
Succes ermee!
Met vriendelijke groet,
Uw Komma Management System";
$email = mail($emailadres2, $subject2, $message, $headers);
exit;
}
if(ini_get('zlib.output_compression')){
ini_set('zlib.output_compression', 'Off');
}
switch($ext){
case "pdf": $ctype="application/pdf"; break;
case "zip": $ctype="application/octet-stream"; break;
case "exe": $ctype="application/octet-stream"; break;
case "doc": $ctype="application/msword"; break;
case "xls": $ctype="application/vnd.ms-excel"; break;
case "ppt": $ctype="application/vnd.ms-powerpoint"; break;
case "gif": $ctype="image/gif"; break;
case "png": $ctype="image/png"; break;
case "jpeg": $ctype="image/jpg"; break;
case "jpg": $ctype="image/jpg"; break;
default: $ctype="application/force-download";
}
header("Pragma: public"); // required
header("Expires: 0");
header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
header("Cache-Control: private",false); // required for certain browsers
if(!ereg("MSIE 7.0",$_SERVER['HTTP_USER_AGENT'])){
//removing the Content Type for IE 7 seems to work
header('Content-Type: '.$ctype);
}
if(!ereg("MSIE 8.0",$_SERVER['HTTP_USER_AGENT'])){
//removing the Content Type for IE 8 seems to work
header('Content-Type: '.$ctype);
}
header("Content-Disposition: attachment; filename=\"".basename($filename)."\";" );
header("Content-Transfer-Encoding: binary");
header("Content-Length: ".filesize($filename));
readfile("$filename");
$q = "INSERT INTO downloads(account_id, bestandsnaam, taal, datum, tijd) VALUES ('$id', '$database_bestand', '$taal_input', '$datum', '$tijd')";
$r = mysql_query($q);
exit();
}else{
if($taal_input == "nl"){ echo("Dit bestand bestaat niet."); }else{ echo("This file doesn't exists."); }
$message2 = "
Beste Stef,
Er is een fout opgetreden op promic.nl
De klant met id $id probeert in het $taal_input het volgdende bestand: $filename
Te downloaden op $datum om $tijd.
Waarschijnlijk is er sprake van fraude met een verkeerde extensie.
Succes ermee!
Met vriendelijke groet,
Uw Komma Management System";
$email = mail($emailadres2, $subject2, $message2, $headers);
exit;
}
}
}else{
if($_SESSION['taal_table']['language'] == "nl"){ echo("U bent niet ingelogd."); }else{ echo("You're not logged in."); }
}
?>