• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Deployment SW

#1
[eluser]Unknown[/eluser]
Hi there,

first of all: Thy very much for taking time for me.

I'm writing a web based deployment website (based on codigniter) which allowes me to upload a file for one specific user. During the upload process a new record will be added into a db with the state 'pending'. Once the user access the download page the state of the entry in the db should change to 'deployed' and the file should be forced to download (by this awesome download-helper-function).

So: User access the download page
if the file is still pending, change it to deployed and download it.
if the file is already deployed, display an error.

My problem is, on the first time the user access the download-page, the db entry changes to 'deployed', he gets NO file but the error message.

Here's a part of my code:

Code:
<?php
$query = $this->db->query("
  SELECT
  d.state,
  d.time_expire,
  z.filename_real,
  z.filename_mask,
  z.encryption_key,
  d.download_timestamp
  FROM
  tbl_deployments d
  INNER JOIN
  tbl_zip_files z
  ON
  (
   z.id = d.id_zip_file
  )
  WHERE d.access_code = " . $this->db->escape($access_code));

$result = $query->result();
if(count($result) != 0)
{
if($result[0]->state == "pending")
{
  $download_file = $result[0];
  $this->db->query("UPDATE tbl_deployments SET state = 'deployed', download_timestamp = ".date("U")." WHERE access_code = '".$access_code."'");
  
  force_download($download_file->filename_real,$this->encrypt->decrypt_file("./upload/".$download_file->filename_mask,"",$download_file->encryption_key,FALSE,TRUE));
  
} else {

  echo "the file is not pending";
}
} else {
echo "wrong access code";
}

the user uses an access code to access his file. On upload i'm encrypting the file, so I have to decrypt it first

Thank you for all replies!

Pfammi


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2019 MyBB Group.