-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgenerator.php
More file actions
81 lines (72 loc) · 2.51 KB
/
generator.php
File metadata and controls
81 lines (72 loc) · 2.51 KB
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
<?php
function generateZip($id){
$template_name = "To Peaso";
$filepath = "temp/";
$download_filename = "_Template_Generator.zip";
$filename = $id."_temp.zip";
//Opening zip if exists else file will be created
$zip = new ZipArchive();
if (!$zip->open($filepath.$filename)===TRUE) { //If it doesn't exist
if ($zip->open($filepath.$filename, ZipArchive::CREATE)!==TRUE) {
exit("cannot open <$filepath.$filename>\n");
}
$zip->addFromString($template_name."/index.php", generateIndex());
$zip->addFromString($template_name."/header.php", generateHeader());
$zip->addFromString($template_name."/footer.php", generateFooter());
$zip->close();
}
//Client downloading
header("Pragma: public");
header("Expires: 0");
header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
header("Cache-Control: public");
header("Content-Description: File Transfer");
header("Content-type: application/octet-stream");
header("Content-Disposition: attachment; filename=\"".str_replace(' ', '_', $template_name).$download_filename."\"");
header("Content-Transfer-Encoding: binary");
header("Content-Length: ".filesize($filepath.$filename));
ob_end_flush();
clearstatcache();
readfile($filepath.$filename);
exit;
}
function generateIndex(){
$web = "getHeader();
Test
getFooter();";
return $web;
}
function generateHeader(){
$web = "<!DOCTYPE html>
<html <?php language_attributes(); ?>>
<head>
<meta charset= <?php bloginfo( 'charset' ); ?>\">
<title><?php wp_title(); ?></title>
<!-- Definir viewport para dispositivos web móviles -->
<meta name=\"viewport\" content=\"width=device-width, minimum-scale=1\">
<link rel=\"shortcut icon\" href=\"<?php echo get_stylesheet_directory_uri(); ?>/favicon.ico\" />
<link rel=\"stylesheet\" media=\"all\" href=\"<?php bloginfo( 'stylesheet_url' ); ?>\" />
<link rel=\"pingback\" href=\"<?php bloginfo( 'pingback_url' ); ?>\" />
<?php wp_head(); ?>
</head>
<body>
<div class=\"wrapper\">
<header>
<h1><a href=\"<?php echo get_option('home'); ?>\"><?php bloginfo('name'); ?></a></h1>
<hr>
<?php wp_nav_menu( array('menu' => 'Main', 'container' => 'nav' )); ?>
</header>";
return $web;
}
function generateFooter(){
$web = " <footer>
<p>&amp;amp;copy; <?php bloginfo('name'); ?>, <?=date('Y');?>. Testing.</p>
</footer>
</div> <!-- Fin de wrapper -->
<?php wp_footer(); ?>
</body>
</html>
";
return $web;
}
?>