News:

Bored?  Looking to kill some time?  Want to chat with other SMF users?  Join us in IRC chat or Discord

Main Menu

affiliating an account to a specified directory for attachments or uploads

Started by drewactual, January 23, 2019, 10:33:52 AM

Previous topic - Next topic

drewactual

is there a way to make a simple addition/alteration to a script (or use existing functions) for a certain user or group 'only' that stores their uploads in a specified directory populated with only their contributions?

I'm attempting to automate something w/o giving access via ftp or any kind of back end access whatsoever. 


Kindred

Слaва
Украинi

Please do not PM, IM or Email me with support questions.  You will get better and faster responses in the support boards.  Thank you.

"Loki is not evil, although he is certainly not a force for good. Loki is... complicated."

Illori

even a gallery may not put the actual files in the same folder on the server.

drewactual

i'd considered such, but it isn't that important. I don't want to load that domain down with additional db's- It has three as it is- with two major engines running off two of them...  I can always collect these items via email... or i could provide a link to chosen people and to a password protected file used for uploading to a specified directory allowing only a certain file type and limiting the size to a certain range... I was just hoping to use SMF's member security for access...

script to do it less the password challenge: (thanks to https://www.w3schools.com/php/php_file_upload.asp)
<?php
$target_dir 
"uploads/";
$target_file $target_dir basename($_FILES["fileToUpload"]["name"]);
$uploadOk 1;
$imageFileType strtolower(pathinfo($target_file,PATHINFO_EXTENSION));
// Check if image file is a actual image or fake image
if(isset($_POST["submit"])) {
    
$check getimagesize($_FILES["fileToUpload"]["tmp_name"]);
    if(
$check !== false) {
        echo 
"File is an image - " $check["mime"] . ".";
        
$uploadOk 1;
    } else {
        echo 
"File is not an image.";
        
$uploadOk 0;
    }
}
// Check if file already exists
if (file_exists($target_file)) {
    echo 
"Sorry, file already exists.";
    
$uploadOk 0;
}
// Check file size
if ($_FILES["fileToUpload"]["size"] > 500000) {
    echo 
"Sorry, your file is too large.";
    
$uploadOk 0;
}
// Allow certain file formats
if($imageFileType != "jpg" && $imageFileType != "png" && $imageFileType != "jpeg"
&& $imageFileType != "gif" ) {
    echo 
"Sorry, only JPG, JPEG, PNG & GIF files are allowed.";
    
$uploadOk 0;
}
// Check if $uploadOk is set to 0 by an error
if ($uploadOk == 0) {
    echo 
"Sorry, your file was not uploaded.";
// if everything is ok, try to upload file
} else {
    if (
move_uploaded_file($_FILES["fileToUpload"]["tmp_name"], $target_file)) {
        echo 
"The file "basename$_FILES["fileToUpload"]["name"]). " has been uploaded.";
    } else {
        echo 
"Sorry, there was an error uploading your file.";
    }
}
?>


and a really dumb question:

can the above script be implemented via php include to the admin.template and limiting only admins and by entwining it with SMF's protocols for access?

vbgamer45

Also be sure to check the file extension. and remove the temp file if not a valid image.
Community Suite for SMF - Take your forum to the next level built for SMF, Gallery,Store,Classifieds,Downloads,more!

SMFHacks.com -  Paid Modifications for SMF

Mods:
EzPortal - Portal System for SMF
SMF Gallery Pro
SMF Store SMF Classifieds Ad Seller Pro

drewactual

good call, Sir.

I'm starting to think instead of incorporating this into SMF may be a bad plan... But allowing access via securing page may not be. 

my intent, if y'all have any interest, is to allow team moderators ability to decorate their own child boards. 

as example: https://www.cfb51.com is the main page with a category 'power five conferences', and boards by conference... there is one child board in this category @ https://www.cfb51.com/index.php?board=3.0... it uses a different theme altogether, but closely resembles the parent theme. 

there are three items on these pages that 'rotate'- one is the banner just below the logo and menu, another is atop the right column, and another is the pictures in the block between these two...

the big block picture is rotated randomly by a simple php script on each reload.  the images have to be named in a prescribed manner and be a certain file type.  I've hard scripted this into the page using css.  what i want to offer is a user (team board captain) opportunity to alter those three area's and ONLY those three area's.  after experimenting I'm thinking it's enough to separate a 'team' board from the 'main' theme, but not enough that a user doesn't know they aren't still on the parent site.  Doing so in this manner will mean the 'team board captain' doesn't need anything more than moderator access, and somewhere where they can't really screw things up such as an admin access. 

basically the script I'm currently using to populate those three area's is a php include of one single line of code, and it pulls the images from a specific directory.   


Kindred

seriously... just get a gallery mod.

or coppermine + bridge if you don't want a specific SMF gallery
Слaва
Украинi

Please do not PM, IM or Email me with support questions.  You will get better and faster responses in the support boards.  Thank you.

"Loki is not evil, although he is certainly not a force for good. Loki is... complicated."

Arantor


drewactual

annual subscription or does support just stop after first year?

difficult to purchase that thing when registration is closed, no?  :P


drewactual

many thank you's, good sir.   send me your paypal address via PM and I'll send you the $40.  I don't expect something for nothing, Sir, and appreciate your offering.

Arantor


drewactual

i have it downloaded and will implement it when traffic dies down... it's inevitable in early February and usually when i try to make changes that have possibility of breaking things. 

i thank you profusely.  let me at least buy your lunch?  send paypal address and i'll make that happen.

Advertisement: