• Welcome to TechPowerUp Forums, Guest! Please check out our forum guidelines for info related to our community.

Folder Backup script ( 90% finished )

Joined
Jan 24, 2008
Messages
888 (0.15/day)
System Name Meshify C Ryzen 2019
Processor AMD Ryzen 3900X
Motherboard X470 AORUS ULTRA GAMING
Cooling AMD Wraith Prism LED Cooler
Memory 32GB DDR4 ( F4-3200C16D-32GTZKW, 16-16-16-36 @ 3200Mhz )
Video Card(s) AMD Radeon RX6800 ( 2400Mhz/2150Mhz )
Storage Samsung Evo 960
Display(s) Pixio PX275h
Case Fractal Design Meshify C – Dark TG
Audio Device(s) Sennheiser GSP 300 ( Headset )
Power Supply Seasonic FOCUS Plus Series 650W
Mouse Logitech G502
Keyboard Logitech G 15
Software Windows 10 Pro 64bit
I am working on a backup script. It works pretty simpel.

You place Backup.php in the folder you want to backup.
You run Backup.php in your webbrowser.
The script starts zipping all the content of the folder and then a download-popup will allow you to download the entire folder-content in a .zip file.

The following code generates the text you see in your browser and starts the download once the backup is completed:

Code:
foreach ($filenames as $filename) {
    echo "Adding " . $filename . "<br/>";
    $zip->addFile($filename,$filename);
}

echo "Files: " . $zip->numFiles . "\n";
echo "Status:" . $zip->status . "\n";
$zip->close();
echo "<meta http-equiv='refresh' content='0;url=Backup.zip'>";

This is what happens at this time:
- Text gets generated
- Page scrolls down to bottem
- Download begins

This is what I want to happen:
- Text gets generated
- Page scrolls down automaticly while text is being generated
- Download begins

The person who helps me will be mentioned in the credits and offcourse I will share the script with you guys once it has all the features I want it to have.

I am currently trying to do it with javascript...
 
Last edited:

Oliver_FF

New Member
Joined
Oct 15, 2006
Messages
544 (0.09/day)
Processor Intel q9400 @ stock
Motherboard Lanparty P45-T2RS
Cooling Zalman CNPS-9500
Memory 8GB OCZ PC2-6400
Video Card(s) BFG Nvidia GTX285 OC
Storage 1TB, 500GB, 500GB
Display(s) 20" Samsung T200HD
Case Antec Mini P180
Audio Device(s) Sound Blaster X-Fi Elite Pro
Power Supply 700w Hiper
Software Ubuntu x64 virtualising Vista
I am working on a backup script. It works pretty simpel.

You place Backup.php in the folder you want to backup.
You run Backup.php in your webbrowser.
The script starts zipping all the content of the folder and then a download-popup will allow you to download the entire folder-content in a .zip file.

The following code generates the text you see in your browser and starts the download once the backup is completed:

Code:
foreach ($filenames as $filename) {
    echo "Adding " . $filename . "<br/>";
    $zip->addFile($filename,$filename);
}

echo "Files: " . $zip->numFiles . "\n";
echo "Status:" . $zip->status . "\n";
$zip->close();
echo "<meta http-equiv='refresh' content='0;url=Backup.zip'>";

This is what happens at this time:
- Text gets generated
- Page scrolls down to bottem
- Download begins

This is what I want to happen:
- Text gets generated
- Page scrolls down automaticly while text is being generated
- Download begins

The person who helps me will be mentioned in the credits and offcourse I will share the script with you guys once it has all the features I want it to have.

I am currently trying to do it with javascript...

Sadly PHP only generates static content, you can't get it to spew out data as it is processed - You create your http request, send it to the web server, the web server starts the php, when the php finishes executing the resulting html is sent back to the client.

Sadly again you can't do this with javascript because it's a client side technology and the security restrictions aren't going to allow it.

You could look into writing a JSP/Servlet and spawn off a new thread that does all the work, then have a html page with some ajax to query how much has been completed... But that's a LOT of effort :(
 
Joined
May 20, 2004
Messages
10,487 (1.44/day)
Use exec() to start winzip/tar or whatever is available on the server and then put the target file as downloadlink? Put date/time in the name and it'll remain unique.
 
