How can I enable php system (user:apache) to add file and commit changes to SVN?
I am making a file uploading form. I want to also add the images I've u开发者_运维知识库ploaded to SVN and then commit that change.
Somthing like:
system('svn add *', $ret1);
system('svn commit -m "the files were added and committed"', $ret2);
echo '<hr />add: ' . $ret1';
echo '<hr />commit: ' . $ret2';
Problem is that php runs as "apache" and so it can't make changes to SVN. I did the right thing and looked for similar question and found this one, but I don't know what password I'm supposed to use there. Using my ssh name/password doesn't work, does my svn account have its own?
You must realise using straight system calls should be avoided as much as possible, most especially if the script resides in a public webspace, .htaccess protected or not.
I strongly suggest you look into this section of the manual and build your script using those functions if possible.
Hopefully, you are running 'nux in which case getting up and running is as easy as
sudo apt-get php5-svn
on most distros.Happy coding friend
svn --username --password will allow you to run the svn transaction as whoever you wish. Hope this helps!
does my svn account have its own?
Yes, your svn server has an own account that normally is unrelated to the account on your system. You should know it because you need to have it to connect to the SVN server and do commits.
You can sandbox your script by testing the commands you want to execute from PHP in the shell first, so to validate username and password.
But what was written in the answer by stefgosselin is valid, too: Take care with system commands. Ensure you're operating in the right working directories. And I don't think it's a good idea to blindly commit user uploads w/o really proper validation first (no idea how much safety you've implemented, just saying so). Better safe than sorry.
精彩评论