Subversion Repositories php-qbpwcf

Rev

Rev 137 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 137 Rev 226
Line 1... Line 1...
1
<?php
1
<?php
2
 
2
 
3
/*
3
/*
4
 
4
 
5
	QBPWCF, Quick Build PHP website Component base on Fedora Linux.
5
	QBPWCF, Quick Build PHP website Component base on Fedora Linux.
6
    Copyright (C) 2015~2025 Min-Jhin,Chen
6
    Copyright (C) 2014~2025 MIN ZHI, CHEN
7
 
7
 
8
    This file is part of QBPWCF.
8
    This file is part of QBPWCF.
9
 
9
 
10
    QBPWCF is free software: you can redistribute it and/or modify
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
11
    it under the terms of the GNU General Public License as published by
Line 461... Line 461...
461
		#解析PHP檔案裡面的變數.
461
		#解析PHP檔案裡面的變數.
462
		#回傳結果:
462
		#回傳結果:
463
		#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
463
		#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
464
		#$result["error"],錯誤訊息.
464
		#$result["error"],錯誤訊息.
465
		#$result["function"],當前執行的函數名稱.
465
		#$result["function"],當前執行的函數名稱.
466
		#$result["argu"],所使用的參數.	
466
		#$result["argu"],所使用的參數.
467
		#$result["content"],找到的變數內容陣列.
467
		#$result["content"],找到的變數內容陣列.
468
		#$result["content"]["value"],依找到變數順序的數值.
468
		#$result["content"]["value"],依找到變數順序的數值.
469
		#$result["content"]["struc"],依找到變數順序的階層結構.
469
		#$result["content"]["struc"],依找到變數順序的階層結構.
470
		#$result["content"]["direct"],變數名稱對應的數值內容.
470
		#$result["content"]["direct"],變數名稱對應的數值內容.
471
		#必填參數:
471
		#必填參數:
Line 499... Line 499...
499
 
499
 
500
			}#if end
500
			}#if end
501
 
501
 
502
		#如果myIp變數有設定
502
		#如果myIp變數有設定
503
		if(isset($parseVaraiableInPHPfile["content"]["myIp"])){
503
		if(isset($parseVaraiableInPHPfile["content"]["myIp"])){
504
		
504
 
505
			#如果內容不為空字串
505
			#如果內容不為空字串
506
			if($parseVaraiableInPHPfile["content"]["myIp"][0]!==""){
506
			if($parseVaraiableInPHPfile["content"]["myIp"][0]!==""){
507
			
507
 
508
				#取得伺服器對外的IP
508
				#取得伺服器對外的IP
509
				$result["content"]=array($parseVaraiableInPHPfile["content"]["myIp"][0]);
509
				$result["content"]=array($parseVaraiableInPHPfile["content"]["myIp"][0]);
510
 
510
 
511
				#設置執行正常
511
				#設置執行正常
512
				$result["status"]="true";
512
				$result["status"]="true";
513
 
513
 
514
				#回傳結果
514
				#回傳結果
515
				return $result;
515
				return $result;
516
			
516
 
517
				}#if end
517
				}#if end
518
		
518
 
519
			}#if end
519
			}#if end
520
		
520
 
521
		#預設用於取得自己對外ip的服務網址
521
		#預設用於取得自己對外ip的服務網址
522
		$getIpUrl="https://ip.qbpwcf.org";
522
		$getIpUrl="https://ip.qbpwcf.org";
523
		
523
 
524
		#如果變數getIpUrl有設定
524
		#如果變數getIpUrl有設定
525
		if(isset($parseVaraiableInPHPfile["content"]["getIpUrl"])){
525
		if(isset($parseVaraiableInPHPfile["content"]["getIpUrl"])){
526
		
526
 
527
			#如果內容不為空字串
527
			#如果內容不為空字串
528
			if($parseVaraiableInPHPfile["content"]["getIpUrl"][0]!==""){
528
			if($parseVaraiableInPHPfile["content"]["getIpUrl"][0]!==""){
529
			
529
 
530
				#更新 getIpUrl
530
				#更新 getIpUrl
531
				$getIpUrl=$parseVaraiableInPHPfile["content"]["getIpUrl"][0];
531
				$getIpUrl=$parseVaraiableInPHPfile["content"]["getIpUrl"][0];
532
			
532
 
533
				}#if end
533
				}#if end
534
		
534
 
535
			}#if end
535
			}#if end
536
 
536
 
537
		#函式說明:
537
		#函式說明:
538
		#運行curl cmd
538
		#運行curl cmd
539
		#回傳結果:
539
		#回傳結果:
Line 1347... Line 1347...
1347
			#如果是 "pathOnly"
1347
			#如果是 "pathOnly"
1348
			case "pathOnly":
1348
			case "pathOnly":
1349
 
1349
 
1350
				#如果是網頁環境
1350
				#如果是網頁環境
1351
				if($getConnectionInfo["mode"]==="web"){
1351
				if($getConnectionInfo["mode"]==="web"){
1352
				
1352
 
1353
					#用 當前檔案的名稱 來分割目前檔案的完整路徑
1353
					#用 當前檔案的名稱 來分割目前檔案的完整路徑
1354
					#函式說明:
1354
					#函式說明:
1355
					#將固定格式的字串分開,並回傳分開的結果。
1355
					#將固定格式的字串分開,並回傳分開的結果。
1356
					#回傳的參數:
1356
					#回傳的參數:
1357
					#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
1357
					#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
Line 1400... Line 1400...
1400
					#設置執行正常
1400
					#設置執行正常
1401
					$result["status"]="true";
1401
					$result["status"]="true";
1402
 
1402
 
1403
					#回傳結果
1403
					#回傳結果
1404
					return $result;
1404
					return $result;
1405
				
1405
 
1406
					}#if end
1406
					}#if end
1407
 
1407
 
1408
				#反之如果是 cmd 環境
1408
				#反之如果是 cmd 環境
1409
				else if($getConnectionInfo["mode"]==="cmd"){
1409
				else if($getConnectionInfo["mode"]==="cmd"){
1410
				
1410
 
1411
					#函式說明:
1411
					#函式說明:
1412
					#將字串特定關鍵字與其後面的內容剔除
1412
					#將字串特定關鍵字與其後面的內容剔除
1413
					#回傳結果:
1413
					#回傳結果:
1414
					#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
1414
					#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
1415
					#$result["error"],錯誤訊息陣列.
1415
					#$result["error"],錯誤訊息陣列.
Line 1431... Line 1431...
1431
					#無.
1431
					#無.
1432
					#備註:
1432
					#備註:
1433
					#無.
1433
					#無.
1434
					$delStrAfterKeyWord=stringProcess::delStrAfterKeyWord($conf["stringProcess::delStrAfterKeyWord"]);
1434
					$delStrAfterKeyWord=stringProcess::delStrAfterKeyWord($conf["stringProcess::delStrAfterKeyWord"]);
1435
					unset($conf["stringProcess::delStrAfterKeyWord"]);
1435
					unset($conf["stringProcess::delStrAfterKeyWord"]);
1436
					
1436
 
1437
					#如果執行失敗
1437
					#如果執行失敗
1438
					if($delStrAfterKeyWord["status"]==="false"){
1438
					if($delStrAfterKeyWord["status"]==="false"){
1439
					
1439
 
1440
						#設置執行失敗
1440
						#設置執行失敗
1441
						$result["status"]="false";
1441
						$result["status"]="false";
1442
 
1442
 
1443
						#設置執行錯誤訊息
1443
						#設置執行錯誤訊息
1444
						$result["error"]=$delStrAfterKeyWord;
1444
						$result["error"]=$delStrAfterKeyWord;
1445
 
1445
 
1446
						#回傳結果
1446
						#回傳結果
1447
						return $result;
1447
						return $result;
1448
 
1448
 
1449
						}#if end
1449
						}#if end
1450
						
1450
 
1451
					#如果沒有應該要有的檔案名稱
1451
					#如果沒有應該要有的檔案名稱
1452
					if($delStrAfterKeyWord["founded"]==="false"){
1452
					if($delStrAfterKeyWord["founded"]==="false"){
1453
					
1453
 
1454
						#設置執行失敗
1454
						#設置執行失敗
1455
						$result["status"]="false";
1455
						$result["status"]="false";
1456
 
1456
 
1457
						#設置執行錯誤訊息
1457
						#設置執行錯誤訊息
1458
						$result["error"]=$delStrAfterKeyWord;
1458
						$result["error"]=$delStrAfterKeyWord;
1459
 
1459
 
1460
						#回傳結果
1460
						#回傳結果
1461
						return $result;
1461
						return $result;
1462
 
1462
 
1463
						}#if end
1463
						}#if end
1464
						
1464
 
1465
					#取得不包含檔案名稱的路徑
1465
					#取得不包含檔案名稱的路徑
1466
					$result["content"]=$delStrAfterKeyWord["content"];
1466
					$result["content"]=$delStrAfterKeyWord["content"];
1467
 
1467
 
1468
					#設置執行正常
1468
					#設置執行正常
1469
					$result["status"]="true";
1469
					$result["status"]="true";
1470
 
1470
 
1471
					#回傳結果
1471
					#回傳結果
1472
					return $result;
1472
					return $result;
1473
				
1473
 
1474
					}#if end
1474
					}#if end
1475
 
1475
 
1476
				#打斷switch
1476
				#打斷switch
1477
				break;
1477
				break;
1478
 
1478
 
Line 1484... Line 1484...
1484
 
1484
 
1485
					#取得上層目錄的名稱
1485
					#取得上層目錄的名稱
1486
					$result["content"]=basename((dirname($getConnectionInfo["requestUri"])));
1486
					$result["content"]=basename((dirname($getConnectionInfo["requestUri"])));
1487
 
1487
 
1488
					}#if end
1488
					}#if end
1489
				
1489
 
1490
				#反之如果是 cmd 環境
1490
				#反之如果是 cmd 環境
1491
				else if($result["mode"]==="cmd"){
1491
				else if($result["mode"]==="cmd"){
1492
				
1492
 
1493
					#取得callback用的參數
1493
					#取得callback用的參數
1494
					$conf["csInformation::getPathOfThisPhpFile"]=$confForCallback;
1494
					$conf["csInformation::getPathOfThisPhpFile"]=$confForCallback;
1495
				
1495
 
1496
					#改取得路徑就好
1496
					#改取得路徑就好
1497
					$conf["csInformation::getPathOfThisPhpFile"]["type"]="pathOnly";
1497
					$conf["csInformation::getPathOfThisPhpFile"]["type"]="pathOnly";
1498
				
1498
 
1499
					/*
1499
					/*
1500
					#函式說明:
1500
					#函式說明:
1501
					#取得目前瀏覽的頁面的路徑或執行的php程式路徑.
1501
					#取得目前瀏覽的頁面的路徑或執行的php程式路徑.
1502
					#回傳結果:
1502
					#回傳結果:
1503
					#$result["status"],執行是否正常,"true"代表執行成功,"false"代表執行失敗.
1503
					#$result["status"],執行是否正常,"true"代表執行成功,"false"代表執行失敗.
Line 1517... Line 1517...
1517
					#備註:
1517
					#備註:
1518
					#無.
1518
					#無.
1519
					*/
