XoopsModules25x /
mylinks
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('fpdf.php'); |
||
| 7 | |||
| 8 | $SJIS_widths=array(' '=>278,'!'=>299,'"'=>353,'#'=>614,'$'=>614,'%'=>721,'&'=>735,'\''=>216, |
||
| 9 | '('=>323,')'=>323,'*'=>449,'+'=>529,','=>219,'-'=>306,'.'=>219,'/'=>453,'0'=>614,'1'=>614, |
||
| 10 | '2'=>614,'3'=>614,'4'=>614,'5'=>614,'6'=>614,'7'=>614,'8'=>614,'9'=>614,':'=>219,';'=>219, |
||
| 11 | '<'=>529,'='=>529,'>'=>529,'?'=>486,'@'=>744,'A'=>646,'B'=>604,'C'=>617,'D'=>681,'E'=>567, |
||
| 12 | 'F'=>537,'G'=>647,'H'=>738,'I'=>320,'J'=>433,'K'=>637,'L'=>566,'M'=>904,'N'=>710,'O'=>716, |
||
| 13 | 'P'=>605,'Q'=>716,'R'=>623,'S'=>517,'T'=>601,'U'=>690,'V'=>668,'W'=>990,'X'=>681,'Y'=>634, |
||
| 14 | 'Z'=>578,'['=>316,'\\'=>614,']'=>316,'^'=>529,'_'=>500,'`'=>387,'a'=>509,'b'=>566,'c'=>478, |
||
| 15 | 'd'=>565,'e'=>503,'f'=>337,'g'=>549,'h'=>580,'i'=>275,'j'=>266,'k'=>544,'l'=>276,'m'=>854, |
||
| 16 | 'n'=>579,'o'=>550,'p'=>578,'q'=>566,'r'=>410,'s'=>444,'t'=>340,'u'=>575,'v'=>512,'w'=>760, |
||
| 17 | 'x'=>503,'y'=>529,'z'=>453,'{'=>326,'|'=>380,'}'=>326,'~'=>387); |
||
| 18 | |||
| 19 | class PDF_Japanese extends FPDF |
||
| 20 | { |
||
| 21 | function AddCIDFont($family,$style,$name,$cw,$CMap,$registry) |
||
| 22 | { |
||
| 23 | $fontkey=strtolower($family).strtoupper($style); |
||
| 24 | if(isset($this->fonts[$fontkey])) |
||
| 25 | $this->Error("CID font already added: $family $style"); |
||
| 26 | $i=count($this->fonts)+1; |
||
| 27 | $this->fonts[$fontkey]=array('i'=>$i,'type'=>'Type0','name'=>$name,'up'=>-120,'ut'=>40,'cw'=>$cw,'CMap'=>$CMap,'registry'=>$registry); |
||
| 28 | } |
||
| 29 | |||
| 30 | View Code Duplication | function AddCIDFonts($family,$name,$cw,$CMap,$registry) |
|
| 31 | { |
||
| 32 | $this->AddCIDFont($family,'',$name,$cw,$CMap,$registry); |
||
| 33 | $this->AddCIDFont($family,'B',$name.',Bold',$cw,$CMap,$registry); |
||
| 34 | $this->AddCIDFont($family,'I',$name.',Italic',$cw,$CMap,$registry); |
||
| 35 | $this->AddCIDFont($family,'BI',$name.',BoldItalic',$cw,$CMap,$registry); |
||
| 36 | } |
||
| 37 | |||
| 38 | function AddSJISFont($family='SJIS') |
||
| 39 | { |
||
| 40 | //Add SJIS font with proportional Latin |
||
| 41 | $name='KozMinPro-Regular-Acro'; |
||
| 42 | $cw=$GLOBALS['SJIS_widths']; |
||
| 43 | $CMap='90msp-RKSJ-H'; |
||
| 44 | $registry=array('ordering'=>'Japan1','supplement'=>2); |
||
| 45 | $this->AddCIDFonts($family,$name,$cw,$CMap,$registry); |
||
| 46 | } |
||
| 47 | |||
| 48 | View Code Duplication | function AddSJIShwFont($family='SJIS-hw') |
|
| 49 | { |
||
| 50 | //Add SJIS font with half-width Latin |
||
| 51 | $name='KozMinPro-Regular-Acro'; |
||
| 52 | for($i=32;$i<=126;$i++) |
||
| 53 | $cw[chr($i)]=500; |
||
|
0 ignored issues
–
show
|
|||
| 54 | $CMap='90ms-RKSJ-H'; |
||
| 55 | $registry=array('ordering'=>'Japan1','supplement'=>2); |
||
| 56 | $this->AddCIDFonts($family,$name,$cw,$CMap,$registry); |
||
| 57 | } |
||
| 58 | |||
| 59 | View Code Duplication | function GetStringWidth($s) |
|
| 60 | { |
||
| 61 | if($this->CurrentFont['type']=='Type0') |
||
| 62 | return $this->GetSJISStringWidth($s); |
||
| 63 | else |
||
| 64 | return parent::GetStringWidth($s); |
||
| 65 | } |
||
| 66 | |||
| 67 | function GetSJISStringWidth($s) |
||
| 68 | { |
||
| 69 | //SJIS version of GetStringWidth() |
||
| 70 | $l=0; |
||
| 71 | $cw=&$this->CurrentFont['cw']; |
||
| 72 | $nb=strlen($s); |
||
| 73 | $i=0; |
||
| 74 | while($i<$nb) |
||
| 75 | { |
||
| 76 | $o=ord($s{$i}); |
||
| 77 | if($o<128) |
||
| 78 | { |
||
| 79 | //ASCII |
||
| 80 | $l+=$cw[$s{$i}]; |
||
| 81 | $i++; |
||
| 82 | } |
||
| 83 | elseif($o>=161 and $o<=223) |
||
| 84 | { |
||
| 85 | //Half-width katakana |
||
| 86 | $l+=500; |
||
| 87 | $i++; |
||
| 88 | } |
||
| 89 | else |
||
| 90 | { |
||
| 91 | //Full-width character |
||
| 92 | $l+=1000; |
||
| 93 | $i+=2; |
||
| 94 | } |
||
| 95 | } |
||
| 96 | |||
| 97 | return $l*$this->FontSize/1000; |
||
| 98 | } |
||
| 99 | |||
| 100 | View Code Duplication | function MultiCell($w,$h,$txt,$border=0,$align='L',$fill=0) |
|
| 101 | { |
||
| 102 | if($this->CurrentFont['type']=='Type0') |
||
| 103 | $this->SJISMultiCell($w,$h,$txt,$border,$align,$fill); |
||
| 104 | else |
||
| 105 | parent::MultiCell($w,$h,$txt,$border,$align,$fill); |
||
| 106 | } |
||
| 107 | |||
| 108 | function SJISMultiCell($w,$h,$txt,$border=0,$align='L',$fill=0) |
||
| 109 | { |
||
| 110 | //Output text with automatic or explicit line breaks |
||
| 111 | $cw=&$this->CurrentFont['cw']; |
||
| 112 | if($w==0) |
||
| 113 | $w=$this->w-$this->rMargin-$this->x; |
||
| 114 | $wmax=($w-2*$this->cMargin)*1000/$this->FontSize; |
||
| 115 | $s=str_replace("\r",'',$txt); |
||
| 116 | $nb=strlen($s); |
||
| 117 | if($nb>0 and $s{$nb-1}=="\n") |
||
| 118 | $nb--; |
||
| 119 | $b=0; |
||
| 120 | if($border) |
||
| 121 | { |
||
| 122 | if($border==1) |
||
| 123 | { |
||
| 124 | $border='LTRB'; |
||
| 125 | $b='LRT'; |
||
| 126 | $b2='LR'; |
||
| 127 | } |
||
| 128 | else |
||
| 129 | { |
||
| 130 | $b2=''; |
||
| 131 | if(is_int(strpos($border,'L'))) |
||
| 132 | $b2.='L'; |
||
| 133 | if(is_int(strpos($border,'R'))) |
||
| 134 | $b2.='R'; |
||
| 135 | $b=is_int(strpos($border,'T')) ? $b2.'T' : $b2; |
||
| 136 | } |
||
| 137 | } |
||
| 138 | $sep=-1; |
||
| 139 | $i=0; |
||
| 140 | $j=0; |
||
| 141 | $l=0; |
||
| 142 | $nl=1; |
||
| 143 | while($i<$nb) |
||
| 144 | { |
||
| 145 | //Get next character |
||
| 146 | $c=$s{$i}; |
||
| 147 | $o=ord($c); |
||
| 148 | if($o==10) |
||
| 149 | { |
||
| 150 | //Explicit line break |
||
| 151 | $this->Cell($w,$h,substr($s,$j,$i-$j),$b,2,$align,$fill); |
||
| 152 | $i++; |
||
| 153 | $sep=-1; |
||
| 154 | $j=$i; |
||
| 155 | $l=0; |
||
| 156 | $nl++; |
||
| 157 | if($border and $nl==2) |
||
| 158 | $b=$b2; |
||
| 159 | continue; |
||
| 160 | } |
||
| 161 | View Code Duplication | if($o<128) |
|
| 162 | { |
||
| 163 | //ASCII |
||
| 164 | $l+=$cw[$c]; |
||
| 165 | $n=1; |
||
| 166 | if($o==32) |
||
| 167 | $sep=$i; |
||
| 168 | } |
||
| 169 | elseif($o>=161 and $o<=223) |
||
| 170 | { |
||
| 171 | //Half-width katakana |
||
| 172 | $l+=500; |
||
| 173 | $n=1; |
||
| 174 | $sep=$i; |
||
| 175 | } |
||
| 176 | else |
||
| 177 | { |
||
| 178 | //Full-width character |
||
| 179 | $l+=1000; |
||
| 180 | $n=2; |
||
| 181 | $sep=$i; |
||
| 182 | } |
||
| 183 | if($l>$wmax) |
||
| 184 | { |
||
| 185 | //Automatic line break |
||
| 186 | if($sep==-1 or $i==$j) |
||
| 187 | { |
||
| 188 | if($i==$j) |
||
| 189 | $i+=$n; |
||
| 190 | $this->Cell($w,$h,substr($s,$j,$i-$j),$b,2,$align,$fill); |
||
| 191 | } |
||
| 192 | else |
||
| 193 | { |
||
| 194 | $this->Cell($w,$h,substr($s,$j,$sep-$j),$b,2,$align,$fill); |
||
| 195 | $i=($s[$sep]==' ') ? $sep+1 : $sep; |
||
| 196 | } |
||
| 197 | $sep=-1; |
||
| 198 | $j=$i; |
||
| 199 | $l=0; |
||
| 200 | $nl++; |
||
| 201 | if($border and $nl==2) |
||
| 202 | $b=$b2; |
||
| 203 | } |
||
| 204 | else |
||
| 205 | { |
||
| 206 | $i+=$n; |
||
| 207 | if($o>=128) |
||
| 208 | $sep=$i; |
||
| 209 | } |
||
| 210 | } |
||
| 211 | //Last chunk |
||
| 212 | if($border and is_int(strpos($border,'B'))) |
||
| 213 | $b.='B'; |
||
| 214 | $this->Cell($w,$h,substr($s,$j,$i-$j),$b,2,$align,$fill); |
||
| 215 | $this->x=$this->lMargin; |
||
| 216 | } |
||
| 217 | |||
| 218 | View Code Duplication | function Write($h,$txt,$link='') |
|
| 219 | { |
||
| 220 | if($this->CurrentFont['type']=='Type0') |
||
| 221 | $this->SJISWrite($h,$txt,$link); |
||
| 222 | else |
||
| 223 | parent::Write($h,$txt,$link); |
||
| 224 | } |
||
| 225 | |||
| 226 | function SJISWrite($h,$txt,$link) |
||
| 227 | { |
||
| 228 | //SJIS version of Write() |
||
| 229 | $cw=&$this->CurrentFont['cw']; |
||
| 230 | $w=$this->w-$this->rMargin-$this->x; |
||
| 231 | $wmax=($w-2*$this->cMargin)*1000/$this->FontSize; |
||
| 232 | $s=str_replace("\r",'',$txt); |
||
| 233 | $nb=strlen($s); |
||
| 234 | $sep=-1; |
||
| 235 | $i=0; |
||
| 236 | $j=0; |
||
| 237 | $l=0; |
||
| 238 | $nl=1; |
||
| 239 | while($i<$nb) |
||
| 240 | { |
||
| 241 | //Get next character |
||
| 242 | $c=$s{$i}; |
||
| 243 | $o=ord($c); |
||
| 244 | if($o==10) |
||
| 245 | { |
||
| 246 | //Explicit line break |
||
| 247 | $this->Cell($w,$h,substr($s,$j,$i-$j),0,2,'',0,$link); |
||
| 248 | $i++; |
||
| 249 | $sep=-1; |
||
| 250 | $j=$i; |
||
| 251 | $l=0; |
||
| 252 | if($nl==1) |
||
| 253 | { |
||
| 254 | //Go to left margin |
||
| 255 | $this->x=$this->lMargin; |
||
| 256 | $w=$this->w-$this->rMargin-$this->x; |
||
| 257 | $wmax=($w-2*$this->cMargin)*1000/$this->FontSize; |
||
| 258 | } |
||
| 259 | $nl++; |
||
| 260 | continue; |
||
| 261 | } |
||
| 262 | View Code Duplication | if($o<128) |
|
| 263 | { |
||
| 264 | //ASCII |
||
| 265 | $l+=$cw[$c]; |
||
| 266 | $n=1; |
||
| 267 | if($o==32) |
||
| 268 | $sep=$i; |
||
| 269 | } |
||
| 270 | elseif($o>=161 and $o<=223) |
||
| 271 | { |
||
| 272 | //Half-width katakana |
||
| 273 | $l+=500; |
||
| 274 | $n=1; |
||
| 275 | $sep=$i; |
||
| 276 | } |
||
| 277 | else |
||
| 278 | { |
||
| 279 | //Full-width character |
||
| 280 | $l+=1000; |
||
| 281 | $n=2; |
||
| 282 | $sep=$i; |
||
| 283 | } |
||
| 284 | if($l>$wmax) |
||
| 285 | { |
||
| 286 | //Automatic line break |
||
| 287 | if($sep==-1 or $i==$j) |
||
| 288 | { |
||
| 289 | if($this->x>$this->lMargin) |
||
| 290 | { |
||
| 291 | //Move to next line |
||
| 292 | $this->x=$this->lMargin; |
||
| 293 | $this->y+=$h; |
||
| 294 | $w=$this->w-$this->rMargin-$this->x; |
||
| 295 | $wmax=($w-2*$this->cMargin)*1000/$this->FontSize; |
||
| 296 | $i+=$n; |
||
| 297 | $nl++; |
||
| 298 | continue; |
||
| 299 | } |
||
| 300 | if($i==$j) |
||
| 301 | $i+=$n; |
||
| 302 | $this->Cell($w,$h,substr($s,$j,$i-$j),0,2,'',0,$link); |
||
| 303 | } |
||
| 304 | else |
||
| 305 | { |
||
| 306 | $this->Cell($w,$h,substr($s,$j,$sep-$j),0,2,'',0,$link); |
||
| 307 | $i=($s[$sep]==' ') ? $sep+1 : $sep; |
||
| 308 | } |
||
| 309 | $sep=-1; |
||
| 310 | $j=$i; |
||
| 311 | $l=0; |
||
| 312 | if($nl==1) |
||
| 313 | { |
||
| 314 | $this->x=$this->lMargin; |
||
| 315 | $w=$this->w-$this->rMargin-$this->x; |
||
| 316 | $wmax=($w-2*$this->cMargin)*1000/$this->FontSize; |
||
| 317 | } |
||
| 318 | $nl++; |
||
| 319 | } |
||
| 320 | else |
||
| 321 | { |
||
| 322 | $i+=$n; |
||
| 323 | if($o>=128) |
||
| 324 | $sep=$i; |
||
| 325 | } |
||
| 326 | } |
||
| 327 | //Last chunk |
||
| 328 | if($i!=$j) |
||
| 329 | $this->Cell($l/1000*$this->FontSize,$h,substr($s,$j,$i-$j),0,0,'',0,$link); |
||
| 330 | } |
||
| 331 | |||
| 332 | View Code Duplication | function _putfonts() |
|
| 333 | { |
||
| 334 | $nf=$this->n; |
||
| 335 | foreach($this->diffs as $diff) |
||
| 336 | { |
||
| 337 | //Encodings |
||
| 338 | $this->_newobj(); |
||
| 339 | $this->_out('<</Type /Encoding /BaseEncoding /WinAnsiEncoding /Differences ['.$diff.']>>'); |
||
| 340 | $this->_out('endobj'); |
||
| 341 | } |
||
| 342 | $mqr=get_magic_quotes_runtime(); |
||
| 343 | set_magic_quotes_runtime(0); |
||
| 344 | foreach($this->FontFiles as $file=>$info) |
||
| 345 | { |
||
| 346 | //Font file embedding |
||
| 347 | $this->_newobj(); |
||
| 348 | $this->FontFiles[$file]['n']=$this->n; |
||
| 349 | if(defined('FPDF_FONTPATH')) |
||
| 350 | $file=FPDF_FONTPATH.$file; |
||
| 351 | $size=filesize($file); |
||
| 352 | if(!$size) |
||
| 353 | $this->Error('Font file not found'); |
||
| 354 | $this->_out('<</Length '.$size); |
||
| 355 | if(substr($file,-2)=='.z') |
||
| 356 | $this->_out('/Filter /FlateDecode'); |
||
| 357 | $this->_out('/Length1 '.$info['length1']); |
||
| 358 | if(isset($info['length2'])) |
||
| 359 | $this->_out('/Length2 '.$info['length2'].' /Length3 0'); |
||
| 360 | $this->_out('>>'); |
||
| 361 | $f=fopen($file,'rb'); |
||
| 362 | $this->_putstream(fread($f,$size)); |
||
| 363 | fclose($f); |
||
| 364 | $this->_out('endobj'); |
||
| 365 | } |
||
| 366 | set_magic_quotes_runtime($mqr); |
||
| 367 | foreach($this->fonts as $k=>$font) |
||
| 368 | { |
||
| 369 | //Font objects |
||
| 370 | $this->_newobj(); |
||
| 371 | $this->fonts[$k]['n']=$this->n; |
||
| 372 | $this->_out('<</Type /Font'); |
||
| 373 | if($font['type']=='Type0') |
||
| 374 | $this->_putType0($font); |
||
| 375 | else |
||
| 376 | { |
||
| 377 | $name=$font['name']; |
||
| 378 | $this->_out('/BaseFont /'.$name); |
||
| 379 | if($font['type']=='core') |
||
| 380 | { |
||
| 381 | //Standard font |
||
| 382 | $this->_out('/Subtype /Type1'); |
||
| 383 | if($name!='Symbol' and $name!='ZapfDingbats') |
||
| 384 | $this->_out('/Encoding /WinAnsiEncoding'); |
||
| 385 | } |
||
| 386 | else |
||
| 387 | { |
||
| 388 | //Additional font |
||
| 389 | $this->_out('/Subtype /'.$font['type']); |
||
| 390 | $this->_out('/FirstChar 32'); |
||
| 391 | $this->_out('/LastChar 255'); |
||
| 392 | $this->_out('/Widths '.($this->n+1).' 0 R'); |
||
| 393 | $this->_out('/FontDescriptor '.($this->n+2).' 0 R'); |
||
| 394 | if($font['enc']) |
||
| 395 | { |
||
| 396 | if(isset($font['diff'])) |
||
| 397 | $this->_out('/Encoding '.($nf+$font['diff']).' 0 R'); |
||
| 398 | else |
||
| 399 | $this->_out('/Encoding /WinAnsiEncoding'); |
||
| 400 | } |
||
| 401 | } |
||
| 402 | $this->_out('>>'); |
||
| 403 | $this->_out('endobj'); |
||
| 404 | if($font['type']!='core') |
||
| 405 | { |
||
| 406 | //Widths |
||
| 407 | $this->_newobj(); |
||
| 408 | $cw=&$font['cw']; |
||
| 409 | $s='['; |
||
| 410 | for($i=32;$i<=255;$i++) |
||
| 411 | $s.=$cw[chr($i)].' '; |
||
| 412 | $this->_out($s.']'); |
||
| 413 | $this->_out('endobj'); |
||
| 414 | //Descriptor |
||
| 415 | $this->_newobj(); |
||
| 416 | $s='<</Type /FontDescriptor /FontName /'.$name; |
||
| 417 | foreach($font['desc'] as $k=>$v) |
||
| 418 | $s.=' /'.$k.' '.$v; |
||
| 419 | $file=$font['file']; |
||
| 420 | if($file) |
||
| 421 | $s.=' /FontFile'.($font['type']=='Type1' ? '' : '2').' '.$this->FontFiles[$file]['n'].' 0 R'; |
||
| 422 | $this->_out($s.'>>'); |
||
| 423 | $this->_out('endobj'); |
||
| 424 | } |
||
| 425 | } |
||
| 426 | } |
||
| 427 | } |
||
| 428 | |||
| 429 | function _putType0($font) |
||
| 430 | { |
||
| 431 | //Type0 |
||
| 432 | $this->_out('/Subtype /Type0'); |
||
| 433 | $this->_out('/BaseFont /'.$font['name'].'-'.$font['CMap']); |
||
| 434 | $this->_out('/Encoding /'.$font['CMap']); |
||
| 435 | $this->_out('/DescendantFonts ['.($this->n+1).' 0 R]'); |
||
| 436 | $this->_out('>>'); |
||
| 437 | $this->_out('endobj'); |
||
| 438 | //CIDFont |
||
| 439 | $this->_newobj(); |
||
| 440 | $this->_out('<</Type /Font'); |
||
| 441 | $this->_out('/Subtype /CIDFontType0'); |
||
| 442 | $this->_out('/BaseFont /'.$font['name']); |
||
| 443 | $this->_out('/CIDSystemInfo <</Registry (Adobe) /Ordering ('.$font['registry']['ordering'].') /Supplement '.$font['registry']['supplement'].'>>'); |
||
| 444 | $this->_out('/FontDescriptor '.($this->n+1).' 0 R'); |
||
| 445 | $W='/W [1 ['; |
||
| 446 | foreach($font['cw'] as $w) |
||
| 447 | $W.=$w.' '; |
||
| 448 | $this->_out($W.'] 231 325 500 631 [500] 326 389 500]'); |
||
| 449 | $this->_out('>>'); |
||
| 450 | $this->_out('endobj'); |
||
| 451 | //Font descriptor |
||
| 452 | $this->_newobj(); |
||
| 453 | $this->_out('<</Type /FontDescriptor'); |
||
| 454 | $this->_out('/FontName /'.$font['name']); |
||
| 455 | $this->_out('/Flags 6'); |
||
| 456 | $this->_out('/FontBBox [0 -200 1000 900]'); |
||
| 457 | $this->_out('/ItalicAngle 0'); |
||
| 458 | $this->_out('/Ascent 800'); |
||
| 459 | $this->_out('/Descent -200'); |
||
| 460 | $this->_out('/CapHeight 800'); |
||
| 461 | $this->_out('/StemV 60'); |
||
| 462 | $this->_out('>>'); |
||
| 463 | $this->_out('endobj'); |
||
| 464 | } |
||
| 465 | } |
||
| 466 |
Adding an explicit array definition is generally preferable to implicit array definition as it guarantees a stable state of the code.
Let’s take a look at an example:
As you can see in this example, the array
$myArrayis initialized the first time when the foreach loop is entered. You can also see that the value of thebarkey is only written conditionally; thus, its value might result from a previous iteration.This might or might not be intended. To make your intention clear, your code more readible and to avoid accidental bugs, we recommend to add an explicit initialization $myArray = array() either outside or inside the foreach loop.