set_time_limit(0); //include "../includes/functions.php"; include "includes/db.php"; require_once "Objects/InsertDownloadAchatClass.php"; require_once "Objects/FunctionClass.php"; $username = isset($_GET['username']) ? $_GET['username'] : ""; $password = isset($_GET['password']) ? $_GET['password'] : ""; $edition_id = isset($_GET['editionid']) ? $_GET['editionid'] : ""; $subscription = isset($_GET['subscription']) ? $_GET['subscription'] : 0; try { $functionObject = new FunctionClass('./'); $user_id = $functionObject->getIdMembre($username, $password); //$edition_id = $functionObject->getEditionIdForUrl($url); $achat_id = $functionObject->getIssueForAchat($user_id, $edition_id); $url = $functionObject->getUrlForEditionId($edition_id); $download_id = $functionObject->getDownloadIdIfExist($user_id, $edition_id); $dateheure = date('Y-m-d H:i:s', time()); if ($subscription) { $STH = $DBH->prepare("\n\t\tINSERT INTO `editions_download_member` (\n\t\t`member_id`, `edition_id`,`date`) \n\t\tVALUES (\n\t\t:member_id, :edition_id, :date)\n\t\t"); $STH->execute(array('member_id' => $user_id, 'edition_id' => $edition_id, 'date' => $dateheure)); } else { $STH = $DBH->prepare("\n\t\tINSERT INTO `editions_download_achat_member` (\n\t\t`member_id`, `achat_id`,`date`) \n\t\tVALUES (\n\t\t:member_id, :achat_id, :date)\n\t\t"); $downloadAchatClass = new InsertDownloadAchatClass($user_id, $achat_id, $dateheure); $STH->execute((array) $downloadAchatClass); } //$downloadEditionClass_affected = $STH->rowCount(); $filename = $url; header('Content-type: application/zip'); header('Content-Description: File Transfer'); header('Content-Transfer-Encoding: binary'); header('Content-Disposition: attachment; filename="' . $filename . '"');