Example #1
0
function showItem($id)
{
    global $database, $my;
    $link = new mosWeblink($database);
    $link->load((int) $id);
    /*
     * Check if link is published
     */
    if (!$link->published) {
        mosNotAuth();
        return;
    }
    $cat = new mosCategory($database);
    $cat->load((int) $link->catid);
    /*
     * Check if category is published
     */
    if (!$cat->published) {
        mosNotAuth();
        return;
    }
    /*
     * check whether category access level allows access
     */
    if ($cat->access > $my->gid) {
        mosNotAuth();
        return;
    }
    // Record the hit
    $query = "UPDATE #__weblinks" . "\n SET hits = hits + 1" . "\n WHERE id = " . (int) $id;
    $database->setQuery($query);
    $database->query();
    if ($link->url) {
        // redirects to url if matching id found
        mosRedirect($link->url);
    } else {
        // redirects to weblink category page if no matching id found
        listWeblinks($cat->id);
    }
}
Example #2
0
function showItem($id, $catid)
{
    global $database;
    //Record the hit
    $sql = "UPDATE #__weblinks SET hits = hits + 1 WHERE id = " . $id . "";
    $database->setQuery($sql);
    $database->query();
    $database->setQuery("SELECT url FROM #__weblinks WHERE id = " . $id . "");
    $url = $database->loadResult();
    mosRedirect($url);
    listWeblinks($catid);
}