120) { echo "This link has expired."; die(); } //Create an md5 string to make sure this is valid $md5 = md5($product_id.$server_id.$t.$id.DOWNLOAD_KEY); if ($md5 != $v) { echo "You are not authorized to access this file."; die(); } $product_index = floor($product_id/1000); // Translate from 1000, 2000, etc to 1, 2, etc //Begin downloading the file if (isset($product[$product_index])) { $downloadfile = $pathtofiles.$product[$product_index]; if (!file_exists($downloadfile)) { spitouterror(); die(); } $filesize = filesize($downloadfile); header('Content-type: application/octet-stream'); header('Content-Disposition: attachment; filename="'.$product[$product_index].'"'); header("Content-Length: $filesize"); readfile($downloadfile, "r"); // Once this is done then send a message back to the calling server $new_t = time(); $new_v = md5($new_t.$id.DOWNLOAD_KEY); $fieldarr = array( "response" => "1", "t" => $new_t, "id" => $id, "v" => $new_v, ); $urlarray = array(); foreach ($fieldarr as $key => $value) { $urlarray[] = "$key=".urlencode($value); } $fields = implode("&", $urlarray); //Start curl session $url = "http://www.nolapro.com/download/index.php"; $ch = curl_init($url); curl_setopt($ch, CURLOPT_HEADER, 0); curl_setopt($ch, CURLOPT_POSTFIELDS, $fields); // set the fields to post curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); // make sure we get the response back curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0); $buffer = curl_exec($ch); curl_close($ch); } else { spitouterror(); } function spitouterror() { echo "NolaPro Download"; ?> "; } ?>