1519
					*/
1520
					$getPathOfThisPhpFile=csInformation::getPathOfThisPhpFile($conf["csInformation::getPathOfThisPhpFile"]);
1520
					$getPathOfThisPhpFile=csInformation::getPathOfThisPhpFile($conf["csInformation::getPathOfThisPhpFile"]);
1521
					unset($conf["csInformation::getPathOfThisPhpFile"]);
1521
					unset($conf["csInformation::getPathOfThisPhpFile"]);
1522
				
1522
 
1523
					#如果執行失敗
1523
					#如果執行失敗
1524
					if($getPathOfThisPhpFile["status"]==="false"){
1524
					if($getPathOfThisPhpFile["status"]==="false"){
1525
					
1525
 
1526
						#設置執行失敗
1526
						#設置執行失敗
1527
						$result["status"]="false";
1527
						$result["status"]="false";
1528
 
1528
 
1529
						#設置執行錯誤訊息
1529
						#設置執行錯誤訊息
1530
						$result["error"]=$getPathOfThisPhpFile;
1530
						$result["error"]=$getPathOfThisPhpFile;
1531
 
1531
 
1532
						#回傳結果
1532
						#回傳結果
1533
						return $result;
1533
						return $result;
1534
 
1534
 
1535
						}#if end
1535
						}#if end
1536
						
1536
 
1537
					#取得路徑
1537
					#取得路徑
1538
					#$getPathOfThisPhpFile["content"];
1538
					#$getPathOfThisPhpFile["content"];
1539
				
1539
 
1540
					#函式說明:
1540
					#函式說明:
1541
					#將固定格式的字串分開,並回傳分開的結果.
1541
					#將固定格式的字串分開,並回傳分開的結果.
1542
					#回傳結果:
1542
					#回傳結果:
1543
					#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
1543
					#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
1544
					#$result["error"],錯誤訊息陣列
1544
					#$result["error"],錯誤訊息陣列
Line 1560... Line 1560...
1560
					#無.
1560
					#無.
1561
					#備註:
1561
					#備註:
1562
					#無.
1562
					#無.
1563
					$spiltString=stringProcess::spiltString($conf["stringProcess::spiltString"]);
1563
					$spiltString=stringProcess::spiltString($conf["stringProcess::spiltString"]);
1564
					unset($conf["stringProcess::spiltString"]);
1564
					unset($conf["stringProcess::spiltString"]);
1565
					
1565
 
1566
					#如果執行失敗
1566
					#如果執行失敗
1567
					if($spiltString["status"]==="false"){
1567
					if($spiltString["status"]==="false"){
1568
					
1568
 
1569
						#設置執行失敗
1569
						#設置執行失敗
1570
						$result["status"]="false";
1570
						$result["status"]="false";
1571
 
1571
 
1572
						#設置執行錯誤訊息
1572
						#設置執行錯誤訊息
1573
						$result["error"]=$spiltString;
1573
						$result["error"]=$spiltString;
1574
 
1574
 
1575
						#回傳結果
1575
						#回傳結果
1576
						return $result;
1576
						return $result;
1577
 
1577
 
1578
						}#if end
1578
						}#if end
1579
						
1579
 
1580
					#如果沒有"/"存在
1580
					#如果沒有"/"存在
1581
					if($spiltString["found"]==="false"){
1581
					if($spiltString["found"]==="false"){
1582
					
1582
 
1583
						#設置執行失敗
1583
						#設置執行失敗
1584
						$result["status"]="false";
1584
						$result["status"]="false";
1585
 
1585
 
1586
						#設置執行錯誤訊息
1586
						#設置執行錯誤訊息
1587
						$result["error"]=$spiltString;
1587
						$result["error"]=$spiltString;
1588
 
1588
 
1589
						#回傳結果
1589
						#回傳結果
1590
						return $result;
1590
						return $result;
1591
 
1591
 
1592
						}#if end
1592
						}#if end
1593
						
1593
 
1594
					#如果沒有分出結果
1594
					#如果沒有分出結果
1595
					if($spiltString["dataCounts"]===0){
1595
					if($spiltString["dataCounts"]===0){
1596
					
1596
 
1597
						#設置上層目錄的名稱為"/"
1597
						#設置上層目錄的名稱為"/"
1598
						$result["content"]="/";
1598
						$result["content"]="/";
1599
					
1599
 
1600
						#設置執行正常
1600
						#設置執行正常
1601
						$result["status"]="true";
1601
						$result["status"]="true";
1602
						
1602
 
1603
						#回傳結果
1603
						#回傳結果
1604
						return $result;
1604
						return $result;
1605
 
1605
 
1606
						}#if end
1606
						}#if end
1607
						
1607
 
1608
					#反之
1608
					#反之
1609
					else{
1609
					else{
1610
					
1610
 
1611
						#取得上層目錄的索引
1611
						#取得上層目錄的索引
1612
						$lastLayerIndex=$spiltString["dataCounts"]-1;
1612
						$lastLayerIndex=$spiltString["dataCounts"]-1;
1613
					
1613
 
1614
						#取得上層目錄
1614
						#取得上層目錄
1615
						$result["content"]=$spiltString["dataArray"][$lastLayerIndex];
1615
						$result["content"]=$spiltString["dataArray"][$lastLayerIndex];
1616
					
1616
 
1617
						#設置執行正常
1617
						#設置執行正常
1618
						$result["status"]="true";
1618
						$result["status"]="true";
1619
						
1619
 
1620
						#回傳結果
1620
						#回傳結果
1621
						return $result;
1621
						return $result;
1622
					
1622
 
1623
						}#if end
1623
						}#if end
1624
					
1624
 
1625
					}#if end
1625
					}#if end
1626
					
1626
 
1627
				#反之為異常結果
1627
				#反之為異常結果
1628
				else{
1628
				else{
1629
				
1629
 
1630
					#設置執行不正常
1630
					#設置執行不正常
1631
					$result["status"]="false";
1631
					$result["status"]="false";
1632
 
1632
 
1633
					#設置錯誤訊息
1633
					#設置錯誤訊息
1634
					$result["error"][]="無法判別環境為web還是cmd";
1634
					$result["error"][]="無法判別環境為web還是cmd";
Line 1636... Line 1636...
1636
					#設置錯誤訊息
1636
					#設置錯誤訊息
1637
					$result["error"][]=$getConnectionInfo;
1637
					$result["error"][]=$getConnectionInfo;
1638
 
1638
 
1639
					#回傳結果
1639
					#回傳結果
1640
					return $result;
1640
					return $result;
1641
				
1641
 
1642
					}#else end
1642
					}#else end
1643
 
1643
 
1644
				#設置執行正常
1644
				#設置執行正常
1645
				$result["status"]="true";
1645
				$result["status"]="true";
1646
 
1646
 
Line 1800... Line 1800...
1800
 
1800
 
1801
			}#else end
1801
			}#else end
1802
 
1802
 
1803
		#預設使用該php程式的使用者帳號
1803
		#預設使用該php程式的使用者帳號
1804
		$result["phpUser"]="apache";
1804
		$result["phpUser"]="apache";
1805
		
1805
 
1806
		#嘗試從系統變數取得使用者名稱
1806
		#嘗試從系統變數取得使用者名稱
1807
		#函式說明:
1807
		#函式說明:
1808
		#呼叫shell執行系統命令,並取得回傳的內容.
1808
		#呼叫shell執行系統命令,並取得回傳的內容.
1809
		#回傳結果:
1809
		#回傳結果:
1810
		#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
1810
		#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
Line 1861... Line 1861...
1861
		#備註:
1861
		#備註:
1862
		#不是所有指令都能用apache的身份執行,目前已知java,javac指令無法執行,使用root身份可能會被selinux阻擋.
1862
		#不是所有指令都能用apache的身份執行,目前已知java,javac指令無法執行,使用root身份可能會被selinux阻擋.
1863
		#若使用的 command、argu 參數,含有 ~ 則會被視為字串,若有需要其於 shell 中代表的家目錄位置,可用 fileAccess::tildeToPath 來進行轉換.
1863
		#若使用的 command、argu 參數,含有 ~ 則會被視為字串,若有需要其於 shell 中代表的家目錄位置,可用 fileAccess::tildeToPath 來進行轉換.
1864
		$callShell=external::callShell($conf["external::callShell"]);
1864
		$callShell=external::callShell($conf["external::callShell"]);
1865
		unset($conf["external::callShell"]);
1865
		unset($conf["external::callShell"]);
1866
	
1866
 
1867
		#如果執行失敗
1867
		#如果執行失敗
1868
		if($callShell["status"]==="false"){
1868
		if($callShell["status"]==="false"){
1869
		
1869
 
1870
			#設置執行失敗
1870
			#設置執行失敗
1871
			$result["status"]="false";
1871
			$result["status"]="false";
1872
 
1872
 
1873
			#設置執行錯誤訊息
1873
			#設置執行錯誤訊息
1874
			$result["error"]=$callShell;
1874
			$result["error"]=$callShell;
1875
 
1875
 
1876
			#回傳結果
1876
			#回傳結果
1877
			return $result;
1877
			return $result;
1878
		
1878
 
1879
			}#if end
1879
			}#if end
1880
			
1880
 
1881
		#函式說明:
1881
		#函式說明:
1882
		#檢查多個字串中的每個字串是否有多個關鍵字
1882
		#檢查多個字串中的每個字串是否有多個關鍵字
1883
		#回傳結果:
1883
		#回傳結果:
1884
		#$result["status"],整體來說,執行是否成功,"true"代表執行成功,"false"代表執行失敗。
1884
		#$result["status"],整體來說,執行是否成功,"true"代表執行成功,"false"代表執行失敗。
1885
		#$result["function"],當前執行的函數名稱.
1885
		#$result["function"],當前執行的函數名稱.
Line 1903... Line 1903...
1903
		#無.
1903
		#無.
1904
		#備註:
1904
		#備註:
1905
		#無.
1905
		#無.
1906
		$findManyKeyWordsFromManyString=search::findManyKeyWordsFromManyString($conf["search::findManyKeyWordsFromManyString"]);
1906
		$findManyKeyWordsFromManyString=search::findManyKeyWordsFromManyString($conf["search::findManyKeyWordsFromManyString"]);
1907
		unset($conf["search::findManyKeyWordsFromManyString"]);
