Eternal Posted February 9, 2009 Posted February 9, 2009 Due to i posted this in a topic here and got some feedback in my inbox about it. I have decided to make it as a topic.... First this doesn't protect anything it just insures that a quick game backup could be restored to continue your Game for players.. Name the file to anything you like "ensure its name isn't easily guessed to prevent people clicking it. You're unable to view this code. Viewing code within this forum requires registration, you can register here for free. also i have tried this on numerous free sites and some paid sites. You need to be able to use the command passthru() as a few sites block its usage... Quote
Isomerizer Posted February 9, 2009 Posted February 9, 2009 Re: [mccode all] sql backup Already been posted here: http://criminalexistence.com/ceforums/i ... pic=1655.0 Also, It's so much easier to just stick this in a daily cron: "/usr/local/bin/mysqldump -u user --password=password database | gzip > /home/*/backup/sql-`/usr/bin/date +\%Y\%m\%d`.sql.gz" Just change the username, password, database name and location of backup folder on server. And kaboom its done, it's that easy! The passthru() function is just executing the unix command and passing it back to the browser, all that really isn't needed... http://uk2.php.net/passthru Quote
Lithium Posted February 9, 2009 Posted February 9, 2009 Re: [mccode all] sql backup Already been posted here: http://criminalexistence.com/ceforums/i ... pic=1655.0 Also, It's so much easier to just stick this in a daily cron: "/usr/local/bin/mysqldump -u user --password=password database | gzip > /home/*/backup/sql-`/usr/bin/date +\%Y\%m\%d`.sql.gz" Just change the username, password, database name and location of backup folder on server. And kaboom its done, it's that easy! The passthru() function is just executing the unix command and passing it back to the browser, all that really isn't needed... http://uk2.php.net/passthru you got a point, but all that is also needed as he sends the gzipped dump to email :) Quote
Isomerizer Posted February 9, 2009 Posted February 9, 2009 Re: [mccode all] sql backup you got a point, but all that is also needed as he sends the gzipped dump to email :) Like I said in a previous post on backing up, Emailing backup via unix cron command is also possible. Using the sendmail unix command... http://linux.about.com/od/commands/l/blcmdl8_sendmai.htm Quote
Haunted Dawg Posted February 9, 2009 Posted February 9, 2009 Re: [mccode all] sql backup I just tested this out. And it look's like passthru is disabled on my server. How ever i used exec() and it worked :) Quote
Tonka Posted February 9, 2009 Posted February 9, 2009 Re: [mccode all] sql backup i have this running on my server and it's works fine using passthru Quote
Eternal Posted February 9, 2009 Author Posted February 9, 2009 Re: [mccode all] sql backup well all i know is that this is working doing its job.. i know some of you proved different ways on it But this was the first way i came across and it doesn't create lag for me or any hassles.. so thank you for providing alternative ways about this as well... Quote
Isomerizer Posted February 9, 2009 Posted February 9, 2009 Re: [mccode all] sql backup i have this running on my server and it's works fine using passthru exec() & passthru() are almost the same, just passthru() shows raw output. Both functions should be used with caution. This is why some host's may disable them, as when used incorrectly they can become very harmful. The function escapeshellcmd() is recommended when using exec/passthru/system. http://uk2.php.net/manual/en/function.e ... ellcmd.php Quote
Haunted Dawg Posted February 9, 2009 Posted February 9, 2009 Re: [mccode all] sql backup The escapeshellcmd() function is only necessary if the "user" is inputing a raw command. If the editor of the script or such is differntly using this. Then that should be his own fault if he screw's up the server. Quote
Isomerizer Posted February 9, 2009 Posted February 9, 2009 Re: [mccode all] sql backup The escapeshellcmd() function is only necessary if the "user" is inputing a raw command. If the editor of the script or such is differntly using this. Then that should be his own fault if he screw's up the server. Lol true, kind of like the mres func when interacting with db. But most people prefer over-the-top-security to efficiency. I think its a very rare case that a user would need to interact with the passthru/exec/system func's. :? Quote
Haunted Dawg Posted February 9, 2009 Posted February 9, 2009 Re: [mccode all] sql backup Very rare to even interact with the passthru/exec/system func? A visitor to your site should never be able to run such a command. Quote
Isomerizer Posted February 9, 2009 Posted February 9, 2009 Re: [mccode all] sql backup Very rare to even interact with the passthru/exec/system func? A visitor to your site should never be able to run such a command. Yes I know, but they must have to in some cases, otherwise why would PHP even bother creating the escapeshellcmd() function. Quote
Haunted Dawg Posted February 9, 2009 Posted February 9, 2009 Re: [mccode all] sql backup Explain in one place a user should run a raw server command? Quote
Isomerizer Posted February 9, 2009 Posted February 9, 2009 Re: [mccode all] sql backup http://uk2.php.net/manual/en/function.e ... ellcmd.php If you scroll down it has a few examples, the common one if the file path is via user input/upload... May not be needed in any of mccodes shit etc, but maybe in some more advancish PHP. e.g shells. Quote
iseeyou94056 Posted February 10, 2009 Posted February 10, 2009 Re: [mccode all] sql backup Warning: file(backup-2009-02-09.sql.gz) [function.file]: failed to open stream: No such file or directory in C:\localhost\www\bla.php on line 16 Warning: implode() [function.implode]: Invalid arguments passed in C:\localhost\www\bla.php on line 16 Warning: mail() [function.mail]: Failed to connect to mailserver at "localhost" port 25, verify your "SMTP" and "smtp_port" setting in php.ini or use ini_set() in C:\localhost\www\bla.php on line 32 Warning: unlink(backup2009-02-09.sql.gz) [function.unlink]: No such file or directory in C:\localhost\www\bla.php on line 33 Quote
Eternal Posted February 10, 2009 Author Posted February 10, 2009 Re: [mccode all] sql backup Warning: file(backup-2009-02-09.sql.gz) [function.file]: failed to open stream: No such file or directory in C:\localhost\www\bla.php on line 16 Warning: implode() [function.implode]: Invalid arguments passed in C:\localhost\www\bla.php on line 16 Warning: mail() [function.mail]: Failed to connect to mailserver at "localhost" port 25, verify your "SMTP" and "smtp_port" setting in php.ini or use ini_set() in C:\localhost\www\bla.php on line 32 Warning: unlink(backup2009-02-09.sql.gz) [function.unlink]: No such file or directory in C:\localhost\www\bla.php on line 33 I don't think this would run on wamp. lol or a similar xamp or so.. Quote
Haunted Dawg Posted February 10, 2009 Posted February 10, 2009 Re: [mccode all] sql backup It actualy will run on xamp or wamp. There it is stating that the file has not been run. Change passthru to exec Quote
iseeyou94056 Posted February 22, 2009 Posted February 22, 2009 Re: [mccode all] sql backup Warning: passthru() has been disabled for security reasons in /home/dothost.eu/vhosts/backup.php on line 14 Warning: file() [function.file]: Unable to access backup-2009-02-22.sql.gz in /home/dothost.eu/vhosts/backup.php on line 20 Warning: file(backup-2009-02-22.sql.gz) [function.file]: failed to open stream: No such file or directory in /home/dothost.eu/vhosts/backup.php on line 20 Warning: implode() [function.implode]: Invalid arguments passed in /home/dothost.eu/vhosts/backup.php on line 20 Warning: unlink(backup-2009-02-22.sql.gz) [function.unlink]: No such file or directory in /home/dothost.eu/vhosts/backup.php on line 41 Quote
Haunted Dawg Posted February 22, 2009 Posted February 22, 2009 Re: [mccode all] sql backup like i already said before. Change passthru to exec. Quote
iseeyou94056 Posted February 22, 2009 Posted February 22, 2009 Re: [mccode all] sql backup get the same error when i did that Quote
Eternal Posted February 23, 2009 Author Posted February 23, 2009 Re: [mccode all] sql backup I just done some more testing on a few hosting sites. You may want to ask your hosting provider to let you have exec or passthru Some hosting sites allow one or the other.,... Quote
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.