Home arrow Forum

Remository Forum

 


Projecto

Karma: 0  
Re:Download resume support - 2007/03/02 15:00 Okay, if you don't mind, we have a couple of questions:

1 - Where exactly in remository_download_Controller.php should we add the "before download, do this" instructions? In that last "else" around line 232?

2 - We're having trouble with the password prompt. We can't use Javascript, because we can't find a way to use its results on PHP... we can't use HTML because it'd need a form and to submit it... we're kinda stumped.

Below is our current progress. Around line 85 are our feeble attempts at making a Javascript password prompt.

Thanks in advance for any help/ideas you can give us.

Code:

 <?php // ------------------------------ FUNCTION GET_TIME_DIFFERENCE ---------------------------         function get_time_difference$start$end )         {             $uts['start']      =    strtotime$start );             $uts['end']        =    strtotime$end );             if( $uts['start']!==-&& $uts['end']!==-)             {                 if( $uts['end'] >= $uts['start'] )                 {                     $diff    =    $uts['end'] - $uts['start'];                     if( $days=intval((floor($diff/86400))) )                         $diff $diff 86400;                     if( $hours=intval((floor($diff/3600))) )                         $diff $diff 3600;                     if( $minutes=intval((floor($diff/60))) )                         $diff $diff 60;                     $diff    =    intval$diff );                                 return( array('days'=>$days'hours'=>$hours'minutes'=>$minutes'seconds'=>$diff) );                 }                 else                 {                     trigger_error"Ending date/time is earlier than the start date/time"E_USER_WARNING );                 }             }             else             {                 trigger_error"Invalid date/time data detected"E_USER_WARNING );             }             return( false );         } // --------------------------- FUNCTION GET_TIME_DIFFERENCE END ------------------------ // -------------------------- IF THE FILE IS PROTECTED, AND USER CLICKS DOWNLOAD, THIS HAPPENS ----- ------------------------- if( mosGetParam$_GET'func') == 'startdown'$FileID mosGetParam$_GET'id'); else $FileID 4; $UserID $my->id; $query1 "SELECT Password, Expiry FROM `jos_downloads_passwords` WHERE (jos_downloads_passwords.FileID = '" $FileID "')"" AND (jos_downloads_passwords.UserID = '" $UserID "')"; $database->setQuery$query1 );  $stuff $database->loadObjectList(); if (count($stuff) == 0) {     //////////////////// PASSWORD GENERATOR /////////////////////     $password ""// start with a blank password     $length 8// define password length     $possible "0123456789bcdfghjkmnpqrstvwxyz"// define possible characters     $i 0// set up a counter     while ($i $length) { // add random characters to $password until $length is reached       $char substr($possiblemt_rand(0strlen($possible)-1), 1); // pick a random character from the possible ones       if (!strstr($password$char)) { // we don't want this character if it's already in the password         $password .= $char;          $i++;       }     }     ///////////////// END OF PASSWORD GENERATOR /////////////////     $intwoweeks date('Y-m-d H:i:«»s'mktime(date("H"«»), date("i"«»), date("s"«»), date("m"«»),  date("d"«»)+14,  date("Y"«»)));     $query2 "INSERT INTO #__downloads_passwords VALUES ('" $FileID "', '" $UserID "', '" $password "', '" $intwoweeks "')";     $database->setQuery$query2 );     $database->query();     echo "This should be sending an email to the file Author now, asking for your password.<br>";     echo "It will, eventually...<br>"; } else {     foreach ( $stuff as $row )     {                 $DbPassword $row->Password;                 $expiry date('Y-m-d H:i:«»s'strtotime($row->Expiry));     }     ?>     <!-- PASSWORD PROMPT... DOESN'T HIDE PASS WITH "****" AND php CAN'T READ THE RETURNED VALUE -->     <!-- script>     function getPass()         var password = prompt("Please, insert your password to download this file:","********" «»);         if (password == "<?PHP echo "$DbPassword"?>"«»)         {             return true;         }         else         {             return false;         }     </script-->     <?php //    echo "<script language="javascript">getPass()</script>"; //    if (getPass()) echo "Yay!"; //    else echo "Nay!";          /*-------------------------------------------------------------------------------*/          echo "It should be asking for a password right now.<br>";     $InputPassword = $DbPassword; // simulate correct password     //$InputPassword = "aleluia!"; // simulate wrong password     if ($InputPassword != $DbPassword)     {         ?><script>alert('Wrong password.')</script><?php     }     else     {         $current = date('Y-m-d H:i:«»s');         $inthreedays  = date('Y-m-d H:i:«»s', mktime(date("H"«»), date("i"«»),  date("s"«»), date("m"«»),  date("d"«»)+3,  date("Y"«»)));         if( $diff=@get_time_difference($current, $expiry) ) // checks if expiry is bigger than  current date         {             echo "Days: " . $diff['days'] . "<br>Hours: " . sprintf( '%02d:%02d:%02d', $diff['hours' ], $diff['minutes'], $diff['seconds'] ) . "<br>";                          if( $diff=@get_time_difference($inthreedays, $expiry) ) // checks if expiry is bigger  than inthreedays             {                 $query3 = "UPDATE `jos_downloads_passwords` SET `Expiry` =  '" . $inthreedays . "'  WHERE (jos_downloads_passwords.FileID = '" . $FileID . "')". " AND (jos_downloads_passwords.UserID  = '" . $UserID . "')";                 $database->setQuery( $query3 );                  $database->query();                                  echo "Expiry reduced to 3 days, and download.";                 // DOWNLOADS!             }             else             {                 echo "Expiry in 3 days or less. Download.";                   // DOWNLOADS!             }         }         else         {             echo "Expiry expired... removes entry from DB.";             $query4 = "DELETE FROM `jos_downloads_passwords` WHERE (jos_downloads_passwords.FileID  = '" . $FileID . "')". " AND (jos_downloads_passwords.UserID = '" . $UserID . "')";             $database->setQuery( $query4 );              $database->query();         }     } } // --------------------------------------- END OF THE BIG IF/ELSE ---------------------------------- -------- // DELETES OLD ENTRIES $current = date('Y-m-d H:i:«»s'); $query5 = "DELETE FROM `jos_downloads_passwords` WHERE (`Expiry` < '" . $current .  "')"; $database->setQuery( $query5 );  $database->query(); ?>

  | | Sorry, you do not currently have permission to write here.

      Topics Author Date
    thread link
