Beispiel #1
0
if (preg_match("/^([a-zA-Z0-9_-])+@([a-zA-Z0-9_-])+((\\.[a-zA-Z0-9_-]{2,3}){1,2})\$/", $username)) {
    $query = $_SGLOBAL['db']->query("select uid,username from " . UC_DBTABLEPRE . "members where email='" . $username . "' and password=md5(concat('" . $password . "',salt))");
} else {
    $query = $_SGLOBAL['db']->query("select uid from " . UC_DBTABLEPRE . "members where username='******' and password=md5(concat('" . $password . "',salt))");
}
/*$username = '******';
	$password = '******';*/
//通过多重md5加密在ihomeuser_members表中查询用户
if ($value = $_SGLOBAL['db']->fetch_array($query)) {
    $uid = $value['uid'];
    $sessionid = session_id();
    //echo $sessionid."aaaaa";exit();
    $_SESSION['username'] = $username;
    $arr = array('flag' => 'success', 'uid' => $uid, 'username' => $username, 'sessionid' => $sessionid);
    //Check the user who have logined the ihome since the user had been created.
    $query1 = $_SGLOBAL['db']->query("SELECT password FROM " . tname('member') . " WHERE uid='{$uid}'");
    if ($value = $_SGLOBAL['db']->fetch_array($query1)) {
        $password1 = addslashes($value['password']);
        $setarr = array('uid' => $uid, 'username' => $username, 'password' => $password1);
        insertsession($setarr);
    } else {
        returnerror();
    }
} else {
    returnerror();
}
echo json_encode($arr);
function returnerror()
{
    $arr = array('flag' => 'failed', 'uid' => 0, 'username' => 0, 'sessionid' => 0);
}
Beispiel #2
0
if ($_FILES['___uploadfile']['error'] == UPLOAD_ERR_PARTIAL) {
    returnerror('The uploaded file was only partially uploaded. ');
}
// 3
if ($_FILES['___uploadfile']['error'] == UPLOAD_ERR_NO_FILE) {
    returnerror('No file was uploaded. ');
}
// 4
if ($_FILES['___uploadfile']['error'] == UPLOAD_ERR_NO_TMP_DIR) {
    returnerror('Missing a temporary folder.');
}
// 6
if ($_FILES['___uploadfile']['error'] == UPLOAD_ERR_CANT_WRITE) {
    returnerror('Failed to write file to disk.');
}
// 7
if ($_FILES['___uploadfile']['error'] == UPLOAD_ERR_EXTENSION) {
    returnerror('A PHP extension stopped the file upload.');
}
// 8
// basedir needs to start with a '/'.
if ($_POST['basedir'][0] != '/') {
    $_POST['basedir'] = '/' . $_POST['basedir'];
}
// Guess I should do the save now that all checks have passed...
$image = @FileManager::MoveUpload($_FILES['___uploadfile']['tmp_name'], TYPEF_DIR . $_POST['basedir'] . '/' . $_FILES['___uploadfile']['name']);
if (!$image) {
    returnerror('Unable to move uploaded file to ' . $_POST['basedir']);
}
// Must have went through.
die(json_encode(array('status' => 1, 'filename' => $image, 'basename' => basename($image))));