Example #1
0
        echo json_encode(model_json::multi(explode(",", $_GET['id'])));
    }
    exit;
}
if ($_SERVER['REQUEST_METHOD'] == 'PUT') {
    damas_service::allowed("model::update");
    if (!isset($_PUT['id']) || !isset($_PUT['keys']) || ($_PUT['id'] == '' || $_PUT['keys'] == '')) {
        header("HTTP/1.1: 400 Bad Request");
        echo "Bad command";
        exit;
    }
    $id = model::update($_PUT['id'], json_decode($_PUT['keys']));
    echo json_encode(model_json::node(arg("id"), 1, $NODE_TAG | $NODE_PRM));
    damas_service::log_event();
    exit;
}
if ($_SERVER['REQUEST_METHOD'] == 'DELETE') {
    damas_service::allowed("model::delete");
    if (!isset($_DELETE['id']) || $_DELETE['id'] == '') {
        header("HTTP/1.1: 400 Bad Request");
        echo "Bad command";
        exit;
    }
    if (!model::delete($_DELETE['id'])) {
        header("HTTP/1.1: 409 Conflict");
        echo "delete Error, please change your values";
        exit;
    }
    damas_service::log_event();
    exit;
}
Example #2
0
 *
 * damas-core is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with damas-core.  If not, see <http://www.gnu.org/licenses/>.
 *
 */
session_start();
include_once "lib/http_service.php";
include_once "lib/model_json.php";
damas_service::init_http();
damas_service::accessGranted();
damas_service::allowed("model::" . arg("cmd"));
if (!arg("cmd")) {
    header("HTTP/1.1: 400 Bad Request");
    echo "Bad command";
    exit;
}
header('Content-type: application/json');
$ret = false;
switch (arg("cmd")) {
    /* SCRUD operations */
    case "search":
        echo json_encode(model::search(json_decode(arg("keys")), arg("sortby"), arg("order"), arg("limit")));
        break;
    case "create":
        if (is_null(arg('keys'))) {
            header("HTTP/1.1: 400 Bad Request");
Example #3
0
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with damas-core.  If not, see <http://www.gnu.org/licenses/>.
 *
 */
session_start();
include_once "lib/http_service.php";
include_once "lib/model_json.php";
include_once "lib/DAM.php";
include_once "lib/asset.php";
damas_service::init_http();
damas_service::accessGranted();
damas_service::allowed("asset::" . arg("cmd"));
header('Content-type: application/json');
switch (arg("cmd")) {
    case "settings":
        //echo json_encode( ini_get_all( null, false ) ); // debug only
        // helper from php.net:
        function return_bytes($val)
        {
            $val = trim($val);
            $last = strtolower($val[strlen($val) - 1]);
            switch ($last) {
                // The 'G' modifier is available since PHP 5.1.0
                case 'g':
                    $val *= 1024;
                case 'm':
                    $val *= 1024;