@@ -521,7 +521,7 @@ discard block |
||
| 521 | 521 | if (!$newcoord) { |
| 522 | 522 | $newcoord = $coords[$coordpos]; |
| 523 | 523 | } |
| 524 | - ++ $coordpos; |
|
| 524 | + ++$coordpos; |
|
| 525 | 525 | } |
| 526 | 526 | if ($newcoord) { |
| 527 | 527 | $distance = geomath::calcDistance( |
@@ -554,7 +554,7 @@ discard block |
||
| 554 | 554 | $original = count($coords) - 1; |
| 555 | 555 | $lastlogdate = $logs[count($logs) - 1]['order_date']; |
| 556 | 556 | while ($original > 0 && $coords[$original - 1]['date'] < $lastlogdate) { |
| 557 | - -- $original; |
|
| 557 | + --$original; |
|
| 558 | 558 | } |
| 559 | 559 | $coord = new coordinate($coords[$original]['latitude'], $coords[$original]['longitude']); |
| 560 | 560 | $logs[] = [ |
@@ -955,7 +955,7 @@ discard block |
||
| 955 | 955 | $logTypes[$i]['selected'] = ($logtype == $defaultLogType) ? true : false; |
| 956 | 956 | $logTypes[$i]['name'] = $logtypeNames[$logtype]; |
| 957 | 957 | $logTypes[$i]['id'] = $logtype; |
| 958 | - $i ++; |
|
| 958 | + $i++; |
|
| 959 | 959 | } |
| 960 | 960 | |
| 961 | 961 | // return |
@@ -34,7 +34,7 @@ |
||
| 34 | 34 | |
| 35 | 35 | // min. 4 different chars |
| 36 | 36 | $chars = array(); |
| 37 | - for ($i = 0; $i < mb_strlen($pw); $i ++) { |
|
| 37 | + for ($i = 0; $i < mb_strlen($pw); $i++) { |
|
| 38 | 38 | $chars[mb_substr($pw, $i, 1)] = true; |
| 39 | 39 | } |
| 40 | 40 | |
@@ -66,7 +66,7 @@ discard block |
||
| 66 | 66 | 'description' => $item->description |
| 67 | 67 | ); |
| 68 | 68 | // increment counter |
| 69 | - $i ++; |
|
| 69 | + $i++; |
|
| 70 | 70 | // htmlspecialchars_decode() works around inconsistent HTML encoding |
| 71 | 71 | // e.g. in SMF Forum Threads |
| 72 | 72 | } elseif (!in_array(htmlspecialchars_decode($item->title), $headlines) && |
@@ -80,7 +80,7 @@ discard block |
||
| 80 | 80 | ); |
| 81 | 81 | $headlines[] = "" . htmlspecialchars_decode($item->title); |
| 82 | 82 | // increment counter |
| 83 | - $i ++; |
|
| 83 | + $i++; |
|
| 84 | 84 | } |
| 85 | 85 | } |
| 86 | 86 | } |
@@ -32,7 +32,7 @@ |
||
| 32 | 32 | */ |
| 33 | 33 | public function t($message, $style, $resource_name, $line, $plural = '', $count = 1, $lang = null) |
| 34 | 34 | { |
| 35 | - global $opt, $locale; // $locale is for lib1 compatibility |
|
| 35 | + global $opt, $locale; // $locale is for lib1 compatibility |
|
| 36 | 36 | |
| 37 | 37 | if ($message == '') { |
| 38 | 38 | return ''; |
@@ -112,7 +112,7 @@ |
||
| 112 | 112 | $errorlog_dir = $opt['rootpath'] . 'var/errorlog'; |
| 113 | 113 | $errorlog_path = $errorlog_dir . "/errorlog-" . date("Y-m-d"); |
| 114 | 114 | |
| 115 | - $error_mail_limit = 32768; // send max 32 KB = ca. 5-20 errors per day/logfile |
|
| 115 | + $error_mail_limit = 32768; // send max 32 KB = ca. 5-20 errors per day/logfile |
|
| 116 | 116 | |
| 117 | 117 | // All errors which may happen here are ignored, to avoid error recursions. |
| 118 | 118 | |
@@ -78,83 +78,83 @@ discard block |
||
| 78 | 78 | $sl1=strlen($ret); |
| 79 | 79 | if($CC==0) $CC=256; |
| 80 | 80 | if($BitCount<24) |
| 81 | - { |
|
| 81 | + { |
|
| 82 | 82 | $ColorTotal=imagecolorstotal($img); |
| 83 | - if($IsTransparent) $ColorTotal--; |
|
| 83 | + if($IsTransparent) $ColorTotal--; |
|
| 84 | 84 | |
| 85 | - for($p=0;$p<$ColorTotal;$p++) |
|
| 86 | - { |
|
| 87 | - $color=imagecolorsforindex($img,$p); |
|
| 88 | - $ret.=inttobyte($color["blue"]); |
|
| 89 | - $ret.=inttobyte($color["green"]); |
|
| 90 | - $ret.=inttobyte($color["red"]); |
|
| 91 | - $ret.=inttobyte(0); //RESERVED |
|
| 92 | - }; |
|
| 85 | + for($p=0;$p<$ColorTotal;$p++) |
|
| 86 | + { |
|
| 87 | + $color=imagecolorsforindex($img,$p); |
|
| 88 | + $ret.=inttobyte($color["blue"]); |
|
| 89 | + $ret.=inttobyte($color["green"]); |
|
| 90 | + $ret.=inttobyte($color["red"]); |
|
| 91 | + $ret.=inttobyte(0); //RESERVED |
|
| 92 | + }; |
|
| 93 | 93 | |
| 94 | 94 | $CT=$ColorTotal; |
| 95 | - for($p=$ColorTotal;$p<$CC;$p++) |
|
| 96 | - { |
|
| 97 | - $ret.=inttobyte(0); |
|
| 98 | - $ret.=inttobyte(0); |
|
| 99 | - $ret.=inttobyte(0); |
|
| 100 | - $ret.=inttobyte(0); //RESERVED |
|
| 101 | - }; |
|
| 102 | - }; |
|
| 95 | + for($p=$ColorTotal;$p<$CC;$p++) |
|
| 96 | + { |
|
| 97 | + $ret.=inttobyte(0); |
|
| 98 | + $ret.=inttobyte(0); |
|
| 99 | + $ret.=inttobyte(0); |
|
| 100 | + $ret.=inttobyte(0); //RESERVED |
|
| 101 | + }; |
|
| 102 | + }; |
|
| 103 | 103 | |
| 104 | 104 | |
| 105 | 105 | if($BitCount<=8) |
| 106 | 106 | { |
| 107 | 107 | |
| 108 | - for($y=$Height-1;$y>=0;$y--) |
|
| 109 | - { |
|
| 110 | - $bWrite=""; |
|
| 111 | - for($x=0;$x<$Width;$x++) |
|
| 112 | - { |
|
| 113 | - $color=imagecolorat($img,$x,$y); |
|
| 114 | - $bWrite.=decbinx($color,$BitCount); |
|
| 115 | - if(strlen($bWrite)==8) |
|
| 108 | + for($y=$Height-1;$y>=0;$y--) |
|
| 109 | + { |
|
| 110 | + $bWrite=""; |
|
| 111 | + for($x=0;$x<$Width;$x++) |
|
| 116 | 112 | { |
| 117 | - $retd.=inttobyte(bindec($bWrite)); |
|
| 118 | - $bWrite=""; |
|
| 113 | + $color=imagecolorat($img,$x,$y); |
|
| 114 | + $bWrite.=decbinx($color,$BitCount); |
|
| 115 | + if(strlen($bWrite)==8) |
|
| 116 | + { |
|
| 117 | + $retd.=inttobyte(bindec($bWrite)); |
|
| 118 | + $bWrite=""; |
|
| 119 | + }; |
|
| 119 | 120 | }; |
| 120 | - }; |
|
| 121 | 121 | |
| 122 | - if((strlen($bWrite)<8)and(strlen($bWrite)!=0)) |
|
| 122 | + if((strlen($bWrite)<8)and(strlen($bWrite)!=0)) |
|
| 123 | 123 | { |
| 124 | - $sl=strlen($bWrite); |
|
| 125 | - for($t=0;$t<8-$sl;$t++) |
|
| 126 | - $sl.="0"; |
|
| 127 | - $retd.=inttobyte(bindec($bWrite)); |
|
| 124 | + $sl=strlen($bWrite); |
|
| 125 | + for($t=0;$t<8-$sl;$t++) |
|
| 126 | + $sl.="0"; |
|
| 127 | + $retd.=inttobyte(bindec($bWrite)); |
|
| 128 | + }; |
|
| 129 | + for($z=0;$z<$Zbytek;$z++) |
|
| 130 | + $retd.=inttobyte(0); |
|
| 128 | 131 | }; |
| 129 | - for($z=0;$z<$Zbytek;$z++) |
|
| 130 | - $retd.=inttobyte(0); |
|
| 131 | - }; |
|
| 132 | 132 | }; |
| 133 | 133 | |
| 134 | 134 | if(($RLE==1)and($BitCount==8)) |
| 135 | 135 | { |
| 136 | - for($t=0;$t<strlen($retd);$t+=4) |
|
| 137 | - { |
|
| 138 | - if($t!=0) |
|
| 139 | - if(($t)%$Width==0) |
|
| 136 | + for($t=0;$t<strlen($retd);$t+=4) |
|
| 137 | + { |
|
| 138 | + if($t!=0) |
|
| 139 | + if(($t)%$Width==0) |
|
| 140 | 140 | $ret.=chr(0).chr(0); |
| 141 | 141 | |
| 142 | - if(($t+5)%$Width==0) |
|
| 143 | - { |
|
| 144 | - $ret.=chr(0).chr(5).substr($retd,$t,5).chr(0); |
|
| 145 | - $t+=1; |
|
| 146 | - } |
|
| 147 | - if(($t+6)%$Width==0) |
|
| 142 | + if(($t+5)%$Width==0) |
|
| 143 | + { |
|
| 144 | + $ret.=chr(0).chr(5).substr($retd,$t,5).chr(0); |
|
| 145 | + $t+=1; |
|
| 146 | + } |
|
| 147 | + if(($t+6)%$Width==0) |
|
| 148 | 148 | { |
| 149 | - $ret.=chr(0).chr(6).substr($retd,$t,6); |
|
| 150 | - $t+=2; |
|
| 149 | + $ret.=chr(0).chr(6).substr($retd,$t,6); |
|
| 150 | + $t+=2; |
|
| 151 | 151 | } |
| 152 | 152 | else |
| 153 | 153 | { |
| 154 | - $ret.=chr(0).chr(4).substr($retd,$t,4); |
|
| 154 | + $ret.=chr(0).chr(4).substr($retd,$t,4); |
|
| 155 | + }; |
|
| 155 | 156 | }; |
| 156 | - }; |
|
| 157 | - $ret.=chr(0).chr(1); |
|
| 157 | + $ret.=chr(0).chr(1); |
|
| 158 | 158 | } |
| 159 | 159 | else |
| 160 | 160 | { |
@@ -165,31 +165,31 @@ discard block |
||
| 165 | 165 | if($BitCount==24) |
| 166 | 166 | { |
| 167 | 167 | for($z=0;$z<$Zbytek;$z++) |
| 168 | - $Dopl.=chr(0); |
|
| 168 | + $Dopl.=chr(0); |
|
| 169 | 169 | |
| 170 | 170 | for($y=$Height-1;$y>=0;$y--) |
| 171 | - { |
|
| 172 | - for($x=0;$x<$Width;$x++) |
|
| 171 | + { |
|
| 172 | + for($x=0;$x<$Width;$x++) |
|
| 173 | 173 | { |
| 174 | - $color=imagecolorsforindex($img,ImageColorAt($img,$x,$y)); |
|
| 175 | - $ret.=chr($color["blue"]).chr($color["green"]).chr($color["red"]); |
|
| 174 | + $color=imagecolorsforindex($img,ImageColorAt($img,$x,$y)); |
|
| 175 | + $ret.=chr($color["blue"]).chr($color["green"]).chr($color["red"]); |
|
| 176 | 176 | } |
| 177 | - $ret.=$Dopl; |
|
| 178 | - }; |
|
| 177 | + $ret.=$Dopl; |
|
| 178 | + }; |
|
| 179 | 179 | |
| 180 | - }; |
|
| 180 | + }; |
|
| 181 | 181 | |
| 182 | - if($file!="") |
|
| 183 | - { |
|
| 182 | + if($file!="") |
|
| 183 | + { |
|
| 184 | 184 | $r=($f=fopen($file,"w")); |
| 185 | 185 | $r=$r and fwrite($f,$ret); |
| 186 | 186 | $r=$r and fclose($f); |
| 187 | 187 | return $r; |
| 188 | - } |
|
| 189 | - else |
|
| 190 | - { |
|
| 191 | - echo $ret; |
|
| 192 | - }; |
|
| 188 | + } |
|
| 189 | + else |
|
| 190 | + { |
|
| 191 | + echo $ret; |
|
| 192 | + }; |
|
| 193 | 193 | }; |
| 194 | 194 | |
| 195 | 195 | |
@@ -213,57 +213,57 @@ discard block |
||
| 213 | 213 | |
| 214 | 214 | if($Header=="BM") |
| 215 | 215 | { |
| 216 | - $Size=freaddword($f); |
|
| 217 | - $Reserved1=freadword($f); |
|
| 218 | - $Reserved2=freadword($f); |
|
| 219 | - $FirstByteOfImage=freaddword($f); |
|
| 220 | - |
|
| 221 | - $SizeBITMAPINFOHEADER=freaddword($f); |
|
| 222 | - $Width=freaddword($f); |
|
| 223 | - $Height=freaddword($f); |
|
| 224 | - $biPlanes=freadword($f); |
|
| 225 | - $biBitCount=freadword($f); |
|
| 226 | - $RLECompression=freaddword($f); |
|
| 227 | - $WidthxHeight=freaddword($f); |
|
| 228 | - $biXPelsPerMeter=freaddword($f); |
|
| 229 | - $biYPelsPerMeter=freaddword($f); |
|
| 230 | - $NumberOfPalettesUsed=freaddword($f); |
|
| 231 | - $NumberOfImportantColors=freaddword($f); |
|
| 216 | + $Size=freaddword($f); |
|
| 217 | + $Reserved1=freadword($f); |
|
| 218 | + $Reserved2=freadword($f); |
|
| 219 | + $FirstByteOfImage=freaddword($f); |
|
| 220 | + |
|
| 221 | + $SizeBITMAPINFOHEADER=freaddword($f); |
|
| 222 | + $Width=freaddword($f); |
|
| 223 | + $Height=freaddword($f); |
|
| 224 | + $biPlanes=freadword($f); |
|
| 225 | + $biBitCount=freadword($f); |
|
| 226 | + $RLECompression=freaddword($f); |
|
| 227 | + $WidthxHeight=freaddword($f); |
|
| 228 | + $biXPelsPerMeter=freaddword($f); |
|
| 229 | + $biYPelsPerMeter=freaddword($f); |
|
| 230 | + $NumberOfPalettesUsed=freaddword($f); |
|
| 231 | + $NumberOfImportantColors=freaddword($f); |
|
| 232 | 232 | |
| 233 | 233 | if($biBitCount<24) |
| 234 | - { |
|
| 235 | - $img=imagecreate($Width,$Height); |
|
| 236 | - $Colors=pow(2,$biBitCount); |
|
| 237 | - for($p=0;$p<$Colors;$p++) |
|
| 238 | - { |
|
| 234 | + { |
|
| 235 | + $img=imagecreate($Width,$Height); |
|
| 236 | + $Colors=pow(2,$biBitCount); |
|
| 237 | + for($p=0;$p<$Colors;$p++) |
|
| 238 | + { |
|
| 239 | 239 | $B=freadbyte($f); |
| 240 | 240 | $G=freadbyte($f); |
| 241 | 241 | $R=freadbyte($f); |
| 242 | 242 | $Reserved=freadbyte($f); |
| 243 | 243 | $Palette[]=imagecolorallocate($img,$R,$G,$B); |
| 244 | - }; |
|
| 244 | + }; |
|
| 245 | 245 | |
| 246 | 246 | |
| 247 | 247 | |
| 248 | 248 | |
| 249 | 249 | if($RLECompression==0) |
| 250 | 250 | { |
| 251 | - $Zbytek=(4-ceil(($Width/(8/$biBitCount)))%4)%4; |
|
| 251 | + $Zbytek=(4-ceil(($Width/(8/$biBitCount)))%4)%4; |
|
| 252 | 252 | |
| 253 | 253 | for($y=$Height-1;$y>=0;$y--) |
| 254 | 254 | { |
| 255 | - $CurrentBit=0; |
|
| 256 | - for($x=0;$x<$Width;$x++) |
|
| 257 | - { |
|
| 258 | - $C=freadbits($f,$biBitCount); |
|
| 259 | - imagesetpixel($img,$x,$y,$Palette[$C]); |
|
| 260 | - }; |
|
| 255 | + $CurrentBit=0; |
|
| 256 | + for($x=0;$x<$Width;$x++) |
|
| 257 | + { |
|
| 258 | + $C=freadbits($f,$biBitCount); |
|
| 259 | + imagesetpixel($img,$x,$y,$Palette[$C]); |
|
| 260 | + }; |
|
| 261 | 261 | if($CurrentBit!=0) {freadbyte($f);}; |
| 262 | 262 | for($g=0;$g<$Zbytek;$g++) |
| 263 | - freadbyte($f); |
|
| 264 | - }; |
|
| 263 | + freadbyte($f); |
|
| 264 | + }; |
|
| 265 | 265 | |
| 266 | - }; |
|
| 266 | + }; |
|
| 267 | 267 | }; |
| 268 | 268 | |
| 269 | 269 | |
@@ -288,29 +288,29 @@ discard block |
||
| 288 | 288 | |
| 289 | 289 | while(!(($prefix==0)and($suffix==0))) |
| 290 | 290 | { |
| 291 | - if($prefix==0) |
|
| 292 | - { |
|
| 293 | - $pocet=$suffix; |
|
| 294 | - $Data.=fread($f,$pocet); |
|
| 295 | - $pocetb+=$pocet; |
|
| 296 | - if($pocetb%2==1) {freadbyte($f); $pocetb++;}; |
|
| 297 | - }; |
|
| 298 | - if($prefix>0) |
|
| 299 | - { |
|
| 300 | - $pocet=$prefix; |
|
| 301 | - for($r=0;$r<$pocet;$r++) |
|
| 291 | + if($prefix==0) |
|
| 292 | + { |
|
| 293 | + $pocet=$suffix; |
|
| 294 | + $Data.=fread($f,$pocet); |
|
| 295 | + $pocetb+=$pocet; |
|
| 296 | + if($pocetb%2==1) {freadbyte($f); $pocetb++;}; |
|
| 297 | + }; |
|
| 298 | + if($prefix>0) |
|
| 299 | + { |
|
| 300 | + $pocet=$prefix; |
|
| 301 | + for($r=0;$r<$pocet;$r++) |
|
| 302 | 302 | $Data.=chr($suffix); |
| 303 | - }; |
|
| 304 | - $prefix=freadbyte($f); |
|
| 305 | - $suffix=freadbyte($f); |
|
| 306 | - $pocetb+=2; |
|
| 307 | - if($echoit) echo "Prefix: $prefix Suffix: $suffix<BR>"; |
|
| 303 | + }; |
|
| 304 | + $prefix=freadbyte($f); |
|
| 305 | + $suffix=freadbyte($f); |
|
| 306 | + $pocetb+=2; |
|
| 307 | + if($echoit) echo "Prefix: $prefix Suffix: $suffix<BR>"; |
|
| 308 | 308 | }; |
| 309 | 309 | |
| 310 | 310 | for($x=0;$x<strlen($Data);$x++) |
| 311 | - { |
|
| 312 | - imagesetpixel($img,$x,$y,$Palette[ord($Data[$x])]); |
|
| 313 | - }; |
|
| 311 | + { |
|
| 312 | + imagesetpixel($img,$x,$y,$Palette[ord($Data[$x])]); |
|
| 313 | + }; |
|
| 314 | 314 | $Data=""; |
| 315 | 315 | |
| 316 | 316 | }; |
@@ -341,44 +341,44 @@ discard block |
||
| 341 | 341 | |
| 342 | 342 | while(!(($prefix==0)and($suffix==0))) |
| 343 | 343 | { |
| 344 | - if($prefix==0) |
|
| 345 | - { |
|
| 346 | - $pocet=$suffix; |
|
| 344 | + if($prefix==0) |
|
| 345 | + { |
|
| 346 | + $pocet=$suffix; |
|
| 347 | 347 | |
| 348 | - $CurrentBit=0; |
|
| 349 | - for($h=0;$h<$pocet;$h++) |
|
| 348 | + $CurrentBit=0; |
|
| 349 | + for($h=0;$h<$pocet;$h++) |
|
| 350 | 350 | $Data.=chr(freadbits($f,4)); |
| 351 | - if($CurrentBit!=0) freadbits($f,4); |
|
| 352 | - $pocetb+=ceil(($pocet/2)); |
|
| 353 | - if($pocetb%2==1) {freadbyte($f); $pocetb++;}; |
|
| 354 | - }; |
|
| 355 | - if($prefix>0) |
|
| 356 | - { |
|
| 357 | - $pocet=$prefix; |
|
| 358 | - $i=0; |
|
| 359 | - for($r=0;$r<$pocet;$r++) |
|
| 351 | + if($CurrentBit!=0) freadbits($f,4); |
|
| 352 | + $pocetb+=ceil(($pocet/2)); |
|
| 353 | + if($pocetb%2==1) {freadbyte($f); $pocetb++;}; |
|
| 354 | + }; |
|
| 355 | + if($prefix>0) |
|
| 356 | + { |
|
| 357 | + $pocet=$prefix; |
|
| 358 | + $i=0; |
|
| 359 | + for($r=0;$r<$pocet;$r++) |
|
| 360 | 360 | { |
| 361 | 361 | if($i%2==0) |
| 362 | - { |
|
| 363 | - $Data.=chr($suffix%16); |
|
| 364 | - } |
|
| 365 | - else |
|
| 366 | - { |
|
| 367 | - $Data.=chr(floor($suffix/16)); |
|
| 368 | - }; |
|
| 362 | + { |
|
| 363 | + $Data.=chr($suffix%16); |
|
| 364 | + } |
|
| 365 | + else |
|
| 366 | + { |
|
| 367 | + $Data.=chr(floor($suffix/16)); |
|
| 368 | + }; |
|
| 369 | 369 | $i++; |
| 370 | 370 | }; |
| 371 | - }; |
|
| 372 | - $prefix=freadbyte($f); |
|
| 373 | - $suffix=freadbyte($f); |
|
| 374 | - $pocetb+=2; |
|
| 375 | - if($echoit) echo "Prefix: $prefix Suffix: $suffix<BR>"; |
|
| 371 | + }; |
|
| 372 | + $prefix=freadbyte($f); |
|
| 373 | + $suffix=freadbyte($f); |
|
| 374 | + $pocetb+=2; |
|
| 375 | + if($echoit) echo "Prefix: $prefix Suffix: $suffix<BR>"; |
|
| 376 | 376 | }; |
| 377 | 377 | |
| 378 | 378 | for($x=0;$x<strlen($Data);$x++) |
| 379 | - { |
|
| 380 | - imagesetpixel($img,$x,$y,$Palette[ord($Data[$x])]); |
|
| 381 | - }; |
|
| 379 | + { |
|
| 380 | + imagesetpixel($img,$x,$y,$Palette[ord($Data[$x])]); |
|
| 381 | + }; |
|
| 382 | 382 | $Data=""; |
| 383 | 383 | |
| 384 | 384 | }; |
@@ -386,25 +386,25 @@ discard block |
||
| 386 | 386 | }; |
| 387 | 387 | |
| 388 | 388 | |
| 389 | - if($biBitCount==24) |
|
| 389 | + if($biBitCount==24) |
|
| 390 | 390 | { |
| 391 | - $img=imagecreatetruecolor($Width,$Height); |
|
| 392 | - $Zbytek=$Width%4; |
|
| 391 | + $img=imagecreatetruecolor($Width,$Height); |
|
| 392 | + $Zbytek=$Width%4; |
|
| 393 | 393 | |
| 394 | - for($y=$Height-1;$y>=0;$y--) |
|
| 394 | + for($y=$Height-1;$y>=0;$y--) |
|
| 395 | 395 | { |
| 396 | - for($x=0;$x<$Width;$x++) |
|
| 397 | - { |
|
| 398 | - $B=freadbyte($f); |
|
| 399 | - $G=freadbyte($f); |
|
| 400 | - $R=freadbyte($f); |
|
| 401 | - $color=imagecolorexact($img,$R,$G,$B); |
|
| 402 | - if($color==-1) $color=imagecolorallocate($img,$R,$G,$B); |
|
| 403 | - imagesetpixel($img,$x,$y,$color); |
|
| 404 | - } |
|
| 396 | + for($x=0;$x<$Width;$x++) |
|
| 397 | + { |
|
| 398 | + $B=freadbyte($f); |
|
| 399 | + $G=freadbyte($f); |
|
| 400 | + $R=freadbyte($f); |
|
| 401 | + $color=imagecolorexact($img,$R,$G,$B); |
|
| 402 | + if($color==-1) $color=imagecolorallocate($img,$R,$G,$B); |
|
| 403 | + imagesetpixel($img,$x,$y,$color); |
|
| 404 | + } |
|
| 405 | 405 | for($z=0;$z<$Zbytek;$z++) |
| 406 | - freadbyte($f); |
|
| 407 | - }; |
|
| 406 | + freadbyte($f); |
|
| 407 | + }; |
|
| 408 | 408 | }; |
| 409 | 409 | return $img; |
| 410 | 410 | |
@@ -438,14 +438,14 @@ discard block |
||
| 438 | 438 | |
| 439 | 439 | function freadbyte($f) |
| 440 | 440 | { |
| 441 | - return ord(fread($f,1)); |
|
| 441 | + return ord(fread($f,1)); |
|
| 442 | 442 | }; |
| 443 | 443 | |
| 444 | 444 | function freadword($f) |
| 445 | 445 | { |
| 446 | - $b1=freadbyte($f); |
|
| 447 | - $b2=freadbyte($f); |
|
| 448 | - return $b2*256+$b1; |
|
| 446 | + $b1=freadbyte($f); |
|
| 447 | + $b2=freadbyte($f); |
|
| 448 | + return $b2*256+$b1; |
|
| 449 | 449 | }; |
| 450 | 450 | |
| 451 | 451 | |
@@ -456,9 +456,9 @@ discard block |
||
| 456 | 456 | |
| 457 | 457 | function freaddword($f) |
| 458 | 458 | { |
| 459 | - $b1=freadword($f); |
|
| 460 | - $b2=freadword($f); |
|
| 461 | - return $b2*65536+$b1; |
|
| 459 | + $b1=freadword($f); |
|
| 460 | + $b2=freadword($f); |
|
| 461 | + return $b2*65536+$b1; |
|
| 462 | 462 | }; |
| 463 | 463 | |
| 464 | 464 | |
@@ -476,30 +476,30 @@ discard block |
||
| 476 | 476 | $CurrentBit=0; |
| 477 | 477 | function freadbits($f,$count) |
| 478 | 478 | { |
| 479 | - global $CurrentBit,$SMode; |
|
| 480 | - $Byte=freadbyte($f); |
|
| 481 | - $LastCBit=$CurrentBit; |
|
| 482 | - $CurrentBit+=$count; |
|
| 483 | - if($CurrentBit==8) |
|
| 484 | - { |
|
| 485 | - $CurrentBit=0; |
|
| 486 | - } |
|
| 487 | - else |
|
| 488 | - { |
|
| 489 | - fseek($f,ftell($f)-1); |
|
| 490 | - }; |
|
| 491 | - return RetBits($Byte,$LastCBit,$count); |
|
| 479 | + global $CurrentBit,$SMode; |
|
| 480 | + $Byte=freadbyte($f); |
|
| 481 | + $LastCBit=$CurrentBit; |
|
| 482 | + $CurrentBit+=$count; |
|
| 483 | + if($CurrentBit==8) |
|
| 484 | + { |
|
| 485 | + $CurrentBit=0; |
|
| 486 | + } |
|
| 487 | + else |
|
| 488 | + { |
|
| 489 | + fseek($f,ftell($f)-1); |
|
| 490 | + }; |
|
| 491 | + return RetBits($Byte,$LastCBit,$count); |
|
| 492 | 492 | }; |
| 493 | 493 | |
| 494 | 494 | |
| 495 | 495 | |
| 496 | 496 | function RGBToHex($Red,$Green,$Blue) |
| 497 | - { |
|
| 498 | - $hRed=dechex($Red);if(strlen($hRed)==1) $hRed="0$hRed"; |
|
| 499 | - $hGreen=dechex($Green);if(strlen($hGreen)==1) $hGreen="0$hGreen"; |
|
| 500 | - $hBlue=dechex($Blue);if(strlen($hBlue)==1) $hBlue="0$hBlue"; |
|
| 501 | - return($hRed.$hGreen.$hBlue); |
|
| 502 | - }; |
|
| 497 | + { |
|
| 498 | + $hRed=dechex($Red);if(strlen($hRed)==1) $hRed="0$hRed"; |
|
| 499 | + $hGreen=dechex($Green);if(strlen($hGreen)==1) $hGreen="0$hGreen"; |
|
| 500 | + $hBlue=dechex($Blue);if(strlen($hBlue)==1) $hBlue="0$hBlue"; |
|
| 501 | + return($hRed.$hGreen.$hBlue); |
|
| 502 | + }; |
|
| 503 | 503 | |
| 504 | 504 | function int_to_dword($n) |
| 505 | 505 | { |
@@ -521,7 +521,7 @@ discard block |
||
| 521 | 521 | $bin=decbin($d); |
| 522 | 522 | $sbin=strlen($bin); |
| 523 | 523 | for($j=0;$j<$n-$sbin;$j++) |
| 524 | - $bin="0$bin"; |
|
| 524 | + $bin="0$bin"; |
|
| 525 | 525 | return $bin; |
| 526 | 526 | }; |
| 527 | 527 | |
@@ -36,7 +36,9 @@ discard block |
||
| 36 | 36 | $IsTransparent=$Transparent!=-1; |
| 37 | 37 | |
| 38 | 38 | |
| 39 | -if($IsTransparent) $ColorCount--; |
|
| 39 | +if($IsTransparent) { |
|
| 40 | + $ColorCount--; |
|
| 41 | +} |
|
| 40 | 42 | |
| 41 | 43 | if($ColorCount==0) {$ColorCount=0; $BitCount=24;}; |
| 42 | 44 | if(($ColorCount>0)and($ColorCount<=2)) {$ColorCount=2; $BitCount=1;}; |
@@ -49,7 +51,9 @@ discard block |
||
| 49 | 51 | |
| 50 | 52 | $Zbytek=(4-($Width/(8/$BitCount))%4)%4; |
| 51 | 53 | |
| 52 | - if($BitCount<24) $palsize=pow(2,$BitCount)*4; |
|
| 54 | + if($BitCount<24) { |
|
| 55 | + $palsize=pow(2,$BitCount)*4; |
|
| 56 | + } |
|
| 53 | 57 | |
| 54 | 58 | $size=(floor($Width/(8/$BitCount))+$Zbytek)*$Height+54; |
| 55 | 59 | $size+=$palsize; |
@@ -76,11 +80,15 @@ discard block |
||
| 76 | 80 | |
| 77 | 81 | $CC=$ColorCount; |
| 78 | 82 | $sl1=strlen($ret); |
| 79 | - if($CC==0) $CC=256; |
|
| 83 | + if($CC==0) { |
|
| 84 | + $CC=256; |
|
| 85 | + } |
|
| 80 | 86 | if($BitCount<24) |
| 81 | 87 | { |
| 82 | 88 | $ColorTotal=imagecolorstotal($img); |
| 83 | - if($IsTransparent) $ColorTotal--; |
|
| 89 | + if($IsTransparent) { |
|
| 90 | + $ColorTotal--; |
|
| 91 | + } |
|
| 84 | 92 | |
| 85 | 93 | for($p=0;$p<$ColorTotal;$p++) |
| 86 | 94 | { |
@@ -122,12 +130,14 @@ discard block |
||
| 122 | 130 | if((strlen($bWrite)<8)and(strlen($bWrite)!=0)) |
| 123 | 131 | { |
| 124 | 132 | $sl=strlen($bWrite); |
| 125 | - for($t=0;$t<8-$sl;$t++) |
|
| 126 | - $sl.="0"; |
|
| 133 | + for($t=0;$t<8-$sl;$t++) { |
|
| 134 | + $sl.="0"; |
|
| 135 | + } |
|
| 127 | 136 | $retd.=inttobyte(bindec($bWrite)); |
| 128 | 137 | }; |
| 129 | - for($z=0;$z<$Zbytek;$z++) |
|
| 130 | - $retd.=inttobyte(0); |
|
| 138 | + for($z=0;$z<$Zbytek;$z++) { |
|
| 139 | + $retd.=inttobyte(0); |
|
| 140 | + } |
|
| 131 | 141 | }; |
| 132 | 142 | }; |
| 133 | 143 | |
@@ -135,9 +145,10 @@ discard block |
||
| 135 | 145 | { |
| 136 | 146 | for($t=0;$t<strlen($retd);$t+=4) |
| 137 | 147 | { |
| 138 | - if($t!=0) |
|
| 139 | - if(($t)%$Width==0) |
|
| 148 | + if($t!=0) { |
|
| 149 | + if(($t)%$Width==0) |
|
| 140 | 150 | $ret.=chr(0).chr(0); |
| 151 | + } |
|
| 141 | 152 | |
| 142 | 153 | if(($t+5)%$Width==0) |
| 143 | 154 | { |
@@ -148,15 +159,13 @@ discard block |
||
| 148 | 159 | { |
| 149 | 160 | $ret.=chr(0).chr(6).substr($retd,$t,6); |
| 150 | 161 | $t+=2; |
| 151 | - } |
|
| 152 | - else |
|
| 162 | + } else |
|
| 153 | 163 | { |
| 154 | 164 | $ret.=chr(0).chr(4).substr($retd,$t,4); |
| 155 | 165 | }; |
| 156 | 166 | }; |
| 157 | 167 | $ret.=chr(0).chr(1); |
| 158 | -} |
|
| 159 | -else |
|
| 168 | +} else |
|
| 160 | 169 | { |
| 161 | 170 | $ret.=$retd; |
| 162 | 171 | }; |
@@ -164,8 +173,9 @@ discard block |
||
| 164 | 173 | |
| 165 | 174 | if($BitCount==24) |
| 166 | 175 | { |
| 167 | - for($z=0;$z<$Zbytek;$z++) |
|
| 168 | - $Dopl.=chr(0); |
|
| 176 | + for($z=0;$z<$Zbytek;$z++) { |
|
| 177 | + $Dopl.=chr(0); |
|
| 178 | + } |
|
| 169 | 179 | |
| 170 | 180 | for($y=$Height-1;$y>=0;$y--) |
| 171 | 181 | { |
@@ -185,8 +195,7 @@ discard block |
||
| 185 | 195 | $r=$r and fwrite($f,$ret); |
| 186 | 196 | $r=$r and fclose($f); |
| 187 | 197 | return $r; |
| 188 | - } |
|
| 189 | - else |
|
| 198 | + } else |
|
| 190 | 199 | { |
| 191 | 200 | echo $ret; |
| 192 | 201 | }; |
@@ -259,17 +268,20 @@ discard block |
||
| 259 | 268 | imagesetpixel($img,$x,$y,$Palette[$C]); |
| 260 | 269 | }; |
| 261 | 270 | if($CurrentBit!=0) {freadbyte($f);}; |
| 262 | - for($g=0;$g<$Zbytek;$g++) |
|
| 263 | - freadbyte($f); |
|
| 271 | + for($g=0;$g<$Zbytek;$g++) { |
|
| 272 | + freadbyte($f); |
|
| 273 | + } |
|
| 264 | 274 | }; |
| 265 | 275 | |
| 266 | 276 | }; |
| 267 | 277 | }; |
| 268 | 278 | |
| 269 | 279 | |
| 270 | -if($RLECompression==1) //$BI_RLE8 |
|
| 280 | +if($RLECompression==1) { |
|
| 281 | + //$BI_RLE8 |
|
| 271 | 282 | { |
| 272 | 283 | $y=$Height; |
| 284 | +} |
|
| 273 | 285 | |
| 274 | 286 | $pocetb=0; |
| 275 | 287 | |
@@ -282,9 +294,15 @@ discard block |
||
| 282 | 294 | |
| 283 | 295 | $echoit=false; |
| 284 | 296 | |
| 285 | -if($echoit)echo "Prefix: $prefix Suffix: $suffix<BR>"; |
|
| 286 | -if(($prefix==0)and($suffix==1)) break; |
|
| 287 | -if(feof($f)) break; |
|
| 297 | +if($echoit) { |
|
| 298 | + echo "Prefix: $prefix Suffix: $suffix<BR>"; |
|
| 299 | +} |
|
| 300 | +if(($prefix==0)and($suffix==1)) { |
|
| 301 | + break; |
|
| 302 | +} |
|
| 303 | +if(feof($f)) { |
|
| 304 | + break; |
|
| 305 | +} |
|
| 288 | 306 | |
| 289 | 307 | while(!(($prefix==0)and($suffix==0))) |
| 290 | 308 | { |
@@ -298,14 +316,17 @@ discard block |
||
| 298 | 316 | if($prefix>0) |
| 299 | 317 | { |
| 300 | 318 | $pocet=$prefix; |
| 301 | - for($r=0;$r<$pocet;$r++) |
|
| 302 | - $Data.=chr($suffix); |
|
| 319 | + for($r=0;$r<$pocet;$r++) { |
|
| 320 | + $Data.=chr($suffix); |
|
| 321 | + } |
|
| 303 | 322 | }; |
| 304 | 323 | $prefix=freadbyte($f); |
| 305 | 324 | $suffix=freadbyte($f); |
| 306 | 325 | $pocetb+=2; |
| 307 | - if($echoit) echo "Prefix: $prefix Suffix: $suffix<BR>"; |
|
| 308 | -}; |
|
| 326 | + if($echoit) { |
|
| 327 | + echo "Prefix: $prefix Suffix: $suffix<BR>"; |
|
| 328 | + } |
|
| 329 | + }; |
|
| 309 | 330 | |
| 310 | 331 | for($x=0;$x<strlen($Data);$x++) |
| 311 | 332 | { |
@@ -318,9 +339,11 @@ discard block |
||
| 318 | 339 | }; |
| 319 | 340 | |
| 320 | 341 | |
| 321 | -if($RLECompression==2) //$BI_RLE4 |
|
| 342 | +if($RLECompression==2) { |
|
| 343 | + //$BI_RLE4 |
|
| 322 | 344 | { |
| 323 | 345 | $y=$Height; |
| 346 | +} |
|
| 324 | 347 | $pocetb=0; |
| 325 | 348 | |
| 326 | 349 | /*while(!feof($f)) |
@@ -335,9 +358,15 @@ discard block |
||
| 335 | 358 | |
| 336 | 359 | $echoit=false; |
| 337 | 360 | |
| 338 | -if($echoit)echo "Prefix: $prefix Suffix: $suffix<BR>"; |
|
| 339 | -if(($prefix==0)and($suffix==1)) break; |
|
| 340 | -if(feof($f)) break; |
|
| 361 | +if($echoit) { |
|
| 362 | + echo "Prefix: $prefix Suffix: $suffix<BR>"; |
|
| 363 | +} |
|
| 364 | +if(($prefix==0)and($suffix==1)) { |
|
| 365 | + break; |
|
| 366 | +} |
|
| 367 | +if(feof($f)) { |
|
| 368 | + break; |
|
| 369 | +} |
|
| 341 | 370 | |
| 342 | 371 | while(!(($prefix==0)and($suffix==0))) |
| 343 | 372 | { |
@@ -346,9 +375,12 @@ discard block |
||
| 346 | 375 | $pocet=$suffix; |
| 347 | 376 | |
| 348 | 377 | $CurrentBit=0; |
| 349 | - for($h=0;$h<$pocet;$h++) |
|
| 350 | - $Data.=chr(freadbits($f,4)); |
|
| 351 | - if($CurrentBit!=0) freadbits($f,4); |
|
| 378 | + for($h=0;$h<$pocet;$h++) { |
|
| 379 | + $Data.=chr(freadbits($f,4)); |
|
| 380 | + } |
|
| 381 | + if($CurrentBit!=0) { |
|
| 382 | + freadbits($f,4); |
|
| 383 | + } |
|
| 352 | 384 | $pocetb+=ceil(($pocet/2)); |
| 353 | 385 | if($pocetb%2==1) {freadbyte($f); $pocetb++;}; |
| 354 | 386 | }; |
@@ -361,8 +393,7 @@ discard block |
||
| 361 | 393 | if($i%2==0) |
| 362 | 394 | { |
| 363 | 395 | $Data.=chr($suffix%16); |
| 364 | - } |
|
| 365 | - else |
|
| 396 | + } else |
|
| 366 | 397 | { |
| 367 | 398 | $Data.=chr(floor($suffix/16)); |
| 368 | 399 | }; |
@@ -372,8 +403,10 @@ discard block |
||
| 372 | 403 | $prefix=freadbyte($f); |
| 373 | 404 | $suffix=freadbyte($f); |
| 374 | 405 | $pocetb+=2; |
| 375 | - if($echoit) echo "Prefix: $prefix Suffix: $suffix<BR>"; |
|
| 376 | -}; |
|
| 406 | + if($echoit) { |
|
| 407 | + echo "Prefix: $prefix Suffix: $suffix<BR>"; |
|
| 408 | + } |
|
| 409 | + }; |
|
| 377 | 410 | |
| 378 | 411 | for($x=0;$x<strlen($Data);$x++) |
| 379 | 412 | { |
@@ -399,11 +432,14 @@ discard block |
||
| 399 | 432 | $G=freadbyte($f); |
| 400 | 433 | $R=freadbyte($f); |
| 401 | 434 | $color=imagecolorexact($img,$R,$G,$B); |
| 402 | - if($color==-1) $color=imagecolorallocate($img,$R,$G,$B); |
|
| 435 | + if($color==-1) { |
|
| 436 | + $color=imagecolorallocate($img,$R,$G,$B); |
|
| 437 | + } |
|
| 403 | 438 | imagesetpixel($img,$x,$y,$color); |
| 404 | 439 | } |
| 405 | - for($z=0;$z<$Zbytek;$z++) |
|
| 406 | - freadbyte($f); |
|
| 440 | + for($z=0;$z<$Zbytek;$z++) { |
|
| 441 | + freadbyte($f); |
|
| 442 | + } |
|
| 407 | 443 | }; |
| 408 | 444 | }; |
| 409 | 445 | return $img; |
@@ -483,8 +519,7 @@ discard block |
||
| 483 | 519 | if($CurrentBit==8) |
| 484 | 520 | { |
| 485 | 521 | $CurrentBit=0; |
| 486 | - } |
|
| 487 | - else |
|
| 522 | + } else |
|
| 488 | 523 | { |
| 489 | 524 | fseek($f,ftell($f)-1); |
| 490 | 525 | }; |
@@ -495,9 +530,15 @@ discard block |
||
| 495 | 530 | |
| 496 | 531 | function RGBToHex($Red,$Green,$Blue) |
| 497 | 532 | { |
| 498 | - $hRed=dechex($Red);if(strlen($hRed)==1) $hRed="0$hRed"; |
|
| 499 | - $hGreen=dechex($Green);if(strlen($hGreen)==1) $hGreen="0$hGreen"; |
|
| 500 | - $hBlue=dechex($Blue);if(strlen($hBlue)==1) $hBlue="0$hBlue"; |
|
| 533 | + $hRed=dechex($Red);if(strlen($hRed)==1) { |
|
| 534 | + $hRed="0$hRed"; |
|
| 535 | + } |
|
| 536 | + $hGreen=dechex($Green);if(strlen($hGreen)==1) { |
|
| 537 | + $hGreen="0$hGreen"; |
|
| 538 | + } |
|
| 539 | + $hBlue=dechex($Blue);if(strlen($hBlue)==1) { |
|
| 540 | + $hBlue="0$hBlue"; |
|
| 541 | + } |
|
| 501 | 542 | return($hRed.$hGreen.$hBlue); |
| 502 | 543 | }; |
| 503 | 544 | |
@@ -520,8 +561,9 @@ discard block |
||
| 520 | 561 | { |
| 521 | 562 | $bin=decbin($d); |
| 522 | 563 | $sbin=strlen($bin); |
| 523 | -for($j=0;$j<$n-$sbin;$j++) |
|
| 564 | +for($j=0;$j<$n-$sbin;$j++) { |
|
| 524 | 565 | $bin="0$bin"; |
| 566 | +} |
|
| 525 | 567 | return $bin; |
| 526 | 568 | }; |
| 527 | 569 | |
@@ -468,6 +468,7 @@ discard block |
||
| 468 | 468 | |
| 469 | 469 | /** |
| 470 | 470 | * @param integer $byte |
| 471 | + * @param integer $len |
|
| 471 | 472 | */ |
| 472 | 473 | function RetBits($byte,$start,$len) |
| 473 | 474 | { |
@@ -525,6 +526,9 @@ discard block |
||
| 525 | 526 | } |
| 526 | 527 | |
| 527 | 528 | |
| 529 | +/** |
|
| 530 | + * @param integer $d |
|
| 531 | + */ |
|
| 528 | 532 | function decbin8($d) |
| 529 | 533 | { |
| 530 | 534 | return decbinx($d,8); |
@@ -29,164 +29,164 @@ discard block |
||
| 29 | 29 | /** |
| 30 | 30 | * @param resource $img |
| 31 | 31 | */ |
| 32 | -function imagebmp($img,$file="",$RLE=0) |
|
| 32 | +function imagebmp($img, $file = "", $RLE = 0) |
|
| 33 | 33 | { |
| 34 | 34 | |
| 35 | 35 | |
| 36 | -$ColorCount=imagecolorstotal($img); |
|
| 36 | +$ColorCount = imagecolorstotal($img); |
|
| 37 | 37 | |
| 38 | -$Transparent=imagecolortransparent($img); |
|
| 39 | -$IsTransparent=$Transparent!=-1; |
|
| 38 | +$Transparent = imagecolortransparent($img); |
|
| 39 | +$IsTransparent = $Transparent != -1; |
|
| 40 | 40 | |
| 41 | 41 | |
| 42 | -if($IsTransparent) $ColorCount--; |
|
| 42 | +if ($IsTransparent) $ColorCount--; |
|
| 43 | 43 | |
| 44 | -if($ColorCount==0) {$ColorCount=0; $BitCount=24;}; |
|
| 45 | -if(($ColorCount>0)and($ColorCount<=2)) {$ColorCount=2; $BitCount=1;}; |
|
| 46 | -if(($ColorCount>2)and($ColorCount<=16)) { $ColorCount=16; $BitCount=4;}; |
|
| 47 | -if(($ColorCount>16)and($ColorCount<=256)) { $ColorCount=0; $BitCount=8;}; |
|
| 44 | +if ($ColorCount == 0) {$ColorCount = 0; $BitCount = 24; }; |
|
| 45 | +if (($ColorCount > 0) and ($ColorCount <= 2)) {$ColorCount = 2; $BitCount = 1; }; |
|
| 46 | +if (($ColorCount > 2) and ($ColorCount <= 16)) { $ColorCount = 16; $BitCount = 4; }; |
|
| 47 | +if (($ColorCount > 16) and ($ColorCount <= 256)) { $ColorCount = 0; $BitCount = 8; }; |
|
| 48 | 48 | |
| 49 | 49 | |
| 50 | - $Width=imagesx($img); |
|
| 51 | - $Height=imagesy($img); |
|
| 50 | + $Width = imagesx($img); |
|
| 51 | + $Height = imagesy($img); |
|
| 52 | 52 | |
| 53 | - $Zbytek=(4-($Width/(8/$BitCount))%4)%4; |
|
| 53 | + $Zbytek = (4 - ($Width / (8 / $BitCount)) % 4) % 4; |
|
| 54 | 54 | |
| 55 | - if($BitCount<24) $palsize=pow(2,$BitCount)*4; |
|
| 55 | + if ($BitCount < 24) $palsize = pow(2, $BitCount) * 4; |
|
| 56 | 56 | |
| 57 | - $size=(floor($Width/(8/$BitCount))+$Zbytek)*$Height+54; |
|
| 58 | - $size+=$palsize; |
|
| 59 | - $offset=54+$palsize; |
|
| 57 | + $size = (floor($Width / (8 / $BitCount)) + $Zbytek) * $Height + 54; |
|
| 58 | + $size += $palsize; |
|
| 59 | + $offset = 54 + $palsize; |
|
| 60 | 60 | |
| 61 | 61 | // Bitmap File Header |
| 62 | - $ret = 'BM'; // header (2b) |
|
| 63 | - $ret .= int_to_dword($size); // size of file (4b) |
|
| 64 | - $ret .= int_to_dword(0); // reserved (4b) |
|
| 65 | - $ret .= int_to_dword($offset); // byte location in the file which is first byte of IMAGE (4b) |
|
| 62 | + $ret = 'BM'; // header (2b) |
|
| 63 | + $ret .= int_to_dword($size); // size of file (4b) |
|
| 64 | + $ret .= int_to_dword(0); // reserved (4b) |
|
| 65 | + $ret .= int_to_dword($offset); // byte location in the file which is first byte of IMAGE (4b) |
|
| 66 | 66 | // Bitmap Info Header |
| 67 | - $ret .= int_to_dword(40); // Size of BITMAPINFOHEADER (4b) |
|
| 68 | - $ret .= int_to_dword($Width); // width of bitmap (4b) |
|
| 69 | - $ret .= int_to_dword($Height); // height of bitmap (4b) |
|
| 70 | - $ret .= int_to_word(1); // biPlanes = 1 (2b) |
|
| 71 | - $ret .= int_to_word($BitCount); // biBitCount = {1 (mono) or 4 (16 clr ) or 8 (256 clr) or 24 (16 Mil)} (2b) |
|
| 72 | - $ret .= int_to_dword($RLE); // RLE COMPRESSION (4b) |
|
| 73 | - $ret .= int_to_dword(0); // width x height (4b) |
|
| 74 | - $ret .= int_to_dword(0); // biXPelsPerMeter (4b) |
|
| 75 | - $ret .= int_to_dword(0); // biYPelsPerMeter (4b) |
|
| 76 | - $ret .= int_to_dword(0); // Number of palettes used (4b) |
|
| 77 | - $ret .= int_to_dword(0); // Number of important colour (4b) |
|
| 67 | + $ret .= int_to_dword(40); // Size of BITMAPINFOHEADER (4b) |
|
| 68 | + $ret .= int_to_dword($Width); // width of bitmap (4b) |
|
| 69 | + $ret .= int_to_dword($Height); // height of bitmap (4b) |
|
| 70 | + $ret .= int_to_word(1); // biPlanes = 1 (2b) |
|
| 71 | + $ret .= int_to_word($BitCount); // biBitCount = {1 (mono) or 4 (16 clr ) or 8 (256 clr) or 24 (16 Mil)} (2b) |
|
| 72 | + $ret .= int_to_dword($RLE); // RLE COMPRESSION (4b) |
|
| 73 | + $ret .= int_to_dword(0); // width x height (4b) |
|
| 74 | + $ret .= int_to_dword(0); // biXPelsPerMeter (4b) |
|
| 75 | + $ret .= int_to_dword(0); // biYPelsPerMeter (4b) |
|
| 76 | + $ret .= int_to_dword(0); // Number of palettes used (4b) |
|
| 77 | + $ret .= int_to_dword(0); // Number of important colour (4b) |
|
| 78 | 78 | // image data |
| 79 | 79 | |
| 80 | - $CC=$ColorCount; |
|
| 81 | - $sl1=strlen($ret); |
|
| 82 | - if($CC==0) $CC=256; |
|
| 83 | - if($BitCount<24) |
|
| 80 | + $CC = $ColorCount; |
|
| 81 | + $sl1 = strlen($ret); |
|
| 82 | + if ($CC == 0) $CC = 256; |
|
| 83 | + if ($BitCount < 24) |
|
| 84 | 84 | { |
| 85 | - $ColorTotal=imagecolorstotal($img); |
|
| 86 | - if($IsTransparent) $ColorTotal--; |
|
| 85 | + $ColorTotal = imagecolorstotal($img); |
|
| 86 | + if ($IsTransparent) $ColorTotal--; |
|
| 87 | 87 | |
| 88 | - for($p=0;$p<$ColorTotal;$p++) |
|
| 88 | + for ($p = 0; $p < $ColorTotal; $p++) |
|
| 89 | 89 | { |
| 90 | - $color=imagecolorsforindex($img,$p); |
|
| 91 | - $ret.=inttobyte($color["blue"]); |
|
| 92 | - $ret.=inttobyte($color["green"]); |
|
| 93 | - $ret.=inttobyte($color["red"]); |
|
| 94 | - $ret.=inttobyte(0); //RESERVED |
|
| 90 | + $color = imagecolorsforindex($img, $p); |
|
| 91 | + $ret .= inttobyte($color["blue"]); |
|
| 92 | + $ret .= inttobyte($color["green"]); |
|
| 93 | + $ret .= inttobyte($color["red"]); |
|
| 94 | + $ret .= inttobyte(0); //RESERVED |
|
| 95 | 95 | }; |
| 96 | 96 | |
| 97 | - $CT=$ColorTotal; |
|
| 98 | - for($p=$ColorTotal;$p<$CC;$p++) |
|
| 97 | + $CT = $ColorTotal; |
|
| 98 | + for ($p = $ColorTotal; $p < $CC; $p++) |
|
| 99 | 99 | { |
| 100 | - $ret.=inttobyte(0); |
|
| 101 | - $ret.=inttobyte(0); |
|
| 102 | - $ret.=inttobyte(0); |
|
| 103 | - $ret.=inttobyte(0); //RESERVED |
|
| 100 | + $ret .= inttobyte(0); |
|
| 101 | + $ret .= inttobyte(0); |
|
| 102 | + $ret .= inttobyte(0); |
|
| 103 | + $ret .= inttobyte(0); //RESERVED |
|
| 104 | 104 | }; |
| 105 | 105 | }; |
| 106 | 106 | |
| 107 | 107 | |
| 108 | -if($BitCount<=8) |
|
| 108 | +if ($BitCount <= 8) |
|
| 109 | 109 | { |
| 110 | 110 | |
| 111 | - for($y=$Height-1;$y>=0;$y--) |
|
| 111 | + for ($y = $Height - 1; $y >= 0; $y--) |
|
| 112 | 112 | { |
| 113 | - $bWrite=""; |
|
| 114 | - for($x=0;$x<$Width;$x++) |
|
| 113 | + $bWrite = ""; |
|
| 114 | + for ($x = 0; $x < $Width; $x++) |
|
| 115 | 115 | { |
| 116 | - $color=imagecolorat($img,$x,$y); |
|
| 117 | - $bWrite.=decbinx($color,$BitCount); |
|
| 118 | - if(strlen($bWrite)==8) |
|
| 116 | + $color = imagecolorat($img, $x, $y); |
|
| 117 | + $bWrite .= decbinx($color, $BitCount); |
|
| 118 | + if (strlen($bWrite) == 8) |
|
| 119 | 119 | { |
| 120 | - $retd.=inttobyte(bindec($bWrite)); |
|
| 121 | - $bWrite=""; |
|
| 120 | + $retd .= inttobyte(bindec($bWrite)); |
|
| 121 | + $bWrite = ""; |
|
| 122 | 122 | }; |
| 123 | 123 | }; |
| 124 | 124 | |
| 125 | - if((strlen($bWrite)<8)and(strlen($bWrite)!=0)) |
|
| 125 | + if ((strlen($bWrite) < 8) and (strlen($bWrite) != 0)) |
|
| 126 | 126 | { |
| 127 | - $sl=strlen($bWrite); |
|
| 128 | - for($t=0;$t<8-$sl;$t++) |
|
| 129 | - $sl.="0"; |
|
| 130 | - $retd.=inttobyte(bindec($bWrite)); |
|
| 127 | + $sl = strlen($bWrite); |
|
| 128 | + for ($t = 0; $t < 8 - $sl; $t++) |
|
| 129 | + $sl .= "0"; |
|
| 130 | + $retd .= inttobyte(bindec($bWrite)); |
|
| 131 | 131 | }; |
| 132 | - for($z=0;$z<$Zbytek;$z++) |
|
| 133 | - $retd.=inttobyte(0); |
|
| 132 | + for ($z = 0; $z < $Zbytek; $z++) |
|
| 133 | + $retd .= inttobyte(0); |
|
| 134 | 134 | }; |
| 135 | 135 | }; |
| 136 | 136 | |
| 137 | -if(($RLE==1)and($BitCount==8)) |
|
| 137 | +if (($RLE == 1) and ($BitCount == 8)) |
|
| 138 | 138 | { |
| 139 | - for($t=0;$t<strlen($retd);$t+=4) |
|
| 139 | + for ($t = 0; $t < strlen($retd); $t += 4) |
|
| 140 | 140 | { |
| 141 | - if($t!=0) |
|
| 142 | - if(($t)%$Width==0) |
|
| 143 | - $ret.=chr(0).chr(0); |
|
| 141 | + if ($t != 0) |
|
| 142 | + if (($t) % $Width == 0) |
|
| 143 | + $ret .= chr(0) . chr(0); |
|
| 144 | 144 | |
| 145 | - if(($t+5)%$Width==0) |
|
| 145 | + if (($t + 5) % $Width == 0) |
|
| 146 | 146 | { |
| 147 | - $ret.=chr(0).chr(5).substr($retd,$t,5).chr(0); |
|
| 148 | - $t+=1; |
|
| 147 | + $ret .= chr(0) . chr(5) . substr($retd, $t, 5) . chr(0); |
|
| 148 | + $t += 1; |
|
| 149 | 149 | } |
| 150 | - if(($t+6)%$Width==0) |
|
| 150 | + if (($t + 6) % $Width == 0) |
|
| 151 | 151 | { |
| 152 | - $ret.=chr(0).chr(6).substr($retd,$t,6); |
|
| 153 | - $t+=2; |
|
| 152 | + $ret .= chr(0) . chr(6) . substr($retd, $t, 6); |
|
| 153 | + $t += 2; |
|
| 154 | 154 | } |
| 155 | 155 | else |
| 156 | 156 | { |
| 157 | - $ret.=chr(0).chr(4).substr($retd,$t,4); |
|
| 157 | + $ret .= chr(0) . chr(4) . substr($retd, $t, 4); |
|
| 158 | 158 | }; |
| 159 | 159 | }; |
| 160 | - $ret.=chr(0).chr(1); |
|
| 160 | + $ret .= chr(0) . chr(1); |
|
| 161 | 161 | } |
| 162 | 162 | else |
| 163 | 163 | { |
| 164 | -$ret.=$retd; |
|
| 164 | +$ret .= $retd; |
|
| 165 | 165 | }; |
| 166 | 166 | |
| 167 | 167 | |
| 168 | - if($BitCount==24) |
|
| 168 | + if ($BitCount == 24) |
|
| 169 | 169 | { |
| 170 | - for($z=0;$z<$Zbytek;$z++) |
|
| 171 | - $Dopl.=chr(0); |
|
| 170 | + for ($z = 0; $z < $Zbytek; $z++) |
|
| 171 | + $Dopl .= chr(0); |
|
| 172 | 172 | |
| 173 | - for($y=$Height-1;$y>=0;$y--) |
|
| 173 | + for ($y = $Height - 1; $y >= 0; $y--) |
|
| 174 | 174 | { |
| 175 | - for($x=0;$x<$Width;$x++) |
|
| 175 | + for ($x = 0; $x < $Width; $x++) |
|
| 176 | 176 | { |
| 177 | - $color=imagecolorsforindex($img,ImageColorAt($img,$x,$y)); |
|
| 178 | - $ret.=chr($color["blue"]).chr($color["green"]).chr($color["red"]); |
|
| 177 | + $color = imagecolorsforindex($img, ImageColorAt($img, $x, $y)); |
|
| 178 | + $ret .= chr($color["blue"]) . chr($color["green"]) . chr($color["red"]); |
|
| 179 | 179 | } |
| 180 | - $ret.=$Dopl; |
|
| 180 | + $ret .= $Dopl; |
|
| 181 | 181 | }; |
| 182 | 182 | |
| 183 | 183 | }; |
| 184 | 184 | |
| 185 | - if($file!="") |
|
| 185 | + if ($file != "") |
|
| 186 | 186 | { |
| 187 | - $r=($f=fopen($file,"w")); |
|
| 188 | - $r=$r and fwrite($f,$ret); |
|
| 189 | - $r=$r and fclose($f); |
|
| 187 | + $r = ($f = fopen($file, "w")); |
|
| 188 | + $r = $r and fwrite($f, $ret); |
|
| 189 | + $r = $r and fclose($f); |
|
| 190 | 190 | return $r; |
| 191 | 191 | } |
| 192 | 192 | else |
@@ -211,58 +211,58 @@ discard block |
||
| 211 | 211 | { |
| 212 | 212 | global $CurrentBit, $echoMode; |
| 213 | 213 | |
| 214 | -$f=fopen($file,"r"); |
|
| 215 | -$Header=fread($f,2); |
|
| 214 | +$f = fopen($file, "r"); |
|
| 215 | +$Header = fread($f, 2); |
|
| 216 | 216 | |
| 217 | -if($Header=="BM") |
|
| 217 | +if ($Header == "BM") |
|
| 218 | 218 | { |
| 219 | - $Size=freaddword($f); |
|
| 220 | - $Reserved1=freadword($f); |
|
| 221 | - $Reserved2=freadword($f); |
|
| 222 | - $FirstByteOfImage=freaddword($f); |
|
| 223 | - |
|
| 224 | - $SizeBITMAPINFOHEADER=freaddword($f); |
|
| 225 | - $Width=freaddword($f); |
|
| 226 | - $Height=freaddword($f); |
|
| 227 | - $biPlanes=freadword($f); |
|
| 228 | - $biBitCount=freadword($f); |
|
| 229 | - $RLECompression=freaddword($f); |
|
| 230 | - $WidthxHeight=freaddword($f); |
|
| 231 | - $biXPelsPerMeter=freaddword($f); |
|
| 232 | - $biYPelsPerMeter=freaddword($f); |
|
| 233 | - $NumberOfPalettesUsed=freaddword($f); |
|
| 234 | - $NumberOfImportantColors=freaddword($f); |
|
| 235 | - |
|
| 236 | -if($biBitCount<24) |
|
| 219 | + $Size = freaddword($f); |
|
| 220 | + $Reserved1 = freadword($f); |
|
| 221 | + $Reserved2 = freadword($f); |
|
| 222 | + $FirstByteOfImage = freaddword($f); |
|
| 223 | + |
|
| 224 | + $SizeBITMAPINFOHEADER = freaddword($f); |
|
| 225 | + $Width = freaddword($f); |
|
| 226 | + $Height = freaddword($f); |
|
| 227 | + $biPlanes = freadword($f); |
|
| 228 | + $biBitCount = freadword($f); |
|
| 229 | + $RLECompression = freaddword($f); |
|
| 230 | + $WidthxHeight = freaddword($f); |
|
| 231 | + $biXPelsPerMeter = freaddword($f); |
|
| 232 | + $biYPelsPerMeter = freaddword($f); |
|
| 233 | + $NumberOfPalettesUsed = freaddword($f); |
|
| 234 | + $NumberOfImportantColors = freaddword($f); |
|
| 235 | + |
|
| 236 | +if ($biBitCount < 24) |
|
| 237 | 237 | { |
| 238 | - $img=imagecreate($Width,$Height); |
|
| 239 | - $Colors=pow(2,$biBitCount); |
|
| 240 | - for($p=0;$p<$Colors;$p++) |
|
| 238 | + $img = imagecreate($Width, $Height); |
|
| 239 | + $Colors = pow(2, $biBitCount); |
|
| 240 | + for ($p = 0; $p < $Colors; $p++) |
|
| 241 | 241 | { |
| 242 | - $B=freadbyte($f); |
|
| 243 | - $G=freadbyte($f); |
|
| 244 | - $R=freadbyte($f); |
|
| 245 | - $Reserved=freadbyte($f); |
|
| 246 | - $Palette[]=imagecolorallocate($img,$R,$G,$B); |
|
| 242 | + $B = freadbyte($f); |
|
| 243 | + $G = freadbyte($f); |
|
| 244 | + $R = freadbyte($f); |
|
| 245 | + $Reserved = freadbyte($f); |
|
| 246 | + $Palette[] = imagecolorallocate($img, $R, $G, $B); |
|
| 247 | 247 | }; |
| 248 | 248 | |
| 249 | 249 | |
| 250 | 250 | |
| 251 | 251 | |
| 252 | -if($RLECompression==0) |
|
| 252 | +if ($RLECompression == 0) |
|
| 253 | 253 | { |
| 254 | - $Zbytek=(4-ceil(($Width/(8/$biBitCount)))%4)%4; |
|
| 254 | + $Zbytek = (4 - ceil(($Width / (8 / $biBitCount))) % 4) % 4; |
|
| 255 | 255 | |
| 256 | -for($y=$Height-1;$y>=0;$y--) |
|
| 256 | +for ($y = $Height - 1; $y >= 0; $y--) |
|
| 257 | 257 | { |
| 258 | - $CurrentBit=0; |
|
| 259 | - for($x=0;$x<$Width;$x++) |
|
| 258 | + $CurrentBit = 0; |
|
| 259 | + for ($x = 0; $x < $Width; $x++) |
|
| 260 | 260 | { |
| 261 | - $C=freadbits($f,$biBitCount); |
|
| 262 | - imagesetpixel($img,$x,$y,$Palette[$C]); |
|
| 261 | + $C = freadbits($f, $biBitCount); |
|
| 262 | + imagesetpixel($img, $x, $y, $Palette[$C]); |
|
| 263 | 263 | }; |
| 264 | - if($CurrentBit!=0) {freadbyte($f);}; |
|
| 265 | - for($g=0;$g<$Zbytek;$g++) |
|
| 264 | + if ($CurrentBit != 0) {freadbyte($f); }; |
|
| 265 | + for ($g = 0; $g < $Zbytek; $g++) |
|
| 266 | 266 | freadbyte($f); |
| 267 | 267 | }; |
| 268 | 268 | |
@@ -270,142 +270,142 @@ discard block |
||
| 270 | 270 | }; |
| 271 | 271 | |
| 272 | 272 | |
| 273 | -if($RLECompression==1) //$BI_RLE8 |
|
| 273 | +if ($RLECompression == 1) //$BI_RLE8 |
|
| 274 | 274 | { |
| 275 | -$y=$Height; |
|
| 275 | +$y = $Height; |
|
| 276 | 276 | |
| 277 | -$pocetb=0; |
|
| 277 | +$pocetb = 0; |
|
| 278 | 278 | |
| 279 | -while(true) |
|
| 279 | +while (true) |
|
| 280 | 280 | { |
| 281 | 281 | $y--; |
| 282 | -$prefix=freadbyte($f); |
|
| 283 | -$suffix=freadbyte($f); |
|
| 284 | -$pocetb+=2; |
|
| 282 | +$prefix = freadbyte($f); |
|
| 283 | +$suffix = freadbyte($f); |
|
| 284 | +$pocetb += 2; |
|
| 285 | 285 | |
| 286 | -$echoit=false; |
|
| 286 | +$echoit = false; |
|
| 287 | 287 | |
| 288 | -if($echoit)echo "Prefix: $prefix Suffix: $suffix<BR>"; |
|
| 289 | -if(($prefix==0)and($suffix==1)) break; |
|
| 290 | -if(feof($f)) break; |
|
| 288 | +if ($echoit)echo "Prefix: $prefix Suffix: $suffix<BR>"; |
|
| 289 | +if (($prefix == 0) and ($suffix == 1)) break; |
|
| 290 | +if (feof($f)) break; |
|
| 291 | 291 | |
| 292 | -while(!(($prefix==0)and($suffix==0))) |
|
| 292 | +while (!(($prefix == 0) and ($suffix == 0))) |
|
| 293 | 293 | { |
| 294 | - if($prefix==0) |
|
| 294 | + if ($prefix == 0) |
|
| 295 | 295 | { |
| 296 | - $pocet=$suffix; |
|
| 297 | - $Data.=fread($f,$pocet); |
|
| 298 | - $pocetb+=$pocet; |
|
| 299 | - if($pocetb%2==1) {freadbyte($f); $pocetb++;}; |
|
| 296 | + $pocet = $suffix; |
|
| 297 | + $Data .= fread($f, $pocet); |
|
| 298 | + $pocetb += $pocet; |
|
| 299 | + if ($pocetb % 2 == 1) {freadbyte($f); $pocetb++; }; |
|
| 300 | 300 | }; |
| 301 | - if($prefix>0) |
|
| 301 | + if ($prefix > 0) |
|
| 302 | 302 | { |
| 303 | - $pocet=$prefix; |
|
| 304 | - for($r=0;$r<$pocet;$r++) |
|
| 305 | - $Data.=chr($suffix); |
|
| 303 | + $pocet = $prefix; |
|
| 304 | + for ($r = 0; $r < $pocet; $r++) |
|
| 305 | + $Data .= chr($suffix); |
|
| 306 | 306 | }; |
| 307 | - $prefix=freadbyte($f); |
|
| 308 | - $suffix=freadbyte($f); |
|
| 309 | - $pocetb+=2; |
|
| 310 | - if($echoit) echo "Prefix: $prefix Suffix: $suffix<BR>"; |
|
| 307 | + $prefix = freadbyte($f); |
|
| 308 | + $suffix = freadbyte($f); |
|
| 309 | + $pocetb += 2; |
|
| 310 | + if ($echoit) echo "Prefix: $prefix Suffix: $suffix<BR>"; |
|
| 311 | 311 | }; |
| 312 | 312 | |
| 313 | -for($x=0;$x<strlen($Data);$x++) |
|
| 313 | +for ($x = 0; $x < strlen($Data); $x++) |
|
| 314 | 314 | { |
| 315 | - imagesetpixel($img,$x,$y,$Palette[ord($Data[$x])]); |
|
| 315 | + imagesetpixel($img, $x, $y, $Palette[ord($Data[$x])]); |
|
| 316 | 316 | }; |
| 317 | -$Data=""; |
|
| 317 | +$Data = ""; |
|
| 318 | 318 | |
| 319 | 319 | }; |
| 320 | 320 | |
| 321 | 321 | }; |
| 322 | 322 | |
| 323 | 323 | |
| 324 | -if($RLECompression==2) //$BI_RLE4 |
|
| 324 | +if ($RLECompression == 2) //$BI_RLE4 |
|
| 325 | 325 | { |
| 326 | -$y=$Height; |
|
| 327 | -$pocetb=0; |
|
| 326 | +$y = $Height; |
|
| 327 | +$pocetb = 0; |
|
| 328 | 328 | |
| 329 | 329 | /*while(!feof($f)) |
| 330 | 330 | echo freadbyte($f)."_".freadbyte($f)."<BR>";*/ |
| 331 | -while(true) |
|
| 331 | +while (true) |
|
| 332 | 332 | { |
| 333 | 333 | //break; |
| 334 | 334 | $y--; |
| 335 | -$prefix=freadbyte($f); |
|
| 336 | -$suffix=freadbyte($f); |
|
| 337 | -$pocetb+=2; |
|
| 335 | +$prefix = freadbyte($f); |
|
| 336 | +$suffix = freadbyte($f); |
|
| 337 | +$pocetb += 2; |
|
| 338 | 338 | |
| 339 | -$echoit=false; |
|
| 339 | +$echoit = false; |
|
| 340 | 340 | |
| 341 | -if($echoit)echo "Prefix: $prefix Suffix: $suffix<BR>"; |
|
| 342 | -if(($prefix==0)and($suffix==1)) break; |
|
| 343 | -if(feof($f)) break; |
|
| 341 | +if ($echoit)echo "Prefix: $prefix Suffix: $suffix<BR>"; |
|
| 342 | +if (($prefix == 0) and ($suffix == 1)) break; |
|
| 343 | +if (feof($f)) break; |
|
| 344 | 344 | |
| 345 | -while(!(($prefix==0)and($suffix==0))) |
|
| 345 | +while (!(($prefix == 0) and ($suffix == 0))) |
|
| 346 | 346 | { |
| 347 | - if($prefix==0) |
|
| 347 | + if ($prefix == 0) |
|
| 348 | 348 | { |
| 349 | - $pocet=$suffix; |
|
| 350 | - |
|
| 351 | - $CurrentBit=0; |
|
| 352 | - for($h=0;$h<$pocet;$h++) |
|
| 353 | - $Data.=chr(freadbits($f,4)); |
|
| 354 | - if($CurrentBit!=0) freadbits($f,4); |
|
| 355 | - $pocetb+=ceil(($pocet/2)); |
|
| 356 | - if($pocetb%2==1) {freadbyte($f); $pocetb++;}; |
|
| 349 | + $pocet = $suffix; |
|
| 350 | + |
|
| 351 | + $CurrentBit = 0; |
|
| 352 | + for ($h = 0; $h < $pocet; $h++) |
|
| 353 | + $Data .= chr(freadbits($f, 4)); |
|
| 354 | + if ($CurrentBit != 0) freadbits($f, 4); |
|
| 355 | + $pocetb += ceil(($pocet / 2)); |
|
| 356 | + if ($pocetb % 2 == 1) {freadbyte($f); $pocetb++; }; |
|
| 357 | 357 | }; |
| 358 | - if($prefix>0) |
|
| 358 | + if ($prefix > 0) |
|
| 359 | 359 | { |
| 360 | - $pocet=$prefix; |
|
| 361 | - $i=0; |
|
| 362 | - for($r=0;$r<$pocet;$r++) |
|
| 360 | + $pocet = $prefix; |
|
| 361 | + $i = 0; |
|
| 362 | + for ($r = 0; $r < $pocet; $r++) |
|
| 363 | 363 | { |
| 364 | - if($i%2==0) |
|
| 364 | + if ($i % 2 == 0) |
|
| 365 | 365 | { |
| 366 | - $Data.=chr($suffix%16); |
|
| 366 | + $Data .= chr($suffix % 16); |
|
| 367 | 367 | } |
| 368 | 368 | else |
| 369 | 369 | { |
| 370 | - $Data.=chr(floor($suffix/16)); |
|
| 370 | + $Data .= chr(floor($suffix / 16)); |
|
| 371 | 371 | }; |
| 372 | 372 | $i++; |
| 373 | 373 | }; |
| 374 | 374 | }; |
| 375 | - $prefix=freadbyte($f); |
|
| 376 | - $suffix=freadbyte($f); |
|
| 377 | - $pocetb+=2; |
|
| 378 | - if($echoit) echo "Prefix: $prefix Suffix: $suffix<BR>"; |
|
| 375 | + $prefix = freadbyte($f); |
|
| 376 | + $suffix = freadbyte($f); |
|
| 377 | + $pocetb += 2; |
|
| 378 | + if ($echoit) echo "Prefix: $prefix Suffix: $suffix<BR>"; |
|
| 379 | 379 | }; |
| 380 | 380 | |
| 381 | -for($x=0;$x<strlen($Data);$x++) |
|
| 381 | +for ($x = 0; $x < strlen($Data); $x++) |
|
| 382 | 382 | { |
| 383 | - imagesetpixel($img,$x,$y,$Palette[ord($Data[$x])]); |
|
| 383 | + imagesetpixel($img, $x, $y, $Palette[ord($Data[$x])]); |
|
| 384 | 384 | }; |
| 385 | -$Data=""; |
|
| 385 | +$Data = ""; |
|
| 386 | 386 | |
| 387 | 387 | }; |
| 388 | 388 | |
| 389 | 389 | }; |
| 390 | 390 | |
| 391 | 391 | |
| 392 | - if($biBitCount==24) |
|
| 392 | + if ($biBitCount == 24) |
|
| 393 | 393 | { |
| 394 | - $img=imagecreatetruecolor($Width,$Height); |
|
| 395 | - $Zbytek=$Width%4; |
|
| 394 | + $img = imagecreatetruecolor($Width, $Height); |
|
| 395 | + $Zbytek = $Width % 4; |
|
| 396 | 396 | |
| 397 | - for($y=$Height-1;$y>=0;$y--) |
|
| 397 | + for ($y = $Height - 1; $y >= 0; $y--) |
|
| 398 | 398 | { |
| 399 | - for($x=0;$x<$Width;$x++) |
|
| 399 | + for ($x = 0; $x < $Width; $x++) |
|
| 400 | 400 | { |
| 401 | - $B=freadbyte($f); |
|
| 402 | - $G=freadbyte($f); |
|
| 403 | - $R=freadbyte($f); |
|
| 404 | - $color=imagecolorexact($img,$R,$G,$B); |
|
| 405 | - if($color==-1) $color=imagecolorallocate($img,$R,$G,$B); |
|
| 406 | - imagesetpixel($img,$x,$y,$color); |
|
| 401 | + $B = freadbyte($f); |
|
| 402 | + $G = freadbyte($f); |
|
| 403 | + $R = freadbyte($f); |
|
| 404 | + $color = imagecolorexact($img, $R, $G, $B); |
|
| 405 | + if ($color == -1) $color = imagecolorallocate($img, $R, $G, $B); |
|
| 406 | + imagesetpixel($img, $x, $y, $color); |
|
| 407 | 407 | } |
| 408 | - for($z=0;$z<$Zbytek;$z++) |
|
| 408 | + for ($z = 0; $z < $Zbytek; $z++) |
|
| 409 | 409 | freadbyte($f); |
| 410 | 410 | }; |
| 411 | 411 | }; |
@@ -441,14 +441,14 @@ discard block |
||
| 441 | 441 | |
| 442 | 442 | function freadbyte($f) |
| 443 | 443 | { |
| 444 | - return ord(fread($f,1)); |
|
| 444 | + return ord(fread($f, 1)); |
|
| 445 | 445 | }; |
| 446 | 446 | |
| 447 | 447 | function freadword($f) |
| 448 | 448 | { |
| 449 | - $b1=freadbyte($f); |
|
| 450 | - $b2=freadbyte($f); |
|
| 451 | - return $b2*256+$b1; |
|
| 449 | + $b1 = freadbyte($f); |
|
| 450 | + $b2 = freadbyte($f); |
|
| 451 | + return $b2 * 256 + $b1; |
|
| 452 | 452 | }; |
| 453 | 453 | |
| 454 | 454 | |
@@ -459,9 +459,9 @@ discard block |
||
| 459 | 459 | |
| 460 | 460 | function freaddword($f) |
| 461 | 461 | { |
| 462 | - $b1=freadword($f); |
|
| 463 | - $b2=freadword($f); |
|
| 464 | - return $b2*65536+$b1; |
|
| 462 | + $b1 = freadword($f); |
|
| 463 | + $b2 = freadword($f); |
|
| 464 | + return $b2 * 65536 + $b1; |
|
| 465 | 465 | }; |
| 466 | 466 | |
| 467 | 467 | |
@@ -469,51 +469,51 @@ discard block |
||
| 469 | 469 | /** |
| 470 | 470 | * @param integer $byte |
| 471 | 471 | */ |
| 472 | -function RetBits($byte,$start,$len) |
|
| 472 | +function RetBits($byte, $start, $len) |
|
| 473 | 473 | { |
| 474 | -$bin=decbin8($byte); |
|
| 475 | -$r=bindec(substr($bin,$start,$len)); |
|
| 474 | +$bin = decbin8($byte); |
|
| 475 | +$r = bindec(substr($bin, $start, $len)); |
|
| 476 | 476 | return $r; |
| 477 | 477 | |
| 478 | 478 | }; |
| 479 | 479 | |
| 480 | 480 | |
| 481 | 481 | |
| 482 | -$CurrentBit=0; |
|
| 482 | +$CurrentBit = 0; |
|
| 483 | 483 | /** |
| 484 | 484 | * @param resource $f |
| 485 | 485 | * @param integer $count |
| 486 | 486 | */ |
| 487 | -function freadbits($f,$count) |
|
| 487 | +function freadbits($f, $count) |
|
| 488 | 488 | { |
| 489 | - global $CurrentBit,$SMode; |
|
| 490 | - $Byte=freadbyte($f); |
|
| 491 | - $LastCBit=$CurrentBit; |
|
| 492 | - $CurrentBit+=$count; |
|
| 493 | - if($CurrentBit==8) |
|
| 489 | + global $CurrentBit, $SMode; |
|
| 490 | + $Byte = freadbyte($f); |
|
| 491 | + $LastCBit = $CurrentBit; |
|
| 492 | + $CurrentBit += $count; |
|
| 493 | + if ($CurrentBit == 8) |
|
| 494 | 494 | { |
| 495 | - $CurrentBit=0; |
|
| 495 | + $CurrentBit = 0; |
|
| 496 | 496 | } |
| 497 | 497 | else |
| 498 | 498 | { |
| 499 | - fseek($f,ftell($f)-1); |
|
| 499 | + fseek($f, ftell($f) - 1); |
|
| 500 | 500 | }; |
| 501 | - return RetBits($Byte,$LastCBit,$count); |
|
| 501 | + return RetBits($Byte, $LastCBit, $count); |
|
| 502 | 502 | }; |
| 503 | 503 | |
| 504 | 504 | |
| 505 | 505 | |
| 506 | -function RGBToHex($Red,$Green,$Blue) |
|
| 506 | +function RGBToHex($Red, $Green, $Blue) |
|
| 507 | 507 | { |
| 508 | - $hRed=dechex($Red);if(strlen($hRed)==1) $hRed="0$hRed"; |
|
| 509 | - $hGreen=dechex($Green);if(strlen($hGreen)==1) $hGreen="0$hGreen"; |
|
| 510 | - $hBlue=dechex($Blue);if(strlen($hBlue)==1) $hBlue="0$hBlue"; |
|
| 511 | - return($hRed.$hGreen.$hBlue); |
|
| 508 | + $hRed = dechex($Red); if (strlen($hRed) == 1) $hRed = "0$hRed"; |
|
| 509 | + $hGreen = dechex($Green); if (strlen($hGreen) == 1) $hGreen = "0$hGreen"; |
|
| 510 | + $hBlue = dechex($Blue); if (strlen($hBlue) == 1) $hBlue = "0$hBlue"; |
|
| 511 | + return($hRed . $hGreen . $hBlue); |
|
| 512 | 512 | }; |
| 513 | 513 | |
| 514 | 514 | function int_to_dword($n) |
| 515 | 515 | { |
| 516 | - return chr($n & 255).chr(($n >> 8) & 255).chr(($n >> 16) & 255).chr(($n >> 24) & 255); |
|
| 516 | + return chr($n & 255) . chr(($n >> 8) & 255) . chr(($n >> 16) & 255) . chr(($n >> 24) & 255); |
|
| 517 | 517 | } |
| 518 | 518 | |
| 519 | 519 | /** |
@@ -521,24 +521,24 @@ discard block |
||
| 521 | 521 | */ |
| 522 | 522 | function int_to_word($n) |
| 523 | 523 | { |
| 524 | - return chr($n & 255).chr(($n >> 8) & 255); |
|
| 524 | + return chr($n & 255) . chr(($n >> 8) & 255); |
|
| 525 | 525 | } |
| 526 | 526 | |
| 527 | 527 | |
| 528 | 528 | function decbin8($d) |
| 529 | 529 | { |
| 530 | -return decbinx($d,8); |
|
| 530 | +return decbinx($d, 8); |
|
| 531 | 531 | }; |
| 532 | 532 | |
| 533 | 533 | /** |
| 534 | 534 | * @param integer $n |
| 535 | 535 | */ |
| 536 | -function decbinx($d,$n) |
|
| 536 | +function decbinx($d, $n) |
|
| 537 | 537 | { |
| 538 | -$bin=decbin($d); |
|
| 539 | -$sbin=strlen($bin); |
|
| 540 | -for($j=0;$j<$n-$sbin;$j++) |
|
| 541 | - $bin="0$bin"; |
|
| 538 | +$bin = decbin($d); |
|
| 539 | +$sbin = strlen($bin); |
|
| 540 | +for ($j = 0; $j < $n - $sbin; $j++) |
|
| 541 | + $bin = "0$bin"; |
|
| 542 | 542 | return $bin; |
| 543 | 543 | }; |
| 544 | 544 | |
@@ -17,7 +17,7 @@ discard block |
||
| 17 | 17 | public $main_template = 'sys_main'; |
| 18 | 18 | public $bench = null; |
| 19 | 19 | public $compile_id = null; |
| 20 | - public $cache_id = null; // This is a smarty caching ID, not a caches.cache_id. |
|
| 20 | + public $cache_id = null; // This is a smarty caching ID, not a caches.cache_id. |
|
| 21 | 21 | public $title = ''; |
| 22 | 22 | public $menuitem = null; |
| 23 | 23 | public $nowpsearch = false; |
@@ -385,7 +385,7 @@ discard block |
||
| 385 | 385 | |
| 386 | 386 | $args = func_get_args(); |
| 387 | 387 | unset($args[0]); |
| 388 | - for ($i = 1; isset($args[$i]); $i ++) { |
|
| 388 | + for ($i = 1; isset($args[$i]); $i++) { |
|
| 389 | 389 | $this->assign('p' . $i, $args[$i]); |
| 390 | 390 | } |
| 391 | 391 | |
@@ -188,7 +188,7 @@ discard block |
||
| 188 | 188 | $str = ''; |
| 189 | 189 | |
| 190 | 190 | ftsearch_load_ignores(); |
| 191 | - for ($i = count($astr) - 1; $i >= 0; $i --) { |
|
| 191 | + for ($i = count($astr) - 1; $i >= 0; $i--) { |
|
| 192 | 192 | // ignore? |
| 193 | 193 | if (array_search(mb_strtolower($astr[$i]), $ftsearch_ignores) !== false) { |
| 194 | 194 | unset($astr[$i]); |
@@ -237,7 +237,7 @@ discard block |
||
| 237 | 237 | } |
| 238 | 238 | |
| 239 | 239 | // doppelte chars ersetzen |
| 240 | - for ($c = ord('a'); $c <= ord('z'); $c ++) { |
|
| 240 | + for ($c = ord('a'); $c <= ord('z'); $c++) { |
|
| 241 | 241 | $old_str = ''; |
| 242 | 242 | while ($old_str != $str) { |
| 243 | 243 | $old_str = $str; |
@@ -485,6 +485,9 @@ |
||
| 485 | 485 | sql_free_result($rs); |
| 486 | 486 | } |
| 487 | 487 | |
| 488 | +/** |
|
| 489 | + * @param integer $object_type |
|
| 490 | + */ |
|
| 488 | 491 | function ftsearch_delete_entries($object_type, $object_id, $cache_id) |
| 489 | 492 | { |
| 490 | 493 | sql("DELETE FROM `search_index` WHERE `object_type`='&1' AND `cache_id`='&2'", $object_type, $cache_id); |
@@ -390,7 +390,7 @@ discard block |
||
| 390 | 390 | $thislog = mb_ereg_replace('{username}', text_xmlentities($rLog['username']), $thislog); |
| 391 | 391 | |
| 392 | 392 | if ($rLog['type'] == 3 && $rLog['needs_maintenance'] == 2) { |
| 393 | - $logtype = 'Needs Maintenance'; // with capital M, other than cache attribute |
|
| 393 | + $logtype = 'Needs Maintenance'; // with capital M, other than cache attribute |
|
| 394 | 394 | } elseif (isset($gpxLogType[$rLog['type']])) { |
| 395 | 395 | $logtype = $gpxLogType[$rLog['type']]; |
| 396 | 396 | } else { |
@@ -511,28 +511,28 @@ discard block |
||
| 511 | 511 | switch ($childWaypoint['type']) { |
| 512 | 512 | case 1: |
| 513 | 513 | $wp_typename = "Parking Area"; |
| 514 | - break; // well-known garmin symbols |
|
| 514 | + break; // well-known garmin symbols |
|
| 515 | 515 | case 2: |
| 516 | 516 | $wp_typename = "Flag, Green"; |
| 517 | - break; // stage / ref point |
|
| 517 | + break; // stage / ref point |
|
| 518 | 518 | case 3: |
| 519 | 519 | $wp_typename = "Flag, Blue"; |
| 520 | - break; // path |
|
| 520 | + break; // path |
|
| 521 | 521 | case 4: |
| 522 | 522 | $wp_typename = "Circle with X"; |
| 523 | 523 | break; // final |
| 524 | 524 | case 5: |
| 525 | 525 | $wp_typename = "Diamond, Green"; |
| 526 | - break; // point of interest |
|
| 526 | + break; // point of interest |
|
| 527 | 527 | default: |
| 528 | 528 | $wp_typename = "Flag, Blue"; |
| 529 | - break; // for the case new types are forgotten here .. |
|
| 529 | + break; // for the case new types are forgotten here .. |
|
| 530 | 530 | } |
| 531 | 531 | $thiswp = mb_ereg_replace('{type}', text_xmlentities($wp_typename), $thiswp); |
| 532 | 532 | $thiswp = mb_ereg_replace('{parent}', $r['waypoint'], $thiswp); |
| 533 | 533 | $thiswp = mb_ereg_replace('{cacheid}', $r['cacheid'], $thiswp); |
| 534 | 534 | $waypoints .= $thiswp; |
| 535 | - ++ $n; |
|
| 535 | + ++$n; |
|
| 536 | 536 | } |
| 537 | 537 | |
| 538 | 538 | if ($cacheNote && !empty($cacheNote['latitude']) && !empty($cacheNote['longitude'])) { |