1907
		unset($conf["search::findManyKeyWordsFromManyString"]);
1908
	
1908
 
1909
		#debug
1909
		#debug
1910
		#var_dump(__LINE__,$findManyKeyWordsFromManyString);
1910
		#var_dump(__LINE__,$findManyKeyWordsFromManyString);
1911
	
1911
 
1912
		#如果執行不正常
1912
		#如果執行不正常
1913
		if($findManyKeyWordsFromManyString["status"]==="false"){
1913
		if($findManyKeyWordsFromManyString["status"]==="false"){
1914
		
1914
 
1915
			#設置執行失敗
1915
			#設置執行失敗
1916
			$result["status"]="false";
1916
			$result["status"]="false";
1917
 
1917
 
1918
			#設置執行錯誤訊息
1918
			#設置執行錯誤訊息
1919
			$result["error"]=$findManyKeyWordsFromManyString;
1919
			$result["error"]=$findManyKeyWordsFromManyString;
1920
 
1920
 
1921
			#回傳結果
1921
			#回傳結果
1922
			return $result;
1922
			return $result;
1923
			
1923
 
1924
			}#if end
1924
			}#if end
1925
			
1925
 
1926
		#針對每個有找到關鍵字的來源字串
1926
		#針對每個有找到關鍵字的來源字串
1927
		foreach($findManyKeyWordsFromManyString["keyWordsIncludeStr"] as $keyWordsIncludeStr){
1927
		foreach($findManyKeyWordsFromManyString["keyWordsIncludeStr"] as $keyWordsIncludeStr){
1928
		
1928
 
1929
			#如果有多個關鍵字
1929
			#如果有多個關鍵字
1930
			if(count($keyWordsIncludeStr["keyWords"])>1){
1930
			if(count($keyWordsIncludeStr["keyWords"])>1){
1931
			
1931
 
1932
				#跳過
1932
				#跳過
1933
				continue;
1933
				continue;
1934
			
1934
 
1935
				}#if end
1935
				}#if end
1936
		
1936
 
1937
			#解析使用者名稱
1937
			#解析使用者名稱
1938
			#函式說明:
1938
			#函式說明:
1939
			#將字串特定關鍵字與其前面的內容剔除
1939
			#將字串特定關鍵字與其前面的內容剔除
1940
			#回傳結果:
1940
			#回傳結果:
1941
			#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
1941
			#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
Line 1943... Line 1943...
1943
			#$result["warning"],警告訊息鎮列.
1943
			#$result["warning"],警告訊息鎮列.
1944
			#$result["founded"],有無找到定字串"true"代表有,"false"代表沒有.
1944
			#$result["founded"],有無找到定字串"true"代表有,"false"代表沒有.
1945
			#$result["function"],當前執行的函數名稱.
1945
			#$result["function"],當前執行的函數名稱.
1946
			#$result["argu"],使用的參數.
1946
			#$result["argu"],使用的參數.
1947
			#$result["oriStr"],要處理的原始字串內容.
1947
			#$result["oriStr"],要處理的原始字串內容.
1948
			#$result["content"],處理好的的字串內容.	
1948
			#$result["content"],處理好的的字串內容.
1949
			#必填參數:
1949
			#必填參數:
1950
			#$conf["stringIn"],字串,要處理的字串.
1950
			#$conf["stringIn"],字串,要處理的字串.
1951
			$conf["stringProcess::delStrBeforeKeyWord"]["stringIn"]=$keyWordsIncludeStr["sourceVal"];
1951
			$conf["stringProcess::delStrBeforeKeyWord"]["stringIn"]=$keyWordsIncludeStr["sourceVal"];
1952
			#$conf["keyWord"],字串,特定字串.
1952
			#$conf["keyWord"],字串,特定字串.
1953
			$conf["stringProcess::delStrBeforeKeyWord"]["keyWord"]=$keyWordsIncludeStr["keyWords"][0];
1953
			$conf["stringProcess::delStrBeforeKeyWord"]["keyWord"]=$keyWordsIncludeStr["keyWords"][0];
Line 1960... Line 1960...
1960
			#無.
1960
			#無.
1961
			#備註:
1961
			#備註:
1962
			#無.
1962
			#無.
1963
			$delStrBeforeKeyWord=stringProcess::delStrBeforeKeyWord($conf["stringProcess::delStrBeforeKeyWord"]);
1963
			$delStrBeforeKeyWord=stringProcess::delStrBeforeKeyWord($conf["stringProcess::delStrBeforeKeyWord"]);
1964
			unset($conf["stringProcess::delStrBeforeKeyWord"]);
1964
			unset($conf["stringProcess::delStrBeforeKeyWord"]);
1965
		
1965
 
1966
			#debug
1966
			#debug
1967
			#var_dump(__LINE__,$delStrBeforeKeyWord);
1967
			#var_dump(__LINE__,$delStrBeforeKeyWord);
1968
		
1968
 
1969
			#如果執行不正常
1969
			#如果執行不正常
1970
			if($delStrBeforeKeyWord["status"]==="false"){
1970
			if($delStrBeforeKeyWord["status"]==="false"){
1971
			
1971
 
1972
				#設置執行失敗
1972
				#設置執行失敗
1973
				$result["status"]="false";
1973
				$result["status"]="false";
1974
 
1974
 
1975
				#設置執行錯誤訊息
1975
				#設置執行錯誤訊息
1976
				$result["error"]=$delStrBeforeKeyWord;
1976
				$result["error"]=$delStrBeforeKeyWord;
1977
 
1977
 
1978
				#回傳結果
1978
				#回傳結果
1979
				return $result;
1979
				return $result;
1980
			
1980
 
1981
				}#if end
1981
				}#if end
1982
				
1982
 
1983
			#如果沒有關鍵字
1983
			#如果沒有關鍵字
1984
			if($delStrBeforeKeyWord["founded"]==="false"){
1984
			if($delStrBeforeKeyWord["founded"]==="false"){
1985
			
1985
 
1986
				#設置執行失敗
1986
				#設置執行失敗
1987
				$result["status"]="false";
1987
				$result["status"]="false";
1988
 
1988
 
1989
				#設置執行錯誤訊息
1989
				#設置執行錯誤訊息
1990
				$result["error"]=$delStrBeforeKeyWord;
1990
				$result["error"]=$delStrBeforeKeyWord;
1991
 
1991
 
1992
				#回傳結果
1992
				#回傳結果
1993
				return $result;
1993
				return $result;
1994
			
1994
 
1995
				}#if end
1995
				}#if end
1996
				
1996
 
1997
			#如果不是空字串
1997
			#如果不是空字串
1998
			if(!empty($delStrBeforeKeyWord["content"])){
1998
			if(!empty($delStrBeforeKeyWord["content"])){
1999
			
1999
 
2000
				#取得使用者名稱
2000
				#取得使用者名稱
2001
				$result["phpUser"]=basename($delStrBeforeKeyWord["content"]);
2001
				$result["phpUser"]=basename($delStrBeforeKeyWord["content"]);
2002
			
2002
 
2003
				#結束 foreach
2003
				#結束 foreach
2004
				break;
2004
				break;
2005
			
2005
 
2006
				}#if end
2006
				}#if end
2007
		
2007
 
2008
			}#foreach end
2008
			}#foreach end
2009
		
2009
 
2010
		#如果 $_SERVER['HTTP_USER_AGENT'] 存在
2010
		#如果 $_SERVER['HTTP_USER_AGENT'] 存在
