Subversion Repositories qbpwcf-lib(archive)

Rev

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

Rev Author Line No. Line
717 liveuser 1
#!/bin/php
529 liveuser 2
<?php
3
 
4
/*
5
 
6
        QBPWCF, Quick Build PHP website Component base on Fedora Linux.
638 liveuser 7
    Copyright (C) 2015~2024 Min-Jhin,Chen
529 liveuser 8
 
9
    This file is part of QBPWCF.
10
 
11
    QBPWCF is free software: you can redistribute it and/or modify
12
    it under the terms of the GNU General Public License as published by
13
    the Free Software Foundation, either version 3 of the License, or
14
    (at your option) any later version.
15
 
16
    QBPWCF is distributed in the hope that it will be useful,
17
    but WITHOUT ANY WARRANTY; without even the implied warranty of
18
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
19
    GNU General Public License for more details.
20
 
21
    You should have received a copy of the GNU General Public License
22
    along with QBPWCF.  If not, see <http://www.gnu.org/licenses/>.
23
 
24
*/
25
 
26
#使用命名空間qbpwcf
27
namespace qbpwcf;
28
 
714 liveuser 29
#以該檔案的實際位置的 lib path 為 include path 首位
30
exec("cd ".pathinfo(__FILE__)["dirname"]."/../qbpwcf;pwd;",$output,$status);
31
set_include_path($output[0].PATH_SEPARATOR.get_include_path());
32
 
529 liveuser 33
#匯入套件
714 liveuser 34
require_once("allInOne.php");
529 liveuser 35
 
36
#建議的log位置
37
$logFile=$_SERVER["DOCUMENT_ROOT"].$_SERVER["PHP_SELF"].".log";
38
 
714 liveuser 39
#要使用的範例name
40
#$nameOfSample="initial";
717 liveuser 41
#$nameOfSample="20240328";
718 liveuser 42
#$nameOfSample="20240401";
43
$nameOfSample="20240401-1";
529 liveuser 44
 
714 liveuser 45
#存放範例的資料夾
46
$sampleFolder="config::client";
529 liveuser 47
 
714 liveuser 48
#設置範例檔案名稱與路徑
49
$fileNameOfSample=$sampleFolder."/".$nameOfSample.".php";
50
 
51
#初始化儲存範例代碼
52
$samples=array();
53
 
54
#增加 config::client 的範例資訊
55
$samples[]=array("name"=>"initial","comnent"=>"initial sample.");
717 liveuser 56
$samples[]=array("name"=>"20240328","comnent"=>"get undefined config from cache");
57
$samples[]=array("name"=>"20240401","comnent"=>"get config string from cache");
718 liveuser 58
$samples[]=array("name"=>"20240401-1","comnent"=>"get config array from cache");
714 liveuser 59
 
60
#針對每個範例資訊
61
foreach($samples as $sample){
62
 
63
	#如果找到對應的範例
64
	if($sample["name"]===$nameOfSample){
529 liveuser 65
 
714 liveuser 66
		#如果存放範例的資料夾不存在
67
		if(!file_exists($sampleFolder)){
68
 
69
			#提示訊息
70
			echo "存放範例的資料夾(".$sampleFolder.")不存在".PHP_EOL;
71
 
72
			#結束執行,並回傳1給shell
73
			exit(1);
74
 
75
			}#if end
76
 
77
		#如果對應的範例檔案不存在
78
		if(!file_exists($fileNameOfSample)){
79
 
80
			#提示訊息
81
			echo "範例檔案(".$fileNameOfSample.")不存在".PHP_EOL;
82
 
83
			#結束執行,並回傳1給shell
84
			exit(1);
85
 
86
			}#if end
87
 
88
		#匯入範例
89
		require_once($fileNameOfSample);
90
 
91
		#結束執行
92
		exit;
93
 
94
		}#if end
529 liveuser 95
 
714 liveuser 96
	}#foreach end
97
 
98
#執行到這邊代表沒有對應的範例
529 liveuser 99
 
714 liveuser 100
#提示範例不存在
101
echo "範例(".$nameOfSample.")不存在".PHP_EOL;
529 liveuser 102
 
714 liveuser 103
#結束執行,並回傳1給shell
104
exit(1);
105
 
717 liveuser 106
?>