<?php
/*
@author waychar
@技术支持 150572314@qq.com
@copyright 2018 waychar.cn 声明：本代码可以用于学习交流使用及要商业化用途
*/

require_once 'model/admin.php';

$admin = new admin();

if ($action == 'newsmenu') {
    $prv_menu = $admin->getPrvmenu(6);
    $menu_list = $admin->getAdminNewsMenu();
    include 'view/top_mini.php';
    include 'view/admin_top.php';
    include 'view/admin_news_menu.php';
    include 'view/bottom.php';
} elseif ($action == "newsmenuadd") {
    $menu_name = get($_REQUEST['menu_name']);
    $prv_menu_id = get($_REQUEST['prv_menu_id']);

    $sql = "insert into news_menu (menu_name,prv_menu_id,create_time) values ('$menu_name',$prv_menu_id," . time() . ")";

    $admin->query($sql);
    go("index.php?c=admin&action=newsmenu");
} elseif ($action == "newsmenuedit") {
    $menu_id = get($_REQUEST['menu_id']);
    $menu_name = get($_REQUEST['menu_name']);
    $prv_menu_id = get($_REQUEST['prv_menu_id']);

    $sql = "update news_menu set menu_name = '$menu_name',prv_menu_id = $prv_menu_id where menu_id = $menu_id";

    $admin->query($sql);
    go("index.php?c=admin&action=newsmenu");
} elseif ($action == "news") {
    $sql ="select id,title,add_time from artile order by id desc limit 0,10";
    $result =$admin->get_data($sql);
    include 'view/admin_top.php';
    include 'view/admin_news_list.php';
    include 'view/bottom.php';
}
elseif ($action == "news_add") {
    $sql ="select id,title,add_time from artile order by id desc limit 0,10";
    $result = $admin->get_data($sql);
    include 'view/admin_top.php';
    include 'view/admin_news_form.php';
    include 'view/bottom.php';
}