Changeset 702 for trunk/forum/includes/functions.php
- Timestamp:
- Mar 31, 2010, 6:32:40 PM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/forum/includes/functions.php
r400 r702 3 3 * 4 4 * @package phpBB3 5 * @version $Id : functions.php 9153 2008-12-02 17:02:56Z acydburn$5 * @version $Id$ 6 6 * @copyright (c) 2005 phpBB Group 7 7 * @license http://opensource.org/licenses/gpl-license.php GNU Public License … … 72 72 } 73 73 74 if (!isset($_REQUEST[$var_name]) || (is_array($_REQUEST[$var_name]) && !is_array($default)) || (is_array($default) && !is_array($_REQUEST[$var_name]))) 74 $super_global = ($cookie) ? '_COOKIE' : '_REQUEST'; 75 if (!isset($GLOBALS[$super_global][$var_name]) || is_array($GLOBALS[$super_global][$var_name]) != is_array($default)) 75 76 { 76 77 return (is_array($default)) ? array() : $default; 77 78 } 78 79 79 $var = $ _REQUEST[$var_name];80 $var = $GLOBALS[$super_global][$var_name]; 80 81 if (!is_array($default)) 81 82 { … … 166 167 167 168 /** 169 * Set dynamic config value with arithmetic operation. 170 */ 171 function set_config_count($config_name, $increment, $is_dynamic = false) 172 { 173 global $db, $cache; 174 175 switch ($db->sql_layer) 176 { 177 case 'firebird': 178 $sql_update = 'CAST(CAST(config_value as integer) + ' . (int) $increment . ' as VARCHAR(255))'; 179 break; 180 181 case 'postgres': 182 $sql_update = 'int4(config_value) + ' . (int) $increment; 183 break; 184 185 // MySQL, SQlite, mssql, mssql_odbc, oracle 186 default: 187 $sql_update = 'config_value + ' . (int) $increment; 188 break; 189 } 190 191 $db->sql_query('UPDATE ' . CONFIG_TABLE . ' SET config_value = ' . $sql_update . " WHERE config_name = '" . $db->sql_escape($config_name) . "'"); 192 193 if (!$is_dynamic) 194 { 195 $cache->destroy('config'); 196 } 197 } 198 199 /** 168 200 * Generates an alphanumeric random string of given length 169 201 */ … … 201 233 /** 202 234 * Return formatted string for filesizes 203 */ 204 function get_formatted_filesize($bytes, $add_size_lang = true) 235 * 236 * @param int $value filesize in bytes 237 * @param bool $string_only true if language string should be returned 238 * @param array $allowed_units only allow these units (data array indexes) 239 * 240 * @return mixed data array if $string_only is false 241 * @author bantu 242 */ 243 function get_formatted_filesize($value, $string_only = true, $allowed_units = false) 205 244 { 206 245 global $user; 207 246 208 if ($bytes >= pow(2, 20)) 209 { 210 return ($add_size_lang) ? round($bytes / 1024 / 1024, 2) . ' ' . $user->lang['MIB'] : round($bytes / 1024 / 1024, 2); 211 } 212 213 if ($bytes >= pow(2, 10)) 214 { 215 return ($add_size_lang) ? round($bytes / 1024, 2) . ' ' . $user->lang['KIB'] : round($bytes / 1024, 2); 216 } 217 218 return ($add_size_lang) ? ($bytes) . ' ' . $user->lang['BYTES'] : ($bytes); 247 $available_units = array( 248 'gb' => array( 249 'min' => 1073741824, // pow(2, 30) 250 'index' => 3, 251 'si_unit' => 'GB', 252 'iec_unit' => 'GIB', 253 ), 254 'mb' => array( 255 'min' => 1048576, // pow(2, 20) 256 'index' => 2, 257 'si_unit' => 'MB', 258 'iec_unit' => 'MIB', 259 ), 260 'kb' => array( 261 'min' => 1024, // pow(2, 10) 262 'index' => 1, 263 'si_unit' => 'KB', 264 'iec_unit' => 'KIB', 265 ), 266 'b' => array( 267 'min' => 0, 268 'index' => 0, 269 'si_unit' => 'BYTES', // Language index 270 'iec_unit' => 'BYTES', // Language index 271 ), 272 ); 273 274 foreach ($available_units as $si_identifier => $unit_info) 275 { 276 if (!empty($allowed_units) && $si_identifier != 'b' && !in_array($si_identifier, $allowed_units)) 277 { 278 continue; 279 } 280 281 if ($value >= $unit_info['min']) 282 { 283 $unit_info['si_identifier'] = $si_identifier; 284 285 break; 286 } 287 } 288 unset($available_units); 289 290 for ($i = 0; $i < $unit_info['index']; $i++) 291 { 292 $value /= 1024; 293 } 294 $value = round($value, 2); 295 296 // Lookup units in language dictionary 297 $unit_info['si_unit'] = (isset($user->lang[$unit_info['si_unit']])) ? $user->lang[$unit_info['si_unit']] : $unit_info['si_unit']; 298 $unit_info['iec_unit'] = (isset($user->lang[$unit_info['iec_unit']])) ? $user->lang[$unit_info['iec_unit']] : $unit_info['iec_unit']; 299 300 // Default to IEC 301 $unit_info['unit'] = $unit_info['iec_unit']; 302 303 if (!$string_only) 304 { 305 $unit_info['value'] = $value; 306 307 return $unit_info; 308 } 309 310 return $value . ' ' . $unit_info['unit']; 219 311 } 220 312 … … 461 553 462 554 /** 555 * Hashes an email address to a big integer 556 * 557 * @param string $email Email address 558 * 559 * @return string Unsigned Big Integer 560 */ 561 function phpbb_email_hash($email) 562 { 563 return sprintf('%u', crc32(strtolower($email))) . strlen($email); 564 } 565 566 /** 463 567 * Global function for chmodding directories and files for internal use 568 * 464 569 * This function determines owner and group whom the file belongs to and user and group of PHP and then set safest possible file permissions. 465 * The function determines owner and group from common.php file and sets the same to the provided file. Permissions are mapped to the group, user always has rw(x) permission.570 * The function determines owner and group from common.php file and sets the same to the provided file. 466 571 * The function uses bit fields to build the permissions. 467 572 * The function sets the appropiate execute bit on directories. … … 476 581 * NOTE: The function uses POSIX extension and fileowner()/filegroup() functions. If any of them is disabled, this function tries to build proper permissions, by calling is_readable() and is_writable() functions. 477 582 * 478 * @param $filenameThe file/directory to be chmodded479 * @param $permsPermissions to set480 * @return true on success, otherwise false481 * 583 * @param string $filename The file/directory to be chmodded 584 * @param int $perms Permissions to set 585 * 586 * @return bool true on success, otherwise false 482 587 * @author faw, phpBB Group 483 588 */ 484 589 function phpbb_chmod($filename, $perms = CHMOD_READ) 485 590 { 591 static $_chmod_info; 592 486 593 // Return if the file no longer exists. 487 594 if (!file_exists($filename)) … … 490 597 } 491 598 492 if (!function_exists('fileowner') || !function_exists('filegroup')) 493 { 494 $file_uid = $file_gid = false; 495 $common_php_owner = $common_php_group = false; 496 } 497 else 498 { 499 global $phpbb_root_path, $phpEx; 500 501 // Determine owner/group of common.php file and the filename we want to change here 502 $common_php_owner = fileowner($phpbb_root_path . 'common.' . $phpEx); 503 $common_php_group = filegroup($phpbb_root_path . 'common.' . $phpEx); 504 505 $file_uid = fileowner($filename); 506 $file_gid = filegroup($filename); 507 508 // Try to set the owner to the same common.php has 509 if ($common_php_owner !== $file_uid && $common_php_owner !== false && $file_uid !== false) 510 { 511 // Will most likely not work 512 if (@chown($filename, $common_php_owner)); 513 { 514 clearstatcache(); 515 $file_uid = fileowner($filename); 516 } 517 } 518 519 // Try to set the group to the same common.php has 520 if ($common_php_group !== $file_gid && $common_php_group !== false && $file_gid !== false) 521 { 522 if (@chgrp($filename, $common_php_group)); 523 { 524 clearstatcache(); 525 $file_gid = filegroup($filename); 526 } 527 } 528 } 529 530 // And the owner and the groups PHP is running under. 531 $php_uid = (function_exists('posix_getuid')) ? @posix_getuid() : false; 532 $php_gids = (function_exists('posix_getgroups')) ? @posix_getgroups() : false; 533 534 // Who is PHP? 535 if ($file_uid === false || $file_gid === false || $php_uid === false || $php_gids === false) 536 { 537 $php = NULL; 538 } 539 else if ($file_uid == $php_uid /* && $common_php_owner !== false && $common_php_owner === $file_uid*/) 540 { 541 $php = 'owner'; 542 } 543 else if (in_array($file_gid, $php_gids)) 544 { 545 $php = 'group'; 546 } 547 else 599 // Determine some common vars 600 if (empty($_chmod_info)) 601 { 602 if (!function_exists('fileowner') || !function_exists('filegroup')) 603 { 604 // No need to further determine owner/group - it is unknown 605 $_chmod_info['process'] = false; 606 } 607 else 608 { 609 global $phpbb_root_path, $phpEx; 610 611 // Determine owner/group of common.php file and the filename we want to change here 612 $common_php_owner = @fileowner($phpbb_root_path . 'common.' . $phpEx); 613 $common_php_group = @filegroup($phpbb_root_path . 'common.' . $phpEx); 614 615 // And the owner and the groups PHP is running under. 616 $php_uid = (function_exists('posix_getuid')) ? @posix_getuid() : false; 617 $php_gids = (function_exists('posix_getgroups')) ? @posix_getgroups() : false; 618 619 // If we are unable to get owner/group, then do not try to set them by guessing 620 if (!$php_uid || empty($php_gids) || !$common_php_owner || !$common_php_group) 621 { 622 $_chmod_info['process'] = false; 623 } 624 else 625 { 626 $_chmod_info = array( 627 'process' => true, 628 'common_owner' => $common_php_owner, 629 'common_group' => $common_php_group, 630 'php_uid' => $php_uid, 631 'php_gids' => $php_gids, 632 ); 633 } 634 } 635 } 636 637 if ($_chmod_info['process']) 638 { 639 $file_uid = @fileowner($filename); 640 $file_gid = @filegroup($filename); 641 642 // Change owner 643 if (@chown($filename, $_chmod_info['common_owner'])) 644 { 645 clearstatcache(); 646 $file_uid = @fileowner($filename); 647 } 648 649 // Change group 650 if (@chgrp($filename, $_chmod_info['common_group'])) 651 { 652 clearstatcache(); 653 $file_gid = @filegroup($filename); 654 } 655 656 // If the file_uid/gid now match the one from common.php we can process further, else we are not able to change something 657 if ($file_uid != $_chmod_info['common_owner'] || $file_gid != $_chmod_info['common_group']) 658 { 659 $_chmod_info['process'] = false; 660 } 661 } 662 663 // Still able to process? 664 if ($_chmod_info['process']) 665 { 666 if ($file_uid == $_chmod_info['php_uid']) 667 { 668 $php = 'owner'; 669 } 670 else if (in_array($file_gid, $_chmod_info['php_gids'])) 671 { 672 $php = 'group'; 673 } 674 else 675 { 676 // Since we are setting the everyone bit anyway, no need to do expensive operations 677 $_chmod_info['process'] = false; 678 } 679 } 680 681 // We are not able to determine or change something 682 if (!$_chmod_info['process']) 548 683 { 549 684 $php = 'other'; … … 565 700 switch ($php) 566 701 { 567 case null:568 702 case 'owner': 569 /* ATTENTION: if php is owner or NULL we set it to group here. This is the most failsafe combination for the vast majority of server setups.570 571 703 $result = @chmod($filename, ($owner << 6) + (0 << 3) + (0 << 0)); 572 704 573 705 clearstatcache(); 574 706 575 if ( !is_null($php) || (is_readable($filename) && is_writable($filename)))707 if (is_readable($filename) && is_writable($filename)) 576 708 { 577 709 break; 578 710 } 579 */580 711 581 712 case 'group': … … 584 715 clearstatcache(); 585 716 586 if ( !is_null($php) || ((!($perms & CHMOD_READ) || is_readable($filename)) && (!($perms & CHMOD_WRITE) || is_writable($filename))))717 if ((!($perms & CHMOD_READ) || is_readable($filename)) && (!($perms & CHMOD_WRITE) || is_writable($filename))) 587 718 { 588 719 break; … … 594 725 clearstatcache(); 595 726 596 if ( !is_null($php) || ((!($perms & CHMOD_READ) || is_readable($filename)) && (!($perms & CHMOD_WRITE) || is_writable($filename))))727 if ((!($perms & CHMOD_READ) || is_readable($filename)) && (!($perms & CHMOD_WRITE) || is_writable($filename))) 597 728 { 598 729 break; … … 605 736 606 737 return $result; 738 } 739 740 /** 741 * Test if a file/directory is writable 742 * 743 * This function calls the native is_writable() when not running under 744 * Windows and it is not disabled. 745 * 746 * @param string $file Path to perform write test on 747 * @return bool True when the path is writable, otherwise false. 748 */ 749 function phpbb_is_writable($file) 750 { 751 if (strtolower(substr(PHP_OS, 0, 3)) === 'win' || !function_exists('is_writable')) 752 { 753 if (file_exists($file)) 754 { 755 // Canonicalise path to absolute path 756 $file = phpbb_realpath($file); 757 758 if (is_dir($file)) 759 { 760 // Test directory by creating a file inside the directory 761 $result = @tempnam($file, 'i_w'); 762 763 if (is_string($result) && file_exists($result)) 764 { 765 unlink($result); 766 767 // Ensure the file is actually in the directory (returned realpathed) 768 return (strpos($result, $file) === 0) ? true : false; 769 } 770 } 771 else 772 { 773 $handle = @fopen($file, 'r+'); 774 775 if (is_resource($handle)) 776 { 777 fclose($handle); 778 return true; 779 } 780 } 781 } 782 else 783 { 784 // file does not exist test if we can write to the directory 785 $dir = dirname($file); 786 787 if (file_exists($dir) && is_dir($dir) && phpbb_is_writable($dir)) 788 { 789 return true; 790 } 791 } 792 793 return false; 794 } 795 else 796 { 797 return is_writable($file); 798 } 607 799 } 608 800 … … 704 896 function is_absolute($path) 705 897 { 706 return ($path[0] == '/' || (DIRECTORY_SEPARATOR == '\\' && preg_match('#^[a-z]: /#i', $path))) ? true : false;898 return ($path[0] == '/' || (DIRECTORY_SEPARATOR == '\\' && preg_match('#^[a-z]:[/\\\]#i', $path))) ? true : false; 707 899 } 708 900 … … 985 1177 { 986 1178 $selected = ($offset == $default) ? ' selected="selected"' : ''; 987 $tz_select .= '<option title="' .$zone.'" value="' . $offset . '"' . $selected . '>' . $zone_trunc . '</option>';1179 $tz_select .= '<option title="' . $zone . '" value="' . $offset . '"' . $selected . '>' . $zone_trunc . '</option>'; 988 1180 } 989 1181 } … … 1048 1240 1049 1241 // Add 0 to forums array to mark global announcements correctly 1050 $forum_id[] = 0;1242 // $forum_id[] = 0; 1051 1243 1052 1244 if ($config['load_db_lastread'] && $user->data['is_registered']) … … 1066 1258 while ($row = $db->sql_fetchrow($result)) 1067 1259 { 1068 $sql_update[] = $row['forum_id'];1260 $sql_update[] = (int) $row['forum_id']; 1069 1261 } 1070 1262 $db->sql_freeresult($result); … … 1463 1655 1464 1656 return $last_read; 1657 } 1658 1659 /** 1660 * Get list of unread topics 1661 * 1662 * @param int $user_id User ID (or false for current user) 1663 * @param string $sql_extra Extra WHERE SQL statement 1664 * @param string $sql_sort ORDER BY SQL sorting statement 1665 * @param string $sql_limit Limits the size of unread topics list, 0 for unlimited query 1666 * 1667 * @return array[int][int] Topic ids as keys, mark_time of topic as value 1668 */ 1669 function get_unread_topics($user_id = false, $sql_extra = '', $sql_sort = '', $sql_limit = 1001) 1670 { 1671 global $config, $db, $user; 1672 1673 $user_id = ($user_id === false) ? (int) $user->data['user_id'] : (int) $user_id; 1674 1675 // Data array we're going to return 1676 $unread_topics = array(); 1677 1678 if (empty($sql_sort)) 1679 { 1680 $sql_sort = 'ORDER BY t.topic_last_post_time DESC'; 1681 } 1682 1683 if ($config['load_db_lastread'] && $user->data['is_registered']) 1684 { 1685 // Get list of the unread topics 1686 $last_mark = $user->data['user_lastmark']; 1687 1688 $sql_array = array( 1689 'SELECT' => 't.topic_id, t.topic_last_post_time, tt.mark_time as topic_mark_time, ft.mark_time as forum_mark_time', 1690 1691 'FROM' => array(TOPICS_TABLE => 't'), 1692 1693 'LEFT_JOIN' => array( 1694 array( 1695 'FROM' => array(TOPICS_TRACK_TABLE => 'tt'), 1696 'ON' => "tt.user_id = $user_id AND t.topic_id = tt.topic_id", 1697 ), 1698 array( 1699 'FROM' => array(FORUMS_TRACK_TABLE => 'ft'), 1700 'ON' => "ft.user_id = $user_id AND t.forum_id = ft.forum_id", 1701 ), 1702 ), 1703 1704 'WHERE' => " 1705 ( 1706 (tt.mark_time IS NOT NULL AND t.topic_last_post_time > tt.mark_time) OR 1707 (tt.mark_time IS NULL AND ft.mark_time IS NOT NULL AND t.topic_last_post_time > ft.mark_time) OR 1708 (tt.mark_time IS NULL AND ft.mark_time IS NULL AND t.topic_last_post_time > $last_mark) 1709 ) 1710 $sql_extra 1711 $sql_sort", 1712 ); 1713 1714 $sql = $db->sql_build_query('SELECT', $sql_array); 1715 $result = $db->sql_query_limit($sql, $sql_limit); 1716 1717 while ($row = $db->sql_fetchrow($result)) 1718 { 1719 $topic_id = (int) $row['topic_id']; 1720 $unread_topics[$topic_id] = ($row['topic_mark_time']) ? (int) $row['topic_mark_time'] : (($row['forum_mark_time']) ? (int) $row['forum_mark_time'] : $last_mark); 1721 } 1722 $db->sql_freeresult($result); 1723 } 1724 else if ($config['load_anon_lastread'] || $user->data['is_registered']) 1725 { 1726 global $tracking_topics; 1727 1728 if (empty($tracking_topics)) 1729 { 1730 $tracking_topics = request_var($config['cookie_name'] . '_track', '', false, true); 1731 $tracking_topics = ($tracking_topics) ? tracking_unserialize($tracking_topics) : array(); 1732 } 1733 1734 if (!$user->data['is_registered']) 1735 { 1736 $user_lastmark = (isset($tracking_topics['l'])) ? base_convert($tracking_topics['l'], 36, 10) + $config['board_startdate'] : 0; 1737 } 1738 else 1739 { 1740 $user_lastmark = (int) $user->data['user_lastmark']; 1741 } 1742 1743 $sql = 'SELECT t.topic_id, t.forum_id, t.topic_last_post_time 1744 FROM ' . TOPICS_TABLE . ' t 1745 WHERE t.topic_last_post_time > ' . $user_lastmark . " 1746 $sql_extra 1747 $sql_sort"; 1748 $result = $db->sql_query_limit($sql, $sql_limit); 1749 1750 while ($row = $db->sql_fetchrow($result)) 1751 { 1752 $forum_id = (int) $row['forum_id']; 1753 $topic_id = (int) $row['topic_id']; 1754 $topic_id36 = base_convert($topic_id, 10, 36); 1755 1756 if (isset($tracking_topics['t'][$topic_id36])) 1757 { 1758 $last_read = base_convert($tracking_topics['t'][$topic_id36], 36, 10) + $config['board_startdate']; 1759 1760 if ($row['topic_last_post_time'] > $last_read) 1761 { 1762 $unread_topics[$topic_id] = $last_read; 1763 } 1764 } 1765 else if (isset($tracking_topics['f'][$forum_id])) 1766 { 1767 $mark_time = base_convert($tracking_topics['f'][$forum_id], 36, 10) + $config['board_startdate']; 1768 1769 if ($row['topic_last_post_time'] > $mark_time) 1770 { 1771 $unread_topics[$topic_id] = $mark_time; 1772 } 1773 } 1774 else 1775 { 1776 $unread_topics[$topic_id] = $user_lastmark; 1777 } 1778 } 1779 $db->sql_freeresult($result); 1780 } 1781 1782 return $unread_topics; 1465 1783 } 1466 1784 … … 1715 2033 1716 2034 $on_page = floor($start_item / $per_page) + 1; 1717 $url_delim = (strpos($base_url, '?') === false) ? '?' : '&';2035 $url_delim = (strpos($base_url, '?') === false) ? '?' : ((strpos($base_url, '?') === strlen($base_url) - 1) ? '' : '&'); 1718 2036 1719 2037 $page_string = ($on_page == 1) ? '<strong>1</strong>' : '<a href="' . $base_url . '">1</a>'; … … 1994 2312 1995 2313 // Determine which type of redirect we need to handle... 1996 $url_parts = parse_url($url);2314 $url_parts = @parse_url($url); 1997 2315 1998 2316 if ($url_parts === false) … … 2138 2456 2139 2457 // Remove previously added sid 2140 if (strpos($url, '?sid=') !== false) 2141 { 2142 $url = preg_replace('/(\?)sid=[a-z0-9]+(&|&)?/', '\1', $url); 2143 } 2144 else if (strpos($url, '&sid=') !== false) 2145 { 2146 $url = preg_replace('/&sid=[a-z0-9]+(&)?/', '\1', $url); 2147 } 2148 else if (strpos($url, '&sid=') !== false) 2149 { 2150 $url = preg_replace('/&sid=[a-z0-9]+(&)?/', '\1', $url); 2458 if (strpos($url, 'sid=') !== false) 2459 { 2460 // All kind of links 2461 $url = preg_replace('/(\?)?(&|&)?sid=[a-z0-9]+/', '', $url); 2462 // if the sid was the first param, make the old second as first ones 2463 $url = preg_replace("/$phpEx(&|&)+?/", "$phpEx?", $url); 2151 2464 } 2152 2465 … … 2210 2523 2211 2524 $redirect .= ($query) ? '?' . $query : ''; 2525 } 2526 2527 // We need to be cautious here. 2528 // On some situations, the redirect path is an absolute URL, sometimes a relative path 2529 // For a relative path, let's prefix it with $phpbb_root_path to point to the correct location, 2530 // else we use the URL directly. 2531 $url_parts = @parse_url($redirect); 2532 2533 // URL 2534 if ($url_parts !== false && !empty($url_parts['scheme']) && !empty($url_parts['host'])) 2535 { 2536 return str_replace('&', '&', $redirect); 2212 2537 } 2213 2538 … … 2373 2698 if ($check && $confirm) 2374 2699 { 2375 $user_id = request_var(' user_id', 0);2700 $user_id = request_var('confirm_uid', 0); 2376 2701 $session_id = request_var('sess', ''); 2377 2702 $confirm_key = request_var('confirm_key', ''); … … 2395 2720 2396 2721 $s_hidden_fields = build_hidden_fields(array( 2397 ' user_id' => $user->data['user_id'],2398 'sess' => $user->session_id,2399 'sid' => $user->session_id)2400 ) ;2722 'confirm_uid' => $user->data['user_id'], 2723 'sess' => $user->session_id, 2724 'sid' => $user->session_id, 2725 )); 2401 2726 2402 2727 // generate activation key … … 2409 2734 else 2410 2735 { 2411 page_header(( !isset($user->lang[$title])) ? $user->lang['CONFIRM'] : $user->lang[$title]);2736 page_header(((!isset($user->lang[$title])) ? $user->lang['CONFIRM'] : $user->lang[$title]), false); 2412 2737 } 2413 2738 … … 2457 2782 { 2458 2783 global $db, $user, $template, $auth, $phpEx, $phpbb_root_path, $config; 2784 2785 if (!class_exists('phpbb_captcha_factory')) 2786 { 2787 include($phpbb_root_path . 'includes/captcha/captcha_factory.' . $phpEx); 2788 } 2459 2789 2460 2790 $err = ''; … … 2568 2898 case LOGIN_ERROR_ATTEMPTS: 2569 2899 2570 // Show confirm image 2571 $sql = 'DELETE FROM ' . CONFIRM_TABLE . " 2572 WHERE session_id = '" . $db->sql_escape($user->session_id) . "' 2573 AND confirm_type = " . CONFIRM_LOGIN; 2574 $db->sql_query($sql); 2575 2576 // Generate code 2577 $code = gen_rand_string(mt_rand(5, 8)); 2578 $confirm_id = md5(unique_id($user->ip)); 2579 $seed = hexdec(substr(unique_id(), 4, 10)); 2580 2581 // compute $seed % 0x7fffffff 2582 $seed -= 0x7fffffff * floor($seed / 0x7fffffff); 2583 2584 $sql = 'INSERT INTO ' . CONFIRM_TABLE . ' ' . $db->sql_build_array('INSERT', array( 2585 'confirm_id' => (string) $confirm_id, 2586 'session_id' => (string) $user->session_id, 2587 'confirm_type' => (int) CONFIRM_LOGIN, 2588 'code' => (string) $code, 2589 'seed' => (int) $seed) 2590 ); 2591 $db->sql_query($sql); 2900 $captcha = phpbb_captcha_factory::get_instance($config['captcha_plugin']); 2901 $captcha->init(CONFIRM_LOGIN); 2902 // $captcha->reset(); 2592 2903 2593 2904 $template->assign_vars(array( 2594 'S_CONFIRM_CODE' => true, 2595 'CONFIRM_ID' => $confirm_id, 2596 'CONFIRM_IMAGE' => '<img src="' . append_sid("{$phpbb_root_path}ucp.$phpEx", 'mode=confirm&id=' . $confirm_id . '&type=' . CONFIRM_LOGIN) . '" alt="" title="" />', 2597 'L_LOGIN_CONFIRM_EXPLAIN' => sprintf($user->lang['LOGIN_CONFIRM_EXPLAIN'], '<a href="mailto:' . htmlspecialchars($config['board_contact']) . '">', '</a>'), 2905 'CAPTCHA_TEMPLATE' => $captcha->get_template(), 2598 2906 )); 2599 2907 2600 2908 $err = $user->lang[$result['error_msg']]; 2601 2602 2909 break; 2603 2910 … … 2626 2933 } 2627 2934 2628 if (!$redirect)2629 {2630 // We just use what the session code determined...2631 // If we are not within the admin directory we use the page dir...2632 $redirect = '';2633 2634 if (!$admin)2635 {2636 $redirect .= ($user->page['page_dir']) ? $user->page['page_dir'] . '/' : '';2637 }2638 2639 $redirect .= $user->page['page_name'] . (($user->page['query_string']) ? '?' . htmlspecialchars($user->page['query_string']) : '');2640 }2641 2642 2935 // Assign credential for username/password pair 2643 2936 $credential = ($admin) ? md5(unique_id()) : false; 2644 2937 2645 2938 $s_hidden_fields = array( 2646 'redirect' => $redirect,2647 2939 'sid' => $user->session_id, 2648 2940 ); 2941 2942 if ($redirect) 2943 { 2944 $s_hidden_fields['redirect'] = $redirect; 2945 } 2649 2946 2650 2947 if ($admin) … … 2660 2957 2661 2958 'U_SEND_PASSWORD' => ($config['email_enable']) ? append_sid("{$phpbb_root_path}ucp.$phpEx", 'mode=sendpassword') : '', 2662 'U_RESEND_ACTIVATION' => ($config['require_activation'] != USER_ACTIVATION_NONE&& $config['email_enable']) ? append_sid("{$phpbb_root_path}ucp.$phpEx", 'mode=resend_act') : '',2959 'U_RESEND_ACTIVATION' => ($config['require_activation'] == USER_ACTIVATION_SELF && $config['email_enable']) ? append_sid("{$phpbb_root_path}ucp.$phpEx", 'mode=resend_act') : '', 2663 2960 'U_TERMS_USE' => append_sid("{$phpbb_root_path}ucp.$phpEx", 'mode=terms'), 2664 2961 'U_PRIVACY' => append_sid("{$phpbb_root_path}ucp.$phpEx", 'mode=privacy'), 2665 2962 2666 2963 'S_DISPLAY_FULL_LOGIN' => ($s_display) ? true : false, 2667 'S_LOGIN_ACTION' => (!$admin) ? append_sid("{$phpbb_root_path}ucp.$phpEx", 'mode=login') : append_sid("index.$phpEx", false, true, $user->session_id), // Needs to stay index.$phpEx because we are within the admin directory2668 2964 'S_HIDDEN_FIELDS' => $s_hidden_fields, 2669 2965 … … 2749 3045 } 2750 3046 2751 page_header($user->lang['LOGIN'] );3047 page_header($user->lang['LOGIN'], false); 2752 3048 2753 3049 $template->assign_vars(array( 3050 'S_LOGIN_ACTION' => build_url(array('f')), 2754 3051 'S_HIDDEN_FIELDS' => build_hidden_fields(array('f' => $forum_data['forum_id']))) 2755 3052 ); … … 2870 3167 { 2871 3168 global $db, $user; 3169 3170 // In phpBB 3.1.x i want to have logging in a class to be able to control it 3171 // For now, we need a quite hakish approach to circumvent logging for some actions 3172 // @todo implement cleanly 3173 if (!empty($GLOBALS['skip_add_log'])) 3174 { 3175 return false; 3176 } 2872 3177 2873 3178 $args = func_get_args(); … … 3138 3443 3139 3444 // Do not display notices if we suppress them via @ 3140 if (error_reporting() == 0 )3445 if (error_reporting() == 0 && $errno != E_USER_ERROR && $errno != E_USER_WARNING && $errno != E_USER_NOTICE) 3141 3446 { 3142 3447 return; … … 3147 3452 { 3148 3453 $msg_text = $msg_long_text; 3454 } 3455 3456 if (!defined('E_DEPRECATED')) 3457 { 3458 define('E_DEPRECATED', 8192); 3149 3459 } 3150 3460 … … 3181 3491 $errfile = str_replace(array(phpbb_realpath($phpbb_root_path), '\\'), array('', '/'), $errfile); 3182 3492 $msg_text = str_replace(array(phpbb_realpath($phpbb_root_path), '\\'), array('', '/'), $msg_text); 3183 3184 3493 echo '<b>[phpBB Debug] PHP Notice</b>: in file <b>' . $errfile . '</b> on line <b>' . $errline . '</b>: <b>' . $msg_text . '</b><br />' . "\n"; 3494 3495 // we are writing an image - the user won't see the debug, so let's place it in the log 3496 if (defined('IMAGE_OUTPUT') || defined('IN_CRON')) 3497 { 3498 add_log('critical', 'LOG_IMAGE_GENERATION_ERROR', $errfile, $errline, $msg_text); 3499 } 3500 // echo '<br /><br />BACKTRACE<br />' . get_backtrace() . '<br />' . "\n"; 3185 3501 } 3186 3502 … … 3215 3531 } 3216 3532 } 3533 3534 if ((defined('DEBUG') || defined('IN_CRON') || defined('IMAGE_OUTPUT')) && isset($db)) 3535 { 3536 // let's avoid loops 3537 $db->sql_return_on_error(true); 3538 add_log('critical', 'LOG_GENERAL_ERROR', $msg_title, $msg_text); 3539 $db->sql_return_on_error(false); 3540 } 3541 3542 // Do not send 200 OK, but service unavailable on errors 3543 header('HTTP/1.1 503 Service Unavailable'); 3217 3544 3218 3545 garbage_collection(); … … 3294 3621 else 3295 3622 { 3296 page_header($msg_title );3623 page_header($msg_title, false); 3297 3624 } 3298 3625 } … … 3323 3650 exit_handler(); 3324 3651 break; 3652 3653 // PHP4 compatibility 3654 case E_DEPRECATED: 3655 return true; 3656 break; 3325 3657 } 3326 3658 … … 3332 3664 /** 3333 3665 * Queries the session table to get information about online guests 3334 * @param int $forum_id Limits the search to the forum with this id 3666 * @param int $item_id Limits the search to the item with this id 3667 * @param string $item The name of the item which is stored in the session table as session_{$item}_id 3335 3668 * @return int The number of active distinct guest sessions 3336 3669 */ 3337 function obtain_guest_count($ forum_id = 0)3670 function obtain_guest_count($item_id = 0, $item = 'forum') 3338 3671 { 3339 3672 global $db, $config; 3340 3673 3341 if ($ forum_id)3342 { 3343 $reading_sql = ' AND s.session_ forum_id = ' . (int) $forum_id;3674 if ($item_id) 3675 { 3676 $reading_sql = ' AND s.session_' . $item . '_id = ' . (int) $item_id; 3344 3677 } 3345 3678 else … … 3370 3703 $reading_sql; 3371 3704 } 3372 $result = $db->sql_query($sql , 60);3705 $result = $db->sql_query($sql); 3373 3706 $guests_online = (int) $db->sql_fetchfield('num_guests'); 3374 3707 $db->sql_freeresult($result); … … 3379 3712 /** 3380 3713 * Queries the session table to get information about online users 3381 * @param int $forum_id Limits the search to the forum with this id 3714 * @param int $item_id Limits the search to the item with this id 3715 * @param string $item The name of the item which is stored in the session table as session_{$item}_id 3382 3716 * @return array An array containing the ids of online, hidden and visible users, as well as statistical info 3383 3717 */ 3384 function obtain_users_online($ forum_id = 0)3718 function obtain_users_online($item_id = 0, $item = 'forum') 3385 3719 { 3386 3720 global $db, $config, $user; 3387 3721 3388 3722 $reading_sql = ''; 3389 if ($ forum_id !== 0)3390 { 3391 $reading_sql = ' AND s.session_ forum_id = ' . (int) $forum_id;3723 if ($item_id !== 0) 3724 { 3725 $reading_sql = ' AND s.session_' . $item . '_id = ' . (int) $item_id; 3392 3726 } 3393 3727 … … 3403 3737 if ($config['load_online_guests']) 3404 3738 { 3405 $online_users['guests_online'] = obtain_guest_count($ forum_id);3739 $online_users['guests_online'] = obtain_guest_count($item_id, $item); 3406 3740 } 3407 3741 … … 3442 3776 * Uses the result of obtain_users_online to generate a localized, readable representation. 3443 3777 * @param mixed $online_users result of obtain_users_online - array with user_id lists for total, hidden and visible users, and statistics 3444 * @param int $forum_id Indicate that the data is limited to one forum and not global. 3778 * @param int $item_id Indicate that the data is limited to one item and not global 3779 * @param string $item The name of the item which is stored in the session table as session_{$item}_id 3445 3780 * @return array An array containing the string for output to the template 3446 3781 */ 3447 function obtain_users_online_string($online_users, $ forum_id = 0)3782 function obtain_users_online_string($online_users, $item_id = 0, $item = 'forum') 3448 3783 { 3449 3784 global $config, $db, $user, $auth; 3450 3785 3451 3786 $user_online_link = $online_userlist = ''; 3787 // Need caps version of $item for language-strings 3788 $item_caps = strtoupper($item); 3452 3789 3453 3790 if (sizeof($online_users['online_users'])) … … 3484 3821 } 3485 3822 3486 if ($ forum_id === 0)3823 if ($item_id === 0) 3487 3824 { 3488 3825 $online_userlist = $user->lang['REGISTERED_USERS'] . ' ' . $online_userlist; … … 3490 3827 else if ($config['load_online_guests']) 3491 3828 { 3492 $l_online = ($online_users['guests_online'] === 1) ? $user->lang['BROWSING_ FORUM_GUEST'] : $user->lang['BROWSING_FORUM_GUESTS'];3829 $l_online = ($online_users['guests_online'] === 1) ? $user->lang['BROWSING_' . $item_caps . '_GUEST'] : $user->lang['BROWSING_' . $item_caps . '_GUESTS']; 3493 3830 $online_userlist = sprintf($l_online, $online_userlist, $online_users['guests_online']); 3494 3831 } 3495 3832 else 3496 3833 { 3497 $online_userlist = sprintf($user->lang['BROWSING_ FORUM'], $online_userlist);3834 $online_userlist = sprintf($user->lang['BROWSING_' . $item_caps], $online_userlist); 3498 3835 } 3499 3836 // Build online listing … … 3549 3886 } 3550 3887 3888 /** 3889 * Get option bitfield from custom data 3890 * 3891 * @param int $bit The bit/value to get 3892 * @param int $data Current bitfield to check 3893 * @return bool Returns true if value of constant is set in bitfield, else false 3894 */ 3895 function phpbb_optionget($bit, $data) 3896 { 3897 return ($data & 1 << (int) $bit) ? true : false; 3898 } 3899 3900 /** 3901 * Set option bitfield 3902 * 3903 * @param int $bit The bit/value to set/unset 3904 * @param bool $set True if option should be set, false if option should be unset. 3905 * @param int $data Current bitfield to change 3906 * 3907 * @return int The new bitfield 3908 */ 3909 function phpbb_optionset($bit, $set, $data) 3910 { 3911 if ($set && !($data & 1 << $bit)) 3912 { 3913 $data += 1 << $bit; 3914 } 3915 else if (!$set && ($data & 1 << $bit)) 3916 { 3917 $data -= 1 << $bit; 3918 } 3919 3920 return $data; 3921 } 3922 3923 /** 3924 * Login using http authenticate. 3925 * 3926 * @param array $param Parameter array, see $param_defaults array. 3927 * 3928 * @return void 3929 */ 3930 function phpbb_http_login($param) 3931 { 3932 global $auth, $user; 3933 global $config; 3934 3935 $param_defaults = array( 3936 'auth_message' => '', 3937 3938 'autologin' => false, 3939 'viewonline' => true, 3940 'admin' => false, 3941 ); 3942 3943 // Overwrite default values with passed values 3944 $param = array_merge($param_defaults, $param); 3945 3946 // User is already logged in 3947 // We will not overwrite his session 3948 if (!empty($user->data['is_registered'])) 3949 { 3950 return; 3951 } 3952 3953 // $_SERVER keys to check 3954 $username_keys = array( 3955 'PHP_AUTH_USER', 3956 'Authorization', 3957 'REMOTE_USER', 'REDIRECT_REMOTE_USER', 3958 'HTTP_AUTHORIZATION', 'REDIRECT_HTTP_AUTHORIZATION', 3959 'REMOTE_AUTHORIZATION', 'REDIRECT_REMOTE_AUTHORIZATION', 3960 'AUTH_USER', 3961 ); 3962 3963 $password_keys = array( 3964 'PHP_AUTH_PW', 3965 'REMOTE_PASSWORD', 3966 'AUTH_PASSWORD', 3967 ); 3968 3969 $username = null; 3970 foreach ($username_keys as $k) 3971 { 3972 if (isset($_SERVER[$k])) 3973 { 3974 $username = $_SERVER[$k]; 3975 break; 3976 } 3977 } 3978 3979 $password = null; 3980 foreach ($password_keys as $k) 3981 { 3982 if (isset($_SERVER[$k])) 3983 { 3984 $password = $_SERVER[$k]; 3985 break; 3986 } 3987 } 3988 3989 // Decode encoded information (IIS, CGI, FastCGI etc.) 3990 if (!is_null($username) && is_null($password) && strpos($username, 'Basic ') === 0) 3991 { 3992 list($username, $password) = explode(':', base64_decode(substr($username, 6)), 2); 3993 } 3994 3995 if (!is_null($username) && !is_null($password)) 3996 { 3997 set_var($username, $username, 'string', true); 3998 set_var($password, $password, 'string', true); 3999 4000 $auth_result = $auth->login($username, $password, $param['autologin'], $param['viewonline'], $param['admin']); 4001 4002 if ($auth_result['status'] == LOGIN_SUCCESS) 4003 { 4004 return; 4005 } 4006 else if ($auth_result['status'] == LOGIN_ERROR_ATTEMPTS) 4007 { 4008 header('HTTP/1.0 401 Unauthorized'); 4009 trigger_error('NOT_AUTHORISED'); 4010 } 4011 } 4012 4013 // Prepend sitename to auth_message 4014 $param['auth_message'] = ($param['auth_message'] === '') ? $config['sitename'] : $config['sitename'] . ' - ' . $param['auth_message']; 4015 4016 // We should probably filter out non-ASCII characters - RFC2616 4017 $param['auth_message'] = preg_replace('/[\x80-\xFF]/', '?', $param['auth_message']); 4018 4019 header('WWW-Authenticate: Basic realm="' . $param['auth_message'] . '"'); 4020 header('HTTP/1.0 401 Unauthorized'); 4021 4022 trigger_error('NOT_AUTHORISED'); 4023 } 3551 4024 3552 4025 /** 3553 4026 * Generate page header 3554 4027 */ 3555 function page_header($page_title = '', $display_online_list = true )4028 function page_header($page_title = '', $display_online_list = true, $item_id = 0, $item = 'forum') 3556 4029 { 3557 4030 global $db, $config, $template, $SID, $_SID, $user, $auth, $phpEx, $phpbb_root_path; … … 3589 4062 3590 4063 // Get users online list ... if required 3591 $l_online_users = $online_userlist = $l_online_record = '';4064 $l_online_users = $online_userlist = $l_online_record = $l_online_time = ''; 3592 4065 3593 4066 if ($config['load_online'] && $config['load_online_time'] && $display_online_list) 3594 4067 { 3595 $f = request_var('f', 0); 3596 $f = max($f, 0); 3597 $online_users = obtain_users_online($f); 3598 $user_online_strings = obtain_users_online_string($online_users, $f); 4068 /** 4069 * Load online data: 4070 * For obtaining another session column use $item and $item_id in the function-parameter, whereby the column is session_{$item}_id. 4071 */ 4072 $item_id = max($item_id, 0); 4073 4074 $online_users = obtain_users_online($item_id, $item); 4075 $user_online_strings = obtain_users_online_string($online_users, $item_id, $item); 3599 4076 3600 4077 $l_online_users = $user_online_strings['l_online_users']; … … 3608 4085 } 3609 4086 3610 $l_online_record = sprintf($user->lang['RECORD_ONLINE_USERS'], $config['record_online_users'], $user->format_date($config['record_online_date'] ));4087 $l_online_record = sprintf($user->lang['RECORD_ONLINE_USERS'], $config['record_online_users'], $user->format_date($config['record_online_date'], false, true)); 3611 4088 3612 4089 $l_online_time = ($config['load_online_time'] == 1) ? 'VIEW_ONLINE_TIME' : 'VIEW_ONLINE_TIMES'; 3613 4090 $l_online_time = sprintf($user->lang[$l_online_time], $config['load_online_time']); 3614 }3615 else3616 {3617 $l_online_time = '';3618 4091 } 3619 4092 … … 3657 4130 } 3658 4131 } 4132 4133 $forum_id = request_var('f', 0); 4134 $topic_id = request_var('t', 0); 4135 4136 $s_feed_news = false; 4137 4138 // Get option for news 4139 if ($config['feed_enable']) 4140 { 4141 $sql = 'SELECT forum_id 4142 FROM ' . FORUMS_TABLE . ' 4143 WHERE ' . $db->sql_bit_and('forum_options', FORUM_OPTION_FEED_NEWS, '<> 0'); 4144 $result = $db->sql_query_limit($sql, 1, 0, 600); 4145 $s_feed_news = (int) $db->sql_fetchfield('forum_id'); 4146 $db->sql_freeresult($result); 4147 } 4148 4149 // Determine board url - we may need it later 4150 $board_url = generate_board_url() . '/'; 4151 $web_path = (defined('PHPBB_USE_BOARD_URL_PATH') && PHPBB_USE_BOARD_URL_PATH) ? $board_url : $phpbb_root_path; 3659 4152 3660 4153 // Which timezone? … … 3685 4178 'S_USER_NEW_PRIVMSG' => $user->data['user_new_privmsg'], 3686 4179 'S_USER_UNREAD_PRIVMSG' => $user->data['user_unread_privmsg'], 4180 'S_USER_NEW' => $user->data['user_new'], 3687 4181 3688 4182 'SID' => $SID, … … 3690 4184 'SESSION_ID' => $user->session_id, 3691 4185 'ROOT_PATH' => $phpbb_root_path, 4186 'BOARD_URL' => $board_url, 3692 4187 3693 4188 'L_LOGIN_LOGOUT' => $l_login_logout, … … 3711 4206 'U_SEARCH_NEW' => append_sid("{$phpbb_root_path}search.$phpEx", 'search_id=newposts'), 3712 4207 'U_SEARCH_UNANSWERED' => append_sid("{$phpbb_root_path}search.$phpEx", 'search_id=unanswered'), 4208 'U_SEARCH_UNREAD' => append_sid("{$phpbb_root_path}search.$phpEx", 'search_id=unreadposts'), 3713 4209 'U_SEARCH_ACTIVE_TOPICS'=> append_sid("{$phpbb_root_path}search.$phpEx", 'search_id=active_topics'), 3714 4210 'U_DELETE_COOKIES' => append_sid("{$phpbb_root_path}ucp.$phpEx", 'mode=delete_cookies'), 3715 4211 'U_TEAM' => ($user->data['user_id'] != ANONYMOUS && !$auth->acl_get('u_viewprofile')) ? '' : append_sid("{$phpbb_root_path}memberlist.$phpEx", 'mode=leaders'), 4212 'U_TERMS_USE' => append_sid("{$phpbb_root_path}ucp.$phpEx", 'mode=terms'), 4213 'U_PRIVACY' => append_sid("{$phpbb_root_path}ucp.$phpEx", 'mode=privacy'), 3716 4214 'U_RESTORE_PERMISSIONS' => ($user->data['user_perm_from'] && $auth->acl_get('a_switchperm')) ? append_sid("{$phpbb_root_path}ucp.$phpEx", 'mode=restore_perm') : '', 4215 'U_FEED' => generate_board_url() . "/feed.$phpEx", 3717 4216 3718 4217 'S_USER_LOGGED_IN' => ($user->data['user_id'] != ANONYMOUS) ? true : false, … … 3736 4235 'S_NEW_PM' => ($s_privmsg_new) ? 1 : 0, 3737 4236 'S_REGISTER_ENABLED' => ($config['require_activation'] != USER_ACTIVATION_DISABLE) ? true : false, 3738 3739 'T_THEME_PATH' => "{$phpbb_root_path}styles/" . $user->theme['theme_path'] . '/theme', 3740 'T_TEMPLATE_PATH' => "{$phpbb_root_path}styles/" . $user->theme['template_path'] . '/template', 3741 'T_SUPER_TEMPLATE_PATH' => (isset($user->theme['template_inherit_path']) && $user->theme['template_inherit_path']) ? "{$phpbb_root_path}styles/" . $user->theme['template_inherit_path'] . '/template' : "{$phpbb_root_path}styles/" . $user->theme['template_path'] . '/template', 3742 'T_IMAGESET_PATH' => "{$phpbb_root_path}styles/" . $user->theme['imageset_path'] . '/imageset', 3743 'T_IMAGESET_LANG_PATH' => "{$phpbb_root_path}styles/" . $user->theme['imageset_path'] . '/imageset/' . $user->data['user_lang'], 3744 'T_IMAGES_PATH' => "{$phpbb_root_path}images/", 3745 'T_SMILIES_PATH' => "{$phpbb_root_path}{$config['smilies_path']}/", 3746 'T_AVATAR_PATH' => "{$phpbb_root_path}{$config['avatar_path']}/", 3747 'T_AVATAR_GALLERY_PATH' => "{$phpbb_root_path}{$config['avatar_gallery_path']}/", 3748 'T_ICONS_PATH' => "{$phpbb_root_path}{$config['icons_path']}/", 3749 'T_RANKS_PATH' => "{$phpbb_root_path}{$config['ranks_path']}/", 3750 'T_UPLOAD_PATH' => "{$phpbb_root_path}{$config['upload_path']}/", 3751 'T_STYLESHEET_LINK' => (!$user->theme['theme_storedb']) ? "{$phpbb_root_path}styles/" . $user->theme['theme_path'] . '/theme/stylesheet.css' : "{$phpbb_root_path}style.$phpEx?sid=$user->session_id&id=" . $user->theme['style_id'] . '&lang=' . $user->data['user_lang'], 4237 'S_FORUM_ID' => $forum_id, 4238 'S_TOPIC_ID' => $topic_id, 4239 4240 'S_LOGIN_ACTION' => ((!defined('ADMIN_START')) ? append_sid("{$phpbb_root_path}ucp.$phpEx", 'mode=login') : append_sid("index.$phpEx", false, true, $user->session_id)), 4241 'S_LOGIN_REDIRECT' => build_hidden_fields(array('redirect' => str_replace('&', '&', build_url()))), 4242 4243 'S_ENABLE_FEEDS' => ($config['feed_enable']) ? true : false, 4244 'S_ENABLE_FEEDS_OVERALL' => ($config['feed_overall']) ? true : false, 4245 'S_ENABLE_FEEDS_FORUMS' => ($config['feed_overall_forums']) ? true : false, 4246 'S_ENABLE_FEEDS_TOPICS' => ($config['feed_topics_new']) ? true : false, 4247 'S_ENABLE_FEEDS_TOPICS_ACTIVE' => ($config['feed_topics_active']) ? true : false, 4248 'S_ENABLE_FEEDS_NEWS' => ($s_feed_news) ? true : false, 4249 4250 'T_THEME_PATH' => "{$web_path}styles/" . $user->theme['theme_path'] . '/theme', 4251 'T_TEMPLATE_PATH' => "{$web_path}styles/" . $user->theme['template_path'] . '/template', 4252 'T_SUPER_TEMPLATE_PATH' => (isset($user->theme['template_inherit_path']) && $user->theme['template_inherit_path']) ? "{$web_path}styles/" . $user->theme['template_inherit_path'] . '/template' : "{$web_path}styles/" . $user->theme['template_path'] . '/template', 4253 'T_IMAGESET_PATH' => "{$web_path}styles/" . $user->theme['imageset_path'] . '/imageset', 4254 'T_IMAGESET_LANG_PATH' => "{$web_path}styles/" . $user->theme['imageset_path'] . '/imageset/' . $user->data['user_lang'], 4255 'T_IMAGES_PATH' => "{$web_path}images/", 4256 'T_SMILIES_PATH' => "{$web_path}{$config['smilies_path']}/", 4257 'T_AVATAR_PATH' => "{$web_path}{$config['avatar_path']}/", 4258 'T_AVATAR_GALLERY_PATH' => "{$web_path}{$config['avatar_gallery_path']}/", 4259 'T_ICONS_PATH' => "{$web_path}{$config['icons_path']}/", 4260 'T_RANKS_PATH' => "{$web_path}{$config['ranks_path']}/", 4261 'T_UPLOAD_PATH' => "{$web_path}{$config['upload_path']}/", 4262 'T_STYLESHEET_LINK' => (!$user->theme['theme_storedb']) ? "{$web_path}styles/" . $user->theme['theme_path'] . '/theme/stylesheet.css' : append_sid("{$phpbb_root_path}style.$phpEx", 'id=' . $user->theme['style_id'] . '&lang=' . $user->data['user_lang'], true, $user->session_id), 3752 4263 'T_STYLESHEET_NAME' => $user->theme['theme_name'], 4264 4265 'T_THEME_NAME' => $user->theme['theme_path'], 4266 'T_TEMPLATE_NAME' => $user->theme['template_path'], 4267 'T_SUPER_TEMPLATE_NAME' => (isset($user->theme['template_inherit_path']) && $user->theme['template_inherit_path']) ? $user->theme['template_inherit_path'] : $user->theme['template_path'], 4268 'T_IMAGESET_NAME' => $user->theme['imageset_path'], 4269 'T_IMAGESET_LANG_NAME' => $user->data['user_lang'], 4270 'T_IMAGES' => 'images', 4271 'T_SMILIES' => $config['smilies_path'], 4272 'T_AVATAR' => $config['avatar_path'], 4273 'T_AVATAR_GALLERY' => $config['avatar_gallery_path'], 4274 'T_ICONS' => $config['icons_path'], 4275 'T_RANKS' => $config['ranks_path'], 4276 'T_UPLOAD' => $config['upload_path'], 3753 4277 3754 4278 'SITE_LOGO_IMG' => $user->img('site_logo'), … … 3785 4309 } 3786 4310 3787 $debug_output = sprintf('Time : %.3fs | ' . $db->sql_num_queries() . ' Queries | GZIP : ' . (($config['gzip_compress'] ) ? 'On' : 'Off') . (($user->load) ? ' | Load : ' . $user->load : ''), $totaltime);4311 $debug_output = sprintf('Time : %.3fs | ' . $db->sql_num_queries() . ' Queries | GZIP : ' . (($config['gzip_compress'] && @extension_loaded('zlib')) ? 'On' : 'Off') . (($user->load) ? ' | Load : ' . $user->load : ''), $totaltime); 3788 4312 3789 4313 if ($auth->acl_get('a_') && defined('DEBUG_EXTRA')) … … 3813 4337 3814 4338 // Call cron-type script 4339 $call_cron = false; 3815 4340 if (!defined('IN_CRON') && $run_cron && !$config['board_disable']) 3816 4341 { 4342 $call_cron = true; 4343 $time_now = (!empty($user->time_now) && is_int($user->time_now)) ? $user->time_now : time(); 4344 4345 // Any old lock present? 4346 if (!empty($config['cron_lock'])) 4347 { 4348 $cron_time = explode(' ', $config['cron_lock']); 4349 4350 // If 1 hour lock is present we do not call cron.php 4351 if ($cron_time[0] + 3600 >= $time_now) 4352 { 4353 $call_cron = false; 4354 } 4355 } 4356 } 4357 4358 // Call cron job? 4359 if ($call_cron) 4360 { 3817 4361 $cron_type = ''; 3818 4362 3819 if ( time()- $config['queue_interval'] > $config['last_queue_run'] && !defined('IN_ADMIN') && file_exists($phpbb_root_path . 'cache/queue.' . $phpEx))4363 if ($time_now - $config['queue_interval'] > $config['last_queue_run'] && !defined('IN_ADMIN') && file_exists($phpbb_root_path . 'cache/queue.' . $phpEx)) 3820 4364 { 3821 4365 // Process email queue 3822 4366 $cron_type = 'queue'; 3823 4367 } 3824 else if (method_exists($cache, 'tidy') && time()- $config['cache_gc'] > $config['cache_last_gc'])4368 else if (method_exists($cache, 'tidy') && $time_now - $config['cache_gc'] > $config['cache_last_gc']) 3825 4369 { 3826 4370 // Tidy the cache 3827 4371 $cron_type = 'tidy_cache'; 3828 4372 } 3829 else if ( time() - $config['warnings_gc'] > $config['warnings_last_gc'])4373 else if ($config['warnings_expire_days'] && ($time_now - $config['warnings_gc'] > $config['warnings_last_gc'])) 3830 4374 { 3831 4375 $cron_type = 'tidy_warnings'; 3832 4376 } 3833 else if ( time()- $config['database_gc'] > $config['database_last_gc'])4377 else if ($time_now - $config['database_gc'] > $config['database_last_gc']) 3834 4378 { 3835 4379 // Tidy the database 3836 4380 $cron_type = 'tidy_database'; 3837 4381 } 3838 else if ( time()- $config['search_gc'] > $config['search_last_gc'])4382 else if ($time_now - $config['search_gc'] > $config['search_last_gc']) 3839 4383 { 3840 4384 // Tidy the search 3841 4385 $cron_type = 'tidy_search'; 3842 4386 } 3843 else if ( time()- $config['session_gc'] > $config['session_last_gc'])4387 else if ($time_now - $config['session_gc'] > $config['session_last_gc']) 3844 4388 { 3845 4389 $cron_type = 'tidy_sessions';
Note:
See TracChangeset
for help on using the changeset viewer.