Subversion Repositories qbpwcf-lib(archive)

Rev

Rev 638 | Rev 717 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
529 liveuser 1
<?php
2
 
3
/*
4
 
5
        QBPWCF, Quick Build PHP website Component base on Fedora Linux.
638 liveuser 6
    Copyright (C) 2015~2024 Min-Jhin,Chen
529 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
#使用命名空間qbpwcf
26
namespace qbpwcf;
27
 
714 liveuser 28
#以該檔案的實際位置的 lib path 為 include path 首位
29
exec("cd ".pathinfo(__FILE__)["dirname"]."/../qbpwcf;pwd;",$output,$status);
30
set_include_path($output[0].PATH_SEPARATOR.get_include_path());
31
 
529 liveuser 32
#匯入套件
714 liveuser 33
require_once("allInOne.php");
529 liveuser 34
 
35
#建議的log位置
36
$logFile=$_SERVER["DOCUMENT_ROOT"].$_SERVER["PHP_SELF"].".log";
37
 
714 liveuser 38
#要使用的範例name
39
#$nameOfSample="initial";
40
$nameOfSample="20240328";
529 liveuser 41
 
714 liveuser 42
#存放範例的資料夾
43
$sampleFolder="config::client";
529 liveuser 44
 
714 liveuser 45
#設置範例檔案名稱與路徑
46
$fileNameOfSample=$sampleFolder."/".$nameOfSample.".php";
47
 
48
#初始化儲存範例代碼
49
$samples=array();
50
 
51
#增加 config::client 的範例資訊
52
$samples[]=array("name"=>"initial","comnent"=>"initial sample.");
53
$samples[]=array("name"=>"20240328","comnent"=>"get config from cache");
54
 
55
#針對每個範例資訊
56
foreach($samples as $sample){
57
 
58
	#如果找到對應的範例
59
	if($sample["name"]===$nameOfSample){
529 liveuser 60
 
714 liveuser 61
		#如果存放範例的資料夾不存在
62
		if(!file_exists($sampleFolder)){
63
 
64
			#提示訊息
65
			echo "存放範例的資料夾(".$sampleFolder.")不存在".PHP_EOL;
66
 
67
			#結束執行,並回傳1給shell
68
			exit(1);
69
 
70
			}#if end
71
 
72
		#如果對應的範例檔案不存在
73
		if(!file_exists($fileNameOfSample)){
74
 
75
			#提示訊息
76
			echo "範例檔案(".$fileNameOfSample.")不存在".PHP_EOL;
77
 
78
			#結束執行,並回傳1給shell
79
			exit(1);
80
 
81
			}#if end
82
 
83
		#匯入範例
84
		require_once($fileNameOfSample);
85
 
86
		#結束執行
87
		exit;
88
 
89
		}#if end
529 liveuser 90
 
714 liveuser 91
	}#foreach end
92
 
93
#執行到這邊代表沒有對應的範例
529 liveuser 94
 
714 liveuser 95
#提示範例不存在
96
echo "範例(".$nameOfSample.")不存在".PHP_EOL;
529 liveuser 97
 
714 liveuser 98
#結束執行,並回傳1給shell
99
exit(1);
100
 
529 liveuser 101
?>