예제 #1
0
파일: common.php 프로젝트: npk/ones
function check_db_connection($db_config)
{
    $dsn = sprintf('mysql:host=%s;dbname=%s;port=%s', $db_config['host'], $db_config['name'], $db_config['port']);
    try {
        $pdo = new PDO($dsn, $db_config['user'], $db_config['pass']);
    } catch (PDOException $e) {
        send_exit_single($e->getMessage());
        return;
    }
    $mysql_version = $pdo->getAttribute(PDO::ATTR_SERVER_VERSION);
    if (version_compare($mysql_version, '5.6.5', '<')) {
        send_exit_single('need mysql version >= 5.6.5');
        return;
    }
    return $pdo;
}
예제 #2
0
파일: install.php 프로젝트: chinapaul/ones
$sql = "SELECT * FROM auth_node WHERE node = 'account.authorize.put'";
$sth = $pdo->query($sql);
$sth->execute();
$auth_node = $sth->fetch(PDO::FETCH_ASSOC);
if (!$auth_node) {
    rollback($pdo);
    return send_exit_single('user role authorize failed (fetch auth node).');
}
$sql = "INSERT INTO authorize(flag, company_id, auth_role_id, auth_node_id)VALUE(1, :company_id, :auth_role_id, :auth_node_id)";
$prepared = $pdo->prepare($sql);
$prepared->bindParam(':company_id', $company_id);
$prepared->bindParam(':auth_role_id', $auth_role_id);
$prepared->bindParam(':auth_node_id', $auth_node['id']);
if (!$prepared->execute()) {
    rollback($pdo);
    return send_exit_single('user role authorize failed (authorize).');
}
// 创建session表
$pdo->exec("CREATE TABLE IF NOT EXISTS `session` (\n  `session_id` varchar(255) NOT NULL,\n  `session_expire` int(11) NOT NULL,\n  `session_data` blob,\n  UNIQUE KEY `session_id` (`session_id`)\n) ENGINE=InnoDB DEFAULT CHARSET=utf8;");
// 写应用表
$sql = "INSERT INTO app(alias, requirements)VALUES(:alias, :requirements)";
$prepared = $pdo->prepare($sql);
foreach ($apps as $alias => $app_config) {
    $requirements = $app_config['requirements'];
    $prepared->bindParam(':alias', $alias);
    $prepared->bindParam(':requirements', $requirements);
    $prepared->execute();
}
display_loading('initialize company and super-user', 5);
file_put_contents(ENTRY_PATH . '/Data/install.lock', time());
echo "\n\n";