Closed Thread
Results 1 to 5 of 5

Thread: earn easy 50 credits (yopic-php copy)

  1. #1
    nahsorhseda's Avatar
    nahsorhseda is offline x10 Sophmore nahsorhseda is an unknown quantity at this point
    Join Date
    Oct 2007
    Location
    mumbai
    Posts
    116

    earn easy 50 credits (yopic-php copy)

    i have a directory called "config" in my public_html dirctory i want a script where i can copy the whole "config" directory with all its files to a new directory(config_copy) in the public_html directory

    iam doing this cause iam tryin to make a site where all the users content is placed in their directory....this is to avoid messing up stuff

    i succeeded in coping many files at once but not the whole dirctory ..........ive seen many people doin it but i dont know how ..........if u make a script for me ill pay you 50 c.

    if you want to refer you can check this..... http://in2.php.net/copy
    Last edited by nahsorhseda; 12-04-2007 at 12:47 AM. Reason: spell.. miss..
    glad to resolve problems in c++ n php

  2. #2
    Tariqul Islam's Avatar
    Tariqul Islam is offline x10 Sophmore Tariqul Islam is an unknown quantity at this point
    Join Date
    Oct 2007
    Location
    Bangladesh
    Posts
    182

    Re: earn easy 50 credits (yopic-php copy)

    PHP Code:
      <?php

    // A function to copy files from one directory to another one, including subdirectories and
    // nonexisting or newer files. Function returns number of files copied.
    // This function is PHP implementation of Windows xcopy  A:\dir1\* B:\dir2 /D /E /F /H /R /Y
    // Syntaxis: [$number =] dircopy($sourcedirectory, $destinationdirectory [, $verbose]);
    // Example: $num = dircopy('A:\dir1', 'B:\dir2', 1);

    function dircopy($srcdir$dstdir$verbose false) {
      
    $num 0;
      if(!
    is_dir($dstdir)) mkdir($dstdir);
      if(
    $curdir opendir($srcdir)) {
        while(
    $file readdir($curdir)) {
          if(
    $file != '.' && $file != '..') {
            
    $srcfile $srcdir '\\' $file;
            
    $dstfile $dstdir '\\' $file;
            if(
    is_file($srcfile)) {
              if(
    is_file($dstfile)) $ow filemtime($srcfile) - filemtime($dstfile); else $ow 1;
              if(
    $ow 0) {
                if(
    $verbose) echo "Copying '$srcfile' to '$dstfile'...";
                if(
    copy($srcfile$dstfile)) {
                  
    touch($dstfilefilemtime($srcfile)); $num++;
                  if(
    $verbose) echo "OK\n";
                }
                else echo 
    "Error: File '$srcfile' could not be copied!\n";
              }                   
            }
            else if(
    is_dir($srcfile)) {
              
    $num += dircopy($srcfile$dstfile$verbose);
            }
          }
        }
        
    closedir($curdir);
      }
      return 
    $num;
    }

    $num dircopy('./''./../config_backup'1);

    echo 
    "$num files copied!";
    ?>
    This will work fine. Just create a file in your config directory and paste the above code. Then open the file using your browser and domain.

    example: http://your_site_url/your_file_name.php

    That's all.
    Last edited by Tariqul Islam; 12-04-2007 at 06:18 AM.



  3. #3
    nahsorhseda's Avatar
    nahsorhseda is offline x10 Sophmore nahsorhseda is an unknown quantity at this point
    Join Date
    Oct 2007
    Location
    mumbai
    Posts
    116

    Re: earn easy 50 credits (yopic-php copy)

    no it aint workin its only creating a folder called config_backup ....and not a single file is copied and also when i run the php script i get this message"o files copied"

    iam not copying the folders for backup to be more specific ......when a user registers into my site with a username "xyz" i want the 'config" folder to be copied and named as 'xyz' ie the username in which he registers


    i want all the files and subfolders to be copied
    glad to resolve problems in c++ n php

  4. #4
    Slothie's Avatar
    Slothie is offline Lord Of The Keys Slothie is an unknown quantity at this point
    Join Date
    Sep 2007
    Location
    Singapore
    Posts
    1,432

    Re: earn easy 50 credits (yopic-php copy)

    PHP Code:
    function scopy($dirsource$dirdest)

    if(
    is_dir($dirsource))$dir_handle=opendir($dirsource);
    mkdir($dirdest."/".$dirsource0750);
    while(
    $file=readdir($dir_handle))
    {
    if(
    $file!="." && $file!="..")
    {
    if(!
    is_dir($dirsource."/".$file)) copy ($dirsource."/".$file$dirdest."/".$dirsource."/".$file);
    else 
    COPY_RECURSIVE_DIRS($dirsource."/".$file$dirdest);
    }
    }
    closedir($dir_handle);
    return 
    true;

    Try this instead.

    Easiest 70 points you'll make on x10

    Feel free to add my reputation by clicking on the if you found my post helpful to you :P


    If I am not responding to your PMs, that means I am ignoring you. Take a hint.



    09 F9 11 02 9D 74 E3 5B D8 41 56 C5 63 56 88 C0


  5. #5
    nahsorhseda's Avatar
    nahsorhseda is offline x10 Sophmore nahsorhseda is an unknown quantity at this point
    Join Date
    Oct 2007
    Location
    mumbai
    Posts
    116

    Re: earn easy 50 credits (yopic-php copy)

    i really dont understand php
    all i want is something like this abn input box called with name "xyz" and when user hits the submit button the directory "config" which is a directory present in public_html must be copied to "xyz" with all files and folders
    glad to resolve problems in c++ n php

Closed Thread

Similar Threads

  1. Unstand PHP?
    By o0slowpaul0o in forum Tutorials
    Replies: 8
    Last Post: 01-07-2008, 09:16 PM
  2. earn easy 100 points for helping me (topic-php)
    By nahsorhseda in forum The Marketplace
    Replies: 6
    Last Post: 11-24-2007, 01:09 AM
  3. Sigo con problemas con phpbb2
    By reciecho in forum Soporte
    Replies: 7
    Last Post: 10-20-2007, 06:28 PM
  4. "PHP Startup: Invalid Library" - Interesting error
    By javaguy78 in forum Free Hosting
    Replies: 5
    Last Post: 03-27-2007, 02:33 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
x10hosting free hosting for the masses
dedicated servers