Exemplo n.º 1
0
session_start();
// if user is not login..redirect him to login page
if (!isset($_SESSION['login'])) {
    header('Location: login.php');
}
if (isset($_SESSION['login'])) {
    $userID = $_SESSION['userID'];
    $usertype = $_SESSION['usertype'];
}
$db = new database();
if (isset($_POST['cid'])) {
    $n = count($_POST['cid']);
    for ($i = 0; $i < $n; $i++) {
        foreach ($_POST['cid'] as $key => $value) {
            if ($key == $i) {
                $x = getArticle_category($value);
                $catname = getCategory_info($value, 'category_name');
                if (count($x) > 0) {
                    // if this category contains an articles then,,,
                    echo '<script>alert( "Sorry, you cannot delete the ' . $catname . ' category because it contains some articles. " );history.go(-1);</script>';
                } else {
                    // else lets f*** him!!!
                    $sql = " delete from category where categoryID = '{$value}' ";
                    $db->query($sql);
                    $_SESSION['catnames'][$i] = $catname;
                    $_SESSION['task'] = 'delete';
                }
            }
        }
    }
}
Exemplo n.º 2
0
    if ($category[$i]->categoryID) {
        $i % 2 == 0 ? $bgcolor = "" : ($bgcolor = "#F5F5F5");
        $row_data .= '<tr class="tdhover" bgcolor = "' . $bgcolor . '">';
        $row_data .= '<td>';
        $row_data .= $j++;
        $row_data .= '</td>';
        $row_data .= '<td>';
        $row_data .= '<input type="checkbox" name="cid[]" id="cb' . $i . '" value="' . $category[$i]->categoryID . '" onClick="isChecked(this.checked);"/>';
        $row_data .= '</td>';
        $row_data .= '<td>';
        $row_data .= '<a href="' . VIEW_CATEGORY_DETAIL_URL . $category[$i]->categoryID . '">';
        $row_data .= $category[$i]->category_name;
        $row_data .= '</a>';
        $row_data .= '</td>';
        $row_data .= '<td>';
        $row_data .= $category[$i]->category_desc;
        $row_data .= '</td>';
        $row_data .= '<td align="left">';
        $x = getArticle_category($category[$i]->categoryID);
        $row_data .= count($x);
        $row_data .= '</td>';
        $row_data .= '<td>&nbsp;';
        $row_data .= '</td>';
        $row_data .= '</tr>';
    }
}
// start compiling the page..
$tpl = new template_parser('../templates/category_manager.tpl.php');
$tags = array('{CATEGORY_NAME}' => 'Category Name', '{CATEGORY_DESC}' => 'Category Description', '{NO_OF_ARTICLES}' => 'Total # of Articles', '{NUMITEMS}' => '' . $totalrows, '{TABLE_DATA}' => $row_data, '{MESSAGE}' => $message, '{PAGELINK}' => $pagelink->pagelinks, '{SITENAME}' => 'CMS Adminss', '{HEADER}' => ' ', '{TOPNAV}' => 'top_menu.php', '{CONTENT}' => $row_data, '{FOOTER}' => 'footer.php');
$tpl->parse_template($tags);
print $tpl->display();