Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- require_once("config.php");
- class megad extends conf
- {
- public $conf = array();
- public $id = 0;
- public function __construct()
- {
- $conf_file = "dev_conf.json";
- $dev_conf = fopen($conf_file, "r");
- $conf_json = fread($dev_conf, filesize($conf_file));
- fclose($dev_conf);
- $this->conf = json_decode($conf_json, TRUE);
- if ( !empty($_REQUEST['id']) )
- $this->id = $_REQUEST['id'];
- }
- public function write_conf()
- {
- $json = json_encode($this->conf);
- $dev_conf = fopen("dev_conf.json", "w");
- fwrite($dev_conf, $json);
- fclose($dev_conf);
- }
- public function menu()
- {
- $result = '<li><a href="index.php">В начало</a></li>';
- foreach ( $this->conf as $key => $val )
- {
- if ( $this->id == $key ) $selected = ' class="Selected"'; else $selected = "";
- $result .= "<li$selected><a href=\"control.php?id=$key\">".$this->conf[$key]['name']."</a></li>";
- }
- if ( !empty($this->conf) )
- $result .= '<li><a href="control.php?all=1">Показать все</a></li>';
- $result .= '<li><a href="edit.php?new=1">Добавить</a></li>';
- return $result;
- }
- public function control($id, $port, $state)
- {
- if ( $this->demo != "true" )
- file_get_contents("http://".$this->conf[$id]['ip']."/".$this->conf[$id]['pwd']."/?cmd=$port:$state");
- }
- public function get($id, $port)
- {
- if ( $this->demo != "true" )
- {
- $state = file_get_contents("http://".$this->conf[$id]['ip']."/".$this->conf[$id]['pwd']."/?pt=$port&cmd=get");
- return $state;
- }
- return;
- }
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement