Hy All

Im here again to ask for you help. I still in the begining to launch the site, and i found a major error. The theory is the following. I planning to start a Pay per download site, which mean the members upload a file and when somebody want to download it, they have to fill a short survey. After survey done, both me and them get money. The problem is i test the script, and when i open the donwload link http://www.filemonster.org/download.php?id=11 the page load, then immediately redirect and i get a following error "Stop trying to download without completing a survey." which is an anti cheat message. Its 100% wrong because its appears all the time. i paste here the code, do you know why its appear straight after the page load? Its just appear for me on the Firefox.

<?php 
ob_start();
session_start();
include_once('secure/core.php');
if (!isset($_GET['extra'])){    
    echo '<script type="text/javascript">alert("Invalid access.");</script>';
    die();
}
$path = $settings->getUploadPath();
$rand = mysql_real_escape_string($_GET['rand']);
$sql = "SELECT * FROM `conversions` WHERE `rand` = '$rand' and `converted` = '1'";
$result = mysql_query($sql);
$row = mysql_fetch_assoc($result);
$file = $row['file_id'];
if($row['converted'] == '1') {
if($row['downloaded'] == '0') {
$path = $settings->getUploadPath(); 
$sql5 = "select * from `uploads` where `id` = '$file'";
$row5 = $ado->fetch($ado->exec($sql5));
$sql6 = "UPDATE `conversions` SET `downloaded` = '1' WHERE `rand` = '$rand'";
$ado->exec($sql6);
set_time_limit(0);  

header("Pragma: public");
header("Expires: 0");
header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
header("Cache-Control: public");
header("Content-Description: File Transfer");
header("Content-Type: application/force-download"); 
header("Content-Type: application/octet-stream"); 
header("Content-Type: application/download"); 
header("Content-Disposition: attachment; filename=\"".$row5['hash']."\"");
header("Content-Transfer-Encoding: binary");
header("Content-Length: ".filesize($path.$row5['hash']));
ob_end_flush(); 
@readfile($path.$row5['hash']);
exit(0); 

} else {
echo '<script type="text/javascript">alert("You have already downloaded this.");</script>';
}
} else {
echo '<script type="text/javascript">alert("Stop trying to download without completing a survey.");</script>'; 
}
?>
<script type="text/javascript">
$('#myModal').modal('hide');
</script>

Please if any of you have an idea, share with me

Recommended Answers

All 5 Replies

Member Avatar for diafol

Can't you hold a var in a session to say whether a survey has been taken successfully?
WHen completed, the var changes from 0 to 1. Or is this more involved?

The script should automatically decide its been downloaded or not, but the problem the message its appear as soon as you open the link, so you even not start to download but straight get the error.

or how to edit the code to make sure that message is not appear?

Member Avatar for diafol

I think...
This is in repsonse to :

if($row['converted'] == '1')

So it's always set to something else.

echo out $row['converted'] to see what it holds. BTW indent conditional blocks - this is really hard to follow.

I remove that line together with the line 42-43, and now i receive another message from line 40. When i remove all of them aswell its work, but the download start automatically so the members dont have to fill the survey

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.