TalkPHP
 
 
Account Login
Latest Articles
» The basic usage of PHPTAL, a XML/XHTML template library for PHP
» Vulnerable methods and the areas they are commonly trusted in.
» Simple way to protect a form from bot
» The Basics On: How Session Stealing Works
» How to keep your forms from double posting data
IRC Channel
IRC Speech Bubble Join the friendly bunch on IRC...
(#TalkPHP on Freenode)

...Also available via a web interface.

See this thread for information on the TalkPHP Free Hugs Initiative™. Subject to availability.
Associates
Associates
CSS Tutorials
Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old 08-05-2005, 05:57 AM   #1 (permalink)
The Contributor
 
Join Date: Jun 2005
Posts: 40
Thanks: 0
clenard is on a distinguished road
Default Auto-populating Directories?

Hey guys, girls...

New question! lol

Right now I'm developing a System for a Buddy of mine and I'm trying to figure out how to do something very simple - yet hard to find ANY information regarding the topic...

I'm using Smarty as a Templating System with about 50+ Templates, and basically the System is much like Soundclick.com or the software Jamroom.net... by that - I'm referring to a User system where you could click "add new user" -> go to a Form, fill out information and click Submit -> then they now have their own little "site" by going to: "www.fakedomain .com/0/bobswebsite/"

inside that directory they can have 5-10 pages (auto populated) for their visitors to click on...

the problem is - I'm not sure exactly how to do this? I know I could manually create directories such as "/0/, /1/,etc" but I'm thinking using "mkdir" and "chdir" would be easier in a function... BUT what would I use to Populate the directories according to the template? I was looking at "file_puts_content" - but will this be enough for what I'm looking for?

thanks for any help! I've hit the php mailing list and got a few real cloudy answers - and a few google comments (lol) but other than that - I can't find ANY information regarding what I'm trying to do...

thanks! :cool:
clenard is offline  
Reply With Quote
Old 08-05-2005, 01:19 PM   #2 (permalink)
The Acquainted
 
Join Date: May 2005
Posts: 106
Thanks: 0
jaswinder_rana is on a distinguished road
Default

you have to create directories to do that and copy all the contents there, something similar to cpanel which copies skeleton when a new account is created.

you can create a template directory which will have all the files needed to do whateever you are doing.
then when you create account, you only have to do is create a directory by that name and then copy all of the folders in that template directory to the new one.

ofcourse there isn't a comand to copy all folders at once, and i had to do the similar thing, then i got a little function from somebody which recursively copies the whole directory to another one. i'l post it here hoping to help you out

and i wont take credit for this as i am just using it and it is written by somebody else.. you can find info about the person in the comments
PHP Code:
/**
     * Copy a file, or recursively copy a folder and its contents
     *
     * @author      Aidan Lister <aidan@php.net>
     * @version     1.0.1
     * @param       string   $source    Source path
     * @param       string   $dest      Destination path
     * @return      bool     Returns TRUE on success, FALSE on failure
     */
    
function copyr($source$dest)
    {
        
// Simple copy for a file
        
if (is_file($source)) {
            return 
copy($source$dest);
        }
     
        
// Make destination directory
        
if (!is_dir($dest)) {
            
mkdir($dest);
        }
     
        
// Loop through the folder
        
$dir dir($source);
        if(
$dir)
        {
            while (
false !== ($entry $dir->read())) {
                
// Skip pointers
                
if ($entry == '.' || $entry == '..') {
                    continue;
                }
         
                
// Deep copy directories
                
if ($dest !== "$source/$entry") {
                    
copyr("$source/$entry""$dest/$entry");
                }
            }
            
// Clean up
            
$dir->close();
        }
     
        
        return 
true;
    } 
__________________
---------------------------
Errors = Improved Programming.
Portfolio
Send a message via MSN to jaswinder_rana
jaswinder_rana is offline  
Reply With Quote
Old 08-05-2005, 05:37 PM   #3 (permalink)
The Acquainted
 
Join Date: Mar 2005
Posts: 177
Thanks: 0
CreativeLogic is on a distinguished road
Default

You may also try using mod_rewrite rather than actually copying over the files. That may be a bit too advanced though.
CreativeLogic is offline  
Reply With Quote
Old 08-05-2005, 08:16 PM   #4 (permalink)
The Contributor
 
Join Date: Jun 2005
Posts: 40
Thanks: 0
clenard is on a distinguished road
Default

Jas, Ryan - I think you both hit it on the nail... I think using the same type of system that CPanel uses is exactly like I need... and actually, when you look at cPanel (for users) with Fantastico - it does the same thing too! So, with that and the mod_rewrite - I think you guys helped out alot with the logic and thought process :D

THANKS GUYS!
clenard is offline  
Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


All times are GMT. The time now is 05:06 AM.

 
     

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0
Inactive Reminders By Icora Web Design