function shortcut_links($uid, &$thispage, $active = _SC_ACTIVE_PUBLIC) { global $xoopsDB; $port = $_SERVER['SERVER_PORT']; $thispage = ($port == 443 ? 'https' : 'http') . '://' . $_SERVER['SERVER_NAME'] . ($port == 80 || $port == 443 ? '' : $port) . $_SERVER['REQUEST_URI']; $cond = "active IN ({$active})"; if (isset($_GET['uid'])) { $cond .= " AND uid=" . intval($_GET['uid']); } elseif ($uid) { $cond = "uid={$uid}"; } else { $cond .= " AND uid=0"; } $result = $xoopsDB->query("SELECT * FROM " . $xoopsDB->prefix("shortcut") . " WHERE " . $cond . " ORDER BY pscref,weight"); $myts =& MyTextSanitizer::getInstance(); $items = array(); $links = array(); $marked = false; while ($row = $xoopsDB->fetchArray($result)) { $pscref = $row['pscref']; $row['uri'] = htmlspecialchars($url = eval_url($row['url'])); $current = $url == $thispage; if (!$current && substr($url, strlen($url) - 1, 1) == '/' && $url . 'index.php' == $thispage) { $current = true; } $row['title'] = htmlspecialchars($row['title']); $row['modified'] = formatTimestamp($row['mdate']); $row['owner'] = $uid ? $row['uid'] == $uid : false; $row['description'] = $myts->displayTarea($row['description'], 0); $row['current'] = $row['selected'] = $current; $id = $row['scid']; $items[$id] = $row; if ($row['pscref']) { $pid = $row['pscref']; $items[$pid]['sub'][] =& $items[$id]; if ($current) { $items[$pid]['selected'] = true; } } else { $links[] =& $items[$id]; } $marked |= $current; } if ($marked) { $thispage = ''; } // bookmarked this page return $links; }
<?php // $Id: sc.php,v 1.6 2008/06/22 08:28:40 nobu Exp $ // NOTE: this file put(copied) on short path length directory // e.g. XOOPS_ROOT_PATH/sc.php if (file_exists('./mainfile.php')) { include './mainfile.php'; } elseif (file_exists('../mainfile.php')) { include '../mainfile.php'; } else { include '../../mainfile.php'; } include XOOPS_ROOT_PATH . '/modules/shortcut/functions.php'; if (empty($_GET)) { $key = basename($_SERVER["REQUEST_URI"]); } else { list($key) = array_keys($_GET); } $qkey = "'" . addslashes(substr($key, 0, 16)) . "'"; $res = $xoopsDB->query('SELECT url FROM ' . $xoopsDB->prefix('shortcut') . ' WHERE active AND cutid=' . $qkey); list($url) = $xoopsDB->fetchRow($res); if (empty($url)) { redirect_header(XOOPS_URL . '/', 3, _NOPERM); } $xoopsDB->queryF('UPDATE ' . $xoopsDB->prefix('shortcut') . ' SET refer=refer+1 WHERE cutid=' . $qkey); header("Location: " . eval_url($url));
function display_entry($pre, &$data, &$ents) { static $n = 0; global $acts; $scid = $data['scid']; $cutid = $data['cutid']; $link = shortcut_script() . $cutid; $data['cutid'] = "<a href='{$link}'>{$cutid}</a>"; $op = "<a href='index.php?op=edit&scid={$scid}'/>" . _EDIT . "</a> | <a href='index.php?op=del&scid={$scid}'>" . _DELETE . "</a>"; $data['active'] = $acts[$data['active']]; $url = $data['url']; $aurl = eval_url($url); if (strlen($url) > 40) { $url = substr($url, 0, 38) . ".."; } $data['url'] = "<a href='{$aurl}'>{$url}</a>"; $bg = ++$n % 2 ? "odd" : "even"; $buf = "<tr class='{$bg}'>"; foreach ($ents as $key => $lab) { $buf .= "<td>" . ($key == 'title' ? $pre : '') . $data[$key] . "</td>"; } $buf .= "<td>{$op}</td></td></tr>\n"; return $buf; }