Exemple #1
0
function add_admin()
{
    global $global, $smarty;
    $adm_username = post('adm_username');
    $adm_password = post('adm_password');
    $re_password = post('re_password');
    $obj = new admin();
    $obj->set_where('adm_id = ' . $global['admin_id']);
    $one = $obj->get_one();
    $adm_grade = $one['adm_grade'] + 1;
    $obj->set_where('');
    $obj->set_where("adm_username = '******'");
    if ($obj->get_count() == 0 && strlen($adm_username) >= 5 && strlen($adm_password) >= 5 && $adm_password == $re_password) {
        $obj->set_value('adm_username', $adm_username);
        $obj->set_value('adm_password', md5($adm_password));
        $obj->set_value('adm_grade', $adm_grade);
        $obj->add();
        $info_text = '添加管理员帐号成功';
        $link_text = '返回列表页';
        $link_href = url(array('channel' => 'basic', 'mod' => 'admin_list'));
    } else {
        $info_text = '添加管理员帐号失败';
        $link_text = '返回上一页';
        $link_href = url(array('channel' => 'basic', 'mod' => 'admin_add'));
    }
    $smarty->assign('info_text', $info_text);
    $smarty->assign('link_text', $link_text);
    $smarty->assign('link_href', $link_href);
}
Exemple #2
0
$menus = array(array('添加管理员', '?moduleid=' . $moduleid . '&file=' . $file . '&action=add'), array('管理员管理', '?moduleid=' . $moduleid . '&file=' . $file));
$this_forward = '?file=' . $file;
switch ($action) {
    case 'add':
        if ($submit) {
            $admin = $admin == 1 ? 1 : 2;
            if ($do->set_admin($username, $admin, $role, $aid)) {
                $r = $do->get_one($username);
                $userid = $r['userid'];
                if ($r['admin'] == 2) {
                    foreach ($MODULE as $m) {
                        if (isset($roles[$m['moduleid']])) {
                            $right = array();
                            $right['title'] = $m['name'] . '管理';
                            $right['url'] = '?moduleid=' . $m['moduleid'];
                            $do->add($userid, $right, $admin);
                        }
                    }
                    if (isset($roles['database'])) {
                        $right = array();
                        $right['title'] = '数据库管理';
                        $right['url'] = '?file=database';
                        $do->add($userid, $right, $admin);
                    }
                    if (isset($roles['template'])) {
                        $right = array();
                        $right['title'] = '模板管理';
                        $right['url'] = '?file=template';
                        $do->add($userid, $right, $admin);
                        $right = array();
                        $right['title'] = '风格管理';