@@ -41,7 +41,7 @@ public function main() {
4141
4242 if (!$ this ->enable ) return $ this ->noCache ();
4343
44- $ content = '' ;
44+ $ content = '<div class="container-fluid"> ' ;
4545
4646// if (empty($_GET['mod'])) {
4747// $content .= $this->welcome();
@@ -58,6 +58,9 @@ public function main() {
5858 default : $ content .= $ this ->cache ();
5959 }
6060// }
61+
62+ $ content .= '</div> ' ;
63+
6164 return $ content ;
6265 }
6366
@@ -67,22 +70,30 @@ public function all() {
6770 if (isset ($ _POST ['refresh ' ])) {
6871 $ this ->db ->query ('UPDATE ' .$ this ->table .'cache SET tstamp=0 ' );
6972 } 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+ }
7280 }
7381 $ c .= '<div class="succes"><p>Done.</p></div> ' ;
7482 }
7583 $ c .= '
7684 <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>
7886 <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">
8088 </form>
8189
82- <h2>Start againg </h2>
90+ <h2>Start again </h2>
8391 <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>
8697 </form>
8798 ' ;
8899 return $ c ;
@@ -98,11 +109,19 @@ private function serializedArrayToQueryString($ar) {
98109 }
99110
100111 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+ }
103118
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+ }
106125
107126 if (!empty ($ id )) {
108127 $ q = $ this ->db ->query ('DELETE FROM ' .$ this ->table .($ old ?'oldlinks ' :'cache ' ).' WHERE id= ' .$ id .' LIMIT 1 ' );
@@ -120,11 +139,15 @@ public function sticky() {
120139 if (empty ($ _GET ['lid ' ])) $ id = 0 ;
121140 else $ id = (int )$ _GET ['lid ' ];
122141
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+ }
125148
126149 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 ' );
128151 if (!$ q || $ this ->db ->affected_rows ()==0 ) {
129152 $ 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> ' ;
130153 } else {
@@ -198,13 +221,11 @@ public function cache() {
198221 ' ;
199222 }
200223 $ 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>
208229 </form> ' ;
209230
210231 if (!empty ($ let )) {
@@ -227,10 +248,13 @@ public function cache() {
227248 <td> ' .$ row ['crdatetime ' ].'</td>
228249 <td> ' .$ row ['tstamp ' ].'</td>
229250 <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>
234258 </td>
235259 </tr> ' ;
236260 }
@@ -258,29 +282,32 @@ public function old() {
258282 ' ;
259283 }
260284 $ 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">
267289 </form> ' ;
268290
269291 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
271293 ON l.id=o.link_id WHERE LOWER(o.url) LIKE ' .$ this ->db ->escape (strtolower ($ let ).'% ' ).' ORDER BY o.url ' );
272294
273295 $ num = $ this ->db ->num_rows ($ q );
274296 if ($ num >0 ) {
275297 $ c .= '<p class="center">Records found: ' .$ num .'</p> ' ;
276298 $ 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> ' ;
278300 while ($ row = $ this ->db ->fetch ($ q )) {
279301 $ c .= '<tr>
280302 <td class="left"> ' .htmlspecialchars ($ row ['ourl ' ]).'</td>
281303 <td class="left"> ' .htmlspecialchars ($ row ['lurl ' ]).'</td>
282304 <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>
284311 </td>
285312 </tr> ' ;
286313 }
@@ -398,14 +425,22 @@ public function link() {
398425 $ c .= '<form method="post" action=" ' .$ this ->file .'mod=link ' .($ new ?'' :'&lid= ' .$ id ).'">
399426 <fieldset>
400427 <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>
407442 </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" >
409444 </form>
410445 ' ;
411446 return $ c ;
@@ -421,9 +456,10 @@ public function redirect() {
421456 if (empty ($ id ) || empty ($ _POST ['url ' ])) {
422457 $ c .= '<div class="error"><p>All fields are required.</p></div> ' ;
423458 } 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 )
425460 VALUES( ' .$ id .',
426- ' .$ this ->db ->escape ($ _POST ['url ' ]).') ' );
461+ ' .$ this ->db ->escape ($ _POST ['url ' ]).',
462+ ' .(!empty ($ _POST ['sticky ' ]) && $ _POST ['sticky ' ]==1 ?1 :0 ).') ' );
427463 $ c .= '<div class="succes"><p>The redirect was saved successfully.</p></div> ' ;
428464 }
429465 }
@@ -433,18 +469,28 @@ public function redirect() {
433469 $ c .= '<form method="post" action=" ' .$ this ->file .'mod=redirect">
434470 <fieldset>
435471 <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">
440479 ' ;
441480 while ($ row = $ this ->db ->fetch ($ allq )) {
442481 $ c .= '<option value=" ' .$ row ['id ' ].'"> ' .$ row ['url ' ].'</option>
443482 ' ;
444483 }
445484 $ 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>
446492 </fieldset>
447- <input type="submit" value="Submit this redirect" class="submit" / >
493+ <input type="submit" value="Submit this redirect" class="submit btn btn-primary" >
448494 </form>
449495 ' ;
450496 return $ c ;
@@ -460,7 +506,7 @@ public function menu() {
460506 if (empty ($ cm )) {
461507 $ cm = 'cache ' ;
462508 }
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 "> ' ;
464510 foreach ($ mods as $ k =>$ v ) {
465511 $ c .= '<li ' .($ cm ==$ k ?' class="active" ' :'' ).'><a href=" ' .$ this ->file .($ k ?'mod= ' .$ k :'' ).'"> ' .$ v .'</a></li> ' ;
466512 }
0 commit comments