Download resume support
BalthaZar 2006/08/06 10:20
    thread link
thread link Re:Download resume support
admin 2006/08/06 14:51
    thread link
thread linkthread link Re:Download resume support
BalthaZar 2006/08/06 21:24
    thread link
thread linkthread linkthread link Re:Download resume support
BalthaZar 2006/08/06 21:33
    thread link
thread linkthread linkthread linkthread link Re:Download resume support
BalthaZar 2006/08/06 21:43
    thread link
thread linkthread linkthread linkthread linkthread link Re:Download resume support
admin 2006/08/07 12:40
    thread link
thread linkthread linkthread linkthread linkthread linkthread link Re:Download resume support
sexvidx 2007/01/10 20:59
    thread link
thread linkthread linkthread linkthread linkthread linkthread linkthread link Re:Download resume support
admin 2007/01/12 09:17
    thread link
thread linkthread linkthread linkthread linkthread linkthread link Re:Download resume support
Projecto 2007/02/22 14:48
    thread link
thread linkthread linkthread linkthread linkthread linkthread linkthread link Re:Download resume support
admin 2007/02/23 12:01
    thread link
thread linkthread linkthread linkthread linkthread linkthread linkthread linkthread link Re:Download resume support
Projecto 2007/02/26 11:55
    thread link
thread linkthread linkthread linkthread linkthread linkthread linkthread linkthread linkthread link Re:Download resume support
admin 2007/02/27 22:07
    thread link
thread linkthread linkthread linkthread linkthread linkthread linkthread linkthread linkthread linkthread link Re:Download resume support
Projecto 2007/02/28 11:29
    thread link
thread linkthread linkthread linkthread linkthread linkthread linkthread linkthread linkthread linkthread linkthread link Re:Download resume support
Projecto 2007/03/02 15:00
    thread link
thread linkthread linkthread linkthread linkthread linkthread linkthread linkthread linkthread linkthread linkthread linkthread link Re:Download resume support
admin 2008/06/30 23:02

Menu

Budding author?

Could you write about software?  Packt Publishing is looking for authors for its new series of Beginners' Guides.  Take a look at their web site to find out more.

Login Form

Username

Password

Remember me
Password Reminder
No account yet?
Create one

Who is Online

Remository welcomes guests and registered users.

We have 4 guest online