Topic: Module so each user can have his own file storing system (fully customizable!) (Read 731 times)
OMG!I am geek
Gender:
Posts: 55
366 credits Members referred : 0
my day will come..
« on: Oct 25, 2006, 07:18:32 AM »
-EDIT- Decided to change the post subject ____________________________
Well Olaf or anyone who can help me, I'm working on customizing the Access_User Class, I'm adding a feature that allows each registered user to upload files. I got that done, it saves the users files into a directory that's like: "files/$username/" situation here is that when Administrators log-in and look for a user (i.e. username: john) I want Administrators to be able to send John files, (putting them on John's folder: files/john/). John will see the files stored at his folder with a folder scan function.
I was wondering if anyone can help me with an FTP very very simple script.. just one 'input type=file' a submit button and the specific functions to upload the file. Thanks
« Last Edit: Oct 25, 2006, 08:40:37 AM by eliezer »
OMG!I am geek
Gender:
Posts: 55
366 credits Members referred : 0
my day will come..
Re: I don't know if I am posting this in the right board..
« Reply #1 on: Oct 25, 2006, 08:34:20 AM »
By the way, you can save and use this as: upload_file.php Just remember to add the upload_file.php hyperlink to the example.php file.
Some variables are in spanish and also the html layout is designed according to my site, but I'm sure you guys can change this values by yourself. Hope ya'll find it useful, peace.
$update_profile->access_page($_SERVER['PHP_SELF'], $_SERVER['QUERY_STRING']); // protect this page too.
$update_profile->get_profile_data();
if (isset($_POST['user_data'])) { $update_profile->update_user($_POST['password'], $_POST['confirm'], $_POST['user_full_name'], $_POST['user_info'], $_POST['user_email']); // the update method } if (isset($_POST['profile_data'])) { $update_profile->save_profile_date($_POST['id'], $_POST['language'], $_POST['address'], $_POST['postcode'], $_POST['city'], $_POST['country'], $_POST['phone'], $_POST['fax'], $_POST['homepage'], $_POST['notes'], $_POST['field_one'], $_POST['field_one'], $_POST['field_two']."##eu_date"); // note the last trailing string, this used to optimize the value as a euro date. } $error = $update_profile->the_msg; // error message
//vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv // You may change maxsize, and allowable upload file types. //^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ //Mmaximum file size. You may increase or decrease. $MAX_SIZE = 99000000;
//Allowable file Mime Types. Add more mime types if you want $FILE_MIMES = array('image/jpeg','image/jpg','image/gif','image/png','application/msword');
//Allowable file ext. names. you may add more extension names. $FILE_EXTS = array('.zip','.mp3','.wma','.jpg','.png','.gif','.psd','.doc','.txt');
//Allow file delete? no, if only allow upload only $DELETABLE = true;
//vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv // Do not touch the below if you are not confident. //^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /******************************* Setup variables ************************************************/
/******************************** Create Upload Directory ***********************************/ if (!is_dir("files/".$update_profile->user."/")) { if (!mkdir($upload_dir)) die ("upload_files no existe dicho directorio y fallo la creacion"); if (!chmod($upload_dir,0755)) die ("cambiar permisos a 755 fallido."); }
/***************************************** Process User's Request *********************************************/ if ($_REQUEST[del] && $DELETABLE) { $resource = fopen("log.txt","a"); fwrite($resource,date("Ymd h:i:s")."DELETE - $_SERVER[REMOTE_ADDR]"."$_REQUEST[del]\n"); fclose($resource);
if (strpos($_REQUEST[del],"/.")>0); //possible hacking else if (strpos($_REQUEST[del],$upload_dir) === false); //possible hacking else if (substr($_REQUEST[del],0,6)==$upload_dir) { unlink($_REQUEST[del]); print "<script>window.location.href='$url_this?message=eliminado exitosamente'</script>"; } } else if ($_FILES['userfile']) { $resource = fopen("log.txt","a"); fwrite($resource,date("Ymd h:i:s")."UPLOAD - $_SERVER[REMOTE_ADDR]" .$_FILES['userfile']['name']." " .$_FILES['userfile']['type']."\n"); fclose($resource);
<br><b>Mis archivos</b> <hr width=70%> <?=$filelist?> </P> <BR> </fieldset> <!-- Notice! you have to change this links here, if the files are not in the same folder --> <p><a href="<?php echo $update_profile->main_page; ?>">Inicio</a></p> </body> </html>
« Last Edit: Oct 25, 2006, 08:37:12 AM by eliezer »
Moderator Community Supporter?
Jedai Sword Master
Gender:
Posts: 6440
39464 credits Members referred : 374