This project does not seem to handle request data directly as such no vulnerable execution paths were found.
include
, or for example
via PHP's auto-loading mechanism.
These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
1 | <?php |
||
2 | if (!defined('XOOPS_ROOT_PATH')) { |
||
3 | die('XOOPS root path not defined'); |
||
4 | } |
||
5 | |||
6 | require_once('fpdf.php'); |
||
7 | |||
8 | $Big5_widths=array(' '=>250,'!'=>250,'"'=>408,'#'=>668,'$'=>490,'%'=>875,'&'=>698,'\''=>250, |
||
9 | '('=>240,')'=>240,'*'=>417,'+'=>667,','=>250,'-'=>313,'.'=>250,'/'=>520,'0'=>500,'1'=>500, |
||
10 | '2'=>500,'3'=>500,'4'=>500,'5'=>500,'6'=>500,'7'=>500,'8'=>500,'9'=>500,':'=>250,';'=>250, |
||
11 | '<'=>667,'='=>667,'>'=>667,'?'=>396,'@'=>921,'A'=>677,'B'=>615,'C'=>719,'D'=>760,'E'=>625, |
||
12 | 'F'=>552,'G'=>771,'H'=>802,'I'=>354,'J'=>354,'K'=>781,'L'=>604,'M'=>927,'N'=>750,'O'=>823, |
||
13 | 'P'=>563,'Q'=>823,'R'=>729,'S'=>542,'T'=>698,'U'=>771,'V'=>729,'W'=>948,'X'=>771,'Y'=>677, |
||
14 | 'Z'=>635,'['=>344,'\\'=>520,']'=>344,'^'=>469,'_'=>500,'`'=>250,'a'=>469,'b'=>521,'c'=>427, |
||
15 | 'd'=>521,'e'=>438,'f'=>271,'g'=>469,'h'=>531,'i'=>250,'j'=>250,'k'=>458,'l'=>240,'m'=>802, |
||
16 | 'n'=>531,'o'=>500,'p'=>521,'q'=>521,'r'=>365,'s'=>333,'t'=>292,'u'=>521,'v'=>458,'w'=>677, |
||
17 | 'x'=>479,'y'=>458,'z'=>427,'{'=>480,'|'=>496,'}'=>480,'~'=>667); |
||
18 | |||
19 | $GB_widths=array(' '=>207,'!'=>270,'"'=>342,'#'=>467,'$'=>462,'%'=>797,'&'=>710,'\''=>239, |
||
20 | '('=>374,')'=>374,'*'=>423,'+'=>605,','=>238,'-'=>375,'.'=>238,'/'=>334,'0'=>462,'1'=>462, |
||
21 | '2'=>462,'3'=>462,'4'=>462,'5'=>462,'6'=>462,'7'=>462,'8'=>462,'9'=>462,':'=>238,';'=>238, |
||
22 | '<'=>605,'='=>605,'>'=>605,'?'=>344,'@'=>748,'A'=>684,'B'=>560,'C'=>695,'D'=>739,'E'=>563, |
||
23 | 'F'=>511,'G'=>729,'H'=>793,'I'=>318,'J'=>312,'K'=>666,'L'=>526,'M'=>896,'N'=>758,'O'=>772, |
||
24 | 'P'=>544,'Q'=>772,'R'=>628,'S'=>465,'T'=>607,'U'=>753,'V'=>711,'W'=>972,'X'=>647,'Y'=>620, |
||
25 | 'Z'=>607,'['=>374,'\\'=>333,']'=>374,'^'=>606,'_'=>500,'`'=>239,'a'=>417,'b'=>503,'c'=>427, |
||
26 | 'd'=>529,'e'=>415,'f'=>264,'g'=>444,'h'=>518,'i'=>241,'j'=>230,'k'=>495,'l'=>228,'m'=>793, |
||
27 | 'n'=>527,'o'=>524,'p'=>524,'q'=>504,'r'=>338,'s'=>336,'t'=>277,'u'=>517,'v'=>450,'w'=>652, |
||
28 | 'x'=>466,'y'=>452,'z'=>407,'{'=>370,'|'=>258,'}'=>370,'~'=>605); |
||
29 | |||
30 | class PDF_Chinese extends FPDF |
||
31 | { |
||
32 | View Code Duplication | function AddCIDFont($family,$style,$name,$cw,$CMap,$registry) |
|
33 | { |
||
34 | $fontkey=strtolower($family).strtoupper($style); |
||
35 | if(isset($this->fonts[$fontkey])) |
||
36 | $this->Error("Font already added: $family $style"); |
||
37 | $i=count($this->fonts)+1; |
||
38 | $name=str_replace(' ','',$name); |
||
39 | $this->fonts[$fontkey]=array('i'=>$i,'type'=>'Type0','name'=>$name,'up'=>-130,'ut'=>40,'cw'=>$cw,'CMap'=>$CMap,'registry'=>$registry); |
||
40 | } |
||
41 | |||
42 | View Code Duplication | function AddCIDFonts($family,$name,$cw,$CMap,$registry) |
|
43 | { |
||
44 | $this->AddCIDFont($family,'',$name,$cw,$CMap,$registry); |
||
45 | $this->AddCIDFont($family,'B',$name.',Bold',$cw,$CMap,$registry); |
||
46 | $this->AddCIDFont($family,'I',$name.',Italic',$cw,$CMap,$registry); |
||
47 | $this->AddCIDFont($family,'BI',$name.',BoldItalic',$cw,$CMap,$registry); |
||
48 | } |
||
49 | |||
50 | function AddBig5Font($family='PMingLiU',$name='MSungStd-Light-Acro') |
||
51 | { |
||
52 | //Add Big5 font with proportional Latin |
||
53 | $cw=$GLOBALS['Big5_widths']; |
||
54 | $CMap='ETenms-B5-H'; |
||
55 | $registry=array('ordering'=>'CNS1','supplement'=>0); |
||
56 | $this->AddCIDFonts($family,$name,$cw,$CMap,$registry); |
||
57 | } |
||
58 | |||
59 | View Code Duplication | function AddBig5hwFont($family='PMingLiU',$name='MSungStd-Light-Acro') |
|
60 | { |
||
61 | //Add Big5 font with half-witdh Latin |
||
62 | for($i=32;$i<=126;$i++) |
||
63 | $cw[chr($i)]=500; |
||
64 | $CMap='ETen-B5-H'; |
||
65 | $registry=array('ordering'=>'CNS1','supplement'=>0); |
||
66 | $this->AddCIDFonts($family,$name,$cw,$CMap,$registry); |
||
67 | } |
||
68 | |||
69 | function AddGBFont($family='GB',$name='STSongStd-Light-Acro') |
||
70 | { |
||
71 | //Add GB font with proportional Latin |
||
72 | $cw=$GLOBALS['GB_widths']; |
||
73 | $CMap='GBKp-EUC-H'; |
||
74 | $registry=array('ordering'=>'GB1','supplement'=>2); |
||
75 | $this->AddCIDFonts($family,$name,$cw,$CMap,$registry); |
||
76 | } |
||
77 | |||
78 | View Code Duplication | function AddGBhwFont($family='GB-hw',$name='STSongStd-Light-Acro') |
|
79 | { |
||
80 | //Add GB font with half-width Latin |
||
81 | for($i=32;$i<=126;$i++) |
||
82 | $cw[chr($i)]=500; |
||
83 | $CMap='GBK-EUC-H'; |
||
84 | $registry=array('ordering'=>'GB1','supplement'=>2); |
||
85 | $this->AddCIDFonts($family,$name,$cw,$CMap,$registry); |
||
86 | } |
||
87 | |||
88 | View Code Duplication | function GetStringWidth($s) |
|
89 | { |
||
90 | if($this->CurrentFont['type']=='Type0') |
||
91 | return $this->GetMBStringWidth($s); |
||
92 | else |
||
93 | return parent::GetStringWidth($s); |
||
94 | } |
||
95 | |||
96 | View Code Duplication | function GetMBStringWidth($s) |
|
97 | { |
||
98 | //Multi-byte version of GetStringWidth() |
||
99 | $l=0; |
||
100 | $cw=&$this->CurrentFont['cw']; |
||
101 | $nb=strlen($s); |
||
102 | $i=0; |
||
103 | while($i<$nb) |
||
104 | { |
||
105 | $c=$s[$i]; |
||
106 | if(ord($c)<128) |
||
107 | { |
||
108 | $l+=$cw[$c]; |
||
109 | $i++; |
||
110 | } |
||
111 | else |
||
112 | { |
||
113 | $l+=1000; |
||
114 | $i+=2; |
||
115 | } |
||
116 | } |
||
117 | |||
118 | return $l*$this->FontSize/1000; |
||
119 | } |
||
120 | |||
121 | View Code Duplication | function MultiCell($w,$h,$txt,$border=0,$align='L',$fill=0) |
|
122 | { |
||
123 | if($this->CurrentFont['type']=='Type0') |
||
124 | $this->MBMultiCell($w,$h,$txt,$border,$align,$fill); |
||
125 | else |
||
126 | parent::MultiCell($w,$h,$txt,$border,$align,$fill); |
||
127 | } |
||
128 | |||
129 | View Code Duplication | function MBMultiCell($w,$h,$txt,$border=0,$align='L',$fill=0) |
|
130 | { |
||
131 | //Multi-byte version of MultiCell() |
||
132 | $cw=&$this->CurrentFont['cw']; |
||
133 | if($w==0) |
||
134 | $w=$this->w-$this->rMargin-$this->x; |
||
135 | $wmax=($w-2*$this->cMargin)*1000/$this->FontSize; |
||
136 | $s=str_replace("\r",'',$txt); |
||
137 | $nb=strlen($s); |
||
138 | if($nb>0 and $s[$nb-1]=="\n") |
||
139 | $nb--; |
||
140 | $b=0; |
||
141 | if($border) |
||
142 | { |
||
143 | if($border==1) |
||
144 | { |
||
145 | $border='LTRB'; |
||
146 | $b='LRT'; |
||
147 | $b2='LR'; |
||
148 | } |
||
149 | else |
||
150 | { |
||
151 | $b2=''; |
||
152 | if(is_int(strpos($border,'L'))) |
||
153 | $b2.='L'; |
||
154 | if(is_int(strpos($border,'R'))) |
||
155 | $b2.='R'; |
||
156 | $b=is_int(strpos($border,'T')) ? $b2.'T' : $b2; |
||
157 | } |
||
158 | } |
||
159 | $sep=-1; |
||
160 | $i=0; |
||
161 | $j=0; |
||
162 | $l=0; |
||
163 | $nl=1; |
||
164 | while($i<$nb) |
||
165 | { |
||
166 | //Get next character |
||
167 | $c=$s[$i]; |
||
168 | //Check if ASCII or MB |
||
169 | $ascii=(ord($c)<128); |
||
170 | if($c=="\n") |
||
171 | { |
||
172 | //Explicit line break |
||
173 | $this->Cell($w,$h,substr($s,$j,$i-$j),$b,2,$align,$fill); |
||
174 | $i++; |
||
175 | $sep=-1; |
||
176 | $j=$i; |
||
177 | $l=0; |
||
178 | $nl++; |
||
179 | if($border and $nl==2) |
||
180 | $b=$b2; |
||
181 | continue; |
||
182 | } |
||
183 | if(!$ascii) |
||
184 | { |
||
185 | $sep=$i; |
||
186 | $ls=$l; |
||
0 ignored issues
–
show
|
|||
187 | } |
||
188 | elseif($c==' ') |
||
189 | { |
||
190 | $sep=$i; |
||
191 | $ls=$l; |
||
0 ignored issues
–
show
$ls is not used, you could remove the assignment.
This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently. $myVar = 'Value';
$higher = false;
if (rand(1, 6) > 3) {
$higher = true;
} else {
$higher = false;
}
Both the ![]() |
|||
192 | } |
||
193 | $l+=$ascii ? $cw[$c] : 1000; |
||
194 | if($l>$wmax) |
||
195 | { |
||
196 | //Automatic line break |
||
197 | if($sep==-1 or $i==$j) |
||
198 | { |
||
199 | if($i==$j) |
||
200 | $i+=$ascii ? 1 : 2; |
||
201 | $this->Cell($w,$h,substr($s,$j,$i-$j),$b,2,$align,$fill); |
||
202 | } |
||
203 | else |
||
204 | { |
||
205 | $this->Cell($w,$h,substr($s,$j,$sep-$j),$b,2,$align,$fill); |
||
206 | $i=($s[$sep]==' ') ? $sep+1 : $sep; |
||
207 | } |
||
208 | $sep=-1; |
||
209 | $j=$i; |
||
210 | $l=0; |
||
211 | $nl++; |
||
212 | if($border and $nl==2) |
||
213 | $b=$b2; |
||
214 | } |
||
215 | else |
||
216 | $i+=$ascii ? 1 : 2; |
||
217 | } |
||
218 | //Last chunk |
||
219 | if($border and is_int(strpos($border,'B'))) |
||
220 | $b.='B'; |
||
221 | $this->Cell($w,$h,substr($s,$j,$i-$j),$b,2,$align,$fill); |
||
222 | $this->x=$this->lMargin; |
||
223 | } |
||
224 | |||
225 | View Code Duplication | function Write($h,$txt,$link='') |
|
226 | { |
||
227 | if($this->CurrentFont['type']=='Type0') |
||
228 | $this->MBWrite($h,$txt,$link); |
||
229 | else |
||
230 | parent::Write($h,$txt,$link); |
||
231 | } |
||
232 | |||
233 | View Code Duplication | function MBWrite($h,$txt,$link) |
|
234 | { |
||
235 | //Multi-byte version of Write() |
||
236 | $cw=&$this->CurrentFont['cw']; |
||
237 | $w=$this->w-$this->rMargin-$this->x; |
||
238 | $wmax=($w-2*$this->cMargin)*1000/$this->FontSize; |
||
239 | $s=str_replace("\r",'',$txt); |
||
240 | $nb=strlen($s); |
||
241 | $sep=-1; |
||
242 | $i=0; |
||
243 | $j=0; |
||
244 | $l=0; |
||
245 | $nl=1; |
||
246 | while($i<$nb) |
||
247 | { |
||
248 | //Get next character |
||
249 | $c=$s[$i]; |
||
250 | //Check if ASCII or MB |
||
251 | $ascii=(ord($c)<128); |
||
252 | if($c=="\n") |
||
253 | { |
||
254 | //Explicit line break |
||
255 | $this->Cell($w,$h,substr($s,$j,$i-$j),0,2,'',0,$link); |
||
256 | $i++; |
||
257 | $sep=-1; |
||
258 | $j=$i; |
||
259 | $l=0; |
||
260 | if($nl==1) |
||
261 | { |
||
262 | $this->x=$this->lMargin; |
||
263 | $w=$this->w-$this->rMargin-$this->x; |
||
264 | $wmax=($w-2*$this->cMargin)*1000/$this->FontSize; |
||
265 | } |
||
266 | $nl++; |
||
267 | continue; |
||
268 | } |
||
269 | if(!$ascii or $c==' ') |
||
270 | $sep=$i; |
||
271 | $l+=$ascii ? $cw[$c] : 1000; |
||
272 | if($l>$wmax) |
||
273 | { |
||
274 | //Automatic line break |
||
275 | if($sep==-1 or $i==$j) |
||
276 | { |
||
277 | if($this->x>$this->lMargin) |
||
278 | { |
||
279 | //Move to next line |
||
280 | $this->x=$this->lMargin; |
||
281 | $this->y+=$h; |
||
282 | $w=$this->w-$this->rMargin-$this->x; |
||
283 | $wmax=($w-2*$this->cMargin)*1000/$this->FontSize; |
||
284 | $i++; |
||
285 | $nl++; |
||
286 | continue; |
||
287 | } |
||
288 | if($i==$j) |
||
289 | $i+=$ascii ? 1 : 2; |
||
290 | $this->Cell($w,$h,substr($s,$j,$i-$j),0,2,'',0,$link); |
||
291 | } |
||
292 | else |
||
293 | { |
||
294 | $this->Cell($w,$h,substr($s,$j,$sep-$j),0,2,'',0,$link); |
||
295 | $i=($s[$sep]==' ') ? $sep+1 : $sep; |
||
296 | } |
||
297 | $sep=-1; |
||
298 | $j=$i; |
||
299 | $l=0; |
||
300 | if($nl==1) |
||
301 | { |
||
302 | $this->x=$this->lMargin; |
||
303 | $w=$this->w-$this->rMargin-$this->x; |
||
304 | $wmax=($w-2*$this->cMargin)*1000/$this->FontSize; |
||
305 | } |
||
306 | $nl++; |
||
307 | } |
||
308 | else |
||
309 | $i+=$ascii ? 1 : 2; |
||
310 | } |
||
311 | //Last chunk |
||
312 | if($i!=$j) |
||
313 | $this->Cell($l/1000*$this->FontSize,$h,substr($s,$j,$i-$j),0,0,'',0,$link); |
||
314 | } |
||
315 | |||
316 | View Code Duplication | function _putfonts() |
|
317 | { |
||
318 | $nf=$this->n; |
||
319 | foreach($this->diffs as $diff) |
||
320 | { |
||
321 | //Encodings |
||
322 | $this->_newobj(); |
||
323 | $this->_out('<</Type /Encoding /BaseEncoding /WinAnsiEncoding /Differences ['.$diff.']>>'); |
||
324 | $this->_out('endobj'); |
||
325 | } |
||
326 | $mqr=get_magic_quotes_runtime(); |
||
327 | set_magic_quotes_runtime(0); |
||
328 | foreach($this->FontFiles as $file=>$info) |
||
329 | { |
||
330 | //Font file embedding |
||
331 | $this->_newobj(); |
||
332 | $this->FontFiles[$file]['n']=$this->n; |
||
333 | if(defined('FPDF_FONTPATH')) |
||
334 | $file=FPDF_FONTPATH.$file; |
||
335 | $size=filesize($file); |
||
336 | if(!$size) |
||
337 | $this->Error('Font file not found'); |
||
338 | $this->_out('<</Length '.$size); |
||
339 | if(substr($file,-2)=='.z') |
||
340 | $this->_out('/Filter /FlateDecode'); |
||
341 | $this->_out('/Length1 '.$info['length1']); |
||
342 | if(isset($info['length2'])) |
||
343 | $this->_out('/Length2 '.$info['length2'].' /Length3 0'); |
||
344 | $this->_out('>>'); |
||
345 | $f=fopen($file,'rb'); |
||
346 | $this->_putstream(fread($f,$size)); |
||
347 | fclose($f); |
||
348 | $this->_out('endobj'); |
||
349 | } |
||
350 | set_magic_quotes_runtime($mqr); |
||
351 | foreach($this->fonts as $k=>$font) |
||
352 | { |
||
353 | //Font objects |
||
354 | $this->_newobj(); |
||
355 | $this->fonts[$k]['n']=$this->n; |
||
356 | $this->_out('<</Type /Font'); |
||
357 | if($font['type']=='Type0') |
||
358 | $this->_putType0($font); |
||
359 | else |
||
360 | { |
||
361 | $name=$font['name']; |
||
362 | $this->_out('/BaseFont /'.$name); |
||
363 | if($font['type']=='core') |
||
364 | { |
||
365 | //Standard font |
||
366 | $this->_out('/Subtype /Type1'); |
||
367 | if($name!='Symbol' and $name!='ZapfDingbats') |
||
368 | $this->_out('/Encoding /WinAnsiEncoding'); |
||
369 | } |
||
370 | else |
||
371 | { |
||
372 | //Additional font |
||
373 | $this->_out('/Subtype /'.$font['type']); |
||
374 | $this->_out('/FirstChar 32'); |
||
375 | $this->_out('/LastChar 255'); |
||
376 | $this->_out('/Widths '.($this->n+1).' 0 R'); |
||
377 | $this->_out('/FontDescriptor '.($this->n+2).' 0 R'); |
||
378 | if($font['enc']) |
||
379 | { |
||
380 | if(isset($font['diff'])) |
||
381 | $this->_out('/Encoding '.($nf+$font['diff']).' 0 R'); |
||
382 | else |
||
383 | $this->_out('/Encoding /WinAnsiEncoding'); |
||
384 | } |
||
385 | } |
||
386 | $this->_out('>>'); |
||
387 | $this->_out('endobj'); |
||
388 | if($font['type']!='core') |
||
389 | { |
||
390 | //Widths |
||
391 | $this->_newobj(); |
||
392 | $cw=&$font['cw']; |
||
393 | $s='['; |
||
394 | for($i=32;$i<=255;$i++) |
||
395 | $s.=$cw[chr($i)].' '; |
||
396 | $this->_out($s.']'); |
||
397 | $this->_out('endobj'); |
||
398 | //Descriptor |
||
399 | $this->_newobj(); |
||
400 | $s='<</Type /FontDescriptor /FontName /'.$name; |
||
401 | foreach($font['desc'] as $k=>$v) |
||
402 | $s.=' /'.$k.' '.$v; |
||
403 | $file=$font['file']; |
||
404 | if($file) |
||
405 | $s.=' /FontFile'.($font['type']=='Type1' ? '' : '2').' '.$this->FontFiles[$file]['n'].' 0 R'; |
||
406 | $this->_out($s.'>>'); |
||
407 | $this->_out('endobj'); |
||
408 | } |
||
409 | } |
||
410 | } |
||
411 | } |
||
412 | |||
413 | function _putType0($font) |
||
414 | { |
||
415 | //Type0 |
||
416 | $this->_out('/Subtype /Type0'); |
||
417 | $this->_out('/BaseFont /'.$font['name'].'-'.$font['CMap']); |
||
418 | $this->_out('/Encoding /'.$font['CMap']); |
||
419 | $this->_out('/DescendantFonts ['.($this->n+1).' 0 R]'); |
||
420 | $this->_out('>>'); |
||
421 | $this->_out('endobj'); |
||
422 | //CIDFont |
||
423 | $this->_newobj(); |
||
424 | $this->_out('<</Type /Font'); |
||
425 | $this->_out('/Subtype /CIDFontType0'); |
||
426 | $this->_out('/BaseFont /'.$font['name']); |
||
427 | $this->_out('/CIDSystemInfo <</Registry '.$this->_textstring('Adobe').' /Ordering '.$this->_textstring($font['registry']['ordering']).' /Supplement '.$font['registry']['supplement'].'>>'); |
||
428 | $this->_out('/FontDescriptor '.($this->n+1).' 0 R'); |
||
429 | if($font['CMap']=='ETen-B5-H') |
||
430 | $W='13648 13742 500'; |
||
431 | elseif($font['CMap']=='GBK-EUC-H') |
||
432 | $W='814 907 500 7716 [500]'; |
||
433 | else |
||
434 | $W='1 ['.implode(' ',$font['cw']).']'; |
||
435 | $this->_out('/W ['.$W.']>>'); |
||
436 | $this->_out('endobj'); |
||
437 | //Font descriptor |
||
438 | $this->_newobj(); |
||
439 | $this->_out('<</Type /FontDescriptor'); |
||
440 | $this->_out('/FontName /'.$font['name']); |
||
441 | $this->_out('/Flags 6'); |
||
442 | $this->_out('/FontBBox [0 -200 1000 900]'); |
||
443 | $this->_out('/ItalicAngle 0'); |
||
444 | $this->_out('/Ascent 800'); |
||
445 | $this->_out('/Descent -200'); |
||
446 | $this->_out('/CapHeight 800'); |
||
447 | $this->_out('/StemV 50'); |
||
448 | $this->_out('>>'); |
||
449 | $this->_out('endobj'); |
||
450 | } |
||
451 | } |
||
452 |
This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.
Both the
$myVar
assignment in line 1 and the$higher
assignment in line 2 are dead. The first because$myVar
is never used and the second because$higher
is always overwritten for every possible time line.