Jump to content

Recommended Posts

ok, i am wanting to make a script to create a new folder and copy a file over and have certain spots of the file edited to meet some specific things,


If anyone can atleast help me with the part of making the directy and having it chmod, and how to copy a file from one directory to the new one. I should then be able to handle it.
You can create a directory with the mkdir() function - If I remember correctly, it's second parameter can be used to chmod the directory at the same time. You can copy files with the copy() function. For more info onhow to use them, check out the manual over at php.net
Sorry i took so long for a reply, but here is my code:
[code]
$set=$_REQUEST[set];
if ($set=='url') {
$url=$_POST[url];
mkdir("../$url", 0707);
mkdir("../$url/include", 0707);

$file = 'http://www.friendshideout.com/test/copy/index.php';
$newfile = 'temp/index.php';
copy($file, $newfile);
$file2 = 'http://www.friendshideout.com/test/copy/include/db.php';
$newfile2 = 'temp/include/db.php';
copy($file2, $newfile2);
$file1 = 'http://www.friendshideout.com/test/copy/include/header.php';
$newfile1 = 'temp/include/header.php';
copy($file1, $newfile1);



$sql="UPDATE `users` SET `url` = 'http://www.friendshideout.com/$url' WHERE username='$username'";
mysql_query("$sql") or die (mysql_error());
echo "Congratulations Your New Url Is: http://www.friendshideout.com/$url";
}
[/code]

Hope that helps
I personaly would do something like this. Are you attempting to open a remote websites index.php file?

[code]
<?php
$set=$_REQUEST[set];
if ($set=='url') {
$url=$_POST[url];
if (!is_dir("../$ur")) {
    mkdir("../$url", 0707);
}
if (!is_dir("../$url/include")) {
  mkdir("../$url/include", 0707);
}
$file = 'http://www.friendshideout.com/test/copy/index.php';
$newfile = 'temp/index.php';

$handle = fopen($file, "rb");
if (!$handle) {
  echo "Unable to open $file.";
  include("somepage.php");
  exit();
}
$contents = fread($handle, filesize($file));
$fp = fopen($newfile, "x+b");
if (!$fp) {
  echo "unable to create the requested file";
  include("somepage.php");
  exit();
}
fwrite($fp, $contents);
fclose($handle);
fclose($fp);
?>
[/code]

Now this is a little sloppy but it should give you the basic idea.

Good luck,
Tom
 

Ok, i have tried that code and these are the errors i am recieving, now i am not very familiar with this so i can't exactly go through and debug it myself but the errors are:

Warning: Wrong parameter count for fread() in /home/friends/public_html/test/set_url.php on line 51

Warning: fopen(../$url/index.php): failed to open stream: No such file or directory in /home/friends/public_html/test/set_url.php on line 52
unable to create the requested file
ok, i have solved this issue, now for the file that is copied, ok what it does is it takes that new folder that was created and stores it in a database, that url is specific to a registered user, now i need to get the page that was copied to when that url is typed in pull the data from the database from that url.

catch what i'm saying or is it confusing??
This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.