-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.php
executable file
·186 lines (172 loc) · 6.05 KB
/
index.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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
<?php
error_reporting(E_ALL);
ini_set('display_errors', 1);
// Error handling when submitting "Create New Roundup" form
$errmsg = $all = false;
if (!empty($_POST)) {
if (isset($_POST['new_date'])) {
$filename = $_POST['new_template'].'-'.$_POST['new_date'].'.html';
if (file_exists('./cache/'.$filename)) {
$errmsg = 'That one already exists!';
} else {
touch('./cache/'.$filename);
}
} else {
$errmsg = 'We need a date!';
}
} else {
$list = (isset($_GET['list'])) ? $_GET['list'] : false;
$all = ($list == 'all') ? true : false;
}
// Gets a list of all the available newsletter files
$files_listed = array();
if ($handle = opendir('./cache')) {
while (false !== ($file = readdir($handle))) {
if ($file != "." && $file != ".." && strtolower(substr($file, strrpos($file, '.') + 1)) == 'html') {
$files_listed[] = $file;
}
}
closedir($handle);
}
// Sorts the list of files by both newsletter type and date
sort($files_listed, SORT_NATURAL);
$files_listed = array_reverse($files_listed);
$files_list = array();
$files_types = array();
foreach ($files_listed as $file) {
// If the "see all" button was clicked, just add all the files to the display list
if ($all) {
$files_list[] = $file;
// otherwise limit them to 5:
} else {
$fileparts = explode('-', $file);
$nl_type = $fileparts[0];
if (isset($files_types[$nl_type])) {
$files_types[$nl_type]++;
} else {
$files_types[$nl_type] = 1;
}
if ($files_types[$nl_type] <= 5) {
$files_list[] = $file;
}
}
}
?>
<!DOCTYPE html>
<head>
<title>ROUNDUP files</title>
<meta name="robots" content="noindex">
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/foundation/5.5.3/css/foundation.min.css" />
<link rel="stylesheet" type="text/css" href="style.css" />
<style type="text/css">
th { font-size:1.2em; }
</style>
<link rel="shortcut icon" href="//plus.denverpost.com/favicon.ico" type="image/x-icon" />
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
</head>
<body>
<section id="header">
<!-- NAVIGATION BAR -->
<div id="top-bar-margin" class="sticky fixed">
<nav class="top-bar" data-topbar="" role="navigation">
<ul class="title-area">
<li class="name">
<a href="https://denverpost.com"><img src="//extras.denverpost.com/candidate-qa/denver-2015/images/dp-logo-white.png" alt="The Denver Post logo" class="nav-logo"></a>
</li>
</ul>
<section class="top-bar-section">
<ul class="right">
<li class="divider"></li>
<li class="top-top"><a href="convert.php"><strong>WORDPRESS NL CONVERTER</strong></a></li>
<li class="divider"></li>
</ul>
</section>
</nav>
</div> <!-- Closes top-bar-margin -->
</section>
<div id="wrapper">
<div class="headerstyle">
<div class="row">
<div class="large-12 columns">
<h1>Edit or create a newsletter</h1>
<p>Select from the list to edit an existing newsletter, or create a new Roundup right here.</p>
<p>Select a template and input the date to create a new one. Then click the created link to edit.</p>
</div>
</div>
</div>
<div id="admin" class="row">
<form id="newroundup" name="newroundup" method="post">
<div class="large-10 large-centered columns">
<fieldset>
<legend> Create a new Roundup (for other newsletters, use the <a href="./convert.php">Wordpress Converter</a>) </legend>
<div class="row">
<div class="large-4 columns">
<label for="new_date">Date:</label>
<input type="text" name="new_date" placeholder="YYYYMMDD">
</div>
<div class="large-5 columns">
<label for="new_template">Template:</label>
<input type="radio" name="new_template" value="roundup" checked> Mile High Roundup
</div>
<div class="large-3 columns">
<input type="submit" value="CREATE" class="button">
</div>
</div>
</fieldset>
<fieldset>
<legend> <?php echo count($files_list); ?> recent newsletters </legend>
<?php if (!count($files_list)>0) { ?>
<div class="row">
<div class="large-12 columns text-center">
<strong style="color:crimson">No source added!</strong>
</div>
</div>
<?php } else { ?>
<table style="width:100%;">
<thead>
<tr>
<th width="*">Filename</th>
<th width="20%" style="text-align:center;">Initial Setup</th>
<th width="20%" style="text-align:center;">Live Editor</th>
</tr>
</thead>
<tbody>
<?php foreach($files_list as $file) { ?>
<tr>
<td><strong style="font-size:1.2em;"><?php echo $file; ?></strong></td>
<td style="text-align:center;"><a href="edit.php?file=<?php echo $file; ?>"><img style="width:2.25em;" src="./img/icon-setup.png" alt="Edit Settings" /></a></td>
<td style="text-align:center;"><a href="live.php?file=<?php echo $file; ?>"><img style="width:2.25em;" src="./img/icon-edit.png" alt="Live Edit" /></a></td>
</tr>
<?php } ?>
</tbody>
</table>
<?php } ?>
</fieldset>
<?php if ($all) { ?>
<fieldset>
<legend> Too many files? </legend>
<a href="./index.php?list=none" style="width:100%;" class="button">GO BACK TO THE SHOTER LIST OF NEWSLETTERS</a>
</fieldset>
<?php } else { ?>
<fieldset>
<legend> Looking for older files? </legend>
<a href="./index.php?list=all" style="width:100%;" class="button">GET THE COMPLETE LIST OF CACHED NEWSLETTERS</a>
</fieldset>
<?php } ?>
</div>
</form>
</div>
<footer>
<div class="row">
<div class="large-12 medium-12 small-12 columns">
<p style="text-align: right">Copyright © 2017, The Denver Post</p>
</div>
</div>
</footer>
<script src="//extras.denverpost.com/foundation/js/foundation.min.js"></script>
<script>
$(document).foundation();
</script>
</body>
</html>