PHP Simplicity Forum

Please login or register.

Login with username, password and session length
Advanced search  

News:

Some of SFU features: Universal password protection, notification of uploads and logging just to name few.

Author Topic: Upload won't work when I turn on password protect option  (Read 1254 times)

0 Members and 1 Guest are viewing this topic.

snowgurl

  • Newbie
  • *
  • Offline Offline
  • Posts: 3
    • View Profile
Upload won't work when I turn on password protect option
« on: June 13, 2005, 11:21:47 pm »
Love the script! I have it all running well except one thing ... If I leave "define('SFU_PROTECT', false);" it all works fine. But, if I change it to "true" the upload doesn't work. I don't get any errors, though. After I click the upload button it just takes me back to the password login page -- where I had already logged in successfully.

I really want to use the password feature so I will keep working on it. I think it must have something to do with carrying the variable or the cookie or something. It's like when globals are off -- but they aren't.

Any suggestions?
Logged

Saleh

  • Administrator
  • Full Member
  • *****
  • Offline Offline
  • Posts: 212
    • View Profile
    • WWW
Re: Upload won't work when I turn on password protect option
« Reply #1 on: June 14, 2005, 09:59:49 am »
this is strange!
let's try and add cookies support and see if it works.
in upload.php, look for:
Code: [Select]
if (SFU_PROTECT == true) {
   session_start();

   if (isset($_POST['SFU_Protect'])) {
      if ($_POST['SFU_Protect'] == SFU_PASSWORD)
         $_SESSION['SFU_Protect'] = SFU_PASSWORD;
      else {
         echo $txt['pass_wrong'];
         html_footer();
         exit;
      }
   } elseif (!isset($_SESSION['SFU_Protect'])) {
      protectForm();
      html_footer();
      exit;
   } elseif ($_SESSION['SFU_Protect'] !== SFU_PASSWORD) {
      session_unset();
      session_destroy();
   }
}

replace it with:
Code: [Select]
if (SFU_PROTECT == true) {
   session_start();

   if (isset($_POST['SFU_Protect'])) {
      if ($_POST['SFU_Protect'] == SFU_PASSWORD) {
         $_SESSION['SFU_Protect'] = SFU_PASSWORD;
         setCookie('SFU_Protect', SFU_PASSWORD);
      } else {
         echo $txt['pass_wrong'];
         html_footer();
         exit;
      }
   } elseif (!isset($_SESSION['SFU_Protect']) && !isset($_COOKIE['SFU_Protect'])) {
      protectForm();
      html_footer();
      exit;
   } elseif ($_SESSION['SFU_Protect'] != SFU_PASSWORD || $_COOKIE['SFU_Protect'] != SFU_PASSWORD) {
      session_unset();
      session_destroy();
   }
}

let me know how it goes..
if it didn't work please PM the link to upload page with the password ..
Logged

We don't need a reason to help people

snowgurl

  • Newbie
  • *
  • Offline Offline
  • Posts: 3
    • View Profile
Re: Upload won't work when I turn on password protect option
« Reply #2 on: June 14, 2005, 04:32:40 pm »
Thanks for the quick response -- but it didn't work. :(

I've tried it on different platforms and browsers just to make sure it wasn't me and my computer handling cookies wrong. Should it be writing a cookie? I see one for this forum but no new ones for the upload site. 

I will PM you the site specifics -- I hope you can figure it out! Thanks.
Logged

Saleh

  • Administrator
  • Full Member
  • *****
  • Offline Offline
  • Posts: 212
    • View Profile
    • WWW
Re: Upload won't work when I turn on password protect option
« Reply #3 on: June 15, 2005, 09:57:15 am »
I can see why it's not working, hopefully :)
because you have some output before session_start() is called..
so in default.php, open the file and put:

<?php
session_start
();
?>


 at the top of the page before any output regardless if it was using pure HTML or any php printing function (echo or print)
after that it should work..

and I'd suggest you rollback the replacement you did to see if cookies works or not (the one in my post above)
« Last Edit: June 15, 2005, 10:03:32 am by Saleh »
Logged

We don't need a reason to help people

snowgurl

  • Newbie
  • *
  • Offline Offline
  • Posts: 3
    • View Profile
Re: Upload won't work when I turn on password protect option
« Reply #4 on: June 15, 2005, 04:49:51 pm »
Hey! That worked like a charm. I see where that session_start is buried in the upload page so it wasn't getting there for a while. I'm surprised noone else had that problem unless I'm the only one using it as an include. Hmm ...

I am having one other little problem -- actually two, but I think I can figure them out myself. I'll throw them out there to you anyway.

One is that on the default page before logging in, if you view source on that page you'll see that the page is being truncated right at the close of the form -- </form>. I doesn't affect the function of the script, but it's cutting off the footer on the page. After logging in the footer reappears when the upload table is showing. I know I can just add the footer somewhere else but it makes me uneasy that the code is cut off. I looked at the code and can't quite figure out why it's doing that.

The other problem is the file listings on the download page -- the file size and dates are being read correctly. I see in the forum that someone else had that problem but never had an answer -- at least written here. I think I can just replace the code with some that I've used before that works, but I wanted mention it in case someone else had the problem.

Any help on those two questions would be appreciated -- and thanks for the help with the login!  :D

PS. I did rollback the replacement code and it's working fine.
Logged

Saleh

  • Administrator
  • Full Member
  • *****
  • Offline Offline
  • Posts: 212
    • View Profile
    • WWW
Re: Upload won't work when I turn on password protect option
« Reply #5 on: June 16, 2005, 11:49:11 am »
glad it worked :)
Quote
One is that on the default page before logging in, if you view source on that page you'll see that the page is being truncated right at the close of the form -- </form>. I doesn't affect the function of the script, but it's cutting off the footer on the page. After logging in the footer reappears when the upload table is showing. I know I can just add the footer somewhere else but it makes me uneasy that the code is cut off. I looked at the code and can't quite figure out why it's doing that.
I could also see why this is happening :)
because in this part:
Code: [Select]
   } elseif (!isset($_SESSION['SFU_Protect'])) {
      protectForm();
      html_footer();
      exit;
   }
I've used exit to terminate the script after the form being printed...
thanks for pointing this to me, I should fix that in the next release (1.4) ;)
but for now, you can put the extar output before the exit in the code above:

   
} elseif (!isset($_SESSION['SFU_Protect'])) {
      
protectForm();
      
html_footer();
      echo 
'My extar output!';
      exit;


as for the stat problem, it's a mystery for me! :'(
some servers works fine some not! why? that's difficult to answer.
I've searched every where I could about a fix for this, but I couldn't find any..
and recently I've been trying to solve a similar problem with someone else and it seemed like it's a server problem not the script's! because even filesize() was NOT working for that person!

currently I am leaving for a vecation so when I come back I'll look into it.
« Last Edit: August 05, 2009, 11:11:40 am by Saleh »
Logged

We don't need a reason to help people
 

+ Quick Reply

With Quick-Reply you can write a post when viewing a topic without loading a new page. You can still use bulletin board code and smileys as you would in a normal post.
After submitting your post you will be directed to the regular post page to verify your post (required for all guests).
Name: Email: