Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie

php question

Options
  • 09-02-2006 4:15pm
    #1
    Closed Accounts Posts: 3,807 ✭✭✭


    Hello,

    Following on from my earlier question - I have a possibly more basic request! so any help would be great...

    I want to create a scenario where a user registers a username and password (and gets email confirmation) - this is OK, as I've seen plenty examples of scripts to do this.
    I then want for this new username (thats jst been registered) a new directory with component files to be created (copied from a different location).

    ie. user logs on a registers username "michael" with his unique password
    then a folder is created (ex. www.proN.com/michael) with a series of files (copied from perhaps www.proN.com/resource)... this files are perhaps a collection of webpages an images...

    best method?


Comments

  • Closed Accounts Posts: 4,655 ✭✭✭Ph3n0m


    when you are sending out your automatic email, you can also have php in the background creating folders based on the username and then copy the files from a predetermined location into that folder, tis easy enough - just remember you also need to chmod the newly create folder correctly, plus make sure there is a valid "owner" on the folder, otherwise you will be calling your hosting company to remove it from the server for you.

    You would need to use the following

    Make http://ie2.php.net/manual/en/function.mkdir.php
    Copy http://ie2.php.net/manual/en/function.copy.php

    Done and dusted


  • Closed Accounts Posts: 3,807 ✭✭✭chump


    thank :)

    more questions on the way!


  • Closed Accounts Posts: 169 ✭✭akari no ryu


    Chump,

    I assume that you own the server yourself and that you're not sharing it with anyone, otherwise the permissions on the folders you make is set such that Apache and PHP own it, meaning that anyone on that server has 777 access to it.

    Is there any reason you're not using mysql (or some other database) to store the files?


  • Registered Users Posts: 4,003 ✭✭✭rsynnott


    Why do you want to do this? If you have more than a small number of users, it's going to be quite inefficient. And imagine if you needed to update the files system-wide!


  • Closed Accounts Posts: 3,807 ✭✭✭chump


    Thing is I don't really know how's the best way to go about what I want which I posted in another forum. I'll say what I want/need and at the end say what I thought I might attempt.

    1. Basically I need the function of a user being able to "register" a user/pass.

    2. Then I want the user to select a page style from a list.

    3a. There will be a selection of templates.
    The template files will contain a selection of vars
    Hobbies: {$name}<br>
    Attitude: {$address}<br>

    3b. I also would like the template to contain image_vars

    I'm reckoning the templates will all contain the same selection of vars. Altho it would be nice if it didn't...

    4. Then post registering I would like for a directory to be created for the user (www.stFanworld.com/palnumberuno/).

    5. A blank page or relatively blank page will be there.

    6a. On the post registering screen or perhaps at www.stFanworld.com/palnumberuno/admin
    an index file will exist to enter the vars into their template.

    6b. it would be nice here if they could in real-time select their specific template, and its specific selection of vars (form input) would pop up.

    6c. Now this admin index page will have to be password protected obviously.
    Images should also be able to be uploaded, initially to replace the speficic collection of images contained in the template file... then read further

    7. On top of all this I want to go about this in the right way, so that to ensure that 'add-ons' like a guest-book and an image uploader can be added. What kind of database configuration and tables set-up would be best to allow this possibility.

    So far because I dont know how to code or really do much I've edited a bit of a login script and set it up so that the user reg's, on reg their directory is also created and dummy files copied
    * The user has submitted the registration form and the
    * results have been processed.
    */
    else if(isset($_SESSION)){
    /* Registration was successful */
    if($_SESSION){
    echo "<h1>Registered!</h1>";
    echo "<p>Thank you <b>".$_SESSION."</b>, your information has been added to the database, "
    ."you may now <a href=\"main.php\">log in</a>.</p>";

    $oldumask = umask(0);
    $puser=$_SESSION;
    mkdir("$puser", 0777); // or even 01777 so you get the sticky bit set
    umask($oldumask);

    $file = "mydir/terrible.txt";
    $newfile = "$puser/test.txt";

    if (!copy($file, $newfile)) {
    echo "failed to copy $file...\n";
    }

    So basically my thinking was, reg a user/pass, bop in default location in the database I setup with script, then create the folder, and the possibility of copying a basic dummy website to that location where they can then go and carry on with the next steps...
    My current thinking, before I get into templating, is how I should arrange the database, what arrangement for the tables etc...

    Say I want user/pass and then 20 other fields (that's the max., say each template uses between 10to20). And then perhaps 3/4 images in the template files that will be changed to the users specific, and then for the possibility of a guestbook and image/description page to be setup...

    I know I'm way out of my depth but this is how I learn best... any tips? :D

    of course if some generous spirit wants to set this up for me and aid me in my project I'd be very grateful :):) (some chance eh!)


  • Advertisement
  • Closed Accounts Posts: 3,807 ✭✭✭chump


    cough :d


  • Closed Accounts Posts: 4,655 ✭✭✭Ph3n0m


    my tips are do some google searching

    also search on www.phpbuilder.com/board/search.php

    this project has been done loads of times before, the scripts are out there

    also try www.hotscripts.com


  • Closed Accounts Posts: 169 ✭✭akari no ryu


    chump wrote:
    6a. On the post registering screen or perhaps at www.stFanworld.com/palnumberuno/admin
    an index file will exist to enter the vars into their template.

    I'm still not seeing why you're not using MySQL for this. This would reduce your templates and admin folders from n (where n is the number of users) to 1. One global admin log in where they enter their username and password.

    Select the id from the user table and keep it in session.

    This way, when it comes to parsing your templates, you select content from the content table where owner = id. Assign that value to some variable, assign the variable to the templating engine and display.


Advertisement