File: class/commands.php

Recommend this page to a friend!
  Classes of Andoitz Jordan Marmolejo   JavaScript Query Terminal   class/commands.php   Download  
File: class/commands.php
Role: Auxiliary data
Content type: text/plain
Description: Auxiliary data
Class: JavaScript Query Terminal
Online console to run server commands using AJAX
Author: By
Last change: Update of class/commands.php
Date: 2 years ago
Size: 860 bytes
 

Contents

Class file image Download
<?php Class Commands{ protected $folder = "commands/"; public $commandMode = false; private $command; public function __construct(){ if(isset($_POST["token"]) && isset($_POST["command"])){ $this->commandMode = true; //LOGIN NEED TO BE HERE IF YOU WANT TO HAVE IT $user = new User(); if($user->logged){ $this->command = strtolower($_POST["command"]); } } } public function loadCommand(){ $result = array("data" => "", "header" => ""); $part = explode(" ",$this->command); $command = $part[0]; unset($part[0]); $params = $part; if(file_exists($this->folder.$command.".php")){ include($this->folder.$command.".php"); $command = new $command; $command->init($params); $result["data"] = $command->data; $result["header"] = $command->header; } echo json_encode($result); //RESPUESTA die(); } } ?>