arbitter Posted August 18, 2010 Share Posted August 18, 2010 Hi there, I wanted to create files from my phpscript. So I used the most obvious function, fopen(). It didn't work on my server and contacted the administrator, who said fopen() was disabled for security reasons, and that I should use cURL. So I did what everyone would do; I googled it. Found the php.net curl manual, but can't really comprehend what it sais. So I have a few questions: 1) Can you create .php files with cURL? 2) How? 3) How do I then write php-content in the file? Please try to explain rather detailed and simplified, I've never been good at quickly understanding all these things. Thanks a lot! Quote Link to comment https://forums.phpfreaks.com/topic/211104-curl/ Share on other sites More sharing options...
MadTechie Posted August 18, 2010 Share Posted August 18, 2010 No, cURL can't "create" files, it commonly used to read contents from other sites and post requests I would suggest using file_put_contents however it depends what your attempting to write, here is an example from PHP.net <?php $file = 'people.txt'; // Open the file to get existing content $current = file_get_contents($file); // Append a new person to the file $current .= "John Smith\n"; // Write the contents back to the file file_put_contents($file, $current); ?> Quote Link to comment https://forums.phpfreaks.com/topic/211104-curl/#findComment-1100928 Share on other sites More sharing options...
arbitter Posted August 18, 2010 Author Share Posted August 18, 2010 Well what I want to do is actually be able to generate a whole webpage by the click of a button... It would get a random name, eg AsUjeZee.php, and it also creates a database with the same random name(this part I have already). The random php file should then be able to connect to the same-named database and show all the queries. On the other hand, I could make it with one single phpfile and a $_GET containing the random name, but I don't really like to work with $_GET[] since it seems rather unsafe... Quote Link to comment https://forums.phpfreaks.com/topic/211104-curl/#findComment-1100938 Share on other sites More sharing options...
MadTechie Posted August 18, 2010 Share Posted August 18, 2010 $_GET would be the better option, and in itself it is NOT unsafe, just remember to filter it see mysql_real_escape_string for protecting mysql, Quote Link to comment https://forums.phpfreaks.com/topic/211104-curl/#findComment-1100939 Share on other sites More sharing options...
arbitter Posted August 18, 2010 Author Share Posted August 18, 2010 I'm really bad in all the safety-stuff... But I'll try to maeke it all with $_GET[] another problem then though is that I can't make an alibi for the url using dot.tk . Eg if I wish to name it whatever.tk, it would not be possible would it? Quote Link to comment https://forums.phpfreaks.com/topic/211104-curl/#findComment-1100946 Share on other sites More sharing options...
MadTechie Posted August 18, 2010 Share Posted August 18, 2010 mypage.php?name=whatever.tk should be fine <?php echo $_GET['name']; Quote Link to comment https://forums.phpfreaks.com/topic/211104-curl/#findComment-1100952 Share on other sites More sharing options...
arbitter Posted August 18, 2010 Author Share Posted August 18, 2010 ah ok then. thanks for the help! Quote Link to comment https://forums.phpfreaks.com/topic/211104-curl/#findComment-1100954 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.