Example #1
0
function Register($data)
{
    $data['password'] = md5($data['password']);
    $data['create_at'] = now();
    $data['update_at'] = now();
    $data['create_ip'] = ip();
    $userid = db_new("user", $data);
    if ($userid) {
        $userinfo = GetInfo($userid);
        $token = Crypt3Des::encrypt(json_encode($userinfo), $GLOBALS['keys']);
        return ErrorCode::CODE("1002", array("token" => urlencode($token)));
    } else {
        return ErrorCode::CODE("1003");
    }
}
Example #2
0
define('BBS_PATH', XIUNO_BBS_2_PATH);
$tablepre = 'bbs_';
define('APP_NAME', 'convert');
!is_dir(XIUNO_BBS_2_PATH) and exit('请修改源代码,设置 XiunoBBS 2.1 的目录。');
!is_dir(XIUNO_BBS_3_PATH) and exit('请修改源代码,设置 XiunoBBS 3.0 的目录。');
$conf = (include XIUNO_BBS_3_PATH . 'conf/conf.php');
$oldconf = (include XIUNO_BBS_2_PATH . 'conf/conf.php');
include './xiunophp/xiunophp.php';
!empty($_SERVER['REMOTE_ADDR']) and exit('本升级程序需要在命令行下执行,不支持 WEB 访问。');
$dbconf = $conf['db'][$conf['db']['type']]['master'];
$olddbconf = $oldconf['db'][$oldconf['db']['type']]['master'];
if ($dbconf['host'] == $olddbconf['host'] && $dbconf['name'] == $olddbconf['name']) {
    exit('不能再同一个数据库里升级,否则数据会被清空!请将新论坛安装到其他数据库。');
}
empty($oldconf) and exit('配置文件读取失败');
$olddb = db_new($oldconf['db']);
$db->connect() or exit('连接数据库服务器失败:' . $db->errstr);
$olddb->connect() or exit('连接数据库服务器失败:' . $olddb->errstr);
echo "upgrade group:\r\n";
$grouplist = $olddb->find("SELECT * FROM {$tablepre}group");
$db->exec("TRUNCATE `bbs_group`");
foreach ($grouplist as $group) {
    $group['groupid'] > 10 && ($group['groupid'] += 90);
    $arr = array('gid' => $group['groupid'], 'name' => $group['name'], 'agreesfrom' => $group['creditsfrom'], 'agreesto' => $group['creditsto'], 'maxagrees' => $group['maxcredits'], 'allowread' => $group['allowread'], 'allowthread' => $group['allowthread'], 'allowpost' => $group['allowpost'], 'allowattach' => $group['allowattach'], 'allowdown' => $group['allowdown'], 'allowtop' => $group['allowtop'], 'allowupdate' => $group['allowupdate'], 'allowdelete' => $group['allowdelete'], 'allowmove' => $group['allowmove'], 'allowbanuser' => $group['allowbanuser'], 'allowdeleteuser' => $group['allowdeleteuser'], 'allowviewip' => $group['allowviewip']);
    $sqladd = array_to_sqladd($arr);
    $r = $db->exec("INSERT INTO `bbs_group` SET {$sqladd}");
    echo ".";
}
echo "[ok]\r\n";
unset($grouplist);
echo "upgrade user:\r\n";
Example #3
0
// $_SERVER['REQUEST_METHOD'] === 'PUT' ? @parse_str(file_get_contents('php://input', false , null, -1 , $_SERVER['CONTENT_LENGTH']), $_PUT) : $_PUT = array(); // 不需要支持 PUT
$ajax = isset($_SERVER['HTTP_X_REQUESTED_WITH']) && strtolower(trim($_SERVER['HTTP_X_REQUESTED_WITH'])) == 'xmlhttprequest';
$method = $_SERVER['REQUEST_METHOD'];
$errno = 0;
$errstr = '';
// error_handle
// register_shutdown_function('shutdown_handle');
set_error_handler('error_handle', -1);
date_default_timezone_set($conf['timezone']);
// 超级全局变量
$_GET += init_query_string();
$_REQUEST = array_merge($_COOKIE, $_POST, $_GET);
// 初始化 db cache,这里并没有连接,在获取数据的时候会自动连接。
include './xiunophp/db.class.php';
include './xiunophp/cache.class.php';
$db = db_new($conf['db']);
$cache = cache_new($conf['cache']);
$db->errno and message(-1, $db->errstr);
// 安装的时候检测过了,不必每次都检测。但是要考虑环境移植。
$cache and $cache->errno and message(-1, $cache->errstr);
// ----------------------------------------------------------> 全局变量申明结束
// ----------------------------------------------------------> 全局函数
// 此处不利于 HHVM,应该强制要求 APP 定义 message 函数,为了正确性,暂时如此。
if (!function_exists('message')) {
    function message($code, $message)
    {
        global $ajax;
        echo $ajax ? xn_json_encode(array('code' => $code, 'message' => $message)) : $message;
        exit;
    }
}
Example #4
0
$ajax = isset($_SERVER['HTTP_X_REQUESTED_WITH']) && strtolower(trim($_SERVER['HTTP_X_REQUESTED_WITH'])) == 'xmlhttprequest';
$method = $_SERVER['REQUEST_METHOD'];
$errno = 0;
$errstr = '';
// error_handle
// register_shutdown_function('shutdown_handle');
set_error_handler('error_handle', -1);
empty($conf['timezone']) and $conf['timezone'] = 'Asia/Shanghai';
date_default_timezone_set($conf['timezone']);
// 超级全局变量
$_GET += init_query_string();
$_REQUEST = array_merge($_COOKIE, $_POST, $_GET);
// 初始化 db cache,这里并没有连接,在获取数据的时候会自动连接。
include './xiunophp/db.class.php';
include './xiunophp/cache.class.php';
$db = !empty($conf['db']) ? db_new($conf['db']) : NULL;
$cache = !empty($conf['cache']) ? cache_new($conf['cache']) : NULL;
$db and $db->errno and xn_message(-1, $db->errstr);
// 安装的时候检测过了,不必每次都检测。但是要考虑环境移植。
$cache and $cache->errno and xn_message(-1, $cache->errstr);
// ----------------------------------------------------------> 全局变量申明结束
// ----------------------------------------------------------> 全局函数
if (!function_exists('message')) {
    // 此处不利于 HHVM,应该强制要求 APP 定义 message 函数,为了正确性,暂时如此。
    function message($code, $message)
    {
        xn_message($code, $message);
    }
}
// 此处不利于 HHVM,应该强制要求 APP 定义 message 函数,为了正确性,暂时如此。
function xn_message($code, $message)
Example #5
0
function addKeys($data)
{
    return db_new("keys", $data);
}