2011
		if(isset($_SERVER['HTTP_USER_AGENT'])){
2011
		if(isset($_SERVER['HTTP_USER_AGENT'])){
2012
 
2012
 
2013
			#var_dump($_SERVER["DOCUMENT_ROOT"]);
2013
			#var_dump($_SERVER["DOCUMENT_ROOT"]);
2014
 
2014
 
Line 2151... Line 2151...
2151
			#預設為空字串,代表非使用者直接觸發
2151
			#預設為空字串,代表非使用者直接觸發
2152
			$result["phpUser"]="";
2152
			$result["phpUser"]="";
2153
 
2153
 
2154
			#如果有 LOGNAME 存在
2154
			#如果有 LOGNAME 存在
2155
			if(isset($_SERVER["LOGNAME"])){
2155
			if(isset($_SERVER["LOGNAME"])){
2156
			
2156
 
2157
				#取得使用該php程式的使用者帳號
2157
				#取得使用該php程式的使用者帳號
2158
				$result["phpUser"]=$_SERVER["LOGNAME"];
2158
				$result["phpUser"]=$_SERVER["LOGNAME"];
2159
		
2159
 
2160
				}#if end
2160
				}#if end
2161
		
2161
 
2162
			#反之
2162
			#反之
2163
			else{
2163
			else{
2164
			
2164
 
2165
				/*
2165
				/*
2166
				LOGNAME=liveuser
2166
				LOGNAME=liveuser
2167
				USERNAME=liveuser
2167
				USERNAME=liveuser
2168
				USER=liveuser
2168
				USER=liveuser
2169
				*/
2169
				*/
2170
			
2170
 
2171
				#嘗試從系統變數取得使用者名稱
2171
				#嘗試從系統變數取得使用者名稱
2172
				#函式說明:
2172
				#函式說明:
2173
				#呼叫shell執行系統命令,並取得回傳的內容.
2173
				#呼叫shell執行系統命令,並取得回傳的內容.
2174
				#回傳結果:
2174
				#回傳結果:
2175
				#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
2175
				#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
Line 2226... Line 2226...
2226
				#備註:
2226
				#備註:
2227
				#不是所有指令都能用apache的身份執行,目前已知java,javac指令無法執行,使用root身份可能會被selinux阻擋.
2227
				#不是所有指令都能用apache的身份執行,目前已知java,javac指令無法執行,使用root身份可能會被selinux阻擋.
2228
				#若使用的 command、argu 參數,含有 ~ 則會被視為字串,若有需要其於 shell 中代表的家目錄位置,可用 fileAccess::tildeToPath 來進行轉換.
2228
				#若使用的 command、argu 參數,含有 ~ 則會被視為字串,若有需要其於 shell 中代表的家目錄位置,可用 fileAccess::tildeToPath 來進行轉換.
2229
				$callShell=external::callShell($conf["external::callShell"]);
2229
				$callShell=external::callShell($conf["external::callShell"]);
2230
				unset($conf["external::callShell"]);
2230
				unset($conf["external::callShell"]);
2231
			
2231
 
2232
				#如果執行失敗
2232
				#如果執行失敗
2233
				if($callShell["status"]==="false"){
2233
				if($callShell["status"]==="false"){
2234
				
2234
 
2235
					#設置執行失敗
2235
					#設置執行失敗
2236
					$result["status"]="false";
2236
					$result["status"]="false";
2237
 
2237
 
2238
					#設置執行錯誤訊息
2238
					#設置執行錯誤訊息
2239
					$result["error"]=$callShell;
2239
					$result["error"]=$callShell;
2240
 
2240
 
2241
					#回傳結果
2241
					#回傳結果
2242
					return $result;
2242
					return $result;
2243
				
2243
 
2244
					}#if end
2244
					}#if end
2245
					
2245
 
2246
				#函式說明:
2246
				#函式說明:
2247
				#檢查多個字串中的每個字串是否有多個關鍵字
2247
				#檢查多個字串中的每個字串是否有多個關鍵字
2248
				#回傳結果:
2248
				#回傳結果:
2249
				#$result["status"],整體來說,執行是否成功,"true"代表執行成功,"false"代表執行失敗。
2249
				#$result["status"],整體來說,執行是否成功,"true"代表執行成功,"false"代表執行失敗。
2250
				#$result["function"],當前執行的函數名稱.
2250
				#$result["function"],當前執行的函數名稱.
Line 2268... Line 2268...
2268
				#無.
2268
				#無.
2269
				#備註:
2269
				#備註:
2270
				#無.
2270
				#無.
2271
				$findManyKeyWordsFromManyString=search::findManyKeyWordsFromManyString($conf["search::findManyKeyWordsFromManyString"]);
2271
				$findManyKeyWordsFromManyString=search::findManyKeyWordsFromManyString($conf["search::findManyKeyWordsFromManyString"]);
2272
				unset($conf["search::findManyKeyWordsFromManyString"]);
2272
				unset($conf["search::findManyKeyWordsFromManyString"]);
2273
			
2273
 
2274
				#debug
2274
				#debug
2275
				#var_dump(__LINE__,$findManyKeyWordsFromManyString);
2275
				#var_dump(__LINE__,$findManyKeyWordsFromManyString);
2276
			
2276
 
2277
				#如果執行不正常
2277
				#如果執行不正常
2278
				if($findManyKeyWordsFromManyString["status"]==="false"){
2278
				if($findManyKeyWordsFromManyString["status"]==="false"){
2279
				
2279
 
2280
					#設置執行失敗
2280
					#設置執行失敗
2281
					$result["status"]="false";
2281
					$result["status"]="false";
2282
 
2282
 
2283
					#設置執行錯誤訊息
2283
					#設置執行錯誤訊息
2284
					$result["error"]=$findManyKeyWordsFromManyString;
2284
					$result["error"]=$findManyKeyWordsFromManyString;
2285
 
2285
 
2286
					#回傳結果
2286
					#回傳結果
2287
					return $result;
2287
					return $result;
2288
					
2288
 
2289
					}#if end
2289
					}#if end
2290
					
2290
 
2291
				#針對每個有找到關鍵字的來源字串
2291
				#針對每個有找到關鍵字的來源字串
2292
				foreach($findManyKeyWordsFromManyString["keyWordsIncludeStr"] as $keyWordsIncludeStr){
2292
				foreach($findManyKeyWordsFromManyString["keyWordsIncludeStr"] as $keyWordsIncludeStr){
2293
				
2293
 
2294
					#如果有多個關鍵字
2294
					#如果有多個關鍵字
2295
					if(count($keyWordsIncludeStr["keyWords"])>1){
2295
					if(count($keyWordsIncludeStr["keyWords"])>1){
2296
					
2296
 
2297
						#跳過
2297
						#跳過
2298
						continue;
2298
						continue;
2299
					
2299
 
2300
						}#if end
2300
						}#if end
2301
				
2301
 
2302
					#解析使用者名稱
2302
					#解析使用者名稱
2303
					#函式說明:
2303
					#函式說明:
2304
					#將字串特定關鍵字與其前面的內容剔除
2304
					#將字串特定關鍵字與其前面的內容剔除
2305
					#回傳結果:
2305
					#回傳結果:
2306
					#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
2306
					#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
Line 2308... Line 2308...
2308
					#$result["warning"],警告訊息鎮列.
2308
					#$result["warning"],警告訊息鎮列.
2309
					#$result["founded"],有無找到定字串"true"代表有,"false"代表沒有.
2309
					#$result["founded"],有無找到定字串"true"代表有,"false"代表沒有.
2310
					#$result["function"],當前執行的函數名稱.
2310
					#$result["function"],當前執行的函數名稱.
2311
					#$result["argu"],使用的參數.
2311
					#$result["argu"],使用的參數.
2312
					#$result["oriStr"],要處理的原始字串內容.
2312
					#$result["oriStr"],要處理的原始字串內容.
2313
					#$result["content"],處理好的的字串內容.	
2313
					#$result["content"],處理好的的字串內容.
2314
					#必填參數:
2314
					#必填參數:
2315
					#$conf["stringIn"],字串,要處理的字串.
2315
					#$conf["stringIn"],字串,要處理的字串.
2316
					$conf["stringProcess::delStrBeforeKeyWord"]["stringIn"]=$keyWordsIncludeStr["sourceVal"];
2316
					$conf["stringProcess::delStrBeforeKeyWord"]["stringIn"]=$keyWordsIncludeStr["sourceVal"];
2317
					#$conf["keyWord"],字串,特定字串.
2317
					#$conf["keyWord"],字串,特定字串.
2318
					$conf["stringProcess::delStrBeforeKeyWord"]["keyWord"]=$keyWordsIncludeStr["keyWords"][0];
2318
					$conf["stringProcess::delStrBeforeKeyWord"]["keyWord"]=$keyWordsIncludeStr["keyWords"][0];
Line 2325... Line 2325...
2325
					#無.
2325
					#無.
2326
					#備註:
2326
					#備註:
2327
					#無.
2327
					#無.
2328
					$delStrBeforeKeyWord=stringProcess::delStrBeforeKeyWord($conf["stringProcess::delStrBeforeKeyWord"]);
2328
					$delStrBeforeKeyWord=stringProcess::delStrBeforeKeyWord($conf["stringProcess::delStrBeforeKeyWord"]);
2329
					unset($conf["stringProcess::delStrBeforeKeyWord"]);
2329
					unset($conf["stringProcess::delStrBeforeKeyWord"]);
2330
				
2330
 
2331
					#debug
2331
					#debug
2332
					#var_dump(__LINE__,$delStrBeforeKeyWord);
2332
					#var_dump(__LINE__,$delStrBeforeKeyWord);
2333
				
2333
 
2334
					#如果執行不正常
2334
					#如果執行不正常
2335
					if($delStrBeforeKeyWord["status"]==="false"){
2335
					if($delStrBeforeKeyWord["status"]==="false"){
2336
					
2336
 
2337
						#設置執行失敗
2337
						#設置執行失敗
2338
						$result["status"]="false";
2338
						$result["status"]="false";
2339
 
2339
 
2340
						#設置執行錯誤訊息
2340
						#設置執行錯誤訊息
2341
						$result["error"]=$delStrBeforeKeyWord;
2341
						$result["error"]=$delStrBeforeKeyWord;
2342
 
2342
 
2343
						#回傳結果
2343
						#回傳結果
2344
						return $result;
2344
						return $result;
2345
					
2345
 
2346
						}#if end
2346
						}#if end
2347
						
2347
 
2348
					#如果沒有關鍵字
2348
					#如果沒有關鍵字
2349
					if($delStrBeforeKeyWord["founded"]==="false"){
2349
					if($delStrBeforeKeyWord["founded"]==="false"){
2350
					
2350
 
2351
						#設置執行失敗
2351
						#設置執行失敗
2352
						$result["status"]="false";
2352
						$result["status"]="false";
2353
 
2353
 
2354
						#設置執行錯誤訊息
2354
						#設置執行錯誤訊息
2355
						$result["error"]=$delStrBeforeKeyWord;
2355
						$result["error"]=$delStrBeforeKeyWord;
2356
 
2356
 
2357
						#回傳結果
2357
						#回傳結果
2358
						return $result;
2358
						return $result;
2359
					
2359
 
2360
						}#if end
2360
						}#if end
2361
						
2361
 
2362
					#如果不是空字串
2362
					#如果不是空字串
2363
					if(!empty($delStrBeforeKeyWord["content"])){
2363
					if(!empty($delStrBeforeKeyWord["content"])){
2364
					
2364
 
2365
						#取得使用者名稱
2365
						#取得使用者名稱
2366
						$result["phpUser"]=basename($delStrBeforeKeyWord["content"]);
2366
						$result["phpUser"]=basename($delStrBeforeKeyWord["content"]);
2367
					
2367
 
2368
						#結束 foreach
2368
						#結束 foreach
2369
						break;
2369
						break;
2370
					
2370
 
2371
						}#if end
2371
						}#if end
2372
				
2372
 
2373
					}#foreach end
2373
					}#foreach end
2374
			
2374
 
2375
				#debug
2375
				#debug
2376
				#var_dump(__LINE__,$result);
2376
				#var_dump(__LINE__,$result);
2377
			
2377
 
2378
				}#else
2378
				}#else
2379
		
2379
 
2380
			#預設的使用者類型為 "regular"
2380
			#預設的使用者類型為 "regular"
2381
			$result["phpUserType"]="regular";
2381
			$result["phpUserType"]="regular";
2382
				
2382
 
2383
			#判斷使用者是否為管理者賬戶 - start
2383
			#判斷使用者是否為管理者賬戶 - start
2384
			
2384
 
2385
			#如果有抓到使用者名稱
2385
			#如果有抓到使用者名稱
2386
			if(!empty($result["phpUser"])){
2386
			if(!empty($result["phpUser"])){
2387
				
2387
 
2388
				#如果是 root 賬號
2388
				#如果是 root 賬號
2389
				if($result["phpUser"]==="root"){
2389
				if($result["phpUser"]==="root"){
2390
				
2390
 
2391
					#設置 phpUserType 為 intrinsic
2391
					#設置 phpUserType 為 intrinsic
2392
					$result["phpUserType"]="intrinsic";
2392
					$result["phpUserType"]="intrinsic";
2393
			
2393
 
2394
					}#if end
2394
					}#if end
2395
				
2395
 
2396
				#反之
2396
				#反之
2397
				else{
2397
				else{
2398
				
2398
 
2399
					#函式說明:
2399
					#函式說明:
2400
					#呼叫shell執行系統命令,並取得回傳的內容.
2400
					#呼叫shell執行系統命令,並取得回傳的內容.
2401
					#回傳結果:
2401
					#回傳結果:
2402
					#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
2402
					#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
2403
					#$result["error"],錯誤訊息陣列.
2403
					#$result["error"],錯誤訊息陣列.
Line 2453... Line 2453...
2453
					#備註:
2453
					#備註:
2454
					#不是所有指令都能用apache的身份執行,目前已知java,javac指令無法執行,使用root身份可能會被selinux阻擋.
2454
					#不是所有指令都能用apache的身份執行,目前已知java,javac指令無法執行,使用root身份可能會被selinux阻擋.
2455
					#若使用的 command、argu 參數,含有 ~ 則會被視為字串,若有需要其於 shell 中代表的家目錄位置,可用 fileAccess::tildeToPath 來進行轉換.
2455
					#若使用的 command、argu 參數,含有 ~ 則會被視為字串,若有需要其於 shell 中代表的家目錄位置,可用 fileAccess::tildeToPath 來進行轉換.
2456
					$callShell=external::callShell($conf["external::callShell"]);
2456
					$callShell=external::callShell($conf["external::callShell"]);
2457
					unset($conf["external::callShell"]);
2457
					unset($conf["external::callShell"]);
2458
				
2458
 
2459
					#如果執行失敗
2459
					#如果執行失敗
2460
					if($callShell["status"]==="false"){
2460
					if($callShell["status"]==="false"){
2461
					
2461
 
2462
						#設置執行失敗
2462
						#設置執行失敗
2463
						$result["status"]="false";
2463
						$result["status"]="false";
2464
 
2464
 
2465
						#設置錯誤訊息
2465
						#設置錯誤訊息
2466
						$result["error"]=$callShell;
2466
						$result["error"]=$callShell;
2467
 
2467
 
2468
						#回傳結果
2468
						#回傳結果
2469
						return $result;
2469
						return $result;
2470
					
2470
 
2471
						}#if end
2471
						}#if end
2472
						
2472
 
2473
					#範例輸出
2473
					#範例輸出
2474
					#   User name: liveuser
2474
					#   User name: liveuser
2475
					# Disposition: regular
2475
					# Disposition: regular
2476
					# Last Passw.: Fri 2023-09-22 08:00:00 CST
2476
					# Last Passw.: Fri 2023-09-22 08:00:00 CST
2477
					#    Login OK: yes
2477
					#    Login OK: yes
Line 2487... Line 2487...
2487
					#       Shell: /bin/bash
2487
					#       Shell: /bin/bash
2488
					# Passwd Chg.: max 273y 9month 1w 4d 19h 30min/warn 1w
2488
					# Passwd Chg.: max 273y 9month 1w 4d 19h 30min/warn 1w
2489
					#Pas. Ch. Now: no
2489
					#Pas. Ch. Now: no
2490
					#   Passwords: 1
2490
					#   Passwords: 1
2491
					#     Service: io.systemd.NameServiceSwitch
2491
					#     Service: io.systemd.NameServiceSwitch
2492
					
2492
 
2493
					#DISPOSITION 為 intrinsic 者代表為系統賬戶 root
2493
					#DISPOSITION 為 intrinsic 者代表為系統賬戶 root
2494
					#DISPOSITION 為 system 者代表為系統賬戶
2494
					#DISPOSITION 為 system 者代表為系統賬戶
2495
					#DISPOSITION 為 regular 者代表為一般賬戶
2495
					#DISPOSITION 為 regular 者代表為一般賬戶
2496
					#一般賬戶的 Aux. Groups 清單若有 wheel 存在,則代表要透過sudo來執行給予系統賬戶權限
2496
					#一般賬戶的 Aux. Groups 清單若有 wheel 存在,則代表要透過sudo來執行給予系統賬戶權限
2497
					
2497
 
2498
					#函式說明:
2498
					#函式說明:
2499
					#檢查多個字串中的每個字串是否有多個關鍵字
2499
					#檢查多個字串中的每個字串是否有多個關鍵字
2500
					#回傳結果:
2500
					#回傳結果:
2501
					#$result["status"],整體來說,執行是否成功,"true"代表執行成功,"false"代表執行失敗。
2501
					#$result["status"],整體來說,執行是否成功,"true"代表執行成功,"false"代表執行失敗。
2502
					#$result["function"],當前執行的函數名稱.
2502
					#$result["function"],當前執行的函數名稱.
Line 2519... Line 2519...
2519
					#無.
2519
					#無.
2520
					#備註:
2520
					#備註:
2521
					#無.
2521
					#無.
2522
					$findManyKeyWordsFromManyString=search::findManyKeyWordsFromManyString($conf["search::findManyKeyWordsFromManyString"]);
2522
					$findManyKeyWordsFromManyString=search::findManyKeyWordsFromManyString($conf["search::findManyKeyWordsFromManyString"]);
2523
					unset($conf["search::findManyKeyWordsFromManyString"]);
2523
					unset($conf["search::findManyKeyWordsFromManyString"]);
2524
					
2524
 
2525
					#如果執行失敗
2525
					#如果執行失敗
2526
					if($findManyKeyWordsFromManyString["status"]==="false"){
2526
					if($findManyKeyWordsFromManyString["status"]==="false"){
2527
					
2527
 
2528
						#設置執行失敗
2528
						#設置執行失敗
2529
						$result["status"]="false";
2529
						$result["status"]="false";
2530
 
2530
 
2531
						#設置錯誤訊息
2531
						#設置錯誤訊息
2532
						$result["error"]=$findManyKeyWordsFromManyString;
2532
						$result["error"]=$findManyKeyWordsFromManyString;
2533
 
2533
 
2534
						#回傳結果
2534
						#回傳結果
2535
						return $result;
2535
						return $result;
2536
					
2536
 
2537
						}#if end
2537
						}#if end
2538
						
2538
 
2539
					#如果沒有關鍵字
2539
					#如果沒有關鍵字
2540
					if($findManyKeyWordsFromManyString["foundedAll"]==="false"){
2540
					if($findManyKeyWordsFromManyString["foundedAll"]==="false"){
2541
					
2541
 
2542
						#設置執行失敗
2542
						#設置執行失敗
2543
						$result["status"]="false";
2543
						$result["status"]="false";
2544
 
2544
 
2545
						#設置錯誤訊息
2545
						#設置錯誤訊息
2546
						$result["error"]=$findManyKeyWordsFromManyString;
2546
						$result["error"]=$findManyKeyWordsFromManyString;
2547
 
2547
 
2548
						#回傳結果
2548
						#回傳結果
2549
						return $result;
2549
						return $result;
2550
					
2550
 
2551
						}#if end
2551
						}#if end
2552
					
2552
 
2553
					#針對每個找到的結果
2553
					#針對每個找到的結果
2554
					foreach($findManyKeyWordsFromManyString["foundedTrueKey"] as $strWithKeyWord){
2554
					foreach($findManyKeyWordsFromManyString["foundedTrueKey"] as $strWithKeyWord){
2555
					
2555
 
2556
						#函式說明:
2556
						#函式說明:
2557
						#將字串特定關鍵字與其前面的內容剔除
2557
						#將字串特定關鍵字與其前面的內容剔除
2558
						#回傳結果:
2558
						#回傳結果:
2559
						#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
2559
						#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
2560
						#$result["error"],錯誤訊息陣列.
2560
						#$result["error"],錯誤訊息陣列.
2561
						#$result["warning"],警告訊息鎮列.
2561
						#$result["warning"],警告訊息鎮列.
2562
						#$result["founded"],有無找到定字串"true"代表有,"false"代表沒有.
2562
						#$result["founded"],有無找到定字串"true"代表有,"false"代表沒有.
2563
						#$result["function"],當前執行的函數名稱.
2563
						#$result["function"],當前執行的函數名稱.
2564
						#$result["argu"],使用的參數.
2564
						#$result["argu"],使用的參數.
2565
						#$result["oriStr"],要處理的原始字串內容.
2565
						#$result["oriStr"],要處理的原始字串內容.
2566
						#$result["content"],處理好的的字串內容.	
2566
						#$result["content"],處理好的的字串內容.
2567
						#必填參數:
2567
						#必填參數:
2568
						#$conf["stringIn"],字串,要處理的字串.
2568
						#$conf["stringIn"],字串,要處理的字串.
2569
						$conf["stringProcess::delStrBeforeKeyWord"]["stringIn"]=$strWithKeyWord;
2569
						$conf["stringProcess::delStrBeforeKeyWord"]["stringIn"]=$strWithKeyWord;
2570
						#$conf["keyWord"],字串,特定字串.
2570
						#$conf["keyWord"],字串,特定字串.
2571
						$conf["stringProcess::delStrBeforeKeyWord"]["keyWord"]="Disposition: ";
2571
						$conf["stringProcess::delStrBeforeKeyWord"]["keyWord"]="Disposition: ";
Line 2578... Line 2578...
2578
						#無.
2578
						#無.
2579
						#備註:
2579
						#備註:
2580
						#無.
2580
						#無.
2581
						$delStrBeforeKeyWord=stringProcess::delStrBeforeKeyWord($conf["stringProcess::delStrBeforeKeyWord"]);
2581
						$delStrBeforeKeyWord=stringProcess::delStrBeforeKeyWord($conf["stringProcess::delStrBeforeKeyWord"]);
2582
						unset($conf["stringProcess::delStrBeforeKeyWord"]);
2582
						unset($conf["stringProcess::delStrBeforeKeyWord"]);
2583
					
2583
 
2584
						#如果執行失敗
2584
						#如果執行失敗
2585
						if($delStrBeforeKeyWord["status"]==="false"){
2585
						if($delStrBeforeKeyWord["status"]==="false"){
2586
						
2586
 
2587
							#設置執行失敗
2587
							#設置執行失敗
2588
							$result["status"]="false";
2588
							$result["status"]="false";
2589
 
2589
 
2590
							#設置錯誤訊息
2590
							#設置錯誤訊息
2591
							$result["error"]=$delStrBeforeKeyWord;
2591
							$result["error"]=$delStrBeforeKeyWord;
2592
 
2592
 
2593
							#回傳結果
2593
							#回傳結果
2594
							return $result;
2594
							return $result;
2595
						
2595
 
2596
							}#if end
2596
							}#if end
2597
							
2597
 
2598
						#如果應該要存在的關鍵字不存在
2598
						#如果應該要存在的關鍵字不存在
2599
						if($delStrBeforeKeyWord["founded"]==="false"){
2599
						if($delStrBeforeKeyWord["founded"]==="false"){
2600
						
2600
 
2601
							#設置執行失敗
2601
							#設置執行失敗
2602
							$result["status"]="false";
2602
							$result["status"]="false";
2603
 
2603
 
2604
							#設置錯誤訊息
2604
							#設置錯誤訊息
2605
							$result["error"]=$delStrBeforeKeyWord;
2605
							$result["error"]=$delStrBeforeKeyWord;
2606
 
2606
 
2607
							#回傳結果
2607
							#回傳結果
2608
							return $result;
2608
							return $result;
2609
						
2609
 
2610
							}#if end
2610
							}#if end
2611
							
2611
 
2612
						#判斷賬戶類型
2612
						#判斷賬戶類型
2613
						switch($delStrBeforeKeyWord["content"]){
2613
						switch($delStrBeforeKeyWord["content"]){
2614
						
2614
 
2615
							#若是 root
2615
							#若是 root
2616
							case "intrinsic":
2616
							case "intrinsic":
2617
						
2617
 
2618
								break;
2618
								break;
2619
								
2619
 
2620
							#若是系統賬戶
2620
							#若是系統賬戶
2621
							case "system";
2621
							case "system";
2622
							
2622
 
2623
								break;
2623
								break;
2624
								
2624
 
2625
							#若是一般使用者
2625
							#若是一般使用者
2626
							case "regular";
2626
							case "regular";
2627
							
2627
 
2628
								#函式說明:
2628
								#函式說明:
2629
								#檢查多個字串中的每個字串是否有多個關鍵字
2629
								#檢查多個字串中的每個字串是否有多個關鍵字
2630
								#回傳結果:
2630
								#回傳結果:
2631
								#$result["status"],整體來說,執行是否成功,"true"代表執行成功,"false"代表執行失敗。
2631
								#$result["status"],整體來說,執行是否成功,"true"代表執行成功,"false"代表執行失敗。
2632
								#$result["function"],當前執行的函數名稱.
2632
								#$result["function"],當前執行的函數名稱.
Line 2649... Line 2649...
2649
								#無.
2649
								#無.
2650
								#備註:
2650
								#備註:
2651
								#無.
2651
								#無.
2652
								$findManyKeyWordsFromManyString=search::findManyKeyWordsFromManyString($conf["search::findManyKeyWordsFromManyString"]);
2652
								$findManyKeyWordsFromManyString=search::findManyKeyWordsFromManyString($conf["search::findManyKeyWordsFromManyString"]);
2653
								unset($conf["search::findManyKeyWordsFromManyString"]);
2653
								unset($conf["search::findManyKeyWordsFromManyString"]);
2654
								
2654
 
2655
								#如果執行失敗
2655
								#如果執行失敗
2656
								if($findManyKeyWordsFromManyString["status"]==="false"){
2656
								if($findManyKeyWordsFromManyString["status"]==="false"){
2657
								
2657
 
2658
									#設置執行失敗
2658
									#設置執行失敗
2659
									$result["status"]="false";
2659
									$result["status"]="false";
2660
 
2660
 
2661
									#設置錯誤訊息
2661
									#設置錯誤訊息
2662
									$result["error"]=$findManyKeyWordsFromManyString;
2662
									$result["error"]=$findManyKeyWordsFromManyString;
2663
 
2663
 
2664
									#回傳結果
2664
									#回傳結果
2665
									return $result;
2665
									return $result;
2666
								
2666
 
2667
									}#if end
2667
									}#if end
2668
								
2668
 
2669
								#初始化執行者所屬的群組
2669
								#初始化執行者所屬的群組
2670
								$groups=array();
2670
								$groups=array();
2671
								
2671
 
2672
								#如果沒有關鍵字
2672
								#如果沒有關鍵字
2673
								if($findManyKeyWordsFromManyString["foundedAll"]==="false"){
2673
								if($findManyKeyWordsFromManyString["foundedAll"]==="false"){
2674
								
2674
 
2675
									#代表使用者所屬的群組只有自己
2675
									#代表使用者所屬的群組只有自己
2676
									$groups[]=$result["phpUser"];
2676
									$groups[]=$result["phpUser"];
2677
									
2677
 
2678
									}#if end
2678
									}#if end
2679
									
2679
 
2680
								#反之,代表屬於多個群組.
2680
								#反之,代表屬於多個群組.
2681
								else{
2681
								else{
2682
								
2682
 
2683
									#針對每個找到的結果
2683
									#針對每個找到的結果
2684
									foreach($findManyKeyWordsFromManyString["foundedTrueKey"] as $groupStartIndex=>$strWithKeyWord){
2684
									foreach($findManyKeyWordsFromManyString["foundedTrueKey"] as $groupStartIndex=>$strWithKeyWord){
2685
									
2685
 
2686
										#函式說明:
2686
										#函式說明:
2687
										#將字串特定關鍵字與其前面的內容剔除
2687
										#將字串特定關鍵字與其前面的內容剔除
2688
										#回傳結果:
2688
										#回傳結果:
2689
										#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
2689
										#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
2690
										#$result["error"],錯誤訊息陣列.
2690
										#$result["error"],錯誤訊息陣列.
2691
										#$result["warning"],警告訊息鎮列.
2691
										#$result["warning"],警告訊息鎮列.
2692
										#$result["founded"],有無找到定字串"true"代表有,"false"代表沒有.
2692
										#$result["founded"],有無找到定字串"true"代表有,"false"代表沒有.
2693
										#$result["function"],當前執行的函數名稱.
2693
										#$result["function"],當前執行的函數名稱.
2694
										#$result["argu"],使用的參數.
2694
										#$result["argu"],使用的參數.
2695
										#$result["oriStr"],要處理的原始字串內容.
2695
										#$result["oriStr"],要處理的原始字串內容.
2696
										#$result["content"],處理好的的字串內容.	
2696
										#$result["content"],處理好的的字串內容.
2697
										#必填參數:
2697
										#必填參數:
2698
										#$conf["stringIn"],字串,要處理的字串.
2698
										#$conf["stringIn"],字串,要處理的字串.
2699
										$conf["stringProcess::delStrBeforeKeyWord"]["stringIn"]=$strWithKeyWord;
2699
										$conf["stringProcess::delStrBeforeKeyWord"]["stringIn"]=$strWithKeyWord;
2700
										#$conf["keyWord"],字串,特定字串.
2700
										#$conf["keyWord"],字串,特定字串.
2701
										$conf["stringProcess::delStrBeforeKeyWord"]["keyWord"]="Aux. Groups: ";
2701
										$conf["stringProcess::delStrBeforeKeyWord"]["keyWord"]="Aux. Groups: ";
Line 2708... Line 2708...
2708
										#無.
2708
										#無.
2709
										#備註:
2709
										#備註:
2710
										#無.
2710
										#無.
2711
										$delStrBeforeKeyWord=stringProcess::delStrBeforeKeyWord($conf["stringProcess::delStrBeforeKeyWord"]);
2711
										$delStrBeforeKeyWord=stringProcess::delStrBeforeKeyWord($conf["stringProcess::delStrBeforeKeyWord"]);
2712
										unset($conf["stringProcess::delStrBeforeKeyWord"]);
2712
										unset($conf["stringProcess::delStrBeforeKeyWord"]);
2713
									
2713
 
2714
										#如果執行失敗
2714
										#如果執行失敗
2715
										if($delStrBeforeKeyWord["status"]==="false"){
2715
										if($delStrBeforeKeyWord["status"]==="false"){
2716
										
2716
 
2717
											#設置執行失敗
2717
											#設置執行失敗
2718
											$result["status"]="false";
2718
											$result["status"]="false";
2719
 
2719
 
2720
											#設置錯誤訊息
2720
											#設置錯誤訊息
2721
											$result["error"]=$delStrBeforeKeyWord;
2721
											$result["error"]=$delStrBeforeKeyWord;
2722
 
2722
 
2723
											#回傳結果
2723
											#回傳結果
2724
											return $result;
2724
											return $result;
2725
										
2725
 
2726
											}#if end
2726
											}#if end
2727
											
2727
 
2728
										#如果應該要存在的關鍵字不存在
2728
										#如果應該要存在的關鍵字不存在
2729
										if($delStrBeforeKeyWord["founded"]==="false"){
2729
										if($delStrBeforeKeyWord["founded"]==="false"){
2730
										
2730
 
2731
											#設置執行失敗
2731
											#設置執行失敗
2732
											$result["status"]="false";
2732
											$result["status"]="false";
2733
 
2733
 
2734
											#設置錯誤訊息
2734
											#設置錯誤訊息
2735
											$result["error"]=$delStrBeforeKeyWord;
2735
											$result["error"]=$delStrBeforeKeyWord;
2736
 
2736
 
2737
											#回傳結果
2737
											#回傳結果
2738
											return $result;
2738
											return $result;
2739
										
2739
 
2740
											}#if end
2740
											}#if end
2741
											
2741
 
2742
										#設置該用戶屬的群組之一
2742
										#設置該用戶屬的群組之一
2743
										$groups[]=$delStrBeforeKeyWord["content"];
2743
										$groups[]=$delStrBeforeKeyWord["content"];
2744
									
2744
 
2745
										#取得群組資訊之後的陣列內容
2745
										#取得群組資訊之後的陣列內容
2746
										#函式說明:
2746
										#函式說明:
2747
										#將陣列進行切割
2747
										#將陣列進行切割
2748
										#回傳結果:
2748
										#回傳結果:
2749
										#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
2749
										#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
Line 2766... Line 2766...
2766
										#無.
2766
										#無.
2767
										#備註:
2767
										#備註:
2768
										#無.
2768
										#無.
2769
										$split=arrays::split($conf["arrays::split"]);
2769
										$split=arrays::split($conf["arrays::split"]);
2770
										unset($conf["arrays::split"]);
2770
										unset($conf["arrays::split"]);
2771
									
2771
 
2772
										#如果執行失敗
2772
										#如果執行失敗
2773
										if($split["status"]==="false"){
2773
										if($split["status"]==="false"){
2774
										
2774
 
2775
											#設置執行失敗
2775
											#設置執行失敗
2776
											$result["status"]="false";
2776
											$result["status"]="false";
2777
 
2777
 
2778
											#設置錯誤訊息
2778
											#設置錯誤訊息
2779
											$result["error"]=$split;
2779
											$result["error"]=$split;
2780
 
2780
 
2781
											#回傳結果
2781
											#回傳結果
2782
											return $result;
2782
											return $result;
2783
										
2783
 
2784
											}#if end
2784
											}#if end
2785
										
2785
 
2786
										#可能為第1個外的群組資訊陣列
2786
										#可能為第1個外的群組資訊陣列
2787
										#$split["content"]["leftR"];
2787
										#$split["content"]["leftR"];
2788
										
2788
 
2789
										#函式說明:
2789
										#函式說明:
2790
										#檢查多個字串中的每個字串是否有多個關鍵字
2790
										#檢查多個字串中的每個字串是否有多個關鍵字
2791
										#回傳結果:
2791
										#回傳結果:
2792
										#$result["status"],整體來說,執行是否成功,"true"代表執行成功,"false"代表執行失敗。
2792
										#$result["status"],整體來說,執行是否成功,"true"代表執行成功,"false"代表執行失敗。
2793
										#$result["function"],當前執行的函數名稱.
2793
										#$result["function"],當前執行的函數名稱.
Line 2810... Line 2810...
2810
										#無.
2810
										#無.
2811
										#備註:
2811
										#備註:
2812
										#無.
2812
										#無.
2813
										$findManyKeyWordsFromManyString=search::findManyKeyWordsFromManyString($conf["search::findManyKeyWordsFromManyString"]);
2813
										$findManyKeyWordsFromManyString=search::findManyKeyWordsFromManyString($conf["search::findManyKeyWordsFromManyString"]);
2814
										unset($conf["search::findManyKeyWordsFromManyString"]);
2814
										unset($conf["search::findManyKeyWordsFromManyString"]);
2815
										
2815
 
2816
										#如果執行失敗
2816
										#如果執行失敗
2817
										if($findManyKeyWordsFromManyString["status"]==="false"){
2817
										if($findManyKeyWordsFromManyString["status"]==="false"){
2818
										
2818
 
2819
											#設置執行失敗
2819
											#設置執行失敗
2820
											$result["status"]="false";
2820
											$result["status"]="false";
2821
 
2821
 
2822
											#設置錯誤訊息
2822
											#設置錯誤訊息
2823
											$result["error"]=$findManyKeyWordsFromManyString;
2823
											$result["error"]=$findManyKeyWordsFromManyString;
2824
 
2824
 
2825
											#回傳結果
2825
											#回傳結果
2826
											return $result;
2826
											return $result;
2827
										
2827
 
2828
											}#if end
2828
											}#if end
2829
											
2829
 
2830
										#如果沒有關鍵字
2830
										#如果沒有關鍵字
2831
										if($findManyKeyWordsFromManyString["foundedAll"]==="false"){
2831
										if($findManyKeyWordsFromManyString["foundedAll"]==="false"){
2832
										
2832
 
2833
											#設置執行失敗
2833
											#設置執行失敗
2834
											$result["status"]="false";
2834
											$result["status"]="false";
2835
 
2835
 
2836
											#設置錯誤訊息
2836
											#設置錯誤訊息
2837
											$result["error"]=$findManyKeyWordsFromManyString;
2837
											$result["error"]=$findManyKeyWordsFromManyString;
2838
 
2838
 
2839
											#回傳結果
2839
											#回傳結果
2840
											return $result;
2840
											return $result;
2841
										
2841
 
2842
											}#if end
2842
											}#if end
2843
											
2843
 
2844
										#針對每個群組名稱
2844
										#針對每個群組名稱
2845
										foreach($findManyKeyWordsFromManyString["foundedFalseKey"] as $group){
2845
										foreach($findManyKeyWordsFromManyString["foundedFalseKey"] as $group){
2846
										
2846
 
2847
											#記錄group
2847
											#記錄group
2848
											$groups[]=trim($group);
2848
											$groups[]=trim($group);
2849
										
2849
 
2850
											}#foreach end 
2850
											}#foreach end
2851
									
2851
 
2852
										#檢查有無 wheel 群組在裡面
2852
										#檢查有無 wheel 群組在裡面
2853
										#函式說明:
2853
										#函式說明:
2854
										#檢查一個數值是否與陣列裏面的元素相同,找到一個相符合的元素後就會停止搜尋.
2854
										#檢查一個數值是否與陣列裏面的元素相同,找到一個相符合的元素後就會停止搜尋.
2855
										#回傳結果:
2855
										#回傳結果:
2856
										#$result["status"],"true"表示執行正確,"false"表示執行錯誤.
2856
										#$result["status"],"true"表示執行正確,"false"表示執行錯誤.
Line 2871... Line 2871...
2871
										#無.
2871
										#無.
2872
										#備註:
2872
										#備註:
2873
										#無.
2873
										#無.
2874
										$getEqualVar=search::getEqualVar($conf["cmd::getEqualVar"]);
2874
										$getEqualVar=search::getEqualVar($conf["cmd::getEqualVar"]);
2875
										unset($conf["cmd::getEqualVar"]);
2875
										unset($conf["cmd::getEqualVar"]);
2876
									
2876
 
2877
										#如果執行失敗
2877
										#如果執行失敗
2878
										if($getEqualVar["status"]==="false"){
2878
										if($getEqualVar["status"]==="false"){
2879
										
2879
 
2880
											#設置執行失敗
2880
											#設置執行失敗
2881
											$result["status"]="false";
2881
											$result["status"]="false";
2882
 
2882
 
2883
											#設置錯誤訊息
2883
											#設置錯誤訊息
2884
											$result["error"]=$getEqualVar;
2884
											$result["error"]=$getEqualVar;
2885
 
2885
 
2886
											#回傳結果
2886
											#回傳結果
2887
											return $result;
2887
											return $result;
2888
										
2888
 
2889
											}#if end
2889
											}#if end
2890
											
2890
 
2891
										#如果是 可以用 sudo 的賬號
2891
										#如果是 可以用 sudo 的賬號
2892
										if($getEqualVar["founded"]==="true"){
2892
										if($getEqualVar["founded"]==="true"){
2893
										
2893
 
2894
											#設置為 wheel 群組的成員
2894
											#設置為 wheel 群組的成員
2895
											$result["phpUserType"]="wheel";
2895
											$result["phpUserType"]="wheel";
2896
										
2896
 
2897
											}#if end
2897
											}#if end
2898
									
2898
 
2899
										#只要找到一個,結束foreach
2899
										#只要找到一個,結束foreach
2900
										break;
2900
										break;
2901
									
2901
 
2902
										}#else end
2902
										}#else end
2903
							
2903
 
2904
								}#foreach end
2904
								}#foreach end
2905
							
2905
 
2906
								break;
2906
								break;
2907
						
2907
 
2908
							}#switch end
2908
							}#switch end
2909
					
2909
 
2910
						}#foreach end
2910
						}#foreach end
2911
				
2911
 
2912
					}#else end
2912
					}#else end
2913
					
2913
 
2914
				}#if end
2914
				}#if end
2915
			
2915
 
2916
			#取得server的ip
2916
			#取得server的ip
2917
			$result["serverIp"]=gethostbyname(gethostname());
2917
			$result["serverIp"]=gethostbyname(gethostname());
2918
 
2918
 
2919
			#設置通訊協定
2919
			#設置通訊協定
2920
			$result["scheme"]="file";
2920
			$result["scheme"]="file";
2921
 
2921
 
2922
			#設置為cmd模式
2922
			#設置為cmd模式
2923
			$result["mode"]="cmd";
2923
			$result["mode"]="cmd";
2924
			
2924
 
2925
			#設置用戶端要求的完整網址
2925
			#設置用戶端要求的完整網址
2926
			$result["requestUriFull"]=__FILE__;
2926
			$result["requestUriFull"]=__FILE__;
2927
 
2927
 
2928
			#函式說明:
2928
			#函式說明:
2929
			#將字串特定關鍵字與其前面的內容剔除
2929
			#將字串特定關鍵字與其前面的內容剔除
Line 2933... Line 2933...
2933
			#$result["warning"],警告訊息鎮列.
2933
			#$result["warning"],警告訊息鎮列.
2934
			#$result["founded"],有無找到定字串"true"代表有,"false"代表沒有.
2934
			#$result["founded"],有無找到定字串"true"代表有,"false"代表沒有.
2935
			#$result["function"],當前執行的函數名稱.
2935
			#$result["function"],當前執行的函數名稱.
2936
			#$result["argu"],使用的參數.
2936
			#$result["argu"],使用的參數.
2937
			#$result["oriStr"],要處理的原始字串內容.
2937
			#$result["oriStr"],要處理的原始字串內容.
2938
			#$result["content"],處理好的的字串內容.	
2938
			#$result["content"],處理好的的字串內容.
2939
			#必填參數:
2939
			#必填參數:
2940
			#$conf["stringIn"],字串,要處理的字串.
2940
			#$conf["stringIn"],字串,要處理的字串.
2941
			$conf["stringProcess::delStrBeforeKeyWord"]["stringIn"]=$result["requestUriFull"];
2941
			$conf["stringProcess::delStrBeforeKeyWord"]["stringIn"]=$result["requestUriFull"];
2942
			#$conf["keyWord"],字串,特定字串.
2942
			#$conf["keyWord"],字串,特定字串.
2943
			$conf["stringProcess::delStrBeforeKeyWord"]["keyWord"]="/";
2943
			$conf["stringProcess::delStrBeforeKeyWord"]["keyWord"]="/";
Line 2962... Line 2962...
2962
				#設置執行錯誤訊息
2962
				#設置執行錯誤訊息
2963
				$result["error"]=$insertData;
2963
				$result["error"]=$insertData;
2964
 
2964
 
2965
				#回傳結果
2965
				#回傳結果
2966
				return $result;
2966
				return $result;
2967
				
2967
 
2968
				}#if end
2968
				}#if end
