user file/folder script

Started on the old forum in January 2013 · view the original in the archive · old links redirect here

5 replies · 452 views · started 13 years ago · 1 min read

4 participants
ahmed_zaab Newbie · 3 posts #5

yeah... i ve a script for that. Follow the step bellow. Step 1 [1]: in your config.php add this line

**``` $SourceDir = 'source';


**Step 2**: create a new dir (source)  in ur host.

**Step 3**: now create a new file (default.php) in ur public html.

<?php function recurse_copy($src,$dst) { // recursive function that copy files from one directory to another $dir = opendir($src); @mkdir($dst); while(false !== ( $file = readdir($dir)) ) { if (( $file != '.' ) && ( $file != '..' )) { if ( is_dir($src . '/' . $file) ) { recurse_copy($src . '/' . $file,$dst . '/' . $file); } else { copy($src . '/' . $file,$dst . '/' . $file); } } } closedir($dir); //echo "$src"; } function remote_mkpath($server, $path) { $dirs = array(); $path = preg_replace('/(\/){2,}|(\\\){1,}/','/',$path); //only forward-slash $dirs = explode("/", $path); $path = "\\\\" . $server . "/"; $i = 0; foreach ($dirs AS $element) { $path .= $element . "/"; if(!is_dir($path) && $i != 0) { if(!mkdir($path)){ echo "something was wrong at : " . $path; return 0; } } $i++; } return true; echo $path; } ?>

**Step 4**: now on  the top of ur register.php put this line 

require_once('default.php');


**Step 5**: Now in register page if users submited from were ok..before run the sql add this last code 

mkdir(dirname(FILE)."/"."$username"); // Create Directory recurse_copy($SourceDir,$username); // Copy files from source directory to target directory


this will make a subfolder for every new registered user.

change the value "$username" according ur register value. 

**Note**: at step 2 where you made a new dir (source) in that dir create a index.php and put ur users data. 

this script will automatic make a subfolder as username and automatic copy the index.php from the (source) dir. even u can add more php file or image for auto copy in @username@ folder
rajivmeg Junior · 30 posts #6

can u attach your script with following method. with .htaccess support. its request

Sign in to reply.

Similar topics

Keyboard shortcuts

g f
Go to forums
g h
Go to your feed
g m
Go to messages
r
Reply (in a topic)
/
Search
j
Next post
k
Previous post
?
This list
Ctrl/⌘ + Enter
Send what you are writing
Ctrl/⌘ + B / I
Bold / italic while writing
Esc
Close