@@ -76,6 +76,12 @@ discard block |
||
| 76 | 76 | // prepare EMail-From |
| 77 | 77 | $emailheaders = 'From: "' . $emailaddr . '" <' . $emailaddr . '>'; |
| 78 | 78 | |
| 79 | +/** |
|
| 80 | + * @param string $module |
|
| 81 | + * @param integer $eventid |
|
| 82 | + * @param integer $objectid2 |
|
| 83 | + * @param string $logtext |
|
| 84 | + */ |
|
| 79 | 85 | function logentry($module, $eventid, $userid, $objectid1, $objectid2, $logtext, $details) |
| 80 | 86 | { |
| 81 | 87 | sql( |
@@ -148,6 +154,9 @@ discard block |
||
| 148 | 154 | return $start; |
| 149 | 155 | } |
| 150 | 156 | |
| 157 | +/** |
|
| 158 | + * @return string |
|
| 159 | + */ |
|
| 151 | 160 | function escape_javascript($text) |
| 152 | 161 | { |
| 153 | 162 | return str_replace('\'', '\\\'', str_replace('"', '"', $text)); |
@@ -159,6 +168,9 @@ discard block |
||
| 159 | 168 | sql_error(); |
| 160 | 169 | } |
| 161 | 170 | |
| 171 | +/** |
|
| 172 | + * @param string $sql |
|
| 173 | + */ |
|
| 162 | 174 | function sqlValue($sql, $default) |
| 163 | 175 | { |
| 164 | 176 | $rs = sql($sql); |
@@ -187,11 +199,21 @@ discard block |
||
| 187 | 199 | } |
| 188 | 200 | } |
| 189 | 201 | |
| 202 | +/** |
|
| 203 | + * @param string $name |
|
| 204 | + * @param string $default |
|
| 205 | + * |
|
| 206 | + * @return string |
|
| 207 | + */ |
|
| 190 | 208 | function getSysConfig($name, $default) |
| 191 | 209 | { |
| 192 | 210 | return sqlValue('SELECT `value` FROM `sysconfig` WHERE `name`=\'' . sql_escape($name) . '\'', $default); |
| 193 | 211 | } |
| 194 | 212 | |
| 213 | +/** |
|
| 214 | + * @param string $name |
|
| 215 | + * @param string $value |
|
| 216 | + */ |
|
| 195 | 217 | function setSysConfig($name, $value) |
| 196 | 218 | { |
| 197 | 219 | if (sqlValue('SELECT COUNT(*) FROM sysconfig WHERE name=\'' . sql_escape($name) . '\'', 0) == 1) { |
@@ -516,6 +538,9 @@ discard block |
||
| 516 | 538 | die('sql_error'); |
| 517 | 539 | } |
| 518 | 540 | |
| 541 | +/** |
|
| 542 | + * @param string $warnmessage |
|
| 543 | + */ |
|
| 519 | 544 | function sql_warn($warnmessage) |
| 520 | 545 | { |
| 521 | 546 | global $sql_errormail; |
@@ -549,6 +574,9 @@ discard block |
||
| 549 | 574 | return mysql_fetch_row($rs); |
| 550 | 575 | } |
| 551 | 576 | |
| 577 | +/** |
|
| 578 | + * @param resource $rs |
|
| 579 | + */ |
|
| 552 | 580 | function sql_fetch_column($rs) |
| 553 | 581 | { |
| 554 | 582 | $col = []; |
@@ -758,6 +786,9 @@ discard block |
||
| 758 | 786 | ]; |
| 759 | 787 | } |
| 760 | 788 | |
| 789 | +/** |
|
| 790 | + * @param string $filename |
|
| 791 | + */ |
|
| 761 | 792 | function fetch_email_template($filename, $language, $domain) |
| 762 | 793 | { |
| 763 | 794 | global $opt, $rootpath; |
@@ -20,7 +20,7 @@ discard block |
||
| 20 | 20 | * $dblink |
| 21 | 21 | ****************************************************************************/ |
| 22 | 22 | |
| 23 | -require_once __DIR__ . '/../vendor/autoload.php'; |
|
| 23 | +require_once __DIR__.'/../vendor/autoload.php'; |
|
| 24 | 24 | |
| 25 | 25 | global $interface_output, $dblink_slave; |
| 26 | 26 | if (!isset($interface_output)) { |
@@ -49,9 +49,9 @@ discard block |
||
| 49 | 49 | define('regex_statpic_text', '^[a-zA-Z0-9\.\-_ @äüöÄÜÖß=)(\/\\\&*\$+~#!§%;,-?:\[\]{}¹²³\'\"`\|µ°]{0,29}$'); |
| 50 | 50 | |
| 51 | 51 | //load default webserver-settings and common includes |
| 52 | -require_once $opt['rootpath'] . 'lib/consts.inc.php'; |
|
| 53 | -require_once $opt['rootpath'] . 'lib/settings.inc.php'; |
|
| 54 | -require_once $opt['rootpath'] . 'lib2/errorhandler.inc.php'; |
|
| 52 | +require_once $opt['rootpath'].'lib/consts.inc.php'; |
|
| 53 | +require_once $opt['rootpath'].'lib/settings.inc.php'; |
|
| 54 | +require_once $opt['rootpath'].'lib2/errorhandler.inc.php'; |
|
| 55 | 55 | |
| 56 | 56 | // check for banned UAs |
| 57 | 57 | $useragent = isset($_SERVER['HTTP_USER_AGENT']) ? $_SERVER['HTTP_USER_AGENT'] : ""; |
@@ -74,7 +74,7 @@ discard block |
||
| 74 | 74 | } |
| 75 | 75 | |
| 76 | 76 | // prepare EMail-From |
| 77 | -$emailheaders = 'From: "' . $emailaddr . '" <' . $emailaddr . '>'; |
|
| 77 | +$emailheaders = 'From: "'.$emailaddr.'" <'.$emailaddr.'>'; |
|
| 78 | 78 | |
| 79 | 79 | function logentry($module, $eventid, $userid, $objectid1, $objectid2, $logtext, $details) |
| 80 | 80 | { |
@@ -113,7 +113,7 @@ discard block |
||
| 113 | 113 | |
| 114 | 114 | while ($nCurPos < mb_strlen($str)) { |
| 115 | 115 | $nNextSep = mb_strlen($str); |
| 116 | - for ($nSepPos = 0; $nSepPos < mb_strlen($sep); $nSepPos ++) { |
|
| 116 | + for ($nSepPos = 0; $nSepPos < mb_strlen($sep); $nSepPos++) { |
|
| 117 | 117 | $nThisPos = mb_strpos($str, mb_substr($sep, $nSepPos, 1), $nCurPos); |
| 118 | 118 | if ($nThisPos !== false) { |
| 119 | 119 | if ($nNextSep > $nThisPos) { |
@@ -189,12 +189,12 @@ discard block |
||
| 189 | 189 | |
| 190 | 190 | function getSysConfig($name, $default) |
| 191 | 191 | { |
| 192 | - return sqlValue('SELECT `value` FROM `sysconfig` WHERE `name`=\'' . sql_escape($name) . '\'', $default); |
|
| 192 | + return sqlValue('SELECT `value` FROM `sysconfig` WHERE `name`=\''.sql_escape($name).'\'', $default); |
|
| 193 | 193 | } |
| 194 | 194 | |
| 195 | 195 | function setSysConfig($name, $value) |
| 196 | 196 | { |
| 197 | - if (sqlValue('SELECT COUNT(*) FROM sysconfig WHERE name=\'' . sql_escape($name) . '\'', 0) == 1) { |
|
| 197 | + if (sqlValue('SELECT COUNT(*) FROM sysconfig WHERE name=\''.sql_escape($name).'\'', 0) == 1) { |
|
| 198 | 198 | sql( |
| 199 | 199 | "UPDATE `sysconfig` SET `value`='&1' WHERE `name`='&2' LIMIT 1", |
| 200 | 200 | $value, |
@@ -294,10 +294,10 @@ discard block |
||
| 294 | 294 | // muss dieses & ersetzt werden, oder ist es escaped? |
| 295 | 295 | $escapesCount = 0; |
| 296 | 296 | while ((($nextarg - $escapesCount - 1) > 0) && (mb_substr($sql, $nextarg - $escapesCount - 1, 1) == '\\')) { |
| 297 | - $escapesCount ++; |
|
| 297 | + $escapesCount++; |
|
| 298 | 298 | } |
| 299 | 299 | if (($escapesCount % 2) == 1) { |
| 300 | - $nextarg ++; |
|
| 300 | + $nextarg++; |
|
| 301 | 301 | } else { |
| 302 | 302 | $nextchar = mb_substr($sql, $nextarg + 1, 1); |
| 303 | 303 | if (is_numeric($nextchar)) { |
@@ -308,7 +308,7 @@ discard block |
||
| 308 | 308 | while (mb_ereg_match('^[0-9]{1}', $nextchar) == 1) { |
| 309 | 309 | $arg .= $nextchar; |
| 310 | 310 | |
| 311 | - $arglength ++; |
|
| 311 | + $arglength++; |
|
| 312 | 312 | $nextchar = mb_substr($sql, $nextarg + $arglength + 1, 1); |
| 313 | 313 | } |
| 314 | 314 | |
@@ -349,13 +349,13 @@ discard block |
||
| 349 | 349 | // Anführungszeichen weg machen und NULL einsetzen |
| 350 | 350 | $filtered_sql = mb_substr($filtered_sql, 0, mb_strlen($filtered_sql) - 1); |
| 351 | 351 | $filtered_sql .= 'NULL'; |
| 352 | - $sqlpos ++; |
|
| 352 | + $sqlpos++; |
|
| 353 | 353 | } else { |
| 354 | 354 | $filtered_sql .= 'NULL'; |
| 355 | 355 | } |
| 356 | 356 | } |
| 357 | 357 | |
| 358 | - $sqlpos ++; |
|
| 358 | + $sqlpos++; |
|
| 359 | 359 | } else { |
| 360 | 360 | $arglength = 0; |
| 361 | 361 | $arg = ''; |
@@ -364,7 +364,7 @@ discard block |
||
| 364 | 364 | while (mb_ereg_match('^[a-zA-Z0-9]{1}', $nextchar) == 1) { |
| 365 | 365 | $arg .= $nextchar; |
| 366 | 366 | |
| 367 | - $arglength ++; |
|
| 367 | + $arglength++; |
|
| 368 | 368 | $nextchar = mb_substr($sql, $nextarg + $arglength + 1, 1); |
| 369 | 369 | } |
| 370 | 370 | |
@@ -396,12 +396,12 @@ discard block |
||
| 396 | 396 | $nextarg - $escapesCount - 1, |
| 397 | 397 | 1 |
| 398 | 398 | ) == '\\')) { |
| 399 | - $escapesCount ++; |
|
| 399 | + $escapesCount++; |
|
| 400 | 400 | } |
| 401 | 401 | if (($escapesCount % 2) == 0) { |
| 402 | 402 | // \& ersetzen durch & |
| 403 | - $filtered_sql = mb_substr($filtered_sql, 0, $nextarg) . '&' . mb_substr($filtered_sql, $nextarg + 2); |
|
| 404 | - $nextarg --; |
|
| 403 | + $filtered_sql = mb_substr($filtered_sql, 0, $nextarg).'&'.mb_substr($filtered_sql, $nextarg + 2); |
|
| 404 | + $nextarg--; |
|
| 405 | 405 | } |
| 406 | 406 | |
| 407 | 407 | $nextarg = mb_strpos($filtered_sql, '\&', $nextarg + 2); |
@@ -418,14 +418,14 @@ discard block |
||
| 418 | 418 | */ |
| 419 | 419 | |
| 420 | 420 | if (isset($sql_debug) && ($sql_debug == true)) { |
| 421 | - require_once $opt['rootpath'] . 'lib/sqldebugger.inc.php'; |
|
| 421 | + require_once $opt['rootpath'].'lib/sqldebugger.inc.php'; |
|
| 422 | 422 | $result = sqldbg_execute($filtered_sql, $bSlave); |
| 423 | 423 | if ($result === false) { |
| 424 | 424 | sql_error(); |
| 425 | 425 | } |
| 426 | 426 | } else { |
| 427 | 427 | // Zeitmessung für die Ausführung |
| 428 | - require_once $opt['rootpath'] . 'lib/bench.inc.php'; |
|
| 428 | + require_once $opt['rootpath'].'lib/bench.inc.php'; |
|
| 429 | 429 | $cSqlExecution = new Cbench; |
| 430 | 430 | $cSqlExecution->start(); |
| 431 | 431 | |
@@ -437,8 +437,8 @@ discard block |
||
| 437 | 437 | $cSqlExecution->stop(); |
| 438 | 438 | |
| 439 | 439 | if ($sql_warntime > 0 && $cSqlExecution->diff() > $sql_warntime) { |
| 440 | - $ua = isset($_SERVER['HTTP_USER_AGENT']) ? "\r\n" . $_SERVER['HTTP_USER_AGENT'] : ""; |
|
| 441 | - sql_warn("execution took " . $cSqlExecution->diff() . " seconds" . $ua); |
|
| 440 | + $ua = isset($_SERVER['HTTP_USER_AGENT']) ? "\r\n".$_SERVER['HTTP_USER_AGENT'] : ""; |
|
| 441 | + sql_warn("execution took ".$cSqlExecution->diff()." seconds".$ua); |
|
| 442 | 442 | } |
| 443 | 443 | } |
| 444 | 444 | |
@@ -473,7 +473,7 @@ discard block |
||
| 473 | 473 | global $db_error; |
| 474 | 474 | |
| 475 | 475 | $db_error += 1; |
| 476 | - $msql_error = mysql_errno() . ": " . mysql_error(); |
|
| 476 | + $msql_error = mysql_errno().": ".mysql_error(); |
|
| 477 | 477 | if ($db_error > 1) { |
| 478 | 478 | $msql_error .= "\n(** error recursion **)"; |
| 479 | 479 | } |
@@ -484,13 +484,13 @@ discard block |
||
| 484 | 484 | $email_content .= "\n--------------------\n"; |
| 485 | 485 | $email_content .= print_r(debug_backtrace(), true); |
| 486 | 486 | if (admin_errormail($sql_errormail, 'sql_error', $email_content, $emailheaders)) { |
| 487 | - mb_send_mail($sql_errormail, 'sql_error: ' . $absolute_server_URI, $email_content, $emailheaders); |
|
| 487 | + mb_send_mail($sql_errormail, 'sql_error: '.$absolute_server_URI, $email_content, $emailheaders); |
|
| 488 | 488 | } |
| 489 | 489 | } |
| 490 | 490 | |
| 491 | 491 | if ($interface_output == 'html') { |
| 492 | 492 | // display errorpage |
| 493 | - $errmsg = $dberrormsg . ($debug_page ? "<br />" . $msql_error : ""); |
|
| 493 | + $errmsg = $dberrormsg.($debug_page ? "<br />".$msql_error : ""); |
|
| 494 | 494 | if ($db_error <= 1) { |
| 495 | 495 | tpl_errorMsg('sql_error', $errmsg); |
| 496 | 496 | } else { |
@@ -504,12 +504,12 @@ discard block |
||
| 504 | 504 | exit; |
| 505 | 505 | } elseif ($interface_output == 'plain') { |
| 506 | 506 | echo "\n"; |
| 507 | - echo 'sql_error' . "\n"; |
|
| 507 | + echo 'sql_error'."\n"; |
|
| 508 | 508 | if ($debug_page) { |
| 509 | - echo $msql_error . "\n"; |
|
| 509 | + echo $msql_error."\n"; |
|
| 510 | 510 | } |
| 511 | - echo '---------' . "\n"; |
|
| 512 | - echo print_r(debug_backtrace(), true) . "\n"; |
|
| 511 | + echo '---------'."\n"; |
|
| 512 | + echo print_r(debug_backtrace(), true)."\n"; |
|
| 513 | 513 | exit; |
| 514 | 514 | } |
| 515 | 515 | |
@@ -527,7 +527,7 @@ discard block |
||
| 527 | 527 | $email_content .= print_r(debug_backtrace(), true); |
| 528 | 528 | |
| 529 | 529 | if (admin_errormail($sql_errormail, 'sql_warn', $email_content, $emailheaders)) { |
| 530 | - $sendMail = @mb_send_mail($sql_errormail, 'sql_warn: ' . $absolute_server_URI, $email_content, $emailheaders); |
|
| 530 | + $sendMail = @mb_send_mail($sql_errormail, 'sql_warn: '.$absolute_server_URI, $email_content, $emailheaders); |
|
| 531 | 531 | if ($sendMail === false) { |
| 532 | 532 | throw new \RuntimeException('the E-Mail can not be send.'); |
| 533 | 533 | } |
@@ -630,7 +630,7 @@ discard block |
||
| 630 | 630 | } |
| 631 | 631 | |
| 632 | 632 | if ($dblink != false) { |
| 633 | - mysql_query("SET NAMES '" . mysql_real_escape_string($opt['charset']['mysql'], $dblink) . "'", $dblink); |
|
| 633 | + mysql_query("SET NAMES '".mysql_real_escape_string($opt['charset']['mysql'], $dblink)."'", $dblink); |
|
| 634 | 634 | |
| 635 | 635 | //database connection established ... set the used database |
| 636 | 636 | if (@mysql_select_db($dbname, $dblink) == false) { |
@@ -666,7 +666,7 @@ discard block |
||
| 666 | 666 | $nMaxTimeDiff = $opt['db']['slave']['max_behind']; |
| 667 | 667 | if ($usr !== false) { |
| 668 | 668 | $nMaxTimeDiff = sqlValue( |
| 669 | - "SELECT TIMESTAMP(NOW())-TIMESTAMP(`datExclude`) FROM `sys_repl_exclude` WHERE `user_id`='" . ($usr['userid'] + 0) . "'", |
|
| 669 | + "SELECT TIMESTAMP(NOW())-TIMESTAMP(`datExclude`) FROM `sys_repl_exclude` WHERE `user_id`='".($usr['userid'] + 0)."'", |
|
| 670 | 670 | $opt['db']['slave']['max_behind'] |
| 671 | 671 | ); |
| 672 | 672 | if ($nMaxTimeDiff > $opt['db']['slave']['max_behind']) { |
@@ -675,7 +675,7 @@ discard block |
||
| 675 | 675 | } |
| 676 | 676 | |
| 677 | 677 | $id = sqlValue( |
| 678 | - "SELECT `id`, `weight`*RAND() AS `w` FROM `sys_repl_slaves` WHERE `active`=1 AND `online`=1 AND (TIMESTAMP(NOW())-TIMESTAMP(`last_check`)+`time_diff`<'" . ($nMaxTimeDiff + 0) . "') ORDER BY `w` DESC LIMIT 1", |
|
| 678 | + "SELECT `id`, `weight`*RAND() AS `w` FROM `sys_repl_slaves` WHERE `active`=1 AND `online`=1 AND (TIMESTAMP(NOW())-TIMESTAMP(`last_check`)+`time_diff`<'".($nMaxTimeDiff + 0)."') ORDER BY `w` DESC LIMIT 1", |
|
| 679 | 679 | - 1 |
| 680 | 680 | ); |
| 681 | 681 | |
@@ -747,9 +747,9 @@ discard block |
||
| 747 | 747 | $protocol = 'http'; |
| 748 | 748 | } |
| 749 | 749 | |
| 750 | - $site_url = $protocol . strstr($opt['domain'][$domain]['url'], '://'); |
|
| 750 | + $site_url = $protocol.strstr($opt['domain'][$domain]['url'], '://'); |
|
| 751 | 751 | if (isset($opt['domain'][$domain]['shortlink_domain']) && $opt['domain'][$domain]['shortlink_domain']) { |
| 752 | - $shortlink_url = $protocol . '://' . $opt['domain'][$domain]['shortlink_domain'] . '/'; |
|
| 752 | + $shortlink_url = $protocol.'://'.$opt['domain'][$domain]['shortlink_domain'].'/'; |
|
| 753 | 753 | } else { |
| 754 | 754 | $shortlink_url = false; |
| 755 | 755 | } |
@@ -769,10 +769,10 @@ discard block |
||
| 769 | 769 | $language = $opt['template']['default']['locale']; |
| 770 | 770 | } |
| 771 | 771 | $language = strtolower($language); |
| 772 | - if (!file_exists($rootpath . '/lang/de/ocstyle/email/' . $language . '/' . $filename . '.email')) { |
|
| 772 | + if (!file_exists($rootpath.'/lang/de/ocstyle/email/'.$language.'/'.$filename.'.email')) { |
|
| 773 | 773 | $language = 'en'; |
| 774 | 774 | } |
| 775 | - $mailtext = read_file($rootpath . '/lang/de/ocstyle/email/' . $language . '/' . $filename . '.email'); |
|
| 775 | + $mailtext = read_file($rootpath.'/lang/de/ocstyle/email/'.$language.'/'.$filename.'.email'); |
|
| 776 | 776 | |
| 777 | 777 | $urls = get_site_urls($domain); |
| 778 | 778 | $mailtext = mb_ereg_replace("{site_url}", $urls['site_url'], $mailtext); |
@@ -323,6 +323,9 @@ discard block |
||
| 323 | 323 | //set no_eval true to prevent this contents from php-parsing. |
| 324 | 324 | //Important when replacing something that the user has posted |
| 325 | 325 | //in HTML code and could contain \<\? php-Code \?\> |
| 326 | +/** |
|
| 327 | + * @param string $name |
|
| 328 | + */ |
|
| 326 | 329 | function tpl_set_var($name, $value, $no_eval = true) |
| 327 | 330 | { |
| 328 | 331 | global $vars, $no_eval_vars; |
@@ -543,6 +546,9 @@ discard block |
||
| 543 | 546 | } |
| 544 | 547 | |
| 545 | 548 | //redirect to another site to display, i.e. to view a cache after logging |
| 549 | +/** |
|
| 550 | + * @param string $page |
|
| 551 | + */ |
|
| 546 | 552 | function tpl_redirect($page) |
| 547 | 553 | { |
| 548 | 554 | global $absolute_server_URI; |
@@ -562,6 +568,9 @@ discard block |
||
| 562 | 568 | //process the template replacements |
| 563 | 569 | //no_eval_replace - if true, variables will be replaced that are |
| 564 | 570 | // marked as "no_eval" |
| 571 | +/** |
|
| 572 | + * @param string $str |
|
| 573 | + */ |
|
| 565 | 574 | function tpl_do_replace($str) |
| 566 | 575 | { |
| 567 | 576 | global $vars, $no_eval_vars; |
@@ -589,6 +598,10 @@ discard block |
||
| 589 | 598 | return $str; |
| 590 | 599 | } |
| 591 | 600 | |
| 601 | +/** |
|
| 602 | + * @param string $tplnameError |
|
| 603 | + * @param string $msg |
|
| 604 | + */ |
|
| 592 | 605 | function tpl_errorMsg($tplnameError, $msg) |
| 593 | 606 | { |
| 594 | 607 | global $tplname; |
@@ -617,6 +630,9 @@ discard block |
||
| 617 | 630 | textdomain('messages'); |
| 618 | 631 | } |
| 619 | 632 | |
| 633 | +/** |
|
| 634 | + * @param string $sCode |
|
| 635 | + */ |
|
| 620 | 636 | function tpl_do_translation($sCode) |
| 621 | 637 | { |
| 622 | 638 | global $opt, $style, $tplname; |
@@ -645,6 +661,9 @@ discard block |
||
| 645 | 661 | return $sResultCode; |
| 646 | 662 | } |
| 647 | 663 | |
| 664 | +/** |
|
| 665 | + * @param string $sCode |
|
| 666 | + */ |
|
| 648 | 667 | function gettext_do_html($sCode) |
| 649 | 668 | { |
| 650 | 669 | $sResultCode = ''; |
@@ -674,6 +693,9 @@ discard block |
||
| 674 | 693 | return $sResultCode; |
| 675 | 694 | } |
| 676 | 695 | |
| 696 | +/** |
|
| 697 | + * @return string |
|
| 698 | + */ |
|
| 677 | 699 | function t($str) |
| 678 | 700 | { |
| 679 | 701 | global $translate; |
@@ -35,19 +35,19 @@ discard block |
||
| 35 | 35 | if (!isset($rootpath)) { |
| 36 | 36 | $rootpath = './'; |
| 37 | 37 | } |
| 38 | -require_once $rootpath . 'lib/clicompatbase.inc.php'; |
|
| 38 | +require_once $rootpath.'lib/clicompatbase.inc.php'; |
|
| 39 | 39 | |
| 40 | 40 | // enforce http or https? |
| 41 | 41 | if (isset($opt['gui']) && $opt['gui'] == GUI_HTML) { |
| 42 | 42 | if ($opt['page']['https']['mode'] == HTTPS_DISABLED) { |
| 43 | 43 | if ($opt['page']['https']['active']) { |
| 44 | - header('Location: http://' . $_SERVER['SERVER_NAME'] . $_SERVER['REQUEST_URI']); |
|
| 44 | + header('Location: http://'.$_SERVER['SERVER_NAME'].$_SERVER['REQUEST_URI']); |
|
| 45 | 45 | } |
| 46 | 46 | $opt['page']['force_https_login'] = false; |
| 47 | 47 | } else { |
| 48 | 48 | if ($opt['page']['https']['mode'] == HTTPS_ENFORCED) { |
| 49 | 49 | if (!$opt['page']['https']['active']) { |
| 50 | - header('Location: https://' . $_SERVER['SERVER_NAME'] . $_SERVER['REQUEST_URI']); |
|
| 50 | + header('Location: https://'.$_SERVER['SERVER_NAME'].$_SERVER['REQUEST_URI']); |
|
| 51 | 51 | } |
| 52 | 52 | $opt['page']['force_https_login'] = true; |
| 53 | 53 | } |
@@ -58,12 +58,12 @@ discard block |
||
| 58 | 58 | load_domain_settings(); |
| 59 | 59 | |
| 60 | 60 | // load HTML specific includes |
| 61 | -require_once $rootpath . 'lib/cookie.class.php'; |
|
| 61 | +require_once $rootpath.'lib/cookie.class.php'; |
|
| 62 | 62 | |
| 63 | 63 | //site in service? |
| 64 | 64 | if ($site_in_service == false) { |
| 65 | 65 | header('Content-type: text/html; charset=utf-8'); |
| 66 | - $page_content = read_file($rootpath . 'html/outofservice.tpl.php'); |
|
| 66 | + $page_content = read_file($rootpath.'html/outofservice.tpl.php'); |
|
| 67 | 67 | die($page_content); |
| 68 | 68 | } |
| 69 | 69 | |
@@ -84,7 +84,7 @@ discard block |
||
| 84 | 84 | } |
| 85 | 85 | |
| 86 | 86 | //are there files for this language? |
| 87 | -if (!file_exists($rootpath . 'lang/' . $lang . '/')) { |
|
| 87 | +if (!file_exists($rootpath.'lang/'.$lang.'/')) { |
|
| 88 | 88 | die('Critical Error: The specified language does not exist!'); |
| 89 | 89 | } |
| 90 | 90 | |
@@ -97,22 +97,22 @@ discard block |
||
| 97 | 97 | } |
| 98 | 98 | |
| 99 | 99 | //does the style exist? |
| 100 | -if (!file_exists($rootpath . 'lang/' . $lang . '/' . $style . '/')) { |
|
| 100 | +if (!file_exists($rootpath.'lang/'.$lang.'/'.$style.'/')) { |
|
| 101 | 101 | $style = 'ocstyle'; |
| 102 | 102 | } |
| 103 | 103 | |
| 104 | -if (!file_exists($rootpath . 'lang/' . $lang . '/' . $style . '/')) { |
|
| 104 | +if (!file_exists($rootpath.'lang/'.$lang.'/'.$style.'/')) { |
|
| 105 | 105 | die('Critical Error: The specified style does not exist!'); |
| 106 | 106 | } |
| 107 | 107 | |
| 108 | 108 | //set up the language path |
| 109 | 109 | if (!isset($langpath)) { |
| 110 | - $langpath = $rootpath . 'lang/' . $lang; |
|
| 110 | + $langpath = $rootpath.'lang/'.$lang; |
|
| 111 | 111 | } |
| 112 | 112 | |
| 113 | 113 | //set up the style path |
| 114 | 114 | if (!isset($stylepath)) { |
| 115 | - $stylepath = $langpath . '/' . $style; |
|
| 115 | + $stylepath = $langpath.'/'.$style; |
|
| 116 | 116 | } |
| 117 | 117 | |
| 118 | 118 | //load gettext translation |
@@ -121,14 +121,14 @@ discard block |
||
| 121 | 121 | //open a databse connection |
| 122 | 122 | db_connect(); |
| 123 | 123 | |
| 124 | -require $opt['rootpath'] . 'lib/auth.inc.php'; |
|
| 125 | -require_once $opt['rootpath'] . 'lib2/translate.class.php'; |
|
| 124 | +require $opt['rootpath'].'lib/auth.inc.php'; |
|
| 125 | +require_once $opt['rootpath'].'lib2/translate.class.php'; |
|
| 126 | 126 | |
| 127 | 127 | //load language specific strings |
| 128 | -require_once $langpath . '/expressions.inc.php'; |
|
| 128 | +require_once $langpath.'/expressions.inc.php'; |
|
| 129 | 129 | |
| 130 | 130 | //set up the defaults for the main template |
| 131 | -require_once $stylepath . '/varset.inc.php'; |
|
| 131 | +require_once $stylepath.'/varset.inc.php'; |
|
| 132 | 132 | |
| 133 | 133 | if ($dblink === false) { |
| 134 | 134 | //error while connecting to the database |
@@ -156,7 +156,7 @@ discard block |
||
| 156 | 156 | tpl_set_var('loginbox', $sLoggedOut); |
| 157 | 157 | tpl_set_var( |
| 158 | 158 | 'login_url', |
| 159 | - ($opt['page']['https']['force_login'] ? $opt['page']['absolute_https_url'] : '') . 'login.php' |
|
| 159 | + ($opt['page']['https']['force_login'] ? $opt['page']['absolute_https_url'] : '').'login.php' |
|
| 160 | 160 | ); |
| 161 | 161 | } else { |
| 162 | 162 | //user logged in |
@@ -170,7 +170,7 @@ discard block |
||
| 170 | 170 | $ocpropping = isset($_SERVER['HTTP_USER_AGENT']) && strpos($_SERVER['HTTP_USER_AGENT'], "Ocprop/") !== false; |
| 171 | 171 | |
| 172 | 172 | // zeitmessung |
| 173 | -require_once $rootpath . 'lib/bench.inc.php'; |
|
| 173 | +require_once $rootpath.'lib/bench.inc.php'; |
|
| 174 | 174 | $bScriptExecution = new Cbench; |
| 175 | 175 | $bScriptExecution->start(); |
| 176 | 176 | |
@@ -334,12 +334,12 @@ discard block |
||
| 334 | 334 | // country dropdown |
| 335 | 335 | global $tpl_usercountries; |
| 336 | 336 | |
| 337 | - tpl_set_var('screen_css_time', filemtime($opt['rootpath'] . "resource2/" . $style . "/css/style_screen.css")); |
|
| 337 | + tpl_set_var('screen_css_time', filemtime($opt['rootpath']."resource2/".$style."/css/style_screen.css")); |
|
| 338 | 338 | tpl_set_var( |
| 339 | 339 | 'screen_msie_css_time', |
| 340 | - filemtime($opt['rootpath'] . "resource2/" . $style . "/css/style_screen_msie.css") |
|
| 340 | + filemtime($opt['rootpath']."resource2/".$style."/css/style_screen_msie.css") |
|
| 341 | 341 | ); |
| 342 | - tpl_set_var('print_css_time', filemtime($opt['rootpath'] . "resource2/" . $style . "/css/style_print.css")); |
|
| 342 | + tpl_set_var('print_css_time', filemtime($opt['rootpath']."resource2/".$style."/css/style_print.css")); |
|
| 343 | 343 | |
| 344 | 344 | if (isset($bScriptExecution)) { |
| 345 | 345 | $bScriptExecution->Stop(); |
@@ -376,8 +376,8 @@ discard block |
||
| 376 | 376 | $ltext = mb_ereg_replace('%1', $lurl, $ltext); |
| 377 | 377 | $ltext = mb_ereg_replace('{site}', $opt['page']['sitename'], $ltext); |
| 378 | 378 | |
| 379 | - $ld = '<p class="sidebar-maintitle">' . $translate->t('Datalicense', '', '', 0) . '</p>' . |
|
| 380 | - '<div style="margin:20px 0 16px 0; width:100%; text-align:center;">' . $ltext . '</div>'; |
|
| 379 | + $ld = '<p class="sidebar-maintitle">'.$translate->t('Datalicense', '', '', 0).'</p>'. |
|
| 380 | + '<div style="margin:20px 0 16px 0; width:100%; text-align:center;">'.$ltext.'</div>'; |
|
| 381 | 381 | tpl_set_var('license_disclaimer', $ld); |
| 382 | 382 | } else { |
| 383 | 383 | tpl_set_var('license_disclaimer', ''); |
@@ -425,25 +425,25 @@ discard block |
||
| 425 | 425 | sql_free_result($rsUserCountries); |
| 426 | 426 | |
| 427 | 427 | //include language specific expressions, so that they are available in the template code |
| 428 | - include $langpath . '/expressions.inc.php'; |
|
| 428 | + include $langpath.'/expressions.inc.php'; |
|
| 429 | 429 | |
| 430 | 430 | //load main template |
| 431 | 431 | tpl_set_var('backgroundimage', '<div id="bg1"> </div><div id="bg2"> </div>'); |
| 432 | 432 | tpl_set_var('bodystyle', ''); |
| 433 | 433 | |
| 434 | 434 | if (isset($_REQUEST['print']) && $_REQUEST['print'] == 'y') { |
| 435 | - $sCode = read_file($stylepath . '/main_print.tpl.php'); |
|
| 435 | + $sCode = read_file($stylepath.'/main_print.tpl.php'); |
|
| 436 | 436 | } else { |
| 437 | 437 | if (isset($_REQUEST['popup']) && $_REQUEST['popup'] == 'y') { |
| 438 | - $sCode = read_file($stylepath . '/popup.tpl.php'); |
|
| 438 | + $sCode = read_file($stylepath.'/popup.tpl.php'); |
|
| 439 | 439 | } else { |
| 440 | - $sCode = read_file($stylepath . '/main.tpl.php'); |
|
| 440 | + $sCode = read_file($stylepath.'/main.tpl.php'); |
|
| 441 | 441 | } |
| 442 | 442 | } |
| 443 | - $sCode = '?>' . $sCode; |
|
| 443 | + $sCode = '?>'.$sCode; |
|
| 444 | 444 | |
| 445 | 445 | //does template exist? |
| 446 | - if (!file_exists($stylepath . '/' . $tplname . '.tpl.php')) { |
|
| 446 | + if (!file_exists($stylepath.'/'.$tplname.'.tpl.php')) { |
|
| 447 | 447 | //set up the error template |
| 448 | 448 | $error = true; |
| 449 | 449 | tpl_set_var('error_msg', htmlspecialchars($error_pagenotexist, ENT_COMPAT, 'UTF-8')); |
@@ -452,7 +452,7 @@ discard block |
||
| 452 | 452 | } |
| 453 | 453 | |
| 454 | 454 | //read the template |
| 455 | - $sTemplate = read_file($stylepath . '/' . $tplname . '.tpl.php'); |
|
| 455 | + $sTemplate = read_file($stylepath.'/'.$tplname.'.tpl.php'); |
|
| 456 | 456 | $sCode = mb_ereg_replace('{template}', $sTemplate, $sCode); |
| 457 | 457 | |
| 458 | 458 | //process translations |
@@ -492,7 +492,7 @@ discard block |
||
| 492 | 492 | // Date in the past |
| 493 | 493 | header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); |
| 494 | 494 | // always modified |
| 495 | - header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT"); |
|
| 495 | + header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT"); |
|
| 496 | 496 | } |
| 497 | 497 | |
| 498 | 498 | //redirect to another site to display, i.e. to view a cache after logging |
@@ -504,9 +504,9 @@ discard block |
||
| 504 | 504 | http_write_no_cache(); |
| 505 | 505 | |
| 506 | 506 | if (!preg_match('/^https?:/i', $page)) { |
| 507 | - header("Location: " . $absolute_server_URI . $page); |
|
| 507 | + header("Location: ".$absolute_server_URI.$page); |
|
| 508 | 508 | } else { |
| 509 | - header("Location: " . $page); |
|
| 509 | + header("Location: ".$page); |
|
| 510 | 510 | } |
| 511 | 511 | |
| 512 | 512 | exit; |
@@ -522,17 +522,17 @@ discard block |
||
| 522 | 522 | if (is_array($vars)) { |
| 523 | 523 | foreach ($vars as $varname => $varvalue) { |
| 524 | 524 | if ($no_eval_vars[$varname] == false) { |
| 525 | - $str = mb_ereg_replace('{' . $varname . '}', $varvalue, $str); |
|
| 525 | + $str = mb_ereg_replace('{'.$varname.'}', $varvalue, $str); |
|
| 526 | 526 | } else { |
| 527 | - $replave_var_name = 'tpl_replace_var_' . $varname; |
|
| 527 | + $replave_var_name = 'tpl_replace_var_'.$varname; |
|
| 528 | 528 | |
| 529 | 529 | global $$replave_var_name; |
| 530 | 530 | $$replave_var_name = $varvalue; |
| 531 | 531 | |
| 532 | 532 | //replace using php-echo |
| 533 | 533 | $str = mb_ereg_replace( |
| 534 | - '{' . $varname . '}', |
|
| 535 | - '<?php global $' . $replave_var_name . '; echo $tpl_replace_var_' . $varname . '; ?>', |
|
| 534 | + '{'.$varname.'}', |
|
| 535 | + '<?php global $'.$replave_var_name.'; echo $tpl_replace_var_'.$varname.'; ?>', |
|
| 536 | 536 | $str |
| 537 | 537 | ); |
| 538 | 538 | } |
@@ -565,7 +565,7 @@ discard block |
||
| 565 | 565 | } |
| 566 | 566 | $opt['template']['locale'] = $locale; |
| 567 | 567 | |
| 568 | - bindtextdomain('messages', $rootpath . '/cache2/translate'); |
|
| 568 | + bindtextdomain('messages', $rootpath.'/cache2/translate'); |
|
| 569 | 569 | set_php_locale(); |
| 570 | 570 | textdomain('messages'); |
| 571 | 571 | } |
@@ -603,7 +603,7 @@ discard block |
||
| 603 | 603 | $sResultCode = ''; |
| 604 | 604 | $nCurrentPos = 0; |
| 605 | 605 | while ($nCurrentPos < mb_strlen($sCode)) { |
| 606 | - $nStartOf = mb_strpos($sCode, '{' . 't}', $nCurrentPos); |
|
| 606 | + $nStartOf = mb_strpos($sCode, '{'.'t}', $nCurrentPos); |
|
| 607 | 607 | if ($nStartOf === false) { |
| 608 | 608 | $sResultCode .= mb_substr($sCode, $nCurrentPos, mb_strlen($sCode) - $nCurrentPos); |
| 609 | 609 | $nCurrentPos = mb_strlen($sCode); |
@@ -633,8 +633,8 @@ discard block |
||
| 633 | 633 | |
| 634 | 634 | $str = $translate->t($str, '', basename(__FILE__), __LINE__); |
| 635 | 635 | $args = func_get_args(); |
| 636 | - for ($nIndex = count($args) - 1; $nIndex > 0; $nIndex --) { |
|
| 637 | - $str = str_replace('%' . $nIndex, $args[$nIndex], $str); |
|
| 636 | + for ($nIndex = count($args) - 1; $nIndex > 0; $nIndex--) { |
|
| 637 | + $str = str_replace('%'.$nIndex, $args[$nIndex], $str); |
|
| 638 | 638 | } |
| 639 | 639 | |
| 640 | 640 | return $str; |
@@ -666,7 +666,7 @@ discard block |
||
| 666 | 666 | |
| 667 | 667 | // user specified a country? |
| 668 | 668 | if (isset($usr) && ($usr !== false)) { |
| 669 | - $sCountry = sqlValue("SELECT `country` FROM `user` WHERE `user_id`='" . ($usr['userid'] + 0) . "'", null); |
|
| 669 | + $sCountry = sqlValue("SELECT `country` FROM `user` WHERE `user_id`='".($usr['userid'] + 0)."'", null); |
|
| 670 | 670 | if ($sCountry != null) { |
| 671 | 671 | return $sCountry; |
| 672 | 672 | } |
@@ -732,14 +732,14 @@ discard block |
||
| 732 | 732 | mysql_free_result($rs); |
| 733 | 733 | |
| 734 | 734 | $imgtitle = $translate->t('Instructions', '', basename(__FILE__), __LINE__); |
| 735 | - $imgtitle = "alt='" . $imgtitle . "' title='" . $imgtitle . "'"; |
|
| 735 | + $imgtitle = "alt='".$imgtitle."' title='".$imgtitle."'"; |
|
| 736 | 736 | |
| 737 | 737 | if (substr($helppage, 0, 1) == "!") { |
| 738 | - return "<a class='nooutline' href='" . substr($helppage, 1) . "' " . $imgtitle . " target='_blank'>"; |
|
| 738 | + return "<a class='nooutline' href='".substr($helppage, 1)."' ".$imgtitle." target='_blank'>"; |
|
| 739 | 739 | } else { |
| 740 | 740 | if ($helppage != "" && isset($opt['locale'][$help_locale]['helpwiki'])) { |
| 741 | - return "<a class='nooutline' href='" . $opt['locale'][$help_locale]['helpwiki'] . |
|
| 742 | - str_replace(' ', '_', $helppage) . "' " . $imgtitle . " target='_blank'>"; |
|
| 741 | + return "<a class='nooutline' href='".$opt['locale'][$help_locale]['helpwiki']. |
|
| 742 | + str_replace(' ', '_', $helppage)."' ".$imgtitle." target='_blank'>"; |
|
| 743 | 743 | } |
| 744 | 744 | } |
| 745 | 745 | |
@@ -149,6 +149,9 @@ |
||
| 149 | 149 | <?php |
| 150 | 150 | } |
| 151 | 151 | |
| 152 | +/** |
|
| 153 | + * @param string $sql |
|
| 154 | + */ |
|
| 152 | 155 | function sqldbg_execute($sql, $bSlave) |
| 153 | 156 | { |
| 154 | 157 | global $dblink; |
@@ -9,7 +9,7 @@ discard block |
||
| 9 | 9 | * Unicode Reminder メモ |
| 10 | 10 | ****************************************************************************/ |
| 11 | 11 | |
| 12 | -require_once $opt['rootpath'] . 'lib/bench.inc.php'; |
|
| 12 | +require_once $opt['rootpath'].'lib/bench.inc.php'; |
|
| 13 | 13 | |
| 14 | 14 | $sqldbg_cmdNo = 0; |
| 15 | 15 | $sqldbg_sumTimes = 0; |
@@ -155,9 +155,9 @@ discard block |
||
| 155 | 155 | global $sqldbg_cmdNo; |
| 156 | 156 | global $sqldbg_sumTimes; |
| 157 | 157 | |
| 158 | - $sqldbg_cmdNo ++; |
|
| 158 | + $sqldbg_cmdNo++; |
|
| 159 | 159 | |
| 160 | - echo '<p class="sqlno"><span class="white">/*</span> SQL command ' . $sqldbg_cmdNo . ' '; |
|
| 160 | + echo '<p class="sqlno"><span class="white">/*</span> SQL command '.$sqldbg_cmdNo.' '; |
|
| 161 | 161 | if ($bSlave) { |
| 162 | 162 | echo '<span class="slave_title">(slave)</span>'; |
| 163 | 163 | } |
@@ -224,19 +224,19 @@ discard block |
||
| 224 | 224 | $bFirstLine = true; |
| 225 | 225 | $nLine = 0; |
| 226 | 226 | $rs = mysql_query($sqlexplain, $dblink); |
| 227 | - echo '<div class="selrows">Number of selected rows: ' . mysql_num_rows($rs) . '</div>'; |
|
| 227 | + echo '<div class="selrows">Number of selected rows: '.mysql_num_rows($rs).'</div>'; |
|
| 228 | 228 | |
| 229 | 229 | echo '<table class="firstresultrow" border="1">'; |
| 230 | 230 | |
| 231 | 231 | while ($r = sql_fetch_assoc($rs)) { |
| 232 | 232 | $usebr = true; |
| 233 | - $nLine ++; |
|
| 233 | + $nLine++; |
|
| 234 | 234 | if ($bFirstLine == true) { |
| 235 | - echo '<tr>' . "\n"; |
|
| 235 | + echo '<tr>'."\n"; |
|
| 236 | 236 | foreach ($r as $field => $value) { |
| 237 | - echo '<th>' . htmlspecialchars($field, ENT_COMPAT, 'UTF-8') . '</th>' . "\n"; |
|
| 237 | + echo '<th>'.htmlspecialchars($field, ENT_COMPAT, 'UTF-8').'</th>'."\n"; |
|
| 238 | 238 | } |
| 239 | - echo '</tr>' . "\n"; |
|
| 239 | + echo '</tr>'."\n"; |
|
| 240 | 240 | } |
| 241 | 241 | |
| 242 | 242 | if ($bFirstLine) { |
@@ -246,9 +246,9 @@ discard block |
||
| 246 | 246 | } |
| 247 | 247 | |
| 248 | 248 | foreach ($r as $value) { |
| 249 | - echo '<td>' . htmlspecialchars(($value != null) ? $value : 'NULL', ENT_COMPAT, 'UTF-8') . '</td>'; |
|
| 249 | + echo '<td>'.htmlspecialchars(($value != null) ? $value : 'NULL', ENT_COMPAT, 'UTF-8').'</td>'; |
|
| 250 | 250 | } |
| 251 | - echo '</tr>' . "\n"; |
|
| 251 | + echo '</tr>'."\n"; |
|
| 252 | 252 | |
| 253 | 253 | if ($nLine == 25) { |
| 254 | 254 | break; |
@@ -261,27 +261,27 @@ discard block |
||
| 261 | 261 | echo '<table class="explain" border="1">'; |
| 262 | 262 | |
| 263 | 263 | $bFirstLine = true; |
| 264 | - $rs = mysql_query('EXPLAIN EXTENDED ' . $sqlexplain); |
|
| 264 | + $rs = mysql_query('EXPLAIN EXTENDED '.$sqlexplain); |
|
| 265 | 265 | while ($r = sql_fetch_assoc($rs)) { |
| 266 | 266 | if ($bFirstLine == true) { |
| 267 | 267 | echo '<tr>'; |
| 268 | 268 | foreach ($r as $field => $value) { |
| 269 | - echo '<th>' . htmlspecialchars($field, ENT_COMPAT, 'UTF-8') . '</th>'; |
|
| 269 | + echo '<th>'.htmlspecialchars($field, ENT_COMPAT, 'UTF-8').'</th>'; |
|
| 270 | 270 | } |
| 271 | - echo '</tr>' . "\n"; |
|
| 271 | + echo '</tr>'."\n"; |
|
| 272 | 272 | |
| 273 | 273 | $bFirstLine = false; |
| 274 | 274 | } |
| 275 | 275 | |
| 276 | 276 | echo '<tr>'; |
| 277 | 277 | foreach ($r as $value) { |
| 278 | - echo '<td>' . htmlspecialchars( |
|
| 278 | + echo '<td>'.htmlspecialchars( |
|
| 279 | 279 | ($value != null) ? mb_ereg_replace('\*/', '* /', $value) : 'NULL', |
| 280 | 280 | ENT_COMPAT, |
| 281 | 281 | 'UTF-8' |
| 282 | - ) . '</td>'; |
|
| 282 | + ).'</td>'; |
|
| 283 | 283 | } |
| 284 | - echo '</tr>' . "\n"; |
|
| 284 | + echo '</tr>'."\n"; |
|
| 285 | 285 | } |
| 286 | 286 | echo '</table>'; |
| 287 | 287 | $usebr = true; |
@@ -303,14 +303,14 @@ discard block |
||
| 303 | 303 | echo '<table>'; |
| 304 | 304 | $rs = mysql_query('SHOW WARNINGS', $dblink); |
| 305 | 305 | while ($r = sql_fetch_assoc($rs)) { |
| 306 | - echo '<tr><td>' . htmlspecialchars($r['Message'], ENT_COMPAT, 'UTF-8') . '</td></tr>'; |
|
| 306 | + echo '<tr><td>'.htmlspecialchars($r['Message'], ENT_COMPAT, 'UTF-8').'</td></tr>'; |
|
| 307 | 307 | } |
| 308 | 308 | echo '</table>'; |
| 309 | 309 | echo '</div>'; |
| 310 | 310 | } |
| 311 | 311 | |
| 312 | - echo '<div class="runtime">Runtime: ' . sprintf('%01.5f', $bSqlExecution->Diff()) . ' sek.</div>'; |
|
| 313 | - echo '<div class="affectedrows">Number of affected rows: ' . mysql_affected_rows($dblink) . '</div>'; |
|
| 312 | + echo '<div class="runtime">Runtime: '.sprintf('%01.5f', $bSqlExecution->Diff()).' sek.</div>'; |
|
| 313 | + echo '<div class="affectedrows">Number of affected rows: '.mysql_affected_rows($dblink).'</div>'; |
|
| 314 | 314 | |
| 315 | 315 | echo '<div class="white">*/</div></div>'; |
| 316 | 316 | |
@@ -322,7 +322,7 @@ discard block |
||
| 322 | 322 | global $sqldbg_sumTimes; |
| 323 | 323 | |
| 324 | 324 | echo '<span class="white">/*</span><div class="allruntime"><hr>'; |
| 325 | - echo 'Runtime sum: ' . sprintf('%01.5f', $sqldbg_sumTimes) . ' sek.<span class="white">*/</span></div>'; |
|
| 325 | + echo 'Runtime sum: '.sprintf('%01.5f', $sqldbg_sumTimes).' sek.<span class="white">*/</span></div>'; |
|
| 326 | 326 | |
| 327 | 327 | echo '</body></html>'; |
| 328 | 328 | exit; |
@@ -347,13 +347,13 @@ discard block |
||
| 347 | 347 | return ''; |
| 348 | 348 | } |
| 349 | 349 | |
| 350 | - return 'SELECT * ' . mb_substr($sql, $start); |
|
| 350 | + return 'SELECT * '.mb_substr($sql, $start); |
|
| 351 | 351 | } |
| 352 | 352 | |
| 353 | 353 | function sqldbg_insert_nocache($sql) |
| 354 | 354 | { |
| 355 | 355 | if (mb_strtoupper(mb_substr($sql, 0, 7)) == 'SELECT ') { |
| 356 | - $sql = 'SELECT SQL_NO_CACHE ' . mb_substr($sql, 7); |
|
| 356 | + $sql = 'SELECT SQL_NO_CACHE '.mb_substr($sql, 7); |
|
| 357 | 357 | } |
| 358 | 358 | |
| 359 | 359 | return $sql; |
@@ -341,6 +341,9 @@ discard block |
||
| 341 | 341 | return $result; |
| 342 | 342 | } |
| 343 | 343 | |
| 344 | +/** |
|
| 345 | + * @param string $sql |
|
| 346 | + */ |
|
| 344 | 347 | function sqlf($sql) |
| 345 | 348 | { |
| 346 | 349 | global $db; |
@@ -354,6 +357,9 @@ discard block |
||
| 354 | 357 | return $result; |
| 355 | 358 | } |
| 356 | 359 | |
| 360 | +/** |
|
| 361 | + * @param string $sql |
|
| 362 | + */ |
|
| 357 | 363 | function sqlf_slave($sql) |
| 358 | 364 | { |
| 359 | 365 | global $db; |
@@ -367,6 +373,9 @@ discard block |
||
| 367 | 373 | return $result; |
| 368 | 374 | } |
| 369 | 375 | |
| 376 | +/** |
|
| 377 | + * @param string $sql |
|
| 378 | + */ |
|
| 370 | 379 | function sqll($sql) |
| 371 | 380 | { |
| 372 | 381 | global $db; |
@@ -380,6 +389,10 @@ discard block |
||
| 380 | 389 | return $result; |
| 381 | 390 | } |
| 382 | 391 | |
| 392 | +/** |
|
| 393 | + * @param string $sql |
|
| 394 | + * @param integer $default |
|
| 395 | + */ |
|
| 383 | 396 | function sqlf_value($sql, $default) |
| 384 | 397 | { |
| 385 | 398 | global $db; |
@@ -394,6 +407,10 @@ discard block |
||
| 394 | 407 | return $result; |
| 395 | 408 | } |
| 396 | 409 | |
| 410 | +/** |
|
| 411 | + * @param string $sql |
|
| 412 | + * @param integer $default |
|
| 413 | + */ |
|
| 397 | 414 | function sqll_value($sql, $default) |
| 398 | 415 | { |
| 399 | 416 | global $db; |
@@ -474,6 +491,9 @@ discard block |
||
| 474 | 491 | return sql_value_internal(true, $sql, $default, $args); |
| 475 | 492 | } |
| 476 | 493 | |
| 494 | +/** |
|
| 495 | + * @param boolean $bQuerySlave |
|
| 496 | + */ |
|
| 477 | 497 | function sql_value_internal($bQuerySlave, $sql, $default) |
| 478 | 498 | { |
| 479 | 499 | $args = func_get_args(); |
@@ -576,6 +596,9 @@ discard block |
||
| 576 | 596 | return $retval; |
| 577 | 597 | } |
| 578 | 598 | |
| 599 | +/** |
|
| 600 | + * @param resource $rs |
|
| 601 | + */ |
|
| 579 | 602 | function sql_fetch_column($rs) |
| 580 | 603 | { |
| 581 | 604 | global $opt; |
@@ -625,11 +648,17 @@ discard block |
||
| 625 | 648 | return mysql_insert_id($db['dblink_slave']); |
| 626 | 649 | } |
| 627 | 650 | |
| 651 | +/** |
|
| 652 | + * @param resource $rs |
|
| 653 | + */ |
|
| 628 | 654 | function sql_num_rows($rs) |
| 629 | 655 | { |
| 630 | 656 | return mysql_num_rows($rs); |
| 631 | 657 | } |
| 632 | 658 | |
| 659 | +/** |
|
| 660 | + * @param string $table |
|
| 661 | + */ |
|
| 633 | 662 | function sql_temp_table($table) |
| 634 | 663 | { |
| 635 | 664 | global $db, $opt; |
@@ -659,6 +688,9 @@ discard block |
||
| 659 | 688 | $db['temptables'][$table] = $table; |
| 660 | 689 | } |
| 661 | 690 | |
| 691 | +/** |
|
| 692 | + * @param string $table |
|
| 693 | + */ |
|
| 662 | 694 | function sql_temp_table_slave($table) |
| 663 | 695 | { |
| 664 | 696 | global $db, $opt; |
@@ -679,6 +711,9 @@ discard block |
||
| 679 | 711 | $db['temptables_slave'][$table] = $table; |
| 680 | 712 | } |
| 681 | 713 | |
| 714 | +/** |
|
| 715 | + * @param string $table |
|
| 716 | + */ |
|
| 682 | 717 | function sql_drop_temp_table($table) |
| 683 | 718 | { |
| 684 | 719 | global $db, $opt; |
@@ -715,6 +750,9 @@ discard block |
||
| 715 | 750 | $db['temptables'][$newname] = $newname; |
| 716 | 751 | } |
| 717 | 752 | |
| 753 | +/** |
|
| 754 | + * @param string $table |
|
| 755 | + */ |
|
| 718 | 756 | function sql_drop_temp_table_slave($table) |
| 719 | 757 | { |
| 720 | 758 | global $db, $opt; |
@@ -1079,6 +1117,9 @@ discard block |
||
| 1079 | 1117 | } |
| 1080 | 1118 | } |
| 1081 | 1119 | |
| 1120 | +/** |
|
| 1121 | + * @param string $warnmessage |
|
| 1122 | + */ |
|
| 1082 | 1123 | function sql_warn($warnmessage) |
| 1083 | 1124 | { |
| 1084 | 1125 | global $opt; |
@@ -1105,6 +1146,9 @@ discard block |
||
| 1105 | 1146 | } |
| 1106 | 1147 | } |
| 1107 | 1148 | |
| 1149 | +/** |
|
| 1150 | + * @param resource $rs |
|
| 1151 | + */ |
|
| 1108 | 1152 | function sql_export_recordset($f, $rs, $table, $truncate = true) |
| 1109 | 1153 | { |
| 1110 | 1154 | fwrite($f, "SET NAMES 'utf8';\n"); |
@@ -1135,6 +1179,9 @@ discard block |
||
| 1135 | 1179 | } |
| 1136 | 1180 | } |
| 1137 | 1181 | |
| 1182 | +/** |
|
| 1183 | + * @param resource $f |
|
| 1184 | + */ |
|
| 1138 | 1185 | function sql_export_table($f, $table) |
| 1139 | 1186 | { |
| 1140 | 1187 | $primary = array(); |
@@ -1156,6 +1203,10 @@ discard block |
||
| 1156 | 1203 | sql_free_result($rs); |
| 1157 | 1204 | } |
| 1158 | 1205 | |
| 1206 | +/** |
|
| 1207 | + * @param string $filename |
|
| 1208 | + * @param string[] $tables |
|
| 1209 | + */ |
|
| 1159 | 1210 | function sql_export_tables_to_file($filename, $tables) |
| 1160 | 1211 | { |
| 1161 | 1212 | $f = fopen($filename, 'w'); |
@@ -1183,6 +1234,9 @@ discard block |
||
| 1183 | 1234 | fclose($f); |
| 1184 | 1235 | } |
| 1185 | 1236 | |
| 1237 | +/** |
|
| 1238 | + * @param resource $f |
|
| 1239 | + */ |
|
| 1186 | 1240 | function sql_export_structure($f, $table) |
| 1187 | 1241 | { |
| 1188 | 1242 | $rs = sql("SHOW CREATE TABLE `&1`", $table); |
@@ -1198,6 +1252,9 @@ discard block |
||
| 1198 | 1252 | fwrite($f, $sTableSql . " ;\n"); |
| 1199 | 1253 | } |
| 1200 | 1254 | |
| 1255 | +/** |
|
| 1256 | + * @param string $filename |
|
| 1257 | + */ |
|
| 1201 | 1258 | function sql_export_structure_to_file($filename, $table) |
| 1202 | 1259 | { |
| 1203 | 1260 | $f = fopen($filename, 'w'); |
@@ -1271,6 +1328,9 @@ discard block |
||
| 1271 | 1328 | } |
| 1272 | 1329 | |
| 1273 | 1330 | // test if a function or procedure exists |
| 1331 | +/** |
|
| 1332 | + * @param string $type |
|
| 1333 | + */ |
|
| 1274 | 1334 | function sql_fp_exists($type, $name) |
| 1275 | 1335 | { |
| 1276 | 1336 | global $opt; |
@@ -1275,7 +1275,7 @@ |
||
| 1275 | 1275 | { |
| 1276 | 1276 | global $opt; |
| 1277 | 1277 | |
| 1278 | - $rs = sql("SHOW $type STATUS LIKE '&1'", $name); |
|
| 1278 | + $rs = sql("show $type STATUS LIKE '&1'", $name); |
|
| 1279 | 1279 | $r = sql_fetch_assoc($rs); |
| 1280 | 1280 | sql_free_result($rs); |
| 1281 | 1281 | |
@@ -185,10 +185,10 @@ discard block |
||
| 185 | 185 | // & escaped? |
| 186 | 186 | $escapesCount = 0; |
| 187 | 187 | while ((($nextarg - $escapesCount - 1) > 0) && (substr($sql, $nextarg - $escapesCount - 1, 1) == '\\')) { |
| 188 | - $escapesCount ++; |
|
| 188 | + $escapesCount++; |
|
| 189 | 189 | } |
| 190 | 190 | if (($escapesCount % 2) == 1) { |
| 191 | - $nextarg ++; |
|
| 191 | + $nextarg++; |
|
| 192 | 192 | } else { |
| 193 | 193 | $nextchar = substr($sql, $nextarg + 1, 1); |
| 194 | 194 | if (is_numeric($nextchar)) { |
@@ -199,7 +199,7 @@ discard block |
||
| 199 | 199 | while (preg_match('/^[0-9]{1}/', $nextchar) == 1) { |
| 200 | 200 | $arg .= $nextchar; |
| 201 | 201 | |
| 202 | - $arglength ++; |
|
| 202 | + $arglength++; |
|
| 203 | 203 | $nextchar = substr($sql, $nextarg + $arglength + 1, 1); |
| 204 | 204 | } |
| 205 | 205 | |
@@ -225,13 +225,13 @@ discard block |
||
| 225 | 225 | // strip apostroph and insert NULL |
| 226 | 226 | $filtered_sql = substr($filtered_sql, 0, strlen($filtered_sql) - 1); |
| 227 | 227 | $filtered_sql .= 'NULL'; |
| 228 | - $sqlpos ++; |
|
| 228 | + $sqlpos++; |
|
| 229 | 229 | } else { |
| 230 | 230 | $filtered_sql .= 'NULL'; |
| 231 | 231 | } |
| 232 | 232 | } |
| 233 | 233 | |
| 234 | - $sqlpos ++; |
|
| 234 | + $sqlpos++; |
|
| 235 | 235 | } else { |
| 236 | 236 | $arglength = 0; |
| 237 | 237 | $arg = ''; |
@@ -241,7 +241,7 @@ discard block |
||
| 241 | 241 | while (preg_match('/^[a-zA-Z0-9_]{1}/', $nextchar) == 1) { |
| 242 | 242 | $arg .= $nextchar; |
| 243 | 243 | |
| 244 | - $arglength ++; |
|
| 244 | + $arglength++; |
|
| 245 | 245 | $nextchar = substr($sql, $nextarg + $arglength + 1, 1); |
| 246 | 246 | } |
| 247 | 247 | |
@@ -263,7 +263,7 @@ discard block |
||
| 263 | 263 | $filtered_sql .= '`'; |
| 264 | 264 | } |
| 265 | 265 | |
| 266 | - $filtered_sql .= sql_escape_backtick($opt['db']['placeholder']['tmpdb']) . '`.`' . sql_escape_backtick($db['temptables'][$arg]); |
|
| 266 | + $filtered_sql .= sql_escape_backtick($opt['db']['placeholder']['tmpdb']).'`.`'.sql_escape_backtick($db['temptables'][$arg]); |
|
| 267 | 267 | |
| 268 | 268 | if (substr($sql, $nextarg + $arglength + 1, 1) != '`') { |
| 269 | 269 | $filtered_sql .= '`'; |
@@ -288,12 +288,12 @@ discard block |
||
| 288 | 288 | $escapesCount = 0; |
| 289 | 289 | while ((($nextarg - $escapesCount - 1) > 0) |
| 290 | 290 | && (substr($filtered_sql, $nextarg - $escapesCount - 1, 1) == '\\')) { |
| 291 | - $escapesCount ++; |
|
| 291 | + $escapesCount++; |
|
| 292 | 292 | } |
| 293 | 293 | if (($escapesCount % 2) == 0) { |
| 294 | 294 | // strip escapes of & |
| 295 | - $filtered_sql = substr($filtered_sql, 0, $nextarg) . '&' . substr($filtered_sql, $nextarg + 2); |
|
| 296 | - $nextarg --; |
|
| 295 | + $filtered_sql = substr($filtered_sql, 0, $nextarg).'&'.substr($filtered_sql, $nextarg + 2); |
|
| 296 | + $nextarg--; |
|
| 297 | 297 | } |
| 298 | 298 | |
| 299 | 299 | $nextarg = strpos($filtered_sql, '\&', $nextarg + 2); |
@@ -310,7 +310,7 @@ discard block |
||
| 310 | 310 | */ |
| 311 | 311 | |
| 312 | 312 | if (isset($db['debug']) && ($db['debug'] == true)) { |
| 313 | - require_once $opt['rootpath'] . 'lib2/sqldebugger.class.php'; |
|
| 313 | + require_once $opt['rootpath'].'lib2/sqldebugger.class.php'; |
|
| 314 | 314 | $result = $sqldebugger->execute($filtered_sql, $dblink, ($dblink === $db['dblink_slave']), $db['slave_server']); |
| 315 | 315 | if ($result === false) { |
| 316 | 316 | sql_error($filtered_sql); |
@@ -318,7 +318,7 @@ discard block |
||
| 318 | 318 | } else { |
| 319 | 319 | // measure time |
| 320 | 320 | if ($opt['db']['warn']['time'] > 0) { |
| 321 | - require_once $opt['rootpath'] . 'lib2/bench.inc.php'; |
|
| 321 | + require_once $opt['rootpath'].'lib2/bench.inc.php'; |
|
| 322 | 322 | $cSqlExecution = new Cbench; |
| 323 | 323 | $cSqlExecution->start(); |
| 324 | 324 | } |
@@ -332,8 +332,8 @@ discard block |
||
| 332 | 332 | $cSqlExecution->stop(); |
| 333 | 333 | |
| 334 | 334 | if ($cSqlExecution->diff() > $opt['db']['warn']['time']) { |
| 335 | - $ua = isset($_SERVER['HTTP_USER_AGENT']) ? "\r\n" . $_SERVER['HTTP_USER_AGENT'] : ""; |
|
| 336 | - sql_warn("execution took " . $cSqlExecution->diff() . " seconds" . $ua); |
|
| 335 | + $ua = isset($_SERVER['HTTP_USER_AGENT']) ? "\r\n".$_SERVER['HTTP_USER_AGENT'] : ""; |
|
| 336 | + sql_warn("execution took ".$cSqlExecution->diff()." seconds".$ua); |
|
| 337 | 337 | } |
| 338 | 338 | } |
| 339 | 339 | } |
@@ -774,7 +774,7 @@ discard block |
||
| 774 | 774 | } |
| 775 | 775 | |
| 776 | 776 | if ($db['dblink'] !== false) { |
| 777 | - mysql_query("SET NAMES '" . mysql_real_escape_string($opt['charset']['mysql'], $db['dblink']) . "'", $db['dblink']); |
|
| 777 | + mysql_query("SET NAMES '".mysql_real_escape_string($opt['charset']['mysql'], $db['dblink'])."'", $db['dblink']); |
|
| 778 | 778 | |
| 779 | 779 | //database connection established ... set the used database |
| 780 | 780 | if (@mysql_select_db($opt['db']['placeholder']['db'], $db['dblink']) == false) { |
@@ -837,7 +837,7 @@ discard block |
||
| 837 | 837 | AND `online`= 1 |
| 838 | 838 | AND (TIMESTAMP(NOW())-TIMESTAMP(`last_check`)+`time_diff`<'&1') |
| 839 | 839 | ORDER BY `w` DESC LIMIT 1", |
| 840 | - - 1, |
|
| 840 | + -1, |
|
| 841 | 841 | $nMaxTimeDiff |
| 842 | 842 | ); |
| 843 | 843 | |
@@ -898,7 +898,7 @@ discard block |
||
| 898 | 898 | sql_error(); |
| 899 | 899 | } |
| 900 | 900 | |
| 901 | - mysql_query("SET NAMES '" . mysql_real_escape_string($opt['charset']['mysql'], $db['dblink_slave']) . "'", $db['dblink_slave']); |
|
| 901 | + mysql_query("SET NAMES '".mysql_real_escape_string($opt['charset']['mysql'], $db['dblink_slave'])."'", $db['dblink_slave']); |
|
| 902 | 902 | |
| 903 | 903 | // initialize temp tables on slave server |
| 904 | 904 | $rs = sqlf_slave("SELECT `threadid`, `name` FROM `sys_temptables` WHERE `threadid`='&1'", mysql_thread_id($db['dblink_slave'])); |
@@ -1010,7 +1010,7 @@ discard block |
||
| 1010 | 1010 | $errno = mysql_errno(); |
| 1011 | 1011 | $error = mysql_error(); |
| 1012 | 1012 | if ($sqlstatement != "") { |
| 1013 | - $error .= "\n\nSQL statement: " . $sqlstatement; |
|
| 1013 | + $error .= "\n\nSQL statement: ".$sqlstatement; |
|
| 1014 | 1014 | } |
| 1015 | 1015 | |
| 1016 | 1016 | if ($db['error'] == true) { |
@@ -1019,7 +1019,7 @@ discard block |
||
| 1019 | 1019 | // could not load translations from database) |
| 1020 | 1020 | |
| 1021 | 1021 | if ($opt['db']['error']['display'] == true) { |
| 1022 | - $errmsg = 'MySQL error recursion (' . $errno . '): ' . $error; |
|
| 1022 | + $errmsg = 'MySQL error recursion ('.$errno.'): '.$error; |
|
| 1023 | 1023 | } else { |
| 1024 | 1024 | $errmsg = ""; |
| 1025 | 1025 | } |
@@ -1034,13 +1034,13 @@ discard block |
||
| 1034 | 1034 | } |
| 1035 | 1035 | |
| 1036 | 1036 | if ($opt['db']['error']['mail'] != '') { |
| 1037 | - $subject = '[' . $opt['page']['domain'] . '] SQL error'; |
|
| 1037 | + $subject = '['.$opt['page']['domain'].'] SQL error'; |
|
| 1038 | 1038 | if (admin_errormail($opt['db']['error']['mail'], |
| 1039 | 1039 | $subject, |
| 1040 | - str_replace("\n", "\r\n", $error) . "\n" . print_r(debug_backtrace(), true), |
|
| 1041 | - "From: " . $opt['mail']['from'] |
|
| 1040 | + str_replace("\n", "\r\n", $error)."\n".print_r(debug_backtrace(), true), |
|
| 1041 | + "From: ".$opt['mail']['from'] |
|
| 1042 | 1042 | )) { |
| 1043 | - require_once $opt['rootpath'] . 'lib2/mail.class.php'; |
|
| 1043 | + require_once $opt['rootpath'].'lib2/mail.class.php'; |
|
| 1044 | 1044 | |
| 1045 | 1045 | $mail = new mail(); |
| 1046 | 1046 | $mail->subject = $subject; |
@@ -1060,13 +1060,13 @@ discard block |
||
| 1060 | 1060 | if ($opt['gui'] == GUI_HTML) { |
| 1061 | 1061 | if (isset($tpl)) { |
| 1062 | 1062 | if ($opt['db']['error']['display'] == true) { |
| 1063 | - $tpl->error('MySQL error (' . $errno . '): ' . $error); |
|
| 1063 | + $tpl->error('MySQL error ('.$errno.'): '.$error); |
|
| 1064 | 1064 | } else { |
| 1065 | 1065 | $tpl->error('A database command could not be performed.'); |
| 1066 | 1066 | } |
| 1067 | 1067 | } else { |
| 1068 | 1068 | if ($opt['db']['error']['display'] == true) { |
| 1069 | - die('<html><body>' . htmlspecialchars('MySQL error (' . $errno . '): ' . str_replace("\n,", "<br />", $error)) . '</body></html>'); |
|
| 1069 | + die('<html><body>'.htmlspecialchars('MySQL error ('.$errno.'): '.str_replace("\n,", "<br />", $error)).'</body></html>'); |
|
| 1070 | 1070 | } else { |
| 1071 | 1071 | die('<html><body>A database command could not be performed</body></html>'); |
| 1072 | 1072 | } |
@@ -1074,7 +1074,7 @@ discard block |
||
| 1074 | 1074 | } else { |
| 1075 | 1075 | // CLI script, simple text output |
| 1076 | 1076 | if ($opt['db']['error']['display'] == true) { |
| 1077 | - die('MySQL error (' . $errno . '): ' . $error . "\n"); |
|
| 1077 | + die('MySQL error ('.$errno.'): '.$error."\n"); |
|
| 1078 | 1078 | } else { |
| 1079 | 1079 | die("A database command could not be performed.\n"); |
| 1080 | 1080 | } |
@@ -1086,13 +1086,13 @@ discard block |
||
| 1086 | 1086 | global $opt; |
| 1087 | 1087 | |
| 1088 | 1088 | if ($opt['db']['error']['mail'] != '') { |
| 1089 | - $subject = '[' . $opt['page']['domain'] . '] SQL error'; |
|
| 1089 | + $subject = '['.$opt['page']['domain'].'] SQL error'; |
|
| 1090 | 1090 | if (admin_errormail($opt['db']['error']['mail'], |
| 1091 | 1091 | $subject, |
| 1092 | - $warnmessage . "\n" . print_r(debug_backtrace(), true), |
|
| 1093 | - "From: " . $opt['mail']['from'] |
|
| 1092 | + $warnmessage."\n".print_r(debug_backtrace(), true), |
|
| 1093 | + "From: ".$opt['mail']['from'] |
|
| 1094 | 1094 | )) { |
| 1095 | - require_once $opt['rootpath'] . 'lib2/mail.class.php'; |
|
| 1095 | + require_once $opt['rootpath'].'lib2/mail.class.php'; |
|
| 1096 | 1096 | $mail = new mail(); |
| 1097 | 1097 | $mail->name = 'sql_warn'; |
| 1098 | 1098 | $mail->subject = $subject; |
@@ -1112,7 +1112,7 @@ discard block |
||
| 1112 | 1112 | fwrite($f, "SET NAMES 'utf8';\n"); |
| 1113 | 1113 | |
| 1114 | 1114 | if ($truncate == true) { |
| 1115 | - fwrite($f, "TRUNCATE TABLE `" . sql_escape($table) . "`;\n"); |
|
| 1115 | + fwrite($f, "TRUNCATE TABLE `".sql_escape($table)."`;\n"); |
|
| 1116 | 1116 | } |
| 1117 | 1117 | |
| 1118 | 1118 | while ($r = sql_fetch_assoc($rs)) { |
@@ -1120,19 +1120,19 @@ discard block |
||
| 1120 | 1120 | $values = array(); |
| 1121 | 1121 | |
| 1122 | 1122 | foreach ($r as $k => $v) { |
| 1123 | - $fields[] = '`' . sql_escape($k) . '`'; |
|
| 1123 | + $fields[] = '`'.sql_escape($k).'`'; |
|
| 1124 | 1124 | if ($v === null) { |
| 1125 | 1125 | $values[] = "NULL"; |
| 1126 | 1126 | } else { |
| 1127 | - $values[] = "'" . sql_escape($v) . "'"; |
|
| 1127 | + $values[] = "'".sql_escape($v)."'"; |
|
| 1128 | 1128 | } |
| 1129 | 1129 | } |
| 1130 | 1130 | unset($r); |
| 1131 | 1131 | |
| 1132 | 1132 | fwrite( |
| 1133 | 1133 | $f, |
| 1134 | - "INSERT INTO `" . sql_escape($table) . "` (" . implode(', ', $fields) . ")" |
|
| 1135 | - . " VALUES (" . implode(', ', $values) . ");\n" |
|
| 1134 | + "INSERT INTO `".sql_escape($table)."` (".implode(', ', $fields).")" |
|
| 1135 | + . " VALUES (".implode(', ', $values).");\n" |
|
| 1136 | 1136 | ); |
| 1137 | 1137 | } |
| 1138 | 1138 | } |
@@ -1143,14 +1143,14 @@ discard block |
||
| 1143 | 1143 | $rsIndex = sql("SHOW INDEX FROM `&1`", $table); |
| 1144 | 1144 | while ($r = sql_fetch_assoc($rsIndex)) { |
| 1145 | 1145 | if ($r['Key_name'] == 'PRIMARY') { |
| 1146 | - $primary[] = '`' . sql_escape($r['Column_name']) . '` ASC'; |
|
| 1146 | + $primary[] = '`'.sql_escape($r['Column_name']).'` ASC'; |
|
| 1147 | 1147 | } |
| 1148 | 1148 | } |
| 1149 | 1149 | sql_free_result($rsIndex); |
| 1150 | 1150 | |
| 1151 | - $sql = "SELECT * FROM `" . sql_escape($table) . "`"; |
|
| 1151 | + $sql = "SELECT * FROM `".sql_escape($table)."`"; |
|
| 1152 | 1152 | if (count($primary) > 0) { |
| 1153 | - $sql .= ' ORDER BY ' . implode(', ', $primary); |
|
| 1153 | + $sql .= ' ORDER BY '.implode(', ', $primary); |
|
| 1154 | 1154 | } |
| 1155 | 1155 | |
| 1156 | 1156 | $rs = sql($sql); |
@@ -1196,8 +1196,8 @@ discard block |
||
| 1196 | 1196 | $sTableSql = preg_replace("/,\n +?(KEY )?`okapi_syncbase`.+?(,)?\n/", "\\2\n", $sTableSql); |
| 1197 | 1197 | |
| 1198 | 1198 | fwrite($f, "SET NAMES 'utf8';\n"); |
| 1199 | - fwrite($f, "DROP TABLE IF EXISTS `" . sql_escape($table) . "`;\n"); |
|
| 1200 | - fwrite($f, $sTableSql . " ;\n"); |
|
| 1199 | + fwrite($f, "DROP TABLE IF EXISTS `".sql_escape($table)."`;\n"); |
|
| 1200 | + fwrite($f, $sTableSql." ;\n"); |
|
| 1201 | 1201 | } |
| 1202 | 1202 | |
| 1203 | 1203 | function sql_export_structure_to_file($filename, $table) |
@@ -58,6 +58,9 @@ |
||
| 58 | 58 | // |
| 59 | 59 | // If $wrap is > 0, longer lines will be wrapped to new lines. |
| 60 | 60 | |
| 61 | +/** |
|
| 62 | + * @param integer $wrap |
|
| 63 | + */ |
|
| 61 | 64 | function html2plaintext($text, $texthtml0, $wrap) |
| 62 | 65 | { |
| 63 | 66 | global $opt, $smiley; |
@@ -83,10 +83,10 @@ discard block |
||
| 83 | 83 | $text = html_entity_decode($text, ENT_COMPAT, 'UTF-8'); |
| 84 | 84 | } else { |
| 85 | 85 | // convert smilies ... |
| 86 | - for ($n = 0; $n < count($smiley['image']); $n ++) { |
|
| 86 | + for ($n = 0; $n < count($smiley['image']); $n++) { |
|
| 87 | 87 | $text = mb_ereg_replace( |
| 88 | - "<img [^>]*?src=[^>]+?" . str_replace('.', '\.', $smiley['file'][$n]) . "[^>]+?>", |
|
| 89 | - "[s![" . $smiley['text'][$n] . "]!s]", |
|
| 88 | + "<img [^>]*?src=[^>]+?".str_replace('.', '\.', $smiley['file'][$n])."[^>]+?>", |
|
| 89 | + "[s![".$smiley['text'][$n]."]!s]", |
|
| 90 | 90 | $text |
| 91 | 91 | ); |
| 92 | 92 | // the [s[ ]s] is needed to protect the spaces around the smileys |
@@ -118,5 +118,5 @@ discard block |
||
| 118 | 118 | |
| 119 | 119 | function editorJsPath() |
| 120 | 120 | { |
| 121 | - return 'resource2/ocstyle/js/editor.js?ft=' . filemtime('resource2/ocstyle/js/editor.js'); |
|
| 121 | + return 'resource2/ocstyle/js/editor.js?ft='.filemtime('resource2/ocstyle/js/editor.js'); |
|
| 122 | 122 | } |
@@ -106,6 +106,10 @@ |
||
| 106 | 106 | // throttle admin error mails; |
| 107 | 107 | // currently used only for SQL errors and warnings |
| 108 | 108 | |
| 109 | +/** |
|
| 110 | + * @param string $errortype |
|
| 111 | + * @param string $message |
|
| 112 | + */ |
|
| 109 | 113 | function admin_errormail($to, $errortype, $message, $headers) |
| 110 | 114 | { |
| 111 | 115 | global $opt; |
@@ -39,7 +39,7 @@ discard block |
||
| 39 | 39 | $errmsg = ""; |
| 40 | 40 | } |
| 41 | 41 | |
| 42 | - require __DIR__ . '/../html/error.php'; |
|
| 42 | + require __DIR__.'/../html/error.php'; |
|
| 43 | 43 | exit; |
| 44 | 44 | } |
| 45 | 45 | } |
@@ -67,8 +67,8 @@ discard block |
||
| 67 | 67 | ) { |
| 68 | 68 | $error_handled = true; |
| 69 | 69 | |
| 70 | - $error = "(" . $error['type'] . ") " . $error['message'] . |
|
| 71 | - " at line " . $error['line'] . " of " . $error['file']; |
|
| 70 | + $error = "(".$error['type'].") ".$error['message']. |
|
| 71 | + " at line ".$error['line']." of ".$error['file']; |
|
| 72 | 72 | php_errormail($error); |
| 73 | 73 | |
| 74 | 74 | $errtitle = "PHP-Fehler"; |
@@ -77,7 +77,7 @@ discard block |
||
| 77 | 77 | $errmsg = $error; |
| 78 | 78 | } |
| 79 | 79 | |
| 80 | - require __DIR__ . '/../html/error.php'; |
|
| 80 | + require __DIR__.'/../html/error.php'; |
|
| 81 | 81 | } |
| 82 | 82 | } |
| 83 | 83 | |
@@ -94,7 +94,7 @@ discard block |
||
| 94 | 94 | global $opt, $sql_errormail, $absolute_server_URI; |
| 95 | 95 | |
| 96 | 96 | $sendMail = true; |
| 97 | - $subject = '[' . $opt['page']['domain'] . '] PHP error'; |
|
| 97 | + $subject = '['.$opt['page']['domain'].'] PHP error'; |
|
| 98 | 98 | |
| 99 | 99 | if (isset($opt['db']['error']['mail']) && $opt['db']['error']['mail'] != '') { |
| 100 | 100 | $sendMail = mb_send_mail($opt['db']['error']['mail'], $subject, $errmsg); |
@@ -114,10 +114,10 @@ discard block |
||
| 114 | 114 | function admin_errormail($to, $errortype, $message, $headers) |
| 115 | 115 | { |
| 116 | 116 | global $opt; |
| 117 | - $errorlog_dir = $opt['rootpath'] . 'var/errorlog'; |
|
| 118 | - $errorlog_path = $errorlog_dir . "/errorlog-" . date("Y-m-d"); |
|
| 117 | + $errorlog_dir = $opt['rootpath'].'var/errorlog'; |
|
| 118 | + $errorlog_path = $errorlog_dir."/errorlog-".date("Y-m-d"); |
|
| 119 | 119 | |
| 120 | - $error_mail_limit = 32768; // send max 32 KB = ca. 5-20 errors per day/logfile |
|
| 120 | + $error_mail_limit = 32768; // send max 32 KB = ca. 5-20 errors per day/logfile |
|
| 121 | 121 | |
| 122 | 122 | // All errors which may happen here are ignored, to avoid error recursions. |
| 123 | 123 | |
@@ -125,7 +125,7 @@ discard block |
||
| 125 | 125 | @mkdir($errorlog_dir); |
| 126 | 126 | } |
| 127 | 127 | $old_logsize = @filesize($errorlog_path) + 0; |
| 128 | - $msg = date("Y-m-d H:i:s.u") . " " . $errortype . "\n" . $message . "\n" . |
|
| 128 | + $msg = date("Y-m-d H:i:s.u")." ".$errortype."\n".$message."\n". |
|
| 129 | 129 | "-------------------------------------------------------------------------\n\n"; |
| 130 | 130 | try { |
| 131 | 131 | error_log( |
@@ -143,9 +143,9 @@ discard block |
||
| 143 | 143 | if ($old_logsize < $error_mail_limit && $new_logsize >= $error_mail_limit) { |
| 144 | 144 | mb_send_mail( |
| 145 | 145 | $to, |
| 146 | - "too many " . $errortype, |
|
| 147 | - "Errors/Warnings are recorded in " . $errorlog_path . ".\n" . |
|
| 148 | - "Email Reporting is DISABLED for today now. Please check the logfile\n" . |
|
| 146 | + "too many ".$errortype, |
|
| 147 | + "Errors/Warnings are recorded in ".$errorlog_path.".\n". |
|
| 148 | + "Email Reporting is DISABLED for today now. Please check the logfile\n". |
|
| 149 | 149 | "and RENAME or delete it when done, so that logging is re-enabled.", |
| 150 | 150 | $headers |
| 151 | 151 | ); |
@@ -26,6 +26,9 @@ discard block |
||
| 26 | 26 | * Returns: if $file specified - true if OK |
| 27 | 27 | if $file not specified - image data |
| 28 | 28 | */ |
| 29 | +/** |
|
| 30 | + * @param resource $img |
|
| 31 | + */ |
|
| 29 | 32 | function imagebmp($img,$file="",$RLE=0) |
| 30 | 33 | { |
| 31 | 34 | |
@@ -463,6 +466,9 @@ discard block |
||
| 463 | 466 | |
| 464 | 467 | |
| 465 | 468 | |
| 469 | +/** |
|
| 470 | + * @param integer $byte |
|
| 471 | + */ |
|
| 466 | 472 | function RetBits($byte,$start,$len) |
| 467 | 473 | { |
| 468 | 474 | $bin=decbin8($byte); |
@@ -474,6 +480,10 @@ discard block |
||
| 474 | 480 | |
| 475 | 481 | |
| 476 | 482 | $CurrentBit=0; |
| 483 | +/** |
|
| 484 | + * @param resource $f |
|
| 485 | + * @param integer $count |
|
| 486 | + */ |
|
| 477 | 487 | function freadbits($f,$count) |
| 478 | 488 | { |
| 479 | 489 | global $CurrentBit,$SMode; |
@@ -505,6 +515,10 @@ discard block |
||
| 505 | 515 | { |
| 506 | 516 | return chr($n & 255).chr(($n >> 8) & 255).chr(($n >> 16) & 255).chr(($n >> 24) & 255); |
| 507 | 517 | } |
| 518 | + |
|
| 519 | + /** |
|
| 520 | + * @param integer $n |
|
| 521 | + */ |
|
| 508 | 522 | function int_to_word($n) |
| 509 | 523 | { |
| 510 | 524 | return chr($n & 255).chr(($n >> 8) & 255); |
@@ -516,6 +530,9 @@ discard block |
||
| 516 | 530 | return decbinx($d,8); |
| 517 | 531 | }; |
| 518 | 532 | |
| 533 | +/** |
|
| 534 | + * @param integer $n |
|
| 535 | + */ |
|
| 519 | 536 | function decbinx($d,$n) |
| 520 | 537 | { |
| 521 | 538 | $bin=decbin($d); |
@@ -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 | |
@@ -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,14 +80,16 @@ discard block |
||
| 76 | 80 | |
| 77 | 81 | $CC=$ColorCount; |
| 78 | 82 | $sl1=strlen($ret); |
| 79 | - if($CC==0) $CC=256; |
|
| 80 | - if($BitCount<24) |
|
| 81 | - { |
|
| 83 | + if($CC==0) { |
|
| 84 | + $CC=256; |
|
| 85 | + } |
|
| 86 | + if($BitCount<24) { |
|
| 82 | 87 | $ColorTotal=imagecolorstotal($img); |
| 83 | - if($IsTransparent) $ColorTotal--; |
|
| 88 | + if($IsTransparent) { |
|
| 89 | + $ColorTotal--; |
|
| 90 | + } |
|
| 84 | 91 | |
| 85 | - for($p=0;$p<$ColorTotal;$p++) |
|
| 86 | - { |
|
| 92 | + for($p=0;$p<$ColorTotal;$p++) { |
|
| 87 | 93 | $color=imagecolorsforindex($img,$p); |
| 88 | 94 | $ret.=inttobyte($color["blue"]); |
| 89 | 95 | $ret.=inttobyte($color["green"]); |
@@ -92,8 +98,7 @@ discard block |
||
| 92 | 98 | }; |
| 93 | 99 | |
| 94 | 100 | $CT=$ColorTotal; |
| 95 | - for($p=$ColorTotal;$p<$CC;$p++) |
|
| 96 | - { |
|
| 101 | + for($p=$ColorTotal;$p<$CC;$p++) { |
|
| 97 | 102 | $ret.=inttobyte(0); |
| 98 | 103 | $ret.=inttobyte(0); |
| 99 | 104 | $ret.=inttobyte(0); |
@@ -102,75 +107,63 @@ discard block |
||
| 102 | 107 | }; |
| 103 | 108 | |
| 104 | 109 | |
| 105 | -if($BitCount<=8) |
|
| 106 | -{ |
|
| 110 | +if($BitCount<=8) { |
|
| 107 | 111 | |
| 108 | - for($y=$Height-1;$y>=0;$y--) |
|
| 109 | - { |
|
| 112 | + for($y=$Height-1;$y>=0;$y--) { |
|
| 110 | 113 | $bWrite=""; |
| 111 | - for($x=0;$x<$Width;$x++) |
|
| 112 | - { |
|
| 114 | + for($x=0;$x<$Width;$x++) { |
|
| 113 | 115 | $color=imagecolorat($img,$x,$y); |
| 114 | 116 | $bWrite.=decbinx($color,$BitCount); |
| 115 | - if(strlen($bWrite)==8) |
|
| 116 | - { |
|
| 117 | + if(strlen($bWrite)==8) { |
|
| 117 | 118 | $retd.=inttobyte(bindec($bWrite)); |
| 118 | 119 | $bWrite=""; |
| 119 | 120 | }; |
| 120 | 121 | }; |
| 121 | 122 | |
| 122 | - if((strlen($bWrite)<8)and(strlen($bWrite)!=0)) |
|
| 123 | - { |
|
| 123 | + if((strlen($bWrite)<8)and(strlen($bWrite)!=0)) { |
|
| 124 | 124 | $sl=strlen($bWrite); |
| 125 | - for($t=0;$t<8-$sl;$t++) |
|
| 126 | - $sl.="0"; |
|
| 125 | + for($t=0;$t<8-$sl;$t++) { |
|
| 126 | + $sl.="0"; |
|
| 127 | + } |
|
| 127 | 128 | $retd.=inttobyte(bindec($bWrite)); |
| 128 | 129 | }; |
| 129 | - for($z=0;$z<$Zbytek;$z++) |
|
| 130 | - $retd.=inttobyte(0); |
|
| 130 | + for($z=0;$z<$Zbytek;$z++) { |
|
| 131 | + $retd.=inttobyte(0); |
|
| 132 | + } |
|
| 131 | 133 | }; |
| 132 | 134 | }; |
| 133 | 135 | |
| 134 | -if(($RLE==1)and($BitCount==8)) |
|
| 135 | -{ |
|
| 136 | - for($t=0;$t<strlen($retd);$t+=4) |
|
| 137 | - { |
|
| 138 | - if($t!=0) |
|
| 139 | - if(($t)%$Width==0) |
|
| 136 | +if(($RLE==1)and($BitCount==8)) { |
|
| 137 | + for($t=0;$t<strlen($retd);$t+=4) { |
|
| 138 | + if($t!=0) { |
|
| 139 | + if(($t)%$Width==0) |
|
| 140 | 140 | $ret.=chr(0).chr(0); |
| 141 | + } |
|
| 141 | 142 | |
| 142 | - if(($t+5)%$Width==0) |
|
| 143 | - { |
|
| 143 | + if(($t+5)%$Width==0) { |
|
| 144 | 144 | $ret.=chr(0).chr(5).substr($retd,$t,5).chr(0); |
| 145 | 145 | $t+=1; |
| 146 | 146 | } |
| 147 | - if(($t+6)%$Width==0) |
|
| 148 | - { |
|
| 147 | + if(($t+6)%$Width==0) { |
|
| 149 | 148 | $ret.=chr(0).chr(6).substr($retd,$t,6); |
| 150 | 149 | $t+=2; |
| 151 | - } |
|
| 152 | - else |
|
| 153 | - { |
|
| 150 | + } else { |
|
| 154 | 151 | $ret.=chr(0).chr(4).substr($retd,$t,4); |
| 155 | 152 | }; |
| 156 | 153 | }; |
| 157 | 154 | $ret.=chr(0).chr(1); |
| 158 | -} |
|
| 159 | -else |
|
| 160 | -{ |
|
| 155 | +} else { |
|
| 161 | 156 | $ret.=$retd; |
| 162 | 157 | }; |
| 163 | 158 | |
| 164 | 159 | |
| 165 | - if($BitCount==24) |
|
| 166 | - { |
|
| 167 | - for($z=0;$z<$Zbytek;$z++) |
|
| 168 | - $Dopl.=chr(0); |
|
| 160 | + if($BitCount==24) { |
|
| 161 | + for($z=0;$z<$Zbytek;$z++) { |
|
| 162 | + $Dopl.=chr(0); |
|
| 163 | + } |
|
| 169 | 164 | |
| 170 | - for($y=$Height-1;$y>=0;$y--) |
|
| 171 | - { |
|
| 172 | - for($x=0;$x<$Width;$x++) |
|
| 173 | - { |
|
| 165 | + for($y=$Height-1;$y>=0;$y--) { |
|
| 166 | + for($x=0;$x<$Width;$x++) { |
|
| 174 | 167 | $color=imagecolorsforindex($img,ImageColorAt($img,$x,$y)); |
| 175 | 168 | $ret.=chr($color["blue"]).chr($color["green"]).chr($color["red"]); |
| 176 | 169 | } |
@@ -179,15 +172,12 @@ discard block |
||
| 179 | 172 | |
| 180 | 173 | }; |
| 181 | 174 | |
| 182 | - if($file!="") |
|
| 183 | - { |
|
| 175 | + if($file!="") { |
|
| 184 | 176 | $r=($f=fopen($file,"w")); |
| 185 | 177 | $r=$r and fwrite($f,$ret); |
| 186 | 178 | $r=$r and fclose($f); |
| 187 | 179 | return $r; |
| 188 | - } |
|
| 189 | - else |
|
| 190 | - { |
|
| 180 | + } else { |
|
| 191 | 181 | echo $ret; |
| 192 | 182 | }; |
| 193 | 183 | }; |
@@ -211,8 +201,7 @@ discard block |
||
| 211 | 201 | $f=fopen($file,"r"); |
| 212 | 202 | $Header=fread($f,2); |
| 213 | 203 | |
| 214 | -if($Header=="BM") |
|
| 215 | -{ |
|
| 204 | +if($Header=="BM") { |
|
| 216 | 205 | $Size=freaddword($f); |
| 217 | 206 | $Reserved1=freadword($f); |
| 218 | 207 | $Reserved2=freadword($f); |
@@ -230,12 +219,10 @@ discard block |
||
| 230 | 219 | $NumberOfPalettesUsed=freaddword($f); |
| 231 | 220 | $NumberOfImportantColors=freaddword($f); |
| 232 | 221 | |
| 233 | -if($biBitCount<24) |
|
| 234 | - { |
|
| 222 | +if($biBitCount<24) { |
|
| 235 | 223 | $img=imagecreate($Width,$Height); |
| 236 | 224 | $Colors=pow(2,$biBitCount); |
| 237 | - for($p=0;$p<$Colors;$p++) |
|
| 238 | - { |
|
| 225 | + for($p=0;$p<$Colors;$p++) { |
|
| 239 | 226 | $B=freadbyte($f); |
| 240 | 227 | $G=freadbyte($f); |
| 241 | 228 | $R=freadbyte($f); |
@@ -246,35 +233,34 @@ discard block |
||
| 246 | 233 | |
| 247 | 234 | |
| 248 | 235 | |
| 249 | -if($RLECompression==0) |
|
| 250 | -{ |
|
| 236 | +if($RLECompression==0) { |
|
| 251 | 237 | $Zbytek=(4-ceil(($Width/(8/$biBitCount)))%4)%4; |
| 252 | 238 | |
| 253 | -for($y=$Height-1;$y>=0;$y--) |
|
| 254 | - { |
|
| 239 | +for($y=$Height-1;$y>=0;$y--) { |
|
| 255 | 240 | $CurrentBit=0; |
| 256 | - for($x=0;$x<$Width;$x++) |
|
| 257 | - { |
|
| 241 | + for($x=0;$x<$Width;$x++) { |
|
| 258 | 242 | $C=freadbits($f,$biBitCount); |
| 259 | 243 | imagesetpixel($img,$x,$y,$Palette[$C]); |
| 260 | 244 | }; |
| 261 | 245 | if($CurrentBit!=0) {freadbyte($f);}; |
| 262 | - for($g=0;$g<$Zbytek;$g++) |
|
| 263 | - freadbyte($f); |
|
| 246 | + for($g=0;$g<$Zbytek;$g++) { |
|
| 247 | + freadbyte($f); |
|
| 248 | + } |
|
| 264 | 249 | }; |
| 265 | 250 | |
| 266 | 251 | }; |
| 267 | 252 | }; |
| 268 | 253 | |
| 269 | 254 | |
| 270 | -if($RLECompression==1) //$BI_RLE8 |
|
| 255 | +if($RLECompression==1) { |
|
| 256 | + //$BI_RLE8 |
|
| 271 | 257 | { |
| 272 | 258 | $y=$Height; |
| 259 | +} |
|
| 273 | 260 | |
| 274 | 261 | $pocetb=0; |
| 275 | 262 | |
| 276 | -while(true) |
|
| 277 | -{ |
|
| 263 | +while(true) { |
|
| 278 | 264 | $y--; |
| 279 | 265 | $prefix=freadbyte($f); |
| 280 | 266 | $suffix=freadbyte($f); |
@@ -282,33 +268,38 @@ discard block |
||
| 282 | 268 | |
| 283 | 269 | $echoit=false; |
| 284 | 270 | |
| 285 | -if($echoit)echo "Prefix: $prefix Suffix: $suffix<BR>"; |
|
| 286 | -if(($prefix==0)and($suffix==1)) break; |
|
| 287 | -if(feof($f)) break; |
|
| 271 | +if($echoit) { |
|
| 272 | + echo "Prefix: $prefix Suffix: $suffix<BR>"; |
|
| 273 | +} |
|
| 274 | +if(($prefix==0)and($suffix==1)) { |
|
| 275 | + break; |
|
| 276 | +} |
|
| 277 | +if(feof($f)) { |
|
| 278 | + break; |
|
| 279 | +} |
|
| 288 | 280 | |
| 289 | -while(!(($prefix==0)and($suffix==0))) |
|
| 290 | -{ |
|
| 291 | - if($prefix==0) |
|
| 292 | - { |
|
| 281 | +while(!(($prefix==0)and($suffix==0))) { |
|
| 282 | + if($prefix==0) { |
|
| 293 | 283 | $pocet=$suffix; |
| 294 | 284 | $Data.=fread($f,$pocet); |
| 295 | 285 | $pocetb+=$pocet; |
| 296 | 286 | if($pocetb%2==1) {freadbyte($f); $pocetb++;}; |
| 297 | 287 | }; |
| 298 | - if($prefix>0) |
|
| 299 | - { |
|
| 288 | + if($prefix>0) { |
|
| 300 | 289 | $pocet=$prefix; |
| 301 | - for($r=0;$r<$pocet;$r++) |
|
| 302 | - $Data.=chr($suffix); |
|
| 290 | + for($r=0;$r<$pocet;$r++) { |
|
| 291 | + $Data.=chr($suffix); |
|
| 292 | + } |
|
| 303 | 293 | }; |
| 304 | 294 | $prefix=freadbyte($f); |
| 305 | 295 | $suffix=freadbyte($f); |
| 306 | 296 | $pocetb+=2; |
| 307 | - if($echoit) echo "Prefix: $prefix Suffix: $suffix<BR>"; |
|
| 308 | -}; |
|
| 297 | + if($echoit) { |
|
| 298 | + echo "Prefix: $prefix Suffix: $suffix<BR>"; |
|
| 299 | + } |
|
| 300 | + }; |
|
| 309 | 301 | |
| 310 | -for($x=0;$x<strlen($Data);$x++) |
|
| 311 | - { |
|
| 302 | +for($x=0;$x<strlen($Data);$x++) { |
|
| 312 | 303 | imagesetpixel($img,$x,$y,$Palette[ord($Data[$x])]); |
| 313 | 304 | }; |
| 314 | 305 | $Data=""; |
@@ -318,15 +309,16 @@ discard block |
||
| 318 | 309 | }; |
| 319 | 310 | |
| 320 | 311 | |
| 321 | -if($RLECompression==2) //$BI_RLE4 |
|
| 312 | +if($RLECompression==2) { |
|
| 313 | + //$BI_RLE4 |
|
| 322 | 314 | { |
| 323 | 315 | $y=$Height; |
| 316 | +} |
|
| 324 | 317 | $pocetb=0; |
| 325 | 318 | |
| 326 | 319 | /*while(!feof($f)) |
| 327 | 320 | echo freadbyte($f)."_".freadbyte($f)."<BR>";*/ |
| 328 | -while(true) |
|
| 329 | -{ |
|
| 321 | +while(true) { |
|
| 330 | 322 | //break; |
| 331 | 323 | $y--; |
| 332 | 324 | $prefix=freadbyte($f); |
@@ -335,35 +327,37 @@ discard block |
||
| 335 | 327 | |
| 336 | 328 | $echoit=false; |
| 337 | 329 | |
| 338 | -if($echoit)echo "Prefix: $prefix Suffix: $suffix<BR>"; |
|
| 339 | -if(($prefix==0)and($suffix==1)) break; |
|
| 340 | -if(feof($f)) break; |
|
| 330 | +if($echoit) { |
|
| 331 | + echo "Prefix: $prefix Suffix: $suffix<BR>"; |
|
| 332 | +} |
|
| 333 | +if(($prefix==0)and($suffix==1)) { |
|
| 334 | + break; |
|
| 335 | +} |
|
| 336 | +if(feof($f)) { |
|
| 337 | + break; |
|
| 338 | +} |
|
| 341 | 339 | |
| 342 | -while(!(($prefix==0)and($suffix==0))) |
|
| 343 | -{ |
|
| 344 | - if($prefix==0) |
|
| 345 | - { |
|
| 340 | +while(!(($prefix==0)and($suffix==0))) { |
|
| 341 | + if($prefix==0) { |
|
| 346 | 342 | $pocet=$suffix; |
| 347 | 343 | |
| 348 | 344 | $CurrentBit=0; |
| 349 | - for($h=0;$h<$pocet;$h++) |
|
| 350 | - $Data.=chr(freadbits($f,4)); |
|
| 351 | - if($CurrentBit!=0) freadbits($f,4); |
|
| 345 | + for($h=0;$h<$pocet;$h++) { |
|
| 346 | + $Data.=chr(freadbits($f,4)); |
|
| 347 | + } |
|
| 348 | + if($CurrentBit!=0) { |
|
| 349 | + freadbits($f,4); |
|
| 350 | + } |
|
| 352 | 351 | $pocetb+=ceil(($pocet/2)); |
| 353 | 352 | if($pocetb%2==1) {freadbyte($f); $pocetb++;}; |
| 354 | 353 | }; |
| 355 | - if($prefix>0) |
|
| 356 | - { |
|
| 354 | + if($prefix>0) { |
|
| 357 | 355 | $pocet=$prefix; |
| 358 | 356 | $i=0; |
| 359 | - for($r=0;$r<$pocet;$r++) |
|
| 360 | - { |
|
| 361 | - if($i%2==0) |
|
| 362 | - { |
|
| 357 | + for($r=0;$r<$pocet;$r++) { |
|
| 358 | + if($i%2==0) { |
|
| 363 | 359 | $Data.=chr($suffix%16); |
| 364 | - } |
|
| 365 | - else |
|
| 366 | - { |
|
| 360 | + } else { |
|
| 367 | 361 | $Data.=chr(floor($suffix/16)); |
| 368 | 362 | }; |
| 369 | 363 | $i++; |
@@ -372,11 +366,12 @@ discard block |
||
| 372 | 366 | $prefix=freadbyte($f); |
| 373 | 367 | $suffix=freadbyte($f); |
| 374 | 368 | $pocetb+=2; |
| 375 | - if($echoit) echo "Prefix: $prefix Suffix: $suffix<BR>"; |
|
| 376 | -}; |
|
| 369 | + if($echoit) { |
|
| 370 | + echo "Prefix: $prefix Suffix: $suffix<BR>"; |
|
| 371 | + } |
|
| 372 | + }; |
|
| 377 | 373 | |
| 378 | -for($x=0;$x<strlen($Data);$x++) |
|
| 379 | - { |
|
| 374 | +for($x=0;$x<strlen($Data);$x++) { |
|
| 380 | 375 | imagesetpixel($img,$x,$y,$Palette[ord($Data[$x])]); |
| 381 | 376 | }; |
| 382 | 377 | $Data=""; |
@@ -386,24 +381,24 @@ discard block |
||
| 386 | 381 | }; |
| 387 | 382 | |
| 388 | 383 | |
| 389 | - if($biBitCount==24) |
|
| 390 | -{ |
|
| 384 | + if($biBitCount==24) { |
|
| 391 | 385 | $img=imagecreatetruecolor($Width,$Height); |
| 392 | 386 | $Zbytek=$Width%4; |
| 393 | 387 | |
| 394 | - for($y=$Height-1;$y>=0;$y--) |
|
| 395 | - { |
|
| 396 | - for($x=0;$x<$Width;$x++) |
|
| 397 | - { |
|
| 388 | + for($y=$Height-1;$y>=0;$y--) { |
|
| 389 | + for($x=0;$x<$Width;$x++) { |
|
| 398 | 390 | $B=freadbyte($f); |
| 399 | 391 | $G=freadbyte($f); |
| 400 | 392 | $R=freadbyte($f); |
| 401 | 393 | $color=imagecolorexact($img,$R,$G,$B); |
| 402 | - if($color==-1) $color=imagecolorallocate($img,$R,$G,$B); |
|
| 394 | + if($color==-1) { |
|
| 395 | + $color=imagecolorallocate($img,$R,$G,$B); |
|
| 396 | + } |
|
| 403 | 397 | imagesetpixel($img,$x,$y,$color); |
| 404 | 398 | } |
| 405 | - for($z=0;$z<$Zbytek;$z++) |
|
| 406 | - freadbyte($f); |
|
| 399 | + for($z=0;$z<$Zbytek;$z++) { |
|
| 400 | + freadbyte($f); |
|
| 401 | + } |
|
| 407 | 402 | }; |
| 408 | 403 | }; |
| 409 | 404 | return $img; |
@@ -480,12 +475,9 @@ discard block |
||
| 480 | 475 | $Byte=freadbyte($f); |
| 481 | 476 | $LastCBit=$CurrentBit; |
| 482 | 477 | $CurrentBit+=$count; |
| 483 | - if($CurrentBit==8) |
|
| 484 | - { |
|
| 478 | + if($CurrentBit==8) { |
|
| 485 | 479 | $CurrentBit=0; |
| 486 | - } |
|
| 487 | - else |
|
| 488 | - { |
|
| 480 | + } else { |
|
| 489 | 481 | fseek($f,ftell($f)-1); |
| 490 | 482 | }; |
| 491 | 483 | return RetBits($Byte,$LastCBit,$count); |
@@ -494,10 +486,16 @@ discard block |
||
| 494 | 486 | |
| 495 | 487 | |
| 496 | 488 | 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"; |
|
| 489 | +{ |
|
| 490 | + $hRed=dechex($Red);if(strlen($hRed)==1) { |
|
| 491 | + $hRed="0$hRed"; |
|
| 492 | + } |
|
| 493 | + $hGreen=dechex($Green);if(strlen($hGreen)==1) { |
|
| 494 | + $hGreen="0$hGreen"; |
|
| 495 | + } |
|
| 496 | + $hBlue=dechex($Blue);if(strlen($hBlue)==1) { |
|
| 497 | + $hBlue="0$hBlue"; |
|
| 498 | + } |
|
| 501 | 499 | return($hRed.$hGreen.$hBlue); |
| 502 | 500 | }; |
| 503 | 501 | |
@@ -520,8 +518,9 @@ discard block |
||
| 520 | 518 | { |
| 521 | 519 | $bin=decbin($d); |
| 522 | 520 | $sbin=strlen($bin); |
| 523 | -for($j=0;$j<$n-$sbin;$j++) |
|
| 521 | +for($j=0;$j<$n-$sbin;$j++) { |
|
| 524 | 522 | $bin="0$bin"; |
| 523 | +} |
|
| 525 | 524 | return $bin; |
| 526 | 525 | }; |
| 527 | 526 | |
@@ -23,6 +23,10 @@ |
||
| 23 | 23 | return self::getAttrbutesListArrayInternal($cacheId, false, $firstLetterUppercase); |
| 24 | 24 | } |
| 25 | 25 | |
| 26 | + /** |
|
| 27 | + * @param boolean $bOnlySelectable |
|
| 28 | + * @param boolean $firstLetterUppercase |
|
| 29 | + */ |
|
| 26 | 30 | public static function getAttrbutesListArrayInternal($cacheId, $bOnlySelectable, $firstLetterUppercase) |
| 27 | 31 | { |
| 28 | 32 | global $opt; |
@@ -79,7 +79,7 @@ discard block |
||
| 79 | 79 | LEFT JOIN `sys_trans_text` AS `tt2` |
| 80 | 80 | ON `t2`.`id`=`tt2`.`trans_id` |
| 81 | 81 | AND `tt2`.`lang`='&1' |
| 82 | - WHERE `cache_attrib`.`group_id`='&2'" . $sAddWhereSql . " |
|
| 82 | + WHERE `cache_attrib`.`group_id`='&2'" . $sAddWhereSql." |
|
| 83 | 83 | AND NOT IFNULL(`cache_attrib`.`hidden`, 0)=1 |
| 84 | 84 | ORDER BY `cache_attrib`.`group_id` ASC", |
| 85 | 85 | $opt['template']['locale'], |
@@ -116,7 +116,7 @@ discard block |
||
| 116 | 116 | } |
| 117 | 117 | while ($rAttr = sql_fetch_assoc($rsAttr)) { |
| 118 | 118 | if ($firstLetterUppercase) { |
| 119 | - $rAttr['name'] = mb_strtoupper(mb_substr($rAttr['name'], 0, 1)) . mb_substr($rAttr['name'], 1); |
|
| 119 | + $rAttr['name'] = mb_strtoupper(mb_substr($rAttr['name'], 0, 1)).mb_substr($rAttr['name'], 1); |
|
| 120 | 120 | } |
| 121 | 121 | $attr[] = $rAttr; |
| 122 | 122 | if ($rAttr['search_default']) { |
@@ -411,9 +411,9 @@ |
||
| 411 | 411 | } |
| 412 | 412 | |
| 413 | 413 | /** |
| 414 | - * @param $cacheId |
|
| 415 | - * @param $start |
|
| 416 | - * @param $count |
|
| 414 | + * @param integer $cacheId |
|
| 415 | + * @param integer $start |
|
| 416 | + * @param integer $count |
|
| 417 | 417 | * @param bool $deleted |
| 418 | 418 | * @param bool $protect_old_coords |
| 419 | 419 | * |
@@ -8,8 +8,8 @@ discard block |
||
| 8 | 8 | * add/remove etc. is executed instantly |
| 9 | 9 | ***************************************************************************/ |
| 10 | 10 | |
| 11 | -require_once __DIR__ . '/logtypes.inc.php'; |
|
| 12 | -require_once __DIR__ . '/../../lib/cache.inc.php'; |
|
| 11 | +require_once __DIR__.'/logtypes.inc.php'; |
|
| 12 | +require_once __DIR__.'/../../lib/cache.inc.php'; |
|
| 13 | 13 | |
| 14 | 14 | class cache |
| 15 | 15 | { |
@@ -283,7 +283,7 @@ discard block |
||
| 283 | 283 | ); |
| 284 | 284 | if ($r = sql_fetch_assoc($rs)) { |
| 285 | 285 | if ($r['listing_outdated'] == 2) { |
| 286 | - $url = 'viewlogs.php?cacheid=' . $this->getCacheId() . '#log' . $r['id']; |
|
| 286 | + $url = 'viewlogs.php?cacheid='.$this->getCacheId().'#log'.$r['id']; |
|
| 287 | 287 | } |
| 288 | 288 | } |
| 289 | 289 | sql_free_result($rs); |
@@ -473,7 +473,7 @@ discard block |
||
| 473 | 473 | `cache_logs`.`text` AS `text`, |
| 474 | 474 | `cache_logs`.`text_html` AS `texthtml`, |
| 475 | 475 | `cache_logs`.`picture`, |
| 476 | - ' . $delfields . ", |
|
| 476 | + ' . $delfields.", |
|
| 477 | 477 | `user`.`username` AS `username`, |
| 478 | 478 | IF(ISNULL(`cache_rating`.`cache_id`), 0, `cache_logs`.`type` IN (1,7)) AS `recommended` |
| 479 | 479 | FROM $table AS `cache_logs` |
@@ -483,7 +483,7 @@ discard block |
||
| 483 | 483 | ON `cache_logs`.`cache_id`=`cache_rating`.`cache_id` |
| 484 | 484 | AND `cache_logs`.`user_id`=`cache_rating`.`user_id` |
| 485 | 485 | AND `cache_logs`.`date`=`cache_rating`.`rating_date` |
| 486 | - " . $addjoin . " |
|
| 486 | + ".$addjoin." |
|
| 487 | 487 | WHERE `cache_logs`.`cache_id`='&1' |
| 488 | 488 | ORDER BY `cache_logs`.`order_date` DESC, `cache_logs`.`date_created` DESC, `id` DESC |
| 489 | 489 | LIMIT &2, &3", |
@@ -508,7 +508,7 @@ discard block |
||
| 508 | 508 | ); |
| 509 | 509 | while ($rPicture = sql_fetch_assoc($rsPictures)) { |
| 510 | 510 | if (trim($rPicture['title']) == '') { |
| 511 | - $rPicture['title'] = $translate->t('Picture', '', '', 0) . ' ' . (count($pictures) + 1); |
|
| 511 | + $rPicture['title'] = $translate->t('Picture', '', '', 0).' '.(count($pictures) + 1); |
|
| 512 | 512 | } |
| 513 | 513 | $pictures[] = $rPicture; |
| 514 | 514 | } |
@@ -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[] = [ |
@@ -676,9 +676,9 @@ discard block |
||
| 676 | 676 | $login->userid, |
| 677 | 677 | $this->nCacheId, |
| 678 | 678 | 0, |
| 679 | - 'Cache ' . sql_escape($this->nCacheId) . ' has changed the owner from userid ' . sql_escape( |
|
| 679 | + 'Cache '.sql_escape($this->nCacheId).' has changed the owner from userid '.sql_escape( |
|
| 680 | 680 | $this->getUserId() |
| 681 | - ) . ' to ' . sql_escape($userId) . ' by ' . sql_escape($login->userid) |
|
| 681 | + ).' to '.sql_escape($userId).' by '.sql_escape($login->userid) |
|
| 682 | 682 | ); |
| 683 | 683 | // Adoptions now are recorded by trigger in cache_adoptions table. |
| 684 | 684 | // Recording adoptions in 'logentries' may be discarded after ensuring that the |
@@ -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 |