Subversion Repositories php-qbpwcf

Rev

Rev 232 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 232 Rev 239
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) 2014~2025 MIN ZHI, CHEN
6
    Copyright (C) 2014~2026 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 2183... Line 2183...
2183
				#如果是要加密
2183
				#如果是要加密
2184
				if($conf["qbpwcfDecode"]==="false"){
2184
				if($conf["qbpwcfDecode"]==="false"){
2185
 
2185
 
2186
					#設置編碼好的內容
2186
					#設置編碼好的內容
2187
					$result["content"]=base64_encode(serialize($conf["enCodeStr"]));
2187
					$result["content"]=base64_encode(serialize($conf["enCodeStr"]));
2188
					
2188
 
2189
					}#if end
2189
					}#if end
2190
 
2190
 
2191
				#反之是要解密
2191
				#反之是要解密
2192
				else{
2192
				else{
2193
 
2193
 
Line 2262... Line 2262...
2262
				#如果是用gpg加密
2262
				#如果是用gpg加密
2263
				if($conf["gpgDecrypt"]==="false"){
2263
				if($conf["gpgDecrypt"]==="false"){
2264
 
2264
 
2265
					#如果是 array 或 object
2265
					#如果是 array 或 object
2266
					if( gettype($conf["enCodeStr"])==="array" || gettype($conf["enCodeStr"])==="object"){
2266
					if( gettype($conf["enCodeStr"])==="array" || gettype($conf["enCodeStr"])==="object"){
2267
					
2267
 
2268
						#用 qbpwcf encode
2268
						#用 qbpwcf encode
2269
						#函式說明:
2269
						#函式說明:
2270
						#加密或編碼字串,可以用的方法有sha1,md5,password_sha,qbpwcf,bin2hex,hex2bin,gpg,sha1可以回傳20或40的數值字串,md5可以回傳32個數值字串,password_hash可以回傳60~255個字元.
2270
						#加密或編碼字串,可以用的方法有sha1,md5,password_sha,qbpwcf,bin2hex,hex2bin,gpg,sha1可以回傳20或40的數值字串,md5可以回傳32個數值字串,password_hash可以回傳60~255個字元.
2271
						#回傳結果:
2271
						#回傳結果:
2272
						#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
2272
						#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
Line 2302... Line 2302...
2302
						#json_decode=>https://www.php.net/manual/en/function.json-decode.php
2302
						#json_decode=>https://www.php.net/manual/en/function.json-decode.php
2303
						#備註:
2303
						#備註:
2304
						#無.
2304
						#無.
2305
						$enCodeStr=self::enCodeStr($conf["self::enCodeStr"]);
2305
						$enCodeStr=self::enCodeStr($conf["self::enCodeStr"]);
2306
						unset($conf["self::enCodeStr"]);
2306
						unset($conf["self::enCodeStr"]);
2307
					
2307
 
2308
						#如果執行失敗
2308
						#如果執行失敗
2309
						if($enCodeStr["status"]==="false"){
2309
						if($enCodeStr["status"]==="false"){
2310
 
2310
 
2311
							#設置執行失敗
2311
							#設置執行失敗
2312
							$result["status"]="false";
2312
							$result["status"]="false";
Line 2316... Line 2316...
2316
 
2316
 
2317
							#回傳結果
2317
							#回傳結果
2318
							return $result;
2318
							return $result;
2319
 
2319
 
2320
							}#if end
2320
							}#if end
2321
							
2321
 
2322
						#取得 qbpwcf 編碼後的結果
2322
						#取得 qbpwcf 編碼後的結果
2323
						$conf["enCodeStr"]=$enCodeStr["content"];
2323
						$conf["enCodeStr"]=$enCodeStr["content"];
2324
					
2324
 
2325
						}#if end
2325
						}#if end
2326
 
2326
 
2327
					#如果已經為字串
2327
					#如果已經為字串
2328
					if(gettype($conf["enCodeStr"])==="string"){
2328
					if(gettype($conf["enCodeStr"])==="string"){
2329
					
2329
 
2330
						#先用 base64 decode 為原始加密後的結果 再用 gpg 解密.
2330
						#先用 base64 decode 為原始加密後的結果 再用 gpg 解密.
2331
						#函式說明:
2331
						#函式說明:
2332
						#呼叫shell執行系統命令,並取得回傳的內容.
2332
						#呼叫shell執行系統命令,並取得回傳的內容.
2333
						#回傳結果:
2333
						#回傳結果:
2334
						#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
2334
						#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
Line 2400... Line 2400...
2400
 
2400
 
2401
							#回傳結果
2401
							#回傳結果
2402
							return $result;
2402
							return $result;
2403
 
2403
 
2404
							}#if end
2404
							}#if end
2405
						
2405
 
2406
						#取得加密後的內容
2406
						#取得加密後的內容
2407
						$result["content"]=$callShell["content"];
2407
						$result["content"]=$callShell["content"];
2408
					
2408
 
2409
						}#if end
2409
						}#if end
2410
 
2410
 
2411
					#反之為不支援的參數形態
2411
					#反之為不支援的參數形態
2412
					else{
2412
					else{
2413
					
2413
 
2414
						#設置執行失敗
2414
						#設置執行失敗
2415
						$result["status"]="false";
2415
						$result["status"]="false";
2416
 
2416
 
2417
						#設置執行錯誤
2417
						#設置執行錯誤
2418
						$result["error"]="unsupported input type(".$gettype($conf["enCodeStr"]).")";
2418
						$result["error"]="unsupported input type(".$gettype($conf["enCodeStr"]).")";
2419
 
2419
 
2420
						#回傳結果
2420
						#回傳結果
2421
						return $result;
2421
						return $result;
2422
					
2422
 
2423
						}#else end
2423
						}#else end
2424
 
2424
 
2425
					}#if end
2425
					}#if end
2426
 
2426
 
2427
				#反之如果是 gpg 解密
2427
				#反之如果是 gpg 解密