From 9322a9fdb1c1b6abee78f89cbc3cf1719de460b6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=B0=B9=E8=AF=9A=E8=AF=9A?= Date: Mon, 27 May 2019 11:42:29 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E5=9C=A8=E7=BA=BF=E5=BC=80?= =?UTF-8?q?=E6=9C=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- webht/controllers/onlineoffice.php | 95 +++++++++++++++++++ webht/views/index/index.php | 7 +- webht/views/index/search.php | 142 ++++++++++++++++------------ webht/views/onlineoffice/wakeup.php | 56 +++++++++++ webht/views/verify.php | 3 +- 5 files changed, 236 insertions(+), 67 deletions(-) create mode 100644 webht/controllers/onlineoffice.php create mode 100644 webht/views/onlineoffice/wakeup.php diff --git a/webht/controllers/onlineoffice.php b/webht/controllers/onlineoffice.php new file mode 100644 index 00000000..0d8b9d97 --- /dev/null +++ b/webht/controllers/onlineoffice.php @@ -0,0 +1,95 @@ +output->enable_profiler(TRUE); + $this->permission->is_admin(true); + $this->load->model('Navigation_model'); + $this->load->model('Operator_model'); + $this->admin_data=$this->session->userdata('admin_chtcdn'); + $this->uid=$this->admin_data['OPI_SN']; + } + + public function index() + { + $data['mid']=$this->uid; + $this->load->view('n-header', $data); + $user_data=$this->Operator_model->get_webhtuser_by_id($this->admin_data['whu_uid']); + $data['whu_ip']=$user_data->whu_ip; + $data['whu_mac']=$user_data->whu_mac; + $this->load->view('onlineoffice/wakeup',$data); + $this->load->view('n-footer'); + } + + + public function wakeonlan($ip,$mac,$port=7){ + //需要在system32目录下放置wolcmd.exe来启动 + $mac=str_replace(':','',$mac); + $last_line = system("wolcmd $mac $ip 255.255.255.0 7", $retval); + echo $last_line; + + return true; + + $addr_byte = explode(':', $mac); + $hw_addr = ''; + for ($i=0; $i <6; $i++){ + $hw_addr .= chr(hexdec($addr_byte[$i])); + } + $msg = chr(255).chr(255).chr(255).chr(255).chr(255).chr(255); + for ($i = 1; $i <= 16; $i++) { + $msg .= $hw_addr; +} + $socket = socket_create(AF_INET, SOCK_DGRAM, SOL_UDP); + if ($socket == false) { + echo "create socket failed!\n"; + echo "error:'".socket_last_error($socket)."' - " . socket_strerror(socket_last_error($socket)); + return FALSE; + } else { + $opt_ret = socket_set_option($socket,SOL_SOCKET, SO_BROADCAST, TRUE); + if($opt_ret <0) { + echo "setsockopt() failed, error: " . strerror($opt_ret) . "\n"; + return FALSE; + } + + if(socket_sendto($socket, $msg, strlen($msg), 0, $ip, $port)) { + echo "唤醒数据包发送成功!"; + socket_close($socket); + return TRUE; + } else { + echo "唤醒数据包发送失败!"; + return FALSE; + } + } + } + + //检查端口是否打开,用来判断电脑是否启动成功 + public function ping($ip,$port=3389) { + $sock = socket_create(AF_INET, SOCK_STREAM, SOL_TCP); + socket_set_nonblock($sock); + @socket_connect($sock,$ip, $port); + socket_set_block($sock); + //返回值说明:2关闭,1打开,0超时 + switch(socket_select($r = array($sock), $w = array($sock), $f = array($sock), 5)){ + case 0: + echo '努力启动中...'; + break; + case 1: + echo '电脑启动成功!'; + break; + case 2: + echo '电脑启动成功,远程端口未打开,联系YCC开启权限'; + break; + } + } + + +} \ No newline at end of file diff --git a/webht/views/index/index.php b/webht/views/index/index.php index e7d9c90a..4f6171ba 100644 --- a/webht/views/index/index.php +++ b/webht/views/index/index.php @@ -1,11 +1,11 @@
- @@ -107,7 +107,6 @@
- + +
+

在线开机

+
+
+
+
+
+ + +
+
+ + +
+ + +
+
+
+
    + +
+
+
+ + +
+ + +
\ No newline at end of file diff --git a/webht/views/verify.php b/webht/views/verify.php index 45897e97..caab44da 100644 --- a/webht/views/verify.php +++ b/webht/views/verify.php @@ -13,12 +13,13 @@
- +