Subversion Repositories php-qbpwcf

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
14 liveuser 1
<?php
2
 
3
#指派命名空間
4
namespace qbpwcf;
5
 
6
#匯入外部套件
7
include("../allInOne.php");
8
 
9
#提示目前正在執行的部分
10
echo"<hr>csInformation::getUserBrowserType - testCase 1<p>";
11
 
12
/*
13
 
14
#涵式說明:
15
#取得用戶端的瀏覽器版本資訊,並回傳。
16
#回傳結果:
17
#$result,瀏覽器的資訊
18
$result["userBrowserType"]=csInformation::getUserBrowserType();
19
 
20
#檢查變數內容
21
var_dump($result["userBrowserType"]);
22
 
23
*/
24
 
25
#提示目前正在執行的部分
26
echo"<hr>csInformation::getClientIP - testCase 1<p>";
27
 
28
/*
29
 
30
#涵式說明:
31
#回傳用戶端的IP位置
32
#回傳的結果:
33
#$result,用戶端的ip
34
$result["getClientIP"]=csInformation::getClientIP();
35
 
36
#檢查變數內容
37
var_dump($result["getClientIP"]);
38
 
39
*/
40
 
41
#提示目前正在執行的部分
42
echo"<hr>csInformation::getServerIP - testCase 1<p>";
43
 
44
/*
45
 
46
#涵式說明:
47
#取得伺服器的IP,並回傳。
48
#回傳的結果:
49
#$result,伺服端的IP
50
#備註:
51
#伺服端必須被 localhost 以外的網址連結才會出現正確的IP
52
$result["getServerIP"]=csInformation::getServerIP();
53
 
54
#檢查變數內容
55
var_dump($result["getServerIP"]);
56
 
57
*/
58
 
59
#提示目前正在執行的部分
60
echo"<hr>csInformation::getPathOfThisPhpFile - testCase 1<p>";
61
 
62
/*
63
 
64
#涵式說明:
65
#取得目前瀏覽的頁面的路徑
66
#回傳的結果:
67
#$result["status"],執行是否正常,"true"代表執行成功,"false"代表執行失敗.
68
#$result["error"],錯誤訊息.
69
#$result["function"],檔前執行的函數名稱.
70
#$result["content"],目前瀏覽的頁面的路徑.
71
#必填的參數:
72
$conf["type"]="full";#想要取得的路徑類型,full代表完整路徑、lastLayer代表上一層目錄的名稱
73
#參考資料:http:#blog.longwin.com.tw/2009/01/php-get-directory-file-path-dirname-2008/
74
var_dump(csInformation::getPathOfThisPhpFile($conf));
75
unset($conf);
76
 
77
*/
78
 
79
#提示目前正在執行的部分
80
echo"<hr>csInformation::getPathOfThisPhpFile - testCase 2<p>";
81
 
82
/*
83
 
84
#涵式說明:
85
#取得目前瀏覽的頁面的路徑
86
#回傳的結果:
87
#$result["status"],執行是否正常,"true"代表執行成功,"false"代表執行失敗.
88
#$result["error"],錯誤訊息.
89
#$result["function"],檔前執行的函數名稱.
90
#$result["content"],目前瀏覽的頁面的路徑.
91
#必填的參數:
92
$conf["type"]="lastLayer";#想要取得的路徑類型,full代表完整路徑、lastLayer代表上一層目錄的名稱
93
#參考資料:http:#blog.longwin.com.tw/2009/01/php-get-directory-file-path-dirname-2008/
94
var_dump(csInformation::getPathOfThisPhpFile($conf));
95
unset($conf);
96
 
97
*/
98
 
99
#提示目前正在執行的部分
100
echo"<hr>csInformation::getPathOfThisPhpFile - testCase 3<p>";
101
 
102
/*
103
 
104
#涵式說明:
105
#取得目前瀏覽的頁面的路徑
106
#回傳的結果:
107
#$result["status"],執行是否正常,"true"代表執行成功,"false"代表執行失敗.
108
#$result["error"],錯誤訊息.
109
#$result["function"],檔前執行的函數名稱.
110
#$result["content"],目前瀏覽的頁面的路徑.
111
#必填的參數:
112
$conf["type"]="pathOnly";#想要取得的路徑類型,full代表完整路徑、lastLayer代表上一層目錄的名稱
113
#參考資料:http:#blog.longwin.com.tw/2009/01/php-get-directory-file-path-dirname-2008/
114
var_dump(csInformation::getPathOfThisPhpFile($conf));
115
unset($conf);
116
 
117
*/
118
 
119
#提示目前正在執行的部分
120
echo"<hr>csInformation::getConnectionInfo - testCase 1<p>";
121
 
