function reco_server_api_awake($siteurl, $name, $secret) { // TODO // 1. Check secret // 2. Create/Update client if (!reco_server_checksecret()) { return reco_err("Bad secret"); } if (reco_server_db()->CreateUpdateClient($siteurl, $name, $secret)) { return array("ok" => "ok", "errstr" => ""); } return array(); }
function reco_jsonize($t) { if (strpos($t, "reco_") !== 0) { return reco_err("impossible function (%s), reco_* required", $t); } if (!function_exists($t)) { return reco_err("unknown function (%s)", $t); } $arr = array_slice(func_get_args(), 1); foreach ($arr as $k => $v) { if ($v === null) { return reco_err("Bad param or validator for %s(param #%d)", $t, $k + 1); } } $r = call_user_func_array($t, $arr); // TODO: ... check fields, bububu if (!isset($r["errstr"])) { return reco_err("%s: errstr not exists", $t); } if (!is_scalar($r["errstr"])) { return reco_err("%s: errstr not scalar", $t); } return json_encode($r); }
function reco_todo($side, $action, $t) { return reco_err("TODO: %s.%s.%s", $side, $action, $t); }
// ---------------------------------------------------------------------- case "calc": print reco_todo("server", $_GET["action"], "посчитать предсказания"); break; // ---------------------------------------------------------------------- // ---------------------------------------------------------------------- case "make": print reco_todo("server", $_GET["action"], "дать рекомендации по группам размещения"); break; // ---------------------------------------------------------------------- // ---------------------------------------------------------------------- case "ws": print reco_todo("server", $_GET["action"], "reco_stat_word(\$_GET[\"list\"], reco_server_config_wordstat())"); break; // ---------------------------------------------------------------------- // ---------------------------------------------------------------------- case "try": print reco_server_try(); break; // ---------------------------------------------------------------------- // ---------------------------------------------------------------------- case "": print reco_err("empty action"); break; // ---------------------------------------------------------------------- // ---------------------------------------------------------------------- default: print reco_err("unknown action (%s)", @$_GET["action"]); break; // ---------------------------------------------------------------------- }