@@ -32,7 +32,7 @@ |
||
| 32 | 32 | if (!isset($counter[$name])) { |
| 33 | 33 | $counter[$name] = 0; |
| 34 | 34 | } |
| 35 | - $counter[$name] ++; |
|
| 35 | + $counter[$name]++; |
|
| 36 | 36 | |
| 37 | 37 | if ($smarty->_cache_including) { |
| 38 | 38 | $param = isset($smarty->_cache_info['cached_vars'][$name][$counter[$name]]) ? $smarty->_cache_info['cached_vars'][$name][$counter[$name]] : []; |
@@ -80,7 +80,7 @@ |
||
| 80 | 80 | ]; |
| 81 | 81 | |
| 82 | 82 | $nTimestamp = time(); |
| 83 | - for ($nIndex = 0; $nIndex < count($seasons); $nIndex ++) { |
|
| 83 | + for ($nIndex = 0; $nIndex < count($seasons); $nIndex++) { |
|
| 84 | 84 | if (strtotime($seasons[$nIndex][0]) > $nTimestamp) { |
| 85 | 85 | return $params['winter']; |
| 86 | 86 | } //''; |
@@ -1011,7 +1011,7 @@ |
||
| 1011 | 1011 | } |
| 1012 | 1012 | $logs_restored = true; |
| 1013 | 1013 | } |
| 1014 | - // if it was not already restored by a later restore operation ... |
|
| 1014 | + // if it was not already restored by a later restore operation ... |
|
| 1015 | 1015 | } elseif (sql_value("SELECT `id` FROM `cache_logs` WHERE `id`='&1'", 0, $revert_logid) == 0) { |
| 1016 | 1016 | // id, uuid, date_created and last_modified are set automatically; |
| 1017 | 1017 | // picture will be updated automatically on picture-restore |
@@ -132,8 +132,8 @@ discard block |
||
| 132 | 132 | |
| 133 | 133 | */ |
| 134 | 134 | |
| 135 | -require __DIR__ . '/lib2/web.inc.php'; |
|
| 136 | -require_once __DIR__ . '/lib2/logic/labels.inc.php'; |
|
| 135 | +require __DIR__.'/lib2/web.inc.php'; |
|
| 136 | +require_once __DIR__.'/lib2/logic/labels.inc.php'; |
|
| 137 | 137 | |
| 138 | 138 | $tpl->name = 'restorecaches'; |
| 139 | 139 | $tpl->menuitem = MNU_ADMIN_RESTORE; |
@@ -308,12 +308,12 @@ discard block |
||
| 308 | 308 | |
| 309 | 309 | function get_archive_data($caches) |
| 310 | 310 | { |
| 311 | - $cachelist = "(" . implode(",", $caches) . ")"; |
|
| 311 | + $cachelist = "(".implode(",", $caches).")"; |
|
| 312 | 312 | $data = array(); |
| 313 | 313 | $admins = array(); |
| 314 | 314 | |
| 315 | 315 | // make waypoint index |
| 316 | - $rs = sql("SELECT `cache_id`, `wp_oc` FROM `caches` WHERE `cache_id` IN " . $cachelist); |
|
| 316 | + $rs = sql("SELECT `cache_id`, `wp_oc` FROM `caches` WHERE `cache_id` IN ".$cachelist); |
|
| 317 | 317 | while ($r = sql_fetch_assoc($rs)) { |
| 318 | 318 | $wp_oc[$r['cache_id']] = $r['wp_oc']; |
| 319 | 319 | } |
@@ -328,7 +328,7 @@ discard block |
||
| 328 | 328 | `latitude`, |
| 329 | 329 | `restored_by` |
| 330 | 330 | FROM `cache_coordinates` |
| 331 | - WHERE `cache_id` IN " . $cachelist . " |
|
| 331 | + WHERE `cache_id` IN " . $cachelist." |
|
| 332 | 332 | ORDER BY `date_created` ASC" |
| 333 | 333 | ); |
| 334 | 334 | // order is relevant, because multiple changes per day possible |
@@ -336,7 +336,7 @@ discard block |
||
| 336 | 336 | while ($r = sql_fetch_assoc($rs)) { |
| 337 | 337 | $coord = new coordinate($r['latitude'], $r['longitude']); |
| 338 | 338 | $coord = $coord->getDecimalMinutes(); |
| 339 | - $coord = $coord['lat'] . " " . $coord['lon']; |
|
| 339 | + $coord = $coord['lat']." ".$coord['lon']; |
|
| 340 | 340 | if (isset($lastcoord[$r['cache_id']]) && $coord != $lastcoord[$r['cache_id']]) { |
| 341 | 341 | // the database contains lots of old coord records with unchanged coords, wtf? |
| 342 | 342 | append_data($data, $admins, $wp_oc, $r, "coord", $lastcoord[$r['cache_id']], $coord); |
@@ -348,7 +348,7 @@ discard block |
||
| 348 | 348 | // cache country |
| 349 | 349 | $rs = sql("SELECT `cache_id`, LEFT(`date_created`,10) AS `date_modified`, `country`, `restored_by` |
| 350 | 350 | FROM `cache_countries` |
| 351 | - WHERE `cache_id` IN " . $cachelist . " |
|
| 351 | + WHERE `cache_id` IN " . $cachelist." |
|
| 352 | 352 | ORDER BY `date_created` ASC"); |
| 353 | 353 | // order is relevant, because multiple changes per day possible |
| 354 | 354 | $lastcountry = array(); |
@@ -364,17 +364,17 @@ discard block |
||
| 364 | 364 | // all other cache data |
| 365 | 365 | // first the current data ... |
| 366 | 366 | $nextcd = array(); |
| 367 | - $rs = sql("SELECT * FROM `caches` WHERE `cache_id` IN " . $cachelist); |
|
| 367 | + $rs = sql("SELECT * FROM `caches` WHERE `cache_id` IN ".$cachelist); |
|
| 368 | 368 | while ($r = sql_fetch_assoc($rs)) { |
| 369 | 369 | $nextcd[$r['wp_oc']] = $r; |
| 370 | - $user_id = $r['user_id']; // is used later for logs |
|
| 370 | + $user_id = $r['user_id']; // is used later for logs |
|
| 371 | 371 | } |
| 372 | 372 | sql_free_result($rs); |
| 373 | 373 | |
| 374 | 374 | // .. and then the changes |
| 375 | 375 | $rs = sql( |
| 376 | 376 | "SELECT * FROM `caches_modified` |
| 377 | - WHERE `cache_id` IN " . $cachelist . " |
|
| 377 | + WHERE `cache_id` IN " . $cachelist." |
|
| 378 | 378 | ORDER BY `date_modified` DESC" |
| 379 | 379 | ); |
| 380 | 380 | while ($r = sql_fetch_assoc($rs)) { |
@@ -417,8 +417,8 @@ discard block |
||
| 417 | 417 | $wp_oc, |
| 418 | 418 | $r, |
| 419 | 419 | "time", |
| 420 | - $r['search_time'] . ' h', |
|
| 421 | - $nextcd[$wp]['search_time'] . ' h' |
|
| 420 | + $r['search_time'].' h', |
|
| 421 | + $nextcd[$wp]['search_time'].' h' |
|
| 422 | 422 | ); |
| 423 | 423 | } |
| 424 | 424 | if ($r['way_length'] != $nextcd[$wp]['way_length']) { |
@@ -428,8 +428,8 @@ discard block |
||
| 428 | 428 | $wp_oc, |
| 429 | 429 | $r, |
| 430 | 430 | "way", |
| 431 | - $r['way_length'] . ' km', |
|
| 432 | - $nextcd[$wp]['way_length'] . ' km' |
|
| 431 | + $r['way_length'].' km', |
|
| 432 | + $nextcd[$wp]['way_length'].' km' |
|
| 433 | 433 | ); |
| 434 | 434 | } |
| 435 | 435 | if ($r['wp_gc'] != $nextcd[$wp]['wp_gc']) { |
@@ -465,9 +465,9 @@ discard block |
||
| 465 | 465 | // attributes |
| 466 | 466 | $rs = sql( |
| 467 | 467 | "SELECT * FROM `caches_attributes_modified` |
| 468 | - WHERE `cache_id` IN " . $cachelist . " /* OConly attrib is shown, but not restorable */ |
|
| 468 | + WHERE `cache_id` IN " . $cachelist." /* OConly attrib is shown, but not restorable */ |
|
| 469 | 469 | ORDER BY `date_modified` ASC" |
| 470 | - ); // order doesn't matter as long it is date only |
|
| 470 | + ); // order doesn't matter as long it is date only |
|
| 471 | 471 | while ($r = sql_fetch_assoc($rs)) { |
| 472 | 472 | append_data( |
| 473 | 473 | $data, |
@@ -475,7 +475,7 @@ discard block |
||
| 475 | 475 | $wp_oc, |
| 476 | 476 | $r, |
| 477 | 477 | "attrib", |
| 478 | - ($r['was_set'] ? "-" : "+") . labels::getLabelValue('cache_attrib', $r['attrib_id']), |
|
| 478 | + ($r['was_set'] ? "-" : "+").labels::getLabelValue('cache_attrib', $r['attrib_id']), |
|
| 479 | 479 | '' |
| 480 | 480 | ); |
| 481 | 481 | } |
@@ -513,7 +513,7 @@ discard block |
||
| 513 | 513 | LENGTH(`short_desc`) AS `sdl`, |
| 514 | 514 | `restored_by` |
| 515 | 515 | FROM `cache_desc_modified` |
| 516 | - WHERE `cache_id` IN " . $cachelist . " |
|
| 516 | + WHERE `cache_id` IN " . $cachelist." |
|
| 517 | 517 | ORDER BY `date_modified` DESC" |
| 518 | 518 | ); |
| 519 | 519 | // order doesn't matter as long only one change per day is recorded |
@@ -535,9 +535,9 @@ discard block |
||
| 535 | 535 | $admins, |
| 536 | 536 | $wp_oc, |
| 537 | 537 | $r, |
| 538 | - "desc(" . $r['language'] . ")", |
|
| 538 | + "desc(".$r['language'].")", |
|
| 539 | 539 | $r['dl'] + 0, |
| 540 | - ($next['dl'] + 0) . ' bytes' |
|
| 540 | + ($next['dl'] + 0).' bytes' |
|
| 541 | 541 | ); |
| 542 | 542 | } |
| 543 | 543 | if ($r['hl'] + 0 != $next['hl'] + 0) { |
@@ -546,9 +546,9 @@ discard block |
||
| 546 | 546 | $admins, |
| 547 | 547 | $wp_oc, |
| 548 | 548 | $r, |
| 549 | - "hint(" . $r['language'] . ")", |
|
| 549 | + "hint(".$r['language'].")", |
|
| 550 | 550 | $r['hl'] + 0, |
| 551 | - ($next['hl'] + 0) . ' bytes' |
|
| 551 | + ($next['hl'] + 0).' bytes' |
|
| 552 | 552 | ); |
| 553 | 553 | } |
| 554 | 554 | if ($r['sdl'] + 0 != $next['sdl'] + 0) { |
@@ -557,9 +557,9 @@ discard block |
||
| 557 | 557 | $admins, |
| 558 | 558 | $wp_oc, |
| 559 | 559 | $r, |
| 560 | - "shortdesc(" . $r['language'] . ")", |
|
| 560 | + "shortdesc(".$r['language'].")", |
|
| 561 | 561 | $r['sdl'] + 0, |
| 562 | - ($next['sdl'] + 0) . ' bytes' |
|
| 562 | + ($next['sdl'] + 0).' bytes' |
|
| 563 | 563 | ); |
| 564 | 564 | } |
| 565 | 565 | |
@@ -582,7 +582,7 @@ discard block |
||
| 582 | 582 | (SELECT 1 AS `op`, `deletion_date` AS `date_modified`, `cache_id`, |
| 583 | 583 | `user_id`, `type`, `date`, `restored_by` |
| 584 | 584 | FROM `cache_logs_archived` |
| 585 | - WHERE `cache_id` IN " . $cachelist . "AND `deleted_by`='&1' AND `user_id`<>'&1' |
|
| 585 | + WHERE `cache_id` IN " . $cachelist."AND `deleted_by`='&1' AND `user_id`<>'&1' |
|
| 586 | 586 | UNION |
| 587 | 587 | SELECT 2 AS `op`, `date_modified`, `cache_id`, |
| 588 | 588 | (SELECT `user_id` FROM `cache_logs_archived` WHERE `id`=`original_id`), |
@@ -590,7 +590,7 @@ discard block |
||
| 590 | 590 | (SELECT `date` FROM `cache_logs_archived` WHERE `id`=`original_id`), |
| 591 | 591 | `restored_by` |
| 592 | 592 | FROM `cache_logs_restored` |
| 593 | - WHERE `cache_id` IN " . $cachelist . ") `logs` |
|
| 593 | + WHERE `cache_id` IN " . $cachelist.") `logs` |
|
| 594 | 594 | INNER JOIN `user` ON `user`.`user_id`=`logs`.`user_id` |
| 595 | 595 | ORDER BY `logs`.`date_modified` ASC", |
| 596 | 596 | // order may not be exact when redoing reverts, because delete and insert |
@@ -604,7 +604,7 @@ discard block |
||
| 604 | 604 | $wp_oc, |
| 605 | 605 | $r, |
| 606 | 606 | $r["op"] == 1 ? "dellog" : "restorelog", |
| 607 | - "<a href='viewprofile.php?userid=" . $r['user_id'] . "' target='_blank'>" . $r['username'] . "</a>/" . $r['date'], |
|
| 607 | + "<a href='viewprofile.php?userid=".$r['user_id']."' target='_blank'>".$r['username']."</a>/".$r['date'], |
|
| 608 | 608 | '' |
| 609 | 609 | ); |
| 610 | 610 | } |
@@ -620,10 +620,10 @@ discard block |
||
| 620 | 620 | |
| 621 | 621 | $piccacheid = "IF(`object_type`=2, `object_id`, IF(`object_type`=1, IFNULL((SELECT `cache_id` FROM `cache_logs` WHERE `id`=`object_id`),(SELECT `cache_id` FROM `cache_logs_archived` WHERE `id`=`object_id`)), 0))"; |
| 622 | 622 | $rs = sql( |
| 623 | - "SELECT *, " . $piccacheid . "AS `cache_id` FROM `pictures_modified` |
|
| 624 | - WHERE " . $piccacheid . " IN " . $cachelist . " |
|
| 623 | + "SELECT *, ".$piccacheid."AS `cache_id` FROM `pictures_modified` |
|
| 624 | + WHERE " . $piccacheid." IN ".$cachelist." |
|
| 625 | 625 | ORDER BY `date_modified` ASC" |
| 626 | - ); // order is relevant for the case of restore-reverts |
|
| 626 | + ); // order is relevant for the case of restore-reverts |
|
| 627 | 627 | while ($r = sql_fetch_assoc($rs)) { |
| 628 | 628 | $r['date_modified'] = substr($r['date_modified'], 0, 10); |
| 629 | 629 | switch ($r['operation']) { |
@@ -645,14 +645,14 @@ discard block |
||
| 645 | 645 | $picchange .= "-cache"; |
| 646 | 646 | break; |
| 647 | 647 | } |
| 648 | - append_data($data, $admins, $wp_oc, $r, $picchange . "pic", $r['title'], ''); |
|
| 648 | + append_data($data, $admins, $wp_oc, $r, $picchange."pic", $r['title'], ''); |
|
| 649 | 649 | } |
| 650 | 650 | sql_free_result($rs); |
| 651 | 651 | |
| 652 | 652 | // admins |
| 653 | 653 | foreach ($admins as $adate => $adata) { |
| 654 | 654 | foreach ($adata as $awp => $alist) { |
| 655 | - $data[$adate][$awp] .= "<br /><strong class='adminrestore'>admins:</strong> " . implode(',', $alist); |
|
| 655 | + $data[$adate][$awp] .= "<br /><strong class='adminrestore'>admins:</strong> ".implode(',', $alist); |
|
| 656 | 656 | } |
| 657 | 657 | } |
| 658 | 658 | |
@@ -701,9 +701,9 @@ discard block |
||
| 701 | 701 | } else { |
| 702 | 702 | $text .= " class='userchange'"; |
| 703 | 703 | } |
| 704 | - $text .= ">$field</strong>: $oldvalue" . ($newvalue != "" ? " → $newvalue" : ""); |
|
| 704 | + $text .= ">$field</strong>: $oldvalue".($newvalue != "" ? " → $newvalue" : ""); |
|
| 705 | 705 | if (isset($data[$mdate][$wp])) { |
| 706 | - $data[$mdate][$wp] .= ", " . $text; |
|
| 706 | + $data[$mdate][$wp] .= ", ".$text; |
|
| 707 | 707 | } else { |
| 708 | 708 | $data[$mdate][$wp] = $text; |
| 709 | 709 | } |
@@ -716,8 +716,8 @@ discard block |
||
| 716 | 716 | $admins[$mdate][$wp] = []; |
| 717 | 717 | } |
| 718 | 718 | $admins[$mdate][$wp][$r['restored_by'] + 0] |
| 719 | - = "<a href='viewprofile.php?userid=" . $r['restored_by'] . "' target='_blank'>" . |
|
| 720 | - sql_value("SELECT `username` FROM `user` WHERE `user_id`='&1'", "", $r['restored_by']) . |
|
| 719 | + = "<a href='viewprofile.php?userid=".$r['restored_by']."' target='_blank'>". |
|
| 720 | + sql_value("SELECT `username` FROM `user` WHERE `user_id`='&1'", "", $r['restored_by']). |
|
| 721 | 721 | "</a>"; |
| 722 | 722 | } |
| 723 | 723 | } |
@@ -727,7 +727,7 @@ discard block |
||
| 727 | 727 | { |
| 728 | 728 | global $opt, $login; |
| 729 | 729 | |
| 730 | - sql("SET @restoredby='&1'", $login->userid); // is evaluated by trigger functions |
|
| 730 | + sql("SET @restoredby='&1'", $login->userid); // is evaluated by trigger functions |
|
| 731 | 731 | sql_slave("SET @restoredby='&1'", $login->userid); |
| 732 | 732 | |
| 733 | 733 | $restored = array(); |
@@ -837,12 +837,12 @@ discard block |
||
| 837 | 837 | if ($setfields != "") { |
| 838 | 838 | $setfields .= ","; |
| 839 | 839 | } |
| 840 | - $setfields .= "`$field`='" . sql_escape($r[$field]) . "'"; |
|
| 840 | + $setfields .= "`$field`='".sql_escape($r[$field])."'"; |
|
| 841 | 841 | $restored[$wp][$field] = true; |
| 842 | 842 | } |
| 843 | 843 | } |
| 844 | 844 | if ($setfields != "" && !$simulate) { |
| 845 | - sql("UPDATE `caches` SET " . $setfields . " WHERE `cache_id`='&1'", $cacheid); |
|
| 845 | + sql("UPDATE `caches` SET ".$setfields." WHERE `cache_id`='&1'", $cacheid); |
|
| 846 | 846 | } |
| 847 | 847 | } |
| 848 | 848 | sql_free_result($rs); |
@@ -1019,7 +1019,7 @@ discard block |
||
| 1019 | 1019 | // id, uuid, date_created and last_modified are set automatically; |
| 1020 | 1020 | // picture will be updated automatically on picture-restore |
| 1021 | 1021 | $log = new cachelog(); |
| 1022 | - $log->setNode($r['node']); // cachelog class currently does not initialize node field |
|
| 1022 | + $log->setNode($r['node']); // cachelog class currently does not initialize node field |
|
| 1023 | 1023 | $log->setCacheId($r['cache_id']); |
| 1024 | 1024 | $log->setUserId($r['user_id']); |
| 1025 | 1025 | $log->setType($r['type'], true); |
@@ -1071,7 +1071,7 @@ discard block |
||
| 1071 | 1071 | } // not already processed |
| 1072 | 1072 | |
| 1073 | 1073 | if ($error != "") { |
| 1074 | - $restored[$wp]['internal error - could not $error log ' + $r['id'] + "/" + $logid]; |
|
| 1074 | + $restored[$wp]['internal error - could not $error log ' +$r['id'] + "/" +$logid]; |
|
| 1075 | 1075 | } |
| 1076 | 1076 | if ($logs_restored) { |
| 1077 | 1077 | $restored[$wp]['logs'] = true; |
@@ -1203,7 +1203,7 @@ discard block |
||
| 1203 | 1203 | } // not already processed |
| 1204 | 1204 | |
| 1205 | 1205 | if ($error != "") { |
| 1206 | - $restored[$wp]['internal error - could not $error picture ' . $r['id'] + "/" + $picid] = true; |
|
| 1206 | + $restored[$wp]['internal error - could not $error picture '.$r['id'] + "/" +$picid] = true; |
|
| 1207 | 1207 | } |
| 1208 | 1208 | if ($pics_restored) { |
| 1209 | 1209 | $restored[$wp]['pictures'] = true; |
@@ -33,7 +33,7 @@ discard block |
||
| 33 | 33 | 'DATA_LICENSE_URL' => $opt['page']['absolute_url'] . $opt['logic']['license']['terms'], |
| 34 | 34 | 'DEBUG' => ($opt['debug'] & DEBUG_DEVELOPER != 0), |
| 35 | 35 | 'DEBUG_PREVENT_SEMAPHORES' |
| 36 | - => !$opt['php']['semaphores'], # not available on old developer system |
|
| 36 | + => !$opt['php']['semaphores'], # not available on old developer system |
|
| 37 | 37 | 'DB_SERVER' => $opt['db']['servername'], |
| 38 | 38 | 'DB_NAME' => $opt['db']['placeholder']['db'], |
| 39 | 39 | 'DB_USERNAME' => $opt['db']['username'], |
@@ -54,7 +54,7 @@ discard block |
||
| 54 | 54 | 'OC_NODE_ID' => $opt['logic']['node']['id'], |
| 55 | 55 | 'OC_COOKIE_NAME' => $opt['session']['cookiename'] . 'data', |
| 56 | 56 | 'OCDE_HTML_PURIFIER_SETTINGS' |
| 57 | - => $opt['html_purifier'], |
|
| 57 | + => $opt['html_purifier'], |
|
| 58 | 58 | 'GITHUB_ACCESS_TOKEN' => $opt['okapi']['github_access_token'], |
| 59 | 59 | ); |
| 60 | 60 | } |
@@ -16,24 +16,24 @@ discard block |
||
| 16 | 16 | # [3] http://code.google.com/p/opencaching-api/issues/detail?id=132 |
| 17 | 17 | |
| 18 | 18 | $opt['rootpath'] = $GLOBALS['rootpath']; |
| 19 | - require $opt['rootpath'] . 'lib2/const.inc.php'; # (into the *local* scope!) |
|
| 20 | - require $opt['rootpath'] . 'config2/settings-dist.inc.php'; |
|
| 21 | - require $opt['rootpath'] . 'config2/settings.inc.php'; |
|
| 19 | + require $opt['rootpath'].'lib2/const.inc.php'; # (into the *local* scope!) |
|
| 20 | + require $opt['rootpath'].'config2/settings-dist.inc.php'; |
|
| 21 | + require $opt['rootpath'].'config2/settings.inc.php'; |
|
| 22 | 22 | |
| 23 | 23 | return array( |
| 24 | 24 | |
| 25 | 25 | # Settings which ARE NOT present in settings.inc.php: |
| 26 | 26 | |
| 27 | - 'OC_BRANCH' => 'oc.de', # Tell OKAPI to work in "OCDE mode". |
|
| 27 | + 'OC_BRANCH' => 'oc.de', # Tell OKAPI to work in "OCDE mode". |
|
| 28 | 28 | |
| 29 | 29 | # Settings which ARE present in settings.inc.php: |
| 30 | 30 | |
| 31 | 31 | 'ADMINS' => array($opt['db']['warn']['mail'], '[email protected]'), |
| 32 | 32 | 'FROM_FIELD' => $opt['mail']['contact'], |
| 33 | - 'DATA_LICENSE_URL' => $opt['page']['absolute_url'] . $opt['logic']['license']['terms'], |
|
| 33 | + 'DATA_LICENSE_URL' => $opt['page']['absolute_url'].$opt['logic']['license']['terms'], |
|
| 34 | 34 | 'DEBUG' => ($opt['debug'] & DEBUG_DEVELOPER != 0), |
| 35 | 35 | 'DEBUG_PREVENT_SEMAPHORES' |
| 36 | - => !$opt['php']['semaphores'], # not available on old developer system |
|
| 36 | + => !$opt['php']['semaphores'], # not available on old developer system |
|
| 37 | 37 | 'DB_SERVER' => $opt['db']['servername'], |
| 38 | 38 | 'DB_NAME' => $opt['db']['placeholder']['db'], |
| 39 | 39 | 'DB_USERNAME' => $opt['db']['username'], |
@@ -43,16 +43,16 @@ discard block |
||
| 43 | 43 | 'TIMEZONE' => $opt['php']['timezone'], |
| 44 | 44 | 'SITE_URL' => $opt['page']['absolute_url'], |
| 45 | 45 | 'REGISTRATION_URL' => $opt['page']['https']['mode'] != HTTPS_DISABLED |
| 46 | - ? 'https://' . $opt['page']['domain'] . '/register.php' |
|
| 47 | - : $opt['page']['absolute_url'] . 'register.php', |
|
| 46 | + ? 'https://'.$opt['page']['domain'].'/register.php' |
|
| 47 | + : $opt['page']['absolute_url'].'register.php', |
|
| 48 | 48 | 'VAR_DIR' => $opt['okapi']['var_dir'], |
| 49 | 49 | 'IMAGES_DIR' => rtrim($opt['logic']['pictures']['dir'], '/'), |
| 50 | 50 | 'IMAGES_URL' => rtrim($opt['logic']['pictures']['url'], '/').'/', |
| 51 | 51 | 'IMAGE_MAX_UPLOAD_SIZE' => 2 * $opt['logic']['pictures']['maxsize'], |
| 52 | - 'IMAGE_MAX_PIXEL_COUNT' => 786432, # 1024 x 768; TODO: move PICTURE_MAX_LONG_SIDE to settings |
|
| 53 | - 'SITE_LOGO' => $opt['page']['absolute_url'] . 'resource2/' . $opt['template']['default']['style'] . '/images/oclogo/oc_logo_alpha3.png', |
|
| 52 | + 'IMAGE_MAX_PIXEL_COUNT' => 786432, # 1024 x 768; TODO: move PICTURE_MAX_LONG_SIDE to settings |
|
| 53 | + 'SITE_LOGO' => $opt['page']['absolute_url'].'resource2/'.$opt['template']['default']['style'].'/images/oclogo/oc_logo_alpha3.png', |
|
| 54 | 54 | 'OC_NODE_ID' => $opt['logic']['node']['id'], |
| 55 | - 'OC_COOKIE_NAME' => $opt['session']['cookiename'] . 'data', |
|
| 55 | + 'OC_COOKIE_NAME' => $opt['session']['cookiename'].'data', |
|
| 56 | 56 | 'OCDE_HTML_PURIFIER_SETTINGS' |
| 57 | 57 | => $opt['html_purifier'], |
| 58 | 58 | 'GITHUB_ACCESS_TOKEN' => $opt['okapi']['github_access_token'], |
@@ -30,7 +30,7 @@ |
||
| 30 | 30 | global $login; |
| 31 | 31 | |
| 32 | 32 | $fields = |
| 33 | - "`pics`.`uuid` AS `pic_uuid`, |
|
| 33 | + "`pics`.`uuid` AS `pic_uuid`, |
|
| 34 | 34 | `pics`.`url` AS `pic_url`, |
| 35 | 35 | `pics`.`title`, |
| 36 | 36 | `pics`.`date_created`, |
@@ -17,12 +17,12 @@ discard block |
||
| 17 | 17 | const FOR_STARTPAGE_GALLERY = 1; |
| 18 | 18 | const FOR_NEWPICS_GALLERY = 2; |
| 19 | 19 | const FOR_USER_STAT = 3; |
| 20 | - const FOR_USER_GALLERY = 4; // params: userid |
|
| 20 | + const FOR_USER_GALLERY = 4; // params: userid |
|
| 21 | 21 | const FOR_MYHOME_GALLERY = 5; |
| 22 | - const FOR_CACHE_STAT = 6; // params: cacheid |
|
| 23 | - const FOR_CACHE_GALLERY = 7; // params: cacheid |
|
| 22 | + const FOR_CACHE_STAT = 6; // params: cacheid |
|
| 23 | + const FOR_CACHE_GALLERY = 7; // params: cacheid |
|
| 24 | 24 | |
| 25 | - const MAX_PICTURES_PER_GALLERY_PAGE = 48; // must be multiple of 6 |
|
| 25 | + const MAX_PICTURES_PER_GALLERY_PAGE = 48; // must be multiple of 6 |
|
| 26 | 26 | |
| 27 | 27 | |
| 28 | 28 | public static function get($purpose, $userid = 0, $cacheid = 0) |
@@ -232,7 +232,7 @@ discard block |
||
| 232 | 232 | $pictures = self::get($purpose, $userid, $cacheid); |
| 233 | 233 | $tpl->assign('pictures', array_slice($pictures, $startat, self::MAX_PICTURES_PER_GALLERY_PAGE)); |
| 234 | 234 | |
| 235 | - $pager = new pager($url . "&startat={offset}"); |
|
| 235 | + $pager = new pager($url."&startat={offset}"); |
|
| 236 | 236 | $pager->make_from_offset($startat, count($pictures), self::MAX_PICTURES_PER_GALLERY_PAGE); |
| 237 | 237 | } |
| 238 | 238 | |
@@ -29,7 +29,7 @@ discard block |
||
| 29 | 29 | // number of points in the polygon |
| 30 | 30 | $n = count($polygon); |
| 31 | 31 | $poly1 = $polygon[0]; |
| 32 | - for ($i = 1; $i <= $n; $i ++) { |
|
| 32 | + for ($i = 1; $i <= $n; $i++) { |
|
| 33 | 33 | $poly1XY = explode(' ', $poly1); |
| 34 | 34 | $poly1x = $poly1XY[0]; |
| 35 | 35 | $poly1y = $poly1XY[1]; |
@@ -44,7 +44,7 @@ discard block |
||
| 44 | 44 | if ($poly1y != $poly2y) { |
| 45 | 45 | $xinters = ($py - $poly1y) * ($poly2x - $poly1x) / ($poly2y - $poly1y) + $poly1x; |
| 46 | 46 | if ($poly1x == $poly2x || $px <= $xinters) { |
| 47 | - $counter ++; |
|
| 47 | + $counter++; |
|
| 48 | 48 | } |
| 49 | 49 | } |
| 50 | 50 | } |
@@ -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 | |
@@ -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 | |
@@ -26,164 +26,164 @@ discard block |
||
| 26 | 26 | * Returns: if $file specified - true if OK |
| 27 | 27 | if $file not specified - image data |
| 28 | 28 | */ |
| 29 | -function imagebmp($img,$file="",$RLE=0) |
|
| 29 | +function imagebmp($img, $file = "", $RLE = 0) |
|
| 30 | 30 | { |
| 31 | 31 | |
| 32 | 32 | |
| 33 | -$ColorCount=imagecolorstotal($img); |
|
| 33 | +$ColorCount = imagecolorstotal($img); |
|
| 34 | 34 | |
| 35 | -$Transparent=imagecolortransparent($img); |
|
| 36 | -$IsTransparent=$Transparent!=-1; |
|
| 35 | +$Transparent = imagecolortransparent($img); |
|
| 36 | +$IsTransparent = $Transparent != -1; |
|
| 37 | 37 | |
| 38 | 38 | |
| 39 | -if($IsTransparent) $ColorCount--; |
|
| 39 | +if ($IsTransparent) $ColorCount--; |
|
| 40 | 40 | |
| 41 | -if($ColorCount==0) {$ColorCount=0; $BitCount=24;}; |
|
| 42 | -if(($ColorCount>0)and($ColorCount<=2)) {$ColorCount=2; $BitCount=1;}; |
|
| 43 | -if(($ColorCount>2)and($ColorCount<=16)) { $ColorCount=16; $BitCount=4;}; |
|
| 44 | -if(($ColorCount>16)and($ColorCount<=256)) { $ColorCount=0; $BitCount=8;}; |
|
| 41 | +if ($ColorCount == 0) {$ColorCount = 0; $BitCount = 24; }; |
|
| 42 | +if (($ColorCount > 0) and ($ColorCount <= 2)) {$ColorCount = 2; $BitCount = 1; }; |
|
| 43 | +if (($ColorCount > 2) and ($ColorCount <= 16)) { $ColorCount = 16; $BitCount = 4; }; |
|
| 44 | +if (($ColorCount > 16) and ($ColorCount <= 256)) { $ColorCount = 0; $BitCount = 8; }; |
|
| 45 | 45 | |
| 46 | 46 | |
| 47 | - $Width=imagesx($img); |
|
| 48 | - $Height=imagesy($img); |
|
| 47 | + $Width = imagesx($img); |
|
| 48 | + $Height = imagesy($img); |
|
| 49 | 49 | |
| 50 | - $Zbytek=(4-($Width/(8/$BitCount))%4)%4; |
|
| 50 | + $Zbytek = (4 - ($Width / (8 / $BitCount)) % 4) % 4; |
|
| 51 | 51 | |
| 52 | - if($BitCount<24) $palsize=pow(2,$BitCount)*4; |
|
| 52 | + if ($BitCount < 24) $palsize = pow(2, $BitCount) * 4; |
|
| 53 | 53 | |
| 54 | - $size=(floor($Width/(8/$BitCount))+$Zbytek)*$Height+54; |
|
| 55 | - $size+=$palsize; |
|
| 56 | - $offset=54+$palsize; |
|
| 54 | + $size = (floor($Width / (8 / $BitCount)) + $Zbytek) * $Height + 54; |
|
| 55 | + $size += $palsize; |
|
| 56 | + $offset = 54 + $palsize; |
|
| 57 | 57 | |
| 58 | 58 | // Bitmap File Header |
| 59 | - $ret = 'BM'; // header (2b) |
|
| 60 | - $ret .= int_to_dword($size); // size of file (4b) |
|
| 61 | - $ret .= int_to_dword(0); // reserved (4b) |
|
| 62 | - $ret .= int_to_dword($offset); // byte location in the file which is first byte of IMAGE (4b) |
|
| 59 | + $ret = 'BM'; // header (2b) |
|
| 60 | + $ret .= int_to_dword($size); // size of file (4b) |
|
| 61 | + $ret .= int_to_dword(0); // reserved (4b) |
|
| 62 | + $ret .= int_to_dword($offset); // byte location in the file which is first byte of IMAGE (4b) |
|
| 63 | 63 | // Bitmap Info Header |
| 64 | - $ret .= int_to_dword(40); // Size of BITMAPINFOHEADER (4b) |
|
| 65 | - $ret .= int_to_dword($Width); // width of bitmap (4b) |
|
| 66 | - $ret .= int_to_dword($Height); // height of bitmap (4b) |
|
| 67 | - $ret .= int_to_word(1); // biPlanes = 1 (2b) |
|
| 68 | - $ret .= int_to_word($BitCount); // biBitCount = {1 (mono) or 4 (16 clr ) or 8 (256 clr) or 24 (16 Mil)} (2b) |
|
| 69 | - $ret .= int_to_dword($RLE); // RLE COMPRESSION (4b) |
|
| 70 | - $ret .= int_to_dword(0); // width x height (4b) |
|
| 71 | - $ret .= int_to_dword(0); // biXPelsPerMeter (4b) |
|
| 72 | - $ret .= int_to_dword(0); // biYPelsPerMeter (4b) |
|
| 73 | - $ret .= int_to_dword(0); // Number of palettes used (4b) |
|
| 74 | - $ret .= int_to_dword(0); // Number of important colour (4b) |
|
| 64 | + $ret .= int_to_dword(40); // Size of BITMAPINFOHEADER (4b) |
|
| 65 | + $ret .= int_to_dword($Width); // width of bitmap (4b) |
|
| 66 | + $ret .= int_to_dword($Height); // height of bitmap (4b) |
|
| 67 | + $ret .= int_to_word(1); // biPlanes = 1 (2b) |
|
| 68 | + $ret .= int_to_word($BitCount); // biBitCount = {1 (mono) or 4 (16 clr ) or 8 (256 clr) or 24 (16 Mil)} (2b) |
|
| 69 | + $ret .= int_to_dword($RLE); // RLE COMPRESSION (4b) |
|
| 70 | + $ret .= int_to_dword(0); // width x height (4b) |
|
| 71 | + $ret .= int_to_dword(0); // biXPelsPerMeter (4b) |
|
| 72 | + $ret .= int_to_dword(0); // biYPelsPerMeter (4b) |
|
| 73 | + $ret .= int_to_dword(0); // Number of palettes used (4b) |
|
| 74 | + $ret .= int_to_dword(0); // Number of important colour (4b) |
|
| 75 | 75 | // image data |
| 76 | 76 | |
| 77 | - $CC=$ColorCount; |
|
| 78 | - $sl1=strlen($ret); |
|
| 79 | - if($CC==0) $CC=256; |
|
| 80 | - if($BitCount<24) |
|
| 77 | + $CC = $ColorCount; |
|
| 78 | + $sl1 = strlen($ret); |
|
| 79 | + if ($CC == 0) $CC = 256; |
|
| 80 | + if ($BitCount < 24) |
|
| 81 | 81 | { |
| 82 | - $ColorTotal=imagecolorstotal($img); |
|
| 83 | - if($IsTransparent) $ColorTotal--; |
|
| 82 | + $ColorTotal = imagecolorstotal($img); |
|
| 83 | + if ($IsTransparent) $ColorTotal--; |
|
| 84 | 84 | |
| 85 | - for($p=0;$p<$ColorTotal;$p++) |
|
| 85 | + for ($p = 0; $p < $ColorTotal; $p++) |
|
| 86 | 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 |
|
| 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 | 92 | }; |
| 93 | 93 | |
| 94 | - $CT=$ColorTotal; |
|
| 95 | - for($p=$ColorTotal;$p<$CC;$p++) |
|
| 94 | + $CT = $ColorTotal; |
|
| 95 | + for ($p = $ColorTotal; $p < $CC; $p++) |
|
| 96 | 96 | { |
| 97 | - $ret.=inttobyte(0); |
|
| 98 | - $ret.=inttobyte(0); |
|
| 99 | - $ret.=inttobyte(0); |
|
| 100 | - $ret.=inttobyte(0); //RESERVED |
|
| 97 | + $ret .= inttobyte(0); |
|
| 98 | + $ret .= inttobyte(0); |
|
| 99 | + $ret .= inttobyte(0); |
|
| 100 | + $ret .= inttobyte(0); //RESERVED |
|
| 101 | 101 | }; |
| 102 | 102 | }; |
| 103 | 103 | |
| 104 | 104 | |
| 105 | -if($BitCount<=8) |
|
| 105 | +if ($BitCount <= 8) |
|
| 106 | 106 | { |
| 107 | 107 | |
| 108 | - for($y=$Height-1;$y>=0;$y--) |
|
| 108 | + for ($y = $Height - 1; $y >= 0; $y--) |
|
| 109 | 109 | { |
| 110 | - $bWrite=""; |
|
| 111 | - for($x=0;$x<$Width;$x++) |
|
| 110 | + $bWrite = ""; |
|
| 111 | + for ($x = 0; $x < $Width; $x++) |
|
| 112 | 112 | { |
| 113 | - $color=imagecolorat($img,$x,$y); |
|
| 114 | - $bWrite.=decbinx($color,$BitCount); |
|
| 115 | - if(strlen($bWrite)==8) |
|
| 113 | + $color = imagecolorat($img, $x, $y); |
|
| 114 | + $bWrite .= decbinx($color, $BitCount); |
|
| 115 | + if (strlen($bWrite) == 8) |
|
| 116 | 116 | { |
| 117 | - $retd.=inttobyte(bindec($bWrite)); |
|
| 118 | - $bWrite=""; |
|
| 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 | 128 | }; |
| 129 | - for($z=0;$z<$Zbytek;$z++) |
|
| 130 | - $retd.=inttobyte(0); |
|
| 129 | + for ($z = 0; $z < $Zbytek; $z++) |
|
| 130 | + $retd .= inttobyte(0); |
|
| 131 | 131 | }; |
| 132 | 132 | }; |
| 133 | 133 | |
| 134 | -if(($RLE==1)and($BitCount==8)) |
|
| 134 | +if (($RLE == 1) and ($BitCount == 8)) |
|
| 135 | 135 | { |
| 136 | - for($t=0;$t<strlen($retd);$t+=4) |
|
| 136 | + for ($t = 0; $t < strlen($retd); $t += 4) |
|
| 137 | 137 | { |
| 138 | - if($t!=0) |
|
| 139 | - if(($t)%$Width==0) |
|
| 140 | - $ret.=chr(0).chr(0); |
|
| 138 | + if ($t != 0) |
|
| 139 | + if (($t) % $Width == 0) |
|
| 140 | + $ret .= chr(0).chr(0); |
|
| 141 | 141 | |
| 142 | - if(($t+5)%$Width==0) |
|
| 142 | + if (($t + 5) % $Width == 0) |
|
| 143 | 143 | { |
| 144 | - $ret.=chr(0).chr(5).substr($retd,$t,5).chr(0); |
|
| 145 | - $t+=1; |
|
| 144 | + $ret .= chr(0).chr(5).substr($retd, $t, 5).chr(0); |
|
| 145 | + $t += 1; |
|
| 146 | 146 | } |
| 147 | - if(($t+6)%$Width==0) |
|
| 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 | { |
| 161 | -$ret.=$retd; |
|
| 161 | +$ret .= $retd; |
|
| 162 | 162 | }; |
| 163 | 163 | |
| 164 | 164 | |
| 165 | - if($BitCount==24) |
|
| 165 | + if ($BitCount == 24) |
|
| 166 | 166 | { |
| 167 | - for($z=0;$z<$Zbytek;$z++) |
|
| 168 | - $Dopl.=chr(0); |
|
| 167 | + for ($z = 0; $z < $Zbytek; $z++) |
|
| 168 | + $Dopl .= chr(0); |
|
| 169 | 169 | |
| 170 | - for($y=$Height-1;$y>=0;$y--) |
|
| 170 | + for ($y = $Height - 1; $y >= 0; $y--) |
|
| 171 | 171 | { |
| 172 | - for($x=0;$x<$Width;$x++) |
|
| 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; |
|
| 177 | + $ret .= $Dopl; |
|
| 178 | 178 | }; |
| 179 | 179 | |
| 180 | 180 | }; |
| 181 | 181 | |
| 182 | - if($file!="") |
|
| 182 | + if ($file != "") |
|
| 183 | 183 | { |
| 184 | - $r=($f=fopen($file,"w")); |
|
| 185 | - $r=$r and fwrite($f,$ret); |
|
| 186 | - $r=$r and fclose($f); |
|
| 184 | + $r = ($f = fopen($file, "w")); |
|
| 185 | + $r = $r and fwrite($f, $ret); |
|
| 186 | + $r = $r and fclose($f); |
|
| 187 | 187 | return $r; |
| 188 | 188 | } |
| 189 | 189 | else |
@@ -208,58 +208,58 @@ discard block |
||
| 208 | 208 | { |
| 209 | 209 | global $CurrentBit, $echoMode; |
| 210 | 210 | |
| 211 | -$f=fopen($file,"r"); |
|
| 212 | -$Header=fread($f,2); |
|
| 211 | +$f = fopen($file, "r"); |
|
| 212 | +$Header = fread($f, 2); |
|
| 213 | 213 | |
| 214 | -if($Header=="BM") |
|
| 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); |
|
| 232 | - |
|
| 233 | -if($biBitCount<24) |
|
| 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 | + |
|
| 233 | +if ($biBitCount < 24) |
|
| 234 | 234 | { |
| 235 | - $img=imagecreate($Width,$Height); |
|
| 236 | - $Colors=pow(2,$biBitCount); |
|
| 237 | - for($p=0;$p<$Colors;$p++) |
|
| 235 | + $img = imagecreate($Width, $Height); |
|
| 236 | + $Colors = pow(2, $biBitCount); |
|
| 237 | + for ($p = 0; $p < $Colors; $p++) |
|
| 238 | 238 | { |
| 239 | - $B=freadbyte($f); |
|
| 240 | - $G=freadbyte($f); |
|
| 241 | - $R=freadbyte($f); |
|
| 242 | - $Reserved=freadbyte($f); |
|
| 243 | - $Palette[]=imagecolorallocate($img,$R,$G,$B); |
|
| 239 | + $B = freadbyte($f); |
|
| 240 | + $G = freadbyte($f); |
|
| 241 | + $R = freadbyte($f); |
|
| 242 | + $Reserved = freadbyte($f); |
|
| 243 | + $Palette[] = imagecolorallocate($img, $R, $G, $B); |
|
| 244 | 244 | }; |
| 245 | 245 | |
| 246 | 246 | |
| 247 | 247 | |
| 248 | 248 | |
| 249 | -if($RLECompression==0) |
|
| 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 | -for($y=$Height-1;$y>=0;$y--) |
|
| 253 | +for ($y = $Height - 1; $y >= 0; $y--) |
|
| 254 | 254 | { |
| 255 | - $CurrentBit=0; |
|
| 256 | - for($x=0;$x<$Width;$x++) |
|
| 255 | + $CurrentBit = 0; |
|
| 256 | + for ($x = 0; $x < $Width; $x++) |
|
| 257 | 257 | { |
| 258 | - $C=freadbits($f,$biBitCount); |
|
| 259 | - imagesetpixel($img,$x,$y,$Palette[$C]); |
|
| 258 | + $C = freadbits($f, $biBitCount); |
|
| 259 | + imagesetpixel($img, $x, $y, $Palette[$C]); |
|
| 260 | 260 | }; |
| 261 | - if($CurrentBit!=0) {freadbyte($f);}; |
|
| 262 | - for($g=0;$g<$Zbytek;$g++) |
|
| 261 | + if ($CurrentBit != 0) {freadbyte($f); }; |
|
| 262 | + for ($g = 0; $g < $Zbytek; $g++) |
|
| 263 | 263 | freadbyte($f); |
| 264 | 264 | }; |
| 265 | 265 | |
@@ -267,142 +267,142 @@ discard block |
||
| 267 | 267 | }; |
| 268 | 268 | |
| 269 | 269 | |
| 270 | -if($RLECompression==1) //$BI_RLE8 |
|
| 270 | +if ($RLECompression == 1) //$BI_RLE8 |
|
| 271 | 271 | { |
| 272 | -$y=$Height; |
|
| 272 | +$y = $Height; |
|
| 273 | 273 | |
| 274 | -$pocetb=0; |
|
| 274 | +$pocetb = 0; |
|
| 275 | 275 | |
| 276 | -while(true) |
|
| 276 | +while (true) |
|
| 277 | 277 | { |
| 278 | 278 | $y--; |
| 279 | -$prefix=freadbyte($f); |
|
| 280 | -$suffix=freadbyte($f); |
|
| 281 | -$pocetb+=2; |
|
| 279 | +$prefix = freadbyte($f); |
|
| 280 | +$suffix = freadbyte($f); |
|
| 281 | +$pocetb += 2; |
|
| 282 | 282 | |
| 283 | -$echoit=false; |
|
| 283 | +$echoit = false; |
|
| 284 | 284 | |
| 285 | -if($echoit)echo "Prefix: $prefix Suffix: $suffix<BR>"; |
|
| 286 | -if(($prefix==0)and($suffix==1)) break; |
|
| 287 | -if(feof($f)) break; |
|
| 285 | +if ($echoit)echo "Prefix: $prefix Suffix: $suffix<BR>"; |
|
| 286 | +if (($prefix == 0) and ($suffix == 1)) break; |
|
| 287 | +if (feof($f)) break; |
|
| 288 | 288 | |
| 289 | -while(!(($prefix==0)and($suffix==0))) |
|
| 289 | +while (!(($prefix == 0) and ($suffix == 0))) |
|
| 290 | 290 | { |
| 291 | - if($prefix==0) |
|
| 291 | + if ($prefix == 0) |
|
| 292 | 292 | { |
| 293 | - $pocet=$suffix; |
|
| 294 | - $Data.=fread($f,$pocet); |
|
| 295 | - $pocetb+=$pocet; |
|
| 296 | - if($pocetb%2==1) {freadbyte($f); $pocetb++;}; |
|
| 293 | + $pocet = $suffix; |
|
| 294 | + $Data .= fread($f, $pocet); |
|
| 295 | + $pocetb += $pocet; |
|
| 296 | + if ($pocetb % 2 == 1) {freadbyte($f); $pocetb++; }; |
|
| 297 | 297 | }; |
| 298 | - if($prefix>0) |
|
| 298 | + if ($prefix > 0) |
|
| 299 | 299 | { |
| 300 | - $pocet=$prefix; |
|
| 301 | - for($r=0;$r<$pocet;$r++) |
|
| 302 | - $Data.=chr($suffix); |
|
| 300 | + $pocet = $prefix; |
|
| 301 | + for ($r = 0; $r < $pocet; $r++) |
|
| 302 | + $Data .= chr($suffix); |
|
| 303 | 303 | }; |
| 304 | - $prefix=freadbyte($f); |
|
| 305 | - $suffix=freadbyte($f); |
|
| 306 | - $pocetb+=2; |
|
| 307 | - if($echoit) echo "Prefix: $prefix Suffix: $suffix<BR>"; |
|
| 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 | -for($x=0;$x<strlen($Data);$x++) |
|
| 310 | +for ($x = 0; $x < strlen($Data); $x++) |
|
| 311 | 311 | { |
| 312 | - imagesetpixel($img,$x,$y,$Palette[ord($Data[$x])]); |
|
| 312 | + imagesetpixel($img, $x, $y, $Palette[ord($Data[$x])]); |
|
| 313 | 313 | }; |
| 314 | -$Data=""; |
|
| 314 | +$Data = ""; |
|
| 315 | 315 | |
| 316 | 316 | }; |
| 317 | 317 | |
| 318 | 318 | }; |
| 319 | 319 | |
| 320 | 320 | |
| 321 | -if($RLECompression==2) //$BI_RLE4 |
|
| 321 | +if ($RLECompression == 2) //$BI_RLE4 |
|
| 322 | 322 | { |
| 323 | -$y=$Height; |
|
| 324 | -$pocetb=0; |
|
| 323 | +$y = $Height; |
|
| 324 | +$pocetb = 0; |
|
| 325 | 325 | |
| 326 | 326 | /*while(!feof($f)) |
| 327 | 327 | echo freadbyte($f)."_".freadbyte($f)."<BR>";*/ |
| 328 | -while(true) |
|
| 328 | +while (true) |
|
| 329 | 329 | { |
| 330 | 330 | //break; |
| 331 | 331 | $y--; |
| 332 | -$prefix=freadbyte($f); |
|
| 333 | -$suffix=freadbyte($f); |
|
| 334 | -$pocetb+=2; |
|
| 332 | +$prefix = freadbyte($f); |
|
| 333 | +$suffix = freadbyte($f); |
|
| 334 | +$pocetb += 2; |
|
| 335 | 335 | |
| 336 | -$echoit=false; |
|
| 336 | +$echoit = false; |
|
| 337 | 337 | |
| 338 | -if($echoit)echo "Prefix: $prefix Suffix: $suffix<BR>"; |
|
| 339 | -if(($prefix==0)and($suffix==1)) break; |
|
| 340 | -if(feof($f)) break; |
|
| 338 | +if ($echoit)echo "Prefix: $prefix Suffix: $suffix<BR>"; |
|
| 339 | +if (($prefix == 0) and ($suffix == 1)) break; |
|
| 340 | +if (feof($f)) break; |
|
| 341 | 341 | |
| 342 | -while(!(($prefix==0)and($suffix==0))) |
|
| 342 | +while (!(($prefix == 0) and ($suffix == 0))) |
|
| 343 | 343 | { |
| 344 | - if($prefix==0) |
|
| 344 | + if ($prefix == 0) |
|
| 345 | 345 | { |
| 346 | - $pocet=$suffix; |
|
| 347 | - |
|
| 348 | - $CurrentBit=0; |
|
| 349 | - for($h=0;$h<$pocet;$h++) |
|
| 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++;}; |
|
| 346 | + $pocet = $suffix; |
|
| 347 | + |
|
| 348 | + $CurrentBit = 0; |
|
| 349 | + for ($h = 0; $h < $pocet; $h++) |
|
| 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 | 354 | }; |
| 355 | - if($prefix>0) |
|
| 355 | + if ($prefix > 0) |
|
| 356 | 356 | { |
| 357 | - $pocet=$prefix; |
|
| 358 | - $i=0; |
|
| 359 | - for($r=0;$r<$pocet;$r++) |
|
| 357 | + $pocet = $prefix; |
|
| 358 | + $i = 0; |
|
| 359 | + for ($r = 0; $r < $pocet; $r++) |
|
| 360 | 360 | { |
| 361 | - if($i%2==0) |
|
| 361 | + if ($i % 2 == 0) |
|
| 362 | 362 | { |
| 363 | - $Data.=chr($suffix%16); |
|
| 363 | + $Data .= chr($suffix % 16); |
|
| 364 | 364 | } |
| 365 | 365 | else |
| 366 | 366 | { |
| 367 | - $Data.=chr(floor($suffix/16)); |
|
| 367 | + $Data .= chr(floor($suffix / 16)); |
|
| 368 | 368 | }; |
| 369 | 369 | $i++; |
| 370 | 370 | }; |
| 371 | 371 | }; |
| 372 | - $prefix=freadbyte($f); |
|
| 373 | - $suffix=freadbyte($f); |
|
| 374 | - $pocetb+=2; |
|
| 375 | - if($echoit) echo "Prefix: $prefix Suffix: $suffix<BR>"; |
|
| 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 | -for($x=0;$x<strlen($Data);$x++) |
|
| 378 | +for ($x = 0; $x < strlen($Data); $x++) |
|
| 379 | 379 | { |
| 380 | - imagesetpixel($img,$x,$y,$Palette[ord($Data[$x])]); |
|
| 380 | + imagesetpixel($img, $x, $y, $Palette[ord($Data[$x])]); |
|
| 381 | 381 | }; |
| 382 | -$Data=""; |
|
| 382 | +$Data = ""; |
|
| 383 | 383 | |
| 384 | 384 | }; |
| 385 | 385 | |
| 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++) |
|
| 396 | + for ($x = 0; $x < $Width; $x++) |
|
| 397 | 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); |
|
| 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 | 404 | } |
| 405 | - for($z=0;$z<$Zbytek;$z++) |
|
| 405 | + for ($z = 0; $z < $Zbytek; $z++) |
|
| 406 | 406 | freadbyte($f); |
| 407 | 407 | }; |
| 408 | 408 | }; |
@@ -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,48 +456,48 @@ 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 | |
| 465 | 465 | |
| 466 | -function RetBits($byte,$start,$len) |
|
| 466 | +function RetBits($byte, $start, $len) |
|
| 467 | 467 | { |
| 468 | -$bin=decbin8($byte); |
|
| 469 | -$r=bindec(substr($bin,$start,$len)); |
|
| 468 | +$bin = decbin8($byte); |
|
| 469 | +$r = bindec(substr($bin, $start, $len)); |
|
| 470 | 470 | return $r; |
| 471 | 471 | |
| 472 | 472 | }; |
| 473 | 473 | |
| 474 | 474 | |
| 475 | 475 | |
| 476 | -$CurrentBit=0; |
|
| 477 | -function freadbits($f,$count) |
|
| 476 | +$CurrentBit = 0; |
|
| 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) |
|
| 479 | + global $CurrentBit, $SMode; |
|
| 480 | + $Byte = freadbyte($f); |
|
| 481 | + $LastCBit = $CurrentBit; |
|
| 482 | + $CurrentBit += $count; |
|
| 483 | + if ($CurrentBit == 8) |
|
| 484 | 484 | { |
| 485 | - $CurrentBit=0; |
|
| 485 | + $CurrentBit = 0; |
|
| 486 | 486 | } |
| 487 | 487 | else |
| 488 | 488 | { |
| 489 | - fseek($f,ftell($f)-1); |
|
| 489 | + fseek($f, ftell($f) - 1); |
|
| 490 | 490 | }; |
| 491 | - return RetBits($Byte,$LastCBit,$count); |
|
| 491 | + return RetBits($Byte, $LastCBit, $count); |
|
| 492 | 492 | }; |
| 493 | 493 | |
| 494 | 494 | |
| 495 | 495 | |
| 496 | -function RGBToHex($Red,$Green,$Blue) |
|
| 496 | +function RGBToHex($Red, $Green, $Blue) |
|
| 497 | 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"; |
|
| 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 | 501 | return($hRed.$hGreen.$hBlue); |
| 502 | 502 | }; |
| 503 | 503 | |
@@ -513,15 +513,15 @@ discard block |
||
| 513 | 513 | |
| 514 | 514 | function decbin8($d) |
| 515 | 515 | { |
| 516 | -return decbinx($d,8); |
|
| 516 | +return decbinx($d, 8); |
|
| 517 | 517 | }; |
| 518 | 518 | |
| 519 | -function decbinx($d,$n) |
|
| 519 | +function decbinx($d, $n) |
|
| 520 | 520 | { |
| 521 | -$bin=decbin($d); |
|
| 522 | -$sbin=strlen($bin); |
|
| 523 | -for($j=0;$j<$n-$sbin;$j++) |
|
| 524 | - $bin="0$bin"; |
|
| 521 | +$bin = decbin($d); |
|
| 522 | +$sbin = strlen($bin); |
|
| 523 | +for ($j = 0; $j < $n - $sbin; $j++) |
|
| 524 | + $bin = "0$bin"; |
|
| 525 | 525 | return $bin; |
| 526 | 526 | }; |
| 527 | 527 | |
@@ -59,7 +59,7 @@ |
||
| 59 | 59 | $to_page = min($last_page, max($first_page, $current_page - $lrspan) + $this->max_pages_shown - 1); |
| 60 | 60 | $from_page = max($first_page, $to_page - $this->max_pages_shown + 1); |
| 61 | 61 | |
| 62 | - for ($page = $from_page; $page <= $to_page; $page ++) { |
|
| 62 | + for ($page = $from_page; $page <= $to_page; $page++) { |
|
| 63 | 63 | if ($page == $current_page) { |
| 64 | 64 | $pages[$page] = false; |
| 65 | 65 | } else { |