@@ -41,7 +41,7 @@ public function main() {
41
41
42
42
if (!$ this ->enable ) return $ this ->noCache ();
43
43
44
- $ content = '' ;
44
+ $ content = '<div class="container-fluid"> ' ;
45
45
46
46
// if (empty($_GET['mod'])) {
47
47
// $content .= $this->welcome();
@@ -58,6 +58,9 @@ public function main() {
58
58
default : $ content .= $ this ->cache ();
59
59
}
60
60
// }
61
+
62
+ $ content .= '</div> ' ;
63
+
61
64
return $ content ;
62
65
}
63
66
@@ -67,22 +70,30 @@ public function all() {
67
70
if (isset ($ _POST ['refresh ' ])) {
68
71
$ this ->db ->query ('UPDATE ' .$ this ->table .'cache SET tstamp=0 ' );
69
72
} elseif (isset ($ _POST ['delete ' ])) {
70
- $ this ->db ->query ('TRUNCATE ' .$ this ->table .'cache ' );
71
- $ this ->db ->query ('TRUNCATE ' .$ this ->table .'oldlinks ' );
73
+ if (isset ($ _POST ['sticky ' ]) && $ _POST ['sticky ' ] == 1 ) {
74
+ $ this ->db ->query ('TRUNCATE ' .$ this ->table .'cache ' );
75
+ $ this ->db ->query ('TRUNCATE ' .$ this ->table .'oldlinks ' );
76
+ } else {
77
+ $ this ->db ->query ('DELETE FROM ' .$ this ->table .'cache WHERE sticky != 1 ' );
78
+ $ this ->db ->query ('DELETE FROM ' .$ this ->table .'oldlinks WHERE sticky != 1 ' );
79
+ }
72
80
}
73
81
$ c .= '<div class="succes"><p>Done.</p></div> ' ;
74
82
}
75
83
$ c .= '
76
84
<h2>Force all links to update upon next hit</h2>
77
- <p>Upon next page hit, all links will be regenerated and if changed, old link will be moved to "oldlinks".</p>
85
+ <p>Upon next page hit, all links will be regenerated and if changed, any old link will be moved to "oldlinks".</p>
78
86
<form method="post" action=" ' .$ this ->file .'mod=all">
79
- <input type="submit" name="refresh" value="FORCE UPDATE OF ALL LINKS" class="btn btn-warning" / >
87
+ <input type="submit" name="refresh" value="FORCE UPDATE OF ALL LINKS" class="btn btn-warning">
80
88
</form>
81
89
82
- <h2>Start againg </h2>
90
+ <h2>Start again </h2>
83
91
<p>Delete everything - cache and oldlinks.</p>
84
- <form method="post" action=" ' .$ this ->file .'mod=all">
85
- <input type="submit" name="delete" value="DELETE EVERYTHING AND START AGAIN" class="btn btn-danger" />
92
+ <form method="post" action=" ' .$ this ->file .'mod=all" class="form-inline">
93
+ <input type="submit" name="delete" value="DELETE EVERYTHING AND START AGAIN" class="btn btn-danger">
94
+ <label class="checkbox">
95
+ <input type="checkbox" name="sticky" value="1"> Delete sticky too
96
+ </label>
86
97
</form>
87
98
' ;
88
99
return $ c ;
@@ -98,11 +109,19 @@ private function serializedArrayToQueryString($ar) {
98
109
}
99
110
100
111
public function delete () {
101
- if (empty ($ _GET ['lid ' ])) $ id = 0 ;
102
- else $ id = (int )$ _GET ['lid ' ];
112
+ if (empty ($ _GET ['lid ' ])) {
113
+ $ id = 0 ;
114
+ }
115
+ else {
116
+ $ id = (int )$ _GET ['lid ' ];
117
+ }
103
118
104
- if (isset ($ _GET ['old ' ])) $ old = true ;
105
- else $ old = false ;
119
+ if (isset ($ _GET ['old ' ])) {
120
+ $ old = true ;
121
+ }
122
+ else {
123
+ $ old = false ;
124
+ }
106
125
107
126
if (!empty ($ id )) {
108
127
$ q = $ this ->db ->query ('DELETE FROM ' .$ this ->table .($ old ?'oldlinks ' :'cache ' ).' WHERE id= ' .$ id .' LIMIT 1 ' );
@@ -120,11 +139,15 @@ public function sticky() {
120
139
if (empty ($ _GET ['lid ' ])) $ id = 0 ;
121
140
else $ id = (int )$ _GET ['lid ' ];
122
141
123
- if (isset ($ _GET ['old ' ])) $ old = true ;
124
- else $ old = false ;
142
+ if (isset ($ _GET ['old ' ])) {
143
+ $ old = true ;
144
+ }
145
+ else {
146
+ $ old = false ;
147
+ }
125
148
126
149
if (!empty ($ id )) {
127
- $ q = $ this ->db ->query ('UPDATE ' .$ this ->table .' cache SET sticky=not(sticky) WHERE id= ' .$ id .' LIMIT 1 ' );
150
+ $ q = $ this ->db ->query ('UPDATE ' .$ this ->table .( $ old ? ' oldlinks ' : ' cache ' ). ' SET sticky=not(sticky) WHERE id= ' .$ id .' LIMIT 1 ' );
128
151
if (!$ q || $ this ->db ->affected_rows ()==0 ) {
129
152
$ c = '<div class="error"><p>The sticky value hasn \'t been changed because the link doesn \'t exist (or maybe a DB error).</p></div> ' ;
130
153
} else {
@@ -198,13 +221,11 @@ public function cache() {
198
221
' ;
199
222
}
200
223
$ c .= '</p> ' ;
201
- $ c .= '<form method="post" action=" ' .$ this ->file .'">
202
- <p class="center">
203
- Link starts with: <input type="text" name="l" class="a" value=" ' .htmlspecialchars ($ let ).'" />
204
- <input type="hidden" name="mod" value="cache" />
205
- <input type="submit" value="Search" class="submit" />
206
- <label>Ignore domain: <input type="checkbox" name="domain" value="1" ' .(!empty ($ _REQUEST ['domain ' ])?' checked="checked" ' :'' ).'/></label>
207
- </p>
224
+ $ c .= '<form method="post" action=" ' .$ this ->file .'" class="form-inline">
225
+ <label>Link starts with: <input type="text" name="l" class="a form-control" value=" ' .htmlspecialchars ($ let ).'"></label>
226
+ <input type="hidden" name="mod" value="cache">
227
+ <input type="submit" value="Search" class="submit btn btn-primary">
228
+ <label><input type="checkbox" name="domain" value="1" ' .(!empty ($ _REQUEST ['domain ' ])?' checked="checked" ' :'' ).'> Ignore domain</label>
208
229
</form> ' ;
209
230
210
231
if (!empty ($ let )) {
@@ -227,10 +248,13 @@ public function cache() {
227
248
<td> ' .$ row ['crdatetime ' ].'</td>
228
249
<td> ' .$ row ['tstamp ' ].'</td>
229
250
<td> ' .($ row ['sticky ' ]?'YES ' :'NO ' ).'</td>
230
- <td class="nowrap"><a href=" ' .$ this ->file .'mod=link&lid= ' .$ row ['id ' ].'"><img src=" ' .$ this ->resPath .'img/button_edit.gif" alt="Edit" title="Edit" /></a>
231
- <a href=" ' .$ this ->file .'mod=update&lid= ' .$ row ['id ' ].'&from=cache: ' .$ let .'"><img src=" ' .$ this ->resPath .'img/button_refresh.gif" alt="Update" title="Update" /></a>
232
- <a href=" ' .$ this ->file .'mod=delete&lid= ' .$ row ['id ' ].'&from=cache: ' .$ let .'"><img src=" ' .$ this ->resPath .'img/button_garbage.gif" alt="Delete" title="Delete" onclick="return confirm( \'Are you sure? \');" /></a>
233
- <a href=" ' .$ this ->file .'mod=sticky&lid= ' .$ row ['id ' ].'&from=cache: ' .$ let .'"><img src=" ' .$ this ->resPath .'img/button_sticky.gif" alt="Sticky on/off" title="Sticky on/off" /></a>
251
+ <td class="nowrap">
252
+ <div class="btn-group">
253
+ <a href=" ' .$ this ->file .'mod=link&lid= ' .$ row ['id ' ].'" class="btn btn-default"><img src=" ' .$ this ->resPath .'img/button_edit.gif" alt="Edit" title="Edit"></a>
254
+ <a href=" ' .$ this ->file .'mod=update&lid= ' .$ row ['id ' ].'&from=cache: ' .$ let .'" class="btn btn-default"><img src=" ' .$ this ->resPath .'img/button_refresh.gif" alt="Update" title="Update"></a>
255
+ <a href=" ' .$ this ->file .'mod=delete&lid= ' .$ row ['id ' ].'&from=cache: ' .$ let .'" class="btn btn-default" onclick="return confirm( \'Are you sure? \');"><img src=" ' .$ this ->resPath .'img/button_garbage.gif" alt="Delete" title="Delete"></a>
256
+ <a href=" ' .$ this ->file .'mod=sticky&lid= ' .$ row ['id ' ].'&from=cache: ' .$ let .'" class="btn btn-default"><img src=" ' .$ this ->resPath .'img/button_sticky.gif" alt="Sticky on/off" title="Sticky on/off"></a>
257
+ </div>
234
258
</td>
235
259
</tr> ' ;
236
260
}
@@ -258,29 +282,32 @@ public function old() {
258
282
' ;
259
283
}
260
284
$ c .= '</p> ' ;
261
- $ c .= '<form method="post" action=" ' .$ this ->file .'mod=old">
262
- <p class="center">
263
- Link starts with: <input type="text" name="l" class="a" value=" ' .htmlspecialchars ($ let ).'" />
264
- <input type="hidden" name="mod" value="cache" />
265
- <input type="submit" value="Search" class="submit" />
266
- </p>
285
+ $ c .= '<form method="post" action=" ' .$ this ->file .'mod=old" class="form-inline">
286
+ <label>Link starts with: <input type="text" name="l" class="a form-control" value=" ' .htmlspecialchars ($ let ).'"></label>
287
+ <input type="hidden" name="mod" value="cache">
288
+ <input type="submit" value="Search" class="submit btn btn-primary">
267
289
</form> ' ;
268
290
269
291
if (!empty ($ let )) {
270
- $ q = $ this ->db ->query ('SELECT o.id, o.url AS ourl, l.url AS lurl, o.tstamp FROM ' .$ this ->table .'oldlinks AS o LEFT JOIN ' .$ this ->table .'cache AS l
292
+ $ q = $ this ->db ->query ('SELECT o.id, o.url AS ourl, l.url AS lurl, o.tstamp, o.sticky FROM ' .$ this ->table .'oldlinks AS o LEFT JOIN ' .$ this ->table .'cache AS l
271
293
ON l.id=o.link_id WHERE LOWER(o.url) LIKE ' .$ this ->db ->escape (strtolower ($ let ).'% ' ).' ORDER BY o.url ' );
272
294
273
295
$ num = $ this ->db ->num_rows ($ q );
274
296
if ($ num >0 ) {
275
297
$ c .= '<p class="center">Records found: ' .$ num .'</p> ' ;
276
298
$ c .= '<form method="post" action=" ' .$ this ->file .'mod=cache"> ' ;
277
- $ c .= '<table id="list" class="table table-striped"><tr><th class="left">Old URI</th><th class="left">Cached URI</th><th>Moved to olds</th><th>Action</th> ' ;
299
+ $ c .= '<table id="list" class="table table-striped"><tr><th class="left">Old URI</th><th class="left">Cached URI</th><th>Moved to olds</th><th>Sticky</th><th> Action</th> ' ;
278
300
while ($ row = $ this ->db ->fetch ($ q )) {
279
301
$ c .= '<tr>
280
302
<td class="left"> ' .htmlspecialchars ($ row ['ourl ' ]).'</td>
281
303
<td class="left"> ' .htmlspecialchars ($ row ['lurl ' ]).'</td>
282
304
<td> ' .$ row ['tstamp ' ].'</td>
283
- <td class="nowrap"><a href=" ' .$ this ->file .'mod=delete&old&lid= ' .$ row ['id ' ].'&from=old: ' .$ let .'"><img src=" ' .$ this ->resPath .'img/button_garbage.gif" alt="Delete" title="Delete" onclick="return confirm( \'Are you sure? \');" /></a>
305
+ <td> ' .($ row ['sticky ' ]?'YES ' :'NO ' ).'</td>
306
+ <td class="nowrap">
307
+ <div class="btn-group">
308
+ <a href=" ' .$ this ->file .'mod=delete&old&lid= ' .$ row ['id ' ].'&from=old: ' .$ let .'" class="btn btn-default" onclick="return confirm( \'Are you sure? \');"><img src=" ' .$ this ->resPath .'img/button_garbage.gif" alt="Delete" title="Delete" ></a>
309
+ <a href=" ' .$ this ->file .'mod=sticky&old&lid= ' .$ row ['id ' ].'&from=old: ' .$ let .'" class="btn btn-default"><img src=" ' .$ this ->resPath .'img/button_sticky.gif" alt="Sticky on/off" title="Sticky on/off"></a>
310
+ </div>
284
311
</td>
285
312
</tr> ' ;
286
313
}
@@ -398,14 +425,22 @@ public function link() {
398
425
$ c .= '<form method="post" action=" ' .$ this ->file .'mod=link ' .($ new ?'' :'&lid= ' .$ id ).'">
399
426
<fieldset>
400
427
<legend>URI details</legend>
401
- <label for="url">URI:</label><br />
402
- <input type="text" name="url" id="url" value=" ' .(empty ($ data ['url ' ])?'' :htmlspecialchars ($ data ['url ' ])).'" /><br />
403
- <label for="params">Parameters (query string: id=1&type=2):</label><br />
404
- <input type="text" name="params" id="params" value=" ' .(empty ($ data ['params ' ])?'' :htmlspecialchars ($ data ['params ' ])).'" /><br />
405
- <label for="sticky">Sticky (won \'t be updated):</label><br />
406
- <input type="checkbox" class="check" name="sticky" id="sticky" value="1" ' .(empty ($ data ['sticky ' ])?'' :' checked="checked" ' ).' />
428
+ <div class="form-group">
429
+ <label for="url">URI:</label>
430
+ <input type="text" name="url" id="url" class="form-control" value=" ' .(empty ($ data ['url ' ])?'' :htmlspecialchars ($ data ['url ' ])).'">
431
+ </div>
432
+ <div class="form-group">
433
+ <label for="params">Parameters (query string: id=1&type=2):</label>
434
+ <input type="text" name="params" id="params" class="form-control" value=" ' .(empty ($ data ['params ' ])?'' :htmlspecialchars ($ data ['params ' ])).'">
435
+ </div>
436
+ <div class="form-group">
437
+ <label for="sticky">
438
+ <input type="checkbox" class="check" name="sticky" id="sticky" value="1" ' .(empty ($ data ['sticky ' ])?'' :' checked="checked" ' ).'>
439
+ Sticky (won \'t be updated)
440
+ </label>
441
+ </div>
407
442
</fieldset>
408
- <input type="submit" value=" ' .($ new ?'Save new URI ' :'Update this URI ' ).' " class="submit" / >
443
+ <input type="submit" value=" ' .($ new ?'Save new URI ' :'Update this URI ' ).' " class="submit btn btn-primary" >
409
444
</form>
410
445
' ;
411
446
return $ c ;
@@ -421,9 +456,10 @@ public function redirect() {
421
456
if (empty ($ id ) || empty ($ _POST ['url ' ])) {
422
457
$ c .= '<div class="error"><p>All fields are required.</p></div> ' ;
423
458
} else {
424
- $ this ->db ->query ('INSERT INTO ' .$ this ->table .'oldlinks(link_id,url)
459
+ $ this ->db ->query ('INSERT INTO ' .$ this ->table .'oldlinks(link_id,url,sticky )
425
460
VALUES( ' .$ id .',
426
- ' .$ this ->db ->escape ($ _POST ['url ' ]).') ' );
461
+ ' .$ this ->db ->escape ($ _POST ['url ' ]).',
462
+ ' .(!empty ($ _POST ['sticky ' ]) && $ _POST ['sticky ' ]==1 ?1 :0 ).') ' );
427
463
$ c .= '<div class="succes"><p>The redirect was saved successfully.</p></div> ' ;
428
464
}
429
465
}
@@ -433,18 +469,28 @@ public function redirect() {
433
469
$ c .= '<form method="post" action=" ' .$ this ->file .'mod=redirect">
434
470
<fieldset>
435
471
<legend>Redirect details</legend>
436
- <label for="url">From:</label><br />
437
- <input type="text" name="url" id="url" /><br />
438
- <label for="to">To:</label><br />
439
- <select name="to" id="to">
472
+ <div class="form-group">
473
+ <label for="url">From:</label>
474
+ <input type="text" name="url" id="url" class="form-control">
475
+ </div>
476
+ <div class="form-group">
477
+ <label for="to">To:</label>
478
+ <select name="to" id="to" class="form-control">
440
479
' ;
441
480
while ($ row = $ this ->db ->fetch ($ allq )) {
442
481
$ c .= '<option value=" ' .$ row ['id ' ].'"> ' .$ row ['url ' ].'</option>
443
482
' ;
444
483
}
445
484
$ c .= '</select>
485
+ </div>
486
+ <div class="checkbox">
487
+ <label for="sticky">
488
+ <input type="checkbox" class="check" name="sticky" id="sticky" value="1" ' .(empty ($ data ['sticky ' ])?'' :' checked="checked" ' ).'>
489
+ Sticky (won \'t be deleted upon Delete all action)
490
+ </label>
491
+ </div>
446
492
</fieldset>
447
- <input type="submit" value="Submit this redirect" class="submit" / >
493
+ <input type="submit" value="Submit this redirect" class="submit btn btn-primary" >
448
494
</form>
449
495
' ;
450
496
return $ c ;
@@ -460,7 +506,7 @@ public function menu() {
460
506
if (empty ($ cm )) {
461
507
$ cm = 'cache ' ;
462
508
}
463
- $ c = '<nav class="navbar navbar-default"><div class="container-fluid"><ul class="nav navbar- nav"> ' ;
509
+ $ c = '<nav class="navbar navbar-default" style="margin-bottom: 20px" ><div class="container-fluid"><ul class="nav nav-tabs "> ' ;
464
510
foreach ($ mods as $ k =>$ v ) {
465
511
$ c .= '<li ' .($ cm ==$ k ?' class="active" ' :'' ).'><a href=" ' .$ this ->file .($ k ?'mod= ' .$ k :'' ).'"> ' .$ v .'</a></li> ' ;
466
512
}
0 commit comments