$auth = new auth($dbo);
    if (!$auth->authorize($accountId, $accessToken)) {
        api::printError(ERROR_ACCESS_TOKEN, "Error authorization.");
    }
    if (isset($_FILES['uploaded_file']['name'])) {
        $uploaded_file = $_FILES['uploaded_file']['tmp_name'];
        $uploaded_file_name = basename($_FILES['uploaded_file']['name']);
        $uploaded_file_ext = pathinfo($_FILES['uploaded_file']['name'], PATHINFO_EXTENSION);
        try {
            $time = time();
            if (!move_uploaded_file($_FILES['uploaded_file']['tmp_name'], "../../" . TEMP_PATH . "{$time}." . $uploaded_file_ext)) {
                // make error flag true
                $response['error'] = true;
                $response['message'] = 'Could not move the file!';
            }
            $imgLib = new imglib($dbo);
            $response = $imgLib->createCover("../../" . TEMP_PATH . "{$time}." . $uploaded_file_ext, "../../" . TEMP_PATH . "{$time}." . $uploaded_file_ext);
            unset($imgLib);
            if ($response['error'] === false) {
                $account = new account($dbo, $accountId);
                $account->setCover($response);
            }
        } catch (Exception $e) {
            // Exception occurred. Make error flag true
            $response['error'] = true;
            $response['message'] = $e->getMessage();
        }
    }
    // Echo final json response to client
    echo json_encode($response);
}
示例#2
0
     break;
 case "unverify":
     $account->setVerify(0);
     header("Location: /admin/profile.php/?id=" . $accountInfo['id']);
     break;
 case "ghost_set":
     $account->setGhost(1);
     header("Location: /admin/profile.php/?id=" . $accountInfo['id']);
     break;
 case "ghost_unset":
     $account->setGhost(0);
     header("Location: /admin/profile.php/?id=" . $accountInfo['id']);
     break;
 case "delete-cover":
     $data = array("originCoverUrl" => '', "normalCoverUrl" => '');
     $account->setCover($data);
     header("Location: /admin/profile.php/?id=" . $accountInfo['id']);
     break;
 case "delete-photo":
     $data = array("originPhotoUrl" => '', "normalPhotoUrl" => '', "lowPhotoUrl" => '');
     $account->setPhoto($data);
     header("Location: /admin/profile.php/?id=" . $accountInfo['id']);
     break;
 default:
     if (!empty($_POST)) {
         $authToken = isset($_POST['authenticity_token']) ? $_POST['authenticity_token'] : '';
         $username = isset($_POST['username']) ? $_POST['username'] : '';
         $fullname = isset($_POST['fullname']) ? $_POST['fullname'] : '';
         $location = isset($_POST['location']) ? $_POST['location'] : '';
         $balance = isset($_POST['balance']) ? $_POST['balance'] : 0;
         $fb_page = isset($_POST['fb_page']) ? $_POST['fb_page'] : '';