function navigation() { global $config, $my, $tpl, $db, $myini; $scache = new scache('modules_navigation'); if ($scache->existsdata() == TRUE) { $menu = $scache->importdata(); } else { $result = $db->query("SELECT id, name, link, param, groups, sub, module FROM {$db->pre}menu WHERE active = '1' AND FIND_IN_SET('navigation', position) ORDER BY ordering, id", __LINE__, __FILE__); $menu = array(); while ($row = $db->fetch_assoc($result)) { if (!isset($menu[$row['sub']])) { $menu[$row['sub']] = array(); } $menu[$row['sub']][] = $row; } $scache->exportdata($menu); } foreach ($menu[0] as $row) { if ($row['module'] == 0 && isset($menu[$row['id']])) { if ($this->GroupCheck($row['groups'])) { $nav_s = array(); foreach ($menu[$row['id']] as $sub) { if ($this->GroupCheck($sub['groups'])) { $sub['sub'] = array(); if (isset($menu[$sub['id']])) { foreach ($menu[$sub['id']] as $subsub) { if ($this->GroupCheck($subsub['groups'])) { $sub['sub'][] = $subsub; } } } $nav_s[] = $sub; } } $tpl->globalvars(compact("row", "nav_s", "nav_ss")); echo $tpl->parse("modules/navigation"); } } else { if ($row['module'] == 1 && ($row['groups'] == NULL || $this->GroupCheck($row['groups']) == TRUE)) { $dir = 'modules/' . $row['link'] . '/'; $ini = $myini->read($dir . "config.ini"); if (count($ini) > 0 && file_exists($dir . $ini['php'][0])) { include $dir . $ini['php'][0]; } unset($dir, $ini); } } } }
function cache_spiders() { global $db; $scache = new scache('spiders'); if ($scache->existsdata() == TRUE) { $bot = $scache->importdata(); } else { $result = $db->query("SELECT id, user_agent, bot_ip, name, type FROM {$db->pre}spider", __LINE__, __FILE__); $bot = array(); while ($row = $db->fetch_assoc($result)) { $bot[$row['id']] = $row; } $scache->exportdata($bot); } return $bot; }
function getStatusData() { global $db; $scache = new scache('group_status'); if ($scache->existsdata() == TRUE) { $this->statusdata = $scache->importdata(); } else { $cresult = $db->query("SELECT id, admin, guest, title, core FROM {$db->pre}groups ORDER BY core DESC", __LINE__, __FILE__); while ($row = $db->fetch_assoc($cresult)) { $this->statusdata[$row['id']] = $row; } $scache->exportdata($this->statusdata); } }
function BoardSelect($board = 0) { global $config, $my, $tpl, $db, $gpc, $lang; $found = FALSE; $sub_cache = array(); $sub_cache_last = array(); $cat_cache = array(); $mod_cache = array(); $forum_cache = array(); $cat_cache = cache_categories(); if (!isset($GLOBALS['memberdata']) || !is_array($GLOBALS['memberdata'])) { $memberdata = cache_memberdata(); } else { $memberdata = $GLOBALS['memberdata']; } $scache = new scache('index-moderators'); if ($scache->existsdata() == TRUE) { $mod_cache = $scache->importdata(); } else { $result = $db->query('SELECT mid, bid FROM ' . $db->pre . 'moderators WHERE time > ' . time() . ' OR time IS NULL', __LINE__, __FILE__); $mod_cache = array(); while ($row = $db->fetch_assoc($result)) { if (isset($memberdata[$row['mid']])) { $row['name'] = $memberdata[$row['mid']]; $mod_cache[$row['bid']][] = $row; } } $scache->exportdata($mod_cache); } // Fetch Forums $sql = "SELECT \n c.id, c.name, c.desc, c.opt, c.optvalue, c.bid, c.topics, c.replys, c.cid, c.last_topic, \n t.topic as btopic, t.id as btopic_id, t.last as bdate, u.name AS uname, t.last_name AS bname\n FROM {$db->pre}cat AS c\n LEFT JOIN {$db->pre}topics AS t ON c.last_topic=t.id \n LEFT JOIN {$db->pre}user AS u ON t.last_name=u.id \n ORDER BY c.cid, c.c_order, c.id"; $result = $db->query($sql, __LINE__, __FILE__); if ($db->num_rows($result) == 0) { $errormsg = array('There are currently no boards to show. Pleas visit the <a href="admin.php' . SID2URL_1 . '">Admin Control Panel</a> and create some forums.'); $errorurl = ''; $tpl->globalvars(compact("errorurl", "errormsg")); echo $tpl->parse('main/error'); return $found; } while ($row = $db->fetch_assoc($result)) { $gpc->prepare($row['name']); $gpc->prepare($row['btopic']); $gpc->prepare($row['uname']); $gpc->prepare($row['bname']); // Caching for Subforums if ($row['bid'] > 0) { $sub_cache[$row['bid']][] = $row; $sub_cache_last[$row['id']] = $row; } // Caching the Forums if ($row['bid'] == $board) { $forum_cache[$row['cid']][] = $row; } } // Work with the chached data! foreach ($cat_cache as $cat) { $forums = array(); if (isset($forum_cache[$cat['id']]) == false) { continue; } foreach ($forum_cache[$cat['id']] as $forum) { $found = TRUE; $forum['new'] = false; $forum['mbdate'] = $forum['bdate']; // Subforendaten vererben (Letzter Beitrag, Markierung) if (isset($sub_cache[$forum['id']])) { $substats = SubStats($forum['topics'], $forum['replys'], $forum['id'], $sub_cache); $forum['topics'] = $substats[0]; $forum['replys'] = $substats[1]; $bids = $substats[2]; } $last = $forum['last_topic']; $last_date = $forum['bdate']; if (isset($sub_cache[$forum['id']])) { foreach ($bids as $bidf) { $sub = $sub_cache_last[$bidf]; if ($last_date < $sub['bdate']) { $last = $sub['id']; $last_date = $sub['bdate']; } } } $forum['lname'] = is_id($forum['bname']) ? $forum['uname'] : $forum['bname']; if ($last != $forum['last_topic']) { $forum['id2'] = $last; $forum['last_topic'] = $sub_cache_last[$forum['id2']]['last_topic']; $forum['btopic_id'] = $sub_cache_last[$forum['id2']]['btopic_id']; $forum['btopic'] = $sub_cache_last[$forum['id2']]['btopic']; $forum['bdate'] = $sub_cache_last[$forum['id2']]['bdate']; if (!isset($sub_cache_last[$forum['id2']]['lname'])) { $forum['lname'] = is_id($sub_cache_last[$forum['id2']]['bname']) ? $sub_cache_last[$forum['id2']]['uname'] : $sub_cache_last[$forum['id2']]['bname']; } else { $forum['lname'] = $sub_cache_last[$forum['id2']]['lname']; } } else { $forum['id2'] = $forum['id']; } $id = array_search(trim($forum['lname']), $memberdata); if (is_id($id)) { $forum['lname'] = array($forum['lname'], $id); } else { $forum['lname'] = array($forum['lname'], 0); } if ($forum['btopic_id']) { $forum['tid'] = $forum['btopic_id']; } else { $forum['tid'] = $forum['last_topic']; } // Rechte und Gelesensystem if ($forum['opt'] != 're') { if (!check_forumperm($forum)) { $forum['foldimg'] = $tpl->img('cat_locked'); $forum['topics'] = '-'; $forum['replys'] = '-'; $forum['btopic'] = FALSE; } else { if (isset($my->mark['f'][$forum['id']]) && $my->mark['f'][$forum['id']] > $forum['bdate'] || $forum['bdate'] < $my->clv || $forum['topics'] < 1) { $forum['foldimg'] = $tpl->img('cat_open'); } else { $forum['foldimg'] = $tpl->img('cat_red'); $forum['new'] = true; } if ($forum['btopic']) { if (strxlen($forum['btopic']) >= 40) { $forum['btopic'] = substr($forum['btopic'], 0, 40); $forum['btopic'] .= "..."; } $forum['bdate'] = str_date($lang->phrase('dformat1'), times($forum['bdate'])); } } } $forum['topics'] = numbers($forum['topics']); $forum['replys'] = numbers($forum['replys']); // Moderatoren $forum['mod'] = array(); if (isset($mod_cache[$forum['id']])) { $anz2 = count($mod_cache[$forum['id']]); for ($i = 0; $i < $anz2; $i++) { if ($anz2 != $i + 1) { $mod_cache[$forum['id']][$i]['sep'] = ', '; } else { $mod_cache[$forum['id']][$i]['sep'] = ''; } $forum['mod'][] = $mod_cache[$forum['id']][$i]; } } // Unterforen $forum['sub'] = array(); if ($config['showsubfs']) { if (isset($sub_cache[$forum['id']])) { $anz2 = count($sub_cache[$forum['id']]); $sub = array(); for ($i = 0; $i < $anz2; $i++) { $sub_cache[$forum['id']][$i]['new'] = false; if ($sub_cache[$forum['id']][$i]['opt'] != 're') { if (!check_forumperm($sub_cache[$forum['id']][$i])) { $sub_cache[$forum['id']][$i]['foldimg'] = $tpl->img('subcat_locked'); } else { if (isset($my->mark['f'][$sub_cache[$forum['id']][$i]['id']]) && $my->mark['f'][$sub_cache[$forum['id']][$i]['id']] > $sub_cache[$forum['id']][$i]['bdate'] || $sub_cache[$forum['id']][$i]['bdate'] < $my->clv || $sub_cache[$forum['id']][$i]['topics'] < 1) { $sub_cache[$forum['id']][$i]['foldimg'] = $tpl->img('subcat_open'); } else { $sub_cache[$forum['id']][$i]['foldimg'] = $tpl->img('subcat_red'); $sub_cache[$forum['id']][$i]['new'] = true; } } } else { $sub_cache[$forum['id']][$i]['foldimg'] = $tpl->img('subcat_redirect'); } $forum['sub'][] = $sub_cache[$forum['id']][$i]; } } } $forums[] = $forum; } $tpl->globalvars(compact("cat", "forums")); echo $tpl->parse("categories"); } return $found; }
<?php $scache = new scache('grabrss'); if ($scache->existsdata() == TRUE) { $grabrss_cache = $scache->importdata(); } else { $cresult = $db->query("SELECT id, file, title, entries, max_age FROM {$db->pre}grab", __LINE__, __FILE__); $grabrss_cache = array(); while ($row = $db->fetch_assoc($cresult)) { $row['title'] = htmlentities($row['title'], ENT_QUOTES); $grabrss_cache[$row['id']] = $row; } $scache->exportdata($grabrss_cache); }
function cache_smileys() { global $db, $bbcode; $scache = new scache('smileys'); if ($scache->existsdata() == TRUE) { $cache = $scache->importdata(); } else { $bbresult = $db->query("SELECT * FROM {$db->pre}smileys", __LINE__, __FILE__); $cache = array(); while ($bb = $db->fetch_assoc($bbresult)) { $cache[] = $bb; } $scache->exportdata($cache); } $this->smileys = $cache; }
<?php global $gpc; $stime = times(); $today = $stime - gmmktime(0, 0, 0, gmdate('m', $stime), gmdate('d', $stime), gmdate('Y', $stime), date('I', $stime)) - 60; $scache = new scache('birthday_module'); if ($scache->existsdata($today) == TRUE) { $data = $scache->importdata(); } else { $result = $db->query("SELECT id, name, birthday FROM {$db->pre}user WHERE RIGHT( birthday, 5 ) = '" . gmdate('m-d', times()) . "' ORDER BY name", __LINE__, __FILE__); $data = array(); while ($e = $db->fetch_assoc($result)) { $e['name'] = $gpc->prepare($e['name']); $e['birthday'] = explode('-', $e['birthday']); $e['age'] = getAge($e['birthday']); $data[] = $e; } $scache->exportdata($data); } if (count($data) > 0) { $tpl->globalvars(compact("data")); echo $tpl->parse($dir . "birthday_box"); }
function cache_spiders() { global $db; $s3cache = new scache('spiders'); if ($s3cache->existsdata() == TRUE) { $botua = $s3cache->importdata(); } else { $cresult = $db->query("SELECT user_agent, name, type FROM {$db->pre}spider", __LINE__, __FILE__); $botua = array(); while ($catc = $db->fetch_assoc($cresult)) { $botua[] = $catc; } $s3cache->exportdata($botua); } return $botua; }