if ($user->login_hash == $login_hash) {
            $controllerPhoto->deletePhoto($photo_id, 1);
            $json = "{\n                    \"photo_realestate_info\" : {\n                                  \"photo_id\" : \"{$photo_id}\",\n                                  \"is_deleted\" : \"1\"\n                                  },\n                    \"status\" : {\n                                  \"status_code\" : \"-1\",\n                                  \"status_text\" : \"Success.\"\n                                }\n                    }";
        } else {
            $json = "{\n                        \"status\" : {\n                                      \"status_code\" : \"5\",\n                                      \"status_text\" : \"It seems you are out of sync. Please relogin again.\"\n                                    }\n                        }";
        }
    } else {
        $json = "{\n                  \"status\" : {\n                                \"status_code\" : \"5\",\n                                \"status_text\" : \"It seems you are out of sync. Please relogin again.\"\n                              }\n                  }";
    }
} else {
    if (!empty($realestate_id) && !empty($photo_id) >= 0 && !empty($login_hash) && !empty($user_id)) {
        $user = $controllerUser->getUserByUserId($user_id);
        $login_hash = str_replace(" ", "+", $login_hash);
        if ($user != null) {
            if ($user->login_hash == $login_hash) {
                $photo = $controllerPhoto->getPhotoByPhotoId($photo_id);
                $itm = new Photo();
                $itm->photo_id = $photo_id;
                $itm->photo_url = $photo_url;
                $itm->thumb_url = $thumb_url;
                $itm->created_at = time();
                $itm->updated_at = time();
                $itm->realestate_id = $realestate_id;
                if (!empty($_FILES["thumb_file"]["name"]) && !empty($_FILES["photo_file"]["name"])) {
                    $desired_dir = IMAGE_UPLOAD_DIR;
                    $desired_dir_path = "../" . IMAGE_UPLOAD_DIR;
                    if (is_dir($desired_dir_path) == false) {
                        // Create directory if it does not exist
                        mkdir("{$desired_dir_path}", 0700);
                    }
                    $id = uniqid();
Esempio n. 2
0
<?php

require_once 'header.php';
$controller = new ControllerPhoto();
$controllerStore = new ControllerStore();
$extras = new Extras();
$photo_id = $extras->decryptQuery1(KEY_SALT, $_SERVER['QUERY_STRING']);
if ($photo_id != null) {
    $photo_store = $controller->getPhotoByPhotoId($photo_id);
    $viewUrl = $extras->encryptQuery1(KEY_SALT, 'store_id', $photo_store->store_id, 'photo_store_view.php');
    if (isset($_POST['url_upload'])) {
        $itm = new Photo();
        $itm->photo_url = trim($_POST['photo_url']);
        $itm->thumb_url = trim($_POST['thumb_url']);
        $itm->store_id = $photo_store->store_id;
        $itm->photo_id = $photo_store->photo_id;
        $controller->updatePhoto($itm);
        echo "<script type='text/javascript'>location.href='{$viewUrl}';</script>";
    }
    if (isset($_POST['file_upload'])) {
        $count = count($_FILES["file"]["name"]);
        if (!empty($_FILES["file"]["name"][0]) && !empty($_FILES["file"]["name"][1])) {
            uploadFile($controller, $photo_store);
        } else {
            echo "<script>alert('You must provide both Photo and Thumbnail file.');</script>";
        }
    }
} else {
    echo "<script type='text/javascript'>location.href='403.php';</script>";
}
?>
<?php

require_once 'header.php';
$controller = new ControllerPhoto();
$controllerRealEstate = new ControllerRealEstate();
$extras = new Extras();
$photo_id = $extras->decryptQuery1(KEY_SALT, $_SERVER['QUERY_STRING']);
if ($photo_id != null) {
    $realestates = $controllerRealEstate->getRealEstates();
    $photo_realestate = $controller->getPhotoByPhotoId($photo_id);
    $viewUrl = $extras->encryptQuery1(KEY_SALT, 'realestate_id', $photo_realestate->realestate_id, 'photo_realestate_view.php');
    if (isset($_POST['url_upload'])) {
        $itm = new Photo();
        $itm->photo_url = trim($_POST['photo_url']);
        $itm->thumb_url = trim($_POST['thumb_url']);
        $itm->realestate_id = $photo_realestate->realestate_id;
        $itm->photo_id = $photo_realestate->photo_id;
        $controller->updatePhoto($itm);
        echo "<script type='text/javascript'>location.href='{$viewUrl}';</script>";
    }
    if (isset($_POST['file_upload'])) {
        $count = count($_FILES["file"]["name"]);
        if (!empty($_FILES["file"]["name"][0]) && !empty($_FILES["file"]["name"][1])) {
            uploadFile($controller, $photo_realestate);
        } else {
            echo "<script>alert('You must provide both Photo and Thumbnail file.');</script>";
        }
    }
} else {
    echo "<script type='text/javascript'>location.href='403.php';</script>";
}