Ejemplo n.º 1
0
/**
 * 
 * 
 * @return \simpleResponse
 */
function execute()
{
    $response = new simpleResponse();
    try {
        include './inc/incWebServiceSessionValidation.php';
        $app_id = filter_input(INPUT_GET, "app_id");
        $appToModify = da_apps_registry::GetApp($app_id);
        $appToModify->account_id = filter_input(INPUT_GET, "account_id");
        $appToModify->app_nickname = filter_input(INPUT_GET, "app_nickname");
        $appToModify->app_description = filter_input(INPUT_GET, "app_description");
        $appToModify->visibility_type_id = filter_input(INPUT_GET, "visibility_type_id");
        if ($appToModify->account_id > 0 && $appToModify->app_nickname != "" && $appToModify->app_description != "" && $appToModify->visibility_type_id > 0) {
            $modifiedApp = da_apps_registry::UpdateApp($appToModify);
            $response->status = "OK";
            $response->message = "SUCCESS";
            $response->data = $modifiedApp;
        } else {
            $response->status = "ERROR";
            if (!$appToModify->account_id > 0) {
                $response->message = "Parámetros Inválidos - AccountID";
            }
            if ($appToModify->app_nickname == "") {
                $response->message = "Parámetros Inválidos - Nickname";
            }
            if ($appToModify->app_description == "") {
                $response->message = "Parámetros Inválidos - Description";
            }
        }
    } catch (Exception $ex) {
        $response->status = "EXCEPTION";
        $response->message = $ex->getMessage();
    }
    return $response;
}
Ejemplo n.º 2
0
 public static function RetrieveApp()
 {
     $response = new simpleResponse();
     $parameters = GetAppWebService::collectParameters();
     try {
         $account_id = 0;
         include './inc/incWebServiceSessionValidation.php';
         if ($account_id > 0) {
             $apps = da_apps_registry::GetApp($parameters->app_id);
             $response->status = "OK";
             $response->message = "SUCCESS";
             $response->data = $apps;
         } else {
             $response->status = "ERROR";
         }
     } catch (Exception $ex) {
         $response->status = "EXCEPTION";
         $response->message = $ex->getMessage();
     }
     return $response;
 }
Ejemplo n.º 3
0
 /**
  * Deletes a app by updating its deleted_datetime
  * @param int $app_id
  * @return be_app
  */
 public static function DeleteApp($app_id)
 {
     $sqlCommand = "UPDATE app_registry " . " SET  deleted_datetime = NOW() " . " WHERE app_id = ? ";
     $paramTypeSpec = "i";
     $mysqli = DA_Helper::mysqli_connect();
     if ($mysqli->connect_errno) {
         $msg = "Failed to connect to MySQL: (" . $mysqli->connect_errno . ") " . $mysqli->connect_error;
         throw new Exception($msg, $mysqli->errno);
     }
     if (!($stmt = $mysqli->prepare($sqlCommand))) {
         $msg = "Prepare failed: (" . $mysqli->errno . ") " . $mysqli->error;
         throw new Exception($msg, $stmt->errno);
     }
     if (!$stmt->bind_param($paramTypeSpec, $app_id)) {
         $msg = "Binding parameters failed: (" . $stmt->errno . ") " . $stmt->error;
         throw new Exception($msg, $stmt->errno);
     }
     if (!$stmt->execute()) {
         $msg = "Execute failed: (" . $stmt->errno . ") " . $stmt->error;
         throw new Exception($msg, $stmt->errno);
     }
     $stmt->close();
     $retrievedApp = da_apps_registry::GetApp($app_id);
     return $retrievedApp;
 }
<?php

//$access is defined in the implementator of this include
if ($access != "RO") {
    $access = "RW";
}
$account_id = filter_input(INPUT_GET, "account_id");
$app_id = filter_input(INPUT_GET, "app_id");
$api_key = filter_input(INPUT_GET, "api_key");
$validation = FALSE;
if (!isset($api_key)) {
    $api_key = "";
}
if (!isset($app_id) || !isset($account_id)) {
    die;
}
$app = da_apps_registry::GetApp($app_id);
if ($app->visibility_type_id == 3 && $access == "RO") {
    // 3 = Public App doesnt require api key for RO vse services
    $validation = $account_id == $app->account_id;
} else {
    $validation = $account_id == $app->account_id && $api_key == $app->api_key;
}
if ($validation == FALSE) {
    die;
}