Example #1
0
function api_parse_params(&$reqbody, $format)
{
    global $db;
    foreach ($format as $key => $matching) {
        if (isset($reqbody["params"][$key])) {
            switch ($matching[1]) {
                case PARAM_PREG_MATCH:
                    break;
                case PARAM_DB_MATCH:
                    break;
                default:
            }
        } elseif ($matching[0] != PARAM_REQUIRED) {
            // => it's a default value then
            $reqbody["params"][$key] = $matching[0];
        } else {
            api_reply(RET_INVALID, $key);
        }
    }
}
Example #2
0
<?php

switch ($reqbody["cmd"]) {
    case 'list':
        $whereCond = array();
        $whereCond[] = 1;
        api_parse_filter(&$reqbody, &$whereCond, array("dns_id" => PARAM_ARRAY, "dns_ip" => PARAM_ARRAY, "dns_is_universal" => PARAM_SINGLE, "dns_location" => PARAM_ARRAY));
        $count = 0;
        $list = array();
        while ($item = $db->find("cfg_dns", $whereCond)) {
            $count++;
            api_clean_db_item($item);
            $list[] = $item;
        }
        api_reply(RET_OK, array("list" => $list, "count" => $count));
        break;
    case '':
        break;
    default:
        api_reply(RET_ENI);
}