示例#1
0
function do_edit_save($aid, $params)
{
    $uid = false;
    if (array_key_exists('id', $params)) {
        $uid = $params['id'];
        $pass = trim($params['password']);
        unset($params['password']);
        cf\api\admin\doAction($aid, $params);
        if ($pass) {
            cf\User::setPassword($uid, $pass);
        }
    } else {
        $uid = cf\User::register($params['login'], $params['password'], $params['name'], $params['email'], $params['descr']);
    }
    if (cf\param::exist('roles')) {
        $roles = array_keys(cf\param::get('roles'));
        cf\execQuery('DELETE FROM cf_user_roles WHERE user_id=:uid', array('uid' => $uid));
        $q = cf\createQuery('INSERT INTO cf_user_roles (user_id,role_id) VALUES(:userId,:roleId)');
        $q->setParam('userId', $uid);
        foreach ($roles as $rid) {
            $q->setParam('roleId', $rid);
            $q->execute();
        }
    }
}
示例#2
0
文件: index.php 项目: sd-studio/sh
        $db = new cf\Database('mysql:host=' . cf\Config::host, cf\Config::user, cf\Config::pass, 'utf8');
        $q = new cf\Query($db);
        $q->exec("\r\n\t\t\tDROP DATABASE IF EXISTS {$dbName};\r\n\t\t\tCREATE DATABASE {$dbName} DEFAULT CHARACTER SET utf8;\r\n\t\t\tUSE {$dbName};\r\n\t\t");
    }
    require_once dirname(__FILE__) . '/../db.php';
    require_once dirname(__FILE__) . '/../user.php';
    if (array_key_exists('modules', $_POST)) {
        foreach ($_POST['modules'] as $module) {
            $sqlFiles[] = $module;
        }
    }
    foreach ($sqlFiles as $f) {
        $sql = 'SET storage_engine=MYISAM;' . file_get_contents(dirname(__FILE__) . "/{$f}.sql");
        cf\execQuery($sql);
    }
    cf\User::register('admin', 'admin', 'Admin');
    cf\execQuery("\r\n\t\tINSERT INTO cf_roles (id,name) VALUES('admin','Администраторы');\r\n\t\tINSERT INTO cf_user_roles (role_id,user_id) VALUES('admin',1);\r\n\t\tINSERT INTO cf_role_view_grants   (view_id,   role_id, can_read)    VALUES (NULL,'admin',1);\r\n\t\tINSERT INTO cf_role_action_grants (action_id, role_id, can_execute) VALUES (NULL,'admin',1);\r\n\t");
    if ($_REQUEST['run_install_sql']) {
        cf\execQuery('SET storage_engine=MYISAM;' . file_get_contents($_SERVER['DOCUMENT_ROOT'] . '/install.sql'));
    }
    if ($_REQUEST['run_install_php']) {
        require_once $_SERVER['DOCUMENT_ROOT'] . '/install.php';
    }
} else {
    if (array_key_exists('cf_install_db', $_SESSION)) {
        $dbName = $_SESSION['cf_install_db'];
    }
    if (array_key_exists('cf_install_create_db', $_SESSION)) {
        $createDB = (bool) $_SESSION['cf_install_create_db'];
    }
    if (array_key_exists('cf_install_host', $_SESSION)) {
示例#3
0
文件: login.php 项目: sd-studio/or
define('NO_AUTH', 1);
require_once 'core.php';
$err = '';
$user = cf\User::getLoggedIn();
if (cf\param::exist('logout')) {
    if ($user) {
        $user->logout();
    }
} elseif ($user) {
    forward(cf\param::exist('referer') ? cf\param::asString('referer') : 'index.php');
} elseif (cf\param::exist('log')) {
    $log = cf\param::asString('log');
    $pwd = cf\param::asString('pwd');
    try {
        if ($log && $pwd && cf\User::login($log, $pwd, cf\param::exist('remember'))) {
            forward(cf\param::exist('referer') ? cf\param::asString('referer') : 'index.php');
        }
    } catch (Exception $e) {
        switch ($e->getCode()) {
            case cf\User::ERR_INVALID_USER:
                $err = 'Неправильное имя пользователя';
                break;
            case cf\User::ERR_PASSWORD_INCORRECT:
                $err = 'Неправильный пароль';
                break;
        }
    }
}
$smarty->assign('errMsg', $err);
$smarty->display('login.tpl');
示例#4
0
文件: core.php 项目: sd-studio/sh
require_once dirname(__FILE__) . '/../config.php';
require_once cf\Config::path . 'param.php';
require_once cf\Config::path . 'user.php';
require_once cf\Config::path . 'image.php';
require_once cf\Config::path . 'api/session.php';
require_once cf\Config::path . 'api/admin.php';
if (cf\Config::use_imagemagick) {
    cf\Image::$USE_IMAGEMAGICK = true;
}
function forward($url)
{
    session_write_close();
    header("Location: {$url}");
    exit;
}
$user = cf\User::getLoggedIn();
if (!$user && !defined('NO_AUTH')) {
    forward('login.php');
}
if (!defined('SMARTY_DIR')) {
    define('SMARTY_DIR', cf\Config::smarty_dir);
}
require_once SMARTY_DIR . 'Smarty.class.php';
$smarty = new Smarty();
$smarty->compile_check = true;
$smarty->debugging = false;
$smarty->addPluginsDir(cf\Config::path . 'components/');
$root_url = substr($_SERVER['REQUEST_URI'], 0, stripos($_SERVER['REQUEST_URI'], 'admin') + 6);
if ($user) {
    $uprofile = cf\query2array("SELECT desktop_url,hide_navigation FROM cf_users WHERE id=:id", array('id' => $user->id()));
    if ($uprofile['desktop_url']) {