Exemplo n.º 1
0
/**
 *
 *
 * @param unknown $params
 * @param unknown $bBlog  (reference)
 * @return unknown
 */
function smarty_function_links($params, &$bBlog)
{
    $markedlinks = '';
    if (!isset($params['sep'])) {
        $sep = "<br />";
    } else {
        $sep = $params['sep'];
    }
    if (isset($params['presep'])) {
        $presep = $params['presep'];
    }
    // use this for lists
    if (isset($params['desc'])) {
        $asde = "DESC";
    } else {
        $asde = "";
    }
    if (isset($params['ord'])) {
        $order = $params['ord'];
    } else {
        $order = "position";
    }
    if (isset($params['num'])) {
        $max = $params['num'];
    } else {
        $max = "20";
    }
    if (isset($params['cat'])) {
        $cat = $bBlog->get_var("select categoryid from " . T_CATEGORIES . " where name='" . $params['cat'] . "'");
    }
    if (isset($params['notcat'])) {
        $notcat = $bBlog->get_var("select categoryid from " . T_CATEGORIES . " where name='" . $params['notcat'] . "'");
    }
    if ($cat) {
        $links = $bBlog->get_results("select * from " . T_LINKS . " where category='" . $cat . "' order by " . $order . " " . $asde . " limit " . $max);
    } elseif ($notcat) {
        $links = $bBlog->get_results("select * from " . T_LINKS . " where category !='" . $notcat . "' order by " . $order . " " . $asde . " limit " . $max);
    } else {
        $links = $bBlog->get_results("select * from " . T_LINKS . " order by " . $order . " " . $asde . " limit " . $max);
    }
    if (!empty($links)) {
        foreach ($links as $link) {
            $url = $link->url;
            $nicename = $link->nicename;
            $markedlinks .= $presep . '<a href="' . $url . '">' . $nicename . '</a>' . $sep;
        }
    }
    return $markedlinks;
}
Exemplo n.º 2
0
/**
 *
 *
 * @param unknown $bBlog (reference)
 * @param unknown $id
 */
function deleteComment(&$bBlog, $id)
{
    $id = intval($id);
    $postid = $bBlog->get_var('select postid from ' . T_COMMENTS . ' where commentid="' . $id . '"');
    $childcount = $bBlog->get_var('select count(*) as c from ' . T_COMMENTS . ' where parentid="' . $id . '" group by commentid');
    if ($childcount > 0) {
        // there are replies to the comment so we can't delete it.
        $bBlog->query('update ' . T_COMMENTS . ' set deleted="true", postername="", posteremail="", posterwebsite="", pubemail=0, pubwebsite=0, commenttext="Deleted Comment" where commentid="' . $val . '"');
    } else {
        // just delete the comment
        $bBlog->query('delete from ' . T_COMMENTS . ' where commentid="' . $id . '"');
    }
    $newnumcomments = $bBlog->get_var('SELECT count(*) as c FROM ' . T_COMMENTS . ' WHERE postid="' . $postid . '" and deleted="false" group by postid');
    $bBlog->query('update ' . T_POSTS . ' set commentcount="' . $newnumcomments . '" where postid="' . $postid . '"');
    $bBlog->modifiednow();
}
Exemplo n.º 3
0
/**
 *
 *
 * @param unknown $bBlog (reference)
 */
function admin_plugin_links_run(&$bBlog)
{
    if (isset($_GET['linkdo'])) {
        $linkdo = $_GET['linkdo'];
    } elseif (isset($_POST['linkdo'])) {
        $linkdo = $_POST['linkdo'];
    } else {
        $linkdo = '';
    }
    switch ($linkdo) {
        case "New":
            // add new link
            $maxposition = $bBlog->get_var("select position from " . T_LINKS . " order by position desc limit 0,1");
            $position = $maxposition + 10;
            $bBlog->query("insert into " . T_LINKS . "\n            set nicename='" . my_addslashes($_POST['nicename']) . "',\n            url='" . my_addslashes($_POST['url']) . "',\n            category='" . my_addslashes($_POST['category']) . "',\n\t    position='{$position}'");
            break;
        case "Delete":
            // delete link
            $bBlog->query("delete from " . T_LINKS . " where linkid=" . $_POST['linkid']);
            break;
        case "Save":
            // update an existing link
            $bBlog->query("update " . T_LINKS . "\n            set nicename='" . my_addslashes($_POST['nicename']) . "',\n            url='" . my_addslashes($_POST['url']) . "',\n            category='" . my_addslashes($_POST['category']) . "'\n            where linkid=" . $_POST['linkid']);
            break;
        case "Up":
            $bBlog->query("update " . T_LINKS . " set position=position-15 where linkid=" . $_POST['linkid']);
            reorder_links();
            break;
        case "Down":
            $bBlog->query("update " . T_LINKS . " set position=position+15 where linkid=" . $_POST['linkid']);
            reorder_links();
            break;
        default:
            // show form
            break;
    }
    if (isset($_GET['catdo'])) {
        $catdo = $_GET['catdo'];
    } elseif (isset($_POST['catdo'])) {
        $catdo = $_POST['catdo'];
    } else {
        $catdo = '';
    }
    switch ($catdo) {
        case "New":
            // add new category
            $bBlog->query("insert into " . T_CATEGORIES . "\n            set name='" . my_addslashes($_POST['name']) . "'");
            break;
        case "Delete":
            // delete category
            // have to remove all references to the category in the links
            $bBlog->query("update " . T_LINKS . "\n            set linkid=0 where linkid=" . $_POST['categoryid']);
            // delete the category
            $bBlog->query("delete from " . T_CATEGORIES . " where categoryid=" . $_POST['categoryid']);
            break;
        case "Save":
            // update an existing category
            $bBlog->query("update " . T_CATEGORIES . "\n            set name='" . my_addslashes($_POST['name']) . "'\n            where categoryid=" . $_POST['categoryid']);
            break;
        default:
            // show form
            break;
    }
    $bBlog->assign('ecategories', $bBlog->get_results("select * from " . T_CATEGORIES));
    $bBlog->assign('elinks', $bBlog->get_results("select * from " . T_LINKS . " order by position"));
}