Commit 8ad1e32d authored by thiaramus's avatar thiaramus
Browse files

Added nodelist API endpoint

parent ecff8d7e
<?php
/*
* webJAM - A modern JAM MessageBase Editor
* Copyright (C) 2017 Philipp Giebel (stimpy@kuehlbox.wtf)
*
* This program is free software: you can redistribute it and/or modify it under the terms of the
* GNU General Public License as published by the Free Software Foundation, either version 3 of
* the License, or (at your option) any later version.
*
* This program 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 this program.
* If not, see (http://www.gnu.org/licenses/).
*
* * filename: apiNodelist.class.php
* * description: /nodelist API endpoint class
* * author: Roman Litvinenko (temp@thiaramus.com)
*
*/
class apiNodelist extends mainApiParent
{
protected $allowedHttpMethods = ['GET'];
private function nameSearch($name) {
if (!$name) {
$this->syntaxErrorMessage('Search query is undefined');
}
$nodelist = new nodelist();
$ret = array();
foreach ($this->config['nodelists'] as $n) {
$nodelist->readFile($nodelist->getLatest($n));
$add = $nodelist->findName($name);
if (is_array($add)) $ret = array_merge($ret, $add);
}
return $ret;
}
public function run() {
if (!array_key_exists(1, $this->apiCallPath)) {
$this->syntaxErrorMessage('Nodelist function is undefined');
}
if ($this->apiCallPath[1] === 'namesearch') {
$name = filter_input(INPUT_GET, 'search', FILTER_SANITIZE_STRING);
$this->response($this->nameSearch($name));
} else {
$this->syntaxErrorMessage('Unknown Nodelist function');
}
}
}
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment