Класс Api
Объект $Api:
Объект для работы с API-запросами
Исходный код
class Api extends \Cms\Site\Base { … }
Методы
route()
$Api->route($Request);
Обработка HTTP-запроса
Параметры:
Имя | Описание |
---|---|
$Request |
Возвращает: true
– запрос обработан;
null
– запрос не обработан
Исходный код
function route($Request) {
if (substr($self = $Request->getSelf(), 0, 7) === 'cms/api') {
$this->routeApi($Request);
return true;
} elseif (substr($self, 0, 11) === 'cms/request') {
$root = $this->root();
$file = null;
if ($self == 'cms/request' && strlen($a = $_GET['a']) && strpos($a, '.') === false) {
$file = $root . '/cms/request/' . $a . '.php';
if (!file_exists($file)) $file = $root . '/cms/request/' . $a . '/index.php';
} else {
$file = $root . '/' . $self . '.php';
if (!file_exists($file)) $file = $root . '/' . $self . '/index.php';
}
if (isset($file) && file_exists($file)) {
unset($_GET['a']);
ob_start();
global $_RESULT;
$_RESULT = array();
$html = $this->Main()->Display()->includeFile($file);
if (!$_RESULT) {
if (strlen($html)) {
$Request->addHeader('Content-Type: text/html; charset=UTF-8');
print $html;
} else {
$Request->addHeader('Content-Type: application/json');
print '[]';
}
} else {
if (strlen($html)) {
if (!isset($_RESULT['html'])) $_RESULT['html'] = $html;
elseif (!isset($_RESULT['output'])) $_RESULT['output'] = $html;
}
$Request->addHeader('Content-Type: application/json');
print json_encode($_RESULT);
}
} else {
$Request->setStatus(403);
}
return true;
}
}
routeApi()
$Api->routeApi($Request);
Исходный код
function routeApi($Request) {
if (!$this->apiAuth($Request)) return $Request->setStatus(403);
$Request->addHeader('Content-Type: application/json');
ob_start();
global $_RESULT;
$_RESULT = array();
$method = $params = null;
if ($_REQUEST && isset($_REQUEST['method'])) {
$method = strval($_REQUEST['method']);
if (isset($_REQUEST['params'])) $params = $_REQUEST['params'];
$_RESULT['jsonrpc'] = '2.0';
try {
$_RESULT['result'] = $this->apiCall($method, $params);
} catch (\Exception $e) {
$_RESULT['error'] = $this->apiError($e);
$code = $e->getCode();
if (400 <= $code && $code <= 599) {
$Request->setStatus($code);
}
} catch (\Error $e) {
$_RESULT['error'] = $this->apiError($e);
}
$_RESULT['id'] = isset($_REQUEST['id']) ? $_REQUEST['id'] : null;
} elseif (is_array($request = json_decode($_SERVER['HTTP_CONTENT_ENCODING'] === 'gzip' ? gzdecode(file_get_contents('php://input')) : file_get_contents('php://input'), true))) {
if (!isset($request[0])) {
$_RESULT['jsonrpc'] = '2.0';
if (!isset($request['jsonrpc'])) {
$_RESULT['error'] = $this->apiError('jsonrpc required', -32600);
} elseif ($request['jsonrpc'] !== '2.0') {
$_RESULT['error'] = $this->apiError('jsonrpc must be "2.0"', -32600);
} elseif (!isset($request['method'])) {
$_RESULT['error'] = $this->apiError('method required', -32600);
} elseif (!is_string($request['method'])) {
$_RESULT['error'] = $this->apiError('method must be string', -32600);
} else {
$method = $request['method'];
if (isset($request['params'])) $params = $request['params'];
try {
$_RESULT['result'] = $this->apiCall($method, $params);
} catch (\Exception $e) {
$_RESULT['error'] = $this->apiError($e);
$code = $e->getCode();
if (400 <= $code && $code <= 599) {
$Request->setStatus($code);
}
} catch (\Error $e) {
$_RESULT['error'] = $this->apiError($e);
}
}
$_RESULT['id'] = isset($request['id']) ? $request['id'] : null;
} elseif (count($request) <= 100) {
foreach ($request as $i => $request) if (is_int($i)) {
$_RESULT[$i] = array();
$_RESULT[$i]['jsonrpc'] = '2.0';
if (!isset($request['jsonrpc'])) {
$_RESULT[$i]['error'] = $this->apiError('jsonrpc required', -32600);
} elseif ($request['jsonrpc'] !== '2.0') {
$_RESULT[$i]['error'] = $this->apiError('jsonrpc must be "2.0"', -32600);
} elseif (!isset($request['method'])) {
$_RESULT[$i]['error'] = $this->apiError('method required', -32600);
} elseif (!is_string($request['method'])) {
$_RESULT[$i]['error'] = $this->apiError('method must be string', -32600);
} else {
$method = $request['method'];
if (isset($request['params'])) $params = $request['params'];
ob_start();
try {
$_RESULT[$i]['result'] = $this->apiCall($method, $params);
} catch (\Exception $e) {
$_RESULT[$i]['error'] = $this->apiError($e);
} catch (\Error $e) {
$_RESULT[$i]['error'] = $this->apiError($e);
}
if (strlen($output = ob_get_clean())) if (is_array($_RESULT[$i])) $_RESULT[$i]['output'] = $output;
}
$_RESULT[$i]['id'] = isset($request['id']) ? $request['id'] : null;
}
} else {
$_RESULT['error'] = $this->apiError('method call limit is 100', -32600);
}
} elseif (strlen($method = substr($Request->getSelf(), 7)) > 1) {
if (isset($_REQUEST['params'])) $params = $_REQUEST['params'];
else $params = $_REQUEST;
$_RESULT['jsonrpc'] = '2.0';
try {
$_RESULT['result'] = $this->apiCall($method, $params);
} catch (\Exception $e) {
$_RESULT['error'] = $this->apiError($e);
$code = $e->getCode();
if (400 <= $code && $code <= 599) {
$Request->setStatus($code);
}
} catch (\Error $e) {
$_RESULT['error'] = $this->apiError($e);
}
$_RESULT['id'] = isset($_REQUEST['id']) ? $_REQUEST['id'] : null;
} else {
$_RESULT['jsonrpc'] = '2.0';
$_RESULT['error'] = $this->apiError('jsonrpc required', -32600);
$_RESULT['id'] = isset($_REQUEST['id']) ? $_REQUEST['id'] : null;
}
if (strlen($output = ob_get_clean())) {
if (is_array($_RESULT) && isset($_RESULT['jsonrpc'])) $_RESULT['output'] = $output;
}
print json_encode($_RESULT);
}
apiAuth()
$Api->apiAuth($Request);
Исходный код
function apiAuth($Request) {
if (isset($_REQUEST['method']) && substr(strval($_REQUEST['method']), 0, 6) === '/auth/') return true;
$this->App()->init();
if ($this->Auth()->admin) return true;
}
apiAuthCall()
$Api->apiAuthCall($call, &$method, &$params);
Исходный код
function apiAuthCall($call, &$method, &$params) {
return true;
}
apiCall()
$Api->apiCall($method, $params);
Исходный код
function apiCall($method, $params) {
if (is_array($params)) {
foreach (array( 'login', 'email' ) as $key) {
if (isset($params[$key]) && is_string($params[$key])) $params[$key] = mb_strtolower($params[$key]);
}
}
if (strlen($call = strtolower(preg_replace('~[^a-zA-Z0-9]~', '', $method)))) {
$call = 'apiCall' . $call;
if (is_callable(array($this, $call))) {
if (!$this->apiAuthCall($call, $method, $params)) {
throw new \Exception('Permission denied', 403);
}
return $this->$call($params);
}
}
throw new \Exception('method «' . $method . '» not found', -32601);
}
apiError()
$Api->apiError($e, $code=null);
Исходный код
function apiError($e, $code = null) {
if ($e instanceof \Exception) {
return array(
'code' => $e->getCode(),
'message' => $e->getMessage(),
);
} else {
return array(
'code' => isset($code) ? $code : -1,
'message' => is_string($e) ? $e : strval($e),
);
}
}
assertObject()
$Api->assertObject(&$params);
Исходный код
function assertObject(&$params) {
if (!is_array($params)) throw new \Exception('params must be object', -32602);
}
apiCallSitemapTypeList()
$Api->apiCallSitemapTypeList($params);
Исходный код
function apiCallSitemapTypeList($params) {
$list = array();
$Data = $this->Data();
foreach ($this->Main()->Modules()->getModuleList() as $type => $Type) if ($Table = $Type->loadTable()) if ($Field = $Table->getEnabledField('type')) {
$table = $Table->getName();
$filter = array( 'type' => $type );
if ($params['count']) {
$sql = $Data->select("COUNT(*) AS `count`", "`$table`", "`$table`.`type`={$Data->quote($type)}");
if ($count = $Data->dLookup($sql)) {
$list[] = array(
'id' => json_encode($filter),
'type' => 'type',
'title' => 'Все: ' . $Type->displayTitle(),
'count' => $count,
'filter' => $filter,
);
}
} else {
$list[] = array(
'id' => json_encode($filter),
'type' => 'type',
'title' => 'Все: ' . $Type->displayTitle(),
'filter' => $filter,
);
}
}
return array( 'list' => $list );
}
apiCallSitemapPageList()
$Api->apiCallSitemapPageList($params);
Исходный код
function apiCallSitemapPageList($params) {
$this->assertObject($params);
$list = array();
$Data = $this->Data();
$Main = $this->Main();
$Storage = $Main->Storage();
$Modules = $Main->Modules();
$tableList = array();
if (isset($params['type'])) {
foreach (is_array($params['type']) ? $params['type'] : array($params['type']) as $type) {
if ($Type = $Modules->initModule(strval($type))) {
if ($Table = $Type->loadTable()) {
$tableList[$Table->getName()] = $Table;
}
}
}
} else {
foreach ($Storage->getItemTableList() as $table => $Table) {
if (
!isset($params['table'])
|| (is_scalar($params['table']) && $params['table'] === $table)
|| (is_array($params['table']) && in_array($table, $params['table']))
) {
$tableList[$table] = $Table;
}
}
}
if ($params['group_type']) {
$typeList = array();
$tableTypeList = array();
foreach ($tableList as $table => $Table) if ($Field = $Table->getEnabledField('type')) {
$sql = $Data->select("`$table`.`type`, COUNT(*) AS `count`", "`$table`")->addGroup("`$table`.`type`");
foreach ($params as $name => $value) if ($Field = $Table->getEnabledField($name)) {
if (is_array($value)) $sql->addWhere("`$table`.`$name` IN ({$Data->qList($value)})");
else $sql->addWhere("`$table`.`$name`={$Data->quote($value)}");
}
foreach ($Data->getRows($sql) as $row) {
$type = $row['type'];
$Type = $Modules->initModule($type);
if (!isset($tableTypeList[$table])) $tableTypeList[$table] = array();
$tableTypeList[$table][$type] = $row;
$typeList[$type] = $Type;
}
}
if ($typeList) {
$sortTypeList = array();
foreach ($Modules->getModuleList() as $type => $Type) if (isset($typeList[$type])) {
$sortTypeList[$type] = $Type;
}
$typeList = $sortTypeList;
}
foreach ($tableTypeList as $table => $typeRows) {
$Table = $tableList[$table];
if (count($typeRows) > 1) {
$count = 0;
foreach ($typeRows as $row) $count += $row['count'];
$filter = array(
'table' => $table,
);
foreach ($params as $name => $value) if ($Field = $Table->getEnabledField($name)) {
if (is_array($value)) $sql->addWhere("`$table`.`$name` IN ({$Data->qList($value)})");
else $sql->addWhere("`$table`.`$name`={$Data->quote($value)}");
$filter[$name] = $value;
}
$list[] = array(
'id' => json_encode($filter),
'type' => 'table',
'title' => $Table->displayTitle(),
'filter' => $filter,
'count' => $count,
'expandable' => false,
);
}
foreach ($typeList as $type => $Type) if (isset($typeRows[$type])) {
$row = $typeRows[$type];
if ($type !== 'page') {
$filter = array(
'type' => $type,
'table' => $table,
);
foreach ($params as $name => $value) if ($Field = $Table->getEnabledField($name)) {
if (is_array($value)) $sql->addWhere("`$table`.`$name` IN ({$Data->qList($value)})");
else $sql->addWhere("`$table`.`$name`={$Data->quote($value)}");
$filter[$name] = $value;
}
$list[] = array(
'id' => json_encode($filter),
'type' => 'type',
'title' => 'Тип: ' . $Type->displayTitle(),
'filter' => $filter,
'count' => $row['count'],
'expandable' => false,
);
}
$sql = $Data->select("`$table`.*", "`$table`", "`$table`.`type`={$Data->quote($type)}");
if ($order = $Type->getOrderList()) $sql->addOrder($order);
foreach ($params as $name => $value) if ($Field = $Table->getEnabledField($name)) {
if (is_array($value)) $sql->addWhere("`$table`.`$name` IN ({$Data->qList($value)})");
else $sql->addWhere("`$table`.`$name`={$Data->quote($value)}");
$filter[$name] = $value;
}
$rows = $Data->getRows($sql);
$countList = null;
if (0 <= count($rows) && count($rows) <= 100) {
$countList = array();
$idList = array();
foreach ($rows as $row) $idList[] = $row['id'];
$sqlCount = $Data->select("`parent`, COUNT(*) `count`", "``", "`parent` IN ({$Data->qList($idList)})")->addGroup("`parent`");
foreach ($Storage->getItemTableList() as $_table => $_Table) {
$sqlCount->setTable($_table);
foreach ($Data->getRows($sqlCount) as $row) {
$countList[$row['parent']] += $row['count'];
}
}
}
foreach ($rows as $row) {
$row['title'] = $this->getRowTitle($row);
$filter = array(
'parent' => $row['id'],
'group_type' => true,
);
$list[] = array(
'id' => $row['id'],
'parent' => $row['parent'],
'type' => $row['type'],
'title' => $row['title'],
'menu' => $row['menu'],
'filter' => $filter,
'url' => $Main->href($row['id']),
'empty' => is_array($countList) ? !$countList[$row['id']] : null,
);
}
}
}
} else {
foreach ($tableList as $table => $Table) {
$sql = $Data->select("`$table`.*", "`$table`");
foreach ($params as $name => $value) if ($Field = $Table->getEnabledField($name)) {
if (is_array($value)) $sql->addWhere("`$table`.`$name` IN ({$Data->qList($value)})");
else $sql->addWhere("`$table`.`$name`={$Data->quote($value)}");
}
if ($order = $Table->getSortList()) $sql->addOrder($order);
$rows = $Data->getRows($sql);
$countList = null;
if (0 <= count($rows) && count($rows) <= 100) {
$countList = array();
$idList = array();
foreach ($rows as $row) $idList[] = $row['id'];
$sqlCount = $Data->select("`parent`, COUNT(*) `count`", "``", "`parent` IN ({$Data->qList($idList)})")->addGroup("`parent`");
foreach ($Storage->getItemTableList() as $_table => $_Table) {
$sqlCount->setTable($_table);
foreach ($Data->getRows($sqlCount) as $row) {
$countList[$row['parent']] += $row['count'];
}
}
}
foreach ($Data->getRows($sql) as $row) {
$row['title'] = $this->getRowTitle($row);
$filter = array(
'parent' => $row['id'],
'group_type' => true,
);
$list[] = array(
'id' => $row['id'],
'parent' => $row['parent'],
'type' => $row['type'],
'title' => $row['title'],
'menu' => $row['menu'],
'filter' => $filter,
'url' => $Main->href($row['id']),
'empty' => is_array($countList) ? !$countList[$row['id']] : null,
);
}
}
}
return array( 'list' => $list );
}
apiCallSitemapPagePath()
$Api->apiCallSitemapPagePath($params);
Исходный код
function apiCallSitemapPagePath($params) {
if (is_scalar($params)) {
$id = strval($params);
$params = array( 'id' => $id );
} elseif (is_array($params)) {
$id = strval($params['id']);
} else {
throw new \Exception('params must be object', -32602);
}
if (!strlen($id)) return;
$Main = $this->Main();
$Storage = $Main->Storage();
$list = array();
$pageList = null;
if ($row = $Storage->getRow($id)) {
$row['title'] = $this->getRowTitle($row);
$filter = array(
'parent' => $row['id'],
'group_type' => true,
);
if ($params['expand_list']) {
$pageList = $this->apiCallSitemapPageList($filter);
}
$list[] = array(
'id' => $row['id'],
'parent' => $row['parent'],
'type' => $row['type'],
'title' => $row['title'],
'menu' => $row['menu'],
'filter' => $filter,
'url' => $Main->href($row['id']),
'empty' => is_array($pageList) && count($pageList['list']) === 0 ? true : null,
) + (is_array($pageList) ? $pageList : array());
$i = 0;
while (++ $i <= 10 && strlen($parent = $row['parent']) && ($row = $Storage->getRow($parent))) {
$row['title'] = $this->getRowTitle($row);
$filter = array(
'parent' => $row['id'],
'group_type' => true,
);
if ($params['expand_list']) {
$pageList = $this->apiCallSitemapPageList($filter);
}
$list[] = array(
'id' => $row['id'],
'parent' => $row['parent'],
'type' => $row['type'],
'title' => $row['title'],
'menu' => $row['menu'],
'filter' => $filter,
'url' => $Main->href($row['id']),
'empty' => is_array($pageList) && count($pageList['list']) === 0 ? true : null,
) + (is_array($pageList) ? $pageList : array());
}
$list = array_reverse($list);
}
return array( 'list' => $list );
}
apiCallSitemapPageTable()
$Api->apiCallSitemapPageTable($params);
Исходный код
function apiCallSitemapPageTable($params) {
$this->assertObject($params);
$html = array();
$Data = $this->Data();
$Main = $this->Main();
$Modules = $Main->Modules();
$Storage = $Main->Storage();
if (isset($params['id'])) {
$T = $Main->create('table');
$T->init();
$T->addCol('title', 'Название', array(
'width' => '90%',
'sort' => false,
));
$T->addCol('panel');
foreach (is_array($params['id']) ? $params['id'] : array($params['id']) as $id) {
if ($Item = $Main->load($id)) {
$T->addRow($Item);
}
}
$html[] = $T->display();
}
$tableList = array();
if (isset($params['type'])) {
foreach (is_array($params['type']) ? $params['type'] : array($params['type']) as $type) {
if ($Type = $Modules->initModule(strval($type))) {
if ($Table = $Type->loadTable()) {
$tableList[$Table->getName()] = $Table;
}
}
}
} else {
foreach ($Storage->getItemTableList() as $table => $Table) {
if (
!isset($params['table'])
|| (is_scalar($params['table']) && $params['table'] === $table)
|| (is_array($params['table']) && in_array($table, $params['table']))
) {
$tableList[$table] = $Table;
}
}
}
foreach ($tableList as $table => $Table) {
$sql = $Data->select("`$table`.*", "`$table`");
if ($order = $Table->getOrderList()) $sql->addOrder($order);
if (isset($params['id'])) if ($Field = $Table->getEnabledField($name = 'parent')) {
$value = $params['id'];
if (is_array($value)) $sql->addWhere("`$table`.`$name` IN ({$Data->qList($value)})");
else $sql->addWhere("`$table`.`$name`={$Data->quote($value)}");
}
foreach ($params as $name => $value) if ($name !== 'id') if ($Field = $Table->getEnabledField($name)) {
if (is_array($value)) $sql->addWhere("`$table`.`$name` IN ({$Data->qList($value)})");
else $sql->addWhere("`$table`.`$name`={$Data->quote($value)}");
}
$T = $Main->create('table');
$T->init();
$T->addCol('title', 'Название', array(
'width' => '90%',
));
$T->addCol('panel');
foreach ($Data->getRows($sql) as $row) {
$T->addRow($row);
}
if ($T->rows) {
$html[] = $T->display();
}
}
return array( 'table' => implode("\n", $html) );
}
apiCallSitemapPageFind()
$Api->apiCallSitemapPageFind($params);
Исходный код
function apiCallSitemapPageFind($params) {
$this->assertObject($params);
$list = array();
$Data = $this->Data();
$Main = $this->Main();
$Storage = $Main->Storage();
$Modules = $Main->Modules();
$words = array();
if (isset($params['query'])) foreach (explode(' ', strval($params['query'])) as $word) if (strlen($word = trim(mb_strtolower($word)))) {
$words[$word] = $word;
}
if ($words) if (count($words) > 1 || mb_strlen($params['query']) > 1) {
$where = $order = $regexp = array();
foreach ($words as $word) {
$where[] = $order[] = "(`title` LIKE '%{$Data->qLike($word)}%')";
$regexp[] = preg_quote($word, '~');
}
$where = implode(" OR ", $where);
$order = implode(" + ", $order) . ' DESC';
$regexp = implode('|', $regexp);
foreach ($Storage->getItemTableList() as $table => $Table) if ($Field = $Table->getEnabledField('title')) {
$sql = $Data->select("`$table`.*", "`$table`", $where, $order, 100);
$rows = $Data->getRows($sql);
$countList = null;
if (0 <= count($rows) && count($rows) <= 100) {
$countList = array();
$idList = array();
foreach ($rows as $row) $idList[] = $row['id'];
$sqlCount = $Data->select("`parent`, COUNT(*) `count`", "``", "`parent` IN ({$Data->qList($idList)})")->addGroup("`parent`");
foreach ($Storage->getItemTableList() as $_table => $_Table) {
$sqlCount->setTable($_table);
foreach ($Data->getRows($sqlCount) as $row) {
$countList[$row['parent']] += $row['count'];
}
}
}
foreach ($rows as $row) {
$row['title'] = $this->getRowTitle($row);
$filter = array(
'parent' => $row['id'],
'group_type' => true,
);
$list[] = array(
'id' => $row['id'],
'parent' => $row['parent'],
'type' => $row['type'],
'title' => $row['title'],
'highlight' => preg_replace('~(' . $regexp . ')~ui', '<b class="hi">$1</b>', htmlspecialchars($row['title'])),
'menu' => $row['menu'],
'filter' => $filter,
'url' => $Main->href($row['id']),
'empty' => is_array($countList) ? !$countList[$row['id']] : null,
);
}
}
}
return array( 'list' => $list, 'count' => count($list) );
}
getRowTitle()
$Api->getRowTitle($row);
Исходный код
function getRowTitle($row) {
return $row['title'];
}
apiCallSitemapPageTitle()
$Api->apiCallSitemapPageTitle($params);
Исходный код
function apiCallSitemapPageTitle($params) {
if (!strlen($id = strval($params))) return;
if ($Item = $this->Main()->load($id)) return $Item->getTitle();
}
apiCallAuthForm()
$Api->apiCallAuthForm($params);
Исходный код
function apiCallAuthForm($params) {
$this->assertObject($params);
return $this->Auth()->apiCallForm($params);
}
apiCallAuthEnter()
$Api->apiCallAuthEnter($params);
Исходный код
function apiCallAuthEnter($params) {
$this->assertObject($params);
return $this->Auth()->apiCallLogin($params);
}
apiCallAuthLogin()
$Api->apiCallAuthLogin($params);
Исходный код
function apiCallAuthLogin($params) {
$this->assertObject($params);
return $this->Auth()->apiCallLogin($params);
}
apiCallAuthRegister()
$Api->apiCallAuthRegister($params);
Исходный код
function apiCallAuthRegister($params) {
$this->assertObject($params);
return $this->Auth()->apiCallRegister($params);
}
apiCallAuthRegisterCode()
$Api->apiCallAuthRegisterCode($params);
Исходный код
function apiCallAuthRegisterCode($params) {
$this->assertObject($params);
return $this->Auth()->apiCallRegisterCode($params);
}
apiCallAuthRemind()
$Api->apiCallAuthRemind($params);
Исходный код
function apiCallAuthRemind($params) {
$this->assertObject($params);
return $this->Auth()->apiCallRemind($params);
}
apiCallAuthRemindCode()
$Api->apiCallAuthRemindCode($params);
Исходный код
function apiCallAuthRemindCode($params) {
$this->assertObject($params);
return $this->Auth()->apiCallRemindCode($params);
}
apiCallFileInfo()
$Api->apiCallFileInfo($params);
Исходный код
function apiCallFileInfo($params) {
$this->assertObject($params);
return $this->App()->get('file')->apiCallFileInfo($params);
}
apiCallFileText()
$Api->apiCallFileText($params);
Исходный код
function apiCallFileText($params) {
$this->assertObject($params);
return $this->App()->get('file')->apiCallFileText($params);
}
apiCallFileUpload()
$Api->apiCallFileUpload($params);
Исходный код
function apiCallFileUpload($params) {
$this->assertObject($params);
return $this->App()->get('file')->apiCallUpload($params);
}
apiCallFileScan()
$Api->apiCallFileScan($params);
Исходный код
function apiCallFileScan($params) {
$this->assertObject($params);
return $this->App()->get('file')->apiCallFileScan($params);
}