Advertisement:

Author Topic: affiliating an account to a specified directory for attachments or uploads  (Read 627 times)

Offline drewactual

  • Full Member
  • ***
  • Posts: 583
    • College Football Fan Site CFB51
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. 


Offline Kindred

  • The Mean One
  • Support Specialist
  • SMF Legend
  • *
  • Posts: 58,063
  • Gender: Male
    • Kindred-999 on GitHub
not easily...

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

Offline Illori

  • Project Manager
  • SMF Legend
  • *
  • Posts: 50,574
even a gallery may not put the actual files in the same folder on the server.

Offline drewactual

  • Full Member
  • ***
  • Posts: 583
    • College Football Fan Site CFB51
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)
Code: [Select]
<?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?

Offline vbgamer45

  • SMF Friend
  • SMF Super Hero
  • *
  • Posts: 21,180
    • smfhacks on Facebook
    • VBGAMER45 on GitHub
    • @createaforum on Twitter
    • SMF For Free
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

Offline drewactual

  • Full Member
  • ***
  • Posts: 583
    • College Football Fan Site CFB51
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.   


Offline Kindred

  • The Mean One
  • Support Specialist
  • SMF Legend
  • *
  • Posts: 58,063
  • Gender: Male
    • Kindred-999 on GitHub
seriously... just get a gallery mod.

or coppermine + bridge if you don't want a specific SMF gallery
Please do not PM, IM or Email me with support questions.  You will get better and faster responses in the support boards.  Thank you.

Offline Arantor

  • Resident Overthinker
  • SMF Friend
  • SMF Legend
  • *
  • Posts: 70,939
    • StoryBB/StoryBB on GitHub
Just use LevGal, give groups or users albums of their own.
Don’t try to tell me that some power can corrupt a person. You haven’t had enough to know what it’s like.

No good deed goes unpunished / No act of charity goes unresented.

Offline drewactual

  • Full Member
  • ***
  • Posts: 583
    • College Football Fan Site CFB51
annual subscription or does support just stop after first year?

difficult to purchase that thing when registration is closed, no?  :P
« Last Edit: January 23, 2019, 02:31:38 PM by drewactual »

Offline Arantor

  • Resident Overthinker
  • SMF Friend
  • SMF Legend
  • *
  • Posts: 70,939
    • StoryBB/StoryBB on GitHub
Don’t try to tell me that some power can corrupt a person. You haven’t had enough to know what it’s like.

No good deed goes unpunished / No act of charity goes unresented.

Offline drewactual

  • Full Member
  • ***
  • Posts: 583
    • College Football Fan Site CFB51
Re: affiliating an account to a specified directory for attachments or uploads
« Reply #10 on: January 23, 2019, 02:41:30 PM »
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.

Offline Arantor

  • Resident Overthinker
  • SMF Friend
  • SMF Legend
  • *
  • Posts: 70,939
    • StoryBB/StoryBB on GitHub
Re: affiliating an account to a specified directory for attachments or uploads
« Reply #11 on: January 23, 2019, 06:21:15 PM »
I gave it away for free, enjoy.
Don’t try to tell me that some power can corrupt a person. You haven’t had enough to know what it’s like.

No good deed goes unpunished / No act of charity goes unresented.

Offline drewactual

  • Full Member
  • ***
  • Posts: 583
    • College Football Fan Site CFB51
Re: affiliating an account to a specified directory for attachments or uploads
« Reply #12 on: January 24, 2019, 09:09:14 AM »
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.