2969
 
2969
 
2970
			#取得目前要求執行的網址爲
2970
			#取得目前要求執行的網址爲
2971
			$result["requestUri"]=$delStrBeforeKeyWord["content"];
2971
			$result["requestUri"]=$delStrBeforeKeyWord["content"];
2972
 
2972
 
Line 2979... Line 2979...
2979
		#$result["content"],取得的header陣列.
2979
		#$result["content"],取得的header陣列.
2980
		#$result["function"],當前執行的函數名稱.
2980
		#$result["function"],當前執行的函數名稱.
2981
		#必填參數:
2981
		#必填參數:
2982
		#無
2982
		#無
2983
		#可省略參數:
2983
		#可省略參數:
2984
		#無 
2984
		#無
2985
		#參考資料:
2985
		#參考資料:
2986
		#無.
2986
		#無.
2987
		#備註:
2987
		#備註:
2988
		#無.
2988
		#無.
2989
		$getReceivedHeaders=header::getReceivedHeaders();
2989
		$getReceivedHeaders=header::getReceivedHeaders();
2990
		
2990
 
2991
		#如果執行失敗
2991
		#如果執行失敗
2992
		if($getReceivedHeaders["status"]=="false"){
2992
		if($getReceivedHeaders["status"]=="false"){
2993
 
2993
 
2994
			#設置執行失敗
2994
			#設置執行失敗
2995
			$result["status"]="false";
2995
			$result["status"]="false";
Line 2999... Line 2999...
2999
 
2999
 
3000
			#回傳結果
3000
			#回傳結果
3001
			return $result;
3001
			return $result;
3002
 
3002
 
3003
			}#if end
3003
			}#if end
3004
		
3004
 
3005
		#設置取得的 header 陣列
3005
		#設置取得的 header 陣列
3006
		$result["header"]=$getReceivedHeaders["content"];
3006
		$result["header"]=$getReceivedHeaders["content"];
3007
 
3007
 
3008
		#取得讀取到 body 字串
3008
		#取得讀取到 body 字串
3009
		$result["body"]=file_get_contents('php://input');
3009
		$result["body"]=file_get_contents('php://input');
Line 3092... Line 3092...
3092
 
3092
 
3093
			}#if end
3093
			}#if end
3094
 
3094
 
3095
		#如果沒有變數 addr
3095
		#如果沒有變數 addr
3096
		if(!isset($conf["addr"])){
3096
		if(!isset($conf["addr"])){
3097
		
3097
 
3098
			#取得用戶端ip
3098
			#取得用戶端ip
3099
			#函式說明:
3099
			#函式說明:
3100
			#回傳用戶端的IP位置
3100
			#回傳用戶端的IP位置
3101
			#回傳的結果:
3101
			#回傳的結果:
3102
			#$result,用戶端的ip,若在命令列下執行則回傳getServerIP()的結果.
3102
			#$result,用戶端的ip,若在命令列下執行則回傳getServerIP()的結果.
3103
			$conf["addr"]=csInformation::getClientIP();
3103
			$conf["addr"]=csInformation::getClientIP();
3104
				
3104
 
3105
			}#if end
3105
			}#if end
3106
			
3106
 
3107
		#查詢相關地理位置資訊的網址
3107
		#查詢相關地理位置資訊的網址
3108
		$endPoint="https://tools.keycdn.com/geo.json?host=".$conf["addr"];
3108
		$endPoint="https://tools.keycdn.com/geo.json?host=".$conf["addr"];
3109
 
3109
 
3110
		#函式說明:
3110
		#函式說明:
3111
		#運行curl cmd
3111
		#運行curl cmd
Line 3177... Line 3177...
3177
			 		"datetime":"2015-05-22 09:10:35"
3177
			 		"datetime":"2015-05-22 09:10:35"
3178
			  		}
3178
			  		}
3179
		   		}
3179
		   		}
3180
			}
3180
			}
3181
		}
3181
		}
3182
		
3182
 
3183
		or
3183
		or
3184
 
3184
 
3185
		{
3185
		{
3186
		   "status":"error",
3186
		   "status":"error",
3187
		   "description":"Hostname did not resolve any IP."
3187
		   "description":"Hostname did not resolve any IP."
Line 3209... Line 3209...
3209
 
3209
 
3210
		#回傳結果
3210
		#回傳結果
3211
		return $result;
3211
		return $result;
3212
 
3212
 
3213
		}#function getIpGeo end
3213
		}#function getIpGeo end
