Admin Uploads Only

All support enquiries for DFH go in here...

Admin Uploads Only

Postby thirty5tech » Sun Mar 13, 2011 2:39 am

Hey Guys, Thanks for a great script . Everything seem to be working fine on my end

Only have 1 question if is possible, How do I enable uploads for Admins only and disable uploads for the rest of the users .

Thanks for all your help ..

Mike
thirty5tech
Standard Member
 
Posts: 16
Joined: Sun Mar 13, 2011 2:27 am

Re: Admin Uploads Only

Postby PeterS » Sun Mar 13, 2011 3:29 am

Hi thirty5tech,

Glad you're enjoying our script. For this you'd have to modify the upload.php file (for File Uploads).

Follow these steps:

1) Open upload.php
2) Find
Code: Select all
require_once("./config.php");

3) Add after it
Code: Select all
session_start();
if(isset($_SESSION['logged_in']) && $_SESSION['logged_in']==md5(md5($adminpass))) {

4) Go to the end of ./upload.php and add after the line
Code: Select all
</td></tr></table></center>
this
Code: Select all
<?php
} else {
echo "Sorry, but you need to be an admin to upload files on our website.";
}
?>


In theory the above code modification should work, however I have not tested it myself and so you'll have to report back to me.

Goodluck!
PeterS
Global Moderator
 
Posts: 159
Joined: Mon Feb 21, 2011 4:58 am

Re: Admin Uploads Only

Postby thirty5tech » Sun Mar 13, 2011 3:44 am

Sorry it did not work , This is what I have done, I look in the codes and found

Code: Select all
error_reporting(0);
require_once("./config.php");
include("./header.php");
if(in_array($language, $LANGUAGE_LIST)) {
  include('./lang/'.$language.'.php');
} else {
  include('./lang/'.$LANGUAGE_LIST[0].'.php');
}

$file_types_check = substr(strrchr($_FILES['upfile']['name'], '.'), 1);


Now it looks like this

Code: Select all
error_reporting(0);
require_once("./config.php");
session_start();
if(isset($_SESSION['logged_in']) && $_SESSION['logged_in']==md5(md5($adminpass))) {
include("./header.php");
if(in_array($language, $LANGUAGE_LIST)) {
  include('./lang/'.$language.'.php');
} else {
  include('./lang/'.$LANGUAGE_LIST[0].'.php');
}

$file_types_check = substr(strrchr($_FILES['upfile']['name'], '.'), 1);


I have added this at the very end

Code: Select all
<?php
} else {
echo "Sorry, but you need to be an admin to upload files on our website.";
}
?>
thirty5tech
Standard Member
 
Posts: 16
Joined: Sun Mar 13, 2011 2:27 am

Re: Admin Uploads Only

Postby thirty5tech » Sun Mar 13, 2011 4:01 am

OK, it seem it has work, But only issue is now, Even though I'm log in , It wont let me upload files .
thirty5tech
Standard Member
 
Posts: 16
Joined: Sun Mar 13, 2011 2:27 am

Re: Admin Uploads Only

Postby PeterS » Sun Mar 13, 2011 4:40 am

Please send me the script's URL via a PM or include it in your next post. Does it not work on both flash and HTML upload forms, or does it not work only on Flash Uploads?
PeterS
Global Moderator
 
Posts: 159
Joined: Mon Feb 21, 2011 4:58 am

Re: Admin Uploads Only

Postby thirty5tech » Sun Mar 13, 2011 4:51 am

thirty5tech
Standard Member
 
Posts: 16
Joined: Sun Mar 13, 2011 2:27 am

Re: Admin Uploads Only

Postby thirty5tech » Sun Mar 13, 2011 4:55 am

did not know about the flash, but it did work for the HTML, but the flash i'm not able to upload as it state i need to be a admin, but in html, it works, If im login as a Admin, it lets me upload, But if not login as a admin, it wont let me upload,

I guess is fine like this, Unless you have a solution for the flash, but not really needed now that I know I could upload via html
thirty5tech
Standard Member
 
Posts: 16
Joined: Sun Mar 13, 2011 2:27 am

Re: Admin Uploads Only

Postby PeterS » Sun Mar 13, 2011 5:50 am

Yeah I thought so, it's because the JavaScript for the flash form isn't transferring your session cookie to ./upload.php and so the script believes you are not authorised to upload any files. I will come up with a solution for you tomorrow.
PeterS
Global Moderator
 
Posts: 159
Joined: Mon Feb 21, 2011 4:58 am

Re: Admin Uploads Only

Postby thirty5tech » Sun Mar 13, 2011 6:46 am

Thanks,

overall , the script is working fine, thanks for all your help and fast support .
thirty5tech
Standard Member
 
Posts: 16
Joined: Sun Mar 13, 2011 2:27 am

Re: Admin Uploads Only

Postby PeterS » Sun Mar 13, 2011 6:20 pm

thirty5tech wrote:Thanks,

overall , the script is working fine, thanks for all your help and fast support .


I'm glad you are liking our script and support :).

To enable Flash with Login Uploads only follow the following steps:

1) Go into upload.php and find
Code: Select all
if(isset($_SESSION['logged_in']) && $_SESSION['logged_in']==md5(md5($adminpass))) {

2) Add above that piece of code
Code: Select all
$_SESSION['logged_in'] = $_POST['check'];

3) Go into ./styles/Indigo/file_upload_form.php and add this code on the very first line.
Code: Select all
<?php
session_start();
?>

4) After that, find
Code: Select all
swfu.addPostParam("pprotect", $("input#pprotect").val());
and add below that
Code: Select all
swfu.addPostParam("check", $("input#check").val());

5) Now find
Code: Select all
<tr><td align=center colspan=2><?php if(isset($categorylist)) { echo $categorylist; } ?></td></tr></table>
and add below that code
Code: Select all
<input type="hidden" name="check" value = "<?php echo $_SESSION['logged_in'];?>" id ="check" size="40" />


Now the flash upload should work along side the HTML form :).

P.S.: I advise you to add the below code in file_upload_form.php to inform you whether you are logged in as Admin or not to avoid uploading a large file just to get an error back saying you must be an admin to upload files. If you are already logged in as Admin and a message was not displayed, refresh the page to update the session ID on the javascript flash progress bar. In other words, do not upload any files unless you see the message "You are logged in as Admin".

1) Find
Code: Select all
<h1><center><? echo $lang[upload];?></center></h1>
and after that line
Code: Select all
<?php
if(isset($_SESSION['logged_in'])) {
?>
<h1><center><font color="#FF0000">You are logged in as Admin</font></center></h1>
<?php
}
?>
PeterS
Global Moderator
 
Posts: 159
Joined: Mon Feb 21, 2011 4:58 am

Next

Return to Daddy's File Host v1.X

Who is online

Users browsing this forum: No registered users and 0 guests

cron