1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/** |
4
|
|
|
* Display <h1> header and logo |
5
|
|
|
* |
6
|
|
|
*/ |
7
|
|
|
function yourls_html_logo() { |
8
|
1 |
|
yourls_do_action( 'pre_html_logo' ); |
9
|
|
|
?> |
10
|
1 |
|
<header role="banner"> |
11
|
|
|
<h1> |
12
|
|
|
<a href="<?php echo yourls_admin_url( 'index.php' ) ?>" title="YOURLS"><span>YOURLS</span>: <span>Y</span>our <span>O</span>wn <span>URL</span> <span>S</span>hortener<br/> |
|
|
|
|
13
|
|
|
<img src="<?php yourls_site_url(); ?>/images/yourls-logo.svg" id="yourls-logo" alt="YOURLS" title="YOURLS" /></a> |
|
|
|
|
14
|
|
|
</h1> |
15
|
|
|
</header> |
16
|
|
|
<?php |
17
|
1 |
|
yourls_do_action( 'html_logo' ); |
18
|
1 |
|
} |
19
|
|
|
|
20
|
|
|
/** |
21
|
|
|
* Display HTML head and <body> tag |
22
|
|
|
* |
23
|
|
|
* @param string $context Context of the page (stats, index, infos, ...) |
24
|
|
|
* @param string $title HTML title of the page |
25
|
|
|
*/ |
26
|
|
|
function yourls_html_head( $context = 'index', $title = '' ) { |
27
|
|
|
|
28
|
1 |
|
yourls_do_action( 'pre_html_head', $context, $title ); |
29
|
|
|
|
30
|
|
|
// All components to false, except when specified true |
31
|
1 |
|
$share = $insert = $tablesorter = $tabs = $cal = $charts = false; |
32
|
|
|
|
33
|
|
|
// Load components as needed |
34
|
1 |
|
switch ( $context ) { |
35
|
1 |
|
case 'infos': |
36
|
|
|
$share = $tabs = $charts = true; |
37
|
|
|
break; |
|
|
|
|
38
|
|
|
|
39
|
1 |
|
case 'bookmark': |
40
|
|
|
$share = $insert = $tablesorter = true; |
41
|
|
|
break; |
|
|
|
|
42
|
|
|
|
43
|
1 |
|
case 'index': |
44
|
|
|
$insert = $tablesorter = $cal = $share = true; |
45
|
|
|
break; |
|
|
|
|
46
|
|
|
|
47
|
1 |
|
case 'plugins': |
48
|
1 |
|
case 'tools': |
49
|
|
|
$tablesorter = true; |
50
|
|
|
break; |
|
|
|
|
51
|
|
|
|
52
|
1 |
|
case 'install': |
53
|
1 |
|
case 'login': |
54
|
1 |
|
case 'new': |
55
|
1 |
|
case 'upgrade': |
56
|
|
|
break; |
|
|
|
|
57
|
|
|
} |
58
|
|
|
|
59
|
|
|
// Force no cache for all admin pages |
60
|
1 |
|
if( yourls_is_admin() && !headers_sent() ) { |
61
|
|
|
yourls_no_cache_headers(); |
62
|
|
|
yourls_content_type_header( yourls_apply_filter( 'html_head_content-type', 'text/html' ) ); |
63
|
|
|
yourls_do_action( 'admin_headers', $context, $title ); |
64
|
|
|
} |
65
|
|
|
|
66
|
|
|
// Store page context |
67
|
1 |
|
yourls_set_html_context($context); |
68
|
|
|
|
69
|
|
|
// Body class |
70
|
1 |
|
$bodyclass = yourls_apply_filter( 'bodyclass', '' ); |
71
|
1 |
|
$bodyclass .= ( yourls_is_mobile_device() ? 'mobile' : 'desktop' ); |
72
|
|
|
|
73
|
|
|
// Page title |
74
|
1 |
|
$_title = 'YOURLS — Your Own URL Shortener | ' . yourls_link(); |
75
|
1 |
|
$title = $title ? $title . " « " . $_title : $_title; |
|
|
|
|
76
|
1 |
|
$title = yourls_apply_filter( 'html_title', $title, $context ); |
77
|
|
|
|
|
|
|
|
78
|
|
|
?> |
79
|
1 |
|
<!DOCTYPE html> |
80
|
|
|
<html <?php yourls_html_language_attributes(); ?>> |
81
|
|
|
<head> |
82
|
|
|
<title><?php echo $title ?></title> |
|
|
|
|
83
|
|
|
<meta http-equiv="Content-Type" content="<?php echo yourls_apply_filter( 'html_head_meta_content-type', 'text/html; charset=utf-8' ); ?>" /> |
|
|
|
|
84
|
|
|
<meta name="generator" content="YOURLS <?php echo YOURLS_VERSION ?>" /> |
|
|
|
|
85
|
|
|
<meta name="description" content="YOURLS » Your Own URL Shortener' | <?php yourls_site_url(); ?>" /> |
|
|
|
|
86
|
|
|
<?php yourls_do_action('html_head_meta', $context); ?> |
87
|
|
|
<link rel="shortcut icon" href="<?php yourls_get_yourls_favicon_url(); ?>" /> |
88
|
|
|
<script src="<?php yourls_site_url(); ?>/js/jquery-3.5.1.min.js?v=<?php echo YOURLS_VERSION; ?>" type="text/javascript"></script> |
|
|
|
|
89
|
|
|
<script src="<?php yourls_site_url(); ?>/js/common.js?v=<?php echo YOURLS_VERSION; ?>" type="text/javascript"></script> |
|
|
|
|
90
|
|
|
<script src="<?php yourls_site_url(); ?>/js/jquery.notifybar.js?v=<?php echo YOURLS_VERSION; ?>" type="text/javascript"></script> |
|
|
|
|
91
|
|
|
<link rel="stylesheet" href="<?php yourls_site_url(); ?>/css/style.css?v=<?php echo YOURLS_VERSION; ?>" type="text/css" media="screen" /> |
|
|
|
|
92
|
|
|
<?php if ( $tabs ) { ?> |
93
|
|
|
<link rel="stylesheet" href="<?php yourls_site_url(); ?>/css/infos.css?v=<?php echo YOURLS_VERSION; ?>" type="text/css" media="screen" /> |
|
|
|
|
94
|
|
|
<script src="<?php yourls_site_url(); ?>/js/infos.js?v=<?php echo YOURLS_VERSION; ?>" type="text/javascript"></script> |
|
|
|
|
95
|
|
|
<?php } ?> |
96
|
|
|
<?php if ( $tablesorter ) { ?> |
97
|
|
|
<link rel="stylesheet" href="<?php yourls_site_url(); ?>/css/tablesorter.css?v=<?php echo YOURLS_VERSION; ?>" type="text/css" media="screen" /> |
|
|
|
|
98
|
|
|
<script src="<?php yourls_site_url(); ?>/js/jquery-3.tablesorter.min.js?v=<?php echo YOURLS_VERSION; ?>" type="text/javascript"></script> |
|
|
|
|
99
|
|
|
<script src="<?php yourls_site_url(); ?>/js/tablesorte.js?v=<?php echo YOURLS_VERSION; ?>" type="text/javascript"></script> |
|
|
|
|
100
|
|
|
<?php } ?> |
101
|
|
|
<?php if ( $insert ) { ?> |
102
|
|
|
<script src="<?php yourls_site_url(); ?>/js/insert.js?v=<?php echo YOURLS_VERSION; ?>" type="text/javascript"></script> |
|
|
|
|
103
|
|
|
<?php } ?> |
104
|
|
|
<?php if ( $share ) { ?> |
105
|
|
|
<link rel="stylesheet" href="<?php yourls_site_url(); ?>/css/share.css?v=<?php echo YOURLS_VERSION; ?>" type="text/css" media="screen" /> |
|
|
|
|
106
|
|
|
<script src="<?php yourls_site_url(); ?>/js/share.js?v=<?php echo YOURLS_VERSION; ?>" type="text/javascript"></script> |
|
|
|
|
107
|
|
|
<script src="<?php yourls_site_url(); ?>/js/clipboard.min.js?v=<?php echo YOURLS_VERSION; ?>" type="text/javascript"></script> |
|
|
|
|
108
|
|
|
<?php } ?> |
109
|
|
|
<?php if ( $cal ) { ?> |
110
|
|
|
<link rel="stylesheet" href="<?php yourls_site_url(); ?>/css/cal.css?v=<?php echo YOURLS_VERSION; ?>" type="text/css" media="screen" /> |
|
|
|
|
111
|
|
|
<?php yourls_l10n_calendar_strings(); ?> |
112
|
|
|
<script src="<?php yourls_site_url(); ?>/js/jquery.cal.js?v=<?php echo YOURLS_VERSION; ?>" type="text/javascript"></script> |
|
|
|
|
113
|
|
|
<?php } ?> |
114
|
|
|
<?php if ( $charts ) { ?> |
115
|
|
|
<script type="text/javascript" src="https://www.google.com/jsapi"></script> |
116
|
|
|
<script type="text/javascript"> |
117
|
|
|
google.load('visualization', '1.0', {'packages':['corechart', 'geochart']}); |
118
|
|
|
</script> |
119
|
|
|
<?php } ?> |
120
|
1 |
|
<script type="text/javascript"> |
121
|
|
|
//<![CDATA[ |
122
|
|
|
var ajaxurl = '<?php echo yourls_admin_url( 'admin-ajax.php' ); ?>'; |
123
|
|
|
//]]> |
124
|
|
|
</script> |
125
|
|
|
<?php yourls_do_action( 'html_head', $context ); ?> |
126
|
1 |
|
</head> |
127
|
|
|
<body class="<?php echo $context; ?> <?php echo $bodyclass; ?>"> |
128
|
|
|
<div id="wrap"> |
129
|
|
|
<?php |
130
|
1 |
|
} |
131
|
|
|
|
132
|
|
|
/** |
133
|
|
|
* Display HTML footer (including closing body & html tags) |
134
|
|
|
* |
135
|
|
|
* Function yourls_die() will call this function with the optional param set to false: most likely, if we're using yourls_die(), |
|
|
|
|
136
|
|
|
* there's a problem, so don't maybe add to it by sending another SQL query |
137
|
|
|
* |
138
|
|
|
* @param bool $can_query If set to false, will not try to send another query to DB server |
139
|
|
|
* @return void |
140
|
|
|
*/ |
141
|
|
|
function yourls_html_footer($can_query = true) { |
142
|
1 |
|
if($can_query & yourls_get_debug_mode()) { |
|
|
|
|
143
|
1 |
|
$num_queries = yourls_get_num_queries(); |
144
|
1 |
|
$num_queries = ' – '. sprintf( yourls_n( '1 query', '%s queries', $num_queries ), $num_queries ); |
|
|
|
|
145
|
|
|
} else { |
146
|
|
|
$num_queries = ''; |
147
|
|
|
} |
148
|
|
|
|
149
|
|
|
?> |
150
|
|
|
</div><?php // wrap ?> |
151
|
1 |
|
<footer id="footer" role="contentinfo"><p> |
152
|
|
|
<?php |
153
|
1 |
|
$footer = yourls_s( 'Powered by %s', '<a href="http://yourls.org/" title="YOURLS">YOURLS</a> v ' . YOURLS_VERSION ); |
|
|
|
|
154
|
1 |
|
$footer .= $num_queries; |
155
|
1 |
|
echo yourls_apply_filter( 'html_footer_text', $footer ); |
156
|
|
|
?> |
157
|
1 |
|
</p></footer> |
158
|
|
|
<?php if( yourls_get_debug_mode() ) { |
|
|
|
|
159
|
1 |
|
echo '<div style="text-align:left"><pre>'; |
160
|
1 |
|
echo join( "\n", yourls_get_debug_log() ); |
161
|
1 |
|
echo '</pre></div>'; |
162
|
|
|
} ?> |
|
|
|
|
163
|
|
|
<?php yourls_do_action( 'html_footer', yourls_get_html_context() ); ?> |
164
|
1 |
|
</body> |
165
|
|
|
</html> |
166
|
|
|
<?php |
167
|
1 |
|
} |
168
|
|
|
|
169
|
|
|
/** |
170
|
|
|
* Display "Add new URL" box |
171
|
|
|
* |
172
|
|
|
* @param string $url URL to prefill the input with |
173
|
|
|
* @param string $keyword Keyword to prefill the input with |
174
|
|
|
*/ |
175
|
|
|
function yourls_html_addnew( $url = '', $keyword = '' ) { |
176
|
|
|
$pre = yourls_apply_filter( 'shunt_html_addnew', false, $url, $keyword ); |
177
|
|
|
if ( false !== $pre ) { |
178
|
|
|
return $pre; |
179
|
|
|
} |
180
|
|
|
?> |
181
|
|
|
<main role="main"> |
182
|
|
|
<div id="new_url"> |
183
|
|
|
<div> |
184
|
|
|
<form id="new_url_form" action="" method="get"> |
185
|
|
|
<div> |
186
|
|
|
<label for="add-url"><strong><?php yourls_e( 'Enter the URL' ); ?></strong></label>: |
|
|
|
|
187
|
|
|
<input type="text" id="add-url" name="url" value="<?php echo $url; ?>" class="text" size="80" placeholder="https://" /> |
|
|
|
|
188
|
|
|
<label for="add-keyword"><?php yourls_e( 'Optional '); ?> : <strong><?php yourls_e('Custom short URL'); ?></strong></label>: |
|
|
|
|
189
|
|
|
<input type="text" id="add-keyword" name="keyword" value="<?php echo $keyword; ?>" class="text" size="8" /> |
|
|
|
|
190
|
|
|
<?php yourls_nonce_field( 'add_url', 'nonce-add' ); ?> |
191
|
|
|
<input type="button" id="add-button" name="add-button" value="<?php yourls_e( 'Shorten The URL' ); ?>" class="button" onclick="add_link();" /> |
|
|
|
|
192
|
|
|
</div> |
193
|
|
|
</form> |
194
|
|
|
<div id="feedback" style="display:none"></div> |
195
|
|
|
</div> |
196
|
|
|
<?php yourls_do_action( 'html_addnew' ); ?> |
197
|
|
|
</div> |
198
|
|
|
<?php |
199
|
|
|
} |
200
|
|
|
|
201
|
|
|
/** |
202
|
|
|
* Display main table's footer |
203
|
|
|
* |
204
|
|
|
* The $param array is defined in /admin/index.php, check the yourls_html_tfooter() call |
205
|
|
|
* |
206
|
|
|
* @param array $params Array of all required parameters |
207
|
|
|
* @return string Result |
208
|
|
|
*/ |
209
|
|
|
function yourls_html_tfooter( $params = array() ) { |
210
|
|
|
// Manually extract all parameters from the array. We prefer doing it this way, over using extract(), |
|
|
|
|
211
|
|
|
// to make things clearer and more explicit about what var is used. |
212
|
|
|
$search = $params['search']; |
213
|
|
|
$search_text = $params['search_text']; |
214
|
|
|
$search_in = $params['search_in']; |
215
|
|
|
$sort_by = $params['sort_by']; |
216
|
|
|
$sort_order = $params['sort_order']; |
217
|
|
|
$page = $params['page']; |
218
|
|
|
$perpage = $params['perpage']; |
219
|
|
|
$click_filter = $params['click_filter']; |
220
|
|
|
$click_limit = $params['click_limit']; |
221
|
|
|
$total_pages = $params['total_pages']; |
222
|
|
|
$date_filter = $params['date_filter']; |
223
|
|
|
$date_first = $params['date_first']; |
224
|
|
|
$date_second = $params['date_second']; |
225
|
|
|
|
|
|
|
|
226
|
|
|
?> |
227
|
|
|
<tfoot> |
228
|
|
|
<tr> |
229
|
|
|
<th colspan="6"> |
230
|
|
|
<div id="filter_form"> |
231
|
|
|
<form action="" method="get"> |
232
|
|
|
<div id="filter_options"> |
233
|
|
|
<?php |
234
|
|
|
|
|
|
|
|
235
|
|
|
// First search control: text to search |
236
|
|
|
$_input = '<input aria-label="' .yourls__( 'Search for' ). '" type="text" name="search" class="text" size="12" value="' . yourls_esc_attr( $search_text ) . '" />'; |
|
|
|
|
237
|
|
|
$_options = array( |
238
|
|
|
'all' => yourls__( 'All fields' ), |
239
|
|
|
'keyword' => yourls__( 'Short URL' ), |
240
|
|
|
'url' => yourls__( 'URL' ), |
241
|
|
|
'title' => yourls__( 'Title' ), |
242
|
|
|
'ip' => yourls__( 'IP' ), |
243
|
|
|
); |
|
|
|
|
244
|
|
|
$_select = yourls_html_select( 'search_in', $_options, $search_in, false, yourls__( 'Search in' ) ); |
|
|
|
|
245
|
|
|
/* //translators: "Search for <input field with text to search> in <select dropdown with URL, title...>" */ |
|
|
|
|
246
|
|
|
yourls_se( 'Search for %1$s in %2$s', $_input , $_select ); |
247
|
|
|
echo "–\n"; |
248
|
|
|
|
249
|
|
|
// Second search control: order by |
250
|
|
|
$_options = array( |
251
|
|
|
'keyword' => yourls__( 'Short URL' ), |
|
|
|
|
252
|
|
|
'url' => yourls__( 'URL' ), |
|
|
|
|
253
|
|
|
'title' => yourls__( 'Title' ), |
|
|
|
|
254
|
|
|
'timestamp' => yourls__( 'Date' ), |
|
|
|
|
255
|
|
|
'ip' => yourls__( 'IP' ), |
|
|
|
|
256
|
|
|
'clicks' => yourls__( 'Clicks' ), |
|
|
|
|
257
|
|
|
); |
|
|
|
|
258
|
|
|
$_select = yourls_html_select( 'sort_by', $_options, $sort_by, false, yourls__( 'Sort by' ) ); |
|
|
|
|
259
|
|
|
$sort_order = isset( $sort_order ) ? $sort_order : 'desc' ; |
|
|
|
|
260
|
|
|
$_options = array( |
261
|
|
|
'asc' => yourls__( 'Ascending' ), |
262
|
|
|
'desc' => yourls__( 'Descending' ), |
263
|
|
|
); |
|
|
|
|
264
|
|
|
$_select2 = yourls_html_select( 'sort_order', $_options, $sort_order, false, yourls__( 'Sort order' ) ); |
|
|
|
|
265
|
|
|
/* //translators: "Order by <criteria dropdown (date, clicks...)> in <order dropdown (Descending or Ascending)>" */ |
|
|
|
|
266
|
|
|
yourls_se( 'Order by %1$s %2$s', $_select , $_select2 ); |
267
|
|
|
echo "–\n"; |
268
|
|
|
|
269
|
|
|
// Third search control: Show XX rows |
270
|
|
|
/* //translators: "Show <text field> rows" */ |
|
|
|
|
271
|
|
|
$_input = '<input aria-label="' .yourls__( 'Number of rows to show' ). '" type="text" name="perpage" class="text" size="2" value="' . $perpage . '" />'; |
|
|
|
|
272
|
|
|
yourls_se( 'Show %s rows', $_input ); |
273
|
|
|
echo "<br/>\n"; |
274
|
|
|
|
275
|
|
|
// Fourth search control: Show links with more than XX clicks |
276
|
|
|
$_options = array( |
277
|
|
|
'more' => yourls__( 'more' ), |
278
|
|
|
'less' => yourls__( 'less' ), |
279
|
|
|
); |
|
|
|
|
280
|
|
|
$_select = yourls_html_select( 'click_filter', $_options, $click_filter, false, yourls__( 'Show links with' ) ); |
|
|
|
|
281
|
|
|
$_input = '<input aria-label="' .yourls__( 'Number of clicks' ). '" type="text" name="click_limit" class="text" size="4" value="' . $click_limit . '" /> '; |
|
|
|
|
282
|
|
|
/* //translators: "Show links with <more/less> than <text field> clicks" */ |
|
|
|
|
283
|
|
|
yourls_se( 'Show links with %1$s than %2$s clicks', $_select, $_input ); |
284
|
|
|
echo "<br/>\n"; |
285
|
|
|
|
286
|
|
|
// Fifth search control: Show links created before/after/between ... |
287
|
|
|
$_options = array( |
288
|
|
|
'before' => yourls__('before'), |
289
|
|
|
'after' => yourls__('after'), |
290
|
|
|
'between' => yourls__('between'), |
291
|
|
|
); |
|
|
|
|
292
|
|
|
$_select = yourls_html_select( 'date_filter', $_options, $date_filter, false, yourls__('Show links created') ); |
|
|
|
|
293
|
|
|
$_input = '<input aria-label="' .yourls__('Select a date') . '" type="text" name="date_first" id="date_first" class="text" size="12" value="' . $date_first . '" />'; |
|
|
|
|
294
|
|
|
$_and = '<span id="date_and"' . ( $date_filter === 'between' ? ' style="display:inline"' : '' ) . '> & </span>'; |
|
|
|
|
295
|
|
|
$_input2 = '<input aria-label="' .yourls__('Select an end date') . '" type="text" name="date_second" id="date_second" class="text" size="12" value="' . $date_second . '"' . ( $date_filter === 'between' ? ' style="display:inline"' : '' ) . '/>'; |
|
|
|
|
296
|
|
|
/* //translators: "Show links created <before/after/between> <date input> <"and" if applicable> <date input if applicable>" */ |
|
|
|
|
297
|
|
|
yourls_se( 'Show links created %1$s %2$s %3$s %4$s', $_select, $_input, $_and, $_input2 ); |
298
|
|
|
?> |
299
|
|
|
|
300
|
|
|
<div id="filter_buttons"> |
301
|
|
|
<input type="submit" id="submit-sort" value="<?php yourls_e('Search'); ?>" class="button primary" /> |
|
|
|
|
302
|
|
|
|
303
|
|
|
<input type="button" id="submit-clear-filter" value="<?php yourls_e('Clear'); ?>" class="button" onclick="window.parent.location.href = 'index.php'" /> |
|
|
|
|
304
|
|
|
</div> |
305
|
|
|
|
306
|
|
|
</div> |
307
|
|
|
</form> |
308
|
|
|
</div> |
309
|
|
|
|
310
|
|
|
<?php |
311
|
|
|
// Remove empty keys from the $params array so it doesn't clutter the pagination links |
312
|
|
|
$params = array_filter( $params, 'yourls_return_if_not_empty_string' ); // remove empty keys |
313
|
|
|
|
314
|
|
|
if( isset( $search_text ) ) { |
315
|
|
|
$params['search'] = $search_text; |
316
|
|
|
unset( $params['search_text'] ); |
317
|
|
|
} |
318
|
|
|
?> |
319
|
|
|
|
320
|
|
|
<div id="pagination"> |
321
|
|
|
<span class="navigation"> |
322
|
|
|
<?php if( $total_pages > 1 ) { ?> |
323
|
|
|
<span class="nav_total"><?php echo sprintf( yourls_n( '1 page', '%s pages', $total_pages ), $total_pages ); ?></span> |
|
|
|
|
324
|
|
|
<?php |
325
|
|
|
$base_page = yourls_admin_url( 'index.php' ); |
326
|
|
|
// Pagination offsets: min( max ( zomg! ) ); |
327
|
|
|
$p_start = max( min( $total_pages - 4, $page - 2 ), 1 ); |
328
|
|
|
$p_end = min( max( 5, $page + 2 ), $total_pages ); |
329
|
|
|
if( $p_start >= 2 ) { |
330
|
|
|
$link = yourls_add_query_arg( array_merge( $params, array( 'page' => 1 ) ), $base_page ); |
331
|
|
|
echo '<span class="nav_link nav_first"><a href="' . $link . '" title="' . yourls_esc_attr__('Go to First Page') . '">' . yourls__( '« First' ) . '</a></span>'; |
|
|
|
|
332
|
|
|
echo '<span class="nav_link nav_prev"></span>'; |
333
|
|
|
} |
334
|
|
|
for( $i = $p_start ; $i <= $p_end; $i++ ) { |
|
|
|
|
335
|
|
|
if( $i == $page ) { |
|
|
|
|
336
|
|
|
echo "<span class='nav_link nav_current'>$i</span>"; |
|
|
|
|
337
|
|
|
} else { |
338
|
|
|
$link = yourls_add_query_arg( array_merge( $params, array( 'page' => $i ) ), $base_page ); |
339
|
|
|
echo '<span class="nav_link nav_goto"><a href="' . $link . '" title="' . sprintf( yourls_esc_attr( 'Page %s' ), $i ) .'">'.$i.'</a></span>'; |
|
|
|
|
340
|
|
|
} |
341
|
|
|
} |
342
|
|
|
if( ( $p_end ) < $total_pages ) { |
343
|
|
|
$link = yourls_add_query_arg( array_merge( $params, array( 'page' => $total_pages ) ), $base_page ); |
|
|
|
|
344
|
|
|
echo '<span class="nav_link nav_next"></span>'; |
345
|
|
|
echo '<span class="nav_link nav_last"><a href="' . $link . '" title="' . yourls_esc_attr__('Go to Last Page') . '">' . yourls__( 'Last »' ) . '</a></span>'; |
|
|
|
|
346
|
|
|
} |
347
|
|
|
?> |
348
|
|
|
<?php } ?> |
349
|
|
|
</span> |
350
|
|
|
</div> |
351
|
|
|
</th> |
352
|
|
|
</tr> |
353
|
|
|
<?php yourls_do_action( 'html_tfooter' ); ?> |
354
|
|
|
</tfoot> |
355
|
|
|
<?php |
356
|
|
|
} |
357
|
|
|
|
358
|
|
|
/** |
359
|
|
|
* Return or display a select dropdown field |
360
|
|
|
* |
361
|
|
|
* @since 1.6 |
362
|
|
|
* |
363
|
|
|
* @param string $name HTML 'name' (also use as the HTML 'id') |
364
|
|
|
* @param array $options array of 'value' => 'Text displayed' |
365
|
|
|
* @param string $selected optional 'value' from the $options array that will be highlighted |
366
|
|
|
* @param boolean $display false (default) to return, true to echo |
367
|
|
|
* @param string $label ARIA label of the element |
368
|
|
|
* @return string HTML content of the select element |
369
|
|
|
*/ |
370
|
|
|
function yourls_html_select( $name, $options, $selected = '', $display = false, $label = '' ) { |
371
|
|
|
$html = "<select aria-label='$label' name='$name' id='$name' size='1'>\n"; |
|
|
|
|
372
|
|
|
foreach( $options as $value => $text ) { |
373
|
|
|
$html .= "<option value='$value' "; |
|
|
|
|
374
|
|
|
$html .= $selected == $value ? ' selected="selected"' : ''; |
|
|
|
|
375
|
|
|
$html .= ">$text</option>\n"; |
|
|
|
|
376
|
|
|
} |
377
|
|
|
$html .= "</select>\n"; |
378
|
|
|
$html = yourls_apply_filter( 'html_select', $html, $name, $options, $selected, $display ); |
379
|
|
|
if( $display ) |
380
|
|
|
echo $html; |
381
|
|
|
return $html; |
382
|
|
|
} |
383
|
|
|
|
384
|
|
|
/** |
385
|
|
|
* Display the Quick Share box |
386
|
|
|
* |
387
|
|
|
*/ |
388
|
|
|
function yourls_share_box( $longurl, $shorturl, $title = '', $text='', $shortlink_title = '', $share_title = '', $hidden = false ) { |
|
|
|
|
389
|
|
|
if ( $shortlink_title == '' ) |
|
|
|
|
390
|
|
|
$shortlink_title = '<h2>' . yourls__( 'Your short link' ) . '</h2>'; |
391
|
|
|
if ( $share_title == '' ) |
|
|
|
|
392
|
|
|
$share_title = '<h2>' . yourls__( 'Quick Share' ) . '</h2>'; |
393
|
|
|
|
394
|
|
|
// Allow plugins to short-circuit the whole function |
395
|
|
|
$pre = yourls_apply_filter( 'shunt_share_box', false ); |
396
|
|
|
if ( false !== $pre ) |
397
|
|
|
return $pre; |
398
|
|
|
|
399
|
|
|
// Make sure IDN domains are in their UTF8 form |
400
|
|
|
$shorturl = yourls_normalize_uri($shorturl); |
401
|
|
|
|
402
|
|
|
$text = ( $text ? '"'.$text.'" ' : '' ); |
403
|
|
|
$title = ( $title ? "$title " : '' ); |
|
|
|
|
404
|
|
|
$share = yourls_esc_textarea( $title.$text.$shorturl ); |
405
|
|
|
$count = 280 - strlen( $share ); |
406
|
|
|
$hidden = ( $hidden ? 'style="display:none;"' : '' ); |
407
|
|
|
|
408
|
|
|
// Allow plugins to filter all data |
409
|
|
|
$data = compact( 'longurl', 'shorturl', 'title', 'text', 'shortlink_title', 'share_title', 'share', 'count', 'hidden' ); |
|
|
|
|
410
|
|
|
$data = yourls_apply_filter( 'share_box_data', $data ); |
411
|
|
|
extract( $data ); |
|
|
|
|
412
|
|
|
|
413
|
|
|
$_share = rawurlencode( $share ); |
414
|
|
|
$_url = rawurlencode( $shorturl ); |
415
|
|
|
?> |
416
|
|
|
|
417
|
|
|
<div id="shareboxes" <?php echo $hidden; ?>> |
418
|
|
|
|
419
|
|
|
<?php yourls_do_action( 'shareboxes_before', $longurl, $shorturl, $title, $text ); ?> |
420
|
|
|
|
421
|
|
|
<div id="copybox" class="share"> |
422
|
|
|
<?php echo $shortlink_title; ?> |
423
|
|
|
<p><input id="copylink" class="text" size="32" value="<?php echo yourls_esc_url( $shorturl ); ?>" /></p> |
|
|
|
|
424
|
|
|
<p><small><?php yourls_e( 'Long link' ); ?>: <a id="origlink" href="<?php echo yourls_esc_url( $longurl ); ?>"><?php echo yourls_esc_url( $longurl ); ?></a></small> |
|
|
|
|
425
|
|
|
<?php if( yourls_do_log_redirect() ) { ?> |
426
|
|
|
<br/><small><?php yourls_e( 'Stats' ); ?>: <a id="statlink" href="<?php echo yourls_esc_url( $shorturl ); ?>+"><?php echo yourls_esc_url( $shorturl ); ?>+</a></small> |
|
|
|
|
427
|
|
|
<input type="hidden" id="titlelink" value="<?php echo yourls_esc_attr( $title ); ?>" /> |
428
|
|
|
<?php } ?> |
429
|
|
|
</p> |
430
|
|
|
</div> |
431
|
|
|
|
432
|
|
|
<?php yourls_do_action( 'shareboxes_middle', $longurl, $shorturl, $title, $text ); ?> |
433
|
|
|
|
434
|
|
|
<div id="sharebox" class="share"> |
435
|
|
|
<?php echo $share_title; ?> |
436
|
|
|
<div id="tweet"> |
437
|
|
|
<span id="charcount" class="hide-if-no-js"><?php echo $count; ?></span> |
438
|
|
|
<textarea id="tweet_body"><?php echo $share; ?></textarea> |
439
|
|
|
</div> |
440
|
|
|
<p id="share_links"><?php yourls_e( 'Share with' ); ?> |
441
|
|
|
<a id="share_tw" href="https://twitter.com/intent/tweet?text=<?php echo $_share; ?>" title="<?php yourls_e( 'Tweet this!' ); ?>" onclick="share('tw');return false">Twitter</a> |
|
|
|
|
442
|
|
|
<a id="share_fb" href="https://www.facebook.com/share.php?u=<?php echo $_url; ?>" title="<?php yourls_e( 'Share on Facebook' ); ?>" onclick="share('fb');return false;">Facebook</a> |
|
|
|
|
443
|
|
|
<?php |
444
|
|
|
yourls_do_action( 'share_links', $longurl, $shorturl, $title, $text ); |
445
|
|
|
// Note: on the main admin page, there are no parameters passed to the sharebox when it's drawn. |
446
|
|
|
?> |
447
|
|
|
</p> |
448
|
|
|
</div> |
449
|
|
|
|
450
|
|
|
<?php yourls_do_action( 'shareboxes_after', $longurl, $shorturl, $title, $text ); ?> |
451
|
|
|
|
452
|
|
|
</div> |
453
|
|
|
|
454
|
|
|
<?php |
455
|
|
|
} |
456
|
|
|
|
457
|
|
|
/** |
458
|
|
|
* Die die die |
459
|
|
|
* |
460
|
|
|
*/ |
461
|
|
|
function yourls_die( $message = '', $title = '', $header_code = 200 ) { |
462
|
3 |
|
yourls_do_action( 'pre_yourls_die', $message, $title, $header_code ); |
463
|
|
|
|
464
|
|
|
yourls_status_header( $header_code ); |
465
|
|
|
|
466
|
|
|
if( !yourls_did_action( 'html_head' ) ) { |
467
|
|
|
yourls_html_head(); |
468
|
|
|
yourls_html_logo(); |
469
|
|
|
} |
470
|
|
|
echo yourls_apply_filter( 'die_title', "<h2>$title</h2>" ); |
|
|
|
|
471
|
|
|
echo yourls_apply_filter( 'die_message', "<p>$message</p>" ); |
|
|
|
|
472
|
|
|
// Hook into 'yourls_die' to add more elements or messages to that page |
473
|
|
|
yourls_do_action( 'yourls_die' ); |
474
|
|
|
if( !yourls_did_action( 'html_footer' ) ) { |
475
|
|
|
yourls_html_footer(false); |
476
|
|
|
} |
477
|
|
|
die(); |
478
|
|
|
} |
479
|
|
|
|
480
|
|
|
/** |
481
|
|
|
* Return an "Edit" row for the main table |
482
|
|
|
* |
483
|
|
|
* @param string $keyword Keyword to edit |
484
|
|
|
* @return string HTML of the edit row |
485
|
|
|
*/ |
486
|
|
|
function yourls_table_edit_row( $keyword ) { |
487
|
|
|
$keyword = yourls_sanitize_keyword($keyword); |
488
|
|
|
$id = yourls_string2htmlid( $keyword ); // used as HTML #id |
489
|
|
|
$url = yourls_get_keyword_longurl( $keyword ); |
490
|
|
|
$title = htmlspecialchars( yourls_get_keyword_title( $keyword ) ); |
491
|
|
|
$safe_url = yourls_esc_attr( $url ); |
492
|
|
|
$safe_title = yourls_esc_attr( $title ); |
493
|
|
|
$safe_keyword = yourls_esc_attr( $keyword ); |
494
|
|
|
|
495
|
|
|
// Make strings sprintf() safe: '%' -> '%%' |
496
|
|
|
$safe_url = str_replace( '%', '%%', $safe_url ); |
497
|
|
|
$safe_title = str_replace( '%', '%%', $safe_title ); |
498
|
|
|
|
499
|
|
|
$www = yourls_link(); |
500
|
|
|
|
501
|
|
|
$nonce = yourls_create_nonce( 'edit-save_'.$id ); |
502
|
|
|
|
503
|
|
|
if( $url ) { |
504
|
|
|
$return = <<<RETURN |
505
|
|
|
<tr id="edit-$id" class="edit-row"><td colspan="5" class="edit-row"><strong>%s</strong>:<input type="text" id="edit-url-$id" name="edit-url-$id" value="$safe_url" class="text" size="70" /><br/><strong>%s</strong>: $www<input type="text" id="edit-keyword-$id" name="edit-keyword-$id" value="$safe_keyword" class="text" size="10" /><br/><strong>%s</strong>: <input type="text" id="edit-title-$id" name="edit-title-$id" value="$safe_title" class="text" size="60" /></td><td colspan="1"><input type="button" id="edit-submit-$id" name="edit-submit-$id" value="%s" title="%s" class="button" onclick="edit_link_save('$id');" /> <input type="button" id="edit-close-$id" name="edit-close-$id" value="%s" title="%s" class="button" onclick="edit_link_hide('$id');" /><input type="hidden" id="old_keyword_$id" value="$safe_keyword"/><input type="hidden" id="nonce_$id" value="$nonce"/></td></tr> |
|
|
|
|
506
|
|
|
RETURN; |
507
|
|
|
$return = sprintf( $return, yourls__( 'Long URL' ), yourls__( 'Short URL' ), yourls__( 'Title' ), yourls__( 'Save' ), yourls__( 'Save new values' ), yourls__( 'Cancel' ), yourls__( 'Cancel editing' ) ); |
|
|
|
|
508
|
|
|
} else { |
509
|
|
|
$return = '<tr class="edit-row notfound"><td colspan="6" class="edit-row notfound">' . yourls__( 'Error, URL not found' ) . '</td></tr>'; |
|
|
|
|
510
|
|
|
} |
511
|
|
|
|
512
|
|
|
$return = yourls_apply_filter( 'table_edit_row', $return, $keyword, $url, $title ); |
513
|
|
|
|
514
|
|
|
return $return; |
515
|
|
|
} |
516
|
|
|
|
517
|
|
|
/** |
518
|
|
|
* Return an "Add" row for the main table |
519
|
|
|
* |
520
|
|
|
* @return string HTML of the edit row |
521
|
|
|
*/ |
522
|
|
|
function yourls_table_add_row( $keyword, $url, $title = '', $ip, $clicks, $timestamp ) { |
523
|
1 |
|
$keyword = yourls_sanitize_keyword($keyword); |
524
|
1 |
|
$id = yourls_string2htmlid( $keyword ); // used as HTML #id |
525
|
1 |
|
$shorturl = yourls_link( $keyword ); |
526
|
|
|
|
527
|
1 |
|
$statlink = yourls_statlink( $keyword ); |
528
|
|
|
|
529
|
1 |
|
$delete_link = yourls_nonce_url( 'delete-link_'.$id, |
530
|
1 |
|
yourls_add_query_arg( array( 'id' => $id, 'action' => 'delete', 'keyword' => $keyword ), yourls_admin_url( 'admin-ajax.php' ) ) |
|
|
|
|
531
|
|
|
); |
532
|
|
|
|
533
|
1 |
|
$edit_link = yourls_nonce_url( 'edit-link_'.$id, |
534
|
1 |
|
yourls_add_query_arg( array( 'id' => $id, 'action' => 'edit', 'keyword' => $keyword ), yourls_admin_url( 'admin-ajax.php' ) ) |
|
|
|
|
535
|
|
|
); |
536
|
|
|
|
537
|
|
|
// Action link buttons: the array |
538
|
|
|
$actions = array( |
539
|
|
|
'stats' => array( |
|
|
|
|
540
|
1 |
|
'href' => $statlink, |
|
|
|
|
541
|
1 |
|
'id' => "statlink-$id", |
|
|
|
|
542
|
1 |
|
'title' => yourls_esc_attr__( 'Stats' ), |
|
|
|
|
543
|
1 |
|
'anchor' => yourls__( 'Stats' ), |
|
|
|
|
544
|
|
|
), |
|
|
|
|
545
|
|
|
'share' => array( |
|
|
|
|
546
|
1 |
|
'href' => '', |
547
|
1 |
|
'id' => "share-button-$id", |
|
|
|
|
548
|
1 |
|
'title' => yourls_esc_attr__( 'Share' ), |
549
|
1 |
|
'anchor' => yourls__( 'Share' ), |
550
|
1 |
|
'onclick' => "toggle_share('$id');return false;", |
|
|
|
|
551
|
|
|
), |
|
|
|
|
552
|
|
|
'edit' => array( |
|
|
|
|
553
|
1 |
|
'href' => $edit_link, |
554
|
1 |
|
'id' => "edit-button-$id", |
|
|
|
|
555
|
1 |
|
'title' => yourls_esc_attr__( 'Edit' ), |
556
|
1 |
|
'anchor' => yourls__( 'Edit' ), |
557
|
1 |
|
'onclick' => "edit_link_display('$id');return false;", |
|
|
|
|
558
|
|
|
), |
|
|
|
|
559
|
|
|
'delete' => array( |
|
|
|
|
560
|
1 |
|
'href' => $delete_link, |
561
|
1 |
|
'id' => "delete-button-$id", |
|
|
|
|
562
|
1 |
|
'title' => yourls_esc_attr__( 'Delete' ), |
563
|
1 |
|
'anchor' => yourls__( 'Delete' ), |
564
|
1 |
|
'onclick' => "remove_link('$id');return false;", |
|
|
|
|
565
|
|
|
) |
|
|
|
|
566
|
|
|
); |
|
|
|
|
567
|
1 |
|
$actions = yourls_apply_filter( 'table_add_row_action_array', $actions, $keyword ); |
568
|
|
|
|
569
|
|
|
// Action link buttons: the HTML |
570
|
1 |
|
$action_links = ''; |
571
|
1 |
|
foreach( $actions as $key => $action ) { |
572
|
1 |
|
$onclick = isset( $action['onclick'] ) ? 'onclick="' . $action['onclick'] . '"' : '' ; |
|
|
|
|
573
|
1 |
|
$action_links .= sprintf( '<a href="%s" id="%s" title="%s" class="%s" %s>%s</a>', |
574
|
1 |
|
$action['href'], $action['id'], $action['title'], 'button button_'.$key, $onclick, $action['anchor'] |
|
|
|
|
575
|
|
|
); |
576
|
|
|
} |
577
|
1 |
|
$action_links = yourls_apply_filter( 'action_links', $action_links, $keyword, $url, $ip, $clicks, $timestamp ); |
|
|
|
|
578
|
|
|
|
579
|
1 |
|
if( ! $title ) |
580
|
|
|
$title = $url; |
581
|
|
|
|
582
|
1 |
|
$protocol_warning = ''; |
583
|
1 |
|
if( ! in_array( yourls_get_protocol( $url ) , array( 'http://', 'https://' ) ) ) |
584
|
|
|
$protocol_warning = yourls_apply_filter( 'add_row_protocol_warning', '<span class="warning" title="' . yourls__( 'Not a common link' ) . '">★</span>' ); |
|
|
|
|
585
|
|
|
|
586
|
|
|
// Row cells: the array |
587
|
|
|
$cells = array( |
588
|
|
|
'keyword' => array( |
|
|
|
|
589
|
1 |
|
'template' => '<a href="%shorturl%">%keyword_html%</a>', |
|
|
|
|
590
|
1 |
|
'shorturl' => yourls_esc_url( $shorturl ), |
|
|
|
|
591
|
1 |
|
'keyword_html' => yourls_esc_html( $keyword ), |
|
|
|
|
592
|
|
|
), |
|
|
|
|
593
|
|
|
'url' => array( |
|
|
|
|
594
|
1 |
|
'template' => '<a href="%long_url%" title="%title_attr%">%title_html%</a><br/><small>%warning%<a href="%long_url%">%long_url_html%</a></small>', |
|
|
|
|
595
|
1 |
|
'long_url' => yourls_esc_url( $url ), |
596
|
1 |
|
'title_attr' => yourls_esc_attr( $title ), |
597
|
1 |
|
'title_html' => yourls_esc_html( yourls_trim_long_string( $title ) ), |
598
|
1 |
|
'long_url_html' => yourls_esc_html( yourls_trim_long_string( urldecode( $url ) ) ), |
599
|
1 |
|
'warning' => $protocol_warning, |
600
|
|
|
), |
|
|
|
|
601
|
|
|
'timestamp' => array( |
602
|
1 |
|
'template' => '<span class="timestamp" aria-hidden="true">%timestamp%</span> %date%', |
|
|
|
|
603
|
1 |
|
'timestamp' => $timestamp, |
604
|
1 |
|
'date' => yourls_date_i18n( yourls_get_datetime_format('M d, Y H:i'), yourls_get_timestamp( $timestamp )), |
|
|
|
|
605
|
|
|
), |
|
|
|
|
606
|
|
|
'ip' => array( |
|
|
|
|
607
|
1 |
|
'template' => '%ip%', |
608
|
1 |
|
'ip' => $ip, |
609
|
|
|
), |
|
|
|
|
610
|
|
|
'clicks' => array( |
|
|
|
|
611
|
1 |
|
'template' => '%clicks%', |
612
|
1 |
|
'clicks' => yourls_number_format_i18n( $clicks, 0, '', '' ), |
613
|
|
|
), |
|
|
|
|
614
|
|
|
'actions' => array( |
|
|
|
|
615
|
1 |
|
'template' => '%actions% <input type="hidden" id="keyword_%id%" value="%keyword%"/>', |
616
|
1 |
|
'actions' => $action_links, |
617
|
1 |
|
'id' => $id, |
618
|
1 |
|
'keyword' => $keyword, |
619
|
|
|
), |
|
|
|
|
620
|
|
|
); |
|
|
|
|
621
|
1 |
|
$cells = yourls_apply_filter( 'table_add_row_cell_array', $cells, $keyword, $url, $title, $ip, $clicks, $timestamp ); |
|
|
|
|
622
|
|
|
|
623
|
|
|
// Row cells: the HTML. Replace every %stuff% in 'template' with 'stuff' value. |
624
|
1 |
|
$row = "<tr id=\"id-$id\">"; |
|
|
|
|
625
|
1 |
|
foreach( $cells as $cell_id => $elements ) { |
626
|
1 |
|
$row .= sprintf( '<td class="%s" id="%s">', $cell_id, $cell_id . '-' . $id ); |
627
|
|
|
$row .= preg_replace_callback( '/%([^%]+)?%/', function( $match ) use ( $elements ) { return $elements[ $match[1] ]; }, $elements['template'] ); |
|
|
|
|
628
|
1 |
|
$row .= '</td>'; |
629
|
|
|
} |
630
|
1 |
|
$row .= "</tr>"; |
|
|
|
|
631
|
1 |
|
$row = yourls_apply_filter( 'table_add_row', $row, $keyword, $url, $title, $ip, $clicks, $timestamp ); |
|
|
|
|
632
|
|
|
|
633
|
1 |
|
return $row; |
634
|
|
|
} |
635
|
|
|
|
636
|
|
|
/** |
637
|
|
|
* Echo the main table head |
638
|
|
|
* |
639
|
|
|
*/ |
640
|
|
|
function yourls_table_head() { |
641
|
|
|
$start = '<table id="main_table" class="tblSorter" cellpadding="0" cellspacing="1"><thead><tr>'."\n"; |
|
|
|
|
642
|
|
|
echo yourls_apply_filter( 'table_head_start', $start ); |
643
|
|
|
|
644
|
|
|
$cells = yourls_apply_filter( 'table_head_cells', array( |
645
|
|
|
'shorturl' => yourls__( 'Short URL' ), |
646
|
|
|
'longurl' => yourls__( 'Original URL' ), |
647
|
|
|
'date' => yourls__( 'Date' ), |
648
|
|
|
'ip' => yourls__( 'IP' ), |
649
|
|
|
'clicks' => yourls__( 'Clicks' ), |
650
|
|
|
'actions' => yourls__( 'Actions' ) |
|
|
|
|
651
|
|
|
) ); |
|
|
|
|
652
|
|
|
foreach( $cells as $k => $v ) { |
653
|
|
|
echo "<th id='main_table_head_$k'>$v</th>\n"; |
|
|
|
|
654
|
|
|
} |
655
|
|
|
|
656
|
|
|
$end = "</tr></thead>\n"; |
657
|
|
|
echo yourls_apply_filter( 'table_head_end', $end ); |
658
|
|
|
} |
659
|
|
|
|
660
|
|
|
/** |
661
|
|
|
* Echo the tbody start tag |
662
|
|
|
* |
663
|
|
|
*/ |
664
|
|
|
function yourls_table_tbody_start() { |
665
|
|
|
echo yourls_apply_filter( 'table_tbody_start', '<tbody>' ); |
666
|
|
|
} |
667
|
|
|
|
668
|
|
|
/** |
669
|
|
|
* Echo the tbody end tag |
670
|
|
|
* |
671
|
|
|
*/ |
672
|
|
|
function yourls_table_tbody_end() { |
673
|
|
|
echo yourls_apply_filter( 'table_tbody_end', '</tbody>' ); |
674
|
|
|
} |
675
|
|
|
|
676
|
|
|
/** |
677
|
|
|
* Echo the table start tag |
678
|
|
|
* |
679
|
|
|
*/ |
680
|
|
|
function yourls_table_end() { |
681
|
|
|
echo yourls_apply_filter( 'table_end', '</table></main>' ); |
682
|
|
|
} |
683
|
|
|
|
684
|
|
|
/** |
685
|
|
|
* Echo HTML tag for a link |
686
|
|
|
* |
687
|
|
|
*/ |
688
|
|
|
function yourls_html_link( $href, $title = '', $element = '' ) { |
689
|
|
|
if( !$title ) |
690
|
|
|
$title = $href; |
691
|
|
|
if( $element ) |
692
|
|
|
$element = sprintf( 'id="%s"', yourls_esc_attr( $element ) ); |
693
|
|
|
$link = sprintf( '<a href="%s" %s>%s</a>', yourls_esc_url( $href ), $element, yourls_esc_html( $title ) ); |
|
|
|
|
694
|
|
|
echo yourls_apply_filter( 'html_link', $link ); |
695
|
|
|
} |
696
|
|
|
|
697
|
|
|
/** |
698
|
|
|
* Display the login screen. Nothing past this point. |
699
|
|
|
* |
700
|
|
|
*/ |
701
|
|
|
function yourls_login_screen( $error_msg = '' ) { |
702
|
|
|
yourls_html_head( 'login' ); |
703
|
|
|
|
704
|
|
|
$action = ( isset( $_GET['action'] ) && $_GET['action'] == 'logout' ? '?' : '' ); |
|
|
|
|
705
|
|
|
|
706
|
|
|
yourls_html_logo(); |
707
|
|
|
?> |
708
|
|
|
<div id="login"> |
709
|
|
|
<form method="post" action="<?php echo $action; ?>"> <?php // reset any QUERY parameters ?> |
710
|
|
|
<?php |
711
|
|
|
if( !empty( $error_msg ) ) { |
|
|
|
|
712
|
|
|
echo '<p class="error">'.$error_msg.'</p>'; |
713
|
|
|
} |
714
|
|
|
yourls_do_action( 'login_form_top' ); |
715
|
|
|
?> |
716
|
|
|
<p> |
717
|
|
|
<label for="username"><?php yourls_e( 'Username' ); ?></label><br /> |
718
|
|
|
<input type="text" id="username" name="username" size="30" class="text" /> |
719
|
|
|
</p> |
720
|
|
|
<p> |
721
|
|
|
<label for="password"><?php yourls_e( 'Password' ); ?></label><br /> |
722
|
|
|
<input type="password" id="password" name="password" size="30" class="text" /> |
723
|
|
|
</p> |
724
|
|
|
<?php |
725
|
|
|
yourls_do_action( 'login_form_bottom' ); |
|
|
|
|
726
|
|
|
?> |
727
|
|
|
<p style="text-align: right;"> |
728
|
|
|
<input type="submit" id="submit" name="submit" value="<?php yourls_e( 'Login' ); ?>" class="button" /> |
|
|
|
|
729
|
|
|
</p> |
730
|
|
|
<?php |
731
|
|
|
yourls_do_action( 'login_form_end' ); |
|
|
|
|
732
|
|
|
?> |
733
|
|
|
</form> |
734
|
|
|
<script type="text/javascript">$('#username').focus();</script> |
735
|
|
|
</div> |
736
|
|
|
<?php |
737
|
|
|
yourls_html_footer(); |
738
|
|
|
die(); |
739
|
|
|
} |
740
|
|
|
|
741
|
|
|
/** |
742
|
|
|
* Display the admin menu |
743
|
|
|
* |
744
|
|
|
*/ |
745
|
|
|
function yourls_html_menu() { |
746
|
|
|
|
747
|
|
|
// Build menu links |
748
|
1 |
|
if( defined( 'YOURLS_USER' ) ) { |
749
|
1 |
|
$logout_link = yourls_apply_filter( 'logout_link', sprintf( yourls__('Hello <strong>%s</strong>'), YOURLS_USER ) . ' (<a href="' . yourls_admin_url( 'index.php' ) . '?action=logout" title="' . yourls_esc_attr__( 'Logout' ) . '">' . yourls__( 'Logout' ) . '</a>)' ); |
|
|
|
|
750
|
|
|
} else { |
751
|
|
|
$logout_link = yourls_apply_filter( 'logout_link', '' ); |
752
|
|
|
} |
753
|
1 |
|
$help_link = yourls_apply_filter( 'help_link', '<a href="' . yourls_site_url( false ) .'/readme.html">' . yourls__( 'Help' ) . '</a>' ); |
|
|
|
|
754
|
|
|
|
755
|
1 |
|
$admin_links = array(); |
756
|
1 |
|
$admin_sublinks = array(); |
757
|
|
|
|
758
|
1 |
|
$admin_links['admin'] = array( |
759
|
1 |
|
'url' => yourls_admin_url( 'index.php' ), |
760
|
1 |
|
'title' => yourls__( 'Go to the admin interface' ), |
761
|
1 |
|
'anchor' => yourls__( 'Admin interface' ) |
|
|
|
|
762
|
|
|
); |
|
|
|
|
763
|
|
|
|
764
|
1 |
|
if( yourls_is_admin() ) { |
765
|
|
|
$admin_links['tools'] = array( |
766
|
|
|
'url' => yourls_admin_url( 'tools.php' ), |
767
|
|
|
'anchor' => yourls__( 'Tools' ) |
|
|
|
|
768
|
|
|
); |
|
|
|
|
769
|
|
|
$admin_links['plugins'] = array( |
770
|
|
|
'url' => yourls_admin_url( 'plugins.php' ), |
771
|
|
|
'anchor' => yourls__( 'Manage Plugins' ) |
|
|
|
|
772
|
|
|
); |
|
|
|
|
773
|
|
|
$admin_sublinks['plugins'] = yourls_list_plugin_admin_pages(); |
774
|
|
|
} |
775
|
|
|
|
776
|
1 |
|
$admin_links = yourls_apply_filter( 'admin_links', $admin_links ); |
777
|
1 |
|
$admin_sublinks = yourls_apply_filter( 'admin_sublinks', $admin_sublinks ); |
778
|
|
|
|
779
|
|
|
// Now output menu |
780
|
1 |
|
echo '<nav role="navigation"><ul id="admin_menu">'."\n"; |
781
|
1 |
|
if ( yourls_is_private() && !empty( $logout_link ) ) |
782
|
1 |
|
echo '<li id="admin_menu_logout_link">' . $logout_link .'</li>'; |
783
|
|
|
|
784
|
1 |
|
foreach( (array)$admin_links as $link => $ar ) { |
785
|
1 |
|
if( isset( $ar['url'] ) ) { |
786
|
1 |
|
$anchor = isset( $ar['anchor'] ) ? $ar['anchor'] : $link; |
787
|
1 |
|
$title = isset( $ar['title'] ) ? 'title="' . $ar['title'] . '"' : ''; |
788
|
1 |
|
printf( '<li id="admin_menu_%s_link" class="admin_menu_toplevel"><a href="%s" %s>%s</a>', $link, $ar['url'], $title, $anchor ); |
|
|
|
|
789
|
|
|
} |
790
|
|
|
// Output submenu if any. TODO: clean up, too many code duplicated here |
791
|
1 |
|
if( isset( $admin_sublinks[$link] ) ) { |
792
|
|
|
echo "<ul>\n"; |
793
|
|
|
foreach( $admin_sublinks[$link] as $link => $ar ) { |
|
|
|
|
794
|
|
|
if( isset( $ar['url'] ) ) { |
795
|
|
|
$anchor = isset( $ar['anchor'] ) ? $ar['anchor'] : $link; |
796
|
|
|
$title = isset( $ar['title'] ) ? 'title="' . $ar['title'] . '"' : ''; |
797
|
|
|
printf( '<li id="admin_menu_%s_link" class="admin_menu_sublevel admin_menu_sublevel_%s"><a href="%s" %s>%s</a>', $link, $link, $ar['url'], $title, $anchor ); |
|
|
|
|
798
|
|
|
} |
799
|
|
|
} |
800
|
|
|
echo "</ul>\n"; |
801
|
|
|
} |
802
|
|
|
} |
803
|
|
|
|
804
|
1 |
|
if ( isset( $help_link ) ) |
805
|
1 |
|
echo '<li id="admin_menu_help_link">' . $help_link .'</li>'; |
806
|
|
|
|
807
|
1 |
|
yourls_do_action( 'admin_menu' ); |
808
|
1 |
|
echo "</ul></nav>\n"; |
809
|
1 |
|
yourls_do_action( 'admin_notices' ); |
810
|
1 |
|
yourls_do_action( 'admin_notice' ); // because I never remember if it's 'notices' or 'notice' |
811
|
|
|
/* |
|
|
|
|
812
|
|
|
To display a notice: |
|
|
|
|
813
|
|
|
$message = "<div>OMG, dude, I mean!</div>" ); |
|
|
|
|
814
|
|
|
yourls_add_action( 'admin_notices', function() use ( $message ) { echo (string) $message; } ); |
|
|
|
|
815
|
|
|
*/ |
|
|
|
|
816
|
1 |
|
} |
817
|
|
|
|
818
|
|
|
/** |
819
|
|
|
* Wrapper function to display admin notices |
820
|
|
|
* |
821
|
|
|
*/ |
822
|
|
|
function yourls_add_notice( $message, $style = 'notice' ) { |
823
|
|
|
// Escape single quotes in $message to avoid breaking the anonymous function |
824
|
1 |
|
$message = yourls_notice_box( strtr( $message, array( "'" => "\'" ) ), $style ); |
825
|
|
|
yourls_add_action( 'admin_notices', function() use ( $message ) { echo (string) $message; } ); |
|
|
|
|
826
|
1 |
|
} |
827
|
|
|
|
828
|
|
|
/** |
829
|
|
|
* Return a formatted notice |
830
|
|
|
* |
831
|
|
|
*/ |
832
|
|
|
function yourls_notice_box( $message, $style = 'notice' ) { |
833
|
|
|
return <<<HTML |
834
|
1 |
|
<div class="$style"> |
835
|
1 |
|
<p>$message</p> |
836
|
|
|
</div> |
837
|
|
|
HTML; |
838
|
|
|
} |
839
|
|
|
|
840
|
|
|
/** |
841
|
|
|
* Display a page |
842
|
|
|
* |
843
|
|
|
* Includes content of a PHP file from the YOURLS_PAGEDIR directory, as if it |
844
|
|
|
* were a standard short URL (ie http://sho.rt/$page) |
845
|
|
|
* |
846
|
|
|
* @since 1.0 |
847
|
|
|
* @param $page PHP file to display |
848
|
|
|
*/ |
849
|
|
|
function yourls_page( $page ) { |
850
|
|
|
if( !yourls_is_page($page)) { |
851
|
|
|
yourls_die( yourls_s('Page "%1$s" not found', $page), yourls__('Not found'), 404 ); |
852
|
|
|
} |
853
|
|
|
|
854
|
|
|
yourls_do_action( 'pre_page', $page ); |
855
|
|
|
include_once( YOURLS_PAGEDIR . "/$page.php" ); |
|
|
|
|
856
|
|
|
yourls_do_action( 'post_page', $page ); |
857
|
|
|
} |
858
|
|
|
|
859
|
|
|
/** |
860
|
|
|
* Display the language attributes for the HTML tag. |
861
|
|
|
* |
862
|
|
|
* Builds up a set of html attributes containing the text direction and language |
863
|
|
|
* information for the page. Stolen from WP. |
864
|
|
|
* |
865
|
|
|
* @since 1.6 |
866
|
|
|
*/ |
867
|
|
|
function yourls_html_language_attributes() { |
868
|
1 |
|
$attributes = array(); |
869
|
1 |
|
$output = ''; |
870
|
|
|
|
871
|
1 |
|
$attributes[] = ( yourls_is_rtl() ? 'dir="rtl"' : 'dir="ltr"' ); |
872
|
|
|
|
873
|
1 |
|
$doctype = yourls_apply_filter( 'html_language_attributes_doctype', 'html' ); |
874
|
|
|
// Experimental: get HTML lang from locale. Should work. Convert fr_FR -> fr-FR |
875
|
1 |
|
if ( $lang = str_replace( '_', '-', yourls_get_locale() ) ) { |
|
|
|
|
876
|
1 |
|
if( $doctype == 'xhtml' ) { |
|
|
|
|
877
|
|
|
$attributes[] = "xml:lang=\"$lang\""; |
|
|
|
|
878
|
|
|
} else { |
879
|
1 |
|
$attributes[] = "lang=\"$lang\""; |
|
|
|
|
880
|
|
|
} |
881
|
|
|
} |
882
|
|
|
|
883
|
1 |
|
$output = implode( ' ', $attributes ); |
884
|
1 |
|
$output = yourls_apply_filter( 'html_language_attributes', $output ); |
885
|
1 |
|
echo $output; |
886
|
1 |
|
} |
887
|
|
|
|
888
|
|
|
/** |
889
|
|
|
* Output translated strings used by the Javascript calendar |
890
|
|
|
* |
891
|
|
|
* @since 1.6 |
892
|
|
|
*/ |
893
|
|
|
function yourls_l10n_calendar_strings() { |
894
|
|
|
echo "\n<script>\n"; |
895
|
|
|
echo "var l10n_cal_month = " . json_encode( array_values( yourls_l10n_months() ) ) . ";\n"; |
|
|
|
|
896
|
|
|
echo "var l10n_cal_days = " . json_encode( array_values( yourls_l10n_weekday_initial() ) ) . ";\n"; |
|
|
|
|
897
|
|
|
echo "var l10n_cal_today = \"" . yourls_esc_js( yourls__( 'Today' ) ) . "\";\n"; |
|
|
|
|
898
|
|
|
echo "var l10n_cal_close = \"" . yourls_esc_js( yourls__( 'Close' ) ) . "\";\n"; |
|
|
|
|
899
|
|
|
echo "</script>\n"; |
900
|
|
|
|
901
|
|
|
// Dummy returns, to initialize l10n strings used in the calendar |
902
|
|
|
yourls__( 'Today' ); |
903
|
|
|
yourls__( 'Close' ); |
904
|
|
|
} |
905
|
|
|
|
906
|
|
|
|
907
|
|
|
/** |
908
|
|
|
* Display a notice if there is a newer version of YOURLS available |
909
|
|
|
* |
910
|
|
|
* @since 1.7 |
911
|
|
|
*/ |
912
|
|
|
function yourls_new_core_version_notice() { |
913
|
|
|
|
914
|
|
|
$checks = yourls_get_option( 'core_version_checks' ); |
915
|
|
|
$latest = isset($checks->last_result->latest) ? yourls_sanitize_version($checks->last_result->latest) : false; |
|
|
|
|
916
|
|
|
|
917
|
|
|
if( $latest AND version_compare( $latest, YOURLS_VERSION, '>' ) ) { |
|
|
|
|
918
|
|
|
$msg = yourls_s( '<a href="%s">YOURLS version %s</a> is available. Please update!', 'http://yourls.org/download', $latest ); |
|
|
|
|
919
|
|
|
yourls_add_notice( $msg ); |
920
|
|
|
} |
921
|
|
|
} |
922
|
|
|
|
923
|
|
|
/** |
924
|
|
|
* Get search text from query string variables search_protocol, search_slashes and search |
925
|
|
|
* |
926
|
|
|
* Some servers don't like query strings containing "(ht|f)tp(s)://". A javascript bit |
927
|
|
|
* explodes the search text into protocol, slashes and the rest (see JS function |
928
|
|
|
* split_search_text_before_search()) and this function glues pieces back together |
929
|
|
|
* See issue https://github.com/YOURLS/YOURLS/issues/1576 |
930
|
|
|
* |
931
|
|
|
* @since 1.7 |
932
|
|
|
* @return string Search string |
933
|
|
|
*/ |
934
|
|
|
function yourls_get_search_text() { |
935
|
|
|
$search = ''; |
936
|
|
|
if( isset( $_GET['search_protocol'] ) ) |
937
|
|
|
$search .= $_GET['search_protocol']; |
938
|
|
|
if( isset( $_GET['search_slashes'] ) ) |
939
|
|
|
$search .= $_GET['search_slashes']; |
940
|
|
|
if( isset( $_GET['search'] ) ) |
941
|
|
|
$search .= $_GET['search']; |
942
|
|
|
|
943
|
|
|
return htmlspecialchars( trim( $search ) ); |
944
|
|
|
} |
945
|
|
|
|
946
|
|
|
/** |
947
|
|
|
* Display or return HTML for a bookmarklet link |
948
|
|
|
* |
949
|
|
|
* @since 1.7.1 |
950
|
|
|
* @param string $href bookmarklet link (presumably minified code with "javascript:" scheme) |
951
|
|
|
* @param string $anchor link anchor |
952
|
|
|
* @param bool $echo true to display, false to return the HTML |
953
|
|
|
* @return string the HTML for a bookmarklet link |
954
|
|
|
*/ |
955
|
|
|
function yourls_bookmarklet_link( $href, $anchor, $echo = true ) { |
956
|
|
|
$alert = yourls_esc_attr__( 'Drag to your toolbar!' ); |
957
|
|
|
$link = <<<LINK |
958
|
|
|
<a href="$href" class="bookmarklet" onclick="alert('$alert');return false;">$anchor</a> |
959
|
|
|
LINK; |
960
|
|
|
|
961
|
|
|
if( $echo ) |
962
|
|
|
echo $link; |
963
|
|
|
return $link; |
964
|
|
|
} |
965
|
|
|
|
966
|
|
|
/** |
967
|
|
|
* Set HTML context (stats, index, infos, ...) |
968
|
|
|
* |
969
|
|
|
* @since 1.7.3 |
970
|
|
|
* @param string $context |
971
|
|
|
* @return void |
972
|
|
|
*/ |
973
|
|
|
function yourls_set_html_context($context) { |
974
|
1 |
|
yourls_get_db()->set_html_context($context); |
975
|
1 |
|
} |
976
|
|
|
|
977
|
|
|
/** |
978
|
|
|
* Get HTML context (stats, index, infos, ...) |
979
|
|
|
* |
980
|
|
|
* @since 1.7.3 |
981
|
|
|
* @return string |
982
|
|
|
*/ |
983
|
|
|
function yourls_get_html_context() { |
984
|
1 |
|
yourls_get_db()->get_html_context(); |
985
|
|
|
} |
986
|
|
|
|