* http://ifsoft.com.ua, http://ifsoft.co.uk * qascript@ifsoft.co.uk * * Copyright 2012-2016 Demyanchuk Dmitry (https://vk.com/dmitry.demyanchuk) */ include_once $_SERVER['DOCUMENT_ROOT'] . "/core/init.inc.php"; include_once $_SERVER['DOCUMENT_ROOT'] . "/config/api.inc.php"; $result = array("error" => true); if (!empty($_POST)) { $accountId = isset($_POST['accountId']) ? $_POST['accountId'] : ''; $accessToken = isset($_POST['accessToken']) ? $_POST['accessToken'] : ''; $auth = new auth($dbo); if (!$auth->authorize($accountId, $accessToken)) { api::printError(ERROR_ACCESS_TOKEN, "Error authorization."); } if (isset($_FILES['uploaded_file']['name'])) { $currentTime = time(); $uploaded_file_ext = @pathinfo($_FILES['uploaded_file']['name'], PATHINFO_EXTENSION); if (@move_uploaded_file($_FILES['uploaded_file']['tmp_name'], "../../" . TEMP_PATH . "{$currentTime}." . $uploaded_file_ext)) { $response = array(); $imgLib = new imglib($dbo); $response = $imgLib->createMyPhoto("../../" . TEMP_PATH . "{$currentTime}." . $uploaded_file_ext); if ($response['error'] === false) { $result = array("error" => false, "originPhotoUrl" => $response['originPhotoUrl'], "normalPhotoUrl" => $response['normalPhotoUrl'], "previewPhotoUrl" => $response['previewPhotoUrl']); } unset($imgLib); } } echo json_encode($result); exit; }
$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); }
$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->createPhoto("../../" . TEMP_PATH . "{$time}." . $uploaded_file_ext); unset($imglib); if ($response['error'] === false) { $account = new account($dbo, $accountId); $account->setPhoto($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); }