dabigchz Posted October 6, 2008 Share Posted October 6, 2008 Basically, Id like to have a php script on www.websitea.com edit a text file on www.websiteb.com Ive tried a couple ideas, but so far nothing has worked... can anyone point me in the right direction? Quote Link to comment Share on other sites More sharing options...
Brian W Posted October 6, 2008 Share Posted October 6, 2008 I believe there are distinct, purposeful, blocks from doing that. Imagine for a second the security risks of allowing people to edit your files from anywhere. Though, if it were to be possible, you may end up looking into XSS. Quote Link to comment Share on other sites More sharing options...
genericnumber1 Posted October 6, 2008 Share Posted October 6, 2008 The easiest way would be through the FTP family of functions http://us.php.net/ftp . That is, assuming the websites are on different servers. Quote Link to comment Share on other sites More sharing options...
dabigchz Posted October 6, 2008 Author Share Posted October 6, 2008 Yes, the websites are on different servers. The file I want to edit will be named to be impossible to guess and will be the only file on the server editable by anyone. I was afraid I'd have to do some FTP thing... I just have no idea where to start... Quote Link to comment Share on other sites More sharing options...
CroNiX Posted October 6, 2008 Share Posted October 6, 2008 http://uk.php.net/ftp Quote Link to comment Share on other sites More sharing options...
genericnumber1 Posted October 6, 2008 Share Posted October 6, 2008 Naming a file "impossible to guess" really isn't secure at all (security by obscurity is no security in and of itself). If the website can be FTP'd to, you can FTP via php. Here are some simple examples to get you started: http://us.php.net/manual/en/ftp.examples.php Quote Link to comment Share on other sites More sharing options...
Brian W Posted October 6, 2008 Share Posted October 6, 2008 Oh yeah, kinda didn't think about FTP dur Why do you need to do this btw? There may be a easier solution. Or maybe FTP is it. Quote Link to comment Share on other sites More sharing options...
dabigchz Posted October 7, 2008 Author Share Posted October 7, 2008 I need it because websiteb will then read the file and carry on with it. My problem has now changed. Apparently what I tried before should have worked, but for some reason, nothing FTP related works to connect from websitea to websiteb. My original code was basically: $text = "Write this to the file"; $file = fopen("ftp://user:password@websiteb.com/file.txt","w"); fwrite($file, $text); when I run that code, the webpage just takes a long time to load, and when it does load, its just a blank page (and the file isn't written). Any ideas? Quote Link to comment Share on other sites More sharing options...
CroNiX Posted October 7, 2008 Share Posted October 7, 2008 you are using the (w)rite attribute for fopen, I imagine you want to ®ead the file. Quote Link to comment Share on other sites More sharing options...
dabigchz Posted October 7, 2008 Author Share Posted October 7, 2008 No, I want to write to it. Either way it won't work though. Quote Link to comment Share on other sites More sharing options...
CroNiX Posted October 7, 2008 Share Posted October 7, 2008 do you have php error reporting turned on? Any messages? Quote Link to comment Share on other sites More sharing options...
DarkWater Posted October 7, 2008 Share Posted October 7, 2008 That's not using the FTP functions. Did you even read the posted link? Quote Link to comment Share on other sites More sharing options...
dabigchz Posted October 7, 2008 Author Share Posted October 7, 2008 No error or anything. Basically anything FTP related just doesnt work... nothing happens other than a long loading time. Quote Link to comment Share on other sites More sharing options...
CroNiX Posted October 7, 2008 Share Posted October 7, 2008 Did you try using ftp commands instead of fopen? Quote Link to comment 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.