Subversion Repositories php-qbpwcf

Rev

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

Rev 3 Rev 226
Line 1... Line 1...
1
#!/usr/bin/php
1
#!/usr/bin/php
2
<?php
2
<?php
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~2024 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 17... Line 17...
17
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18
    GNU General Public License for more details.
18
    GNU General Public License for more details.
19
 
19
 
20
    You should have received a copy of the GNU General Public License
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/>.
21
    along with QBPWCF.  If not, see <http://www.gnu.org/licenses/>.
22
    
22
 
23
*/
23
*/
24
 
24
 
25
/*
25
/*
26
 
26
 
27
計算檔案的checksum in 16 位元
27
計算檔案的checksum in 16 位元
Line 66... Line 66...
66
	#結束執行,回傳shell 1.
66
	#結束執行,回傳shell 1.
67
	exit(1);
67
	exit(1);
68
 
68
 
69
	}#if end
69
	}#if end
70
 
70
 
71
#設置 include path 
71
#設置 include path
72
set_include_path($output[0].PATH_SEPARATOR.get_include_path());
72
set_include_path($output[0].PATH_SEPARATOR.get_include_path());
73
 
73
 
74
#匯入外部套件
74
#匯入外部套件
75
include("allInOne.php");
75
include("allInOne.php");
76
 
76
 
Line 135... Line 135...
135
 
135
 
136
#取得checksum的第二個bytes位置
136
#取得checksum的第二個bytes位置
137
$checksumBytes2=$getFileContent["fullContent"][$checksumAddr2];
137
$checksumBytes2=$getFileContent["fullContent"][$checksumAddr2];
138
 
138
 
139
#將 checksum 位置的內容設置為 00
139
#將 checksum 位置的內容設置為 00
140
$getFileContent["fullContent"][$checksumAddr1]=chr(base_convert("00",16,10)); 
140
$getFileContent["fullContent"][$checksumAddr1]=chr(base_convert("00",16,10));
141
$getFileContent["fullContent"][$checksumAddr2]=chr(base_convert("00",16,10)); 
141
$getFileContent["fullContent"][$checksumAddr2]=chr(base_convert("00",16,10));
142
 
142
 
143
#存放結果變數
143
#存放結果變數
144
$sumOfHex4num=0;
144
$sumOfHex4num=0;
145
 
145
 
146
#迴圈
146
#迴圈
Line 149... Line 149...
149
	#不存在就用00替補
149
	#不存在就用00替補
150
	if(!isset($getFileContent["fullContent"][$i+1]))
150
	if(!isset($getFileContent["fullContent"][$i+1]))
151
	{
151
	{
152
		$getFileContent["fullContent"][$i+1]="00";
152
		$getFileContent["fullContent"][$i+1]="00";
153
	}
153
	}
154
	
154
 
155
	#取得4個bytes的16進位數值
155
	#取得4個bytes的16進位數值
156
	$hex2bytes=sprintf("%02s",base_convert(ord($getFileContent["fullContent"][$i]),10,16)).sprintf("%02s",base_convert(ord($getFileContent["fullContent"][$i+1]),10,16));
156
	$hex2bytes=sprintf("%02s",base_convert(ord($getFileContent["fullContent"][$i]),10,16)).sprintf("%02s",base_convert(ord($getFileContent["fullContent"][$i+1]),10,16));
157
 
157
 
158
	#加總
158
	#加總
159
	$sumOfHex4num=$sumOfHex4num+(int)base_convert($hex2bytes,16,10);
159
	$sumOfHex4num=$sumOfHex4num+(int)base_convert($hex2bytes,16,10);
Line 172... Line 172...
172
	#如果長度不是4的倍數
172
	#如果長度不是4的倍數
173
	if(strlen($sumOfHex4num)%4!==0)
173
	if(strlen($sumOfHex4num)%4!==0)
174
	{
174
	{
175
		//前面補一個0
175
		//前面補一個0
176
		$sumOfHex4num="0".$sumOfHex4num;
176
		$sumOfHex4num="0".$sumOfHex4num;
177
		
177
 
178
		//繼續while
178
		//繼續while
179
		continue;
179
		continue;
180
	}
180
	}
181
 
181
 
182
	for($i=0;$i<strlen($sumOfHex4num);$i=$i+4)
182
	for($i=0;$i<strlen($sumOfHex4num);$i=$i+4)
Line 186... Line 186...
186
 
186
 
187
		#加總
187
		#加總
188
		$newSumOfHex4num=$newSumOfHex4num+base_convert($hex2bytes,16,10);
188
		$newSumOfHex4num=$newSumOfHex4num+base_convert($hex2bytes,16,10);
189
 
189
 
190
	}#for end
190
	}#for end
191
	
191
 
192
	#更新成16進位
192
	#更新成16進位
193
	$newSumOfHex4num=base_convert($newSumOfHex4num,10,16);
193
	$newSumOfHex4num=base_convert($newSumOfHex4num,10,16);
194
	
194
 
195
	#設置回儲存加總的地方
195
	#設置回儲存加總的地方
196
	$sumOfHex4num=$newSumOfHex4num;
196
	$sumOfHex4num=$newSumOfHex4num;
197
 
197
 
198
}#while end
198
}#while end
199
 
199
 
Line 213... Line 213...
213
	#不存在就用00替補
213
	#不存在就用00替補
214
	if(!isset($getFileContent["fullContent"][$i+1]))
214
	if(!isset($getFileContent["fullContent"][$i+1]))
215
	{
215
	{
216
		$getFileContent["fullContent"][$i+1]="00";
216
		$getFileContent["fullContent"][$i+1]="00";
217
	}
217
	}
218
	
218
 
219
	#取得4個bytes的16進位數值
219
	#取得4個bytes的16進位數值
220
	$hex2bytes=sprintf("%02s",base_convert(ord($getFileContent["fullContent"][$i]),10,16)).sprintf("%02s",base_convert(ord($getFileContent["fullContent"][$i+1]),10,16));
220
	$hex2bytes=sprintf("%02s",base_convert(ord($getFileContent["fullContent"][$i]),10,16)).sprintf("%02s",base_convert(ord($getFileContent["fullContent"][$i+1]),10,16));
221
 
221
 
222
	#加總
222
	#加總
223
	$sumOfHex4num=$sumOfHex4num+(int)base_convert($hex2bytes,16,10);
223
	$sumOfHex4num=$sumOfHex4num+(int)base_convert($hex2bytes,16,10);
Line 236... Line 236...
236
	#如果長度不是4的倍數
236
	#如果長度不是4的倍數
237
	if(strlen($sumOfHex4num)%4!==0)
237
	if(strlen($sumOfHex4num)%4!==0)
238
	{
238
	{
239
		//前面補一個0
239
		//前面補一個0
240
		$sumOfHex4num="0".$sumOfHex4num;
240
		$sumOfHex4num="0".$sumOfHex4num;
241
		
241
 
242
		//繼續while
242
		//繼續while
243
		continue;
243
		continue;
244
	}
244
	}
245
 
245
 
246
	for($i=0;$i<strlen($sumOfHex4num);$i=$i+4)
246
	for($i=0;$i<strlen($sumOfHex4num);$i=$i+4)
Line 250... Line 250...
250
 
250
 
251
		#加總
251
		#加總
252
		$newSumOfHex4num=$newSumOfHex4num+base_convert($hex2bytes,16,10);
252
		$newSumOfHex4num=$newSumOfHex4num+base_convert($hex2bytes,16,10);
253
 
253
 
254
	}#for end
254
	}#for end
255
	
255
 
256
	#更新成16進位
256
	#更新成16進位
257
	$newSumOfHex4num=base_convert($newSumOfHex4num,10,16);
257
	$newSumOfHex4num=base_convert($newSumOfHex4num,10,16);
258
	
258
 
259
	#設置回儲存加總的地方
259
	#設置回儲存加總的地方
260
	$sumOfHex4num=$newSumOfHex4num;
260
	$sumOfHex4num=$newSumOfHex4num;
261
 
261
 
262
}#while end
262
}#while end
263
 
263