forked from devsbuz/landing-page-builder-Getleads
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsave.php
82 lines (46 loc) · 2.05 KB
/
save.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
<?php
/* CONFIG */
$pathToAssets = array("elements/css", "elements/fonts", "elements/images", "elements/js", "elements/php");
$filename = "tmp/my_getleads.zip"; //use the /tmp folder to circumvent any permission issues on the root folder
/* END CONFIG */
$zip = new ZipArchive();
$zip->open($filename, ZipArchive::CREATE);
//add folder structure
foreach( $pathToAssets as $thePath ) {
// Create recursive directory iterator
$files = new RecursiveIteratorIterator(
new RecursiveDirectoryIterator( $thePath ), RecursiveIteratorIterator::LEAVES_ONLY
);
foreach ($files as $name => $file) {
if( $file->getFilename() != '.' && $file->getFilename() != '..' ) {
// Get real path for current file
$filePath = $file->getRealPath();
$temp = explode("/", $name);
array_shift( $temp );
$newName = implode("/", $temp);
// Add current file to archive
$zip->addFile($filePath, $newName);
}
}
}
foreach( $_POST['pages'] as $page=>$content ) {
$content = preg_replace("/GetLeads - Landing Page with Page Builder/", $_POST['title'], $content);
$content = preg_replace("/glDescription/", $_POST['description'], $content);
$content = preg_replace("/glKeywords/", $_POST['keywords'], $content);
$content = preg_replace("/glAuthor/", $_POST['author'], $content);
$zip->addFromString($page.".html", $_POST['doctype']."\n".stripslashes($content));
//echo $content;
}
//$zip->addFromString("testfilephp.txt" . time(), "#1 This is a test string added as testfilephp.txt.\n");
//$zip->addFromString("testfilephp2.txt" . time(), "#2 This is a test string added as testfilephp2.txt.\n");
$zip->close();
$yourfile = $filename;
$file_name = basename($yourfile);
header("Content-Type: application/zip");
header("Content-Transfer-Encoding: Binary");
header("Content-Disposition: attachment; filename=$file_name");
header("Content-Length: " . filesize($yourfile));
readfile($yourfile);
unlink('my_getleads.zip');
exit;
?>