$sql = 'SELECT * FROM ' . ARTICLES_TABLE . ' WHERE articles_status = ' . STATUS_ACTIVE . ' ORDER BY articles_order ASC'; $result = $_CLASS['core_db']->query_limit($sql, $limit, $start); while ($row = $_CLASS['core_db']->fetch_row_assoc($result)) { // this can cause problems, only thing to do is remove the limit query and do a loop until we get the needed articles if ($row['articles_auth'] && !$_CLASS['core_auth']->auth(@unserialize($row['articles_auth'])) && !$_CLASS['core_auth']->admin_power('articles')) { continue; } if ($row['articles_expires'] && !$expire_updated && $_CLASS['core_user']->time > $row['articles_expires']) { $_CLASS['core_db']->query('UPDATE ' . ARTICLES_TABLE . ' SET articles_status = ' . STATUS_DISABLED . ' WHERE articles_expires > 0 AND articles_expires <= ' . $_CLASS['core_user']->time); $expire_updated = true; continue; } if ($row['articles_starts'] && $row['articles_starts'] > $_CLASS['core_user']->time) { continue; } $_CLASS['core_template']->assign_vars_array('articles', array('poster' => $row['poster_name'] ? $row['poster_name'] : $_CLASS['core_user']->get_lang('ANONYMOUS'), 'content' => $row['articles_intro'] ? $row['articles_intro'] : $row['articles_text'], 'time' => $_CLASS['core_user']->format_date($row['articles_posted']), 'title' => $row['articles_title'], 'id' => $row['articles_id'], 'collapse' => check_collapsed_status('a_' . $row['articles_id']), 'full_story' => $row['articles_intro'] && $row['articles_text'], 'link_poster' => $row['poster_name'] && $row['poster_id'] ? generate_link('Members_List&mode=viewprofile&u=' . $row['poster_id']) : '', 'link_content' => generate_link('articles&mode=view&id=' . $row['articles_id']), 'link_print' => generate_link('articles&mode=print&id=' . $row['articles_id']), 'link_send' => generate_link('articles&mode=send&id=' . $row['articles_id']))); $collapable_holding[] = 'a_' . $row['articles_id']; } $_CLASS['core_db']->free_result($result); // Garbage collection, would cause problems with guest/loggin articl views if ($cookie_data = get_variable('collapsed_items', 'COOKIE')) { $collapsed_items = $cookie_data ? explode(':', $cookie_data) : array(); $count = count($collapsed_items); for ($i = 0; $i < $count; $i++) { if (mb_strpos($collapsed_items[$i], 'a_') === 0 && !in_array($collapsed_items[$i], $collapable_holding)) { unset($collapsed_items[$i]); } } $collapsed_items = implode(':', $collapsed_items); setcookie('collapsed_items', $collapsed_items, (int) $_CLASS['core_user']->time + 31536000000.0, '/'); }
function block_side() { global $_CLASS; $position = $this->display_position == BLOCK_RIGHT ? 'right' : 'left'; $_CLASS['core_template']->assign_vars_array('block_' . $position, array('title' => $this->block['block_title'], 'content' => $this->content, 'collapsed' => check_collapsed_status('block_' . $this->block['block_id']), 'id' => $this->block['block_id'])); }
function page_articles() { global $_CLASS; $_CLASS['core_user']->user_setup(); if (isset($_GET['mode'])) { switch ($_GET['mode']) { case 'print': $print = true; case 'view': $print = isset($print); $id = get_variable('id', 'GET', false, 'int'); if (!$id) { trigger_error('ARTICLE_NOT_FOUND'); } $result = $_CLASS['core_db']->query('SELECT * FROM ' . ARTICLES_TABLE . ' WHERE articles_id = ' . $id); $row = $_CLASS['core_db']->fetch_row_assoc($result); $_CLASS['core_db']->free_result($result); if (!$row || $row['articles_status'] != STATUS_ACTIVE) { trigger_error('ARTICLE_NOT_FOUND'); } $_CLASS['core_template']->assign_array(array('ARTICLES_POSTER' => $row['poster_name'] ? $row['poster_name'] : $_CLASS['core_user']->get_lang('ANONYMOUS'), 'ARTICLES_POSTER_LINK' => $row['poster_name'] && $row['poster_id'] ? generate_link('Members_List&mode=viewprofile&u=' . $row['poster_id']) : '', 'ARTICLES_TEXT' => $row['articles_text'], 'ARTICLES_CONTENT_LINK' => generate_link('articles&mode=view&id=' . $row['articles_id']), 'ARTICLES_TIME' => $_CLASS['core_user']->format_date($row['articles_posted']), 'ARTICLES_TITLE' => $row['articles_title'], 'ARTICLES_ID' => $id, 'ARTICLES_LINK_PRINT' => generate_link('articles&mode=print&id=' . $row['articles_id']), 'ARTICLES_LINK_SEND' => generate_link('articles&mode=send&id=' . $row['articles_id']))); $_CLASS['core_display']->display(false, $print ? 'modules/articles/print.html' : 'modules/articles/view.html'); script_close(); break; } } $start = get_variable('start', 'GET', false, 'int'); $collapable_holding = array(); $expire_updated = false; $limit = 10; $sql = 'SELECT * FROM ' . ARTICLES_TABLE . ' WHERE articles_status = ' . STATUS_ACTIVE . ' ORDER BY articles_order ASC'; $result = $_CLASS['core_db']->query_limit($sql, $limit, $start); while ($row = $_CLASS['core_db']->fetch_row_assoc($result)) { // this can cause problems, only thing to do is remove the limit query and do a loop until we get the needed articles if ($row['articles_auth'] && !$_CLASS['core_auth']->auth(@unserialize($row['articles_auth'])) && !$_CLASS['core_auth']->admin_power('articles')) { continue; } if ($row['articles_expires'] && !$expire_updated && $_CLASS['core_user']->time > $row['articles_expires']) { $_CLASS['core_db']->query('UPDATE ' . ARTICLES_TABLE . ' SET articles_status = ' . STATUS_DISABLED . ' WHERE articles_expires > 0 AND articles_expires <= ' . $_CLASS['core_user']->time); $expire_updated = true; continue; } if ($row['articles_starts'] && $row['articles_starts'] > $_CLASS['core_user']->time) { continue; } $_CLASS['core_template']->assign_vars_array('articles', array('poster' => $row['poster_name'] ? $row['poster_name'] : $_CLASS['core_user']->get_lang('ANONYMOUS'), 'content' => $row['articles_intro'] ? $row['articles_intro'] : $row['articles_text'], 'time' => $_CLASS['core_user']->format_date($row['articles_posted']), 'title' => $row['articles_title'], 'id' => $row['articles_id'], 'collapse' => check_collapsed_status('a_' . $row['articles_id']), 'full_story' => $row['articles_intro'] && $row['articles_text'], 'link_poster' => $row['poster_name'] && $row['poster_id'] ? generate_link('Members_List&mode=viewprofile&u=' . $row['poster_id']) : '', 'link_content' => generate_link('articles&mode=view&id=' . $row['articles_id']), 'link_print' => generate_link('articles&mode=print&id=' . $row['articles_id']), 'link_send' => generate_link('articles&mode=send&id=' . $row['articles_id']))); $collapable_holding[] = 'a_' . $row['articles_id']; } $_CLASS['core_db']->free_result($result); // Garbage collection, would cause problems with guest/loggin articl views if ($cookie_data = get_variable('collapsed_items', 'COOKIE')) { $collapsed_items = $cookie_data ? explode(':', $cookie_data) : array(); $count = count($collapsed_items); for ($i = 0; $i < $count; $i++) { if (mb_strpos($collapsed_items[$i], 'a_') === 0 && !in_array($collapsed_items[$i], $collapable_holding)) { unset($collapsed_items[$i]); } } $collapsed_items = implode(':', $collapsed_items); setcookie('collapsed_items', $collapsed_items, (int) $_CLASS['core_user']->time + 31536000000.0, '/'); } $result = $_CLASS['core_db']->query('SELECT COUNT(*) AS total FROM ' . ARTICLES_TABLE . ' WHERE articles_status = ' . STATUS_ACTIVE); $row = $_CLASS['core_db']->fetch_row_assoc($result); $_CLASS['core_db']->free_result($result); $pagination = generate_pagination('articles', $row['total'], $limit, $start); $_CLASS['core_template']->assign_array(array('articles_pagination' => $pagination['formated'], 'articles_pagination_array' => $pagination['array'])); $_CLASS['core_display']->display(false, 'modules/articles/index.html'); }