Joined
Apr 21, 2008
Messages
5,250 (0.90/day)
Location
IRAQ-Baghdad
System Name MASTER
Processor Core i7 3930k run at 4.4ghz
Motherboard Asus Rampage IV extreme
Cooling Corsair H100i
Memory 4x4G kingston hyperx beast 2400mhz
Video Card(s) 2X EVGA GTX680
Storage 2X Crusial M4 256g raid0, 1TbWD g, 2x500 WD B
Display(s) Samsung 27' 1080P LED 3D monitior 2ms
Case CoolerMaster Chosmos II
Audio Device(s) Creative sound blaster X-FI Titanum champion,Creative speakers 7.1 T7900
Power Supply Corsair 1200i, Logitch G500 Mouse, headset Corsair vengeance 1500
Software Win7 64bit Ultimate
Benchmark Scores 3d mark 2011: testing
Last edited:
Joined
Jan 24, 2008
Messages
888 (0.15/day)
System Name Meshify C Ryzen 2019
Processor AMD Ryzen 3900X
Motherboard X470 AORUS ULTRA GAMING
Cooling AMD Wraith Prism LED Cooler
Memory 32GB DDR4 ( F4-3200C16D-32GTZKW, 16-16-16-36 @ 3200Mhz )
Video Card(s) AMD Radeon RX6800 ( 2400Mhz/2150Mhz )
Storage Samsung Evo 960
Display(s) Pixio PX275h
Case Fractal Design Meshify C – Dark TG
Audio Device(s) Sennheiser GSP 300 ( Headset )
Power Supply Seasonic FOCUS Plus Series 650W
Mouse Logitech G502
Keyboard Logitech G 15
Software Windows 10 Pro 64bit
I find a way around it. What I wanted was for the user to view something animated while waiting for the backup, scrolling the generated text was the first thing that comes to mind. But since that requires quite a lot of code with AJAX, I decided to display a "loading..." animated gif untill the backup is complete. Once complete I scroll down with one line of javascript code.

I am still having one issue. I am trying to add the code to a PHP-Fusion panel:

Code:
// GUI
if(iSUPERADMIN) {
	openside($p_data['panel_name']);

	echo "<div style='text-align:center;'>";
	if(empty($err_txt)) {
		echo $locale['aw_last'] . "<br />"
			. showdate("shortdate", filemtime(A_TOUCH_FILE));
		if(iSUPERADMIN) {
			echo "<p><a href='".FUSION_SELF."?force_backup=1'>"
				.$locale['AWAU010']."</a>\n";
			echo "<p><a href='".BASEDIR."Backup.php""'>"
				.$locale['aw_download']."</a>\n";
		}
	} else {
		echo $err_txt;
	}
	echo "</div>";

	closeside();
}
//

I get:

Parse error: syntax error, unexpected T_CONSTANT_ENCAPSED_STRING, expecting ',' or ';' in /home/pcgidsin/public_html/Websites/TNAC/infusions/auto_db_backup_panel/auto_db_backup_panel.php on line 204
 

W1zzard

Administrator
Staff member
Joined
May 14, 2004
Messages
27,032 (3.71/day)
Processor Ryzen 7 5700X
Memory 48 GB
Video Card(s) RTX 4080
Storage 2x HDD RAID 1, 3x M.2 NVMe
Display(s) 30" 2560x1600 + 19" 1280x1024
Software Windows 10 64-bit
Sadly PHP only generates static content, you can't get it to spew out data as it is processed - You create your http request, send it to the web server, the web server starts the php, when the php finishes executing the resulting html is sent back to the client.

actually, not exactly. as soon as php sends output it goes to the browser which can display it as it receives it (with several limitations like html tables etc). what you describe is only happening when output buffering ( ob_start() ) is active.
 
Joined
Jan 24, 2008
Messages
888 (0.15/day)
System Name Meshify C Ryzen 2019
Processor AMD Ryzen 3900X
Motherboard X470 AORUS ULTRA GAMING
Cooling AMD Wraith Prism LED Cooler
Memory 32GB DDR4 ( F4-3200C16D-32GTZKW, 16-16-16-36 @ 3200Mhz )
Video Card(s) AMD Radeon RX6800 ( 2400Mhz/2150Mhz )
Storage Samsung Evo 960
Display(s) Pixio PX275h
Case Fractal Design Meshify C – Dark TG
Audio Device(s) Sennheiser GSP 300 ( Headset )
Power Supply Seasonic FOCUS Plus Series 650W
Mouse Logitech G502
Keyboard Logitech G 15
Software Windows 10 Pro 64bit
Fixed the errorcode, stupid mistake lol.

W1zzard, are you saying that what I asked in first post is possible?
 

Oliver_FF

New Member
Joined
Oct 15, 2006
Messages
544 (0.09/day)
Processor Intel q9400 @ stock
Motherboard Lanparty P45-T2RS
Cooling Zalman CNPS-9500
Memory 8GB OCZ PC2-6400
Video Card(s) BFG Nvidia GTX285 OC
Storage 1TB, 500GB, 500GB
Display(s) 20" Samsung T200HD
Case Antec Mini P180
Audio Device(s) Sound Blaster X-Fi Elite Pro
Power Supply 700w Hiper
Software Ubuntu x64 virtualising Vista
actually, not exactly. as soon as php sends output it goes to the browser which can display it as it receives it (with several limitations like html tables etc). what you describe is only happening when output buffering ( ob_start() ) is active.

Oh cool, i didn't know that :laugh:

So if you could disable the output buffer or somehow flush the output buffer then the data in the buffer would go out in a http response packet which could be displayed by the client whilst the processing is still going on?
 
Top