122
/*
123
 
124
#涵式說明:
125
#取得用戶端的資訊
126
#回傳的結果:
127
#$result["status"],執行是否正常,"true"代表執行成功,"false"代表執行失敗.
128
#$result["error"],錯誤訊息.
129
#$result["function"],檔前執行的函數名稱.
130
#$result["userBrowserType"],爲使用者的瀏覽器資訊
131
#$result["userIp"],爲使用者的IP
132
#$result["requestUri"],爲使用者要求的網址
133
#$result["username"],爲使用者目前的帳戶,若爲""則表示尚未登入成功
134
#必填的參數:
135
$conf["getAccount"]="true";#是否要取得帳號
136
#可省略的參數:
137
#$conf["accountVar"]=$_SESSION["username"];#帳號儲存在哪個變數裏面,預設爲$_SESSION["username"]
138
$conf["saveToDb"]="true";#是否要除儲存到資料庫,"true"為要儲存",預設為不儲存
139
$conf["dbAddress"]=$dbAddress;;#爲mysql-Server的位置,若#$conf["saveToDb"]設為"true",則該參數為必填。
140
$conf["dbAccount"]=$dbAccount;#爲用於連入mysql-Server時要使用的帳號,若#$conf["saveToDb"]設為"true",則該參數為必填。
141
$conf["dbName"]=$dbName;#要選取的資料庫名稱,若#$conf["saveToDb"]設為"true",則該參數為必填。
142
$conf["tableName"]="visitorInfo";#爲要插入資料的資料表名稱,若#$conf["saveToDb"]設為"true",則該參數為必填。
143
$conf["columnName"]=array("username","userWebBrowser","userIp","requestUri","systemDateAndTime");#爲資料表的項目名稱,
144
	#例如:$conf["columnName"]=array("columnName1","columnName2","columnName3",...);
145
	#寫入的資料依序為,使用者帳戶、瀏覽器資訊、使用者IP、觀看的網址、當時的時間
146
	#$conf["saveToDb"]設為"true",則該參數為必填。
147
$conf["dbPassword"]=$dbPassword;#爲連線到mysql-Server時要使用的密碼,可省略,若省略則代表不使用密碼
148
$conf["displayQueryError"]="true";#爲是否呈現Query的錯誤訊息,預設不呈現,若要呈現則請將此值設爲"true"
149
$conf["displayQueryString"]="true";#爲是否呈現Query的命令,預設不呈現,若要呈現則請將此值設爲"true"	
150
var_dump(csInformation::getConnectionInfo($conf));
151
unset($conf);
152
 
153
*/
154
 
155
/*
156
 
157
#提示目前正在執行的部分
158
echo"<hr>csInformation::getServerRealIP - testCase 1<p>";
159
 
160
##涵式說明:
161
#依據提供查詢IP服務的網站取得伺服器對外的IP.
162
#回傳的結果:
163
#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
164
#$result["function"],當前執行的函數名稱.
165
#$result["error"],錯誤訊息陣列.
166
#$result["content"],伺服端對外的IP.
167
#必填參數:
168
#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑
169
$conf["fileArgu"]=__FILE__;
170
var_dump(csInformation::getServerRealIP($conf));
171
unset($conf);
172
 
173
*/
174
 
175
#提示目前正在執行的部分
176
echo"<hr>csInformation::getClientPort - testCase 1<p>";
177
 
178
/*
179
 
180
#涵式說明:
181
#回傳用戶端連線到網頁的port
182
#回傳的結果:
183
#$result,用戶端連線到網頁的port
184
var_dump(csInformation::getClientPort());
185
 
186
*/	
187
 
188
#提示目前正在執行的部分
189
echo"<hr>csInformation::getEnv - testCase 1<p>";
190
 
191
/*
192
 
193
#涵式說明:
194
#判斷當前環境為web還是cmd
195
#回傳結果:
196
#$result,"web"或"cmd"	
197
var_dump(csInformation::getEnv());
198
 
199
*/
200
 
201
#提示目前正在執行的部分
202
echo"<hr>csInformation::getServerIPs - testCase 1<p>";
203
 
204
/*
205
 
206
#涵式說明:
207
#取得主機可能的ip位址
208
#回傳的結果:
209
#$result["status"],執行是否正常,"true"代表執行成功,"false"代表執行失敗.
210
#$result["error"],錯誤訊息.
211
#$result["function"],檔前執行的函數名稱.
212
#$result["content"],目前瀏覽的頁面的路徑. 
213
#必填參數:
214
#$conf["fileArgu"],字串,__FILE__的內容.
215
$conf["fileArgu"]=__FILE__;
216
#可省略參數:
217
#無
218
#備註:
219
#僅能在命令列執行.
220
#建構中...
221
$getServerIPs=csInformation::getServerIPs($conf);
222
 
223
#如果取得伺服器可能的ip失敗
224
if($getServerIPs["status"]==="false"){
225
 
226
	#印出結果
227
	var_dump($getServerIPs);
228
 
229
	#結束程式
230
	exit;
231
 
232
	}#if end
233
 
234
#印出結果
235
var_dump($getServerIPs["content"]);
236
 
237
*/
238
 
239
#提示目前正在執行的部分
240
echo"<hr>csInformation::getIpGeo - testCase 1<p>";
241
 
242
/*
243
 
244
#涵式說明:
245
#取得 dns/ip 的地理位置資訊 
246
#必填參數:
247
#$conf["fileArgu"],字串,__FILE__的內容.
248
$conf["fileArgu"]=__FILE__;
249
#可省略參數:
250
#$conf["addr"],字串,dns或ip.
251
$conf["addr"]="qbpwcf.bridge.cloudns.asia";
252
$getIpGeo=csInformation::getIpGeo($conf);
253
unset($conf);
254
 
255
var_dump($getIpGeo);
256
 
257
*/
258
 
259
/*
260
 
261
#提示目前正在執行的部分
262
echo"<hr>csInformation::ipv4toipv6 - testCase 1<p>";
263
 
264
#函式說明:
265
#將ipv4轉換成ipv6
266
#回傳結果:
267
#
268
#必填參數:
269
#$conf["ipv4"],字串,人可讀的ipv4字串.
270
$conf["ipv4"]="3.1.205.119";
271
#可省略參數:
272
#無.
273
#參考資料:
274
#http://benjr.tw/17314
275
$ipv4toipv6=csInformation::ipv4toipv6($conf);
276
unset($conf);
277
 
278
#如果取得伺服器可能的ip失敗
279
if($ipv4toipv6["status"]==="false"){
280
 
281
	#印出結果
282
	var_dump($ipv4toipv6);
283
 
284
	#結束程式
285
	exit;
286
 
287
	}#if end
288
 
289
#印出結果
290
var_dump($ipv4toipv6);
291
 
292
*/
293
 
294
?>