Exemplo n.º 1
0
            header('HTTP/1.1: 400 Bad Request');
            exit;
        }
        // Here we implemented the children method to return indexes for performance, keeping the backward compatibility
        if (arg("int") === '1') {
            echo json_encode(model::children(arg('id')));
        } else {
            echo json_encode(model_json::multi(model::children(arg('id'))));
        }
        break;
    case "move":
        if (is_null(arg('id')) || is_null(arg('target'))) {
            header("HTTP/1.1: 400 Bad Request");
            echo "Bad command";
            exit;
        }
        if (!model::move(arg("id"), arg("target"))) {
            header("HTTP/1.1: 409 Conflict");
            echo "move Error, please change your values";
            exit;
        }
        break;
    default:
        header('HTTP/1.1: 400 Bad Request');
        exit;
}
// switch / case
$nolog = array('read', 'ancestors', 'children', 'links', 'stats', 'types', 'tags', 'search');
if (!in_array(arg('cmd'), $nolog)) {
    damas_service::log_event();
}
Exemplo n.º 2
0
 * (at your option) any later version.
 *
 * 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.php";
damas_service::init_http();
if (arg('cmd') != 'login') {
    damas_service::accessGranted();
}
switch (arg("cmd")) {
    case "login":
        if (!login(arg("user"), arg("password"))) {
            header("HTTP/1.1: 401 Unauthorized");
            echo "Incorrect username and password";
            exit;
        }
        header('Content-type: application/json');
        echo json_encode(true);
        exit;
    case "logout":
        if (!logout()) {
            header("HTTP/1.1: 417 Expectation Failed");
            echo "User log out failed";