Ejemplo n.º 1
0
 * 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->createChatImg("../../" . TEMP_PATH . "{$currentTime}." . $uploaded_file_ext, "../../" . TEMP_PATH . "{$currentTime}." . $uploaded_file_ext);
            if ($response['error'] === false) {
                $result = array("error" => false, "imgUrl" => $response['imgUrl']);
            }
            unset($imgLib);
        }
    }
    echo json_encode($result);
    exit;
}