Skip to content

Commit bbbec97

Browse files
committed
Admin panel load optmiziation
* Caching period extended for checking updates, news and 'did you know' sections.
1 parent d09ad3f commit bbbec97

File tree

3 files changed

+21
-18
lines changed

3 files changed

+21
-18
lines changed

modules/market/market.class.php

Lines changed: 2 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,7 @@ function admin(&$out)
236236
}
237237

238238
if ($this->ajax && $op == 'didyouknow') {
239-
$result = $this->marketRequest('op=didyouknow', 0);
239+
$result = $this->marketRequest('op=didyouknow', 7 * 24 * 60 * 60);
240240
$data = json_decode($result, true);
241241
if ($data['BODY']) {
242242
echo nl2br(htmlspecialchars($data['BODY']));
@@ -253,7 +253,7 @@ function admin(&$out)
253253
}
254254

255255
if ($this->ajax && $op == 'news') {
256-
$result = $this->marketRequest('op=news', 15 * 60); //15*60
256+
$result = $this->marketRequest('op=news', 7 * 24 * 60 * 60);
257257
$data = json_decode($result, true);
258258
//echo json_encode($data);
259259
if (is_array($data)) {
@@ -300,20 +300,6 @@ function admin(&$out)
300300
echo '<div class="fullTextNewsClass" id="news_title_' . $i . '" style="display: none;margin-top: 10px;padding-top: 10px;border-top: 1px solid lightgray;"><blockquote style="border-left: 5px solid #4d96d3;">' . $body . ' ' . $linkDetail . '</blockquote></div>';
301301
echo '</li>';
302302

303-
304-
//echo '<a href="javascript://" onclick="$(\'#news_title_'.$i.'\').toggle(\'slow\');" class="list-group-item" style="padding-top: 10px;padding-bottom: 5px;">';
305-
//echo '<h5 id="news_head_'.$i.'" class="list-group-item-heading">'.(htmlspecialchars($data[$i]['TITLE'])).'</h5>';
306-
//$body = nl2br(htmlspecialchars($data[$i]['BODY']));
307-
//$body = str_replace('&amp;', '&', $body);
308-
//$body = preg_replace('/(https?:\/\/[\w\d\-\/\.\?&=#]+)/', '<a href="$1" target=_blank>$1</a>', $body);
309-
310-
//echo '<p id="news_title_'.$i.'" style="display: none;" class="list-group-item-text">'.(htmlspecialchars($data[$i]['BODY'])).'</p>';
311-
//echo '</a>';
312-
313-
314-
/* if ($data[$i]['LINK'] != '') {
315-
echo "<br/><a href='" . $data[$i]['LINK'] . "' target='_blank'>" . LANG_DETAILS . "</a>";
316-
} */
317303
}
318304
echo '</ul>';
319305
}

modules/saverestore/saverestore.class.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,13 @@ function admin(&$out)
196196
$github_feed_url = $update_url;
197197
$github_feed_url = str_replace('/archive/', '/commits/', $github_feed_url);
198198
$github_feed_url = str_replace('.tar.gz', '.atom', $github_feed_url);
199-
$github_feed = getURL($github_feed_url, 30 * 60);
199+
200+
if ($_GET['op'] == 'check_updates') {
201+
$cache_timeout = 3 * 24 * 60 * 60;
202+
} else {
203+
$cache_timeout = 30 * 60;
204+
}
205+
$github_feed = getURL($github_feed_url, $cache_timeout);
200206

201207
if ($github_feed != '') {
202208
$tmp = GetXMLTree($github_feed);

scripts/startup_maintenance.php

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -258,7 +258,7 @@
258258
}
259259
}
260260
}
261-
echo ("Found in db $found_in_db / found in dir: $found_in_dir\n");
261+
echo("Found in db $found_in_db / found in dir: $found_in_dir\n");
262262
foreach ($found_files as $k => $v) {
263263
$path = $folder . $k;
264264
if (is_file($path)) {
@@ -326,3 +326,14 @@
326326
if ($serial_data != '') {
327327
sg('ThisComputer.Serial', $serial_data);
328328
}
329+
330+
331+
// caching some data
332+
include_once DIR_MODULES . 'market/market.class.php';
333+
$mkt = new market();
334+
$mkt->marketRequest('op=didyouknow');
335+
$mkt->marketRequest('op=news');
336+
337+
include_once DIR_MODULES . 'saverestore/saverestore.class.php';
338+
$sv = new saverestore();
339+
$sv->admin($out);

0 commit comments

Comments
 (0)