// the user has to be an associate if (!Surfer::is_associate()) { Safe::header('Status: 401 Unauthorized', TRUE, 401); Logger::error(i18n::s('You are not allowed to perform this operation.')); // forward to the index page $menu = array('links/' => i18n::s('Links')); $context['text'] .= Skin::build_list($menu, 'menu_bar'); // check links through the Internet } elseif (isset($_REQUEST['action']) && $_REQUEST['action'] == 'check') { // scan links $context['text'] .= '<p>' . sprintf(i18n::s('Analyzing table %s...'), SQL::table_name('links')) . "</p>\n"; // process all links $links_offset = 0; while ($links_offset < MAXIMUM_SIZE) { // seek the database if (($rows = Links::list_by_date($links_offset, CHUNK_SIZE, 'review')) && count($rows)) { // analyze each link foreach ($rows as $view_url => $label) { $prefix = $suffix = $variant = $actual_url = ''; if (is_array($label)) { $prefix = $label[0]; $suffix = $label[2]; $variant = $label[3]; $actual_url = $label[4]; $label = $label[1]; } // the url is valid if ($stamp = Link::validate($actual_url)) { $context['text'] .= '.'; // remember Last-Modified data, if any if (preg_match('/\\d\\d\\d\\d-\\d\\d-\\d\\d/', $stamp)) {
// page main content $cache_id = 'links/index.php#text#' . $page; if (!($text = Cache::get($cache_id))) { // load the layout to use switch ($context['root_articles_layout']) { case 'daily': include_once 'layout_links_as_daily.php'; $layout = new Layout_links_as_daily(); break; default: $layout = 'full'; break; } // query the database and layout that stuff $offset = ($page - 1) * $items_per_page; if (!($text = Links::list_by_date($offset, $items_per_page, $layout))) { $text = '<p>' . i18n::s('No link has been recorded yet.') . '</p>'; } // we have an array to format if (is_array($text)) { $text =& Skin::build_list($text, 'decorated'); } // cache this to speed subsequent queries Cache::put($cache_id, $text, 'links'); } $context['text'] .= $text; } // page tools if (Surfer::is_associate()) { if ($section = Sections::get('clicks')) { $context['page_tools'][] = Skin::build_link(Sections::get_permalink($section), i18n::s('Detected clicks'), 'basic');