gerkintrigg Posted January 31, 2013 Share Posted January 31, 2013 I wrote a script to automatically generate a folder with an index page in it using data from a database record, but it only operates when the administrator activates the record. I've worked out nearly all of it, but is there a simple way to copy the original contents of the master file, but leave the original intact? I'm not getting any errors, and the directory is being created, but it's empty. So-far I have: $path_to_file=$root.$shop_name.'/index.php'; if(!file_exists($path_to_file)){ mkdir($root.$shop_name,'0777'); copy($root.'members/do-not-delete.php', $root.$shop_name.'/index.php'); } I can't see anything wrong with the code and all the Google snippets seem to suggest this is the way to do it. Help, please. Neil Quote Link to comment https://forums.phpfreaks.com/topic/273885-duplicating-a-master-file/ Share on other sites More sharing options...
Jessica Posted February 1, 2013 Share Posted February 1, 2013 Are you actually creating a subdirectory for each shop and then copying your PHP files into it? That is *NOT* the way to do it. You should probably be using mod rewrite for this. Quote Link to comment https://forums.phpfreaks.com/topic/273885-duplicating-a-master-file/#findComment-1409400 Share on other sites More sharing options...
gerkintrigg Posted February 1, 2013 Author Share Posted February 1, 2013 I am using Mod Rewrite too, but this creates a blank page to work from so they can customise it themselves. I'm fine with doing it this way and there are reasons for it which I won't go into now, but needless to say I need a subdirectory (a real one) for each new shop.The only issue is how to duplicate the file. Quote Link to comment https://forums.phpfreaks.com/topic/273885-duplicating-a-master-file/#findComment-1409457 Share on other sites More sharing options...
Christian F. Posted February 1, 2013 Share Posted February 1, 2013 (edited) You should check your error logs, and see if you get an error message returned. Also, remove the quotes around the permissions. They prevent the mode from being parsed as an octal: php > echo 0777; 511 php > echo intval ('0777'); 777 Edited February 1, 2013 by Christian F. Quote Link to comment https://forums.phpfreaks.com/topic/273885-duplicating-a-master-file/#findComment-1409463 Share on other sites More sharing options...
trq Posted February 1, 2013 Share Posted February 1, 2013 Your missing the entire point of dynamic web applications. Do you think this forum creates a new php page every time someone adds a new post? Quote Link to comment https://forums.phpfreaks.com/topic/273885-duplicating-a-master-file/#findComment-1409474 Share on other sites More sharing options...
Jessica Posted February 1, 2013 Share Posted February 1, 2013 You are giving your users a PHP file to edit? Very dangerous. Quote Link to comment https://forums.phpfreaks.com/topic/273885-duplicating-a-master-file/#findComment-1409487 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.