123
-=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- (c) WidthPadding Industries 1987 0|439|0 -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=-
Socoder -> Web Development -> MySQL export through web-interface

Posted : Thursday, 06 October 2011, 13:24
HoboBen
I'd like to support a MySQL export/import feature for a website admin panel.

Import is not that important, as it should be rare enough to be done manually.

I was thinking of just execing mysqldump to a temporary file, giving it to the admin to download, then deleting the file.

Issues are:

a) ensuring only the admin can download it (without having to maintain a manual IP whitelist)

-- possible solution: generating a .htaccess and folder on the fly for the user with the user's IP, deleting when done.

-- possible solution: pipe the output directly through the browser with a correct download mime type header. As this (hopefully) won't be used by many users simultaneously, keeping a script running for a long time won't matter much.

b) deleting the file when it's finished being downloaded. How do you know when the user has finished downloading the file?

-- possible solution: cron job to clear a folder.

---- issue: if it's a daily cron job, what happens if the user starts the download at 11:59pm?

---- issue: if a user does this multiple times they can fill up the server and run out of disk space.

---- issue: editing cron jobs on the fly is horrible and hacky. There's no good interface. You can drop files into /etc/cron.d/ if you're root, but apache is not root!

--- Simplest solution, I could be the only one who does this, use scp (secure copy) & a command line script to download, and clean up afterwards. Obviously this means that no-one else can do the same without full SSH access.

Your insights greatly appreciated!

-=-=-

Posted : Thursday, 06 October 2011, 13:39
HoboBen
There's the *nix "at" package, which looks like it might help, but it has dependencies on exim (a mailer) for e-mailing you when it's done, and I'd rather not have a non-essential daemon running on the server.

-=-=-

Posted : Thursday, 06 October 2011, 14:14
Jayenkai
Alternatvely, compress with randomly generated password, send user password when originally requested.
Not 100% sure how safe compression encryption is, mind... Been a LONG time since I looked into that!

-=-=-
''Load, Next List!''
Posted : Sunday, 09 October 2011, 16:51
HoboBen
In the end, I just echo'd out some comma-separated and base64 encoded values with a header:

header('Content-Description: File Transfer');
header('Content-Disposition: attachment; filename='.$file);
header('Content-Type: text/csv');
header('Content-Transfer-Encoding: binary');

-=-=-