| 578 |
liveuser |
1 |
#!/bin/php
|
|
|
2 |
<?php
|
|
|
3 |
|
|
|
4 |
/*
|
|
|
5 |
QBPWCF, Quick Build PHP website Component base on Fedora Linux.
|
| 619 |
liveuser |
6 |
Copyright (C) 2015~2024 Min-Jhin,Chen
|
| 578 |
liveuser |
7 |
|
|
|
8 |
This file is part of QBPWCF.
|
|
|
9 |
|
|
|
10 |
QBPWCF is free software: you can redistribute it and/or modify
|
|
|
11 |
it under the terms of the GNU General Public License as published by
|
|
|
12 |
the Free Software Foundation, either version 3 of the License, or
|
|
|
13 |
(at your option) any later version.
|
|
|
14 |
|
|
|
15 |
QBPWCF is distributed in the hope that it will be useful,
|
|
|
16 |
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
17 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
18 |
GNU General Public License for more details.
|
|
|
19 |
|
|
|
20 |
You should have received a copy of the GNU General Public License
|
|
|
21 |
along with QBPWCF. If not, see <http://www.gnu.org/licenses/>.
|
|
|
22 |
|
|
|
23 |
*/
|
|
|
24 |
|
|
|
25 |
/*
|
|
|
26 |
|
|
|
27 |
說明:
|
|
|
28 |
提供QBPWCF套件執行任何指令的unix domain socket服務.
|
|
|
29 |
|
|
|
30 |
*/
|
|
|
31 |
|
|
|
32 |
#使用命名空間qbpwcf
|
|
|
33 |
namespace qbpwcf;
|
|
|
34 |
|
|
|
35 |
#以該檔案的實際位置的 lib path 為 include path 首位
|
| 906 |
liveuser |
36 |
exec("cd ".pathinfo(__FILE__)["dirname"]."/../lib;pwd;",$output,$status);
|
| 578 |
liveuser |
37 |
set_include_path($output[0].PATH_SEPARATOR.get_include_path());
|
|
|
38 |
|
|
|
39 |
#匯入外部套件
|
|
|
40 |
include("allInOne.php");
|
|
|
41 |
|
|
|
42 |
#函式說明:
|
|
|
43 |
#建立 unix domain socket server, 僅提供具備檔案存取權限的用戶使用.
|
|
|
44 |
#回傳結果:
|
|
|
45 |
#$result["status"],"true"代表執行正常;"false"代表執行不正常.
|
|
|
46 |
#$result["error"],錯誤訊息陣列.
|
|
|
47 |
#$result["function"],當前執行的函式名稱.
|
|
|
48 |
#必填參數:
|
|
|
49 |
#$conf["sock"],字串,socket檔案要放在哪邊,名稱為何.
|
|
|
50 |
$conf["sock"]=qbpwcf_usock_path;
|
|
|
51 |
#$conf["fileArgu"],字串,變數__FILE__的內容.
|
|
|
52 |
$conf["fileArgu"]=__FILE__;
|
|
|
53 |
#可省略參數:
|
|
|
54 |
#$conf["changeOwner"],字串,要將socket檔案的擁有着權限進行修改."user.group"代表擁有者帳號為user,群組為group.
|
|
|
55 |
$conf["changeOwner"]="root.apache";
|
|
|
56 |
#$conf["changePermission"],整數,要將socket檔案的權限設為多少.ex: 0666(所有帳戶都有存取的權限) 或 0660(僅有擁有者與群組帳戶有存取的權限) 或 0600(只有擁有者有權限執行).
|
| 594 |
liveuser |
57 |
$conf["changePermission"]="0770";
|
| 578 |
liveuser |
58 |
#$conf["sessionTimeout"],字串,當連線結束後於下一次連線間隔多久就算session timeout,server端會將記錄移除,client端需要重新拿取id,預設為300秒.
|
|
|
59 |
#$conf["sessionTimeout"]="300";
|
|
|
60 |
#參考資料:
|
|
|
61 |
#http://php.net/manual/en/function.stream-socket-server.php
|
|
|
62 |
#備註:
|
|
|
63 |
#無.
|
|
|
64 |
$unixDomainSockServer=sock::unixDomainSockServer($conf);
|
|
|
65 |
unset($conf);
|
|
|
66 |
|
|
|
67 |
#如果執行失敗
|
|
|
68 |
if($unixDomainSockServer["status"]=="false"){
|
|
|
69 |
|
|
|
70 |
#設置錯誤識別
|
|
|
71 |
$result["status"]="false";
|
|
|
72 |
|
|
|
73 |
#設置錯誤訊息
|
|
|
74 |
$result["error"]=$unixDomainSockServer;
|
|
|
75 |
|
|
|
76 |
#印出結果
|
|
|
77 |
var_dump($result);
|
|
|
78 |
|
|
|
79 |
#結束執行
|
|
|
80 |
exit;
|
|
|
81 |
|
|
|
82 |
}#if end
|