3214
		
3214
 
3215
	/*
3215
	/*
3216
	#函式說明:
3216
	#函式說明:
3217
	#將ipv4轉換成ipv6
3217
	#將ipv4轉換成ipv6
3218
	#回傳結果:
3218
	#回傳結果:
3219
	#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
3219
	#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
Line 3231... Line 3231...
3231
	#https://www.ultratools.com/tools/ipv4toipv6
3231
	#https://www.ultratools.com/tools/ipv4toipv6
3232
	#備註:
3232
	#備註:
3233
	#無.
3233
	#無.
3234
	*/
3234
	*/
3235
	public static function ipv4toipv6($conf){
3235
	public static function ipv4toipv6($conf){
3236
		
3236
 
3237
		#初始化要回傳的結果
3237
		#初始化要回傳的結果
3238
		$result=array();
3238
		$result=array();
3239
 
3239
 
3240
		#取得當前執行的函數名稱
3240
		#取得當前執行的函數名稱
3241
		$result["function"]=__FUNCTION__;
3241
		$result["function"]=__FUNCTION__;
Line 3262... Line 3262...
3262
 
3262
 
3263
			#回傳結果
3263
			#回傳結果
3264
			return $result;
3264
			return $result;
3265
 
3265
 
3266
			}#if end
3266
			}#if end
3267
			
3267
 
3268
		#函式說明:
3268
		#函式說明:
3269
		#檢查必填與可省略的參數,可省略參數可指定預設要給與什麼數值內容。
3269
		#檢查必填與可省略的參數,可省略參數可指定預設要給與什麼數值內容。
3270
		#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
3270
		#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
3271
		#$reuslt["error"],執行不正常結束的錯訊息陣列.
3271
		#$reuslt["error"],執行不正常結束的錯訊息陣列.
3272
		#$result["function"],當前執行的函式名稱.
3272
		#$result["function"],當前執行的函式名稱.
Line 3311... Line 3311...
3311
		#$conf["arrayCountEqualCheck"][]=array();
3311
		#$conf["arrayCountEqualCheck"][]=array();
3312
		#參考資料來源:
3312
		#參考資料來源:
3313
		#array_keys=>http://php.net/manual/en/function.array-keys.php
3313
		#array_keys=>http://php.net/manual/en/function.array-keys.php
3314
		$checkArguments=variableCheck::checkArguments($conf["variable::checkArguments"]);
3314
		$checkArguments=variableCheck::checkArguments($conf["variable::checkArguments"]);
3315
		unset($conf["variable::checkArguments"]);
3315
		unset($conf["variable::checkArguments"]);
3316
		
3316
 
3317
		#如果檢查參數失敗
3317
		#如果檢查參數失敗
3318
		if($checkArguments["status"]==="false"){
3318
		if($checkArguments["status"]==="false"){
3319
		
3319
 
3320
			#設置執行不正常
3320
			#設置執行不正常
3321
			$result["status"]="false";
3321
			$result["status"]="false";
3322
		
3322
 
3323
			#設置錯誤訊息
3323
			#設置錯誤訊息
3324
			$result["error"]=$checkArguments;
3324
			$result["error"]=$checkArguments;
3325
			
3325
 
3326
			#回傳結果
3326
			#回傳結果
3327
			return $result;
3327
			return $result;
3328
		
3328
 
3329
			}#if end
3329
			}#if end
3330
		
3330
 
3331
		#分割每個ipv4的數字
3331
		#分割每個ipv4的數字
3332
		#函式說明:
3332
		#函式說明:
3333
		#將固定格式的字串分開,並回傳分開的結果。
3333
		#將固定格式的字串分開,並回傳分開的結果。
3334
		#回傳結果:
3334
		#回傳結果:
3335
		#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
3335
		#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
Line 3345... Line 3345...
3345
		$conf["stringProcess::spiltString"]["spiltSymbol"]=".";#爲以哪個符號作爲分割
3345
		$conf["stringProcess::spiltString"]["spiltSymbol"]=".";#爲以哪個符號作爲分割
3346
		#可省略參數:
3346
		#可省略參數:
3347
		#$conf["allowEmptyStr"],是否允許分割出來空字串,預設為"false"不允許;"true"代表允許.
3347
		#$conf["allowEmptyStr"],是否允許分割出來空字串,預設為"false"不允許;"true"代表允許.
3348
		$conf["stringProcess::spiltString"]["allowEmptyStr"]="false";
3348
		$conf["stringProcess::spiltString"]["allowEmptyStr"]="false";
3349
		$spiltString=stringProcess::spiltString($conf["stringProcess::spiltString"]);
3349
		$spiltString=stringProcess::spiltString($conf["stringProcess::spiltString"]);
3350
		unset($conf["stringProcess::spiltString"]);		
3350
		unset($conf["stringProcess::spiltString"]);
3351
		
3351
 
3352
		#如果執行失敗
3352
		#如果執行失敗
3353
		if($spiltString["status"]==="false"){
3353
		if($spiltString["status"]==="false"){
3354
		
3354
 
3355
			#設置執行不正常
3355
			#設置執行不正常
3356
			$result["status"]="false";
3356
			$result["status"]="false";
3357
		
3357
 
3358
			#設置錯誤訊息
3358
			#設置錯誤訊息
3359
			$result["error"]=$spiltString;
3359
			$result["error"]=$spiltString;
3360
			
3360
 
3361
			#回傳結果
3361
			#回傳結果
3362
			return $result;
3362
			return $result;
3363
		
3363
 
3364
			}#if end
3364
			}#if end
3365
			
3365
 
3366
		#如果沒有找到切割用的關鍵字
3366
		#如果沒有找到切割用的關鍵字
3367
		if($spiltString["found"]==="false"){
3367
		if($spiltString["found"]==="false"){
3368
		
3368
 
3369
			#設置執行不正常
3369
			#設置執行不正常
3370
			$result["status"]="false";
3370
			$result["status"]="false";
3371
		
3371
 
3372
			#設置錯誤訊息
3372
			#設置錯誤訊息
3373
			$result["error"]=$spiltString;
3373
			$result["error"]=$spiltString;
3374
			
3374
 
3375
			#回傳結果
3375
			#回傳結果
3376
			return $result;
3376
			return $result;
3377
		
3377
 
3378
			}#if end
3378
			}#if end
3379
			
3379
 
3380
		#如果沒有切割出4段
3380
		#如果沒有切割出4段
3381
		if($spiltString["dataCounts"]!==4){
3381
		if($spiltString["dataCounts"]!==4){
3382
		
3382
 
3383
			#設置執行不正常
3383
			#設置執行不正常
3384
			$result["status"]="false";
3384
			$result["status"]="false";
3385
		
3385
 
3386
			#設置錯誤訊息
3386
			#設置錯誤訊息
3387
			$result["error"]=$spiltString;
3387
			$result["error"]=$spiltString;
3388
			
3388
 
3389
			#回傳結果
3389
			#回傳結果
3390
			return $result;
3390
			return $result;
3391
		
3391
 
3392
			}#if end
3392
			}#if end
3393
			
3393
 
3394
		#轉換每段ip位置為16進位
3394
		#轉換每段ip位置為16進位
3395
		$ipv6="0:0:0:0:0:ffff:".sprintf('%2x',$spiltString["dataArray"][0]).sprintf('%02x',$spiltString["dataArray"][1]).":".sprintf('%2x',$spiltString["dataArray"][2]).sprintf('%02x',$spiltString["dataArray"][3]);
3395
		$ipv6="0:0:0:0:0:ffff:".sprintf('%2x',$spiltString["dataArray"][0]).sprintf('%02x',$spiltString["dataArray"][1]).":".sprintf('%2x',$spiltString["dataArray"][2]).sprintf('%02x',$spiltString["dataArray"][3]);
3396
			
3396
 
3397
		#取得 ipv6
3397
		#取得 ipv6
3398
		$result["content"]=$ipv6;
3398
		$result["content"]=$ipv6;
3399
		
3399
 
3400
		#設置執行正常
3400
		#設置執行正常
3401
		$result["status"]="true";
3401
		$result["status"]="true";
3402
		
3402
 
3403
		#回傳結果
3403
		#回傳結果
3404
		return $result;
3404
		return $result;
3405
		
3405
 
3406
		}#function ipv4toipv6 end
3406
		}#function ipv4toipv6 end
3407
 
3407
 
3408
	}#class csInformation end
3408
	}#class csInformation end
3409
 
3409
 
3410
?>
3410
?>