Changeset 702 for trunk/forum/includes
- Timestamp:
- Mar 31, 2010, 6:32:40 PM (15 years ago)
- Location:
- trunk/forum/includes
- Files:
-
- 92 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/forum/includes/acm/acm_file.php
r400 r702 3 3 * 4 4 * @package acm 5 * @version $Id : acm_file.php 9076 2008-11-22 19:06:42Z acydburn$6 * @copyright (c) 2005 phpBB Group5 * @version $Id$ 6 * @copyright (c) 2005, 2009 phpBB Group 7 7 * @license http://opensource.org/licenses/gpl-license.php GNU Public License 8 8 * … … 45 45 function load() 46 46 { 47 global $phpEx; 48 if (file_exists($this->cache_dir . 'data_global.' . $phpEx)) 49 { 50 @include($this->cache_dir . 'data_global.' . $phpEx); 51 } 52 else 53 { 54 return false; 55 } 56 57 return true; 47 return $this->_read('data_global'); 58 48 } 59 49 … … 87 77 global $phpEx; 88 78 89 if ($fp = @fopen($this->cache_dir . 'data_global.' . $phpEx, 'wb')) 90 { 91 @flock($fp, LOCK_EX); 92 fwrite($fp, "<?php\n\$this->vars = " . var_export($this->vars, true) . ";\n\n\$this->var_expires = " . var_export($this->var_expires, true) . "\n?>"); 93 @flock($fp, LOCK_UN); 94 fclose($fp); 95 96 if (!function_exists('phpbb_chmod')) 97 { 98 global $phpbb_root_path; 99 include($phpbb_root_path . 'includes/functions.' . $phpEx); 100 } 101 102 phpbb_chmod($this->cache_dir . 'data_global.' . $phpEx, CHMOD_WRITE); 103 } 104 else 79 if (!$this->_write('data_global')) 105 80 { 106 81 // Now, this occurred how often? ... phew, just tell the user then... 107 82 if (!@is_writable($this->cache_dir)) 108 83 { 109 trigger_error($this->cache_dir . ' is NOT writable.', E_USER_ERROR); 110 } 111 112 trigger_error('Not able to open ' . $this->cache_dir . 'data_global.' . $phpEx, E_USER_ERROR); 84 // We need to use die() here, because else we may encounter an infinite loop (the message handler calls $cache->unload()) 85 die($this->cache_dir . ' is NOT writable.'); 86 exit; 87 } 88 89 die('Not able to open ' . $this->cache_dir . 'data_global.' . $phpEx); 90 exit; 113 91 } 114 92 … … 130 108 } 131 109 110 $time = time(); 111 132 112 while (($entry = readdir($dir)) !== false) 133 113 { … … 137 117 } 138 118 139 $expired = true; 140 @include($this->cache_dir . $entry); 141 if ($expired) 119 if (!($handle = @fopen($this->cache_dir . $entry, 'rb'))) 120 { 121 continue; 122 } 123 124 // Skip the PHP header 125 fgets($handle); 126 127 // Skip expiration 128 $expires = (int) fgets($handle); 129 130 fclose($handle); 131 132 if ($time >= $expires) 142 133 { 143 134 $this->remove_file($this->cache_dir . $entry); … … 155 146 foreach ($this->var_expires as $var_name => $expires) 156 147 { 157 if ( time() >$expires)148 if ($time >= $expires) 158 149 { 159 150 $this->destroy($var_name); … … 179 170 } 180 171 181 @include($this->cache_dir . "data{$var_name}.$phpEx"); 182 return (isset($data)) ? $data : false; 172 return $this->_read('data' . $var_name); 183 173 } 184 174 else … … 195 185 if ($var_name[0] == '_') 196 186 { 197 global $phpEx; 198 199 if ($fp = @fopen($this->cache_dir . "data{$var_name}.$phpEx", 'wb')) 200 { 201 @flock($fp, LOCK_EX); 202 fwrite($fp, "<?php\n\$expired = (time() > " . (time() + $ttl) . ") ? true : false;\nif (\$expired) { return; }\n\n\$data = " . (sizeof($var) ? "unserialize(" . var_export(serialize($var), true) . ");" : 'array();') . "\n\n?>"); 203 @flock($fp, LOCK_UN); 204 fclose($fp); 205 206 if (!function_exists('phpbb_chmod')) 207 { 208 global $phpbb_root_path; 209 include($phpbb_root_path . 'includes/functions.' . $phpEx); 210 } 211 212 phpbb_chmod($this->cache_dir . "data{$var_name}.$phpEx", CHMOD_WRITE); 213 } 187 $this->_write('data' . $var_name, $var, time() + $ttl); 214 188 } 215 189 else … … 286 260 } 287 261 288 // The following method is more failproof than simply assuming the query is on line 3 (which it should be) 289 $check_line = @file_get_contents($this->cache_dir . $entry); 290 291 if (empty($check_line)) 262 if (!($handle = @fopen($this->cache_dir . $entry, 'rb'))) 292 263 { 293 264 continue; 294 265 } 295 266 296 // Now get the contents between /* and */ 297 $check_line = substr($check_line, strpos($check_line, '/* ') + 3, strpos($check_line, ' */') - strpos($check_line, '/* ') - 3); 298 299 $found = false; 267 // Skip the PHP header 268 fgets($handle); 269 270 // Skip expiration 271 fgets($handle); 272 273 // Grab the query, remove the LF 274 $query = substr(fgets($handle), 0, -1); 275 276 fclose($handle); 277 300 278 foreach ($table as $check_table) 301 279 { 302 280 // Better catch partial table names than no table names. ;) 303 if (strpos($ check_line, $check_table) !== false)281 if (strpos($query, $check_table) !== false) 304 282 { 305 $ found = true;283 $this->remove_file($this->cache_dir . $entry); 306 284 break; 307 285 } 308 }309 310 if ($found)311 {312 $this->remove_file($this->cache_dir . $entry);313 286 } 314 287 } … … 369 342 function sql_load($query) 370 343 { 371 global $phpEx;372 373 344 // Remove extra spaces and tabs 374 345 $query = preg_replace('/[\n\r\s\t]+/', ' ', $query); 346 347 if (($rowset = $this->_read('sql_' . md5($query))) === false) 348 { 349 return false; 350 } 351 375 352 $query_id = sizeof($this->sql_rowset); 376 377 if (!file_exists($this->cache_dir . 'sql_' . md5($query) . ".$phpEx")) 378 { 379 return false; 380 } 381 382 @include($this->cache_dir . 'sql_' . md5($query) . ".$phpEx"); 383 384 if (!isset($expired)) 385 { 386 return false; 387 } 388 else if ($expired) 389 { 390 $this->remove_file($this->cache_dir . 'sql_' . md5($query) . ".$phpEx", true); 391 return false; 392 } 393 353 $this->sql_rowset[$query_id] = $rowset; 394 354 $this->sql_row_pointer[$query_id] = 0; 395 355 … … 402 362 function sql_save($query, &$query_result, $ttl) 403 363 { 404 global $db , $phpEx;364 global $db; 405 365 406 366 // Remove extra spaces and tabs 407 367 $query = preg_replace('/[\n\r\s\t]+/', ' ', $query); 408 $filename = $this->cache_dir . 'sql_' . md5($query) . '.' . $phpEx; 409 410 if ($fp = @fopen($filename, 'wb')) 411 { 412 @flock($fp, LOCK_EX); 413 414 $query_id = sizeof($this->sql_rowset); 415 $this->sql_rowset[$query_id] = array(); 416 $this->sql_row_pointer[$query_id] = 0; 417 418 while ($row = $db->sql_fetchrow($query_result)) 419 { 420 $this->sql_rowset[$query_id][] = $row; 421 } 422 $db->sql_freeresult($query_result); 423 424 $file = "<?php\n\n/* " . str_replace('*/', '*\/', $query) . " */\n"; 425 $file .= "\n\$expired = (time() > " . (time() + $ttl) . ") ? true : false;\nif (\$expired) { return; }\n"; 426 427 fwrite($fp, $file . "\n\$this->sql_rowset[\$query_id] = " . (sizeof($this->sql_rowset[$query_id]) ? "unserialize(" . var_export(serialize($this->sql_rowset[$query_id]), true) . ");" : 'array();') . "\n\n?>"); 428 @flock($fp, LOCK_UN); 429 fclose($fp); 368 369 $query_id = sizeof($this->sql_rowset); 370 $this->sql_rowset[$query_id] = array(); 371 $this->sql_row_pointer[$query_id] = 0; 372 373 while ($row = $db->sql_fetchrow($query_result)) 374 { 375 $this->sql_rowset[$query_id][] = $row; 376 } 377 $db->sql_freeresult($query_result); 378 379 if ($this->_write('sql_' . md5($query), $this->sql_rowset[$query_id], $ttl + time(), $query)) 380 { 381 $query_result = $query_id; 382 } 383 } 384 385 /** 386 * Ceck if a given sql query exist in cache 387 */ 388 function sql_exists($query_id) 389 { 390 return isset($this->sql_rowset[$query_id]); 391 } 392 393 /** 394 * Fetch row from cache (database) 395 */ 396 function sql_fetchrow($query_id) 397 { 398 if ($this->sql_row_pointer[$query_id] < sizeof($this->sql_rowset[$query_id])) 399 { 400 return $this->sql_rowset[$query_id][$this->sql_row_pointer[$query_id]++]; 401 } 402 403 return false; 404 } 405 406 /** 407 * Fetch a field from the current row of a cached database result (database) 408 */ 409 function sql_fetchfield($query_id, $field) 410 { 411 if ($this->sql_row_pointer[$query_id] < sizeof($this->sql_rowset[$query_id])) 412 { 413 return (isset($this->sql_rowset[$query_id][$this->sql_row_pointer[$query_id]][$field])) ? $this->sql_rowset[$query_id][$this->sql_row_pointer[$query_id]++][$field] : false; 414 } 415 416 return false; 417 } 418 419 /** 420 * Seek a specific row in an a cached database result (database) 421 */ 422 function sql_rowseek($rownum, $query_id) 423 { 424 if ($rownum >= sizeof($this->sql_rowset[$query_id])) 425 { 426 return false; 427 } 428 429 $this->sql_row_pointer[$query_id] = $rownum; 430 return true; 431 } 432 433 /** 434 * Free memory used for a cached database result (database) 435 */ 436 function sql_freeresult($query_id) 437 { 438 if (!isset($this->sql_rowset[$query_id])) 439 { 440 return false; 441 } 442 443 unset($this->sql_rowset[$query_id]); 444 unset($this->sql_row_pointer[$query_id]); 445 446 return true; 447 } 448 449 /** 450 * Read cached data from a specified file 451 * 452 * @access private 453 * @param string $filename Filename to write 454 * @return mixed False if an error was encountered, otherwise the data type of the cached data 455 */ 456 function _read($filename) 457 { 458 global $phpEx; 459 460 $file = "{$this->cache_dir}$filename.$phpEx"; 461 462 $type = substr($filename, 0, strpos($filename, '_')); 463 464 if (!file_exists($file)) 465 { 466 return false; 467 } 468 469 if (!($handle = @fopen($file, 'rb'))) 470 { 471 return false; 472 } 473 474 // Skip the PHP header 475 fgets($handle); 476 477 if ($filename == 'data_global') 478 { 479 $this->vars = $this->var_expires = array(); 480 481 $time = time(); 482 483 while (($expires = (int) fgets($handle)) && !feof($handle)) 484 { 485 // Number of bytes of data 486 $bytes = substr(fgets($handle), 0, -1); 487 488 if (!is_numeric($bytes) || ($bytes = (int) $bytes) === 0) 489 { 490 // We cannot process the file without a valid number of bytes 491 // so we discard it 492 fclose($handle); 493 494 $this->vars = $this->var_expires = array(); 495 $this->is_modified = false; 496 497 $this->remove_file($file); 498 499 return false; 500 } 501 502 if ($time >= $expires) 503 { 504 fseek($handle, $bytes, SEEK_CUR); 505 506 continue; 507 } 508 509 $var_name = substr(fgets($handle), 0, -1); 510 511 // Read the length of bytes that consists of data. 512 $data = fread($handle, $bytes - strlen($var_name)); 513 $data = @unserialize($data); 514 515 // Don't use the data if it was invalid 516 if ($data !== false) 517 { 518 $this->vars[$var_name] = $data; 519 $this->var_expires[$var_name] = $expires; 520 } 521 522 // Absorb the LF 523 fgets($handle); 524 } 525 526 fclose($handle); 527 528 $this->is_modified = false; 529 530 return true; 531 } 532 else 533 { 534 $data = false; 535 $line = 0; 536 537 while (($buffer = fgets($handle)) && !feof($handle)) 538 { 539 $buffer = substr($buffer, 0, -1); // Remove the LF 540 541 // $buffer is only used to read integers 542 // if it is non numeric we have an invalid 543 // cache file, which we will now remove. 544 if (!is_numeric($buffer)) 545 { 546 break; 547 } 548 549 if ($line == 0) 550 { 551 $expires = (int) $buffer; 552 553 if (time() >= $expires) 554 { 555 break; 556 } 557 558 if ($type == 'sql') 559 { 560 // Skip the query 561 fgets($handle); 562 } 563 } 564 else if ($line == 1) 565 { 566 $bytes = (int) $buffer; 567 568 // Never should have 0 bytes 569 if (!$bytes) 570 { 571 break; 572 } 573 574 // Grab the serialized data 575 $data = fread($handle, $bytes); 576 577 // Read 1 byte, to trigger EOF 578 fread($handle, 1); 579 580 if (!feof($handle)) 581 { 582 // Somebody tampered with our data 583 $data = false; 584 } 585 break; 586 } 587 else 588 { 589 // Something went wrong 590 break; 591 } 592 $line++; 593 } 594 fclose($handle); 595 596 // unserialize if we got some data 597 $data = ($data !== false) ? @unserialize($data) : $data; 598 599 if ($data === false) 600 { 601 $this->remove_file($file); 602 return false; 603 } 604 605 return $data; 606 } 607 } 608 609 /** 610 * Write cache data to a specified file 611 * 612 * 'data_global' is a special case and the generated format is different for this file: 613 * <code> 614 * <?php exit; ?> 615 * (expiration) 616 * (length of var and serialised data) 617 * (var) 618 * (serialised data) 619 * ... (repeat) 620 * </code> 621 * 622 * The other files have a similar format: 623 * <code> 624 * <?php exit; ?> 625 * (expiration) 626 * (query) [SQL files only] 627 * (length of serialised data) 628 * (serialised data) 629 * </code> 630 * 631 * @access private 632 * @param string $filename Filename to write 633 * @param mixed $data Data to store 634 * @param int $expires Timestamp when the data expires 635 * @param string $query Query when caching SQL queries 636 * @return bool True if the file was successfully created, otherwise false 637 */ 638 function _write($filename, $data = null, $expires = 0, $query = '') 639 { 640 global $phpEx; 641 642 $file = "{$this->cache_dir}$filename.$phpEx"; 643 644 if ($handle = @fopen($file, 'wb')) 645 { 646 @flock($handle, LOCK_EX); 647 648 // File header 649 fwrite($handle, '<' . '?php exit; ?' . '>'); 650 651 if ($filename == 'data_global') 652 { 653 // Global data is a different format 654 foreach ($this->vars as $var => $data) 655 { 656 if (strpos($var, "\r") !== false || strpos($var, "\n") !== false) 657 { 658 // CR/LF would cause fgets() to read the cache file incorrectly 659 // do not cache test entries, they probably won't be read back 660 // the cache keys should really be alphanumeric with a few symbols. 661 continue; 662 } 663 $data = serialize($data); 664 665 // Write out the expiration time 666 fwrite($handle, "\n" . $this->var_expires[$var] . "\n"); 667 668 // Length of the remaining data for this var (ignoring two LF's) 669 fwrite($handle, strlen($data . $var) . "\n"); 670 fwrite($handle, $var . "\n"); 671 fwrite($handle, $data); 672 } 673 } 674 else 675 { 676 fwrite($handle, "\n" . $expires . "\n"); 677 678 if (strpos($filename, 'sql_') === 0) 679 { 680 fwrite($handle, $query . "\n"); 681 } 682 $data = serialize($data); 683 684 fwrite($handle, strlen($data) . "\n"); 685 fwrite($handle, $data); 686 } 687 688 @flock($handle, LOCK_UN); 689 fclose($handle); 430 690 431 691 if (!function_exists('phpbb_chmod')) … … 435 695 } 436 696 437 phpbb_chmod($filename, CHMOD_WRITE); 438 439 $query_result = $query_id; 440 } 441 } 442 443 /** 444 * Ceck if a given sql query exist in cache 445 */ 446 function sql_exists($query_id) 447 { 448 return isset($this->sql_rowset[$query_id]); 449 } 450 451 /** 452 * Fetch row from cache (database) 453 */ 454 function sql_fetchrow($query_id) 455 { 456 if ($this->sql_row_pointer[$query_id] < sizeof($this->sql_rowset[$query_id])) 457 { 458 return $this->sql_rowset[$query_id][$this->sql_row_pointer[$query_id]++]; 697 phpbb_chmod($file, CHMOD_READ | CHMOD_WRITE); 698 699 return true; 459 700 } 460 701 461 702 return false; 462 }463 464 /**465 * Fetch a field from the current row of a cached database result (database)466 */467 function sql_fetchfield($query_id, $field)468 {469 if ($this->sql_row_pointer[$query_id] < sizeof($this->sql_rowset[$query_id]))470 {471 return (isset($this->sql_rowset[$query_id][$this->sql_row_pointer[$query_id]][$field])) ? $this->sql_rowset[$query_id][$this->sql_row_pointer[$query_id]][$field] : false;472 }473 474 return false;475 }476 477 /**478 * Seek a specific row in an a cached database result (database)479 */480 function sql_rowseek($rownum, $query_id)481 {482 if ($rownum >= sizeof($this->sql_rowset[$query_id]))483 {484 return false;485 }486 487 $this->sql_row_pointer[$query_id] = $rownum;488 return true;489 }490 491 /**492 * Free memory used for a cached database result (database)493 */494 function sql_freeresult($query_id)495 {496 if (!isset($this->sql_rowset[$query_id]))497 {498 return false;499 }500 501 unset($this->sql_rowset[$query_id]);502 unset($this->sql_row_pointer[$query_id]);503 504 return true;505 703 } 506 704 -
trunk/forum/includes/acp/acp_attachments.php
r400 r702 3 3 * 4 4 * @package acp 5 * @version $Id : acp_attachments.php 9041 2008-11-02 11:19:12Z acydburn$5 * @version $Id$ 6 6 * @copyright (c) 2005 phpBB Group 7 7 * @license http://opensource.org/licenses/gpl-license.php GNU Public License … … 125 125 'img_display_inlined' => array('lang' => 'DISPLAY_INLINED', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true), 126 126 'img_create_thumbnail' => array('lang' => 'CREATE_THUMBNAIL', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true), 127 'img_max_thumb_width' => array('lang' => 'MAX_THUMB_WIDTH', 'validate' => 'int', 'type' => 'text:7:15', 'explain' => true, 'append' => ' px'),127 'img_max_thumb_width' => array('lang' => 'MAX_THUMB_WIDTH', 'validate' => 'int', 'type' => 'text:7:15', 'explain' => true, 'append' => ' ' . $user->lang['PIXEL']), 128 128 'img_min_thumb_filesize' => array('lang' => 'MIN_THUMB_FILESIZE', 'validate' => 'int', 'type' => 'text:7:15', 'explain' => true, 'append' => ' ' . $user->lang['BYTES']), 129 129 'img_imagick' => array('lang' => 'IMAGICK_PATH', 'validate' => 'string', 'type' => 'text:20:200', 'explain' => true, 'append' => ' <span>[ <a href="' . $this->u_action . '&action=imgmagick">' . $user->lang['SEARCH_IMAGICK'] . '</a> ]</span>'), 130 'img_max' => array('lang' => 'MAX_IMAGE_SIZE', 'validate' => 'int', 'type' => 'dimension:3:4', 'explain' => true, 'append' => ' px'),131 'img_link' => array('lang' => 'IMAGE_LINK_SIZE', 'validate' => 'int', 'type' => 'dimension:3:4', 'explain' => true, 'append' => ' px'),130 'img_max' => array('lang' => 'MAX_IMAGE_SIZE', 'validate' => 'int', 'type' => 'dimension:3:4', 'explain' => true, 'append' => ' ' . $user->lang['PIXEL']), 131 'img_link' => array('lang' => 'IMAGE_LINK_SIZE', 'validate' => 'int', 'type' => 'dimension:3:4', 'explain' => true, 'append' => ' ' . $user->lang['PIXEL']), 132 132 ) 133 133 ); … … 685 685 } 686 686 687 $size_format = ($ext_group_row['max_filesize'] >= 1048576) ? 'mb' : (($ext_group_row['max_filesize'] >= 1024) ? 'kb' : 'b'); 688 $ext_group_row['max_filesize'] = get_formatted_filesize($ext_group_row['max_filesize'], false); 687 $max_filesize = get_formatted_filesize($ext_group_row['max_filesize'], false, array('mb', 'kb', 'b')); 688 $size_format = $max_filesize['si_identifier']; 689 $ext_group_row['max_filesize'] = $max_filesize['value']; 689 690 690 691 $img_path = $config['upload_icons_path']; … … 695 696 $imglist = filelist($phpbb_root_path . $img_path); 696 697 697 if ( sizeof($imglist))698 if (!empty($imglist[''])) 698 699 { 699 700 $imglist = array_values($imglist); … … 1004 1005 if ($files_added) 1005 1006 { 1006 set_config ('upload_dir_size', $config['upload_dir_size'] +$space_taken, true);1007 set_config ('num_files', $config['num_files'] +$files_added, true);1007 set_config_count('upload_dir_size', $space_taken, true); 1008 set_config_count('num_files', $files_added, true); 1008 1009 } 1009 1010 } … … 1027 1028 'FILESIZE' => get_formatted_filesize($row['filesize']), 1028 1029 'FILETIME' => $user->format_date($row['filetime']), 1029 'REAL_FILENAME' => basename($row['real_filename']),1030 'PHYSICAL_FILENAME' => basename($row['physical_filename']),1030 'REAL_FILENAME' => utf8_basename($row['real_filename']), 1031 'PHYSICAL_FILENAME' => utf8_basename($row['physical_filename']), 1031 1032 'ATTACH_ID' => $row['attach_id'], 1032 1033 'POST_IDS' => (!empty($post_ids[$row['attach_id']])) ? $post_ids[$row['attach_id']] : '', … … 1430 1431 { 1431 1432 // Determine size var and adjust the value accordingly 1432 $size_var = ($value >= 1048576) ? 'mb' : (($value >= 1024) ? 'kb' : 'b'); 1433 $value = get_formatted_filesize($value, false); 1433 $filesize = get_formatted_filesize($value, false, array('mb', 'kb', 'b')); 1434 $size_var = $filesize['si_identifier']; 1435 $value = $filesize['value']; 1434 1436 1435 1437 return '<input type="text" id="' . $key . '" size="8" maxlength="15" name="config[' . $key . ']" value="' . $value . '" /> <select name="' . $key . '">' . size_select_options($size_var) . '</select>'; -
trunk/forum/includes/acp/acp_ban.php
r400 r702 3 3 * 4 4 * @package acp 5 * @version $Id : acp_ban.php 8479 2008-03-29 00:22:48Z naderman$5 * @version $Id$ 6 6 * @copyright (c) 2005 phpBB Group 7 7 * @license http://opensource.org/licenses/gpl-license.php GNU Public License … … 157 157 WHERE (ban_end >= ' . time() . " 158 158 OR ban_end = 0) 159 AND ban_ip <> ''"; 159 AND ban_ip <> '' 160 ORDER BY ban_ip"; 160 161 break; 161 162 … … 169 170 WHERE (ban_end >= ' . time() . " 170 171 OR ban_end = 0) 171 AND ban_email <> ''"; 172 AND ban_email <> '' 173 ORDER BY ban_email"; 172 174 break; 173 175 } … … 182 184 183 185 $time_length = ($row['ban_end']) ? ($row['ban_end'] - $row['ban_start']) / 60 : 0; 184 $ban_length[$row['ban_id']] = (isset($ban_end_text[$time_length])) ? $ban_end_text[$time_length] : $user->lang['UNTIL'] . ' -> ' . $user->format_date($row['ban_end']); 186 187 if ($time_length == 0) 188 { 189 // Banned permanently 190 $ban_length[$row['ban_id']] = $user->lang['PERMANENT']; 191 } 192 else if (isset($ban_end_text[$time_length])) 193 { 194 // Banned for a given duration 195 $ban_length[$row['ban_id']] = sprintf($user->lang['BANNED_UNTIL_DURATION'], $ban_end_text[$time_length], $user->format_date($row['ban_end'], false, true)); 196 } 197 else 198 { 199 // Banned until given date 200 $ban_length[$row['ban_id']] = sprintf($user->lang['BANNED_UNTIL_DATE'], $user->format_date($row['ban_end'], false, true)); 201 } 185 202 186 203 $ban_reasons[$row['ban_id']] = $row['ban_reason']; -
trunk/forum/includes/acp/acp_bbcodes.php
r400 r702 3 3 * 4 4 * @package acp 5 * @version $Id : acp_bbcodes.php 8743 2008-08-12 16:03:18Z Kellanved$5 * @version $Id$ 6 6 * @copyright (c) 2005 phpBB Group 7 7 * @license http://opensource.org/licenses/gpl-license.php GNU Public License … … 125 125 case 'create': 126 126 127 $data = $this->build_regexp($bbcode_match, $bbcode_tpl); 128 129 // Make sure the user didn't pick a "bad" name for the BBCode tag. 130 $hard_coded = array('code', 'quote', 'quote=', 'attachment', 'attachment=', 'b', 'i', 'url', 'url=', 'img', 'size', 'size=', 'color', 'color=', 'u', 'list', 'list=', 'email', 'email=', 'flash', 'flash='); 131 132 if (($action == 'modify' && strtolower($data['bbcode_tag']) !== strtolower($row['bbcode_tag'])) || ($action == 'create')) 133 { 134 $sql = 'SELECT 1 as test 135 FROM ' . BBCODES_TABLE . " 136 WHERE LOWER(bbcode_tag) = '" . $db->sql_escape(strtolower($data['bbcode_tag'])) . "'"; 137 $result = $db->sql_query($sql); 138 $info = $db->sql_fetchrow($result); 139 $db->sql_freeresult($result); 140 141 // Grab the end, interrogate the last closing tag 142 if ($info['test'] === '1' || in_array(strtolower($data['bbcode_tag']), $hard_coded) || (preg_match('#\[/([^[]*)]$#', $bbcode_match, $regs) && in_array(strtolower($regs[1]), $hard_coded))) 143 { 144 trigger_error($user->lang['BBCODE_INVALID_TAG_NAME'] . adm_back_link($this->u_action), E_USER_WARNING); 145 } 146 } 147 148 if (substr($data['bbcode_tag'], -1) === '=') 149 { 150 $test = substr($data['bbcode_tag'], 0, -1); 151 } 152 else 153 { 154 $test = $data['bbcode_tag']; 155 } 156 157 if (!preg_match('%\\[' . $test . '[^]]*].*?\\[/' . $test . ']%s', $bbcode_match)) 158 { 159 trigger_error($user->lang['BBCODE_OPEN_ENDED_TAG'] . adm_back_link($this->u_action), E_USER_WARNING); 160 } 161 162 if (strlen($data['bbcode_tag']) > 16) 163 { 164 trigger_error($user->lang['BBCODE_TAG_TOO_LONG'] . adm_back_link($this->u_action), E_USER_WARNING); 165 } 166 167 if (strlen($bbcode_match) > 4000) 168 { 169 trigger_error($user->lang['BBCODE_TAG_DEF_TOO_LONG'] . adm_back_link($this->u_action), E_USER_WARNING); 170 } 171 172 173 if (strlen($bbcode_helpline) > 255) 174 { 175 trigger_error($user->lang['BBCODE_HELPLINE_TOO_LONG'] . adm_back_link($this->u_action), E_USER_WARNING); 176 } 177 178 $sql_ary = array( 179 'bbcode_tag' => $data['bbcode_tag'], 180 'bbcode_match' => $bbcode_match, 181 'bbcode_tpl' => $bbcode_tpl, 182 'display_on_posting' => $display_on_posting, 183 'bbcode_helpline' => $bbcode_helpline, 184 'first_pass_match' => $data['first_pass_match'], 185 'first_pass_replace' => $data['first_pass_replace'], 186 'second_pass_match' => $data['second_pass_match'], 187 'second_pass_replace' => $data['second_pass_replace'] 188 ); 189 190 if ($action == 'create') 191 { 192 $sql = 'SELECT MAX(bbcode_id) as max_bbcode_id 193 FROM ' . BBCODES_TABLE; 194 $result = $db->sql_query($sql); 195 $row = $db->sql_fetchrow($result); 196 $db->sql_freeresult($result); 197 198 if ($row) 199 { 200 $bbcode_id = $row['max_bbcode_id'] + 1; 201 202 // Make sure it is greater than the core bbcode ids... 203 if ($bbcode_id <= NUM_CORE_BBCODES) 127 $warn_text = preg_match('%<[^>]*\{text[\d]*\}[^>]*>%i', $bbcode_tpl); 128 if (!$warn_text || confirm_box(true)) 129 { 130 $data = $this->build_regexp($bbcode_match, $bbcode_tpl); 131 132 // Make sure the user didn't pick a "bad" name for the BBCode tag. 133 $hard_coded = array('code', 'quote', 'quote=', 'attachment', 'attachment=', 'b', 'i', 'url', 'url=', 'img', 'size', 'size=', 'color', 'color=', 'u', 'list', 'list=', 'email', 'email=', 'flash', 'flash='); 134 135 if (($action == 'modify' && strtolower($data['bbcode_tag']) !== strtolower($row['bbcode_tag'])) || ($action == 'create')) 136 { 137 $sql = 'SELECT 1 as test 138 FROM ' . BBCODES_TABLE . " 139 WHERE LOWER(bbcode_tag) = '" . $db->sql_escape(strtolower($data['bbcode_tag'])) . "'"; 140 $result = $db->sql_query($sql); 141 $info = $db->sql_fetchrow($result); 142 $db->sql_freeresult($result); 143 144 // Grab the end, interrogate the last closing tag 145 if ($info['test'] === '1' || in_array(strtolower($data['bbcode_tag']), $hard_coded) || (preg_match('#\[/([^[]*)]$#', $bbcode_match, $regs) && in_array(strtolower($regs[1]), $hard_coded))) 146 { 147 trigger_error($user->lang['BBCODE_INVALID_TAG_NAME'] . adm_back_link($this->u_action), E_USER_WARNING); 148 } 149 } 150 151 if (substr($data['bbcode_tag'], -1) === '=') 152 { 153 $test = substr($data['bbcode_tag'], 0, -1); 154 } 155 else 156 { 157 $test = $data['bbcode_tag']; 158 } 159 160 if (!preg_match('%\\[' . $test . '[^]]*].*?\\[/' . $test . ']%s', $bbcode_match)) 161 { 162 trigger_error($user->lang['BBCODE_OPEN_ENDED_TAG'] . adm_back_link($this->u_action), E_USER_WARNING); 163 } 164 165 if (strlen($data['bbcode_tag']) > 16) 166 { 167 trigger_error($user->lang['BBCODE_TAG_TOO_LONG'] . adm_back_link($this->u_action), E_USER_WARNING); 168 } 169 170 if (strlen($bbcode_match) > 4000) 171 { 172 trigger_error($user->lang['BBCODE_TAG_DEF_TOO_LONG'] . adm_back_link($this->u_action), E_USER_WARNING); 173 } 174 175 176 if (strlen($bbcode_helpline) > 255) 177 { 178 trigger_error($user->lang['BBCODE_HELPLINE_TOO_LONG'] . adm_back_link($this->u_action), E_USER_WARNING); 179 } 180 181 $sql_ary = array( 182 'bbcode_tag' => $data['bbcode_tag'], 183 'bbcode_match' => $bbcode_match, 184 'bbcode_tpl' => $bbcode_tpl, 185 'display_on_posting' => $display_on_posting, 186 'bbcode_helpline' => $bbcode_helpline, 187 'first_pass_match' => $data['first_pass_match'], 188 'first_pass_replace' => $data['first_pass_replace'], 189 'second_pass_match' => $data['second_pass_match'], 190 'second_pass_replace' => $data['second_pass_replace'] 191 ); 192 193 if ($action == 'create') 194 { 195 $sql = 'SELECT MAX(bbcode_id) as max_bbcode_id 196 FROM ' . BBCODES_TABLE; 197 $result = $db->sql_query($sql); 198 $row = $db->sql_fetchrow($result); 199 $db->sql_freeresult($result); 200 201 if ($row) 202 { 203 $bbcode_id = $row['max_bbcode_id'] + 1; 204 205 // Make sure it is greater than the core bbcode ids... 206 if ($bbcode_id <= NUM_CORE_BBCODES) 207 { 208 $bbcode_id = NUM_CORE_BBCODES + 1; 209 } 210 } 211 else 204 212 { 205 213 $bbcode_id = NUM_CORE_BBCODES + 1; 206 214 } 215 216 if ($bbcode_id > 1511) 217 { 218 trigger_error($user->lang['TOO_MANY_BBCODES'] . adm_back_link($this->u_action), E_USER_WARNING); 219 } 220 221 $sql_ary['bbcode_id'] = (int) $bbcode_id; 222 223 $db->sql_query('INSERT INTO ' . BBCODES_TABLE . $db->sql_build_array('INSERT', $sql_ary)); 224 $cache->destroy('sql', BBCODES_TABLE); 225 226 $lang = 'BBCODE_ADDED'; 227 $log_action = 'LOG_BBCODE_ADD'; 207 228 } 208 229 else 209 230 { 210 $bbcode_id = NUM_CORE_BBCODES + 1; 211 } 212 213 if ($bbcode_id > 1511) 214 { 215 trigger_error($user->lang['TOO_MANY_BBCODES'] . adm_back_link($this->u_action), E_USER_WARNING); 216 } 217 218 $sql_ary['bbcode_id'] = (int) $bbcode_id; 219 220 $db->sql_query('INSERT INTO ' . BBCODES_TABLE . $db->sql_build_array('INSERT', $sql_ary)); 221 $cache->destroy('sql', BBCODES_TABLE); 222 223 $lang = 'BBCODE_ADDED'; 224 $log_action = 'LOG_BBCODE_ADD'; 231 $sql = 'UPDATE ' . BBCODES_TABLE . ' 232 SET ' . $db->sql_build_array('UPDATE', $sql_ary) . ' 233 WHERE bbcode_id = ' . $bbcode_id; 234 $db->sql_query($sql); 235 $cache->destroy('sql', BBCODES_TABLE); 236 237 $lang = 'BBCODE_EDITED'; 238 $log_action = 'LOG_BBCODE_EDIT'; 239 } 240 241 add_log('admin', $log_action, $data['bbcode_tag']); 242 243 trigger_error($user->lang[$lang] . adm_back_link($this->u_action)); 225 244 } 226 245 else 227 246 { 228 $sql = 'UPDATE ' . BBCODES_TABLE . ' 229 SET ' . $db->sql_build_array('UPDATE', $sql_ary) . ' 230 WHERE bbcode_id = ' . $bbcode_id; 231 $db->sql_query($sql); 232 $cache->destroy('sql', BBCODES_TABLE); 233 234 $lang = 'BBCODE_EDITED'; 235 $log_action = 'LOG_BBCODE_EDIT'; 236 } 237 238 add_log('admin', $log_action, $data['bbcode_tag']); 239 240 trigger_error($user->lang[$lang] . adm_back_link($this->u_action)); 247 confirm_box(false, $user->lang['BBCODE_DANGER'], build_hidden_fields(array( 248 'action' => $action, 249 'bbcode' => $bbcode_id, 250 'bbcode_match' => $bbcode_match, 251 'bbcode_tpl' => htmlspecialchars($bbcode_tpl), 252 'bbcode_helpline' => $bbcode_helpline, 253 'display_on_posting' => $display_on_posting, 254 )) 255 , 'confirm_bbcode.html'); 256 } 241 257 242 258 break; … … 300 316 $bbcode_match = trim($bbcode_match); 301 317 $bbcode_tpl = trim($bbcode_tpl); 318 $utf8 = strpos($bbcode_match, 'INTTEXT') !== false; 319 320 // make sure we have utf8 support 321 $utf8_pcre_properties = false; 322 if (version_compare(PHP_VERSION, '5.1.0', '>=') || (version_compare(PHP_VERSION, '5.0.0-dev', '<=') && version_compare(PHP_VERSION, '4.4.0', '>='))) 323 { 324 // While this is the proper range of PHP versions, PHP may not be linked with the bundled PCRE lib and instead with an older version 325 if (@preg_match('/\p{L}/u', 'a') !== false) 326 { 327 $utf8_pcre_properties = true; 328 } 329 } 302 330 303 331 $fp_match = preg_quote($bbcode_match, '!'); … … 326 354 'SIMPLETEXT' => array( 327 355 '!([a-zA-Z0-9-+.,_ ]+)!' => "$1" 356 ), 357 'INTTEXT' => array( 358 ($utf8_pcre_properties) ? '!([\p{L}\p{N}\-+,_. ]+)!u' : '!([a-zA-Z0-9\-+,_. ]+)!u' => "$1" 328 359 ), 329 360 'IDENTIFIER' => array( … … 344 375 'TEXT' => '(.*?)', 345 376 'SIMPLETEXT' => '([a-zA-Z0-9-+.,_ ]+)', 377 'INTTEXT' => ($utf8_pcre_properties) ? '([\p{L}\p{N}\-+,_. ]+)' : '([a-zA-Z0-9\-+,_. ]+)', 346 378 'IDENTIFIER' => '([a-zA-Z0-9-_]+)', 347 379 'COLOR' => '([a-zA-Z]+|#[0-9abcdefABCDEF]+)', … … 351 383 $pad = 0; 352 384 $modifiers = 'i'; 385 $modifiers .= ($utf8 && $utf8_pcre_properties) ? 'u' : ''; 353 386 354 387 if (preg_match_all('/\{(' . implode('|', array_keys($tokens)) . ')[0-9]*\}/i', $bbcode_match, $m)) … … 399 432 400 433 $fp_match = '!' . $fp_match . '!' . $modifiers; 401 $sp_match = '!' . $sp_match . '!s' ;434 $sp_match = '!' . $sp_match . '!s' . (($utf8) ? 'u' : ''); 402 435 403 436 if (strpos($fp_match, 'e') !== false) -
trunk/forum/includes/acp/acp_board.php
r400 r702 3 3 * 4 4 * @package acp 5 * @version $Id : acp_board.php 8911 2008-09-23 13:03:33Z acydburn$5 * @version $Id$ 6 6 * @copyright (c) 2005 phpBB Group 7 7 * @license http://opensource.org/licenses/gpl-license.php GNU Public License … … 30 30 global $db, $user, $auth, $template; 31 31 global $config, $phpbb_root_path, $phpbb_admin_path, $phpEx; 32 global $cache; 32 33 33 34 $user->add_lang('acp/board'); 34 35 35 36 $action = request_var('action', ''); 36 $submit = (isset($_POST['submit']) ) ? true : false;37 $submit = (isset($_POST['submit']) || isset($_POST['allow_quick_reply_enable'])) ? true : false; 37 38 38 39 $form_key = 'acp_board'; … … 65 66 'legend2' => 'WARNINGS', 66 67 'warnings_expire_days' => array('lang' => 'WARNINGS_EXPIRE', 'validate' => 'int', 'type' => 'text:3:4', 'explain' => true, 'append' => ' ' . $user->lang['DAYS']), 68 69 'legend3' => 'ACP_SUBMIT_CHANGES', 67 70 ) 68 71 ); … … 80 83 'allow_attachments' => array('lang' => 'ALLOW_ATTACHMENTS', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => false), 81 84 'allow_pm_attach' => array('lang' => 'ALLOW_PM_ATTACHMENTS', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => false), 85 'allow_pm_report' => array('lang' => 'ALLOW_PM_REPORT', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true), 82 86 'allow_bbcode' => array('lang' => 'ALLOW_BBCODE', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => false), 83 87 'allow_smilies' => array('lang' => 'ALLOW_SMILIES', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => false), … … 86 90 'allow_bookmarks' => array('lang' => 'ALLOW_BOOKMARKS', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true), 87 91 'allow_birthdays' => array('lang' => 'ALLOW_BIRTHDAYS', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true), 92 'allow_quick_reply' => array('lang' => 'ALLOW_QUICK_REPLY', 'validate' => 'bool', 'type' => 'custom', 'method' => 'quick_reply', 'explain' => true), 88 93 89 94 'legend2' => 'ACP_LOAD_SETTINGS', … … 94 99 'load_cpf_viewprofile' => array('lang' => 'LOAD_CPF_VIEWPROFILE', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => false), 95 100 'load_cpf_viewtopic' => array('lang' => 'LOAD_CPF_VIEWTOPIC', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => false), 101 102 'legend3' => 'ACP_SUBMIT_CHANGES', 96 103 ) 97 104 ); … … 109 116 'avatar_max_height' => array('lang' => 'MAX_AVATAR_SIZE', 'validate' => 'int:0', 'type' => false, 'method' => false, 'explain' => false,), 110 117 118 'allow_avatar' => array('lang' => 'ALLOW_AVATARS', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true), 111 119 'allow_avatar_local' => array('lang' => 'ALLOW_LOCAL', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => false), 112 120 'allow_avatar_remote' => array('lang' => 'ALLOW_REMOTE', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true), 113 121 'allow_avatar_upload' => array('lang' => 'ALLOW_UPLOAD', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => false), 122 'allow_avatar_remote_upload'=> array('lang' => 'ALLOW_REMOTE_UPLOAD', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true), 114 123 'avatar_filesize' => array('lang' => 'MAX_FILESIZE', 'validate' => 'int:0', 'type' => 'text:4:10', 'explain' => true, 'append' => ' ' . $user->lang['BYTES']), 115 124 'avatar_min' => array('lang' => 'MIN_AVATAR_SIZE', 'validate' => 'int:0', 'type' => 'dimension:3:4', 'explain' => true, 'append' => ' ' . $user->lang['PIXEL']), … … 144 153 'auth_img_pm' => array('lang' => 'ALLOW_IMG_PM', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => false), 145 154 'auth_flash_pm' => array('lang' => 'ALLOW_FLASH_PM', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true), 146 'enable_pm_icons' => array('lang' => 'ENABLE_PM_ICONS', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => false) 155 'enable_pm_icons' => array('lang' => 'ENABLE_PM_ICONS', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => false), 156 157 'legend3' => 'ACP_SUBMIT_CHANGES', 147 158 ) 148 159 ); … … 163 174 'allow_bookmarks' => array('lang' => 'ALLOW_BOOKMARKS', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true), 164 175 'enable_post_confirm' => array('lang' => 'VISUAL_CONFIRM_POST', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true), 176 'allow_quick_reply' => array('lang' => 'ALLOW_QUICK_REPLY', 'validate' => 'bool', 'type' => 'custom', 'method' => 'quick_reply', 'explain' => true), 165 177 166 178 'legend2' => 'POSTING', 167 'enable_queue_trigger' => array('lang' => 'ENABLE_QUEUE_TRIGGER', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true),168 'queue_trigger_posts' => array('lang' => 'QUEUE_TRIGGER_POSTS', 'validate' => 'int:0:250', 'type' => 'text:4:4', 'explain' => true),169 179 'bump_type' => false, 170 180 'edit_time' => array('lang' => 'EDIT_TIME', 'validate' => 'int:0', 'type' => 'text:5:5', 'explain' => true, 'append' => ' ' . $user->lang['MINUTES']), 181 'delete_time' => array('lang' => 'DELETE_TIME', 'validate' => 'int:0', 'type' => 'text:5:5', 'explain' => true, 'append' => ' ' . $user->lang['MINUTES']), 171 182 'display_last_edited' => array('lang' => 'DISPLAY_LAST_EDITED', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true), 172 183 'flood_interval' => array('lang' => 'FLOOD_INTERVAL', 'validate' => 'int:0', 'type' => 'text:3:10', 'explain' => true, 'append' => ' ' . $user->lang['SECONDS']), … … 174 185 'topics_per_page' => array('lang' => 'TOPICS_PER_PAGE', 'validate' => 'int:1', 'type' => 'text:3:4', 'explain' => false), 175 186 'posts_per_page' => array('lang' => 'POSTS_PER_PAGE', 'validate' => 'int:1', 'type' => 'text:3:4', 'explain' => false), 187 'smilies_per_page' => array('lang' => 'SMILIES_PER_PAGE', 'validate' => 'int:1', 'type' => 'text:3:4', 'explain' => false), 176 188 'hot_threshold' => array('lang' => 'HOT_THRESHOLD', 'validate' => 'int:0', 'type' => 'text:3:4', 'explain' => true), 177 189 'max_poll_options' => array('lang' => 'MAX_POLL_OPTIONS', 'validate' => 'int:2:127', 'type' => 'text:4:4', 'explain' => false), 178 190 'max_post_chars' => array('lang' => 'CHAR_LIMIT', 'validate' => 'int:0', 'type' => 'text:4:6', 'explain' => true), 191 'min_post_chars' => array('lang' => 'MIN_CHAR_LIMIT', 'validate' => 'int:0', 'type' => 'text:4:6', 'explain' => true), 179 192 'max_post_smilies' => array('lang' => 'SMILIES_LIMIT', 'validate' => 'int:0', 'type' => 'text:4:4', 'explain' => true), 180 193 'max_post_urls' => array('lang' => 'MAX_POST_URLS', 'validate' => 'int:0', 'type' => 'text:5:4', 'explain' => true), … … 183 196 'max_post_img_width' => array('lang' => 'MAX_POST_IMG_WIDTH', 'validate' => 'int:0', 'type' => 'text:5:4', 'explain' => true, 'append' => ' ' . $user->lang['PIXEL']), 184 197 'max_post_img_height' => array('lang' => 'MAX_POST_IMG_HEIGHT', 'validate' => 'int:0', 'type' => 'text:5:4', 'explain' => true, 'append' => ' ' . $user->lang['PIXEL']), 198 199 'legend3' => 'ACP_SUBMIT_CHANGES', 185 200 ) 186 201 ); … … 206 221 'max_sig_img_width' => array('lang' => 'MAX_SIG_IMG_WIDTH', 'validate' => 'int:0', 'type' => 'text:5:4', 'explain' => true, 'append' => ' ' . $user->lang['PIXEL']), 207 222 'max_sig_img_height' => array('lang' => 'MAX_SIG_IMG_HEIGHT', 'validate' => 'int:0', 'type' => 'text:5:4', 'explain' => true, 'append' => ' ' . $user->lang['PIXEL']), 223 224 'legend3' => 'ACP_SUBMIT_CHANGES', 208 225 ) 209 226 ); … … 219 236 220 237 'require_activation' => array('lang' => 'ACC_ACTIVATION', 'validate' => 'int', 'type' => 'custom', 'method' => 'select_acc_activation', 'explain' => true), 238 'new_member_post_limit' => array('lang' => 'NEW_MEMBER_POST_LIMIT', 'validate' => 'int:0:255', 'type' => 'text:4:4', 'explain' => true, 'append' => ' ' . $user->lang['POSTS']), 239 'new_member_group_default'=> array('lang' => 'NEW_MEMBER_GROUP_DEFAULT', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true), 221 240 'min_name_chars' => array('lang' => 'USERNAME_LENGTH', 'validate' => 'int:1', 'type' => 'custom:5:180', 'method' => 'username_length', 'explain' => true), 222 241 'min_pass_chars' => array('lang' => 'PASSWORD_LENGTH', 'validate' => 'int:1', 'type' => 'custom', 'method' => 'password_length', 'explain' => true), … … 236 255 'coppa_mail' => array('lang' => 'COPPA_MAIL', 'validate' => 'string', 'type' => 'textarea:5:40', 'explain' => true), 237 256 'coppa_fax' => array('lang' => 'COPPA_FAX', 'validate' => 'string', 'type' => 'text:25:100', 'explain' => false), 257 258 'legend4' => 'ACP_SUBMIT_CHANGES', 259 ) 260 ); 261 break; 262 263 case 'feed': 264 $display_vars = array( 265 'title' => 'ACP_FEED_MANAGEMENT', 266 'vars' => array( 267 'legend1' => 'ACP_FEED_GENERAL', 268 'feed_enable' => array('lang' => 'ACP_FEED_ENABLE', 'validate' => 'bool', 'type' => 'radio:enabled_disabled', 'explain' => true ), 269 'feed_item_statistics' => array('lang' => 'ACP_FEED_ITEM_STATISTICS', 'validate' => 'bool', 'type' => 'radio:enabled_disabled', 'explain' => true), 270 'feed_http_auth' => array('lang' => 'ACP_FEED_HTTP_AUTH', 'validate' => 'bool', 'type' => 'radio:enabled_disabled', 'explain' => true), 271 272 'legend2' => 'ACP_FEED_POST_BASED', 273 'feed_limit_post' => array('lang' => 'ACP_FEED_LIMIT', 'validate' => 'int:5', 'type' => 'text:3:4', 'explain' => true), 274 'feed_overall' => array('lang' => 'ACP_FEED_OVERALL', 'validate' => 'bool', 'type' => 'radio:enabled_disabled', 'explain' => true ), 275 'feed_forum' => array('lang' => 'ACP_FEED_FORUM', 'validate' => 'bool', 'type' => 'radio:enabled_disabled', 'explain' => true ), 276 'feed_topic' => array('lang' => 'ACP_FEED_TOPIC', 'validate' => 'bool', 'type' => 'radio:enabled_disabled', 'explain' => true ), 277 278 'legend3' => 'ACP_FEED_TOPIC_BASED', 279 'feed_limit_topic' => array('lang' => 'ACP_FEED_LIMIT', 'validate' => 'int:5', 'type' => 'text:3:4', 'explain' => true), 280 'feed_topics_new' => array('lang' => 'ACP_FEED_TOPICS_NEW', 'validate' => 'bool', 'type' => 'radio:enabled_disabled', 'explain' => true ), 281 'feed_topics_active' => array('lang' => 'ACP_FEED_TOPICS_ACTIVE', 'validate' => 'bool', 'type' => 'radio:enabled_disabled', 'explain' => true ), 282 'feed_news_id' => array('lang' => 'ACP_FEED_NEWS', 'validate' => 'string', 'type' => 'custom', 'method' => 'select_news_forums', 'explain' => true), 283 284 'legend4' => 'ACP_FEED_SETTINGS_OTHER', 285 'feed_overall_forums' => array('lang' => 'ACP_FEED_OVERALL_FORUMS', 'validate' => 'bool', 'type' => 'radio:enabled_disabled', 'explain' => true ), 286 'feed_exclude_id' => array('lang' => 'ACP_FEED_EXCLUDE_ID', 'validate' => 'string', 'type' => 'custom', 'method' => 'select_exclude_forums', 'explain' => true), 238 287 ) 239 288 ); … … 280 329 'load_cpf_viewprofile' => array('lang' => 'LOAD_CPF_VIEWPROFILE', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => false), 281 330 'load_cpf_viewtopic' => array('lang' => 'LOAD_CPF_VIEWTOPIC', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => false), 331 332 'legend4' => 'ACP_SUBMIT_CHANGES', 282 333 ) 283 334 ); … … 313 364 'server_port' => array('lang' => 'SERVER_PORT', 'validate' => 'int:0', 'type' => 'text:5:5', 'explain' => true), 314 365 'script_path' => array('lang' => 'SCRIPT_PATH', 'validate' => 'script_path', 'type' => 'text::255', 'explain' => true), 366 367 'legend4' => 'ACP_SUBMIT_CHANGES', 315 368 ) 316 369 ); … … 361 414 'smtp_auth_method' => array('lang' => 'SMTP_AUTH_METHOD', 'validate' => 'string', 'type' => 'select', 'method' => 'mail_auth_select', 'explain' => true), 362 415 'smtp_username' => array('lang' => 'SMTP_USERNAME', 'validate' => 'string', 'type' => 'text:25:255', 'explain' => true), 363 'smtp_password' => array('lang' => 'SMTP_PASSWORD', 'validate' => 'string', 'type' => 'password:25:255', 'explain' => true) 416 'smtp_password' => array('lang' => 'SMTP_PASSWORD', 'validate' => 'string', 'type' => 'password:25:255', 'explain' => true), 417 418 'legend3' => 'ACP_SUBMIT_CHANGES', 364 419 ) 365 420 ); … … 401 456 } 402 457 403 if ($config_name == 'auth_method' )458 if ($config_name == 'auth_method' || $config_name == 'feed_news_id' || $config_name == 'feed_exclude_id') 404 459 { 405 460 continue; … … 418 473 { 419 474 set_config($config_name, $config_value); 420 } 475 476 if ($config_name == 'allow_quick_reply' && isset($_POST['allow_quick_reply_enable'])) 477 { 478 enable_bitfield_column_flag(FORUMS_TABLE, 'forum_flags', log(FORUM_FLAG_QUICK_REPLY, 2)); 479 } 480 } 481 } 482 483 // Store news and exclude ids 484 if ($mode == 'feed' && $submit) 485 { 486 $cache->destroy('_feed_news_forum_ids'); 487 $cache->destroy('_feed_excluded_forum_ids'); 488 489 $this->store_feed_forums(FORUM_OPTION_FEED_NEWS, 'feed_news_id'); 490 $this->store_feed_forums(FORUM_OPTION_FEED_EXCLUDE, 'feed_exclude_id'); 421 491 } 422 492 … … 795 865 796 866 /** 867 * Global quick reply enable/disable setting and button to enable in all forums 868 */ 869 function quick_reply($value, $key) 870 { 871 global $user; 872 873 $radio_ary = array(1 => 'YES', 0 => 'NO'); 874 875 return h_radio('config[allow_quick_reply]', $radio_ary, $value) . 876 '<br /><br /><input class="button2" type="submit" id="' . $key . '_enable" name="' . $key . '_enable" value="' . $user->lang['ALLOW_QUICK_REPLY_BUTTON'] . '" />'; 877 } 878 879 880 /** 797 881 * Select default dateformat 798 882 */ … … 831 915 <input type=\"text\" name=\"config[$key]\" id=\"$key\" value=\"$value\" maxlength=\"30\" />"; 832 916 } 917 918 /** 919 * Select multiple forums 920 */ 921 function select_news_forums($value, $key) 922 { 923 global $user, $config; 924 925 $forum_list = make_forum_select(false, false, true, true, true, false, true); 926 927 // Build forum options 928 $s_forum_options = '<select id="' . $key . '" name="' . $key . '[]" multiple="multiple">'; 929 foreach ($forum_list as $f_id => $f_row) 930 { 931 $f_row['selected'] = phpbb_optionget(FORUM_OPTION_FEED_NEWS, $f_row['forum_options']); 932 933 $s_forum_options .= '<option value="' . $f_id . '"' . (($f_row['selected']) ? ' selected="selected"' : '') . (($f_row['disabled']) ? ' disabled="disabled" class="disabled-option"' : '') . '>' . $f_row['padding'] . $f_row['forum_name'] . '</option>'; 934 } 935 $s_forum_options .= '</select>'; 936 937 return $s_forum_options; 938 } 939 940 function select_exclude_forums($value, $key) 941 { 942 global $user, $config; 943 944 $forum_list = make_forum_select(false, false, true, true, true, false, true); 945 946 // Build forum options 947 $s_forum_options = '<select id="' . $key . '" name="' . $key . '[]" multiple="multiple">'; 948 foreach ($forum_list as $f_id => $f_row) 949 { 950 $f_row['selected'] = phpbb_optionget(FORUM_OPTION_FEED_EXCLUDE, $f_row['forum_options']); 951 952 $s_forum_options .= '<option value="' . $f_id . '"' . (($f_row['selected']) ? ' selected="selected"' : '') . (($f_row['disabled']) ? ' disabled="disabled" class="disabled-option"' : '') . '>' . $f_row['padding'] . $f_row['forum_name'] . '</option>'; 953 } 954 $s_forum_options .= '</select>'; 955 956 return $s_forum_options; 957 } 958 959 function store_feed_forums($option, $key) 960 { 961 global $db, $cache; 962 963 // Get key 964 $values = request_var($key, array(0 => 0)); 965 966 // Empty option bit for all forums 967 $sql = 'UPDATE ' . FORUMS_TABLE . ' 968 SET forum_options = forum_options - ' . (1 << $option) . ' 969 WHERE ' . $db->sql_bit_and('forum_options', $option, '<> 0'); 970 $db->sql_query($sql); 971 972 // Already emptied for all... 973 if (sizeof($values)) 974 { 975 // Set for selected forums 976 $sql = 'UPDATE ' . FORUMS_TABLE . ' 977 SET forum_options = forum_options + ' . (1 << $option) . ' 978 WHERE ' . $db->sql_in_set('forum_id', $values); 979 $db->sql_query($sql); 980 } 981 982 // Empty sql cache for forums table because options changed 983 $cache->destroy('sql', FORUMS_TABLE); 984 } 985 833 986 } 834 987 -
trunk/forum/includes/acp/acp_captcha.php
r400 r702 3 3 * 4 4 * @package acp 5 * @version $Id : acp_captcha.php 8722 2008-07-29 15:13:13Z Kellanved$5 * @version $Id$ 6 6 * @copyright (c) 2005 phpBB Group 7 7 * @license http://opensource.org/licenses/gpl-license.php GNU Public License … … 30 30 $user->add_lang('acp/board'); 31 31 32 include($phpbb_root_path . 'includes/captcha/captcha_factory.' . $phpEx); 33 $captchas = phpbb_captcha_factory::get_captcha_types(); 32 34 33 $captcha_vars = array( 34 'captcha_gd_x_grid' => 'CAPTCHA_GD_X_GRID', 35 'captcha_gd_y_grid' => 'CAPTCHA_GD_Y_GRID', 36 'captcha_gd_foreground_noise' => 'CAPTCHA_GD_FOREGROUND_NOISE', 37 'captcha_gd' => 'CAPTCHA_GD_PREVIEWED' 38 ); 35 $selected = request_var('select_captcha', $config['captcha_plugin']); 36 $selected = (isset($captchas['available'][$selected]) || isset($captchas['unavailable'][$selected])) ? $selected : $config['captcha_plugin']; 37 $configure = request_var('configure', false); 39 38 40 if (isset($_GET['demo'])) 39 40 // Oh, they are just here for the view 41 if (isset($_GET['captcha_demo'])) 41 42 { 42 $captcha_vars = array_keys($captcha_vars); 43 foreach ($captcha_vars as $captcha_var) 43 $this->deliver_demo($selected); 44 } 45 46 // Delegate 47 if ($configure) 48 { 49 $config_captcha =& phpbb_captcha_factory::get_instance($selected); 50 $config_captcha->acp_page($id, $this); 51 } 52 else 53 { 54 $config_vars = array( 55 'enable_confirm' => array('tpl' => 'REG_ENABLE', 'default' => false), 56 'enable_post_confirm' => array('tpl' => 'POST_ENABLE', 'default' => false), 57 'confirm_refresh' => array('tpl' => 'CONFIRM_REFRESH', 'default' => false), 58 'max_reg_attempts' => array('tpl' => 'REG_LIMIT', 'default' => 0), 59 'max_login_attempts' => array('tpl' => 'MAX_LOGIN_ATTEMPTS', 'default' => 0), 60 ); 61 62 $this->tpl_name = 'acp_captcha'; 63 $this->page_title = 'ACP_VC_SETTINGS'; 64 $form_key = 'acp_captcha'; 65 add_form_key($form_key); 66 67 $submit = request_var('main_submit', false); 68 69 if ($submit && check_form_key($form_key)) 44 70 { 45 $config[$captcha_var] = (isset($_REQUEST[$captcha_var])) ? request_var($captcha_var, 0) : $config[$captcha_var]; 71 foreach ($config_vars as $config_var => $options) 72 { 73 set_config($config_var, request_var($config_var, $options['default'])); 74 } 75 76 if ($selected !== $config['captcha_plugin']) 77 { 78 // sanity check 79 if (isset($captchas['available'][$selected])) 80 { 81 $old_captcha =& phpbb_captcha_factory::get_instance($config['captcha_plugin']); 82 $old_captcha->uninstall(); 83 84 set_config('captcha_plugin', $selected); 85 $new_captcha =& phpbb_captcha_factory::get_instance($config['captcha_plugin']); 86 $new_captcha->install(); 87 88 add_log('admin', 'LOG_CONFIG_VISUAL'); 89 } 90 else 91 { 92 trigger_error($user->lang['CAPTCHA_UNAVAILABLE'] . adm_back_link($this->u_action)); 93 } 94 } 95 trigger_error($user->lang['CONFIG_UPDATED'] . adm_back_link($this->u_action)); 46 96 } 47 if ($config['captcha_gd'])97 else if ($submit) 48 98 { 49 include($phpbb_root_path . 'includes/captcha/captcha_gd.' . $phpEx);99 trigger_error($user->lang['FORM_INVALID'] . adm_back_link()); 50 100 } 51 101 else 52 102 { 53 include($phpbb_root_path . 'includes/captcha/captcha_non_gd.' . $phpEx); 103 $captcha_select = ''; 104 foreach ($captchas['available'] as $value => $title) 105 { 106 $current = ($selected !== false && $value == $selected) ? ' selected="selected"' : ''; 107 $captcha_select .= '<option value="' . $value . '"' . $current . '>' . $user->lang[$title] . '</option>'; 108 } 109 110 foreach ($captchas['unavailable'] as $value => $title) 111 { 112 $current = ($selected !== false && $value == $selected) ? ' selected="selected"' : ''; 113 $captcha_select .= '<option value="' . $value . '"' . $current . ' class="disabled-option">' . $user->lang[$title] . '</option>'; 114 } 115 116 $demo_captcha =& phpbb_captcha_factory::get_instance($selected); 117 118 foreach ($config_vars as $config_var => $options) 119 { 120 $template->assign_var($options['tpl'], (isset($_POST[$config_var])) ? request_var($config_var, $options['default']) : $config[$config_var]) ; 121 } 122 123 $template->assign_vars(array( 124 'CAPTCHA_PREVIEW_TPL' => $demo_captcha->get_demo_template($id), 125 'S_CAPTCHA_HAS_CONFIG' => $demo_captcha->has_config(), 126 'CAPTCHA_SELECT' => $captcha_select, 127 )); 54 128 } 55 $captcha = new captcha();56 $captcha->execute(gen_rand_string(mt_rand(5, 8)), time());57 exit;58 129 } 130 } 59 131 60 $config_vars = array( 61 'enable_confirm' => 'REG_ENABLE', 62 'enable_post_confirm' => 'POST_ENABLE', 63 'captcha_gd' => 'CAPTCHA_GD', 64 ); 132 /** 133 * Entry point for delivering image CAPTCHAs in the ACP. 134 */ 135 function deliver_demo($selected) 136 { 137 global $db, $user, $config; 65 138 66 $this->tpl_name = 'acp_captcha'; 67 $this->page_title = 'ACP_VC_SETTINGS'; 68 $form_key = 'acp_captcha'; 69 add_form_key($form_key); 139 $captcha =& phpbb_captcha_factory::get_instance($selected); 140 $captcha->init(CONFIRM_REG); 141 $captcha->execute_demo(); 70 142 71 $submit = request_var('submit', ''); 72 73 if ($submit && check_form_key($form_key)) 74 { 75 $config_vars = array_keys($config_vars); 76 foreach ($config_vars as $config_var) 77 { 78 set_config($config_var, request_var($config_var, '')); 79 } 80 $captcha_vars = array_keys($captcha_vars); 81 foreach ($captcha_vars as $captcha_var) 82 { 83 $value = request_var($captcha_var, 0); 84 if ($value >= 0) 85 { 86 set_config($captcha_var, $value); 87 } 88 } 89 trigger_error($user->lang['CONFIG_UPDATED'] . adm_back_link($this->u_action)); 90 } 91 else if ($submit) 92 { 93 trigger_error($user->lang['FORM_INVALID'] . adm_back_link($this->u_action)); 94 } 95 else 96 { 97 98 $preview_image_src = append_sid(append_sid("{$phpbb_admin_path}index.$phpEx", "i=$id&demo=demo")); 99 if (@extension_loaded('gd')) 100 { 101 $template->assign_var('GD', true); 102 } 103 foreach ($config_vars as $config_var => $template_var) 104 { 105 $template->assign_var($template_var, (isset($_REQUEST[$config_var])) ? request_var($config_var, '') : $config[$config_var]) ; 106 } 107 foreach ($captcha_vars as $captcha_var => $template_var) 108 { 109 $var = (isset($_REQUEST[$captcha_var])) ? request_var($captcha_var, 0) : $config[$captcha_var]; 110 $template->assign_var($template_var, $var); 111 $preview_image_src .= "&$captcha_var=" . $var; 112 } 113 $template->assign_vars(array( 114 'CAPTCHA_PREVIEW' => $preview_image_src, 115 'PREVIEW' => isset($_POST['preview']), 116 )); 117 118 } 143 garbage_collection(); 144 exit_handler(); 119 145 } 120 146 } -
trunk/forum/includes/acp/acp_database.php
r400 r702 3 3 * 4 4 * @package acp 5 * @version $Id : acp_database.php 8814 2008-09-04 12:01:47Z acydburn$5 * @version $Id$ 6 6 * @copyright (c) 2005 phpBB Group 7 7 * @license http://opensource.org/licenses/gpl-license.php GNU Public License … … 28 28 global $cache, $db, $user, $auth, $template, $table_prefix; 29 29 global $config, $phpbb_root_path, $phpbb_admin_path, $phpEx; 30 30 31 31 $user->add_lang('acp/database'); 32 32 … … 83 83 84 84 @set_time_limit(1200); 85 @set_time_limit(0); 85 86 86 87 $time = time(); … … 142 143 143 144 case 'oracle': 144 $extractor->flush('TRUNCATE TABLE ' . $table_name . " \\\n");145 $extractor->flush('TRUNCATE TABLE ' . $table_name . "/\n"); 145 146 break; 146 147 … … 188 189 'U_ACTION' => $this->u_action . '&action=download' 189 190 )); 190 191 191 192 $available_methods = array('gzip' => 'zlib', 'bzip2' => 'bz2'); 192 193 … … 425 426 $dh = @opendir($dir); 426 427 428 $backup_files = array(); 429 427 430 if ($dh) 428 431 { … … 431 434 if (preg_match('#^backup_(\d{10,})_[a-z\d]{16}\.(sql(?:\.(?:gz|bz2))?)$#', $file, $matches)) 432 435 { 433 $supported = in_array($matches[2], $methods); 434 435 if ($supported == 'true') 436 if (in_array($matches[2], $methods)) 436 437 { 437 $template->assign_block_vars('files', array( 438 'FILE' => $file, 439 'NAME' => gmdate("d-m-Y H:i:s", $matches[1]), 440 'SUPPORTED' => $supported 441 )); 438 $backup_files[gmdate("d-m-Y H:i:s", $matches[1])] = $file; 442 439 } 443 440 } 444 441 } 445 442 closedir($dh); 443 } 444 445 if (!empty($backup_files)) 446 { 447 krsort($backup_files); 448 449 foreach ($backup_files as $name => $file) 450 { 451 $template->assign_block_vars('files', array( 452 'FILE' => $file, 453 'NAME' => $name, 454 'SUPPORTED' => true, 455 )); 456 } 446 457 } 447 458 … … 509 520 header("Content-Type: $mimetype; name=\"$name\""); 510 521 header("Content-disposition: attachment; filename=$name"); 511 522 512 523 switch ($format) 513 524 { … … 528 539 } 529 540 } 530 541 531 542 if ($store == true) 532 543 { 533 544 global $phpbb_root_path; 534 545 $file = $phpbb_root_path . 'store/' . $filename . $ext; 535 546 536 547 $this->fp = $open($file, 'w'); 537 548 538 549 if (!$this->fp) 539 550 { 540 trigger_error(' Unable to write temporary file to storage folder', E_USER_ERROR);551 trigger_error('FILE_WRITE_FAIL', E_USER_ERROR); 541 552 } 542 553 } … … 546 557 { 547 558 static $close; 559 548 560 if ($this->store) 549 561 { … … 663 675 { 664 676 $fields_cnt = mysqli_num_fields($result); 665 677 666 678 // Get field information 667 679 $field = mysqli_fetch_fields($result); 668 680 $field_set = array(); 669 681 670 682 for ($j = 0; $j < $fields_cnt; $j++) 671 683 { … … 680 692 $query_len = 0; 681 693 $max_len = get_usable_memory(); 682 694 683 695 while ($row = mysqli_fetch_row($result)) 684 696 { … … 751 763 } 752 764 $field_set = array(); 753 765 754 766 for ($j = 0; $j < $fields_cnt; $j++) 755 767 { … … 967 979 } 968 980 $db->sql_freeresult($result); 969 981 970 982 foreach ($ar as $value) 971 983 { … … 1125 1137 } 1126 1138 $db->sql_freeresult($result); 1127 1139 1128 1140 $field_query = "SELECT a.attnum, a.attname as field, t.typname as type, a.attlen as length, a.atttypmod as lengthvar, a.attnotnull as notnull 1129 1141 FROM pg_class c, pg_attribute a, pg_type t … … 1146 1158 AND d.adnum = " . $row['attnum']; 1147 1159 $def_res = $db->sql_query($sql_get_default); 1148 1149 if (!$def_res) 1160 $def_row = $db->sql_fetchrow($def_res); 1161 $db->sql_freeresult($def_res); 1162 1163 if (empty($def_row)) 1150 1164 { 1151 1165 unset($row['rowdefault']); … … 1153 1167 else 1154 1168 { 1155 $row['rowdefault'] = $db->sql_fetchfield('rowdefault', false, $def_res); 1156 } 1157 $db->sql_freeresult($def_res); 1169 $row['rowdefault'] = $def_row['rowdefault']; 1170 } 1158 1171 1159 1172 if ($row['type'] == 'bpchar') … … 1189 1202 $line .= ' NOT NULL'; 1190 1203 } 1191 1204 1192 1205 $lines[] = $line; 1193 1206 } … … 1389 1402 $sql_data .= "\nCREATE TABLE [$table_name] (\n"; 1390 1403 $rows = array(); 1391 1404 1392 1405 $text_flag = false; 1393 1406 1394 1407 $sql = "SELECT COLUMN_NAME, COLUMN_DEFAULT, IS_NULLABLE, DATA_TYPE, CHARACTER_MAXIMUM_LENGTH, COLUMNPROPERTY(object_id(TABLE_NAME), COLUMN_NAME, 'IsIdentity') as IS_IDENTITY 1395 1408 FROM INFORMATION_SCHEMA.COLUMNS 1396 1409 WHERE TABLE_NAME = '$table_name'"; 1397 1410 $result = $db->sql_query($sql); 1398 1411 1399 1412 while ($row = $db->sql_fetchrow($result)) 1400 1413 { 1401 1414 $line = "\t[{$row['COLUMN_NAME']}] [{$row['DATA_TYPE']}]"; 1402 1415 1403 1416 if ($row['DATA_TYPE'] == 'text') 1404 1417 { 1405 1418 $text_flag = true; 1406 1419 } 1407 1420 1408 1421 if ($row['IS_IDENTITY']) 1409 1422 { 1410 1423 $line .= ' IDENTITY (1 , 1)'; 1411 1424 } 1412 1425 1413 1426 if ($row['CHARACTER_MAXIMUM_LENGTH'] && $row['DATA_TYPE'] !== 'text') 1414 1427 { 1415 1428 $line .= ' (' . $row['CHARACTER_MAXIMUM_LENGTH'] . ')'; 1416 1429 } 1417 1430 1418 1431 if ($row['IS_NULLABLE'] == 'YES') 1419 1432 { … … 1424 1437 $line .= ' NOT NULL'; 1425 1438 } 1426 1439 1427 1440 if ($row['COLUMN_DEFAULT']) 1428 1441 { 1429 1442 $line .= ' DEFAULT ' . $row['COLUMN_DEFAULT']; 1430 1443 } 1431 1444 1432 1445 $rows[] = $line; 1433 1446 } 1434 1447 $db->sql_freeresult($result); 1435 1448 1436 1449 $sql_data .= implode(",\n", $rows); 1437 1450 $sql_data .= "\n) ON [PRIMARY]"; 1438 1451 1439 1452 if ($text_flag) 1440 1453 { 1441 1454 $sql_data .= " TEXTIMAGE_ON [PRIMARY]"; 1442 1455 } 1443 1456 1444 1457 $sql_data .= "\nGO\n\n"; 1445 1458 $rows = array(); 1446 1459 1447 1460 $sql = "SELECT CONSTRAINT_NAME, COLUMN_NAME 1448 1461 FROM INFORMATION_SCHEMA.KEY_COLUMN_USAGE … … 1464 1477 } 1465 1478 $db->sql_freeresult($result); 1466 1479 1467 1480 $index = array(); 1468 1481 $sql = "EXEC sp_statistics '$table_name'"; … … 1476 1489 } 1477 1490 $db->sql_freeresult($result); 1478 1491 1479 1492 foreach ($index as $index_name => $column_name) 1480 1493 { 1481 1494 $index[$index_name] = implode(', ', $column_name); 1482 1495 } 1483 1496 1484 1497 foreach ($index as $index_name => $columns) 1485 1498 { … … 1509 1522 $ident_set = false; 1510 1523 $sql_data = ''; 1511 1524 1512 1525 // Grab all of the data from current table. 1513 1526 $sql = "SELECT * … … 1603 1616 $ident_set = false; 1604 1617 $sql_data = ''; 1605 1618 1606 1619 // Grab all of the data from current table. 1607 1620 $sql = "SELECT * … … 1704 1717 global $db; 1705 1718 $sql_data = '-- Table: ' . $table_name . "\n"; 1706 $sql_data .= "DROP TABLE $table_name;\n"; 1707 $sql_data .= '\\' . "\n"; 1719 $sql_data .= "DROP TABLE $table_name\n/\n"; 1708 1720 $sql_data .= "\nCREATE TABLE $table_name (\n"; 1709 1721 … … 1720 1732 if ($row['data_type'] !== 'CLOB') 1721 1733 { 1722 if ($row['data_type'] !== 'VARCHAR2' )1734 if ($row['data_type'] !== 'VARCHAR2' && $row['data_type'] !== 'CHAR') 1723 1735 { 1724 1736 $line .= '(' . $row['data_precision'] . ')'; … … 1750 1762 $result = $db->sql_query($sql); 1751 1763 1752 while ($row = $db->sql_fetchrow($result)) 1753 { 1754 $rows[] = " CONSTRAINT {$row['constraint_name']} PRIMARY KEY ({$row['column_name']})"; 1755 } 1756 $db->sql_freeresult($result); 1764 $primary_key = array(); 1765 $contraint_name = ''; 1766 while ($row = $db->sql_fetchrow($result)) 1767 { 1768 $constraint_name = '"' . $row['constraint_name'] . '"'; 1769 $primary_key[] = '"' . $row['column_name'] . '"'; 1770 } 1771 $db->sql_freeresult($result); 1772 1773 if (sizeof($primary_key)) 1774 { 1775 $rows[] = " CONSTRAINT {$constraint_name} PRIMARY KEY (" . implode(', ', $primary_key) . ')'; 1776 } 1757 1777 1758 1778 $sql = "SELECT A.CONSTRAINT_NAME, A.COLUMN_NAME … … 1763 1783 $result = $db->sql_query($sql); 1764 1784 1765 while ($row = $db->sql_fetchrow($result)) 1766 { 1767 $rows[] = " CONSTRAINT {$row['constraint_name']} UNIQUE ({$row['column_name']})"; 1768 } 1769 $db->sql_freeresult($result); 1785 $unique = array(); 1786 $contraint_name = ''; 1787 while ($row = $db->sql_fetchrow($result)) 1788 { 1789 $constraint_name = '"' . $row['constraint_name'] . '"'; 1790 $unique[] = '"' . $row['column_name'] . '"'; 1791 } 1792 $db->sql_freeresult($result); 1793 1794 if (sizeof($unique)) 1795 { 1796 $rows[] = " CONSTRAINT {$constraint_name} UNIQUE (" . implode(', ', $unique) . ')'; 1797 } 1770 1798 1771 1799 $sql_data .= implode(",\n", $rows); 1772 $sql_data .= "\n)\n \\";1773 1774 $sql = "SELECT A.REFERENCED_NAME 1775 FROM USER_DEPENDENCIES A, USER_TRIGGERS B 1800 $sql_data .= "\n)\n/\n"; 1801 1802 $sql = "SELECT A.REFERENCED_NAME, C.* 1803 FROM USER_DEPENDENCIES A, USER_TRIGGERS B, USER_SEQUENCES C 1776 1804 WHERE A.REFERENCED_TYPE = 'SEQUENCE' 1777 1805 AND A.NAME = B.TRIGGER_NAME 1778 AND B. TABLE_NAME = '{$table_name}'"; 1806 AND B.TABLE_NAME = '{$table_name}' 1807 AND C.SEQUENCE_NAME = A.REFERENCED_NAME"; 1779 1808 $result = $db->sql_query($sql); 1780 while ($row = $db->sql_fetchrow($result)) 1781 { 1782 $sql_data .= "\nCREATE SEQUENCE {$row['referenced_name']}\\\n"; 1809 1810 $type = request_var('type', ''); 1811 1812 while ($row = $db->sql_fetchrow($result)) 1813 { 1814 $sql_data .= "\nDROP SEQUENCE \"{$row['referenced_name']}\"\n/\n"; 1815 $sql_data .= "\nCREATE SEQUENCE \"{$row['referenced_name']}\""; 1816 1817 if ($type == 'full') 1818 { 1819 $sql_data .= ' START WITH ' . $row['last_number']; 1820 } 1821 1822 $sql_data .= "\n/\n"; 1783 1823 } 1784 1824 $db->sql_freeresult($result); … … 1790 1830 while ($row = $db->sql_fetchrow($result)) 1791 1831 { 1792 $sql_data .= "\nCREATE OR REPLACE TRIGGER {$row['description']}WHEN ({$row['when_clause']})\n{$row['trigger_body']}\ \";1832 $sql_data .= "\nCREATE OR REPLACE TRIGGER {$row['description']}WHEN ({$row['when_clause']})\n{$row['trigger_body']}\n/\n"; 1793 1833 } 1794 1834 $db->sql_freeresult($result); … … 1810 1850 foreach ($index as $index_name => $column_names) 1811 1851 { 1812 $sql_data .= "\nCREATE INDEX $index_name ON $table_name(" . implode(', ', $column_names) . ")\n \\";1852 $sql_data .= "\nCREATE INDEX $index_name ON $table_name(" . implode(', ', $column_names) . ")\n/\n"; 1813 1853 } 1814 1854 $db->sql_freeresult($result); … … 1820 1860 global $db; 1821 1861 $ary_type = $ary_name = array(); 1822 1862 1823 1863 // Grab all of the data from current table. 1824 1864 $sql = "SELECT * … … 1843 1883 for ($i = 0; $i < $i_num_fields; $i++) 1844 1884 { 1845 $str_val = $row[$ary_name[$i]]; 1846 1847 if (preg_match('#char|text|bool|raw#i', $ary_type[$i])) 1885 // Oracle uses uppercase - we use lowercase 1886 $str_val = $row[strtolower($ary_name[$i])]; 1887 1888 if (preg_match('#char|text|bool|raw|clob#i', $ary_type[$i])) 1848 1889 { 1849 1890 $str_quote = ''; … … 1874 1915 1875 1916 $schema_vals[$i] = $str_quote . $str_val . $str_quote; 1876 $schema_fields[$i] = '"' . $ary_name[$i] . "'";1917 $schema_fields[$i] = '"' . $ary_name[$i] . '"'; 1877 1918 } 1878 1919 1879 1920 // Take the ordered fields and their associated data and build it 1880 1921 // into a valid sql statement to recreate that field in the data. 1881 $sql_data = "INSERT INTO $table_name (" . implode(', ', $schema_fields) . ') VALUES (' . implode(', ', $schema_vals) . ") ;\n";1922 $sql_data = "INSERT INTO $table_name (" . implode(', ', $schema_fields) . ') VALUES (' . implode(', ', $schema_vals) . ")\n/\n"; 1882 1923 1883 1924 $this->flush($sql_data); … … 1916 1957 global $db; 1917 1958 $ary_type = $ary_name = array(); 1918 1959 1919 1960 // Grab all of the data from current table. 1920 1961 $sql = "SELECT * … … 2198 2239 function sanitize_data_oracle($text) 2199 2240 { 2200 $data = preg_split('/[\0\n\t\r\b\f\'"\\\]/', $text); 2201 preg_match_all('/[\0\n\t\r\b\f\'"\\\]/', $text, $matches); 2241 // $data = preg_split('/[\0\n\t\r\b\f\'"\/\\\]/', $text); 2242 // preg_match_all('/[\0\n\t\r\b\f\'"\/\\\]/', $text, $matches); 2243 $data = preg_split('/[\0\b\f\'\/]/', $text); 2244 preg_match_all('/[\0\r\b\f\'\/]/', $text, $matches); 2202 2245 2203 2246 $val = array(); … … 2245 2288 $record = ''; 2246 2289 $delim_len = strlen($delim); 2247 2290 2248 2291 while (!$eof($fp)) 2249 2292 { -
trunk/forum/includes/acp/acp_email.php
r400 r702 3 3 * 4 4 * @package acp 5 * @version $Id : acp_email.php 8479 2008-03-29 00:22:48Z naderman$5 * @version $Id$ 6 6 * @copyright (c) 2005 phpBB Group 7 7 * @license http://opensource.org/licenses/gpl-license.php GNU Public License … … 109 109 trigger_error($user->lang['NO_USER'] . adm_back_link($this->u_action), E_USER_WARNING); 110 110 } 111 111 112 112 $i = $j = 0; 113 113 … … 122 122 if (($row['user_notify_type'] == NOTIFY_EMAIL && $row['user_email']) || 123 123 ($row['user_notify_type'] == NOTIFY_IM && $row['user_jabber']) || 124 ($row['user_notify_type'] == NOTIFY_BOTH && $row['user_email'] && $row['user_jabber']))124 ($row['user_notify_type'] == NOTIFY_BOTH && ($row['user_email'] || $row['user_jabber']))) 125 125 { 126 126 if ($i == $max_chunk_size || $row['user_lang'] != $old_lang || $row['user_notify_type'] != $old_notify_type) … … 174 174 $messenger->headers('X-AntiAbuse: Username - ' . $user->data['username']); 175 175 $messenger->headers('X-AntiAbuse: User IP - ' . $user->ip); 176 176 177 177 $messenger->subject(htmlspecialchars_decode($subject)); 178 178 $messenger->set_mail_priority($priority); … … 182 182 'MESSAGE' => htmlspecialchars_decode($message)) 183 183 ); 184 184 185 185 if (!($messenger->send($used_method))) 186 186 { … … 240 240 $select_list = '<option value="0"' . ((!$group_id) ? ' selected="selected"' : '') . '>' . $user->lang['ALL_USERS'] . '</option>'; 241 241 $select_list .= group_select_options($group_id, $exclude); 242 242 243 243 $s_priority_options = '<option value="' . MAIL_LOW_PRIORITY . '">' . $user->lang['MAIL_LOW_PRIORITY'] . '</option>'; 244 244 $s_priority_options .= '<option value="' . MAIL_NORMAL_PRIORITY . '" selected="selected">' . $user->lang['MAIL_NORMAL_PRIORITY'] . '</option>'; -
trunk/forum/includes/acp/acp_forums.php
r400 r702 3 3 * 4 4 * @package acp 5 * @version $Id : acp_forums.php 8898 2008-09-19 17:07:13Z acydburn$5 * @version $Id$ 6 6 * @copyright (c) 2005 phpBB Group 7 7 * @license http://opensource.org/licenses/gpl-license.php GNU Public License … … 140 140 'enable_prune' => request_var('enable_prune', false), 141 141 'enable_post_review' => request_var('enable_post_review', true), 142 'enable_quick_reply' => request_var('enable_quick_reply', false), 142 143 'prune_days' => request_var('prune_days', 7), 143 144 'prune_viewed' => request_var('prune_viewed', 7), … … 151 152 ); 152 153 154 // On add, add empty forum_options... else do not consider it (not updating it) 155 if ($action == 'add') 156 { 157 $forum_data['forum_options'] = 0; 158 } 159 153 160 // Use link_display_on_index setting if forum type is link 154 161 if ($forum_data['forum_type'] == FORUM_LINK) … … 163 170 } 164 171 165 $forum_data['show_active'] = ($forum_data['forum_type'] == FORUM_POST) ? request_var('display_recent', false) : request_var('display_active', false);172 $forum_data['show_active'] = ($forum_data['forum_type'] == FORUM_POST) ? request_var('display_recent', true) : request_var('display_active', true); 166 173 167 174 // Get data for forum rules if specified... … … 182 189 { 183 190 $forum_perm_from = request_var('forum_perm_from', 0); 191 $cache->destroy('sql', FORUMS_TABLE); 184 192 185 193 // Copy permissions? 186 if ($forum_perm_from && !empty($forum_perm_from) &&$forum_perm_from != $forum_data['forum_id'] &&187 ( ($action != 'edit')|| empty($forum_id) || ($auth->acl_get('a_fauth') && $auth->acl_get('a_authusers') && $auth->acl_get('a_authgroups') && $auth->acl_get('a_mauth'))))194 if ($forum_perm_from && $forum_perm_from != $forum_data['forum_id'] && 195 ($action != 'edit' || empty($forum_id) || ($auth->acl_get('a_fauth') && $auth->acl_get('a_authusers') && $auth->acl_get('a_authgroups') && $auth->acl_get('a_mauth')))) 188 196 { 189 // if we edit a forum delete current permissions first 190 if ($action == 'edit') 191 { 192 $sql = 'DELETE FROM ' . ACL_USERS_TABLE . ' 193 WHERE forum_id = ' . (int) $forum_data['forum_id']; 194 $db->sql_query($sql); 195 196 $sql = 'DELETE FROM ' . ACL_GROUPS_TABLE . ' 197 WHERE forum_id = ' . (int) $forum_data['forum_id']; 198 $db->sql_query($sql); 199 } 200 201 // From the mysql documentation: 202 // Prior to MySQL 4.0.14, the target table of the INSERT statement cannot appear in the FROM clause of the SELECT part of the query. This limitation is lifted in 4.0.14. 203 // Due to this we stay on the safe side if we do the insertion "the manual way" 204 205 // Copy permisisons from/to the acl users table (only forum_id gets changed) 206 $sql = 'SELECT user_id, auth_option_id, auth_role_id, auth_setting 207 FROM ' . ACL_USERS_TABLE . ' 208 WHERE forum_id = ' . $forum_perm_from; 209 $result = $db->sql_query($sql); 210 211 $users_sql_ary = array(); 212 while ($row = $db->sql_fetchrow($result)) 213 { 214 $users_sql_ary[] = array( 215 'user_id' => (int) $row['user_id'], 216 'forum_id' => (int) $forum_data['forum_id'], 217 'auth_option_id' => (int) $row['auth_option_id'], 218 'auth_role_id' => (int) $row['auth_role_id'], 219 'auth_setting' => (int) $row['auth_setting'] 220 ); 221 } 222 $db->sql_freeresult($result); 223 224 // Copy permisisons from/to the acl groups table (only forum_id gets changed) 225 $sql = 'SELECT group_id, auth_option_id, auth_role_id, auth_setting 226 FROM ' . ACL_GROUPS_TABLE . ' 227 WHERE forum_id = ' . $forum_perm_from; 228 $result = $db->sql_query($sql); 229 230 $groups_sql_ary = array(); 231 while ($row = $db->sql_fetchrow($result)) 232 { 233 $groups_sql_ary[] = array( 234 'group_id' => (int) $row['group_id'], 235 'forum_id' => (int) $forum_data['forum_id'], 236 'auth_option_id' => (int) $row['auth_option_id'], 237 'auth_role_id' => (int) $row['auth_role_id'], 238 'auth_setting' => (int) $row['auth_setting'] 239 ); 240 } 241 $db->sql_freeresult($result); 242 243 // Now insert the data 244 $db->sql_multi_insert(ACL_USERS_TABLE, $users_sql_ary); 245 $db->sql_multi_insert(ACL_GROUPS_TABLE, $groups_sql_ary); 197 copy_forum_permissions($forum_perm_from, $forum_data['forum_id'], ($action == 'edit') ? true : false); 246 198 cache_moderators(); 247 199 } 248 200 /* Commented out because of questionable UI workflow - re-visit for 3.0.7 201 else if (!$this->parent_id && $action != 'edit' && $auth->acl_get('a_fauth') && $auth->acl_get('a_authusers') && $auth->acl_get('a_authgroups') && $auth->acl_get('a_mauth')) 202 { 203 $this->copy_permission_page($forum_data); 204 return; 205 } 206 */ 249 207 $auth->acl_clear_prefetch(); 250 $cache->destroy('sql', FORUMS_TABLE);251 208 252 209 $acl_url = '&mode=setting_forum_local&forum_id[]=' . $forum_data['forum_id']; … … 424 381 $forum_data['forum_flags'] += ($forum_data['show_active']) ? FORUM_FLAG_ACTIVE_TOPICS : 0; 425 382 $forum_data['forum_flags'] += (request_var('enable_post_review', true)) ? FORUM_FLAG_POST_REVIEW : 0; 383 $forum_data['forum_flags'] += (request_var('enable_quick_reply', false)) ? FORUM_FLAG_QUICK_REPLY : 0; 426 384 } 427 385 … … 485 443 'prune_viewed' => 7, 486 444 'prune_freq' => 1, 487 'forum_flags' => FORUM_FLAG_POST_REVIEW, 445 'forum_flags' => FORUM_FLAG_POST_REVIEW + FORUM_FLAG_ACTIVE_TOPICS, 446 'forum_options' => 0, 488 447 'forum_password' => '', 489 448 'forum_password_confirm'=> '', … … 561 520 WHERE forum_type = ' . FORUM_POST . " 562 521 AND forum_id <> $forum_id"; 563 $result = $db->sql_query($sql); 564 522 $result = $db->sql_query_limit($sql, 1); 523 524 $postable_forum_exists = false; 565 525 if ($db->sql_fetchrow($result)) 566 526 { 567 $template->assign_vars(array( 568 'S_MOVE_FORUM_OPTIONS' => make_forum_select($forum_data['parent_id'], $forum_id, false, true, false)) 569 ); 527 $postable_forum_exists = true; 570 528 } 571 529 $db->sql_freeresult($result); … … 584 542 $forums_list = make_forum_select($forum_data['parent_id'], $subforums_id); 585 543 586 $sql = 'SELECT forum_id 587 FROM ' . FORUMS_TABLE . ' 588 WHERE forum_type = ' . FORUM_POST . " 589 AND forum_id <> $forum_id"; 590 $result = $db->sql_query($sql); 591 592 if ($db->sql_fetchrow($result)) 544 if ($postable_forum_exists) 593 545 { 594 546 $template->assign_vars(array( … … 596 548 ); 597 549 } 598 $db->sql_freeresult($result);599 550 600 551 $template->assign_vars(array( 601 552 'S_HAS_SUBFORUMS' => ($forum_data['right_id'] - $forum_data['left_id'] > 1) ? true : false, 602 553 'S_FORUMS_LIST' => $forums_list) 554 ); 555 } 556 else if ($postable_forum_exists) 557 { 558 $template->assign_vars(array( 559 'S_MOVE_FORUM_OPTIONS' => make_forum_select($forum_data['parent_id'], $forum_id, false, true, false)) 603 560 ); 604 561 } … … 685 642 'S_DISPLAY_ACTIVE_TOPICS' => ($forum_data['forum_flags'] & FORUM_FLAG_ACTIVE_TOPICS) ? true : false, 686 643 'S_ENABLE_POST_REVIEW' => ($forum_data['forum_flags'] & FORUM_FLAG_POST_REVIEW) ? true : false, 644 'S_ENABLE_QUICK_REPLY' => ($forum_data['forum_flags'] & FORUM_FLAG_QUICK_REPLY) ? true : false, 687 645 'S_CAN_COPY_PERMISSIONS' => ($action != 'edit' || empty($forum_id) || ($auth->acl_get('a_fauth') && $auth->acl_get('a_authusers') && $auth->acl_get('a_authgroups') && $auth->acl_get('a_mauth'))) ? true : false, 688 646 )); … … 715 673 WHERE forum_type = ' . FORUM_POST . " 716 674 AND forum_id <> $forum_id"; 717 $result = $db->sql_query ($sql);675 $result = $db->sql_query_limit($sql, 1); 718 676 719 677 if ($db->sql_fetchrow($result)) … … 743 701 return; 744 702 break; 703 704 case 'copy_perm': 705 $forum_perm_from = request_var('forum_perm_from', 0); 706 707 // Copy permissions? 708 if (!empty($forum_perm_from) && $forum_perm_from != $forum_id) 709 { 710 copy_forum_permissions($forum_perm_from, $forum_id, true); 711 cache_moderators(); 712 $auth->acl_clear_prefetch(); 713 $cache->destroy('sql', FORUMS_TABLE); 714 715 $acl_url = '&mode=setting_forum_local&forum_id[]=' . $forum_id; 716 717 $message = $user->lang['FORUM_UPDATED']; 718 719 // Redirect to permissions 720 if ($auth->acl_get('a_fauth')) 721 { 722 $message .= '<br /><br />' . sprintf($user->lang['REDIRECT_ACL'], '<a href="' . append_sid("{$phpbb_admin_path}index.$phpEx", 'i=permissions' . $acl_url) . '">', '</a>'); 723 } 724 725 trigger_error($message . adm_back_link($this->u_action . '&parent_id=' . $this->parent_id)); 726 } 727 728 break; 745 729 } 746 730 … … 807 791 808 792 $url = $this->u_action . "&parent_id=$this->parent_id&f={$row['forum_id']}"; 809 810 $forum_title = ($forum_type != FORUM_LINK) ? '<a href="' . $this->u_action . '&parent_id=' . $row['forum_id'] . '">' : '';811 $forum_title .= $row['forum_name'];812 $forum_title .= ($forum_type != FORUM_LINK) ? '</a>' : '';813 793 814 794 $template->assign_block_vars('forums', array( … … 889 869 function update_forum_data(&$forum_data) 890 870 { 891 global $db, $user, $cache ;871 global $db, $user, $cache, $phpbb_root_path; 892 872 893 873 $errors = array(); … … 926 906 array('lang' => 'FORUM_TOPICS_PAGE', 'value' => $forum_data['forum_topics_per_page'], 'column_type' => 'TINT:0'), 927 907 ); 908 909 if (!empty($forum_data['forum_image']) && !file_exists($phpbb_root_path . $forum_data['forum_image'])) 910 { 911 $errors[] = $user->lang['FORUM_IMAGE_NO_EXIST']; 912 } 928 913 929 914 validate_range($range_test_ary, $errors); … … 943 928 $forum_data['forum_flags'] += ($forum_data['show_active']) ? FORUM_FLAG_ACTIVE_TOPICS : 0; 944 929 $forum_data['forum_flags'] += ($forum_data['enable_post_review']) ? FORUM_FLAG_POST_REVIEW : 0; 930 $forum_data['forum_flags'] += ($forum_data['enable_quick_reply']) ? FORUM_FLAG_QUICK_REPLY : 0; 945 931 946 932 // Unset data that are not database fields … … 953 939 unset($forum_data_sql['show_active']); 954 940 unset($forum_data_sql['enable_post_review']); 941 unset($forum_data_sql['enable_quick_reply']); 955 942 unset($forum_data_sql['forum_password_confirm']); 956 943 … … 1929 1916 adm_page_footer(); 1930 1917 } 1918 1919 /** 1920 * Display copy permission page 1921 * Not used at the moment - we will have a look at it for 3.0.7 1922 */ 1923 function copy_permission_page($forum_data) 1924 { 1925 global $phpEx, $phpbb_admin_path, $template, $user; 1926 1927 $acl_url = '&mode=setting_forum_local&forum_id[]=' . $forum_data['forum_id']; 1928 $action = append_sid($this->u_action . "&parent_id={$this->parent_id}&f={$forum_data['forum_id']}&action=copy_perm"); 1929 1930 $l_acl = sprintf($user->lang['COPY_TO_ACL'], '<a href="' . append_sid("{$phpbb_admin_path}index.$phpEx", 'i=permissions' . $acl_url) . '">', '</a>'); 1931 1932 $this->tpl_name = 'acp_forums_copy_perm'; 1933 1934 $template->assign_vars(array( 1935 'U_ACL' => append_sid("{$phpbb_admin_path}index.$phpEx", 'i=permissions' . $acl_url), 1936 'L_ACL_LINK' => $l_acl, 1937 'L_BACK_LINK' => adm_back_link($this->u_action . '&parent_id=' . $this->parent_id), 1938 'S_COPY_ACTION' => $action, 1939 'S_FORUM_OPTIONS' => make_forum_select($forum_data['parent_id'], $forum_data['forum_id'], false, false, false), 1940 )); 1941 } 1942 1931 1943 } 1932 1944 -
trunk/forum/includes/acp/acp_groups.php
r400 r702 3 3 * 4 4 * @package acp 5 * @version $Id : acp_groups.php 9053 2008-11-09 15:10:40Z acydburn$5 * @version $Id$ 6 6 * @copyright (c) 2005 phpBB Group 7 7 * @license http://opensource.org/licenses/gpl-license.php GNU Public License … … 310 310 'max_recipients' => request_var('group_max_recipients', 0), 311 311 'founder_manage' => 0, 312 'skip_auth' => request_var('group_skip_auth', 0), 312 313 ); 313 314 … … 401 402 402 403 $group_attributes = array(); 403 $test_variables = array('rank', 'colour', 'avatar', 'avatar_type', 'avatar_width', 'avatar_height', 'receive_pm', 'legend', 'message_limit', 'max_recipients', 'founder_manage'); 404 foreach ($test_variables as $test) 404 $test_variables = array( 405 'rank' => 'int', 406 'colour' => 'string', 407 'avatar' => 'string', 408 'avatar_type' => 'int', 409 'avatar_width' => 'int', 410 'avatar_height' => 'int', 411 'receive_pm' => 'int', 412 'legend' => 'int', 413 'message_limit' => 'int', 414 'max_recipients'=> 'int', 415 'founder_manage'=> 'int', 416 'skip_auth' => 'int', 417 ); 418 419 foreach ($test_variables as $test => $type) 405 420 { 406 421 if (isset($submit_ary[$test]) && ($action == 'add' || $group_row['group_' . $test] != $submit_ary[$test])) 407 422 { 423 settype($submit_ary[$test], $type); 408 424 $group_attributes['group_' . $test] = $group_row['group_' . $test] = $submit_ary[$test]; 409 425 } … … 563 579 'GROUP_MAX_RECIPIENTS' => (isset($group_row['group_max_recipients'])) ? $group_row['group_max_recipients'] : 0, 564 580 'GROUP_COLOUR' => (isset($group_row['group_colour'])) ? $group_row['group_colour'] : '', 565 581 'GROUP_SKIP_AUTH' => (!empty($group_row['group_skip_auth'])) ? ' checked="checked"' : '', 566 582 567 583 'S_DESC_BBCODE_CHECKED' => $group_desc_data['allow_bbcode'], … … 592 608 'U_ACTION' => "{$this->u_action}&action=$action&g=$group_id", 593 609 'L_AVATAR_EXPLAIN' => sprintf($user->lang['AVATAR_EXPLAIN'], $config['avatar_max_width'], $config['avatar_max_height'], round($config['avatar_filesize'] / 1024)), 594 ) 595 ); 610 )); 596 611 597 612 return; … … 608 623 609 624 // Grab the leaders - always, on every page... 610 $sql = 'SELECT u.user_id, u.username, u.username_clean, u.user_regdate, u.user_ posts, u.group_id, ug.group_leader, ug.user_pending625 $sql = 'SELECT u.user_id, u.username, u.username_clean, u.user_regdate, u.user_colour, u.user_posts, u.group_id, ug.group_leader, ug.user_pending 611 626 FROM ' . USERS_TABLE . ' u, ' . USER_GROUP_TABLE . " ug 612 627 WHERE ug.group_id = $group_id … … 622 637 623 638 'USERNAME' => $row['username'], 639 'USERNAME_COLOUR' => $row['user_colour'], 624 640 'S_GROUP_DEFAULT' => ($row['group_id'] == $group_id) ? true : false, 625 641 'JOINED' => ($row['user_regdate']) ? $user->format_date($row['user_regdate']) : ' - ', 626 642 'USER_POSTS' => $row['user_posts'], 627 'USER_ID' => $row['user_id'] )628 ) ;643 'USER_ID' => $row['user_id'], 644 )); 629 645 } 630 646 $db->sql_freeresult($result); … … 663 679 664 680 // Grab the members 665 $sql = 'SELECT u.user_id, u.username, u.username_clean, u.user_ regdate, u.user_posts, u.group_id, ug.group_leader, ug.user_pending681 $sql = 'SELECT u.user_id, u.username, u.username_clean, u.user_colour, u.user_regdate, u.user_posts, u.group_id, ug.group_leader, ug.user_pending 666 682 FROM ' . USERS_TABLE . ' u, ' . USER_GROUP_TABLE . " ug 667 683 WHERE ug.group_id = $group_id … … 688 704 689 705 'USERNAME' => $row['username'], 706 'USERNAME_COLOUR' => $row['user_colour'], 690 707 'S_GROUP_DEFAULT' => ($row['group_id'] == $group_id) ? true : false, 691 708 'JOINED' => ($row['user_regdate']) ? $user->format_date($row['user_regdate']) : ' - ', … … 764 781 'GROUP_NAME' => $group_name, 765 782 'TOTAL_MEMBERS' => $row['total_members'], 766 ) 767 ); 783 )); 768 784 } 769 785 } -
trunk/forum/includes/acp/acp_icons.php
r400 r702 3 3 * 4 4 * @package acp 5 * @version $Id : acp_icons.php 8974 2008-10-06 13:23:41Z acydburn$5 * @version $Id$ 6 6 * @copyright (c) 2005 phpBB Group 7 7 * @license http://opensource.org/licenses/gpl-license.php GNU Public License … … 90 90 } 91 91 92 // adjust the width and height to be lower than 128px while perserving the aspect ratio (for icons) 93 if ($mode == 'icons') 94 { 95 if ($img_size[0] > 127 && $img_size[0] > $img_size[1]) 96 { 97 $img_size[1] = (int) ($img_size[1] * (127 / $img_size[0])); 98 $img_size[0] = 127; 99 } 100 else if ($img_size[1] > 127) 101 { 102 $img_size[0] = (int) ($img_size[0] * (127 / $img_size[1])); 103 $img_size[1] = 127; 104 } 105 } 106 92 107 $_images[$path . $img]['file'] = $path . $img; 93 108 $_images[$path . $img]['width'] = $img_size[0]; … … 169 184 } 170 185 } 171 186 172 187 $sql = "SELECT * 173 188 FROM $table 174 189 ORDER BY {$fields}_order " . (($icon_id || $action == 'add') ? 'DESC' : 'ASC'); 175 190 $result = $db->sql_query($sql); 176 191 177 192 $data = array(); 178 193 $after = false; … … 181 196 $add_order_lists = array('', ''); 182 197 $display_count = 0; 183 198 184 199 while ($row = $db->sql_fetchrow($result)) 185 200 { … … 232 247 } 233 248 234 $colspan = (($mode == 'smilies') ? '7' : '5');249 $colspan = (($mode == 'smilies') ? 7 : 5); 235 250 $colspan += ($icon_id) ? 1 : 0; 236 251 $colspan += ($action == 'add') ? 2 : 0; 237 252 238 253 $template->assign_vars(array( 239 254 'S_EDIT' => true, 240 255 'S_SMILIES' => ($mode == 'smilies') ? true : false, 241 256 'S_ADD' => ($action == 'add') ? true : false, 242 257 243 258 'S_ORDER_LIST_DISPLAY' => $order_list . $order_lists[1], 244 259 'S_ORDER_LIST_UNDISPLAY' => $order_list . $order_lists[0], … … 287 302 288 303 'S_IMG_OPTIONS' => $smiley_options, 289 304 290 305 'S_ADD_ORDER_LIST_DISPLAY' => $add_order_list . $add_order_lists[1], 291 306 'S_ADD_ORDER_LIST_UNDISPLAY' => $add_order_list . $add_order_lists[0], 292 307 293 308 'IMG_SRC' => $phpbb_root_path . $img_path . '/' . $default_row['smiley_url'], 294 309 'IMG_PATH' => $img_path, … … 304 319 305 320 return; 306 321 307 322 break; 308 323 … … 312 327 // Get items to create/modify 313 328 $images = (isset($_POST['image'])) ? array_keys(request_var('image', array('' => 0))) : array(); 314 329 315 330 // Now really get the items 316 331 $image_id = (isset($_POST['id'])) ? request_var('id', array('' => 0)) : array(); … … 349 364 } 350 365 366 if ($mode == 'smilies' && $action == 'create') 367 { 368 $smiley_count = $this->item_count($table); 369 370 $addable_smileys_count = sizeof($images); 371 foreach ($images as $image) 372 { 373 if (!isset($image_add[$image])) 374 { 375 --$addable_smileys_count; 376 } 377 } 378 379 if ($smiley_count + $addable_smileys_count > SMILEY_LIMIT) 380 { 381 trigger_error(sprintf($user->lang['TOO_MANY_SMILIES'], SMILEY_LIMIT) . adm_back_link($this->u_action), E_USER_WARNING); 382 } 383 } 384 351 385 $icons_updated = 0; 352 386 $errors = array(); … … 368 402 $image_width[$image] = $img_size[0]; 369 403 $image_height[$image] = $img_size[1]; 404 } 405 406 // Adjust image width/height for icons 407 if ($mode == 'icons') 408 { 409 if ($image_width[$image] > 127 && $image_width[$image] > $image_height[$image]) 410 { 411 $image_height[$image] = (int) ($image_height[$image] * (127 / $image_width[$image])); 412 $image_width[$image] = 127; 413 } 414 else if ($image_height[$image] > 127) 415 { 416 $image_width[$image] = (int) ($image_width[$image] * (127 / $image_height[$image])); 417 $image_height[$image] = 127; 418 } 370 419 } 371 420 … … 427 476 $icons_updated++; 428 477 } 429 478 430 479 } 431 480 } 432 481 433 482 $cache->destroy('_icons'); 434 483 $cache->destroy('sql', $table); 435 484 436 485 $level = E_USER_NOTICE; 437 486 switch ($icons_updated) … … 441 490 $level = E_USER_WARNING; 442 491 break; 443 492 444 493 case 1: 445 494 $suc_lang = "{$lang}_ONE"; 446 495 break; 447 496 448 497 default: 449 498 $suc_lang = $lang; … … 496 545 } 497 546 498 499 547 // The user has already selected a smilies_pak file 500 548 if ($current == 'delete') … … 540 588 } 541 589 $db->sql_freeresult($result); 590 } 591 592 if ($mode == 'smilies') 593 { 594 $smiley_count = $this->item_count($table); 595 if ($smiley_count + sizeof($pak_ary) > SMILEY_LIMIT) 596 { 597 trigger_error(sprintf($user->lang['TOO_MANY_SMILIES'], SMILEY_LIMIT) . adm_back_link($this->u_action), E_USER_WARNING); 598 } 542 599 } 543 600 … … 836 893 837 894 $spacer = false; 895 $pagination_start = request_var('start', 0); 896 897 $item_count = $this->item_count($table); 838 898 839 899 $sql = "SELECT * 840 900 FROM $table 841 901 ORDER BY {$fields}_order ASC"; 842 $result = $db->sql_query ($sql);902 $result = $db->sql_query_limit($sql, $config['smilies_per_page'], $pagination_start); 843 903 844 904 while ($row = $db->sql_fetchrow($result)) … … 856 916 'U_EDIT' => $this->u_action . '&action=edit&id=' . $row[$fields . '_id'], 857 917 'U_DELETE' => $this->u_action . '&action=delete&id=' . $row[$fields . '_id'], 858 'U_MOVE_UP' => $this->u_action . '&action=move_up&id=' . $row[$fields . '_id'] ,859 'U_MOVE_DOWN' => $this->u_action . '&action=move_down&id=' . $row[$fields . '_id'] )860 ) ;918 'U_MOVE_UP' => $this->u_action . '&action=move_up&id=' . $row[$fields . '_id'] . '&start=' . $pagination_start, 919 'U_MOVE_DOWN' => $this->u_action . '&action=move_down&id=' . $row[$fields . '_id'] . '&start=' . $pagination_start, 920 )); 861 921 862 922 if (!$spacer && !$row['display_on_posting']) … … 866 926 } 867 927 $db->sql_freeresult($result); 928 929 $template->assign_var('PAGINATION', 930 generate_pagination($this->u_action, $item_count, $config['smilies_per_page'], $pagination_start, true) 931 ); 932 } 933 934 /** 935 * Returns the count of smilies or icons in the database 936 * 937 * @param string $table The table of items to count. 938 * @return int number of items 939 */ 940 /* private */ function item_count($table) 941 { 942 global $db; 943 944 $sql = "SELECT COUNT(*) AS item_count 945 FROM $table"; 946 $result = $db->sql_query($sql); 947 $item_count = (int) $db->sql_fetchfield('item_count'); 948 $db->sql_freeresult($result); 949 950 return $item_count; 868 951 } 869 952 } -
trunk/forum/includes/acp/acp_inactive.php
r400 r702 3 3 * 4 4 * @package acp 5 * @version $Id : acp_inactive.php 8598 2008-06-04 15:37:06Z naderman$5 * @version $Id$ 6 6 * @copyright (c) 2006 phpBB Group 7 7 * @license http://opensource.org/licenses/gpl-license.php GNU Public License … … 52 52 add_form_key($form_key); 53 53 54 // We build the sort key and per page settings here, because they may be needed later 55 56 // Number of entries to display 57 $per_page = request_var('users_per_page', (int) $config['topics_per_page']); 58 59 // Sorting 60 $limit_days = array(0 => $user->lang['ALL_ENTRIES'], 1 => $user->lang['1_DAY'], 7 => $user->lang['7_DAYS'], 14 => $user->lang['2_WEEKS'], 30 => $user->lang['1_MONTH'], 90 => $user->lang['3_MONTHS'], 180 => $user->lang['6_MONTHS'], 365 => $user->lang['1_YEAR']); 61 $sort_by_text = array('i' => $user->lang['SORT_INACTIVE'], 'j' => $user->lang['SORT_REG_DATE'], 'l' => $user->lang['SORT_LAST_VISIT'], 'd' => $user->lang['SORT_LAST_REMINDER'], 'r' => $user->lang['SORT_REASON'], 'u' => $user->lang['SORT_USERNAME'], 'p' => $user->lang['SORT_POSTS'], 'e' => $user->lang['SORT_REMINDER']); 62 $sort_by_sql = array('i' => 'user_inactive_time', 'j' => 'user_regdate', 'l' => 'user_lastvisit', 'd' => 'user_reminded_time', 'r' => 'user_inactive_reason', 'u' => 'username_clean', 'p' => 'user_posts', 'e' => 'user_reminded'); 63 64 $s_limit_days = $s_sort_key = $s_sort_dir = $u_sort_param = ''; 65 gen_sort_selects($limit_days, $sort_by_text, $sort_days, $sort_key, $sort_dir, $s_limit_days, $s_sort_key, $s_sort_dir, $u_sort_param); 66 54 67 if ($submit && sizeof($mark)) 55 68 { … … 68 81 WHERE ' . $db->sql_in_set('user_id', $mark); 69 82 $result = $db->sql_query($sql); 70 83 71 84 $user_affected = array(); 72 85 while ($row = $db->sql_fetchrow($result)) … … 78 91 if ($action == 'activate') 79 92 { 80 if ($config['require_activation'] == USER_ACTIVATION_ADMIN) 81 { 82 // Get those 'being activated'... 83 $sql = 'SELECT user_id, username, user_email, user_lang 84 FROM ' . USERS_TABLE . ' 85 WHERE ' . $db->sql_in_set('user_id', $mark) . ' 86 AND user_type = ' . USER_INACTIVE; 87 $result = $db->sql_query($sql); 88 89 $inactive_users = array(); 90 while ($row = $db->sql_fetchrow($result)) 91 { 92 $inactive_users[] = $row; 93 } 94 $db->sql_freeresult($result); 95 } 93 // Get those 'being activated'... 94 $sql = 'SELECT user_id, username' . (($config['require_activation'] == USER_ACTIVATION_ADMIN) ? ', user_email, user_lang' : '') . ' 95 FROM ' . USERS_TABLE . ' 96 WHERE ' . $db->sql_in_set('user_id', $mark) . ' 97 AND user_type = ' . USER_INACTIVE; 98 $result = $db->sql_query($sql); 99 100 $inactive_users = array(); 101 while ($row = $db->sql_fetchrow($result)) 102 { 103 $inactive_users[] = $row; 104 } 105 $db->sql_freeresult($result); 96 106 97 107 user_active_flip('activate', $mark); … … 101 111 include_once($phpbb_root_path . 'includes/functions_messenger.' . $phpEx); 102 112 103 $messenger = new messenger( );113 $messenger = new messenger(false); 104 114 105 115 foreach ($inactive_users as $row) … … 112 122 $messenger->headers('X-AntiAbuse: User_id - ' . $user->data['user_id']); 113 123 $messenger->headers('X-AntiAbuse: Username - ' . $user->data['username']); 124 $messenger->headers('X-AntiAbuse: User IP - ' . $user->ip); 114 125 115 126 $messenger->assign_vars(array( … … 122 133 $messenger->save_queue(); 123 134 } 135 136 if (!empty($inactive_users)) 137 { 138 foreach ($inactive_users as $row) 139 { 140 add_log('admin', 'LOG_USER_ACTIVE', $row['username']); 141 add_log('user', $row['user_id'], 'LOG_USER_ACTIVE_USER'); 142 } 143 } 144 145 // For activate we really need to redirect, else a refresh can result in users being deactivated again 146 $u_action = $this->u_action . "&$u_sort_param&start=$start"; 147 $u_action .= ($per_page != $config['topics_per_page']) ? "&users_per_page=$per_page" : ''; 148 149 redirect($u_action); 124 150 } 125 151 else if ($action == 'delete') … … 162 188 $sql = 'SELECT user_id, username, user_email, user_lang, user_jabber, user_notify_type, user_regdate, user_actkey 163 189 FROM ' . USERS_TABLE . ' 164 WHERE ' . $db->sql_in_set('user_id', $mark); 190 WHERE ' . $db->sql_in_set('user_id', $mark) . ' 191 AND user_inactive_reason'; 192 193 $sql .= ($config['require_activation'] == USER_ACTIVATION_ADMIN) ? ' = ' . INACTIVE_REMIND : ' <> ' . INACTIVE_MANUAL; 194 165 195 $result = $db->sql_query($sql); 166 196 … … 171 201 172 202 $messenger = new messenger(); 173 $usernames = array();203 $usernames = $user_ids = array(); 174 204 175 205 do … … 180 210 $messenger->im($row['user_jabber'], $row['username']); 181 211 212 $messenger->headers('X-AntiAbuse: Board servername - ' . $config['server_name']); 213 $messenger->headers('X-AntiAbuse: User_id - ' . $user->data['user_id']); 214 $messenger->headers('X-AntiAbuse: Username - ' . $user->data['username']); 215 $messenger->headers('X-AntiAbuse: User IP - ' . $user->ip); 216 182 217 $messenger->assign_vars(array( 183 218 'USERNAME' => htmlspecialchars_decode($row['username']), 184 'REGISTER_DATE' => $user->format_date($row['user_regdate'] ),219 'REGISTER_DATE' => $user->format_date($row['user_regdate'], false, true), 185 220 'U_ACTIVATE' => generate_board_url() . "/ucp.$phpEx?mode=activate&u=" . $row['user_id'] . '&k=' . $row['user_actkey']) 186 221 ); … … 189 224 190 225 $usernames[] = $row['username']; 226 $user_ids[] = (int) $row['user_id']; 191 227 } 192 228 while ($row = $db->sql_fetchrow($result)); 193 229 194 230 $messenger->save_queue(); 231 232 // Add the remind state to the database 233 $sql = 'UPDATE ' . USERS_TABLE . ' 234 SET user_reminded = user_reminded + 1, 235 user_reminded_time = ' . time() . ' 236 WHERE ' . $db->sql_in_set('user_id', $user_ids); 237 $db->sql_query($sql); 195 238 196 239 add_log('admin', 'LOG_INACTIVE_REMIND', implode(', ', $usernames)); … … 198 241 } 199 242 $db->sql_freeresult($result); 200 243 244 // For remind we really need to redirect, else a refresh can result in more than one reminder 245 $u_action = $this->u_action . "&$u_sort_param&start=$start"; 246 $u_action .= ($per_page != $config['topics_per_page']) ? "&users_per_page=$per_page" : ''; 247 248 redirect($u_action); 249 201 250 break; 202 251 } 203 252 } 204 253 205 // Sorting206 $limit_days = array(0 => $user->lang['ALL_ENTRIES'], 1 => $user->lang['1_DAY'], 7 => $user->lang['7_DAYS'], 14 => $user->lang['2_WEEKS'], 30 => $user->lang['1_MONTH'], 90 => $user->lang['3_MONTHS'], 180 => $user->lang['6_MONTHS'], 365 => $user->lang['1_YEAR']);207 $sort_by_text = array('i' => $user->lang['SORT_INACTIVE'], 'j' => $user->lang['SORT_REG_DATE'], 'l' => $user->lang['SORT_LAST_VISIT'], 'r' => $user->lang['SORT_REASON'], 'u' => $user->lang['SORT_USERNAME']);208 $sort_by_sql = array('i' => 'user_inactive_time', 'j' => 'user_regdate', 'l' => 'user_lastvisit', 'r' => 'user_inactive_reason', 'u' => 'username_clean');209 210 $s_limit_days = $s_sort_key = $s_sort_dir = $u_sort_param = '';211 gen_sort_selects($limit_days, $sort_by_text, $sort_days, $sort_key, $sort_dir, $s_limit_days, $s_sort_key, $s_sort_dir, $u_sort_param);212 213 254 // Define where and sort sql for use in displaying logs 214 255 $sql_where = ($sort_days) ? (time() - ($sort_days * 86400)) : 0; … … 218 259 $inactive_count = 0; 219 260 220 $start = view_inactive_users($inactive, $inactive_count, $ config['topics_per_page'], $start, $sql_where, $sql_sort);261 $start = view_inactive_users($inactive, $inactive_count, $per_page, $start, $sql_where, $sql_sort); 221 262 222 263 foreach ($inactive as $row) … … 224 265 $template->assign_block_vars('inactive', array( 225 266 'INACTIVE_DATE' => $user->format_date($row['user_inactive_time']), 267 'REMINDED_DATE' => $user->format_date($row['user_reminded_time']), 226 268 'JOINED' => $user->format_date($row['user_regdate']), 227 269 'LAST_VISIT' => (!$row['user_lastvisit']) ? ' - ' : $user->format_date($row['user_lastvisit']), 270 228 271 'REASON' => $row['inactive_reason'], 229 272 'USER_ID' => $row['user_id'], 230 'USERNAME' => $row['username'], 231 'U_USER_ADMIN' => append_sid("{$phpbb_admin_path}index.$phpEx", "i=users&mode=overview&u={$row['user_id']}")) 232 ); 273 'POSTS' => ($row['user_posts']) ? $row['user_posts'] : 0, 274 'REMINDED' => $row['user_reminded'], 275 276 'REMINDED_EXPLAIN' => $user->lang('USER_LAST_REMINDED', (int) $row['user_reminded'], $user->format_date($row['user_reminded_time'])), 277 278 'USERNAME_FULL' => get_username_string('full', $row['user_id'], $row['username'], $row['user_colour'], false, append_sid("{$phpbb_admin_path}index.$phpEx", 'i=users&mode=overview')), 279 'USERNAME' => get_username_string('username', $row['user_id'], $row['username'], $row['user_colour']), 280 'USER_COLOR' => get_username_string('colour', $row['user_id'], $row['username'], $row['user_colour']), 281 282 'U_USER_ADMIN' => append_sid("{$phpbb_admin_path}index.$phpEx", "i=users&mode=overview&u={$row['user_id']}"), 283 'U_SEARCH_USER' => ($auth->acl_get('u_search')) ? append_sid("{$phpbb_root_path}search.$phpEx", "author_id={$row['user_id']}&sr=posts") : '', 284 )); 233 285 } 234 286 … … 246 298 'S_SORT_KEY' => $s_sort_key, 247 299 'S_SORT_DIR' => $s_sort_dir, 248 'S_ON_PAGE' => on_page($inactive_count, $config['topics_per_page'], $start), 249 'PAGINATION' => generate_pagination($this->u_action . "&$u_sort_param", $inactive_count, $config['topics_per_page'], $start, true), 250 300 'S_ON_PAGE' => on_page($inactive_count, $per_page, $start), 301 'PAGINATION' => generate_pagination($this->u_action . "&$u_sort_param&users_per_page=$per_page", $inactive_count, $per_page, $start, true), 302 'USERS_PER_PAGE' => $per_page, 303 251 304 'U_ACTION' => $this->u_action . '&start=' . $start, 252 305 )); -
trunk/forum/includes/acp/acp_jabber.php
r400 r702 3 3 * 4 4 * @package acp 5 * @version $Id : acp_jabber.php 8990 2008-10-09 15:41:19Z acydburn$5 * @version $Id$ 6 6 * @copyright (c) 2005 phpBB Group 7 7 * @license http://opensource.org/licenses/gpl-license.php GNU Public License … … 45 45 $this->page_title = 'ACP_JABBER_SETTINGS'; 46 46 47 $jab_enable = request_var('jab_enable', 48 $jab_host = request_var('jab_host', 49 $jab_port = request_var('jab_port', 50 $jab_username = request_var('jab_username', 51 $jab_password = request_var('jab_password', 52 $jab_package_size = request_var('jab_package_size', 53 $jab_use_ssl = request_var('jab_use_ssl', 47 $jab_enable = request_var('jab_enable', (bool) $config['jab_enable']); 48 $jab_host = request_var('jab_host', (string) $config['jab_host']); 49 $jab_port = request_var('jab_port', (int) $config['jab_port']); 50 $jab_username = request_var('jab_username', (string) $config['jab_username']); 51 $jab_password = request_var('jab_password', (string) $config['jab_password']); 52 $jab_package_size = request_var('jab_package_size', (int) $config['jab_package_size']); 53 $jab_use_ssl = request_var('jab_use_ssl', (bool) $config['jab_use_ssl']); 54 54 55 55 $form_name = 'acp_jabber'; … … 89 89 { 90 90 // This feature is disabled. 91 // We update the user table to be sure all users that have IM as notify type are set to both as notify type 91 // We update the user table to be sure all users that have IM as notify type are set to both as notify type 92 // We set this to both because users still have their jabber address entered and may want to receive jabber notifications again once it is re-enabled. 92 93 $sql_ary = array( 93 94 'user_notify_type' => NOTIFY_BOTH, … … 117 118 'L_JAB_SERVER_EXPLAIN' => sprintf($user->lang['JAB_SERVER_EXPLAIN'], '<a href="http://www.jabber.org/">', '</a>'), 118 119 'JAB_HOST' => $jab_host, 119 'JAB_PORT' => $jab_port,120 'JAB_PORT' => ($jab_port) ? $jab_port : '', 120 121 'JAB_USERNAME' => $jab_username, 121 122 'JAB_PASSWORD' => $jab_password, -
trunk/forum/includes/acp/acp_language.php
r400 r702 3 3 * 4 4 * @package acp 5 * @version $Id : acp_language.php 8780 2008-08-22 12:52:48Z acydburn$5 * @version $Id$ 6 6 * @copyright (c) 2005 phpBB Group 7 7 * @license http://opensource.org/licenses/gpl-license.php GNU Public License … … 767 767 } 768 768 769 $db->sql_query('DELETE FROM ' . LANG_TABLE . ' WHERE lang_id = ' . $lang_id); 770 771 $sql = 'UPDATE ' . USERS_TABLE . " 772 SET user_lang = '" . $db->sql_escape($config['default_lang']) . "' 773 WHERE user_lang = '" . $db->sql_escape($row['lang_iso']) . "'"; 774 $db->sql_query($sql); 775 776 // We also need to remove the translated entries for custom profile fields - we want clean tables, don't we? 777 $sql = 'DELETE FROM ' . PROFILE_LANG_TABLE . ' WHERE lang_id = ' . $lang_id; 778 $db->sql_query($sql); 779 780 $sql = 'DELETE FROM ' . PROFILE_FIELDS_LANG_TABLE . ' WHERE lang_id = ' . $lang_id; 781 $db->sql_query($sql); 782 783 $sql = 'DELETE FROM ' . STYLES_IMAGESET_DATA_TABLE . " WHERE image_lang = '" . $db->sql_escape($row['lang_iso']) . "'"; 784 $result = $db->sql_query($sql); 785 786 $cache->destroy('sql', STYLES_IMAGESET_DATA_TABLE); 787 788 add_log('admin', 'LOG_LANGUAGE_PACK_DELETED', $row['lang_english_name']); 789 790 trigger_error(sprintf($user->lang['LANGUAGE_PACK_DELETED'], $row['lang_english_name']) . adm_back_link($this->u_action)); 769 if (confirm_box(true)) 770 { 771 $db->sql_query('DELETE FROM ' . LANG_TABLE . ' WHERE lang_id = ' . $lang_id); 772 773 $sql = 'UPDATE ' . USERS_TABLE . " 774 SET user_lang = '" . $db->sql_escape($config['default_lang']) . "' 775 WHERE user_lang = '" . $db->sql_escape($row['lang_iso']) . "'"; 776 $db->sql_query($sql); 777 778 // We also need to remove the translated entries for custom profile fields - we want clean tables, don't we? 779 $sql = 'DELETE FROM ' . PROFILE_LANG_TABLE . ' WHERE lang_id = ' . $lang_id; 780 $db->sql_query($sql); 781 782 $sql = 'DELETE FROM ' . PROFILE_FIELDS_LANG_TABLE . ' WHERE lang_id = ' . $lang_id; 783 $db->sql_query($sql); 784 785 $sql = 'DELETE FROM ' . STYLES_IMAGESET_DATA_TABLE . " WHERE image_lang = '" . $db->sql_escape($row['lang_iso']) . "'"; 786 $result = $db->sql_query($sql); 787 788 $cache->destroy('sql', STYLES_IMAGESET_DATA_TABLE); 789 790 add_log('admin', 'LOG_LANGUAGE_PACK_DELETED', $row['lang_english_name']); 791 792 trigger_error(sprintf($user->lang['LANGUAGE_PACK_DELETED'], $row['lang_english_name']) . adm_back_link($this->u_action)); 793 } 794 else 795 { 796 $s_hidden_fields = array( 797 'i' => $id, 798 'mode' => $mode, 799 'action' => $action, 800 'id' => $lang_id, 801 ); 802 confirm_box(false, $user->lang['CONFIRM_OPERATION'], build_hidden_fields($s_hidden_fields)); 803 } 791 804 break; 792 805 … … 1108 1121 while (($file = readdir($dp)) !== false) 1109 1122 { 1123 if (!is_dir($phpbb_root_path . 'language/' . $file)) 1124 { 1125 continue; 1126 } 1127 1110 1128 if ($file[0] != '.' && file_exists("{$phpbb_root_path}language/$file/iso.txt")) 1111 1129 { … … 1255 1273 1256 1274 $non_static = array_shift($keys); 1257 $value = array_shift($keys);1275 $value = utf8_normalize_nfc(array_shift($keys)); 1258 1276 1259 1277 if (!$non_static) -
trunk/forum/includes/acp/acp_logs.php
r400 r702 3 3 * 4 4 * @package acp 5 * @version $Id : acp_logs.php 8479 2008-03-29 00:22:48Z naderman$5 * @version $Id$ 6 6 * @copyright (c) 2005 phpBB Group 7 7 * @license http://opensource.org/licenses/gpl-license.php GNU Public License … … 34 34 $action = request_var('action', ''); 35 35 $forum_id = request_var('f', 0); 36 $topic_id = request_var('t', 0); 36 37 $start = request_var('start', 0); 37 38 $deletemark = (!empty($_POST['delmarked'])) ? true : false; … … 105 106 $sql_sort = $sort_by_sql[$sort_key] . ' ' . (($sort_dir == 'd') ? 'DESC' : 'ASC'); 106 107 108 $keywords = utf8_normalize_nfc(request_var('keywords', '', true)); 109 $keywords_param = !empty($keywords) ? '&keywords=' . urlencode(htmlspecialchars_decode($keywords)) : ''; 110 107 111 $l_title = $user->lang['ACP_' . strtoupper($mode) . '_LOGS']; 108 112 $l_title_explain = $user->lang['ACP_' . strtoupper($mode) . '_LOGS_EXPLAIN']; … … 124 128 $log_data = array(); 125 129 $log_count = 0; 126 view_log($mode, $log_data, $log_count, $config['topics_per_page'], $start, $forum_id, 0, 0, $sql_where, $sql_sort );130 view_log($mode, $log_data, $log_count, $config['topics_per_page'], $start, $forum_id, 0, 0, $sql_where, $sql_sort, $keywords); 127 131 128 132 $template->assign_vars(array( … … 132 136 133 137 'S_ON_PAGE' => on_page($log_count, $config['topics_per_page'], $start), 134 'PAGINATION' => generate_pagination($this->u_action . "&$u_sort_param ", $log_count, $config['topics_per_page'], $start, true),138 'PAGINATION' => generate_pagination($this->u_action . "&$u_sort_param$keywords_param", $log_count, $config['topics_per_page'], $start, true), 135 139 136 140 'S_LIMIT_DAYS' => $s_limit_days, … … 138 142 'S_SORT_DIR' => $s_sort_dir, 139 143 'S_CLEARLOGS' => $auth->acl_get('a_clearlogs'), 144 'S_KEYWORDS' => $keywords, 140 145 ) 141 146 ); -
trunk/forum/includes/acp/acp_main.php
r400 r702 3 3 * 4 4 * @package acp 5 * @version $Id : acp_main.php 9171 2008-12-04 14:53:04Z acydburn$5 * @version $Id$ 6 6 * @copyright (c) 2005 phpBB Group 7 7 * @license http://opensource.org/licenses/gpl-license.php GNU Public License … … 97 97 $confirm = true; 98 98 $confirm_lang = 'PURGE_CACHE_CONFIRM'; 99 break; 100 case 'purge_sessions': 101 $confirm = true; 102 $confirm_lang = 'PURGE_SESSIONS_CONFIRM'; 99 103 break; 100 104 … … 342 346 add_log('admin', 'LOG_PURGE_CACHE'); 343 347 break; 348 349 case 'purge_sessions': 350 if ((int) $user->data['user_type'] !== USER_FOUNDER) 351 { 352 trigger_error($user->lang['NO_AUTH_OPERATION'] . adm_back_link($this->u_action), E_USER_WARNING); 353 } 354 355 $tables = array(CONFIRM_TABLE, SESSIONS_TABLE); 356 357 foreach ($tables as $table) 358 { 359 switch ($db->sql_layer) 360 { 361 case 'sqlite': 362 case 'firebird': 363 $db->sql_query("DELETE FROM $table"); 364 break; 365 366 default: 367 $db->sql_query("TRUNCATE TABLE $table"); 368 break; 369 } 370 } 371 372 // let's restore the admin session 373 $reinsert_ary = array( 374 'session_id' => (string) $user->session_id, 375 'session_page' => (string) substr($user->page['page'], 0, 199), 376 'session_forum_id' => $user->page['forum'], 377 'session_user_id' => (int) $user->data['user_id'], 378 'session_start' => (int) $user->data['session_start'], 379 'session_last_visit' => (int) $user->data['session_last_visit'], 380 'session_time' => (int) $user->time_now, 381 'session_browser' => (string) trim(substr($user->browser, 0, 149)), 382 'session_forwarded_for' => (string) $user->forwarded_for, 383 'session_ip' => (string) $user->ip, 384 'session_autologin' => (int) $user->data['session_autologin'], 385 'session_admin' => 1, 386 'session_viewonline' => (int) $user->data['session_viewonline'], 387 ); 388 389 $sql = 'INSERT INTO ' . SESSIONS_TABLE . ' ' . $db->sql_build_array('INSERT', $reinsert_ary); 390 $db->sql_query($sql); 391 392 add_log('admin', 'LOG_PURGE_SESSIONS'); 393 break; 344 394 } 345 395 } 396 } 397 398 // Version check 399 $user->add_lang('install'); 400 401 if ($auth->acl_get('a_server') && version_compare(PHP_VERSION, '5.2.0', '<')) 402 { 403 $template->assign_vars(array( 404 'S_PHP_VERSION_OLD' => true, 405 'L_PHP_VERSION_OLD' => sprintf($user->lang['PHP_VERSION_OLD'], '<a href="http://www.phpbb.com/community/viewtopic.php?f=14&t=1958605">', '</a>'), 406 )); 407 } 408 409 $latest_version_info = false; 410 if (($latest_version_info = obtain_latest_version_info(request_var('versioncheck_force', false))) === false) 411 { 412 $template->assign_var('S_VERSIONCHECK_FAIL', true); 413 } 414 else 415 { 416 $latest_version_info = explode("\n", $latest_version_info); 417 418 $latest_version = str_replace('rc', 'RC', strtolower(trim($latest_version_info[0]))); 419 $current_version = str_replace('rc', 'RC', strtolower($config['version'])); 420 421 $template->assign_vars(array( 422 'S_VERSION_UP_TO_DATE' => version_compare($current_version, $latest_version, '<') ? false : true, 423 )); 346 424 } 347 425 … … 436 514 'TOTAL_ORPHAN' => $total_orphan, 437 515 'S_TOTAL_ORPHAN' => ($total_orphan === false) ? false : true, 438 'GZIP_COMPRESSION' => ($config['gzip_compress'] ) ? $user->lang['ON'] : $user->lang['OFF'],516 'GZIP_COMPRESSION' => ($config['gzip_compress'] && @extension_loaded('zlib')) ? $user->lang['ON'] : $user->lang['OFF'], 439 517 'DATABASE_INFO' => $db->sql_server_info(), 440 518 'BOARD_VERSION' => $config['version'], … … 443 521 'U_ADMIN_LOG' => append_sid("{$phpbb_admin_path}index.$phpEx", 'i=logs&mode=admin'), 444 522 'U_INACTIVE_USERS' => append_sid("{$phpbb_admin_path}index.$phpEx", 'i=inactive&mode=list'), 523 'U_VERSIONCHECK' => append_sid("{$phpbb_admin_path}index.$phpEx", 'i=update&mode=version_check'), 524 'U_VERSIONCHECK_FORCE' => append_sid("{$phpbb_admin_path}index.$phpEx", 'i=1&versioncheck_force=1'), 445 525 446 526 'S_ACTION_OPTIONS' => ($auth->acl_get('a_board')) ? true : false, … … 469 549 if ($auth->acl_get('a_user')) 470 550 { 551 $user->add_lang('memberlist'); 552 471 553 $inactive = array(); 472 554 $inactive_count = 0; … … 478 560 $template->assign_block_vars('inactive', array( 479 561 'INACTIVE_DATE' => $user->format_date($row['user_inactive_time']), 562 'REMINDED_DATE' => $user->format_date($row['user_reminded_time']), 480 563 'JOINED' => $user->format_date($row['user_regdate']), 481 564 'LAST_VISIT' => (!$row['user_lastvisit']) ? ' - ' : $user->format_date($row['user_lastvisit']), 565 482 566 'REASON' => $row['inactive_reason'], 483 567 'USER_ID' => $row['user_id'], 484 'USERNAME' => $row['username'], 485 'U_USER_ADMIN' => append_sid("{$phpbb_admin_path}index.$phpEx", "i=users&mode=overview&u={$row['user_id']}")) 486 ); 568 'POSTS' => ($row['user_posts']) ? $row['user_posts'] : 0, 569 'REMINDED' => $row['user_reminded'], 570 571 'REMINDED_EXPLAIN' => $user->lang('USER_LAST_REMINDED', (int) $row['user_reminded'], $user->format_date($row['user_reminded_time'])), 572 573 'USERNAME_FULL' => get_username_string('full', $row['user_id'], $row['username'], $row['user_colour'], false, append_sid("{$phpbb_admin_path}index.$phpEx", 'i=users&mode=overview')), 574 'USERNAME' => get_username_string('username', $row['user_id'], $row['username'], $row['user_colour']), 575 'USER_COLOR' => get_username_string('colour', $row['user_id'], $row['username'], $row['user_colour']), 576 577 'U_USER_ADMIN' => append_sid("{$phpbb_admin_path}index.$phpEx", "i=users&mode=overview&u={$row['user_id']}"), 578 'U_SEARCH_USER' => ($auth->acl_get('u_search')) ? append_sid("{$phpbb_root_path}search.$phpEx", "author_id={$row['user_id']}&sr=posts") : '', 579 )); 487 580 } 488 581 … … 500 593 501 594 // Warn if install is still present 502 if (file_exists($phpbb_root_path . 'install') )595 if (file_exists($phpbb_root_path . 'install') && !is_file($phpbb_root_path . 'install')) 503 596 { 504 597 $template->assign_var('S_REMOVE_INSTALL', true); 505 598 } 506 599 507 if (!defined('PHPBB_DISABLE_CONFIG_CHECK') && file_exists($phpbb_root_path . 'config.' . $phpEx) && is_writable($phpbb_root_path . 'config.' . $phpEx))600 if (!defined('PHPBB_DISABLE_CONFIG_CHECK') && file_exists($phpbb_root_path . 'config.' . $phpEx) && phpbb_is_writable($phpbb_root_path . 'config.' . $phpEx)) 508 601 { 509 602 // World-Writable? (000x) 510 603 $template->assign_var('S_WRITABLE_CONFIG', (bool) (@fileperms($phpbb_root_path . 'config.' . $phpEx) & 0x0002)); 604 } 605 606 // Fill dbms version if not yet filled 607 if (empty($config['dbms_version'])) 608 { 609 set_config('dbms_version', $db->sql_server_info(true)); 511 610 } 512 611 -
trunk/forum/includes/acp/acp_permissions.php
r400 r702 3 3 * 4 4 * @package acp 5 * @version $Id : acp_permissions.php 8710 2008-07-29 13:35:49Z acydburn$5 * @version $Id$ 6 6 * @copyright (c) 2005 phpBB Group 7 7 * @license http://opensource.org/licenses/gpl-license.php GNU Public License … … 24 24 var $u_action; 25 25 var $permission_dropdown; 26 26 27 27 function main($id, $mode) 28 28 { … … 55 55 return; 56 56 } 57 trigger_error('NO_MODE', E_USER_ERROR); 58 } 59 60 // Copy forum permissions 61 if ($mode == 'setting_forum_copy') 62 { 63 $this->tpl_name = 'permission_forum_copy'; 64 65 if ($auth->acl_get('a_fauth') && $auth->acl_get('a_authusers') && $auth->acl_get('a_authgroups') && $auth->acl_get('a_mauth')) 66 { 67 $this->page_title = 'ACP_FORUM_PERMISSIONS_COPY'; 68 $this->copy_forum_permissions(); 69 return; 70 } 71 57 72 trigger_error('NO_MODE', E_USER_ERROR); 58 73 } … … 95 110 $db->sql_freeresult($result); 96 111 } 97 112 98 113 // Map usernames to ids and vice versa 99 114 if ($usernames) … … 113 128 } 114 129 unset($username); 115 130 116 131 // Build forum ids (of all forums are checked or subforum listing used) 117 132 if ($all_forums) … … 218 233 } 219 234 220 221 235 // Handle actions 222 236 if (strpos($mode, 'setting_') === 0 && $action) … … 225 239 { 226 240 case 'delete': 227 228 if (!check_form_key($form_name)) 229 { 230 trigger_error($user->lang['FORM_INVALID']. adm_back_link($this->u_action), E_USER_WARNING); 231 } 232 // All users/groups selected? 233 $all_users = (isset($_POST['all_users'])) ? true : false; 234 $all_groups = (isset($_POST['all_groups'])) ? true : false; 235 236 if ($all_users || $all_groups) 237 { 238 $items = $this->retrieve_defined_user_groups($permission_scope, $forum_id, $permission_type); 239 240 if ($all_users && sizeof($items['user_ids'])) 241 if (confirm_box(true)) 242 { 243 // All users/groups selected? 244 $all_users = (isset($_POST['all_users'])) ? true : false; 245 $all_groups = (isset($_POST['all_groups'])) ? true : false; 246 247 if ($all_users || $all_groups) 241 248 { 242 $user_id = $items['user_ids']; 249 $items = $this->retrieve_defined_user_groups($permission_scope, $forum_id, $permission_type); 250 251 if ($all_users && sizeof($items['user_ids'])) 252 { 253 $user_id = $items['user_ids']; 254 } 255 else if ($all_groups && sizeof($items['group_ids'])) 256 { 257 $group_id = $items['group_ids']; 258 } 243 259 } 244 else if ($all_groups && sizeof($items['group_ids'])) 260 261 if (sizeof($user_id) || sizeof($group_id)) 245 262 { 246 $ group_id = $items['group_ids'];263 $this->remove_permissions($mode, $permission_type, $auth_admin, $user_id, $group_id, $forum_id); 247 264 } 248 } 249 250 if (sizeof($user_id) || sizeof($group_id)) 251 { 252 $this->remove_permissions($mode, $permission_type, $auth_admin, $user_id, $group_id, $forum_id); 265 else 266 { 267 trigger_error($user->lang['NO_USER_GROUP_SELECTED'] . adm_back_link($this->u_action), E_USER_WARNING); 268 } 253 269 } 254 270 else 255 271 { 256 trigger_error($user->lang['NO_USER_GROUP_SELECTED'] . adm_back_link($this->u_action), E_USER_WARNING); 272 if (isset($_POST['cancel'])) 273 { 274 $u_redirect = $this->u_action . '&type=' . $permission_type; 275 foreach ($forum_id as $fid) 276 { 277 $u_redirect .= '&forum_id[]=' . $fid; 278 } 279 redirect($u_redirect); 280 } 281 282 $s_hidden_fields = array( 283 'i' => $id, 284 'mode' => $mode, 285 'action' => array($action => 1), 286 'user_id' => $user_id, 287 'group_id' => $group_id, 288 'forum_id' => $forum_id, 289 'type' => $permission_type, 290 ); 291 if (isset($_POST['all_users'])) 292 { 293 $s_hidden_fields['all_users'] = 1; 294 } 295 if (isset($_POST['all_groups'])) 296 { 297 $s_hidden_fields['all_groups'] = 1; 298 } 299 confirm_box(false, $user->lang['CONFIRM_OPERATION'], build_hidden_fields($s_hidden_fields)); 257 300 } 258 301 break; … … 529 572 continue; 530 573 } 531 574 532 575 if ($branch_there) 533 576 { … … 540 583 return $s_options; 541 584 } 542 585 543 586 /** 544 587 * Build dropdown field for changing permission types … … 547 590 { 548 591 global $user, $auth; 549 592 550 593 $s_dropdown_options = ''; 551 594 foreach ($options as $setting) … … 627 670 trigger_error($user->lang['NO_AUTH_OPERATION'] . adm_back_link($this->u_action), E_USER_WARNING); 628 671 } 629 672 630 673 $ug_id = $forum_id = 0; 631 674 … … 763 806 $this->log_action($mode, 'add', $permission_type, $ug_type, $ug_ids, $forum_ids); 764 807 765 trigger_error($user->lang['AUTH_UPDATED'] . adm_back_link($this->u_action)); 808 if ($mode == 'setting_forum_local' || $mode == 'setting_mod_local') 809 { 810 trigger_error($user->lang['AUTH_UPDATED'] . adm_back_link($this->u_action . '&forum_id[]=' . implode('&forum_id[]=', $forum_ids))); 811 } 812 else 813 { 814 trigger_error($user->lang['AUTH_UPDATED'] . adm_back_link($this->u_action)); 815 } 766 816 } 767 817 … … 810 860 { 811 861 global $user, $db, $auth; 812 862 813 863 // User or group to be set? 814 864 $ug_type = (sizeof($user_id)) ? 'user' : 'group'; … … 830 880 $this->log_action($mode, 'del', $permission_type, $ug_type, (($ug_type == 'user') ? $user_id : $group_id), (sizeof($forum_id) ? $forum_id : array(0 => 0))); 831 881 832 trigger_error($user->lang['AUTH_UPDATED'] . adm_back_link($this->u_action)); 882 if ($mode == 'setting_forum_local' || $mode == 'setting_mod_local') 883 { 884 trigger_error($user->lang['AUTH_UPDATED'] . adm_back_link($this->u_action . '&forum_id[]=' . implode('&forum_id[]=', $forum_id))); 885 } 886 else 887 { 888 trigger_error($user->lang['AUTH_UPDATED'] . adm_back_link($this->u_action)); 889 } 833 890 } 834 891 … … 950 1007 WHERE ug.user_id = ' . $user_id . ' 951 1008 AND ug.user_pending = 0 1009 AND NOT (ug.group_leader = 1 AND g.group_skip_auth = 1) 952 1010 ORDER BY g.group_type DESC, g.group_id DESC'; 953 1011 $result = $db->sql_query($sql); … … 1111 1169 1112 1170 /** 1171 * Handles copying permissions from one forum to others 1172 */ 1173 function copy_forum_permissions() 1174 { 1175 global $auth, $cache, $template, $user; 1176 1177 $user->add_lang('acp/forums'); 1178 1179 $submit = isset($_POST['submit']) ? true : false; 1180 1181 if ($submit) 1182 { 1183 $src = request_var('src_forum_id', 0); 1184 $dest = request_var('dest_forum_ids', array(0)); 1185 1186 if (confirm_box(true)) 1187 { 1188 if (copy_forum_permissions($src, $dest)) 1189 { 1190 cache_moderators(); 1191 1192 $auth->acl_clear_prefetch(); 1193 $cache->destroy('sql', FORUMS_TABLE); 1194 1195 trigger_error($user->lang['AUTH_UPDATED'] . adm_back_link($this->u_action)); 1196 } 1197 else 1198 { 1199 trigger_error($user->lang['SELECTED_FORUM_NOT_EXIST'] . adm_back_link($this->u_action), E_USER_WARNING); 1200 } 1201 } 1202 else 1203 { 1204 $s_hidden_fields = array( 1205 'submit' => $submit, 1206 'src_forum_id' => $src, 1207 'dest_forum_ids' => $dest, 1208 ); 1209 1210 $s_hidden_fields = build_hidden_fields($s_hidden_fields); 1211 1212 confirm_box(false, $user->lang['COPY_PERMISSIONS_CONFIRM'], $s_hidden_fields); 1213 } 1214 } 1215 1216 $template->assign_vars(array( 1217 'S_FORUM_OPTIONS' => make_forum_select(false, false, false, false, false), 1218 )); 1219 } 1220 1221 /** 1113 1222 * Get already assigned users/groups 1114 1223 */ … … 1151 1260 $sql_where = 'AND (' . $db->sql_in_set('a.auth_option_id', $option_ids) . ' OR ' . $db->sql_in_set('a.auth_role_id', $role_ids) . ')'; 1152 1261 } 1153 else 1262 else if (sizeof($role_ids)) 1263 { 1264 $sql_where = 'AND ' . $db->sql_in_set('a.auth_role_id', $role_ids); 1265 } 1266 else if (sizeof($option_ids)) 1154 1267 { 1155 1268 $sql_where = 'AND ' . $db->sql_in_set('a.auth_option_id', $option_ids); -
trunk/forum/includes/acp/acp_profile.php
r400 r702 3 3 * 4 4 * @package acp 5 * @version $Id : acp_profile.php 9127 2008-11-26 19:58:35Z acydburn$5 * @version $Id$ 6 6 * @copyright (c) 2005 phpBB Group 7 7 * @license http://opensource.org/licenses/gpl-license.php GNU Public License … … 370 370 'field_no_view' => 0, 371 371 'field_show_on_reg' => 0, 372 'field_show_on_vt' => 0, 372 373 'lang_name' => utf8_normalize_nfc(request_var('field_ident', '', true)), 373 374 'lang_explain' => '', … … 380 381 // $exclude contains the data we gather in each step 381 382 $exclude = array( 382 1 => array('field_ident', 'lang_name', 'lang_explain', 'field_option_none', 'field_show_on_reg', 'field_ required', 'field_hide', 'field_show_profile', 'field_no_view'),383 1 => array('field_ident', 'lang_name', 'lang_explain', 'field_option_none', 'field_show_on_reg', 'field_show_on_vt', 'field_required', 'field_hide', 'field_show_profile', 'field_no_view'), 383 384 2 => array('field_length', 'field_maxlen', 'field_minlen', 'field_validation', 'field_novalue', 'field_default_value'), 384 385 3 => array('l_lang_name', 'l_lang_explain', 'l_lang_default_value', 'l_lang_options') … … 406 407 'field_required', 407 408 'field_show_on_reg', 409 'field_show_on_vt', 408 410 'field_show_profile', 409 411 'field_hide', … … 508 510 $var = request_var('field_default_value', 0); 509 511 }*/ 512 else if ($field_type == FIELD_INT && $key == 'field_default_value') 513 { 514 // Permit an empty string 515 if (request_var('field_default_value', '') === '') 516 { 517 $var = ''; 518 } 519 } 510 520 511 521 $cp->vars[$key] = $var; … … 722 732 'S_FIELD_REQUIRED' => ($cp->vars['field_required']) ? true : false, 723 733 'S_SHOW_ON_REG' => ($cp->vars['field_show_on_reg']) ? true : false, 734 'S_SHOW_ON_VT' => ($cp->vars['field_show_on_vt']) ? true : false, 724 735 'S_FIELD_HIDE' => ($cp->vars['field_hide']) ? true : false, 725 736 'S_SHOW_PROFILE' => ($cp->vars['field_show_profile']) ? true : false, … … 923 934 case FIELD_TEXT: 924 935 case FIELD_STRING: 925 if ( $cp->vars['lang_default_value'])936 if (strlen($cp->vars['lang_default_value'])) 926 937 { 927 938 $options['lang_default_value'] = ($field_type == FIELD_STRING) ? 'string' : 'text'; … … 1037 1048 'field_required' => $cp->vars['field_required'], 1038 1049 'field_show_on_reg' => $cp->vars['field_show_on_reg'], 1050 'field_show_on_vt' => $cp->vars['field_show_on_vt'], 1039 1051 'field_hide' => $cp->vars['field_hide'], 1040 1052 'field_show_profile' => $cp->vars['field_show_profile'], … … 1540 1552 1541 1553 // We are defining the biggest common value, because of the possibility to edit the min/max values of each field. 1542 $sql = 'ALTER TABLE ' . PROFILE_FIELDS_DATA_TABLE . " ADD \"$field_ident\" ";1554 $sql = 'ALTER TABLE ' . PROFILE_FIELDS_DATA_TABLE . ' ADD "' . strtoupper($field_ident) . '" '; 1543 1555 1544 1556 switch ($field_type) -
trunk/forum/includes/acp/acp_prune.php
r400 r702 3 3 * 4 4 * @package acp 5 * @version $Id : acp_prune.php 8479 2008-03-29 00:22:48Z naderman$5 * @version $Id$ 6 6 * @copyright (c) 2005 phpBB Group 7 7 * @license http://opensource.org/licenses/gpl-license.php GNU Public License … … 407 407 $where_sql .= ($count !== '') ? " AND user_posts " . $key_match[$count_select] . ' ' . (int) $count . ' ' : ''; 408 408 409 if (sizeof($active) && $active_select != 'lt') 409 // First handle pruning of users who never logged in, last active date is 0000-00-00 410 if (sizeof($active) && (int) $active[0] == 0 && (int) $active[1] == 0 && (int) $active[2] == 0) 411 { 412 $where_sql .= ' AND user_lastvisit = 0'; 413 } 414 else if (sizeof($active) && $active_select != 'lt') 410 415 { 411 416 $where_sql .= ' AND user_lastvisit ' . $key_match[$active_select] . ' ' . gmmktime(0, 0, 0, (int) $active[1], (int) $active[2], (int) $active[0]); -
trunk/forum/includes/acp/acp_ranks.php
r400 r702 3 3 * 4 4 * @package acp 5 * @version $Id : acp_ranks.php 8479 2008-03-29 00:22:48Z naderman$5 * @version $Id$ 6 6 * @copyright (c) 2005 phpBB Group 7 7 * @license http://opensource.org/licenses/gpl-license.php GNU Public License … … 40 40 $this->page_title = 'ACP_MANAGE_RANKS'; 41 41 42 $form_name = 'acp_ prune';42 $form_name = 'acp_ranks'; 43 43 add_form_key($form_name); 44 44 … … 169 169 $img = $path . $img; 170 170 171 if ( !in_array($img, $existing_imgs) || $action == 'edit')171 if ($ranks && $img == $ranks['rank_image']) 172 172 { 173 if ($ranks && $img == $ranks['rank_image']) 174 { 175 $selected = ' selected="selected"'; 176 $edit_img = $img; 177 } 178 else 179 { 180 $selected = ''; 181 } 182 183 if (strlen($img) > 255) 184 { 185 continue; 186 } 187 188 $filename_list .= '<option value="' . htmlspecialchars($img) . '"' . $selected . '>' . $img . '</option>'; 173 $selected = ' selected="selected"'; 174 $edit_img = $img; 189 175 } 176 else 177 { 178 $selected = ''; 179 } 180 181 if (strlen($img) > 255) 182 { 183 continue; 184 } 185 186 $filename_list .= '<option value="' . htmlspecialchars($img) . '"' . $selected . '>' . $img . ((in_array($img, $existing_imgs)) ? ' ' . $user->lang['RANK_IMAGE_IN_USE'] : '') . '</option>'; 190 187 } 191 188 } -
trunk/forum/includes/acp/acp_search.php
r400 r702 3 3 * 4 4 * @package acp 5 * @version $Id : acp_search.php 8479 2008-03-29 00:22:48Z naderman$5 * @version $Id$ 6 6 * @copyright (c) 2005 phpBB Group 7 7 * @license http://opensource.org/licenses/gpl-license.php GNU Public License … … 64 64 'limit_search_load' => 'float', 65 65 'min_search_author_chars' => 'integer', 66 'max_num_search_keywords' => 'integer', 66 67 'search_store_results' => 'integer', 67 68 ); … … 217 218 'SEARCH_GUEST_INTERVAL' => (float) $config['search_anonymous_interval'], 218 219 'SEARCH_STORE_RESULTS' => (int) $config['search_store_results'], 220 'MAX_NUM_SEARCH_KEYWORDS' => (int) $config['max_num_search_keywords'], 219 221 220 222 'S_SEARCH_TYPES' => $search_options, … … 592 594 ksort($this->state); 593 595 594 set_config('search_indexing_state', implode(',', $this->state) );596 set_config('search_indexing_state', implode(',', $this->state), true); 595 597 } 596 598 -
trunk/forum/includes/acp/acp_styles.php
r400 r702 3 3 * 4 4 * @package acp 5 * @version $Id : acp_styles.php 9152 2008-12-02 16:49:59Z acydburn$5 * @version $Id$ 6 6 * @copyright (c) 2005 phpBB Group 7 7 * @license http://opensource.org/licenses/gpl-license.php GNU Public License … … 38 38 $bitfield = new bitfield(); 39 39 $bitfield->set(0); 40 $bitfield->set(1); 41 $bitfield->set(2); 40 42 $bitfield->set(3); 43 $bitfield->set(4); 41 44 $bitfield->set(8); 42 45 $bitfield->set(9); … … 208 211 } 209 212 210 $sql = 'UPDATE ' . STYLES_TABLE . ' 211 SET style_active = ' . (($action == 'activate') ? 1 : 0) . ' 212 WHERE style_id = ' . $style_id; 213 $db->sql_query($sql); 214 215 // Set style to default for any member using deactivated style 216 if ($action == 'deactivate') 213 if (($action == 'deactivate' && confirm_box(true)) || $action == 'activate') 217 214 { 218 $sql = 'UPDATE ' . USERS_TABLE . '219 SET user_style = ' . $config['default_style'] . "220 WHERE user_style = $style_id";215 $sql = 'UPDATE ' . STYLES_TABLE . ' 216 SET style_active = ' . (($action == 'activate') ? 1 : 0) . ' 217 WHERE style_id = ' . $style_id; 221 218 $db->sql_query($sql); 222 219 223 $sql = 'UPDATE ' . FORUMS_TABLE . ' 224 SET forum_style = 0 225 WHERE forum_style = ' . $style_id; 226 $db->sql_query($sql); 220 // Set style to default for any member using deactivated style 221 if ($action == 'deactivate') 222 { 223 $sql = 'UPDATE ' . USERS_TABLE . ' 224 SET user_style = ' . $config['default_style'] . " 225 WHERE user_style = $style_id"; 226 $db->sql_query($sql); 227 228 $sql = 'UPDATE ' . FORUMS_TABLE . ' 229 SET forum_style = 0 230 WHERE forum_style = ' . $style_id; 231 $db->sql_query($sql); 232 } 233 } 234 else if ($action == 'deactivate') 235 { 236 $s_hidden_fields = array( 237 'i' => $id, 238 'mode' => $mode, 239 'action' => $action, 240 'style_id' => $style_id, 241 ); 242 confirm_box(false, $user->lang['CONFIRM_OPERATION'], build_hidden_fields($s_hidden_fields)); 227 243 } 228 244 break; … … 628 644 while (($file = readdir($dp)) !== false) 629 645 { 646 if (!is_dir($phpbb_root_path . 'styles/' . $file)) 647 { 648 continue; 649 } 650 630 651 $subpath = ($mode != 'style') ? "$mode/" : ''; 631 652 if ($file[0] != '.' && file_exists("{$phpbb_root_path}styles/$file/$subpath$mode.cfg")) … … 732 753 if (!($fp = @fopen($file, 'wb'))) 733 754 { 734 trigger_error($user->lang['NO_TEMPLATE'] . adm_back_link($this->u_action), E_USER_WARNING); 755 // File exists and is writeable, but still not able to be written to 756 trigger_error(sprintf($user->lang['TEMPLATE_FILE_NOT_WRITABLE'], htmlspecialchars($template_file)) . adm_back_link($this->u_action), E_USER_WARNING); 735 757 } 736 758 fwrite($fp, $template_data); … … 744 766 if (!$template_info['template_storedb']) 745 767 { 746 if ($ this->get_super('template', $template_id))768 if ($super = $this->get_super('template', $template_id)) 747 769 { 748 770 $this->store_in_db('template', $super['template_id']); … … 825 847 } 826 848 849 if (empty($filelist[''])) 850 { 851 trigger_error($user->lang['NO_TEMPLATE'] . adm_back_link($this->u_action), E_USER_WARNING); 852 } 853 827 854 // Now create the categories 828 855 $filelist_cats[''] = array(); … … 1022 1049 foreach ($file_ary as $file) 1023 1050 { 1024 $file 1051 $file = str_replace('/', '.', $file); 1025 1052 1026 1053 // perform some dirty guessing to get the path right. 1027 1054 // We assume that three dots in a row were '../' 1028 $tpl_file 1029 $tpl_file 1055 $tpl_file = str_replace('.', '/', $file); 1056 $tpl_file = str_replace('///', '../', $tpl_file); 1030 1057 1031 1058 $filename = "{$cache_prefix}_$file.html.$phpEx"; … … 1059 1086 } 1060 1087 1088 // Correct the filename if it is stored in database and the file is in a subfolder. 1089 if ($template_row['template_storedb']) 1090 { 1091 $file = str_replace('.', '/', $file); 1092 } 1061 1093 1062 1094 $template->assign_block_vars('file', array( … … 1066 1098 'FILENAME' => $file, 1067 1099 'FILENAME_PATH' => $file_tpl, 1068 'FILESIZE' => sprintf('%.1f ' . $user->lang['KIB'], filesize("{$phpbb_root_path}cache/$filename") / 1024),1100 'FILESIZE' => get_formatted_filesize(filesize("{$phpbb_root_path}cache/$filename")), 1069 1101 'MODIFIED' => $user->format_date((!$template_row['template_storedb']) ? filemtime($file_tpl) : $filemtime[$file . '.html'])) 1070 1102 ); … … 1264 1296 } 1265 1297 1266 1267 1298 /** 1268 1299 * Edit imagesets … … 1276 1307 $this->page_title = 'EDIT_IMAGESET'; 1277 1308 1309 if (!$imageset_id) 1310 { 1311 trigger_error($user->lang['NO_IMAGESET'] . adm_back_link($this->u_action), E_USER_WARNING); 1312 } 1313 1278 1314 $update = (isset($_POST['update'])) ? true : false; 1279 1315 1280 $imgname = request_var('imgname', ''); 1281 $imgpath = request_var('imgpath', ''); 1282 $imgsize = request_var('imgsize', false); 1283 $imgwidth = request_var('imgwidth', 0); 1284 $imgheight = request_var('imgheight', 0); 1285 1316 $imgname = request_var('imgname', 'site_logo'); 1286 1317 $imgname = preg_replace('#[^a-z0-9\-+_]#i', '', $imgname); 1287 $imgpath = str_replace('..', '.', $imgpath); 1288 1289 if ($imageset_id) 1290 { 1291 $sql = 'SELECT imageset_path, imageset_name 1292 FROM ' . STYLES_IMAGESET_TABLE . " 1293 WHERE imageset_id = $imageset_id"; 1294 $result = $db->sql_query($sql); 1295 $imageset_row = $db->sql_fetchrow($result); 1296 $db->sql_freeresult($result); 1297 1298 $imageset_path = $imageset_row['imageset_path']; 1299 $imageset_name = $imageset_row['imageset_name']; 1300 1301 $sql_extra = ''; 1302 if (strpos($imgname, '-') !== false) 1303 { 1304 list($imgname, $imgnamelang) = explode('-', $imgname); 1305 $sql_extra = " AND image_lang IN ('" . $db->sql_escape($imgnamelang) . "', '')"; 1306 } 1307 1308 $sql = 'SELECT image_filename, image_width, image_height, image_lang, image_id 1309 FROM ' . STYLES_IMAGESET_DATA_TABLE . " 1310 WHERE imageset_id = $imageset_id 1311 AND image_name = '" . $db->sql_escape($imgname) . "'$sql_extra"; 1312 $result = $db->sql_query($sql); 1313 $imageset_data_row = $db->sql_fetchrow($result); 1314 $db->sql_freeresult($result); 1315 1316 $image_filename = $imageset_data_row['image_filename']; 1317 $image_width = $imageset_data_row['image_width']; 1318 $image_height = $imageset_data_row['image_height']; 1319 $image_lang = $imageset_data_row['image_lang']; 1320 $image_id = $imageset_data_row['image_id']; 1321 1322 if (!$imageset_row) 1323 { 1324 trigger_error($user->lang['NO_IMAGESET'] . adm_back_link($this->u_action), E_USER_WARNING); 1325 } 1326 1327 // Check to see whether the selected image exists in the table 1328 $valid_name = ($update) ? false : true; 1329 1330 foreach ($this->imageset_keys as $category => $img_ary) 1331 { 1332 if (in_array($imgname, $img_ary)) 1333 { 1334 $valid_name = true; 1335 break; 1336 } 1337 } 1338 1339 if ($update && isset($_POST['imgpath'])) 1340 { 1341 if ($valid_name) 1342 { 1343 // If imgwidth and imgheight are non-zero grab the actual size 1344 // from the image itself ... we ignore width settings for the poll center image 1345 $imgwidth = request_var('imgwidth', 0); 1346 $imgheight = request_var('imgheight', 0); 1347 $imglang = ''; 1348 1349 if ($imgpath && !file_exists("{$phpbb_root_path}styles/$imageset_path/imageset/$imgpath")) 1350 { 1351 trigger_error($user->lang['NO_IMAGE_ERROR'] . adm_back_link($this->u_action), E_USER_WARNING); 1352 } 1353 1354 if ($imgsize && $imgpath) 1355 { 1356 if (!$imgwidth || !$imgheight) 1357 { 1358 list($imgwidth_file, $imgheight_file) = getimagesize("{$phpbb_root_path}styles/$imageset_path/imageset/$imgpath"); 1359 $imgwidth = ($imgwidth) ? $imgwidth : $imgwidth_file; 1360 $imgheight = ($imgheight) ? $imgheight : $imgheight_file; 1361 } 1362 $imgwidth = ($imgname != 'poll_center') ? (int) $imgwidth : 0; 1363 $imgheight = (int) $imgheight; 1364 } 1365 1366 1367 if (strpos($imgpath, '/') !== false) 1368 { 1369 list($imglang, $imgfilename) = explode('/', $imgpath); 1370 } 1371 else 1372 { 1373 $imgfilename = $imgpath; 1374 } 1375 1376 $sql_ary = array( 1377 'image_filename' => (string) $imgfilename, 1378 'image_width' => (int) $imgwidth, 1379 'image_height' => (int) $imgheight, 1380 'image_lang' => (string) $imglang, 1381 ); 1382 1383 // already exists 1384 if ($imageset_data_row) 1385 { 1386 $sql = 'UPDATE ' . STYLES_IMAGESET_DATA_TABLE . ' 1387 SET ' . $db->sql_build_array('UPDATE', $sql_ary) . " 1388 WHERE image_id = $image_id"; 1389 $db->sql_query($sql); 1390 } 1391 // does not exist 1392 else if (!$imageset_data_row) 1393 { 1394 $sql_ary['image_name'] = $imgname; 1395 $sql_ary['imageset_id'] = (int) $imageset_id; 1396 $db->sql_query('INSERT INTO ' . STYLES_IMAGESET_DATA_TABLE . ' ' . $db->sql_build_array('INSERT', $sql_ary)); 1397 } 1398 1399 $cache->destroy('sql', STYLES_IMAGESET_DATA_TABLE); 1400 1401 add_log('admin', 'LOG_IMAGESET_EDIT', $imageset_name); 1402 1403 $template->assign_var('SUCCESS', true); 1404 1405 $image_filename = $imgfilename; 1406 $image_width = $imgwidth; 1407 $image_height = $imgheight; 1408 $image_lang = $imglang; 1409 } 1410 } 1318 $sql_extra = $imgnamelang = ''; 1319 1320 $sql = 'SELECT imageset_path, imageset_name 1321 FROM ' . STYLES_IMAGESET_TABLE . " 1322 WHERE imageset_id = $imageset_id"; 1323 $result = $db->sql_query($sql); 1324 $imageset_row = $db->sql_fetchrow($result); 1325 $db->sql_freeresult($result); 1326 1327 if (!$imageset_row) 1328 { 1329 trigger_error($user->lang['NO_IMAGESET'] . adm_back_link($this->u_action), E_USER_WARNING); 1330 } 1331 1332 $imageset_path = $imageset_row['imageset_path']; 1333 $imageset_name = $imageset_row['imageset_name']; 1334 1335 if (strpos($imgname, '-') !== false) 1336 { 1337 list($imgname, $imgnamelang) = explode('-', $imgname); 1338 $sql_extra = " AND image_lang IN ('" . $db->sql_escape($imgnamelang) . "', '')"; 1339 } 1340 1341 $sql = 'SELECT image_filename, image_width, image_height, image_lang, image_id 1342 FROM ' . STYLES_IMAGESET_DATA_TABLE . " 1343 WHERE imageset_id = $imageset_id 1344 AND image_name = '" . $db->sql_escape($imgname) . "'$sql_extra"; 1345 $result = $db->sql_query($sql); 1346 $imageset_data_row = $db->sql_fetchrow($result); 1347 $db->sql_freeresult($result); 1348 1349 $image_filename = $imageset_data_row['image_filename']; 1350 $image_width = $imageset_data_row['image_width']; 1351 $image_height = $imageset_data_row['image_height']; 1352 $image_lang = $imageset_data_row['image_lang']; 1353 $image_id = $imageset_data_row['image_id']; 1354 $imgsize = ($imageset_data_row['image_width'] && $imageset_data_row['image_height']) ? 1 : 0; 1355 1356 // Check to see whether the selected image exists in the table 1357 $valid_name = ($update) ? false : true; 1358 1359 foreach ($this->imageset_keys as $category => $img_ary) 1360 { 1361 if (in_array($imgname, $img_ary)) 1362 { 1363 $valid_name = true; 1364 break; 1365 } 1366 } 1367 1368 if ($update && isset($_POST['imgpath']) && $valid_name) 1369 { 1370 // If imgwidth and imgheight are non-zero grab the actual size 1371 // from the image itself ... we ignore width settings for the poll center image 1372 $imgwidth = request_var('imgwidth', 0); 1373 $imgheight = request_var('imgheight', 0); 1374 $imgsize = request_var('imgsize', 0); 1375 $imgpath = request_var('imgpath', ''); 1376 $imgpath = str_replace('..', '.', $imgpath); 1377 1378 // If no dimensions selected, we reset width and height to 0 ;) 1379 if (!$imgsize) 1380 { 1381 $imgwidth = $imgheight = 0; 1382 } 1383 1384 $imglang = ''; 1385 1386 if ($imgpath && !file_exists("{$phpbb_root_path}styles/$imageset_path/imageset/$imgpath")) 1387 { 1388 trigger_error($user->lang['NO_IMAGE_ERROR'] . adm_back_link($this->u_action), E_USER_WARNING); 1389 } 1390 1391 // Determine width/height. If dimensions included and no width/height given, we detect them automatically... 1392 if ($imgsize && $imgpath) 1393 { 1394 if (!$imgwidth || !$imgheight) 1395 { 1396 list($imgwidth_file, $imgheight_file) = getimagesize("{$phpbb_root_path}styles/$imageset_path/imageset/$imgpath"); 1397 $imgwidth = ($imgwidth) ? $imgwidth : $imgwidth_file; 1398 $imgheight = ($imgheight) ? $imgheight : $imgheight_file; 1399 } 1400 $imgwidth = ($imgname != 'poll_center') ? (int) $imgwidth : 0; 1401 $imgheight = (int) $imgheight; 1402 } 1403 1404 if (strpos($imgpath, '/') !== false) 1405 { 1406 list($imglang, $imgfilename) = explode('/', $imgpath); 1407 } 1408 else 1409 { 1410 $imgfilename = $imgpath; 1411 } 1412 1413 $sql_ary = array( 1414 'image_filename' => (string) $imgfilename, 1415 'image_width' => (int) $imgwidth, 1416 'image_height' => (int) $imgheight, 1417 'image_lang' => (string) $imglang, 1418 ); 1419 1420 // already exists 1421 if ($imageset_data_row) 1422 { 1423 $sql = 'UPDATE ' . STYLES_IMAGESET_DATA_TABLE . ' 1424 SET ' . $db->sql_build_array('UPDATE', $sql_ary) . " 1425 WHERE image_id = $image_id"; 1426 $db->sql_query($sql); 1427 } 1428 // does not exist 1429 else if (!$imageset_data_row) 1430 { 1431 $sql_ary['image_name'] = $imgname; 1432 $sql_ary['imageset_id'] = (int) $imageset_id; 1433 $db->sql_query('INSERT INTO ' . STYLES_IMAGESET_DATA_TABLE . ' ' . $db->sql_build_array('INSERT', $sql_ary)); 1434 } 1435 1436 $cache->destroy('sql', STYLES_IMAGESET_DATA_TABLE); 1437 1438 add_log('admin', 'LOG_IMAGESET_EDIT', $imageset_name); 1439 1440 $template->assign_var('SUCCESS', true); 1441 1442 $image_filename = $imgfilename; 1443 $image_width = $imgwidth; 1444 $image_height = $imgheight; 1445 $image_lang = $imglang; 1411 1446 } 1412 1447 … … 1530 1565 'NAME' => $imageset_name, 1531 1566 'A_NAME' => addslashes($imageset_name), 1567 'PATH' => $imageset_path, 1568 'A_PATH' => addslashes($imageset_path), 1532 1569 'ERROR' => !$valid_name, 1533 1570 'IMG_SRC' => ($image_found) ? '../styles/' . $imageset_path . '/imageset/' . $img_val : 'images/no_image.png', … … 2396 2433 } 2397 2434 2398 2399 2435 if ($mode == 'template') 2400 2436 { … … 2527 2563 trigger_error("Could not open {$phpbb_root_path}styles/$template_path$pathfile$file", E_USER_ERROR); 2528 2564 } 2529 $template_data = fread($fp, filesize("{$phpbb_root_path}styles/$template_path$pathfile$file")); 2565 2566 $filesize = filesize("{$phpbb_root_path}styles/$template_path$pathfile$file"); 2567 2568 if ($filesize) 2569 { 2570 $template_data = fread($fp, $filesize); 2571 } 2572 2530 2573 fclose($fp); 2574 2575 if (!$filesize) 2576 { 2577 // File is empty 2578 continue; 2579 } 2531 2580 2532 2581 if (preg_match_all('#<!-- INCLUDE (.*?\.html) -->#is', $template_data, $matches)) … … 3196 3245 $db->sql_freeresult($result); 3197 3246 3198 3199 3247 if ($row) 3200 3248 { … … 3211 3259 if (isset($cfg_data['inherit_from']) && $cfg_data['inherit_from']) 3212 3260 { 3213 $sql = "SELECT {$mode}_id, {$mode}_name, {$mode}_path, {$mode}_storedb 3261 if ($mode === 'template') 3262 { 3263 $select_bf = ', bbcode_bitfield'; 3264 } 3265 else 3266 { 3267 $select_bf = ''; 3268 } 3269 3270 $sql = "SELECT {$mode}_id, {$mode}_name, {$mode}_path, {$mode}_storedb $select_bf 3214 3271 FROM $sql_from 3215 3272 WHERE {$mode}_name = '" . $db->sql_escape($cfg_data['inherit_from']) . "' … … 3226 3283 $inherit_id = $row["{$mode}_id"]; 3227 3284 $inherit_path = $row["{$mode}_path"]; 3285 $inherit_bf = ($mode === 'template') ? $row["bbcode_bitfield"] : false; 3228 3286 $cfg_data['store_db'] = $row["{$mode}_storedb"]; 3229 3287 $store_db = $row["{$mode}_storedb"]; … … 3234 3292 $inherit_id = 0; 3235 3293 $inherit_path = ''; 3236 }3237 3294 $inherit_bf = false; 3295 } 3238 3296 3239 3297 if (sizeof($error)) … … 3255 3313 { 3256 3314 $sql_ary['bbcode_bitfield'] = $cfg_data['template_bitfield']; 3315 } 3316 else if ($inherit_bf) 3317 { 3318 $sql_ary['bbcode_bitfield'] = $inherit_bf; 3257 3319 } 3258 3320 else … … 3502 3564 } 3503 3565 3504 3505 3566 $sql = "SELECT {$mode}_inherits_id 3506 3567 FROM $sql_from -
trunk/forum/includes/acp/acp_update.php
r400 r702 3 3 * 4 4 * @package acp 5 * @version $Id : acp_update.php 8479 2008-03-29 00:22:48Z naderman$5 * @version $Id$ 6 6 * @copyright (c) 2005 phpBB Group 7 7 * @license http://opensource.org/licenses/gpl-license.php GNU Public License … … 38 38 $errno = 0; 39 39 40 $info = get_remote_file('www.phpbb.com', '/updatecheck', ((defined('PHPBB_QA')) ? '30x_qa.txt' : '30x.txt'), $errstr, $errno);40 $info = obtain_latest_version_info(request_var('versioncheck_force', false), true); 41 41 42 42 if ($info === false) 43 43 { 44 trigger_error( $errstr, E_USER_WARNING);44 trigger_error('VERSIONCHECK_FAIL', E_USER_WARNING); 45 45 } 46 46 … … 49 49 50 50 $announcement_url = trim($info[1]); 51 $announcement_url = (strpos($announcement_url, '&') === false) ? str_replace('&', '&', $announcement_url) : $announcement_url; 51 52 $update_link = append_sid($phpbb_root_path . 'install/index.' . $phpEx, 'mode=update'); 52 53 … … 69 70 'S_VERSION_CHECK' => true, 70 71 'U_ACTION' => $this->u_action, 72 'U_VERSIONCHECK_FORCE' => append_sid($this->u_action . '&versioncheck_force=1'), 71 73 72 74 'LATEST_VERSION' => $latest_version, -
trunk/forum/includes/acp/acp_users.php
r400 r702 3 3 * 4 4 * @package acp 5 * @version $Id : acp_users.php 8831 2008-09-05 19:02:36Z toonarmy$5 * @version $Id$ 6 6 * @copyright (c) 2005 phpBB Group 7 7 * @license http://opensource.org/licenses/gpl-license.php GNU Public License … … 386 386 user_active_flip('flip', $user_id); 387 387 388 if ($user_row['user_type'] == USER_INACTIVE) 389 { 390 if ($config['require_activation'] == USER_ACTIVATION_ADMIN) 391 { 392 include_once($phpbb_root_path . 'includes/functions_messenger.' . $phpEx); 393 394 $messenger = new messenger(false); 395 396 $messenger->template('admin_welcome_activated', $user_row['user_lang']); 397 398 $messenger->to($user_row['user_email'], $user_row['username']); 399 400 $messenger->headers('X-AntiAbuse: Board servername - ' . $config['server_name']); 401 $messenger->headers('X-AntiAbuse: User_id - ' . $user->data['user_id']); 402 $messenger->headers('X-AntiAbuse: Username - ' . $user->data['username']); 403 $messenger->headers('X-AntiAbuse: User IP - ' . $user->ip); 404 405 $messenger->assign_vars(array( 406 'USERNAME' => htmlspecialchars_decode($user_row['username'])) 407 ); 408 409 $messenger->send(NOTIFY_EMAIL); 410 } 411 } 412 388 413 $message = ($user_row['user_type'] == USER_INACTIVE) ? 'USER_ADMIN_ACTIVATED' : 'USER_ADMIN_DEACTIVED'; 389 414 $log = ($user_row['user_type'] == USER_INACTIVE) ? 'LOG_USER_ACTIVE' : 'LOG_USER_INACTIVE'; … … 494 519 } 495 520 521 break; 522 523 case 'deloutbox': 524 525 if (confirm_box(true)) 526 { 527 $msg_ids = array(); 528 $lang = 'EMPTY'; 529 530 $sql = 'SELECT msg_id 531 FROM ' . PRIVMSGS_TO_TABLE . " 532 WHERE author_id = $user_id 533 AND folder_id = " . PRIVMSGS_OUTBOX; 534 $result = $db->sql_query($sql); 535 536 if ($row = $db->sql_fetchrow($result)) 537 { 538 if (!function_exists('delete_pm')) 539 { 540 include($phpbb_root_path . 'includes/functions_privmsgs.' . $phpEx); 541 } 542 543 do 544 { 545 $msg_ids[] = (int) $row['msg_id']; 546 } 547 while ($row = $db->sql_fetchrow($result)); 548 549 $db->sql_freeresult($result); 550 551 delete_pm($user_id, $msg_ids, PRIVMSGS_OUTBOX); 552 553 add_log('admin', 'LOG_USER_DEL_OUTBOX', $user_row['username']); 554 555 $lang = 'EMPTIED'; 556 } 557 $db->sql_freeresult($result); 558 559 trigger_error($user->lang['USER_OUTBOX_' . $lang] . adm_back_link($this->u_action . '&u=' . $user_id)); 560 } 561 else 562 { 563 confirm_box(false, $user->lang['CONFIRM_OPERATION'], build_hidden_fields(array( 564 'u' => $user_id, 565 'i' => $id, 566 'mode' => $mode, 567 'action' => $action, 568 'update' => true)) 569 ); 570 } 496 571 break; 497 572 … … 651 726 652 727 break; 728 729 case 'leave_nr': 730 731 if (confirm_box(true)) 732 { 733 remove_newly_registered($user_id, $user_row); 734 735 add_log('admin', 'LOG_USER_REMOVED_NR', $user_row['username']); 736 trigger_error($user->lang['USER_LIFTED_NR'] . adm_back_link($this->u_action . '&u=' . $user_id)); 737 } 738 else 739 { 740 confirm_box(false, $user->lang['CONFIRM_OPERATION'], build_hidden_fields(array( 741 'u' => $user_id, 742 'i' => $id, 743 'mode' => $mode, 744 'action' => $action, 745 'update' => true)) 746 ); 747 } 748 749 break; 653 750 } 654 751 … … 776 873 $sql_ary += array( 777 874 'user_email' => $update_email, 778 'user_email_hash' => crc32($update_email) . strlen($update_email)875 'user_email_hash' => phpbb_email_hash($update_email), 779 876 ); 780 877 … … 821 918 if ($user_id == $user->data['user_id']) 822 919 { 823 $quick_tool_ary = array('delsig' => 'DEL_SIG', 'delavatar' => 'DEL_AVATAR', 'moveposts' => 'MOVE_POSTS', 'delposts' => 'DEL_POSTS', 'delattach' => 'DEL_ATTACH'); 920 $quick_tool_ary = array('delsig' => 'DEL_SIG', 'delavatar' => 'DEL_AVATAR', 'moveposts' => 'MOVE_POSTS', 'delposts' => 'DEL_POSTS', 'delattach' => 'DEL_ATTACH', 'deloutbox' => 'DEL_OUTBOX'); 921 if ($user_row['user_new']) 922 { 923 $quick_tool_ary['leave_nr'] = 'LEAVE_NR'; 924 } 824 925 } 825 926 else … … 837 938 } 838 939 839 $quick_tool_ary += array('delsig' => 'DEL_SIG', 'delavatar' => 'DEL_AVATAR', 'moveposts' => 'MOVE_POSTS', 'delposts' => 'DEL_POSTS', 'delattach' => 'DEL_ATTACH' );940 $quick_tool_ary += array('delsig' => 'DEL_SIG', 'delavatar' => 'DEL_AVATAR', 'moveposts' => 'MOVE_POSTS', 'delposts' => 'DEL_POSTS', 'delattach' => 'DEL_ATTACH', 'deloutbox' => 'DEL_OUTBOX'); 840 941 841 942 if ($config['email_enable'] && ($user_row['user_type'] == USER_NORMAL || $user_row['user_type'] == USER_INACTIVE)) 842 943 { 843 944 $quick_tool_ary['reactivate'] = 'FORCE'; 945 } 946 947 if ($user_row['user_new']) 948 { 949 $quick_tool_ary['leave_nr'] = 'LEAVE_NR'; 844 950 } 845 951 } … … 918 1024 'U_MCP_QUEUE' => ($auth->acl_getf_global('m_approve')) ? append_sid("{$phpbb_root_path}mcp.$phpEx", 'i=queue', true, $user->session_id) : '', 919 1025 920 'U_SWITCH_PERMISSIONS' => ($auth->acl_get('a_switchperm') && $user->data['user_id'] != $user_row['user_id']) ? append_sid("{$phpbb_root_path}ucp.$phpEx", "mode=switch_perm&u={$user_row['user_id']} ") : '',1026 'U_SWITCH_PERMISSIONS' => ($auth->acl_get('a_switchperm') && $user->data['user_id'] != $user_row['user_id']) ? append_sid("{$phpbb_root_path}ucp.$phpEx", "mode=switch_perm&u={$user_row['user_id']}&hash=" . generate_link_hash('switchperm')) : '', 921 1027 922 1028 'POSTS_IN_QUEUE' => $user_row['posts_in_queue'], … … 973 1079 $sql = 'DELETE FROM ' . LOG_TABLE . ' 974 1080 WHERE log_type = ' . LOG_USERS . " 1081 AND reportee_id = $user_id 975 1082 $where_sql"; 976 1083 $db->sql_query($sql); … … 1032 1139 ); 1033 1140 } 1141 1142 break; 1143 1144 case 'warnings': 1145 $user->add_lang('mcp'); 1146 1147 // Set up general vars 1148 $start = request_var('start', 0); 1149 $deletemark = (isset($_POST['delmarked'])) ? true : false; 1150 $deleteall = (isset($_POST['delall'])) ? true : false; 1151 $confirm = (isset($_POST['confirm'])) ? true : false; 1152 $marked = request_var('mark', array(0)); 1153 $message = utf8_normalize_nfc(request_var('message', '', true)); 1154 1155 // Sort keys 1156 $sort_days = request_var('st', 0); 1157 $sort_key = request_var('sk', 't'); 1158 $sort_dir = request_var('sd', 'd'); 1159 1160 // Delete entries if requested and able 1161 if ($deletemark || $deleteall || $confirm) 1162 { 1163 if (confirm_box(true)) 1164 { 1165 $where_sql = ''; 1166 $deletemark = request_var('delmarked', 0); 1167 $deleteall = request_var('delall', 0); 1168 if ($deletemark && $marked) 1169 { 1170 $where_sql = ' AND ' . $db->sql_in_set('warning_id', array_values($marked)); 1171 } 1172 1173 if ($where_sql || $deleteall) 1174 { 1175 $sql = 'DELETE FROM ' . WARNINGS_TABLE . " 1176 WHERE user_id = $user_id 1177 $where_sql"; 1178 $db->sql_query($sql); 1179 1180 if ($deleteall) 1181 { 1182 $log_warnings = $deleted_warnings = 0; 1183 } 1184 else 1185 { 1186 $num_warnings = (int) $db->sql_affectedrows(); 1187 $deleted_warnings = ' user_warnings - ' . $num_warnings; 1188 $log_warnings = ($num_warnings > 2) ? 2 : $num_warnings; 1189 } 1190 1191 $sql = 'UPDATE ' . USERS_TABLE . " 1192 SET user_warnings = $deleted_warnings 1193 WHERE user_id = $user_id"; 1194 $db->sql_query($sql); 1195 1196 switch ($log_warnings) 1197 { 1198 case 2: 1199 add_log('admin', 'LOG_WARNINGS_DELETED', $user_row['username'], $num_warnings); 1200 break; 1201 case 1: 1202 add_log('admin', 'LOG_WARNING_DELETED', $user_row['username']); 1203 break; 1204 default: 1205 add_log('admin', 'LOG_WARNINGS_DELETED_ALL', $user_row['username']); 1206 break; 1207 } 1208 } 1209 } 1210 else 1211 { 1212 $s_hidden_fields = array( 1213 'i' => $id, 1214 'mode' => $mode, 1215 'u' => $user_id, 1216 'mark' => $marked, 1217 ); 1218 if (isset($_POST['delmarked'])) 1219 { 1220 $s_hidden_fields['delmarked'] = 1; 1221 } 1222 if (isset($_POST['delall'])) 1223 { 1224 $s_hidden_fields['delall'] = 1; 1225 } 1226 if (isset($_POST['delall']) || (isset($_POST['delmarked']) && sizeof($marked))) 1227 { 1228 confirm_box(false, $user->lang['CONFIRM_OPERATION'], build_hidden_fields($s_hidden_fields)); 1229 } 1230 } 1231 } 1232 1233 $sql = 'SELECT w.warning_id, w.warning_time, w.post_id, l.log_operation, l.log_data, l.user_id AS mod_user_id, m.username AS mod_username, m.user_colour AS mod_user_colour 1234 FROM ' . WARNINGS_TABLE . ' w 1235 LEFT JOIN ' . LOG_TABLE . ' l 1236 ON (w.log_id = l.log_id) 1237 LEFT JOIN ' . USERS_TABLE . ' m 1238 ON (l.user_id = m.user_id) 1239 WHERE w.user_id = ' . $user_id . ' 1240 ORDER BY w.warning_time DESC'; 1241 $result = $db->sql_query($sql); 1242 1243 while ($row = $db->sql_fetchrow($result)) 1244 { 1245 if (!$row['log_operation']) 1246 { 1247 // We do not have a log-entry anymore, so there is no data available 1248 $row['action'] = $user->lang['USER_WARNING_LOG_DELETED']; 1249 } 1250 else 1251 { 1252 $row['action'] = (isset($user->lang[$row['log_operation']])) ? $user->lang[$row['log_operation']] : '{' . ucfirst(str_replace('_', ' ', $row['log_operation'])) . '}'; 1253 if (!empty($row['log_data'])) 1254 { 1255 $log_data_ary = @unserialize($row['log_data']); 1256 $log_data_ary = ($log_data_ary === false) ? array() : $log_data_ary; 1257 1258 if (isset($user->lang[$row['log_operation']])) 1259 { 1260 // Check if there are more occurrences of % than arguments, if there are we fill out the arguments array 1261 // It doesn't matter if we add more arguments than placeholders 1262 if ((substr_count($row['action'], '%') - sizeof($log_data_ary)) > 0) 1263 { 1264 $log_data_ary = array_merge($log_data_ary, array_fill(0, substr_count($row['action'], '%') - sizeof($log_data_ary), '')); 1265 } 1266 $row['action'] = vsprintf($row['action'], $log_data_ary); 1267 $row['action'] = bbcode_nl2br(censor_text($row['action'])); 1268 } 1269 else if (!empty($log_data_ary)) 1270 { 1271 $row['action'] .= '<br />' . implode('', $log_data_ary); 1272 } 1273 } 1274 } 1275 1276 1277 $template->assign_block_vars('warn', array( 1278 'ID' => $row['warning_id'], 1279 'USERNAME' => ($row['log_operation']) ? get_username_string('full', $row['mod_user_id'], $row['mod_username'], $row['mod_user_colour']) : '-', 1280 'ACTION' => make_clickable($row['action']), 1281 'DATE' => $user->format_date($row['warning_time']), 1282 )); 1283 } 1284 $db->sql_freeresult($result); 1285 1286 $template->assign_vars(array( 1287 'S_WARNINGS' => true, 1288 )); 1034 1289 1035 1290 break; … … 1136 1391 1137 1392 // Update Custom Fields 1138 if (sizeof($cp_data)) 1139 { 1140 switch ($db->sql_layer) 1141 { 1142 case 'oracle': 1143 case 'firebird': 1144 case 'postgres': 1145 $right_delim = $left_delim = '"'; 1146 break; 1147 1148 case 'sqlite': 1149 case 'mssql': 1150 case 'mssql_odbc': 1151 $right_delim = ']'; 1152 $left_delim = '['; 1153 break; 1154 1155 case 'mysql': 1156 case 'mysql4': 1157 case 'mysqli': 1158 $right_delim = $left_delim = '`'; 1159 break; 1160 } 1161 1162 foreach ($cp_data as $key => $value) 1163 { 1164 $cp_data[$left_delim . $key . $right_delim] = $value; 1165 unset($cp_data[$key]); 1166 } 1167 1168 $sql = 'UPDATE ' . PROFILE_FIELDS_DATA_TABLE . ' 1169 SET ' . $db->sql_build_array('UPDATE', $cp_data) . " 1170 WHERE user_id = $user_id"; 1171 $db->sql_query($sql); 1172 1173 if (!$db->sql_affectedrows()) 1174 { 1175 $cp_data['user_id'] = (int) $user_id; 1176 1177 $db->sql_return_on_error(true); 1178 1179 $sql = 'INSERT INTO ' . PROFILE_FIELDS_DATA_TABLE . ' ' . $db->sql_build_array('INSERT', $cp_data); 1180 $db->sql_query($sql); 1181 1182 $db->sql_return_on_error(false); 1183 } 1184 } 1393 $cp->update_profile_field_data($user_id, $cp_data); 1185 1394 1186 1395 trigger_error($user->lang['USER_PROFILE_UPDATED'] . adm_back_link($this->u_action . '&u=' . $user_id)); … … 1208 1417 $now = getdate(); 1209 1418 $s_birthday_year_options = '<option value="0"' . ((!$data['bday_year']) ? ' selected="selected"' : '') . '>--</option>'; 1210 for ($i = $now['year'] - 100; $i < $now['year']; $i++)1419 for ($i = $now['year'] - 100; $i <= $now['year']; $i++) 1211 1420 { 1212 1421 $selected = ($i == $data['bday_year']) ? ' selected="selected"' : ''; … … 1475 1684 } 1476 1685 1686 if (!$config['allow_avatar'] && $user_row['user_avatar_type']) 1687 { 1688 $error[] = $user->lang['USER_AVATAR_NOT_ALLOWED']; 1689 } 1690 else if ((($user_row['user_avatar_type'] == AVATAR_UPLOAD) && !$config['allow_avatar_upload']) || 1691 (($user_row['user_avatar_type'] == AVATAR_REMOTE) && !$config['allow_avatar_remote']) || 1692 (($user_row['user_avatar_type'] == AVATAR_GALLERY) && !$config['allow_avatar_local'])) 1693 { 1694 $error[] = $user->lang['USER_AVATAR_TYPE_NOT_ALLOWED']; 1695 } 1696 1477 1697 // Generate users avatar 1478 $avatar_img = ($user_row['user_avatar']) ? get_user_avatar($user_row['user_avatar'], $user_row['user_avatar_type'], $user_row['user_avatar_width'], $user_row['user_avatar_height'] ) : '<img src="' . $phpbb_admin_path . 'images/no_avatar.gif" alt="" />';1698 $avatar_img = ($user_row['user_avatar']) ? get_user_avatar($user_row['user_avatar'], $user_row['user_avatar_type'], $user_row['user_avatar_width'], $user_row['user_avatar_height'], 'USER_AVATAR', true) : '<img src="' . $phpbb_admin_path . 'images/no_avatar.gif" alt="" />'; 1479 1699 1480 1700 $display_gallery = (isset($_POST['display_gallery'])) ? true : false; … … 1489 1709 $template->assign_vars(array( 1490 1710 'S_AVATAR' => true, 1491 'S_CAN_UPLOAD' => ($can_upload && $config['allow_avatar_upload']) ? true : false, 1492 'S_ALLOW_REMOTE' => ($config['allow_avatar_remote']) ? true : false, 1493 'S_DISPLAY_GALLERY' => ($config['allow_avatar_local'] && !$display_gallery) ? true : false, 1494 'S_IN_GALLERY' => ($config['allow_avatar_local'] && $display_gallery) ? true : false, 1711 'S_CAN_UPLOAD' => $can_upload, 1712 'S_UPLOAD_FILE' => ($config['allow_avatar'] && $can_upload && $config['allow_avatar_upload']) ? true : false, 1713 'S_REMOTE_UPLOAD' => ($config['allow_avatar'] && $can_upload && $config['allow_avatar_remote_upload']) ? true : false, 1714 'S_ALLOW_REMOTE' => ($config['allow_avatar'] && $config['allow_avatar_remote']) ? true : false, 1715 'S_DISPLAY_GALLERY' => ($config['allow_avatar'] && $config['allow_avatar_local'] && !$display_gallery) ? true : false, 1716 'S_IN_GALLERY' => ($config['allow_avatar'] && $config['allow_avatar_local'] && $display_gallery) ? true : false, 1495 1717 1496 1718 'AVATAR_IMAGE' => $avatar_img, … … 1550 1772 include_once($phpbb_root_path . 'includes/functions_display.' . $phpEx); 1551 1773 1552 $enable_bbcode = ($config['allow_sig_bbcode']) ? ( (request_var('disable_bbcode', !$user->optionget('bbcode'))) ? false : true) : false;1553 $enable_smilies = ($config['allow_sig_smilies']) ? ( (request_var('disable_smilies', !$user->optionget('smilies'))) ? false : true) : false;1554 $enable_urls = ($config['allow_sig_links']) ? ( (request_var('disable_magic_url', false)) ? false : true) : false;1774 $enable_bbcode = ($config['allow_sig_bbcode']) ? (bool) $this->optionget($user_row, 'sig_bbcode') : false; 1775 $enable_smilies = ($config['allow_sig_smilies']) ? (bool) $this->optionget($user_row, 'sig_smilies') : false; 1776 $enable_urls = ($config['allow_sig_links']) ? (bool) $this->optionget($user_row, 'sig_links') : false; 1555 1777 $signature = utf8_normalize_nfc(request_var('signature', (string) $user_row['user_sig'], true)); 1556 1778 … … 1560 1782 { 1561 1783 include_once($phpbb_root_path . 'includes/message_parser.' . $phpEx); 1784 1785 $enable_bbcode = ($config['allow_sig_bbcode']) ? ((request_var('disable_bbcode', false)) ? false : true) : false; 1786 $enable_smilies = ($config['allow_sig_smilies']) ? ((request_var('disable_smilies', false)) ? false : true) : false; 1787 $enable_urls = ($config['allow_sig_links']) ? ((request_var('disable_magic_url', false)) ? false : true) : false; 1562 1788 1563 1789 $message_parser = new parse_message($signature); … … 1578 1804 if (!sizeof($error) && $submit) 1579 1805 { 1806 $this->optionset($user_row, 'sig_bbcode', $enable_bbcode); 1807 $this->optionset($user_row, 'sig_smilies', $enable_smilies); 1808 $this->optionset($user_row, 'sig_links', $enable_urls); 1809 1580 1810 $sql_ary = array( 1581 1811 'user_sig' => (string) $message_parser->message, 1812 'user_options' => $user_row['user_options'], 1582 1813 'user_sig_bbcode_uid' => (string) $message_parser->bbcode_uid, 1583 1814 'user_sig_bbcode_bitfield' => (string) $message_parser->bbcode_bitfield … … 1847 2078 1848 2079 $error = array(); 2080 2081 // The delete action was successful - therefore update the user row... 2082 $sql = 'SELECT u.*, s.* 2083 FROM ' . USERS_TABLE . ' u 2084 LEFT JOIN ' . SESSIONS_TABLE . ' s ON (s.session_user_id = u.user_id) 2085 WHERE u.user_id = ' . $user_id . ' 2086 ORDER BY s.session_time DESC'; 2087 $result = $db->sql_query($sql); 2088 $user_row = $db->sql_fetchrow($result); 2089 $db->sql_freeresult($result); 1849 2090 } 1850 2091 else … … 1860 2101 1861 2102 break; 2103 2104 case 'approve': 2105 2106 if (confirm_box(true)) 2107 { 2108 if (!$group_id) 2109 { 2110 trigger_error($user->lang['NO_GROUP'] . adm_back_link($this->u_action . '&u=' . $user_id), E_USER_WARNING); 2111 } 2112 group_user_attributes($action, $group_id, $user_id); 2113 } 2114 else 2115 { 2116 confirm_box(false, $user->lang['CONFIRM_OPERATION'], build_hidden_fields(array( 2117 'u' => $user_id, 2118 'i' => $id, 2119 'mode' => $mode, 2120 'action' => $action, 2121 'g' => $group_id)) 2122 ); 2123 } 2124 2125 break; 1862 2126 } 1863 2127 … … 1952 2216 'U_DEMOTE_PROMOTE' => $this->u_action . '&action=' . (($data['group_leader']) ? 'demote' : 'promote') . "&u=$user_id&g=" . $data['group_id'], 1953 2217 'U_DELETE' => $this->u_action . "&action=delete&u=$user_id&g=" . $data['group_id'], 2218 'U_APPROVE' => ($group_type == 'pending') ? $this->u_action . "&action=approve&u=$user_id&g=" . $data['group_id'] : '', 1954 2219 1955 2220 'GROUP_NAME' => ($group_type == 'special') ? $user->lang['G_' . $data['group_name']] : $data['group_name'], 1956 2221 'L_DEMOTE_PROMOTE' => ($data['group_leader']) ? $user->lang['GROUP_DEMOTE'] : $user->lang['GROUP_PROMOTE'], 1957 2222 2223 'S_IS_MEMBER' => ($group_type != 'pending') ? true : false, 1958 2224 'S_NO_DEFAULT' => ($user_row['group_id'] != $data['group_id']) ? true : false, 1959 2225 'S_SPECIAL_GROUP' => ($group_type == 'special') ? true : false, -
trunk/forum/includes/acp/acp_words.php
r400 r702 3 3 * 4 4 * @package acp 5 * @version $Id : acp_words.php 8479 2008-03-29 00:22:48Z naderman$5 * @version $Id$ 6 6 * @copyright (c) 2005 phpBB Group 7 7 * @license http://opensource.org/licenses/gpl-license.php GNU Public License … … 24 24 { 25 25 var $u_action; 26 26 27 27 function main($id, $mode) 28 28 { … … 48 48 { 49 49 case 'edit': 50 50 51 $word_id = request_var('id', 0); 51 52 52 53 if (!$word_id) 53 54 { … … 74 75 'S_HIDDEN_FIELDS' => $s_hidden_fields) 75 76 ); 76 77 77 78 return; 78 79 … … 85 86 trigger_error($user->lang['FORM_INVALID']. adm_back_link($this->u_action), E_USER_WARNING); 86 87 } 88 87 89 $word_id = request_var('id', 0); 88 90 $word = utf8_normalize_nfc(request_var('word', '', true)); 89 91 $replacement = utf8_normalize_nfc(request_var('replacement', '', true)); 90 91 if ( !$word || !$replacement)92 93 if ($word === '' || $replacement === '') 92 94 { 93 95 trigger_error($user->lang['ENTER_WORD'] . adm_back_link($this->u_action), E_USER_WARNING); -
trunk/forum/includes/acp/auth.php
r400 r702 3 3 * 4 4 * @package phpBB3 5 * @version $Id : auth.php 8479 2008-03-29 00:22:48Z naderman$5 * @version $Id$ 6 6 * @copyright (c) 2005 phpBB Group 7 7 * @license http://opensource.org/licenses/gpl-license.php GNU Public License … … 59 59 } 60 60 } 61 61 62 62 /** 63 63 * Get permission mask … … 141 141 } 142 142 143 143 144 144 $hold_ary[$userdata['user_id']] = array(); 145 145 foreach ($forum_ids as $f_id) … … 346 346 // Build js roles array (role data assignments) 347 347 $s_role_js_array = ''; 348 348 349 349 if (sizeof($roles)) 350 350 { … … 697 697 $cur_options = array(); 698 698 699 // Determine current options 699 700 $sql = 'SELECT auth_option, is_global, is_local 700 701 FROM ' . ACL_OPTIONS_TABLE . ' … … 704 705 while ($row = $db->sql_fetchrow($result)) 705 706 { 706 if ($row['is_global']) 707 { 708 $cur_options['global'][] = $row['auth_option']; 709 } 710 711 if ($row['is_local']) 712 { 713 $cur_options['local'][] = $row['auth_option']; 714 } 707 $cur_options[$row['auth_option']] = ($row['is_global'] && $row['is_local']) ? 'both' : (($row['is_global']) ? 'global' : 'local'); 715 708 } 716 709 $db->sql_freeresult($result); … … 727 720 foreach ($option_ary as $option_value) 728 721 { 729 if (!in_array($option_value, $cur_options[$type])) 730 { 731 $new_options[$type][] = $option_value; 732 } 722 $new_options[$type][] = $option_value; 733 723 734 724 $flag = substr($option_value, 0, strpos($option_value, '_') + 1); 735 725 736 if (!in_array($flag, $ cur_options[$type]) && !in_array($flag, $new_options[$type]))726 if (!in_array($flag, $new_options[$type])) 737 727 { 738 728 $new_options[$type][] = $flag; … … 745 735 $options['local'] = array_diff($new_options['local'], $new_options['global']); 746 736 $options['global'] = array_diff($new_options['global'], $new_options['local']); 747 $options['local_global'] = array_intersect($new_options['local'], $new_options['global']); 748 749 $sql_ary = array(); 750 737 $options['both'] = array_intersect($new_options['local'], $new_options['global']); 738 739 // Now check which options to add/update 740 $add_options = $update_options = array(); 741 742 // First local ones... 751 743 foreach ($options as $type => $option_ary) 752 744 { 753 745 foreach ($option_ary as $option) 754 746 { 755 $sql_ary[] = array( 756 'auth_option' => (string) $option, 757 'is_global' => ($type == 'global' || $type == 'local_global') ? 1 : 0, 758 'is_local' => ($type == 'local' || $type == 'local_global') ? 1 : 0 759 ); 760 } 761 } 762 763 $db->sql_multi_insert(ACL_OPTIONS_TABLE, $sql_ary); 747 if (!isset($cur_options[$option])) 748 { 749 $add_options[] = array( 750 'auth_option' => (string) $option, 751 'is_global' => ($type == 'global' || $type == 'both') ? 1 : 0, 752 'is_local' => ($type == 'local' || $type == 'both') ? 1 : 0 753 ); 754 755 continue; 756 } 757 758 // Else, update existing entry if it is changed... 759 if ($type === $cur_options[$option]) 760 { 761 continue; 762 } 763 764 // New type is always both: 765 // If is now both, we set both. 766 // If it was global the new one is local and we need to set it to both 767 // If it was local the new one is global and we need to set it to both 768 $update_options[] = $option; 769 } 770 } 771 772 if (!empty($add_options)) 773 { 774 $db->sql_multi_insert(ACL_OPTIONS_TABLE, $add_options); 775 } 776 777 if (!empty($update_options)) 778 { 779 $sql = 'UPDATE ' . ACL_OPTIONS_TABLE . ' 780 SET is_global = 1, is_local = 1 781 WHERE ' . $db->sql_in_set('auth_option', $update_options); 782 $db->sql_query($sql); 783 } 764 784 765 785 $cache->destroy('_acl_options'); … … 803 823 $flag = key($auth); 804 824 $flag = substr($flag, 0, strpos($flag, '_') + 1); 805 825 806 826 // This ID (the any-flag) is set if one or more permissions are true... 807 827 $any_option_id = (int) $this->acl_options['id'][$flag]; … … 917 937 $flag = key($auth); 918 938 $flag = substr($flag, 0, strpos($flag, '_') + 1); 919 939 920 940 // Remove any-flag from auth ary 921 941 if (isset($auth[$flag])) … … 1068 1088 $where_sql[] = $db->sql_in_set('auth_option_id', array_map('intval', $option_id_ary)); 1069 1089 } 1070 1090 1071 1091 $sql = "DELETE FROM $table 1072 1092 WHERE " . implode(' AND ', $where_sql); … … 1091 1111 'S_NEVER' => ($cat_array['S_NEVER'] && !$cat_array['S_YES'] && !$cat_array['S_NO']) ? true : false, 1092 1112 'S_NO' => ($cat_array['S_NO'] && !$cat_array['S_NEVER'] && !$cat_array['S_YES']) ? true : false, 1093 1113 1094 1114 'CAT_NAME' => $user->lang['permission_cat'][$cat]) 1095 1115 ); … … 1180 1200 ); 1181 1201 } 1182 1202 1183 1203 $cat = $user->lang['acl_' . $permission]['cat']; 1184 1204 1185 1205 // Build our categories array 1186 1206 if (!isset($categories[$cat])) -
trunk/forum/includes/acp/info/acp_board.php
r400 r702 3 3 * 4 4 * @package acp 5 * @version $Id : acp_board.php 8479 2008-03-29 00:22:48Z naderman$5 * @version $Id$ 6 6 * @copyright (c) 2005 phpBB Group 7 7 * @license http://opensource.org/licenses/gpl-license.php GNU Public License … … 27 27 'post' => array('title' => 'ACP_POST_SETTINGS', 'auth' => 'acl_a_board', 'cat' => array('ACP_BOARD_CONFIGURATION')), 28 28 'signature' => array('title' => 'ACP_SIGNATURE_SETTINGS', 'auth' => 'acl_a_board', 'cat' => array('ACP_BOARD_CONFIGURATION')), 29 'feed' => array('title' => 'ACP_FEED_SETTINGS', 'auth' => 'acl_a_board', 'cat' => array('ACP_BOARD_CONFIGURATION')), 29 30 'registration' => array('title' => 'ACP_REGISTER_SETTINGS', 'auth' => 'acl_a_board', 'cat' => array('ACP_BOARD_CONFIGURATION')), 30 31 -
trunk/forum/includes/acp/info/acp_permissions.php
r400 r702 3 3 * 4 4 * @package acp 5 * @version $Id : acp_permissions.php 8479 2008-03-29 00:22:48Z naderman$5 * @version $Id$ 6 6 * @copyright (c) 2005 phpBB Group 7 7 * @license http://opensource.org/licenses/gpl-license.php GNU Public License … … 25 25 26 26 'setting_forum_local' => array('title' => 'ACP_FORUM_PERMISSIONS', 'auth' => 'acl_a_fauth && (acl_a_authusers || acl_a_authgroups)', 'cat' => array('ACP_FORUM_BASED_PERMISSIONS')), 27 'setting_forum_copy' => array('title' => 'ACP_FORUM_PERMISSIONS_COPY', 'auth' => 'acl_a_fauth && acl_a_authusers && acl_a_authgroups && acl_a_mauth', 'cat' => array('ACP_FORUM_BASED_PERMISSIONS')), 27 28 'setting_mod_local' => array('title' => 'ACP_FORUM_MODERATORS', 'auth' => 'acl_a_mauth && (acl_a_authusers || acl_a_authgroups)', 'cat' => array('ACP_FORUM_BASED_PERMISSIONS')), 28 29 'setting_user_global' => array('title' => 'ACP_USERS_PERMISSIONS', 'auth' => 'acl_a_authusers && (acl_a_aauth || acl_a_mauth || acl_a_uauth)', 'cat' => array('ACP_GLOBAL_PERMISSIONS', 'ACP_CAT_USERS')), -
trunk/forum/includes/acp/info/acp_users.php
r400 r702 3 3 * 4 4 * @package acp 5 * @version $Id : acp_users.php 8479 2008-03-29 00:22:48Z naderman$5 * @version $Id$ 6 6 * @copyright (c) 2005 phpBB Group 7 7 * @license http://opensource.org/licenses/gpl-license.php GNU Public License … … 23 23 'overview' => array('title' => 'ACP_MANAGE_USERS', 'auth' => 'acl_a_user', 'cat' => array('ACP_CAT_USERS')), 24 24 'feedback' => array('title' => 'ACP_USER_FEEDBACK', 'auth' => 'acl_a_user', 'display' => false, 'cat' => array('ACP_CAT_USERS')), 25 'warnings' => array('title' => 'ACP_USER_WARNINGS', 'auth' => 'acl_a_user', 'display' => false, 'cat' => array('ACP_CAT_USERS')), 25 26 'profile' => array('title' => 'ACP_USER_PROFILE', 'auth' => 'acl_a_user', 'display' => false, 'cat' => array('ACP_CAT_USERS')), 26 27 'prefs' => array('title' => 'ACP_USER_PREFS', 'auth' => 'acl_a_user', 'display' => false, 'cat' => array('ACP_CAT_USERS')), -
trunk/forum/includes/auth.php
r400 r702 3 3 * 4 4 * @package phpBB3 5 * @version $Id : auth.php 8985 2008-10-09 13:18:38Z acydburn$5 * @version $Id$ 6 6 * @copyright (c) 2005 phpBB Group 7 7 * @license http://opensource.org/licenses/gpl-license.php GNU Public License … … 65 65 66 66 $cache->put('_acl_options', $this->acl_options); 67 $this->acl_cache($userdata);68 } 69 elseif (!trim($userdata['user_permissions']))67 } 68 69 if (!trim($userdata['user_permissions'])) 70 70 { 71 71 $this->acl_cache($userdata); … … 609 609 // Now grab group settings - non-role specific... 610 610 $sql_ary[] = 'SELECT ug.user_id, a.forum_id, a.auth_setting, a.auth_option_id' . $sql_opts_select . ' 611 FROM ' . ACL_GROUPS_TABLE . ' a, ' . USER_GROUP_TABLE . ' ug ' . $sql_opts_from . '611 FROM ' . ACL_GROUPS_TABLE . ' a, ' . USER_GROUP_TABLE . ' ug, ' . GROUPS_TABLE . ' g' . $sql_opts_from . ' 612 612 WHERE a.auth_role_id = 0 ' . 613 613 (($sql_opts_from) ? 'AND a.auth_option_id = ao.auth_option_id ' : '') . ' 614 614 AND a.group_id = ug.group_id 615 AND g.group_id = ug.group_id 615 616 AND ug.user_pending = 0 617 AND NOT (ug.group_leader = 1 AND g.group_skip_auth = 1) 616 618 ' . (($sql_user) ? 'AND ug.' . $sql_user : '') . " 617 619 $sql_forum … … 620 622 // Now grab group settings - role specific... 621 623 $sql_ary[] = 'SELECT ug.user_id, a.forum_id, r.auth_setting, r.auth_option_id' . $sql_opts_select . ' 622 FROM ' . ACL_GROUPS_TABLE . ' a, ' . USER_GROUP_TABLE . ' ug, ' . ACL_ROLES_DATA_TABLE . ' r' . $sql_opts_from . '624 FROM ' . ACL_GROUPS_TABLE . ' a, ' . USER_GROUP_TABLE . ' ug, ' . GROUPS_TABLE . ' g, ' . ACL_ROLES_DATA_TABLE . ' r' . $sql_opts_from . ' 623 625 WHERE a.auth_role_id = r.role_id ' . 624 626 (($sql_opts_from) ? 'AND r.auth_option_id = ao.auth_option_id ' : '') . ' 625 627 AND a.group_id = ug.group_id 628 AND g.group_id = ug.group_id 626 629 AND ug.user_pending = 0 630 AND NOT (ug.group_leader = 1 AND g.group_skip_auth = 1) 627 631 ' . (($sql_user) ? 'AND ug.' . $sql_user : '') . " 628 632 $sql_forum … … 826 830 // Now grab group-specific permission settings 827 831 $sql = 'SELECT a.forum_id, a.auth_option_id, a.auth_role_id, a.auth_setting 828 FROM ' . ACL_GROUPS_TABLE . ' a, ' . USER_GROUP_TABLE . ' ug 832 FROM ' . ACL_GROUPS_TABLE . ' a, ' . USER_GROUP_TABLE . ' ug, ' . GROUPS_TABLE . ' g 829 833 WHERE a.group_id = ug.group_id 834 AND g.group_id = ug.group_id 830 835 AND ug.user_pending = 0 836 AND NOT (ug.group_leader = 1 AND g.group_skip_auth = 1) 831 837 AND ug.user_id = ' . $user_id; 832 838 $result = $db->sql_query($sql); -
trunk/forum/includes/auth/auth_apache.php
r400 r702 6 6 * 7 7 * @package login 8 * @version $Id : auth_apache.php 8602 2008-06-04 16:05:27Z naderman$8 * @version $Id$ 9 9 * @copyright (c) 2005 phpBB Group 10 10 * @license http://opensource.org/licenses/gpl-license.php GNU Public License … … 105 105 ); 106 106 } 107 107 108 108 // Successful login... 109 109 return array( … … 218 218 'user_type' => USER_NORMAL, 219 219 'user_ip' => $user->ip, 220 'user_new' => ($config['new_member_post_limit']) ? 1 : 0, 220 221 ); 221 222 } … … 228 229 function validate_session_apache(&$user) 229 230 { 230 if (!isset($_SERVER['PHP_AUTH_USER'])) 231 { 232 return false; 233 } 234 235 $php_auth_user = ''; 236 set_var($php_auth_user, $_SERVER['PHP_AUTH_USER'], 'string', true); 237 238 return ($php_auth_user === $user['username']) ? true : false; 231 // Check if PHP_AUTH_USER is set and handle this case 232 if (isset($_SERVER['PHP_AUTH_USER'])) 233 { 234 $php_auth_user = ''; 235 set_var($php_auth_user, $_SERVER['PHP_AUTH_USER'], 'string', true); 236 237 return ($php_auth_user === $user['username']) ? true : false; 238 } 239 240 // PHP_AUTH_USER is not set. A valid session is now determined by the user type (anonymous/bot or not) 241 if ($user['user_type'] == USER_IGNORE) 242 { 243 return true; 244 } 245 246 return false; 239 247 } 240 248 -
trunk/forum/includes/auth/auth_db.php
r400 r702 8 8 * 9 9 * @package login 10 * @version $Id : auth_db.php 8479 2008-03-29 00:22:48Z naderman$10 * @version $Id$ 11 11 * @copyright (c) 2005 phpBB Group 12 12 * @license http://opensource.org/licenses/gpl-license.php GNU Public License … … 63 63 ); 64 64 } 65 $show_captcha = $config['max_login_attempts'] && $row['user_login_attempts'] >= $config['max_login_attempts']; 65 66 66 67 // If there are too much login attempts, we need to check for an confirm image 67 68 // Every auth module is able to define what to do by itself... 68 if ($config['max_login_attempts'] && $row['user_login_attempts'] >= $config['max_login_attempts']) 69 { 70 $confirm_id = request_var('confirm_id', ''); 71 $confirm_code = request_var('confirm_code', ''); 72 69 if ($show_captcha) 70 { 73 71 // Visual Confirmation handling 74 if (!$confirm_id) 72 if (!class_exists('phpbb_captcha_factory')) 73 { 74 global $phpbb_root_path, $phpEx; 75 include ($phpbb_root_path . 'includes/captcha/captcha_factory.' . $phpEx); 76 } 77 78 $captcha =& phpbb_captcha_factory::get_instance($config['captcha_plugin']); 79 $captcha->init(CONFIRM_LOGIN); 80 $vc_response = $captcha->validate($row); 81 if ($vc_response) 75 82 { 76 83 return array( … … 82 89 else 83 90 { 84 global $user; 85 86 $sql = 'SELECT code 87 FROM ' . CONFIRM_TABLE . " 88 WHERE confirm_id = '" . $db->sql_escape($confirm_id) . "' 89 AND session_id = '" . $db->sql_escape($user->session_id) . "' 90 AND confirm_type = " . CONFIRM_LOGIN; 91 $result = $db->sql_query($sql); 92 $confirm_row = $db->sql_fetchrow($result); 93 $db->sql_freeresult($result); 94 95 if ($confirm_row) 96 { 97 if (strcasecmp($confirm_row['code'], $confirm_code) === 0) 98 { 99 $sql = 'DELETE FROM ' . CONFIRM_TABLE . " 100 WHERE confirm_id = '" . $db->sql_escape($confirm_id) . "' 101 AND session_id = '" . $db->sql_escape($user->session_id) . "' 102 AND confirm_type = " . CONFIRM_LOGIN; 103 $db->sql_query($sql); 104 } 105 else 106 { 107 return array( 108 'status' => LOGIN_ERROR_ATTEMPTS, 109 'error_msg' => 'CONFIRM_CODE_WRONG', 110 'user_row' => $row, 111 ); 112 } 113 } 114 else 115 { 116 return array( 117 'status' => LOGIN_ERROR_ATTEMPTS, 118 'error_msg' => 'CONFIRM_CODE_WRONG', 119 'user_row' => $row, 120 ); 121 } 122 } 91 $captcha->reset(); 92 } 93 123 94 } 124 95 … … 142 113 143 114 // cp1252 is phpBB2's default encoding, characters outside ASCII range might work when converted into that encoding 144 if (md5($password_old_format) == $row['user_password'] || md5(utf8_to_cp1252($password_old_format)) == $row['user_password']) 115 // plain md5 support left in for conversions from other systems. 116 if ((strlen($row['user_password']) == 34 && (phpbb_check_hash(md5($password_old_format), $row['user_password']) || phpbb_check_hash(md5(utf8_to_cp1252($password_old_format)), $row['user_password']))) 117 || (strlen($row['user_password']) == 32 && (md5($password_old_format) == $row['user_password'] || md5(utf8_to_cp1252($password_old_format)) == $row['user_password']))) 145 118 { 146 119 $hash = phpbb_hash($password_new_format); … … 227 200 // Give status about wrong password... 228 201 return array( 229 'status' => LOGIN_ERROR_PASSWORD,230 'error_msg' => 'LOGIN_ERROR_PASSWORD',202 'status' => ($show_captcha) ? LOGIN_ERROR_ATTEMPTS : LOGIN_ERROR_PASSWORD, 203 'error_msg' => ($show_captcha) ? 'LOGIN_ERROR_ATTEMPTS' : 'LOGIN_ERROR_PASSWORD', 231 204 'user_row' => $row, 232 205 ); -
trunk/forum/includes/auth/auth_ldap.php
r400 r702 7 7 * 8 8 * @package login 9 * @version $Id : auth_ldap.php 8479 2008-03-29 00:22:48Z naderman$9 * @version $Id$ 10 10 * @copyright (c) 2005 phpBB Group 11 11 * @license http://opensource.org/licenses/gpl-license.php GNU Public License … … 64 64 $search = @ldap_search( 65 65 $ldap, 66 $config['ldap_base_dn'],66 htmlspecialchars_decode($config['ldap_base_dn']), 67 67 ldap_user_filter($user->data['username']), 68 (empty($config['ldap_email'])) ? array($config['ldap_uid']) : array($config['ldap_uid'], $config['ldap_email']), 68 (empty($config['ldap_email'])) ? 69 array(htmlspecialchars_decode($config['ldap_uid'])) : 70 array(htmlspecialchars_decode($config['ldap_uid']), htmlspecialchars_decode($config['ldap_email'])), 69 71 0, 70 72 1 … … 86 88 } 87 89 88 if (!empty($config['ldap_email']) && !isset($result[0][ $config['ldap_email']]))90 if (!empty($config['ldap_email']) && !isset($result[0][htmlspecialchars_decode($config['ldap_email'])])) 89 91 { 90 92 return $user->lang['LDAP_NO_EMAIL']; … … 153 155 if ($config['ldap_user'] || $config['ldap_password']) 154 156 { 155 if (!@ldap_bind($ldap, $config['ldap_user'], htmlspecialchars_decode($config['ldap_password'])))157 if (!@ldap_bind($ldap, htmlspecialchars_decode($config['ldap_user']), htmlspecialchars_decode($config['ldap_password']))) 156 158 { 157 159 return $user->lang['LDAP_NO_SERVER_CONNECTION']; … … 161 163 $search = @ldap_search( 162 164 $ldap, 163 $config['ldap_base_dn'],165 htmlspecialchars_decode($config['ldap_base_dn']), 164 166 ldap_user_filter($username), 165 (empty($config['ldap_email'])) ? array($config['ldap_uid']) : array($config['ldap_uid'], $config['ldap_email']), 167 (empty($config['ldap_email'])) ? 168 array(htmlspecialchars_decode($config['ldap_uid'])) : 169 array(htmlspecialchars_decode($config['ldap_uid']), htmlspecialchars_decode($config['ldap_email'])), 166 170 0, 167 171 1 … … 224 228 'username' => $username, 225 229 'user_password' => phpbb_hash($password), 226 'user_email' => (!empty($config['ldap_email'])) ? $ldap_result[0][$config['ldap_email']][0]: '',230 'user_email' => (!empty($config['ldap_email'])) ? utf8_htmlspecialchars($ldap_result[0][htmlspecialchars_decode($config['ldap_email'])][0]) : '', 227 231 'group_id' => (int) $row['group_id'], 228 232 'user_type' => USER_NORMAL, 229 233 'user_ip' => $user->ip, 234 'user_new' => ($config['new_member_post_limit']) ? 1 : 0, 230 235 ); 231 236 … … 277 282 if ($config['ldap_user_filter']) 278 283 { 279 $filter = "(&$filter({$config['ldap_user_filter']}))"; 284 $_filter = ($config['ldap_user_filter'][0] == '(' && substr($config['ldap_user_filter'], -1) == ')') ? $config['ldap_user_filter'] : "({$config['ldap_user_filter']})"; 285 $filter = "(&{$filter}{$_filter})"; 280 286 } 281 287 return $filter; -
trunk/forum/includes/bbcode.php
r400 r702 3 3 * 4 4 * @package phpBB3 5 * @version $Id : bbcode.php 8953 2008-09-28 17:08:09Z acydburn$5 * @version $Id$ 6 6 * @copyright (c) 2005 phpBB Group 7 7 * @license http://opensource.org/licenses/gpl-license.php GNU Public License … … 129 129 function bbcode_cache_init() 130 130 { 131 global $ user, $phpbb_root_path;131 global $phpbb_root_path, $template, $user; 132 132 133 133 if (empty($this->template_filename)) … … 135 135 $this->template_bitfield = new bitfield($user->theme['bbcode_bitfield']); 136 136 $this->template_filename = $phpbb_root_path . 'styles/' . $user->theme['template_path'] . '/template/bbcode.html'; 137 137 138 138 if (!@file_exists($this->template_filename)) 139 139 { … … 266 266 $this->bbcode_cache[$bbcode_id] = array( 267 267 'preg' => array( 268 '!\[color=(#[0-9a-f]{ 6}|[a-z\-]+):$uid\](.*?)\[/color:$uid\]!is' => $this->bbcode_tpl('color', $bbcode_id),268 '!\[color=(#[0-9a-f]{3}|#[0-9a-f]{6}|[a-z\-]+):$uid\](.*?)\[/color:$uid\]!is' => $this->bbcode_tpl('color', $bbcode_id), 269 269 ) 270 270 ); … … 361 361 // to replace all {VARS} to corresponding backreferences 362 362 // Note that backreferences are numbered from bbcode_match 363 if (preg_match_all('/\{(URL|LOCAL_URL|EMAIL|TEXT|SIMPLETEXT|I DENTIFIER|COLOR|NUMBER)[0-9]*\}/', $rowset[$bbcode_id]['bbcode_match'], $m))363 if (preg_match_all('/\{(URL|LOCAL_URL|EMAIL|TEXT|SIMPLETEXT|INTTEXT|IDENTIFIER|COLOR|NUMBER)[0-9]*\}/', $rowset[$bbcode_id]['bbcode_match'], $m)) 364 364 { 365 365 foreach ($m[0] as $i => $tok) … … 411 411 { 412 412 global $user; 413 413 414 414 $bbcode_hardtpl = array( 415 415 'b_open' => '<span style="font-weight: bold">', … … 529 529 { 530 530 $tpl = 'olist_open'; 531 $type = ' arabic-numbers';531 $type = 'decimal'; 532 532 } 533 533 else 534 534 { 535 535 $tpl = 'olist_open'; 536 $type = ' arabic-numbers';536 $type = 'decimal'; 537 537 } 538 538 -
trunk/forum/includes/cache.php
r400 r702 3 3 * 4 4 * @package acm 5 * @version $Id : cache.php 8691 2008-07-28 13:26:20Z acydburn$5 * @version $Id$ 6 6 * @copyright (c) 2005 phpBB Group 7 7 * @license http://opensource.org/licenses/gpl-license.php GNU Public License … … 85 85 while ($row = $db->sql_fetchrow($result)) 86 86 { 87 $censors['match'][] = '#(?<!\w)(' . str_replace('\*', '\w*?', preg_quote($row['word'], '#')) . ')(?!\w)#i'; 87 if ((version_compare(PHP_VERSION, '5.1.0', '>=') || (version_compare(PHP_VERSION, '5.0.0-dev', '<=') && version_compare(PHP_VERSION, '4.4.0', '>='))) && @preg_match('/\p{L}/u', 'a') !== false) 88 { 89 $censors['match'][] = '#(?<![\p{Nd}\p{L}_])(' . str_replace('\*', '[\p{Nd}\p{L}_]*?', preg_quote($row['word'], '#')) . ')(?![\p{Nd}\p{L}_])#iu'; 90 } 91 else 92 { 93 $censors['match'][] = '#(?<!\S)(' . str_replace('\*', '\S*?', preg_quote($row['word'], '#')) . ')(?!\S)#iu'; 94 } 95 88 96 $censors['replace'][] = $row['replacement']; 89 97 } -
trunk/forum/includes/captcha/captcha_gd.php
r400 r702 3 3 * 4 4 * @package VC 5 * @version $Id : captcha_gd.php 8479 2008-03-29 00:22:48Z naderman$5 * @version $Id$ 6 6 * @copyright (c) 2006 phpBB Group 7 7 * @license http://opensource.org/licenses/gpl-license.php GNU Public License … … 28 28 var $height = 96; 29 29 30 30 31 /** 31 32 * Create the image containing $code with a seed of $seed … … 34 35 { 35 36 global $config; 36 srand($seed);37 37 38 mt_srand($seed); 38 39 … … 53 54 54 55 // Generate code characters 55 $characters = $sizes = $bounding_boxes = array();56 $characters = $sizes = $bounding_boxes = $noise = array(); 56 57 $width_avail = $this->width - 15; 57 58 $code_len = strlen($code); 58 59 59 $captcha_bitmaps = $this->captcha_bitmaps(); 60 60 61 for ($i = 0; $i < $code_len; ++$i) 61 62 { … … 70 71 } 71 72 73 72 74 // Redistribute leftover x-space 73 75 $offset = array(); … … 99 101 } 100 102 } 101 103 if ($config['captcha_gd_wave'] && ($config['captcha_gd_y_grid'] || $config['captcha_gd_y_grid'])) 104 { 105 $this->wave($img); 106 } 107 108 109 if ($config['captcha_gd_3d_noise']) 110 { 111 $xoffset = mt_rand(0,9); 112 $noise_bitmaps = $this->captcha_noise_bg_bitmaps(); 113 for ($i = 0; $i < $code_len; ++$i) 114 { 115 $noise[$i] = new char_cube3d($noise_bitmaps, mt_rand(1, count($noise_bitmaps['data']))); 116 117 list($min, $max) = $noise[$i]->range(); 118 //$box = $noise[$i]->dimensions($sizes[$i]); 119 } 120 $xoffset = 0; 121 for ($i = 0; $i < $code_len; ++$i) 122 { 123 $dimm = $bounding_boxes[$i]; 124 $xoffset += ($offset[$i] - $dimm[0]); 125 $yoffset = mt_rand(-$dimm[1], $this->height - $dimm[3]); 126 127 $noise[$i]->drawchar($sizes[$i], $xoffset, $yoffset, $img, $colour->get_resource('background'), $scheme); 128 $xoffset += $dimm[2]; 129 } 130 } 102 131 $xoffset = 5; 103 132 for ($i = 0; $i < $code_len; ++$i) … … 110 139 $xoffset += $dimm[2]; 111 140 } 112 141 if ($config['captcha_gd_wave']) 142 { 143 $this->wave($img); 144 } 113 145 if ($config['captcha_gd_foreground_noise']) 114 146 { 115 147 $this->noise_line($img, 0, 0, $this->width, $this->height, $colour->get_resource('background'), $scheme, $bg_colours); 116 148 } 117 118 149 // Send image 119 150 header('Content-Type: image/png'); … … 124 155 125 156 /** 157 * Sinus 158 */ 159 function wave($img) 160 { 161 global $config; 162 163 $period_x = mt_rand(12,18); 164 $period_y = mt_rand(7,14); 165 $amp_x = mt_rand(5,10); 166 $amp_y = mt_rand(2,4); 167 $socket = mt_rand(0,100); 168 169 $dampen_x = mt_rand($this->width/5, $this->width/2); 170 $dampen_y = mt_rand($this->height/5, $this->height/2); 171 $direction_x = (mt_rand (0, 1)); 172 $direction_y = (mt_rand (0, 1)); 173 174 for ($i = 0; $i < $this->width; $i++) 175 { 176 $dir = ($direction_x) ? $i : ($this->width - $i); 177 imagecopy($img, $img, $i-1, sin($socket+ $i/($period_x + $dir/$dampen_x)) * $amp_x, $i, 0, 1, $this->height); 178 } 179 $socket = mt_rand(0,100); 180 for ($i = 0; $i < $this->height; $i++) 181 { 182 $dir = ($direction_y) ? $i : ($this->height - $i); 183 imagecopy($img, $img ,sin($socket + $i/($period_y + ($dir)/$dampen_y)) * $amp_y, $i-1, 0, $i, $this->width, 1); 184 } 185 return $img; 186 } 187 188 /** 126 189 * Noise line 127 190 */ … … 172 235 } 173 236 237 238 function captcha_noise_bg_bitmaps() 239 { 240 return array( 241 'width' => 15, 242 'height' => 5, 243 'data' => array( 244 245 1 => array( 246 array(1,0,0,0,1,0,0,0,0,0,0,0,0,0,0), 247 array(1,0,0,0,0,1,0,0,0,0,0,0,0,0,0), 248 array(1,0,0,0,0,0,0,0,0,0,0,0,0,0,0), 249 array(1,0,0,0,0,1,0,0,0,0,0,0,1,0,0), 250 array(1,0,0,0,0,0,1,0,0,0,0,1,0,0,0), 251 ), 252 2 => array( 253 array(1,1,mt_rand(0,1),1,0,1,1,1,1,0,0,0,0,0,0), 254 array(0,0,0,0,0,0,0,1,0,0,0,0,0,0,0), 255 array(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0), 256 array(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0), 257 array(0,0,0,0,0,0,0,0,0,1,1,0,1,1,1), 258 ), 259 3 => array( 260 array(1,0,0,0,0,0,0,0,0,0,0,0,0,0,1), 261 array(1,0,0,0,0,0,0,0,0,0,0,0,0,1,0), 262 array(0,0,0,0,1,0,0,0,0,0,0,0,0,0,1), 263 array(1,0,0,0,0,0,0,0,0,0,0,0,0,1,0), 264 array(1,0,0,0,0,0,0,0,0,0,0,0,0,0,1), 265 ), 266 4 => array( 267 array(1,0,1,0,1,0,0,1,1,0,0,0,0,0,0), 268 array(0,0,0,0,0,0,0,1,0,0,0,0,0,0,0), 269 array(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0), 270 array(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0), 271 array(1,0,1,0,0,0,0,0,0,0,0,0,0,0,0), 272 ), 273 5 => array( 274 array(1,1,1,1,0,0,0,1,1,1,0,0,1,0,1), 275 array(0,0,0,0,0,0,0,1,0,0,0,0,0,0,0), 276 array(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0), 277 array(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0), 278 array(1,0,1,0,0,0,0,0,0,0,0,0,0,0,0), 279 ), 280 6 => array( 281 array(mt_rand(0,1),mt_rand(0,1),mt_rand(0,1),mt_rand(0,1),mt_rand(0,1),0,mt_rand(0,1),mt_rand(0,1),mt_rand(0,1),mt_rand(0,1),mt_rand(0,1),0,mt_rand(0,1),mt_rand(0,1),mt_rand(0,1)), 282 array(0,0,0,0,0,0,0,mt_rand(0,1),0,0,0,0,0,0,0), 283 array(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0), 284 array(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0), 285 array(mt_rand(0,1),0,mt_rand(0,1),0,0,0,0,0,0,0,0,0,0,0,0), 286 ), 287 7 => array( 288 array(0,0,0,0,0,0,0,0,0,0,1,1,0,1,1), 289 array(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0), 290 array(0,0,1,1,0,0,0,1,0,0,0,0,0,0,0), 291 array(0,1,0,0,0,1,0,0,0,0,0,0,0,0,0), 292 array(1,0,0,0,0,0,0,0,0,0,0,0,0,0,0), 293 ), 294 )); 295 } 296 174 297 /** 175 298 * Return bitmaps … … 177 300 function captcha_bitmaps() 178 301 { 302 global $config; 303 304 $chars = array( 305 'A' => array( 306 array( 307 array(0,0,0,0,1,0,0,0,0), 308 array(0,0,0,1,0,1,0,0,0), 309 array(0,0,0,1,0,1,0,0,0), 310 array(0,0,0,1,0,1,0,0,0), 311 array(0,0,1,0,0,0,1,0,0), 312 array(0,0,1,0,0,0,1,0,0), 313 array(0,0,1,0,0,0,1,0,0), 314 array(0,1,0,0,0,0,0,1,0), 315 array(0,1,0,0,0,0,0,1,0), 316 array(0,1,1,1,1,1,1,1,0), 317 array(0,1,0,0,0,0,0,1,0), 318 array(1,0,0,0,0,0,0,0,1), 319 array(1,0,0,0,0,0,0,0,1), 320 array(1,0,0,0,0,0,0,0,1), 321 array(1,0,0,0,0,0,0,0,1), 322 ), 323 array( 324 array(0,0,0,0,0,0,0,0,0), 325 array(0,0,0,0,0,0,0,0,0), 326 array(0,0,0,0,1,0,0,0,0), 327 array(0,0,0,1,0,1,0,0,0), 328 array(0,0,1,1,0,1,1,0,0), 329 array(0,0,1,0,0,0,1,0,0), 330 array(0,1,0,0,0,0,0,1,0), 331 array(0,1,0,0,0,0,0,1,0), 332 array(0,1,1,1,1,1,1,1,0), 333 array(0,1,0,0,0,0,0,1,0), 334 array(0,1,0,0,0,0,0,1,0), 335 array(0,1,0,0,0,0,0,1,0), 336 array(0,1,0,0,0,0,0,1,0), 337 array(0,1,0,0,0,0,0,1,0), 338 array(1,1,1,0,0,0,1,1,1), 339 ), 340 array( 341 array(0,0,0,0,0,0,0,0,0), 342 array(0,0,0,0,0,0,0,0,0), 343 array(0,0,0,0,0,0,0,0,0), 344 array(0,0,0,0,0,0,0,0,0), 345 array(0,0,1,1,1,1,1,0,0), 346 array(0,1,1,0,0,0,1,1,0), 347 array(1,1,0,0,0,0,0,1,1), 348 array(1,0,0,0,0,0,0,0,1), 349 array(0,0,0,0,0,0,0,1,1), 350 array(0,0,0,0,0,1,1,1,1), 351 array(0,0,0,1,1,1,0,0,1), 352 array(0,1,1,1,0,0,0,0,1), 353 array(1,0,0,0,0,0,0,0,1), 354 array(1,1,0,0,0,0,1,1,1), 355 array(0,1,1,1,1,1,1,0,1), 356 ), 357 ), 358 'B' => array( 359 array( 360 array(1,1,1,1,1,1,1,0,0), 361 array(1,0,0,0,0,0,0,1,0), 362 array(1,0,0,0,0,0,0,0,1), 363 array(1,0,0,0,0,0,0,0,1), 364 array(1,0,0,0,0,0,0,0,1), 365 array(1,0,0,0,0,0,0,0,1), 366 array(1,0,0,0,0,0,0,1,0), 367 array(1,1,1,1,1,1,1,0,0), 368 array(1,0,0,0,0,0,0,1,0), 369 array(1,0,0,0,0,0,0,0,1), 370 array(1,0,0,0,0,0,0,0,1), 371 array(1,0,0,0,0,0,0,0,1), 372 array(1,0,0,0,0,0,0,0,1), 373 array(1,0,0,0,0,0,0,1,0), 374 array(1,1,1,1,1,1,1,0,0), 375 ), 376 array( 377 array(1,1,1,1,1,1,1,0,0), 378 array(0,1,0,0,0,0,0,1,0), 379 array(0,1,0,0,0,0,0,0,1), 380 array(0,1,0,0,0,0,0,0,1), 381 array(0,1,0,0,0,0,0,0,1), 382 array(0,1,0,0,0,0,0,0,1), 383 array(0,1,0,0,0,0,0,1,0), 384 array(0,1,1,1,1,1,1,0,0), 385 array(0,1,0,0,0,0,0,1,0), 386 array(0,1,0,0,0,0,0,0,1), 387 array(0,1,0,0,0,0,0,0,1), 388 array(0,1,0,0,0,0,0,0,1), 389 array(0,1,0,0,0,0,0,0,1), 390 array(0,1,0,0,0,0,0,1,0), 391 array(1,1,1,1,1,1,1,0,0), 392 ), 393 array( 394 array(0,1,0,0,0,0,0,0,0), 395 array(0,1,0,0,0,0,0,0,0), 396 array(0,1,0,0,0,0,0,0,0), 397 array(0,1,0,0,0,0,0,0,0), 398 array(0,1,0,0,0,0,0,0,0), 399 array(0,1,0,0,0,0,0,0,0), 400 array(0,1,0,0,0,0,0,0,0), 401 array(0,1,1,1,1,1,1,0,0), 402 array(0,1,0,0,0,0,0,1,0), 403 array(0,1,0,0,0,0,0,0,1), 404 array(0,1,0,0,0,0,0,0,1), 405 array(0,1,0,0,0,0,0,0,1), 406 array(0,1,0,0,0,0,0,0,1), 407 array(0,1,0,0,0,0,0,1,0), 408 array(0,1,1,1,1,1,1,0,0), 409 ), 410 ), 411 'C' => array( 412 array( 413 array(0,0,1,1,1,1,1,0,0), 414 array(0,1,0,0,0,0,0,1,0), 415 array(1,0,0,0,0,0,0,0,1), 416 array(1,0,0,0,0,0,0,0,1), 417 array(1,0,0,0,0,0,0,0,0), 418 array(1,0,0,0,0,0,0,0,0), 419 array(1,0,0,0,0,0,0,0,0), 420 array(1,0,0,0,0,0,0,0,0), 421 array(1,0,0,0,0,0,0,0,0), 422 array(1,0,0,0,0,0,0,0,0), 423 array(1,0,0,0,0,0,0,0,0), 424 array(1,0,0,0,0,0,0,0,1), 425 array(1,0,0,0,0,0,0,0,1), 426 array(0,1,0,0,0,0,0,1,0), 427 array(0,0,1,1,1,1,1,0,0), 428 ), 429 array( 430 array(0,0,1,1,1,1,1,0,1), 431 array(0,1,0,0,0,0,0,1,1), 432 array(1,0,0,0,0,0,0,0,1), 433 array(1,0,0,0,0,0,0,0,1), 434 array(1,0,0,0,0,0,0,0,0), 435 array(1,0,0,0,0,0,0,0,0), 436 array(1,0,0,0,0,0,0,0,0), 437 array(1,0,0,0,0,0,0,0,0), 438 array(1,0,0,0,0,0,0,0,0), 439 array(1,0,0,0,0,0,0,0,0), 440 array(1,0,0,0,0,0,0,0,0), 441 array(1,0,0,0,0,0,0,0,1), 442 array(1,0,0,0,0,0,0,0,1), 443 array(0,1,0,0,0,0,0,1,1), 444 array(0,0,1,1,1,1,1,0,1), 445 ), 446 ), 447 'D' => array( 448 array( 449 array(1,1,1,1,1,1,1,0,0), 450 array(1,0,0,0,0,0,0,1,0), 451 array(1,0,0,0,0,0,0,0,1), 452 array(1,0,0,0,0,0,0,0,1), 453 array(1,0,0,0,0,0,0,0,1), 454 array(1,0,0,0,0,0,0,0,1), 455 array(1,0,0,0,0,0,0,0,1), 456 array(1,0,0,0,0,0,0,0,1), 457 array(1,0,0,0,0,0,0,0,1), 458 array(1,0,0,0,0,0,0,0,1), 459 array(1,0,0,0,0,0,0,0,1), 460 array(1,0,0,0,0,0,0,0,1), 461 array(1,0,0,0,0,0,0,0,1), 462 array(1,0,0,0,0,0,0,1,0), 463 array(1,1,1,1,1,1,1,0,0), 464 ), 465 array( 466 array(1,1,1,1,1,1,1,0,0), 467 array(0,1,0,0,0,0,0,1,0), 468 array(0,1,0,0,0,0,0,0,1), 469 array(0,1,0,0,0,0,0,0,1), 470 array(0,1,0,0,0,0,0,0,1), 471 array(0,1,0,0,0,0,0,0,1), 472 array(0,1,0,0,0,0,0,0,1), 473 array(0,1,0,0,0,0,0,0,1), 474 array(0,1,0,0,0,0,0,0,1), 475 array(0,1,0,0,0,0,0,0,1), 476 array(0,1,0,0,0,0,0,0,1), 477 array(0,1,0,0,0,0,0,0,1), 478 array(0,1,0,0,0,0,0,0,1), 479 array(0,1,0,0,0,0,0,1,0), 480 array(1,1,1,1,1,1,1,0,0), 481 ), 482 array( 483 array(0,0,0,0,0,0,0,0,1), 484 array(0,0,0,0,0,0,0,0,1), 485 array(0,0,0,0,0,0,0,0,1), 486 array(0,0,0,0,0,0,0,0,1), 487 array(0,0,0,0,0,0,0,0,1), 488 array(0,0,0,0,0,0,0,0,1), 489 array(0,0,0,0,0,0,0,0,1), 490 array(0,0,1,1,1,1,1,0,1), 491 array(0,1,1,0,0,0,1,1,1), 492 array(0,1,0,0,0,0,0,0,1), 493 array(0,1,0,0,0,0,0,0,1), 494 array(0,1,0,0,0,0,0,0,1), 495 array(0,1,0,0,0,0,0,0,1), 496 array(0,1,1,0,0,0,1,1,1), 497 array(0,0,1,1,1,1,1,0,1), 498 ), 499 ), 500 'E' => array( 501 array( 502 array(1,1,1,1,1,1,1,1,1), 503 array(1,0,0,0,0,0,0,0,0), 504 array(1,0,0,0,0,0,0,0,0), 505 array(1,0,0,0,0,0,0,0,0), 506 array(1,0,0,0,0,0,0,0,0), 507 array(1,0,0,0,0,0,0,0,0), 508 array(1,0,0,0,0,0,0,0,0), 509 array(1,1,1,1,1,1,1,1,0), 510 array(1,0,0,0,0,0,0,0,0), 511 array(1,0,0,0,0,0,0,0,0), 512 array(1,0,0,0,0,0,0,0,0), 513 array(1,0,0,0,0,0,0,0,0), 514 array(1,0,0,0,0,0,0,0,0), 515 array(1,0,0,0,0,0,0,0,0), 516 array(1,1,1,1,1,1,1,1,1), 517 ), 518 array( 519 array(1,1,1,1,1,1,1,1,1), 520 array(1,0,0,0,0,0,0,0,1), 521 array(1,0,0,0,0,0,0,0,0), 522 array(1,0,0,0,0,0,0,0,0), 523 array(1,0,0,0,0,0,0,0,0), 524 array(1,0,0,0,0,0,0,0,0), 525 array(1,0,0,0,0,0,0,0,0), 526 array(1,1,1,1,1,1,1,0,0), 527 array(1,0,0,0,0,0,0,0,0), 528 array(1,0,0,0,0,0,0,0,0), 529 array(1,0,0,0,0,0,0,0,0), 530 array(1,0,0,0,0,0,0,0,0), 531 array(1,0,0,0,0,0,0,0,0), 532 array(1,0,0,0,0,0,0,0,1), 533 array(1,1,1,1,1,1,1,1,1), 534 ), 535 array( 536 array(0,0,0,0,0,0,0,0,0), 537 array(0,0,0,0,0,0,0,0,0), 538 array(0,0,0,0,0,0,0,0,0), 539 array(0,0,0,0,0,0,0,0,0), 540 array(0,0,0,0,0,0,0,0,0), 541 array(0,0,0,0,0,0,0,0,0), 542 array(0,0,0,0,0,0,0,0,0), 543 array(0,0,1,1,1,1,1,0,0), 544 array(0,1,1,0,0,0,1,1,0), 545 array(1,1,0,0,0,0,0,1,1), 546 array(1,1,1,1,1,1,1,1,1), 547 array(1,0,0,0,0,0,0,0,0), 548 array(1,0,0,0,0,0,0,0,1), 549 array(1,1,0,0,0,0,0,1,1), 550 array(0,1,1,1,1,1,1,1,0), 551 ), 552 ), 553 'F' => array( 554 array( 555 array(1,1,1,1,1,1,1,1,1), 556 array(1,0,0,0,0,0,0,0,0), 557 array(1,0,0,0,0,0,0,0,0), 558 array(1,0,0,0,0,0,0,0,0), 559 array(1,0,0,0,0,0,0,0,0), 560 array(1,0,0,0,0,0,0,0,0), 561 array(1,0,0,0,0,0,0,0,0), 562 array(1,1,1,1,1,1,1,0,0), 563 array(1,0,0,0,0,0,0,0,0), 564 array(1,0,0,0,0,0,0,0,0), 565 array(1,0,0,0,0,0,0,0,0), 566 array(1,0,0,0,0,0,0,0,0), 567 array(1,0,0,0,0,0,0,0,0), 568 array(1,0,0,0,0,0,0,0,0), 569 array(1,0,0,0,0,0,0,0,0), 570 ), 571 array( 572 array(0,1,1,1,1,1,1,1,1), 573 array(0,1,0,0,0,0,0,0,1), 574 array(0,1,0,0,0,0,0,0,0), 575 array(0,1,0,0,0,0,0,0,0), 576 array(0,1,0,0,0,0,0,0,0), 577 array(0,1,0,0,0,0,0,0,0), 578 array(0,1,0,0,0,0,0,0,0), 579 array(0,1,1,1,1,1,1,0,0), 580 array(0,1,0,0,0,0,0,0,0), 581 array(0,1,0,0,0,0,0,0,0), 582 array(0,1,0,0,0,0,0,0,0), 583 array(0,1,0,0,0,0,0,0,0), 584 array(0,1,0,0,0,0,0,0,0), 585 array(0,1,0,0,0,0,0,0,0), 586 array(1,1,1,0,0,0,0,0,0), 587 ), 588 array( 589 array(0,0,0,1,1,0,0,0,0), 590 array(0,0,1,1,0,0,0,0,0), 591 array(0,1,1,0,0,0,0,0,0), 592 array(0,1,0,0,0,0,0,0,0), 593 array(0,1,0,0,0,0,0,0,0), 594 array(1,1,1,1,0,0,0,0,0), 595 array(0,1,0,0,0,0,0,0,0), 596 array(0,1,0,0,0,0,0,0,0), 597 array(0,1,0,0,0,0,0,0,0), 598 array(0,1,0,0,0,0,0,0,0), 599 array(0,1,0,0,0,0,0,0,0), 600 array(0,1,0,0,0,0,0,0,0), 601 array(0,1,0,0,0,0,0,0,0), 602 array(0,1,0,0,0,0,0,0,0), 603 array(0,1,0,0,0,0,0,0,0), 604 ), 605 ), 606 'G' => array( 607 array( 608 array(0,0,1,1,1,1,1,0,0), 609 array(0,1,0,0,0,0,0,1,0), 610 array(1,0,0,0,0,0,0,0,1), 611 array(1,0,0,0,0,0,0,0,0), 612 array(1,0,0,0,0,0,0,0,0), 613 array(1,0,0,0,0,0,0,0,0), 614 array(1,0,0,0,0,0,0,0,0), 615 array(1,0,0,0,0,0,0,0,0), 616 array(1,0,0,0,0,0,1,1,1), 617 array(1,0,0,0,0,0,0,0,1), 618 array(1,0,0,0,0,0,0,0,1), 619 array(1,0,0,0,0,0,0,0,1), 620 array(1,0,0,0,0,0,0,0,1), 621 array(0,1,0,0,0,0,0,1,0), 622 array(0,0,1,1,1,1,1,0,0), 623 ), 624 array( 625 array(0,0,1,1,1,1,1,0,1), 626 array(0,1,0,0,0,0,0,1,1), 627 array(1,0,0,0,0,0,0,0,1), 628 array(1,0,0,0,0,0,0,0,0), 629 array(1,0,0,0,0,0,0,0,0), 630 array(1,0,0,0,0,0,0,0,0), 631 array(1,0,0,0,0,0,0,0,0), 632 array(1,0,0,0,0,0,0,0,0), 633 array(1,0,0,0,1,1,1,1,1), 634 array(1,0,0,0,1,0,0,0,1), 635 array(1,0,0,0,1,0,0,0,1), 636 array(1,0,0,0,0,0,0,0,1), 637 array(1,0,0,0,0,0,0,0,1), 638 array(0,1,0,0,0,0,0,1,1), 639 array(0,0,1,1,1,1,1,0,1), 640 ), 641 array( 642 array(0,0,1,1,1,1,1,0,1), 643 array(0,1,1,0,0,0,0,1,1), 644 array(1,1,0,0,0,0,0,1,1), 645 array(1,0,0,0,0,0,0,0,1), 646 array(1,0,0,0,0,0,0,0,1), 647 array(1,1,1,0,0,0,0,0,1), 648 array(0,0,1,1,1,1,1,1,1), 649 array(0,0,0,0,0,0,0,0,1), 650 array(0,0,0,0,0,0,0,0,1), 651 array(0,0,0,0,0,0,0,0,1), 652 array(0,0,0,0,0,0,0,0,1), 653 array(0,0,0,0,0,0,0,1,1), 654 array(1,1,1,1,1,1,1,1,0), 655 array(0,0,0,0,0,0,0,0,0), 656 array(0,0,0,0,0,0,0,0,0), 657 ), 658 ), 659 'H' => array( 660 array( 661 array(1,0,0,0,0,0,0,0,1), 662 array(1,0,0,0,0,0,0,0,1), 663 array(1,0,0,0,0,0,0,0,1), 664 array(1,0,0,0,0,0,0,0,1), 665 array(1,0,0,0,0,0,0,0,1), 666 array(1,0,0,0,0,0,0,0,1), 667 array(1,0,0,0,0,0,0,0,1), 668 array(1,1,1,1,1,1,1,1,1), 669 array(1,0,0,0,0,0,0,0,1), 670 array(1,0,0,0,0,0,0,0,1), 671 array(1,0,0,0,0,0,0,0,1), 672 array(1,0,0,0,0,0,0,0,1), 673 array(1,0,0,0,0,0,0,0,1), 674 array(1,0,0,0,0,0,0,0,1), 675 array(1,0,0,0,0,0,0,0,1), 676 ), 677 array( 678 array(1,1,1,0,0,0,1,1,1), 679 array(0,1,0,0,0,0,0,1,0), 680 array(0,1,0,0,0,0,0,1,0), 681 array(0,1,0,0,0,0,0,1,0), 682 array(0,1,0,0,0,0,0,1,0), 683 array(0,1,0,0,0,0,0,1,0), 684 array(0,1,0,0,0,0,0,1,0), 685 array(0,1,1,1,1,1,1,1,0), 686 array(0,1,0,0,0,0,0,1,0), 687 array(0,1,0,0,0,0,0,1,0), 688 array(0,1,0,0,0,0,0,1,0), 689 array(0,1,0,0,0,0,0,1,0), 690 array(0,1,0,0,0,0,0,1,0), 691 array(0,1,0,0,0,0,0,1,0), 692 array(1,1,1,0,0,0,1,1,1), 693 ), 694 array( 695 array(1,0,0,0,0,0,0,0,0), 696 array(1,0,0,0,0,0,0,0,0), 697 array(1,0,0,0,0,0,0,0,0), 698 array(1,0,0,0,0,0,0,0,0), 699 array(1,0,0,0,0,0,0,0,0), 700 array(1,0,0,0,0,0,0,0,0), 701 array(1,0,0,0,0,0,0,0,0), 702 array(1,0,0,1,1,1,0,0,0), 703 array(1,1,1,1,0,1,1,0,0), 704 array(1,0,0,0,0,0,1,0,0), 705 array(1,0,0,0,0,0,1,0,0), 706 array(1,0,0,0,0,0,1,0,0), 707 array(1,0,0,0,0,0,1,0,0), 708 array(1,0,0,0,0,0,1,0,0), 709 array(1,0,0,0,0,0,1,0,0), 710 ), 711 ), 712 'I' => array( 713 array( 714 array(1,1,1,1,1,1,1,1,1), 715 array(0,0,0,0,1,0,0,0,0), 716 array(0,0,0,0,1,0,0,0,0), 717 array(0,0,0,0,1,0,0,0,0), 718 array(0,0,0,0,1,0,0,0,0), 719 array(0,0,0,0,1,0,0,0,0), 720 array(0,0,0,0,1,0,0,0,0), 721 array(0,0,0,0,1,0,0,0,0), 722 array(0,0,0,0,1,0,0,0,0), 723 array(0,0,0,0,1,0,0,0,0), 724 array(0,0,0,0,1,0,0,0,0), 725 array(0,0,0,0,1,0,0,0,0), 726 array(0,0,0,0,1,0,0,0,0), 727 array(0,0,0,0,1,0,0,0,0), 728 array(1,1,1,1,1,1,1,1,1), 729 ), 730 array( 731 array(0,0,0,1,1,1,0,0,0), 732 array(0,0,0,0,1,0,0,0,0), 733 array(0,0,0,0,1,0,0,0,0), 734 array(0,0,0,0,1,0,0,0,0), 735 array(0,0,0,0,1,0,0,0,0), 736 array(0,0,0,0,1,0,0,0,0), 737 array(0,0,0,0,1,0,0,0,0), 738 array(0,0,0,0,1,0,0,0,0), 739 array(0,0,0,0,1,0,0,0,0), 740 array(0,0,0,0,1,0,0,0,0), 741 array(0,0,0,0,1,0,0,0,0), 742 array(0,0,0,0,1,0,0,0,0), 743 array(0,0,0,0,1,0,0,0,0), 744 array(0,0,0,0,1,0,0,0,0), 745 array(0,0,0,1,1,1,0,0,0), 746 ), 747 array( 748 array(0,0,0,0,0,0,0,0,0), 749 array(0,0,0,0,0,0,0,0,0), 750 array(0,0,0,0,0,0,0,0,0), 751 array(0,0,0,0,1,0,0,0,0), 752 array(0,0,0,1,1,1,0,0,0), 753 array(0,0,0,0,1,0,0,0,0), 754 array(0,0,0,0,0,0,0,0,0), 755 array(0,0,0,0,1,0,0,0,0), 756 array(0,0,0,0,1,0,0,0,0), 757 array(0,0,0,0,1,0,0,0,0), 758 array(0,0,0,0,1,0,0,0,0), 759 array(0,0,0,0,1,0,0,0,0), 760 array(0,0,0,0,1,0,0,0,0), 761 array(0,0,0,0,1,0,0,0,0), 762 array(0,0,0,1,1,1,0,0,0), 763 ), 764 ), 765 'J' => array( 766 array( 767 array(1,1,1,1,1,1,1,1,1), 768 array(0,0,0,0,0,1,0,0,0), 769 array(0,0,0,0,0,1,0,0,0), 770 array(0,0,0,0,0,1,0,0,0), 771 array(0,0,0,0,0,1,0,0,0), 772 array(0,0,0,0,0,1,0,0,0), 773 array(0,0,0,0,0,1,0,0,0), 774 array(0,0,0,0,0,1,0,0,0), 775 array(0,0,0,0,0,1,0,0,0), 776 array(0,0,0,0,0,1,0,0,0), 777 array(0,0,0,0,0,1,0,0,0), 778 array(1,0,0,0,0,1,0,0,0), 779 array(1,0,0,0,0,1,0,0,0), 780 array(0,1,0,0,1,0,0,0,0), 781 array(0,0,1,1,0,0,0,0,0), 782 ), 783 array( 784 array(1,1,1,1,1,1,1,1,1), 785 array(0,0,0,0,0,1,0,0,0), 786 array(0,0,0,0,0,1,0,0,0), 787 array(0,0,0,0,0,1,0,0,0), 788 array(0,0,0,0,0,1,0,0,0), 789 array(0,0,0,0,0,1,0,0,0), 790 array(0,0,0,0,0,1,0,0,0), 791 array(0,0,0,0,0,1,0,0,0), 792 array(0,0,0,0,0,1,0,0,0), 793 array(0,0,0,0,0,1,0,0,0), 794 array(0,0,0,0,0,1,0,0,0), 795 array(1,0,0,0,0,1,0,0,0), 796 array(1,0,0,0,0,1,0,0,0), 797 array(1,1,0,0,1,0,0,0,0), 798 array(1,0,1,1,0,0,0,0,0), 799 ), 800 array( 801 array(0,0,0,0,0,0,0,0,0), 802 array(0,0,0,0,0,0,0,0,0), 803 array(0,0,0,0,0,0,0,0,0), 804 array(0,0,0,0,0,0,0,0,0), 805 array(0,0,0,0,0,1,0,0,0), 806 array(0,0,0,0,0,0,0,0,0), 807 array(0,0,0,0,0,1,0,0,0), 808 array(0,0,0,0,0,1,0,0,0), 809 array(0,0,0,0,0,1,0,0,0), 810 array(0,0,0,0,0,1,0,0,0), 811 array(0,0,0,0,0,1,0,0,0), 812 array(1,0,0,0,0,1,0,0,0), 813 array(1,0,0,0,0,1,0,0,0), 814 array(0,1,0,0,1,0,0,0,0), 815 array(0,0,1,1,0,0,0,0,0), 816 ), 817 ), 818 'K' => array( 819 array( // New 'K', supplied by NeoThermic 820 array(1,0,0,0,0,0,0,0,1), 821 array(1,0,0,0,0,0,0,1,0), 822 array(1,0,0,0,0,0,1,0,0), 823 array(1,0,0,0,0,1,0,0,0), 824 array(1,0,0,0,1,0,0,0,0), 825 array(1,0,0,1,0,0,0,0,0), 826 array(1,0,1,0,0,0,0,0,0), 827 array(1,1,0,0,0,0,0,0,0), 828 array(1,0,1,0,0,0,0,0,0), 829 array(1,0,0,1,0,0,0,0,0), 830 array(1,0,0,0,1,0,0,0,0), 831 array(1,0,0,0,0,1,0,0,0), 832 array(1,0,0,0,0,0,1,0,0), 833 array(1,0,0,0,0,0,0,1,0), 834 array(1,0,0,0,0,0,0,0,1), 835 ), 836 array( 837 array(0,1,0,0,0,0,0,0,1), 838 array(0,1,0,0,0,0,0,1,0), 839 array(0,1,0,0,0,0,1,0,0), 840 array(0,1,0,0,0,1,0,0,0), 841 array(0,1,0,0,1,0,0,0,0), 842 array(0,1,0,1,0,0,0,0,0), 843 array(0,1,1,0,0,0,0,0,0), 844 array(0,1,0,0,0,0,0,0,0), 845 array(0,1,1,0,0,0,0,0,0), 846 array(0,1,0,1,0,0,0,0,0), 847 array(0,1,0,0,1,0,0,0,0), 848 array(0,1,0,0,0,1,0,0,0), 849 array(0,1,0,0,0,0,1,0,0), 850 array(0,1,0,0,0,0,0,1,0), 851 array(1,1,1,0,0,0,1,1,1), 852 ), 853 array( 854 array(0,0,0,0,0,0,0,0,0), 855 array(0,1,0,0,0,0,0,0,0), 856 array(0,1,0,0,0,0,0,0,0), 857 array(0,1,0,0,0,1,0,0,0), 858 array(0,1,0,0,1,0,0,0,0), 859 array(0,1,0,1,0,0,0,0,0), 860 array(0,1,1,0,0,0,0,0,0), 861 array(0,1,0,0,0,0,0,0,0), 862 array(0,1,1,0,0,0,0,0,0), 863 array(0,1,0,1,0,0,0,0,0), 864 array(0,1,0,0,1,0,0,0,0), 865 array(0,1,0,0,0,1,0,0,0), 866 array(0,1,0,0,0,0,1,0,0), 867 array(0,1,0,0,0,0,0,1,0), 868 array(0,1,0,0,0,0,0,1,0), 869 ), 870 ), 871 'L' => array( 872 array( 873 array(0,0,0,0,0,0,0,0,0), 874 array(1,0,0,0,0,0,0,0,0), 875 array(1,0,0,0,0,0,0,0,0), 876 array(1,0,0,0,0,0,0,0,0), 877 array(1,0,0,0,0,0,0,0,0), 878 array(1,0,0,0,0,0,0,0,0), 879 array(1,0,0,0,0,0,0,0,0), 880 array(1,0,0,0,0,0,0,0,0), 881 array(1,0,0,0,0,0,0,0,0), 882 array(1,0,0,0,0,0,0,0,0), 883 array(1,0,0,0,0,0,0,0,0), 884 array(1,0,0,0,0,0,0,0,0), 885 array(1,0,0,0,0,0,0,0,0), 886 array(1,0,0,0,0,0,0,0,0), 887 array(1,1,1,1,1,1,1,1,1), 888 ), 889 array( 890 array(0,0,0,0,0,0,0,0,0), 891 array(0,1,0,0,0,0,0,0,0), 892 array(0,1,0,0,0,0,0,0,0), 893 array(0,1,0,0,0,0,0,0,0), 894 array(0,1,0,0,0,0,0,0,0), 895 array(0,1,0,0,0,0,0,0,0), 896 array(0,1,0,0,0,0,0,0,0), 897 array(0,1,0,0,0,0,0,0,0), 898 array(0,1,0,0,0,0,0,0,0), 899 array(0,1,0,0,0,0,0,0,0), 900 array(0,1,0,0,0,0,0,0,0), 901 array(0,1,0,0,0,0,0,0,0), 902 array(0,1,0,0,0,0,0,0,0), 903 array(0,1,0,0,0,0,0,0,1), 904 array(1,1,1,1,1,1,1,1,1), 905 ), 906 array( 907 array(0,0,0,0,0,0,0,0,0), 908 array(0,1,0,0,0,0,0,0,0), 909 array(0,1,0,0,0,0,0,0,0), 910 array(0,1,0,0,0,0,0,0,0), 911 array(0,1,0,0,0,0,0,0,0), 912 array(0,1,0,0,0,0,0,0,0), 913 array(0,1,0,0,0,0,0,0,0), 914 array(0,1,0,0,0,0,0,0,0), 915 array(0,1,0,0,0,0,0,0,0), 916 array(0,1,0,0,0,0,0,0,0), 917 array(0,1,0,0,0,0,0,0,0), 918 array(0,1,0,0,0,0,0,0,0), 919 array(0,1,0,0,0,0,0,0,0), 920 array(0,1,1,0,0,0,0,0,0), 921 array(0,0,1,1,1,0,0,0,0), 922 ), 923 ), 924 'M' => array( 925 array( 926 array(1,1,0,0,0,0,0,1,1), 927 array(1,1,0,0,0,0,0,1,1), 928 array(1,0,1,0,0,0,1,0,1), 929 array(1,0,1,0,0,0,1,0,1), 930 array(1,0,1,0,0,0,1,0,1), 931 array(1,0,0,1,0,1,0,0,1), 932 array(1,0,0,1,0,1,0,0,1), 933 array(1,0,0,1,0,1,0,0,1), 934 array(1,0,0,0,1,0,0,0,1), 935 array(1,0,0,0,1,0,0,0,1), 936 array(1,0,0,0,0,0,0,0,1), 937 array(1,0,0,0,0,0,0,0,1), 938 array(1,0,0,0,0,0,0,0,1), 939 array(1,0,0,0,0,0,0,0,1), 940 array(1,0,0,0,0,0,0,0,1), 941 ), 942 array( 943 array(0,0,0,0,0,0,0,0,0), 944 array(0,1,0,0,0,0,0,1,0), 945 array(0,1,1,0,0,0,1,1,0), 946 array(0,1,1,0,0,0,1,1,0), 947 array(0,1,1,0,0,0,1,1,0), 948 array(0,1,0,1,0,1,0,1,0), 949 array(0,1,0,1,0,1,0,1,0), 950 array(0,1,0,1,0,1,0,1,0), 951 array(0,1,0,0,1,0,0,1,0), 952 array(0,1,0,0,1,0,0,1,0), 953 array(0,1,0,0,0,0,0,1,0), 954 array(0,1,0,0,0,0,0,1,0), 955 array(0,1,0,0,0,0,0,1,0), 956 array(0,1,0,0,0,0,0,1,0), 957 array(1,1,1,0,0,0,1,1,1), 958 ), 959 array( 960 array(0,0,0,0,0,0,0,0,0), 961 array(0,0,0,0,0,0,0,0,0), 962 array(0,0,0,0,0,0,0,0,0), 963 array(0,0,0,0,0,0,0,0,0), 964 array(0,0,0,0,0,0,0,0,0), 965 array(0,0,0,0,0,0,0,0,0), 966 array(0,1,1,1,0,1,1,1,0), 967 array(1,1,0,1,1,1,0,1,1), 968 array(1,0,0,0,1,0,0,0,1), 969 array(1,0,0,0,1,0,0,0,1), 970 array(1,0,0,0,1,0,0,0,1), 971 array(1,0,0,0,1,0,0,0,1), 972 array(1,0,0,0,1,0,0,0,1), 973 array(1,0,0,0,1,0,0,0,1), 974 array(1,0,0,0,1,0,0,0,1), 975 ), 976 ), 977 'N' => array( 978 array( 979 array(1,1,0,0,0,0,0,0,1), 980 array(1,1,0,0,0,0,0,0,1), 981 array(1,0,1,0,0,0,0,0,1), 982 array(1,0,1,0,0,0,0,0,1), 983 array(1,0,0,1,0,0,0,0,1), 984 array(1,0,0,1,0,0,0,0,1), 985 array(1,0,0,0,1,0,0,0,1), 986 array(1,0,0,0,1,0,0,0,1), 987 array(1,0,0,0,1,0,0,0,1), 988 array(1,0,0,0,0,1,0,0,1), 989 array(1,0,0,0,0,1,0,0,1), 990 array(1,0,0,0,0,0,1,0,1), 991 array(1,0,0,0,0,0,1,0,1), 992 array(1,0,0,0,0,0,0,1,1), 993 array(1,0,0,0,0,0,0,1,1), 994 ), 995 array( 996 array(0,0,0,0,0,0,0,0,0), 997 array(0,1,0,0,0,0,0,1,0), 998 array(0,1,1,0,0,0,0,1,0), 999 array(0,1,1,0,0,0,0,1,0), 1000 array(0,1,1,0,0,0,0,1,0), 1001 array(0,1,0,1,0,0,0,1,0), 1002 array(0,1,0,1,0,0,0,1,0), 1003 array(0,1,0,1,0,0,0,1,0), 1004 array(0,1,0,0,1,0,0,1,0), 1005 array(0,1,0,0,1,1,0,1,0), 1006 array(0,1,0,0,0,1,0,1,0), 1007 array(0,1,0,0,0,1,1,1,0), 1008 array(0,1,0,0,0,0,1,1,0), 1009 array(0,1,0,0,0,0,0,1,0), 1010 array(1,1,1,0,0,0,1,1,1), 1011 ), 1012 array( 1013 array(0,0,0,0,0,0,0,0,0), 1014 array(0,0,0,0,0,0,0,0,0), 1015 array(0,0,0,0,0,0,0,0,0), 1016 array(0,0,0,0,0,0,0,0,0), 1017 array(0,0,0,0,0,0,0,0,0), 1018 array(0,0,0,0,0,0,0,0,0), 1019 array(0,0,0,0,0,0,0,0,0), 1020 array(1,0,1,1,1,1,0,0,0), 1021 array(1,1,1,0,0,1,1,0,0), 1022 array(1,0,0,0,0,0,1,0,0), 1023 array(1,0,0,0,0,0,1,0,0), 1024 array(1,0,0,0,0,0,1,0,0), 1025 array(1,0,0,0,0,0,1,0,0), 1026 array(1,0,0,0,0,0,1,0,0), 1027 array(1,0,0,0,0,0,1,0,0), 1028 ), 1029 ), 1030 'O' => array( 1031 array( 1032 array(0,0,1,1,1,1,1,0,0), 1033 array(0,1,0,0,0,0,0,1,0), 1034 array(1,0,0,0,0,0,0,0,1), 1035 array(1,0,0,0,0,0,0,0,1), 1036 array(1,0,0,0,0,0,0,0,1), 1037 array(1,0,0,0,0,0,0,0,1), 1038 array(1,0,0,0,0,0,0,0,1), 1039 array(1,0,0,0,0,0,0,0,1), 1040 array(1,0,0,0,0,0,0,0,1), 1041 array(1,0,0,0,0,0,0,0,1), 1042 array(1,0,0,0,0,0,0,0,1), 1043 array(1,0,0,0,0,0,0,0,1), 1044 array(1,0,0,0,0,0,0,0,1), 1045 array(0,1,0,0,0,0,0,1,0), 1046 array(0,0,1,1,1,1,1,0,0), 1047 ), 1048 array( 1049 array(0,0,1,1,1,1,1,0,0), 1050 array(0,1,0,0,0,0,0,1,0), 1051 array(1,1,0,0,0,0,0,1,1), 1052 array(1,1,0,0,0,0,0,1,1), 1053 array(1,1,0,0,0,0,0,1,1), 1054 array(1,1,0,0,0,0,0,1,1), 1055 array(1,1,0,0,0,0,0,1,1), 1056 array(1,1,0,0,0,0,0,1,1), 1057 array(1,1,0,0,0,0,0,1,1), 1058 array(1,1,0,0,0,0,0,1,1), 1059 array(1,1,0,0,0,0,0,1,1), 1060 array(1,1,0,0,0,0,0,1,1), 1061 array(1,1,0,0,0,0,0,1,1), 1062 array(0,1,0,0,0,0,0,1,0), 1063 array(0,0,1,1,1,1,1,0,0), 1064 ), 1065 array( 1066 array(0,0,0,0,0,0,0,0,0), 1067 array(0,0,0,0,0,0,0,0,0), 1068 array(0,0,0,0,0,0,0,0,0), 1069 array(0,0,0,0,0,0,0,0,0), 1070 array(0,0,0,0,0,0,0,0,0), 1071 array(0,0,0,0,0,0,0,0,0), 1072 array(0,0,0,0,0,0,0,0,0), 1073 array(0,1,1,1,1,1,0,0,0), 1074 array(1,1,1,0,0,1,1,0,0), 1075 array(1,0,0,0,0,0,1,0,0), 1076 array(1,0,0,0,0,0,1,0,0), 1077 array(1,0,0,0,0,0,1,0,0), 1078 array(1,0,0,0,0,0,1,0,0), 1079 array(1,1,0,0,0,1,1,0,0), 1080 array(0,1,1,1,1,1,0,0,0), 1081 ), 1082 ), 1083 'P' => array( 1084 array( 1085 array(1,1,1,1,1,1,1,0,0), 1086 array(1,0,0,0,0,0,0,1,0), 1087 array(1,0,0,0,0,0,0,0,1), 1088 array(1,0,0,0,0,0,0,0,1), 1089 array(1,0,0,0,0,0,0,0,1), 1090 array(1,0,0,0,0,0,0,0,1), 1091 array(1,0,0,0,0,0,0,1,0), 1092 array(1,1,1,1,1,1,1,0,0), 1093 array(1,0,0,0,0,0,0,0,0), 1094 array(1,0,0,0,0,0,0,0,0), 1095 array(1,0,0,0,0,0,0,0,0), 1096 array(1,0,0,0,0,0,0,0,0), 1097 array(1,0,0,0,0,0,0,0,0), 1098 array(1,0,0,0,0,0,0,0,0), 1099 array(1,0,0,0,0,0,0,0,0), 1100 ), 1101 array( 1102 array(1,1,1,1,1,1,1,0,0), 1103 array(0,1,0,0,0,0,0,1,0), 1104 array(0,1,0,0,0,0,0,0,1), 1105 array(0,1,0,0,0,0,0,0,1), 1106 array(0,1,0,0,0,0,0,0,1), 1107 array(0,1,0,0,0,0,0,0,1), 1108 array(0,1,0,0,0,0,0,1,0), 1109 array(1,1,1,1,1,1,1,0,0), 1110 array(0,1,0,0,0,0,0,0,0), 1111 array(0,1,0,0,0,0,0,0,0), 1112 array(0,1,0,0,0,0,0,0,0), 1113 array(0,1,0,0,0,0,0,0,0), 1114 array(0,1,0,0,0,0,0,0,0), 1115 array(0,1,0,0,0,0,0,0,0), 1116 array(1,1,1,0,0,0,0,0,0), 1117 ), 1118 array( 1119 array(0,0,0,0,0,0,0,0,0), 1120 array(0,0,0,0,0,0,0,0,0), 1121 array(1,0,0,0,0,0,0,0,0), 1122 array(1,0,1,1,0,0,0,0,0), 1123 array(1,1,0,1,1,0,0,0,0), 1124 array(1,0,0,0,1,0,0,0,0), 1125 array(1,0,0,0,1,0,0,0,0), 1126 array(1,0,0,1,1,0,0,0,0), 1127 array(1,1,1,1,0,0,0,0,0), 1128 array(1,0,0,0,0,0,0,0,0), 1129 array(1,0,0,0,0,0,0,0,0), 1130 array(1,0,0,0,0,0,0,0,0), 1131 array(1,0,0,0,0,0,0,0,0), 1132 array(1,0,0,0,0,0,0,0,0), 1133 array(1,0,0,0,0,0,0,0,0), 1134 ), 1135 ), 1136 'Q' => array( 1137 array( 1138 array(0,0,1,1,1,1,1,0,0), 1139 array(0,1,0,0,0,0,0,1,0), 1140 array(1,0,0,0,0,0,0,0,1), 1141 array(1,0,0,0,0,0,0,0,1), 1142 array(1,0,0,0,0,0,0,0,1), 1143 array(1,0,0,0,0,0,0,0,1), 1144 array(1,0,0,0,0,0,0,0,1), 1145 array(1,0,0,0,0,0,0,0,1), 1146 array(1,0,0,0,0,0,0,0,1), 1147 array(1,0,0,0,0,0,0,0,1), 1148 array(1,0,0,0,0,0,0,0,1), 1149 array(1,0,0,0,0,1,0,0,1), 1150 array(1,0,0,0,0,0,1,0,1), 1151 array(0,1,0,0,0,0,0,1,0), 1152 array(0,0,1,1,1,1,1,0,1), 1153 ), 1154 array( 1155 array(0,0,1,1,1,1,1,0,0), 1156 array(0,1,0,0,0,0,0,1,0), 1157 array(1,0,0,0,0,0,0,0,1), 1158 array(1,0,0,0,0,0,0,0,1), 1159 array(1,0,0,0,0,0,0,0,1), 1160 array(1,0,0,0,0,0,0,0,1), 1161 array(1,0,0,0,0,0,0,0,1), 1162 array(1,0,0,0,0,0,0,0,1), 1163 array(1,0,0,0,0,0,0,0,1), 1164 array(1,0,0,0,1,0,0,0,1), 1165 array(1,1,0,0,1,1,0,1,1), 1166 array(0,1,1,1,1,1,1,1,0), 1167 array(0,0,0,0,0,0,1,1,0), 1168 array(0,0,0,0,0,0,0,1,1), 1169 array(0,0,0,0,0,0,0,0,1), 1170 ), 1171 array( 1172 array(0,0,0,0,0,0,0,0,0), 1173 array(0,0,0,0,0,0,0,0,0), 1174 array(0,0,0,0,0,0,0,0,0), 1175 array(0,0,0,0,0,1,1,1,1), 1176 array(0,0,0,0,1,1,0,0,1), 1177 array(0,0,0,0,1,0,0,0,1), 1178 array(0,0,0,0,1,0,0,0,1), 1179 array(0,0,0,0,1,1,0,1,1), 1180 array(0,0,0,0,0,1,1,0,1), 1181 array(0,0,0,0,0,0,0,0,1), 1182 array(0,0,0,0,0,0,0,0,1), 1183 array(0,0,0,0,0,0,0,0,1), 1184 array(0,0,0,0,0,0,0,0,1), 1185 array(0,0,0,0,0,0,0,0,1), 1186 array(0,0,0,0,0,0,0,0,1), 1187 ), 1188 ), 1189 'R' => array( 1190 array( 1191 array(1,1,1,1,1,1,1,0,0), 1192 array(1,0,0,0,0,0,0,1,0), 1193 array(1,0,0,0,0,0,0,0,1), 1194 array(1,0,0,0,0,0,0,0,1), 1195 array(1,0,0,0,0,0,0,0,1), 1196 array(1,0,0,0,0,0,0,0,1), 1197 array(1,0,0,0,0,0,0,1,0), 1198 array(1,1,1,1,1,1,1,0,0), 1199 array(1,1,1,0,0,0,0,0,0), 1200 array(1,0,0,1,0,0,0,0,0), 1201 array(1,0,0,0,1,0,0,0,0), 1202 array(1,0,0,0,0,1,0,0,0), 1203 array(1,0,0,0,0,0,1,0,0), 1204 array(1,0,0,0,0,0,0,1,0), 1205 array(1,0,0,0,0,0,0,0,1), 1206 ), 1207 array( 1208 array(1,1,1,1,1,1,1,0,0), 1209 array(0,1,0,0,0,0,0,1,0), 1210 array(0,1,0,0,0,0,0,0,1), 1211 array(0,1,0,0,0,0,0,0,1), 1212 array(0,1,0,0,0,0,0,0,1), 1213 array(0,1,0,0,0,0,0,0,1), 1214 array(0,1,0,0,0,0,0,1,0), 1215 array(1,1,1,1,1,1,1,0,0), 1216 array(0,1,1,0,0,0,0,0,0), 1217 array(0,1,1,1,0,0,0,0,0), 1218 array(0,1,0,1,1,0,0,0,0), 1219 array(0,1,0,0,1,1,0,0,0), 1220 array(0,1,0,0,0,1,1,0,0), 1221 array(0,1,0,0,0,0,1,1,0), 1222 array(1,1,1,0,0,0,1,1,1), 1223 ), 1224 array( 1225 array(0,0,0,0,0,0,0,0,0), 1226 array(0,0,0,0,0,0,0,0,0), 1227 array(0,0,0,0,0,0,0,0,0), 1228 array(0,0,0,0,0,0,0,0,0), 1229 array(0,0,0,0,0,0,0,0,0), 1230 array(0,0,0,0,0,0,0,0,0), 1231 array(1,0,0,0,0,0,0,0,0), 1232 array(1,1,1,1,1,0,0,0,0), 1233 array(1,1,0,0,1,1,0,0,0), 1234 array(1,0,0,0,0,0,0,0,0), 1235 array(1,0,0,0,0,0,0,0,0), 1236 array(1,0,0,0,0,0,0,0,0), 1237 array(1,0,0,0,0,0,0,0,0), 1238 array(1,0,0,0,0,0,0,0,0), 1239 array(1,0,0,0,0,0,0,0,0), 1240 ), 1241 ), 1242 'S' => array( 1243 array( 1244 array(0,0,1,1,1,1,1,0,0), 1245 array(0,1,0,0,0,0,0,1,0), 1246 array(1,0,0,0,0,0,0,0,1), 1247 array(1,0,0,0,0,0,0,0,0), 1248 array(1,0,0,0,0,0,0,0,0), 1249 array(1,0,0,0,0,0,0,0,0), 1250 array(0,1,0,0,0,0,0,0,0), 1251 array(0,0,1,1,1,1,1,0,0), 1252 array(0,0,0,0,0,0,0,1,0), 1253 array(0,0,0,0,0,0,0,0,1), 1254 array(0,0,0,0,0,0,0,0,1), 1255 array(0,0,0,0,0,0,0,0,1), 1256 array(1,0,0,0,0,0,0,0,1), 1257 array(0,1,0,0,0,0,0,1,0), 1258 array(0,0,1,1,1,1,1,0,0), 1259 ), 1260 array( 1261 array(0,0,1,1,1,1,1,0,1), 1262 array(0,1,0,0,0,0,0,1,1), 1263 array(1,0,0,0,0,0,0,0,1), 1264 array(1,0,0,0,0,0,0,0,1), 1265 array(1,0,0,0,0,0,0,0,0), 1266 array(1,0,0,0,0,0,0,0,0), 1267 array(0,1,0,0,0,0,0,0,0), 1268 array(0,0,1,1,1,1,1,0,0), 1269 array(0,0,0,0,0,0,0,1,0), 1270 array(0,0,0,0,0,0,0,0,1), 1271 array(1,0,0,0,0,0,0,0,1), 1272 array(1,0,0,0,0,0,0,0,1), 1273 array(1,0,0,0,0,0,0,0,1), 1274 array(1,1,0,0,0,0,0,1,0), 1275 array(1,0,1,1,1,1,1,0,0), 1276 ), 1277 array( 1278 array(0,0,0,0,0,0,0,0,0), 1279 array(0,0,0,0,0,0,0,0,0), 1280 array(0,0,0,0,0,0,0,0,0), 1281 array(0,0,0,0,0,0,0,0,0), 1282 array(0,0,0,0,0,0,0,0,0), 1283 array(0,0,0,0,0,0,0,0,0), 1284 array(0,0,0,0,0,0,0,0,0), 1285 array(0,1,1,1,1,0,0,0,0), 1286 array(1,0,0,0,0,1,0,0,0), 1287 array(1,0,0,0,0,0,0,0,0), 1288 array(1,1,0,0,0,0,0,0,0), 1289 array(0,1,1,1,1,0,0,0,0), 1290 array(0,0,0,0,0,1,0,0,0), 1291 array(1,0,0,0,1,1,0,0,0), 1292 array(0,1,1,1,1,0,0,0,0), 1293 ), 1294 ), 1295 'T' => array( 1296 array( 1297 array(1,1,1,1,1,1,1,1,1), 1298 array(0,0,0,0,1,0,0,0,0), 1299 array(0,0,0,0,1,0,0,0,0), 1300 array(0,0,0,0,1,0,0,0,0), 1301 array(0,0,0,0,1,0,0,0,0), 1302 array(0,0,0,0,1,0,0,0,0), 1303 array(0,0,0,0,1,0,0,0,0), 1304 array(0,0,0,0,1,0,0,0,0), 1305 array(0,0,0,0,1,0,0,0,0), 1306 array(0,0,0,0,1,0,0,0,0), 1307 array(0,0,0,0,1,0,0,0,0), 1308 array(0,0,0,0,1,0,0,0,0), 1309 array(0,0,0,0,1,0,0,0,0), 1310 array(0,0,0,0,1,0,0,0,0), 1311 array(0,0,0,0,1,0,0,0,0), 1312 ), 1313 array( 1314 array(1,1,1,1,1,1,1,1,1), 1315 array(1,0,0,0,1,0,0,0,1), 1316 array(0,0,0,0,1,0,0,0,0), 1317 array(0,0,0,0,1,0,0,0,0), 1318 array(0,0,0,0,1,0,0,0,0), 1319 array(0,0,0,0,1,0,0,0,0), 1320 array(0,0,0,0,1,0,0,0,0), 1321 array(0,0,0,0,1,0,0,0,0), 1322 array(0,0,0,0,1,0,0,0,0), 1323 array(0,0,0,0,1,0,0,0,0), 1324 array(0,0,0,0,1,0,0,0,0), 1325 array(0,0,0,0,1,0,0,0,0), 1326 array(0,0,0,0,1,0,0,0,0), 1327 array(0,0,0,0,1,0,0,0,0), 1328 array(0,0,0,1,1,1,0,0,0), 1329 ), 1330 array( 1331 array(0,0,0,0,1,0,0,0,0), 1332 array(0,0,0,0,1,0,0,0,0), 1333 array(0,0,0,0,1,0,0,0,0), 1334 array(0,0,1,1,1,1,1,1,0), 1335 array(0,0,0,0,1,0,0,0,0), 1336 array(0,0,0,0,1,0,0,0,0), 1337 array(0,0,0,0,1,0,0,0,0), 1338 array(0,0,0,0,1,0,0,0,0), 1339 array(0,0,0,0,1,0,0,0,0), 1340 array(0,0,0,0,1,0,0,0,0), 1341 array(0,0,0,0,1,0,0,0,0), 1342 array(0,0,0,0,1,0,0,0,0), 1343 array(0,0,0,0,1,0,0,0,0), 1344 array(0,0,0,0,1,1,0,0,0), 1345 array(0,0,0,0,0,1,1,1,0), 1346 ), 1347 ), 1348 'U' => array( 1349 array( 1350 array(1,0,0,0,0,0,0,0,1), 1351 array(1,0,0,0,0,0,0,0,1), 1352 array(1,0,0,0,0,0,0,0,1), 1353 array(1,0,0,0,0,0,0,0,1), 1354 array(1,0,0,0,0,0,0,0,1), 1355 array(1,0,0,0,0,0,0,0,1), 1356 array(1,0,0,0,0,0,0,0,1), 1357 array(1,0,0,0,0,0,0,0,1), 1358 array(1,0,0,0,0,0,0,0,1), 1359 array(1,0,0,0,0,0,0,0,1), 1360 array(1,0,0,0,0,0,0,0,1), 1361 array(1,0,0,0,0,0,0,0,1), 1362 array(1,0,0,0,0,0,0,0,1), 1363 array(0,1,0,0,0,0,0,1,0), 1364 array(0,0,1,1,1,1,1,0,0), 1365 ), 1366 array( 1367 array(1,0,0,0,0,0,0,0,0), 1368 array(1,1,1,0,0,0,1,1,1), 1369 array(0,1,0,0,0,0,0,1,0), 1370 array(0,1,0,0,0,0,0,1,0), 1371 array(0,1,0,0,0,0,0,1,0), 1372 array(0,1,0,0,0,0,0,1,0), 1373 array(0,1,0,0,0,0,0,1,0), 1374 array(0,1,0,0,0,0,0,1,0), 1375 array(0,1,0,0,0,0,0,1,0), 1376 array(0,1,0,0,0,0,0,1,0), 1377 array(0,1,0,0,0,0,0,1,0), 1378 array(0,1,0,0,0,0,0,1,0), 1379 array(0,1,0,0,0,0,0,1,0), 1380 array(0,1,1,0,0,0,1,1,0), 1381 array(0,0,1,1,1,1,1,0,0), 1382 ), 1383 array( 1384 array(0,0,0,0,0,0,0,0,0), 1385 array(0,0,0,0,0,0,0,0,0), 1386 array(0,0,0,0,0,0,0,0,0), 1387 array(0,0,0,0,0,0,0,0,0), 1388 array(0,0,0,0,0,0,0,0,0), 1389 array(0,0,0,0,0,0,0,0,0), 1390 array(0,0,0,0,0,0,0,0,0), 1391 array(0,0,1,0,0,0,0,0,1), 1392 array(0,0,1,0,0,0,0,0,1), 1393 array(0,0,1,0,0,0,0,0,1), 1394 array(0,0,1,0,0,0,0,0,1), 1395 array(0,0,1,0,0,0,0,0,1), 1396 array(0,0,1,0,0,0,0,1,1), 1397 array(0,0,1,1,0,0,1,1,1), 1398 array(0,0,0,1,1,1,1,0,1), 1399 ), 1400 ), 1401 'V' => array( 1402 array( 1403 array(1,0,0,0,0,0,0,0,1), 1404 array(1,0,0,0,0,0,0,0,1), 1405 array(1,0,0,0,0,0,0,0,1), 1406 array(0,1,0,0,0,0,0,1,0), 1407 array(0,1,0,0,0,0,0,1,0), 1408 array(0,1,0,0,0,0,0,1,0), 1409 array(0,0,1,0,0,0,1,0,0), 1410 array(0,0,1,0,0,0,1,0,0), 1411 array(0,0,1,0,0,0,1,0,0), 1412 array(0,0,1,0,0,0,1,0,0), 1413 array(0,0,0,1,0,1,0,0,0), 1414 array(0,0,0,1,0,1,0,0,0), 1415 array(0,0,0,1,0,1,0,0,0), 1416 array(0,0,0,0,1,0,0,0,0), 1417 array(0,0,0,0,1,0,0,0,0), 1418 ), 1419 array( 1420 array(0,0,0,0,0,0,0,0,0), 1421 array(0,0,0,0,0,0,0,0,0), 1422 array(0,0,0,0,0,0,0,0,0), 1423 array(1,1,1,0,0,0,1,1,1), 1424 array(0,1,0,0,0,0,0,1,0), 1425 array(0,1,0,0,0,0,0,1,0), 1426 array(0,0,1,0,0,0,1,0,0), 1427 array(0,0,1,0,0,0,1,0,0), 1428 array(0,0,1,0,0,0,1,0,0), 1429 array(0,0,1,0,0,0,1,0,0), 1430 array(0,0,0,1,0,1,0,0,0), 1431 array(0,0,0,1,0,1,0,0,0), 1432 array(0,0,0,1,0,1,0,0,0), 1433 array(0,0,0,0,1,0,0,0,0), 1434 array(0,0,0,0,1,0,0,0,0), 1435 ), 1436 array( 1437 array(0,0,0,0,0,0,0,0,0), 1438 array(0,0,0,0,0,0,0,0,0), 1439 array(0,0,0,0,0,0,0,0,0), 1440 array(0,0,0,0,0,0,0,0,0), 1441 array(0,0,0,0,0,0,0,0,0), 1442 array(0,0,0,0,0,0,0,0,0), 1443 array(0,0,1,0,0,0,1,0,0), 1444 array(0,0,1,0,0,0,1,0,0), 1445 array(0,0,1,0,0,0,1,0,0), 1446 array(0,0,1,0,0,0,1,0,0), 1447 array(0,0,0,1,0,1,0,0,0), 1448 array(0,0,0,1,0,1,0,0,0), 1449 array(0,0,0,1,0,1,0,0,0), 1450 array(0,0,0,0,1,0,0,0,0), 1451 array(0,0,0,0,1,0,0,0,0), 1452 ), 1453 ), 1454 'W' => array( 1455 array( 1456 array(1,0,0,0,0,0,0,0,1), 1457 array(1,0,0,0,0,0,0,0,1), 1458 array(1,0,0,0,0,0,0,0,1), 1459 array(1,0,0,0,0,0,0,0,1), 1460 array(1,0,0,0,0,0,0,0,1), 1461 array(1,0,0,0,1,0,0,0,1), 1462 array(1,0,0,0,1,0,0,0,1), 1463 array(1,0,0,1,0,1,0,0,1), 1464 array(1,0,0,1,0,1,0,0,1), 1465 array(1,0,0,1,0,1,0,0,1), 1466 array(1,0,1,0,0,0,1,0,1), 1467 array(1,0,1,0,0,0,1,0,1), 1468 array(1,0,1,0,0,0,1,0,1), 1469 array(1,1,0,0,0,0,0,1,1), 1470 array(1,1,0,0,0,0,0,1,1), 1471 ), 1472 array( 1473 array(0,0,0,0,0,0,0,0,0), 1474 array(0,0,0,0,0,0,0,0,0), 1475 array(1,1,1,0,0,0,1,1,1), 1476 array(0,1,0,0,0,0,0,1,0), 1477 array(0,1,0,0,0,0,0,1,0), 1478 array(0,1,0,0,0,0,0,1,0), 1479 array(0,1,0,0,0,0,0,1,0), 1480 array(0,1,0,0,1,0,0,1,0), 1481 array(0,1,0,0,1,0,0,1,0), 1482 array(0,1,0,1,1,1,0,1,0), 1483 array(0,1,0,1,0,1,0,1,0), 1484 array(0,1,1,1,0,1,1,1,0), 1485 array(0,1,1,0,0,0,1,1,0), 1486 array(0,1,0,0,0,0,0,1,0), 1487 array(0,0,0,0,0,0,0,0,0), 1488 ), 1489 array( 1490 array(0,0,0,0,0,0,0,0,0), 1491 array(0,0,0,0,0,0,0,0,0), 1492 array(0,0,0,0,0,0,0,0,0), 1493 array(0,0,0,0,0,0,0,0,0), 1494 array(0,0,0,0,0,0,0,0,0), 1495 array(0,0,0,0,0,0,0,0,0), 1496 array(0,1,0,0,0,0,0,1,0), 1497 array(0,1,0,0,1,0,0,1,0), 1498 array(0,1,0,0,1,0,0,1,0), 1499 array(0,1,0,1,1,1,0,1,0), 1500 array(0,1,0,1,0,1,0,1,0), 1501 array(0,1,1,1,0,1,1,1,0), 1502 array(0,1,1,0,0,0,1,1,0), 1503 array(0,1,0,0,0,0,0,1,0), 1504 array(0,0,0,0,0,0,0,0,0), 1505 ), 1506 ), 1507 'X' => array( 1508 array( 1509 array(1,0,0,0,0,0,0,0,1), 1510 array(1,0,0,0,0,0,0,0,1), 1511 array(0,1,0,0,0,0,0,1,0), 1512 array(0,1,0,0,0,0,0,1,0), 1513 array(0,0,1,0,0,0,1,0,0), 1514 array(0,0,0,1,0,1,0,0,0), 1515 array(0,0,0,1,0,1,0,0,0), 1516 array(0,0,0,0,1,0,0,0,0), 1517 array(0,0,0,1,0,1,0,0,0), 1518 array(0,0,0,1,0,1,0,0,0), 1519 array(0,0,1,0,0,0,1,0,0), 1520 array(0,1,0,0,0,0,1,0,0), 1521 array(0,1,0,0,0,0,0,1,0), 1522 array(1,0,0,0,0,0,0,0,1), 1523 array(1,0,0,0,0,0,0,0,1), 1524 ), 1525 array( 1526 array(0,0,0,0,0,0,0,0,0), 1527 array(1,1,1,0,0,0,1,1,1), 1528 array(0,1,0,0,0,0,0,1,0), 1529 array(0,1,0,0,0,0,0,1,0), 1530 array(0,0,1,0,0,0,1,0,0), 1531 array(0,0,0,1,0,1,0,0,0), 1532 array(0,0,0,1,0,1,0,0,0), 1533 array(0,0,0,0,1,0,0,0,0), 1534 array(0,0,0,1,0,1,0,0,0), 1535 array(0,0,0,1,0,1,0,0,0), 1536 array(0,0,1,0,0,0,1,0,0), 1537 array(0,1,0,0,0,0,1,0,0), 1538 array(0,1,0,0,0,0,0,1,0), 1539 array(1,1,1,0,0,0,1,1,1), 1540 array(0,0,0,0,0,0,0,0,0), 1541 ), 1542 array( 1543 array(0,0,0,0,0,0,0,0,0), 1544 array(0,0,0,0,0,0,0,0,0), 1545 array(0,0,0,0,0,0,0,0,0), 1546 array(0,0,0,0,0,0,0,0,0), 1547 array(0,0,0,0,0,0,0,0,0), 1548 array(0,0,0,0,0,0,0,0,0), 1549 array(0,0,0,0,0,0,0,0,0), 1550 array(0,1,0,0,0,0,0,1,0), 1551 array(0,1,1,0,0,0,1,1,0), 1552 array(0,0,1,1,0,1,1,0,0), 1553 array(0,0,0,1,1,1,0,0,0), 1554 array(0,0,0,1,1,1,0,0,0), 1555 array(0,0,1,1,0,1,1,0,0), 1556 array(0,1,1,0,0,0,1,1,0), 1557 array(0,0,0,0,0,0,0,0,0), 1558 ), 1559 ), 1560 'Y' => array( 1561 array( 1562 array(1,0,0,0,0,0,0,0,1), 1563 array(1,0,0,0,0,0,0,0,1), 1564 array(0,1,0,0,0,0,0,1,0), 1565 array(0,1,0,0,0,0,0,1,0), 1566 array(0,0,1,0,0,0,1,0,0), 1567 array(0,0,1,0,0,0,1,0,0), 1568 array(0,0,0,1,0,1,0,0,0), 1569 array(0,0,0,0,1,0,0,0,0), 1570 array(0,0,0,0,1,0,0,0,0), 1571 array(0,0,0,0,1,0,0,0,0), 1572 array(0,0,0,0,1,0,0,0,0), 1573 array(0,0,0,0,1,0,0,0,0), 1574 array(0,0,0,0,1,0,0,0,0), 1575 array(0,0,0,0,1,0,0,0,0), 1576 array(0,0,0,0,1,0,0,0,0), 1577 ), 1578 array( 1579 array(0,0,0,0,0,0,0,0,0), 1580 array(1,1,1,0,0,0,1,1,1), 1581 array(0,1,0,0,0,0,0,1,0), 1582 array(0,1,0,0,0,0,0,1,0), 1583 array(0,0,1,0,0,0,1,0,0), 1584 array(0,0,1,0,0,0,1,0,0), 1585 array(0,0,0,1,0,1,0,0,0), 1586 array(0,0,0,0,1,0,0,0,0), 1587 array(0,0,0,0,1,0,0,0,0), 1588 array(0,0,0,0,1,0,0,0,0), 1589 array(0,0,0,0,1,0,0,0,0), 1590 array(0,0,0,0,1,0,0,0,0), 1591 array(0,0,0,0,1,0,0,0,0), 1592 array(0,0,0,0,1,0,0,0,0), 1593 array(0,0,0,1,1,1,0,0,0), 1594 ), 1595 array( 1596 array(0,0,0,0,0,0,0,0,0), 1597 array(0,0,0,0,0,0,0,0,0), 1598 array(0,0,0,0,0,0,0,0,0), 1599 array(0,0,0,0,0,0,0,0,0), 1600 array(0,0,0,1,0,0,0,0,1), 1601 array(0,0,0,1,1,0,0,0,1), 1602 array(0,0,0,0,1,0,0,1,1), 1603 array(0,0,0,0,1,1,0,1,0), 1604 array(0,0,0,0,0,1,1,1,0), 1605 array(0,0,0,0,0,0,1,0,0), 1606 array(0,0,0,0,0,1,1,0,0), 1607 array(0,0,0,0,0,1,0,0,0), 1608 array(0,0,0,0,1,1,0,0,0), 1609 array(0,0,1,1,1,0,0,0,0), 1610 array(0,0,0,0,0,0,0,0,0), 1611 ), 1612 ), 1613 'Z' => array( 1614 array( 1615 array(1,1,1,1,1,1,1,1,1), 1616 array(1,0,0,0,0,0,0,0,1), 1617 array(0,0,0,0,0,0,0,0,1), 1618 array(0,0,0,0,0,0,0,1,0), 1619 array(0,0,0,0,0,0,1,0,0), 1620 array(0,0,0,0,0,1,0,0,0), 1621 array(0,0,0,0,0,1,0,0,0), 1622 array(0,0,0,0,1,0,0,0,0), 1623 array(0,0,0,1,0,0,0,0,0), 1624 array(0,0,0,1,0,0,0,0,0), 1625 array(0,0,1,0,0,0,0,0,0), 1626 array(0,1,0,0,0,0,0,0,0), 1627 array(1,0,0,0,0,0,0,0,0), 1628 array(1,0,0,0,0,0,0,0,1), 1629 array(1,1,1,1,1,1,1,1,1), 1630 ), 1631 array( 1632 array(1,1,1,1,1,1,1,1,1), 1633 array(0,0,0,0,0,0,0,0,1), 1634 array(0,0,0,0,0,0,0,0,1), 1635 array(0,0,0,0,0,0,0,1,0), 1636 array(0,0,0,0,0,0,1,0,0), 1637 array(0,0,0,0,0,1,0,0,0), 1638 array(0,0,0,0,0,1,0,0,0), 1639 array(0,0,1,1,1,1,1,0,0), 1640 array(0,0,0,1,0,0,0,0,0), 1641 array(0,0,0,1,0,0,0,0,0), 1642 array(0,0,1,0,0,0,0,0,0), 1643 array(0,1,0,0,0,0,0,0,0), 1644 array(1,0,0,0,0,0,0,0,0), 1645 array(1,0,0,0,0,0,0,0,0), 1646 array(1,1,1,1,1,1,1,1,1), 1647 ), 1648 array( 1649 array(0,0,0,0,0,0,0,0,0), 1650 array(0,0,0,0,0,0,0,0,0), 1651 array(0,0,0,0,0,0,0,0,0), 1652 array(0,0,0,0,0,0,0,0,0), 1653 array(0,0,0,0,0,0,0,0,0), 1654 array(0,0,0,0,0,0,0,0,0), 1655 array(0,0,0,0,0,0,0,0,0), 1656 array(0,0,0,0,0,0,0,0,0), 1657 array(0,1,1,1,1,1,1,1,0), 1658 array(0,0,0,0,0,1,1,0,0), 1659 array(0,0,0,0,1,1,0,0,0), 1660 array(0,0,0,1,1,0,0,0,0), 1661 array(0,0,1,1,0,0,0,0,0), 1662 array(0,0,1,0,0,0,0,0,0), 1663 array(0,1,1,1,1,1,1,1,0), 1664 ), 1665 ), 1666 ); 179 1667 return array( 180 1668 'width' => 9, … … 182 1670 'data' => array( 183 1671 184 'A' => array( 185 array(0,0,0,0,1,0,0,0,0), 186 array(0,0,0,1,0,1,0,0,0), 187 array(0,0,0,1,0,1,0,0,0), 188 array(0,0,0,1,0,1,0,0,0), 189 array(0,0,1,0,0,0,1,0,0), 190 array(0,0,1,0,0,0,1,0,0), 191 array(0,0,1,0,0,0,1,0,0), 192 array(0,1,0,0,0,0,0,1,0), 193 array(0,1,0,0,0,0,0,1,0), 194 array(0,1,1,1,1,1,1,1,0), 195 array(0,1,0,0,0,0,0,1,0), 196 array(1,0,0,0,0,0,0,0,1), 197 array(1,0,0,0,0,0,0,0,1), 198 array(1,0,0,0,0,0,0,0,1), 199 array(1,0,0,0,0,0,0,0,1), 200 ), 201 'B' => array( 202 array(1,1,1,1,1,1,1,0,0), 203 array(1,0,0,0,0,0,0,1,0), 204 array(1,0,0,0,0,0,0,0,1), 205 array(1,0,0,0,0,0,0,0,1), 206 array(1,0,0,0,0,0,0,0,1), 207 array(1,0,0,0,0,0,0,0,1), 208 array(1,0,0,0,0,0,0,1,0), 209 array(1,1,1,1,1,1,1,0,0), 210 array(1,0,0,0,0,0,0,1,0), 211 array(1,0,0,0,0,0,0,0,1), 212 array(1,0,0,0,0,0,0,0,1), 213 array(1,0,0,0,0,0,0,0,1), 214 array(1,0,0,0,0,0,0,0,1), 215 array(1,0,0,0,0,0,0,1,0), 216 array(1,1,1,1,1,1,1,0,0), 217 ), 218 'C' => array( 219 array(0,0,1,1,1,1,1,0,0), 220 array(0,1,0,0,0,0,0,1,0), 221 array(1,0,0,0,0,0,0,0,1), 222 array(1,0,0,0,0,0,0,0,1), 223 array(1,0,0,0,0,0,0,0,0), 224 array(1,0,0,0,0,0,0,0,0), 225 array(1,0,0,0,0,0,0,0,0), 226 array(1,0,0,0,0,0,0,0,0), 227 array(1,0,0,0,0,0,0,0,0), 228 array(1,0,0,0,0,0,0,0,0), 229 array(1,0,0,0,0,0,0,0,0), 230 array(1,0,0,0,0,0,0,0,1), 231 array(1,0,0,0,0,0,0,0,1), 232 array(0,1,0,0,0,0,0,1,0), 233 array(0,0,1,1,1,1,1,0,0), 234 ), 235 'D' => array( 236 array(1,1,1,1,1,1,1,0,0), 237 array(1,0,0,0,0,0,0,1,0), 238 array(1,0,0,0,0,0,0,0,1), 239 array(1,0,0,0,0,0,0,0,1), 240 array(1,0,0,0,0,0,0,0,1), 241 array(1,0,0,0,0,0,0,0,1), 242 array(1,0,0,0,0,0,0,0,1), 243 array(1,0,0,0,0,0,0,0,1), 244 array(1,0,0,0,0,0,0,0,1), 245 array(1,0,0,0,0,0,0,0,1), 246 array(1,0,0,0,0,0,0,0,1), 247 array(1,0,0,0,0,0,0,0,1), 248 array(1,0,0,0,0,0,0,0,1), 249 array(1,0,0,0,0,0,0,1,0), 250 array(1,1,1,1,1,1,1,0,0), 251 ), 252 'E' => array( 253 array(1,1,1,1,1,1,1,1,1), 254 array(1,0,0,0,0,0,0,0,0), 255 array(1,0,0,0,0,0,0,0,0), 256 array(1,0,0,0,0,0,0,0,0), 257 array(1,0,0,0,0,0,0,0,0), 258 array(1,0,0,0,0,0,0,0,0), 259 array(1,0,0,0,0,0,0,0,0), 260 array(1,1,1,1,1,1,1,1,0), 261 array(1,0,0,0,0,0,0,0,0), 262 array(1,0,0,0,0,0,0,0,0), 263 array(1,0,0,0,0,0,0,0,0), 264 array(1,0,0,0,0,0,0,0,0), 265 array(1,0,0,0,0,0,0,0,0), 266 array(1,0,0,0,0,0,0,0,0), 267 array(1,1,1,1,1,1,1,1,1), 268 ), 269 'F' => array( 270 array(1,1,1,1,1,1,1,1,1), 271 array(1,0,0,0,0,0,0,0,0), 272 array(1,0,0,0,0,0,0,0,0), 273 array(1,0,0,0,0,0,0,0,0), 274 array(1,0,0,0,0,0,0,0,0), 275 array(1,0,0,0,0,0,0,0,0), 276 array(1,0,0,0,0,0,0,0,0), 277 array(1,1,1,1,1,1,1,0,0), 278 array(1,0,0,0,0,0,0,0,0), 279 array(1,0,0,0,0,0,0,0,0), 280 array(1,0,0,0,0,0,0,0,0), 281 array(1,0,0,0,0,0,0,0,0), 282 array(1,0,0,0,0,0,0,0,0), 283 array(1,0,0,0,0,0,0,0,0), 284 array(1,0,0,0,0,0,0,0,0), 285 ), 286 'G' => array( 287 array(0,0,1,1,1,1,1,0,0), 288 array(0,1,0,0,0,0,0,1,0), 289 array(1,0,0,0,0,0,0,0,1), 290 array(1,0,0,0,0,0,0,0,0), 291 array(1,0,0,0,0,0,0,0,0), 292 array(1,0,0,0,0,0,0,0,0), 293 array(1,0,0,0,0,0,0,0,0), 294 array(1,0,0,0,0,0,0,0,0), 295 array(1,0,0,0,0,0,1,1,1), 296 array(1,0,0,0,0,0,0,0,1), 297 array(1,0,0,0,0,0,0,0,1), 298 array(1,0,0,0,0,0,0,0,1), 299 array(1,0,0,0,0,0,0,0,1), 300 array(0,1,0,0,0,0,0,1,0), 301 array(0,0,1,1,1,1,1,0,0), 302 ), 303 'H' => array( 304 array(1,0,0,0,0,0,0,0,1), 305 array(1,0,0,0,0,0,0,0,1), 306 array(1,0,0,0,0,0,0,0,1), 307 array(1,0,0,0,0,0,0,0,1), 308 array(1,0,0,0,0,0,0,0,1), 309 array(1,0,0,0,0,0,0,0,1), 310 array(1,0,0,0,0,0,0,0,1), 311 array(1,1,1,1,1,1,1,1,1), 312 array(1,0,0,0,0,0,0,0,1), 313 array(1,0,0,0,0,0,0,0,1), 314 array(1,0,0,0,0,0,0,0,1), 315 array(1,0,0,0,0,0,0,0,1), 316 array(1,0,0,0,0,0,0,0,1), 317 array(1,0,0,0,0,0,0,0,1), 318 array(1,0,0,0,0,0,0,0,1), 319 ), 320 'I' => array( 321 array(1,1,1,1,1,1,1,1,1), 322 array(0,0,0,0,1,0,0,0,0), 323 array(0,0,0,0,1,0,0,0,0), 324 array(0,0,0,0,1,0,0,0,0), 325 array(0,0,0,0,1,0,0,0,0), 326 array(0,0,0,0,1,0,0,0,0), 327 array(0,0,0,0,1,0,0,0,0), 328 array(0,0,0,0,1,0,0,0,0), 329 array(0,0,0,0,1,0,0,0,0), 330 array(0,0,0,0,1,0,0,0,0), 331 array(0,0,0,0,1,0,0,0,0), 332 array(0,0,0,0,1,0,0,0,0), 333 array(0,0,0,0,1,0,0,0,0), 334 array(0,0,0,0,1,0,0,0,0), 335 array(1,1,1,1,1,1,1,1,1), 336 ), 337 'J' => array( 338 array(1,1,1,1,1,1,1,1,1), 339 array(0,0,0,0,0,1,0,0,0), 340 array(0,0,0,0,0,1,0,0,0), 341 array(0,0,0,0,0,1,0,0,0), 342 array(0,0,0,0,0,1,0,0,0), 343 array(0,0,0,0,0,1,0,0,0), 344 array(0,0,0,0,0,1,0,0,0), 345 array(0,0,0,0,0,1,0,0,0), 346 array(0,0,0,0,0,1,0,0,0), 347 array(0,0,0,0,0,1,0,0,0), 348 array(0,0,0,0,0,1,0,0,0), 349 array(1,0,0,0,0,1,0,0,0), 350 array(1,0,0,0,0,1,0,0,0), 351 array(0,1,0,0,1,0,0,0,0), 352 array(0,0,1,1,0,0,0,0,0), 353 ), 354 'K' => array( // New 'K', supplied by NeoThermic 355 array(1,0,0,0,0,0,0,0,1), 356 array(1,0,0,0,0,0,0,1,0), 357 array(1,0,0,0,0,0,1,0,0), 358 array(1,0,0,0,0,1,0,0,0), 359 array(1,0,0,0,1,0,0,0,0), 360 array(1,0,0,1,0,0,0,0,0), 361 array(1,0,1,0,0,0,0,0,0), 362 array(1,1,0,0,0,0,0,0,0), 363 array(1,0,1,0,0,0,0,0,0), 364 array(1,0,0,1,0,0,0,0,0), 365 array(1,0,0,0,1,0,0,0,0), 366 array(1,0,0,0,0,1,0,0,0), 367 array(1,0,0,0,0,0,1,0,0), 368 array(1,0,0,0,0,0,0,1,0), 369 array(1,0,0,0,0,0,0,0,1), 370 ), 371 'L' => array( 372 array(0,0,0,0,0,0,0,0,0), 373 array(1,0,0,0,0,0,0,0,0), 374 array(1,0,0,0,0,0,0,0,0), 375 array(1,0,0,0,0,0,0,0,0), 376 array(1,0,0,0,0,0,0,0,0), 377 array(1,0,0,0,0,0,0,0,0), 378 array(1,0,0,0,0,0,0,0,0), 379 array(1,0,0,0,0,0,0,0,0), 380 array(1,0,0,0,0,0,0,0,0), 381 array(1,0,0,0,0,0,0,0,0), 382 array(1,0,0,0,0,0,0,0,0), 383 array(1,0,0,0,0,0,0,0,0), 384 array(1,0,0,0,0,0,0,0,0), 385 array(1,0,0,0,0,0,0,0,0), 386 array(1,1,1,1,1,1,1,1,1), 387 ), 388 'M' => array( 389 array(1,1,0,0,0,0,0,1,1), 390 array(1,1,0,0,0,0,0,1,1), 391 array(1,0,1,0,0,0,1,0,1), 392 array(1,0,1,0,0,0,1,0,1), 393 array(1,0,1,0,0,0,1,0,1), 394 array(1,0,0,1,0,1,0,0,1), 395 array(1,0,0,1,0,1,0,0,1), 396 array(1,0,0,1,0,1,0,0,1), 397 array(1,0,0,0,1,0,0,0,1), 398 array(1,0,0,0,1,0,0,0,1), 399 array(1,0,0,0,0,0,0,0,1), 400 array(1,0,0,0,0,0,0,0,1), 401 array(1,0,0,0,0,0,0,0,1), 402 array(1,0,0,0,0,0,0,0,1), 403 array(1,0,0,0,0,0,0,0,1), 404 ), 405 'N' => array( 406 array(1,1,0,0,0,0,0,0,1), 407 array(1,1,0,0,0,0,0,0,1), 408 array(1,0,1,0,0,0,0,0,1), 409 array(1,0,1,0,0,0,0,0,1), 410 array(1,0,0,1,0,0,0,0,1), 411 array(1,0,0,1,0,0,0,0,1), 412 array(1,0,0,0,1,0,0,0,1), 413 array(1,0,0,0,1,0,0,0,1), 414 array(1,0,0,0,1,0,0,0,1), 415 array(1,0,0,0,0,1,0,0,1), 416 array(1,0,0,0,0,1,0,0,1), 417 array(1,0,0,0,0,0,1,0,1), 418 array(1,0,0,0,0,0,1,0,1), 419 array(1,0,0,0,0,0,0,1,1), 420 array(1,0,0,0,0,0,0,1,1), 421 ), 422 'O' => array( 423 array(0,0,1,1,1,1,1,0,0), 424 array(0,1,0,0,0,0,0,1,0), 425 array(1,0,0,0,0,0,0,0,1), 426 array(1,0,0,0,0,0,0,0,1), 427 array(1,0,0,0,0,0,0,0,1), 428 array(1,0,0,0,0,0,0,0,1), 429 array(1,0,0,0,0,0,0,0,1), 430 array(1,0,0,0,0,0,0,0,1), 431 array(1,0,0,0,0,0,0,0,1), 432 array(1,0,0,0,0,0,0,0,1), 433 array(1,0,0,0,0,0,0,0,1), 434 array(1,0,0,0,0,0,0,0,1), 435 array(1,0,0,0,0,0,0,0,1), 436 array(0,1,0,0,0,0,0,1,0), 437 array(0,0,1,1,1,1,1,0,0), 438 ), 439 'P' => array( 440 array(1,1,1,1,1,1,1,0,0), 441 array(1,0,0,0,0,0,0,1,0), 442 array(1,0,0,0,0,0,0,0,1), 443 array(1,0,0,0,0,0,0,0,1), 444 array(1,0,0,0,0,0,0,0,1), 445 array(1,0,0,0,0,0,0,0,1), 446 array(1,0,0,0,0,0,0,1,0), 447 array(1,1,1,1,1,1,1,0,0), 448 array(1,0,0,0,0,0,0,0,0), 449 array(1,0,0,0,0,0,0,0,0), 450 array(1,0,0,0,0,0,0,0,0), 451 array(1,0,0,0,0,0,0,0,0), 452 array(1,0,0,0,0,0,0,0,0), 453 array(1,0,0,0,0,0,0,0,0), 454 array(1,0,0,0,0,0,0,0,0), 455 ), 456 'Q' => array( 457 array(0,0,1,1,1,1,1,0,0), 458 array(0,1,0,0,0,0,0,1,0), 459 array(1,0,0,0,0,0,0,0,1), 460 array(1,0,0,0,0,0,0,0,1), 461 array(1,0,0,0,0,0,0,0,1), 462 array(1,0,0,0,0,0,0,0,1), 463 array(1,0,0,0,0,0,0,0,1), 464 array(1,0,0,0,0,0,0,0,1), 465 array(1,0,0,0,0,0,0,0,1), 466 array(1,0,0,0,0,0,0,0,1), 467 array(1,0,0,0,0,0,0,0,1), 468 array(1,0,0,0,0,1,0,0,1), 469 array(1,0,0,0,0,0,1,0,1), 470 array(0,1,0,0,0,0,0,1,0), 471 array(0,0,1,1,1,1,1,0,1), 472 ), 473 'R' => array( 474 array(1,1,1,1,1,1,1,0,0), 475 array(1,0,0,0,0,0,0,1,0), 476 array(1,0,0,0,0,0,0,0,1), 477 array(1,0,0,0,0,0,0,0,1), 478 array(1,0,0,0,0,0,0,0,1), 479 array(1,0,0,0,0,0,0,0,1), 480 array(1,0,0,0,0,0,0,1,0), 481 array(1,1,1,1,1,1,1,0,0), 482 array(1,1,1,0,0,0,0,0,0), 483 array(1,0,0,1,0,0,0,0,0), 484 array(1,0,0,0,1,0,0,0,0), 485 array(1,0,0,0,0,1,0,0,0), 486 array(1,0,0,0,0,0,1,0,0), 487 array(1,0,0,0,0,0,0,1,0), 488 array(1,0,0,0,0,0,0,0,1), 489 ), 490 'S' => array( 491 array(0,0,1,1,1,1,1,0,0), 492 array(0,1,0,0,0,0,0,1,0), 493 array(1,0,0,0,0,0,0,0,1), 494 array(1,0,0,0,0,0,0,0,0), 495 array(1,0,0,0,0,0,0,0,0), 496 array(1,0,0,0,0,0,0,0,0), 497 array(0,1,0,0,0,0,0,0,0), 498 array(0,0,1,1,1,1,1,0,0), 499 array(0,0,0,0,0,0,0,1,0), 500 array(0,0,0,0,0,0,0,0,1), 501 array(0,0,0,0,0,0,0,0,1), 502 array(0,0,0,0,0,0,0,0,1), 503 array(1,0,0,0,0,0,0,0,1), 504 array(0,1,0,0,0,0,0,1,0), 505 array(0,0,1,1,1,1,1,0,0), 506 ), 507 'T' => array( 508 array(1,1,1,1,1,1,1,1,1), 509 array(0,0,0,0,1,0,0,0,0), 510 array(0,0,0,0,1,0,0,0,0), 511 array(0,0,0,0,1,0,0,0,0), 512 array(0,0,0,0,1,0,0,0,0), 513 array(0,0,0,0,1,0,0,0,0), 514 array(0,0,0,0,1,0,0,0,0), 515 array(0,0,0,0,1,0,0,0,0), 516 array(0,0,0,0,1,0,0,0,0), 517 array(0,0,0,0,1,0,0,0,0), 518 array(0,0,0,0,1,0,0,0,0), 519 array(0,0,0,0,1,0,0,0,0), 520 array(0,0,0,0,1,0,0,0,0), 521 array(0,0,0,0,1,0,0,0,0), 522 array(0,0,0,0,1,0,0,0,0), 523 ), 524 'U' => array( 525 array(1,0,0,0,0,0,0,0,1), 526 array(1,0,0,0,0,0,0,0,1), 527 array(1,0,0,0,0,0,0,0,1), 528 array(1,0,0,0,0,0,0,0,1), 529 array(1,0,0,0,0,0,0,0,1), 530 array(1,0,0,0,0,0,0,0,1), 531 array(1,0,0,0,0,0,0,0,1), 532 array(1,0,0,0,0,0,0,0,1), 533 array(1,0,0,0,0,0,0,0,1), 534 array(1,0,0,0,0,0,0,0,1), 535 array(1,0,0,0,0,0,0,0,1), 536 array(1,0,0,0,0,0,0,0,1), 537 array(1,0,0,0,0,0,0,0,1), 538 array(0,1,0,0,0,0,0,1,0), 539 array(0,0,1,1,1,1,1,0,0), 540 ), 541 'V' => array( 542 array(1,0,0,0,0,0,0,0,1), 543 array(1,0,0,0,0,0,0,0,1), 544 array(1,0,0,0,0,0,0,0,1), 545 array(0,1,0,0,0,0,0,1,0), 546 array(0,1,0,0,0,0,0,1,0), 547 array(0,1,0,0,0,0,0,1,0), 548 array(0,0,1,0,0,0,1,0,0), 549 array(0,0,1,0,0,0,1,0,0), 550 array(0,0,1,0,0,0,1,0,0), 551 array(0,0,1,0,0,0,1,0,0), 552 array(0,0,0,1,0,1,0,0,0), 553 array(0,0,0,1,0,1,0,0,0), 554 array(0,0,0,1,0,1,0,0,0), 555 array(0,0,0,0,1,0,0,0,0), 556 array(0,0,0,0,1,0,0,0,0), 557 ), 558 'W' => array( // New 'W', supplied by MHobbit 559 array(1,0,0,0,0,0,0,0,1), 560 array(1,0,0,0,0,0,0,0,1), 561 array(1,0,0,0,0,0,0,0,1), 562 array(1,0,0,0,0,0,0,0,1), 563 array(1,0,0,0,0,0,0,0,1), 564 array(1,0,0,0,1,0,0,0,1), 565 array(1,0,0,0,1,0,0,0,1), 566 array(1,0,0,1,0,1,0,0,1), 567 array(1,0,0,1,0,1,0,0,1), 568 array(1,0,0,1,0,1,0,0,1), 569 array(1,0,1,0,0,0,1,0,1), 570 array(1,0,1,0,0,0,1,0,1), 571 array(1,0,1,0,0,0,1,0,1), 572 array(1,1,0,0,0,0,0,1,1), 573 array(1,1,0,0,0,0,0,1,1), 574 ), 575 'X' => array( 576 array(1,0,0,0,0,0,0,0,1), 577 array(1,0,0,0,0,0,0,0,1), 578 array(0,1,0,0,0,0,0,1,0), 579 array(0,1,0,0,0,0,0,1,0), 580 array(0,0,1,0,0,0,1,0,0), 581 array(0,0,0,1,0,1,0,0,0), 582 array(0,0,0,1,0,1,0,0,0), 583 array(0,0,0,0,1,0,0,0,0), 584 array(0,0,0,1,0,1,0,0,0), 585 array(0,0,0,1,0,1,0,0,0), 586 array(0,0,1,0,0,0,1,0,0), 587 array(0,1,0,0,0,0,1,0,0), 588 array(0,1,0,0,0,0,0,1,0), 589 array(1,0,0,0,0,0,0,0,1), 590 array(1,0,0,0,0,0,0,0,1), 591 ), 592 'Y' => array( 593 array(1,0,0,0,0,0,0,0,1), 594 array(1,0,0,0,0,0,0,0,1), 595 array(0,1,0,0,0,0,0,1,0), 596 array(0,1,0,0,0,0,0,1,0), 597 array(0,0,1,0,0,0,1,0,0), 598 array(0,0,1,0,0,0,1,0,0), 599 array(0,0,0,1,0,1,0,0,0), 600 array(0,0,0,0,1,0,0,0,0), 601 array(0,0,0,0,1,0,0,0,0), 602 array(0,0,0,0,1,0,0,0,0), 603 array(0,0,0,0,1,0,0,0,0), 604 array(0,0,0,0,1,0,0,0,0), 605 array(0,0,0,0,1,0,0,0,0), 606 array(0,0,0,0,1,0,0,0,0), 607 array(0,0,0,0,1,0,0,0,0), 608 ), 609 'Z' => array( // New 'Z' supplied by Anon 610 array(1,1,1,1,1,1,1,1,1), 611 array(1,0,0,0,0,0,0,0,1), 612 array(0,0,0,0,0,0,0,0,1), 613 array(0,0,0,0,0,0,0,1,0), 614 array(0,0,0,0,0,0,1,0,0), 615 array(0,0,0,0,0,1,0,0,0), 616 array(0,0,0,0,0,1,0,0,0), 617 array(0,0,0,0,1,0,0,0,0), 618 array(0,0,0,1,0,0,0,0,0), 619 array(0,0,0,1,0,0,0,0,0), 620 array(0,0,1,0,0,0,0,0,0), 621 array(0,1,0,0,0,0,0,0,0), 622 array(1,0,0,0,0,0,0,0,0), 623 array(1,0,0,0,0,0,0,0,1), 624 array(1,1,1,1,1,1,1,1,1), 625 ), 1672 'A' => $chars['A'][mt_rand(0, min(count($chars['A']), $config['captcha_gd_fonts']) -1)], 1673 'B' => $chars['B'][mt_rand(0, min(count($chars['B']), $config['captcha_gd_fonts']) -1)], 1674 'C' => $chars['C'][mt_rand(0, min(count($chars['C']), $config['captcha_gd_fonts']) -1)], 1675 'D' => $chars['D'][mt_rand(0, min(count($chars['D']), $config['captcha_gd_fonts']) -1)], 1676 'E' => $chars['E'][mt_rand(0, min(count($chars['E']), $config['captcha_gd_fonts']) -1)], 1677 'F' => $chars['F'][mt_rand(0, min(count($chars['F']), $config['captcha_gd_fonts']) -1)], 1678 'G' => $chars['G'][mt_rand(0, min(count($chars['G']), $config['captcha_gd_fonts']) -1)], 1679 'H' => $chars['H'][mt_rand(0, min(count($chars['H']), $config['captcha_gd_fonts']) -1)], 1680 'I' => $chars['I'][mt_rand(0, min(count($chars['I']), $config['captcha_gd_fonts']) -1)], 1681 'J' => $chars['J'][mt_rand(0, min(count($chars['J']), $config['captcha_gd_fonts']) -1)], 1682 'K' => $chars['K'][mt_rand(0, min(count($chars['K']), $config['captcha_gd_fonts']) -1)], 1683 'L' => $chars['L'][mt_rand(0, min(count($chars['L']), $config['captcha_gd_fonts']) -1)], 1684 'M' => $chars['M'][mt_rand(0, min(count($chars['M']), $config['captcha_gd_fonts']) -1)], 1685 'N' => $chars['N'][mt_rand(0, min(count($chars['N']), $config['captcha_gd_fonts']) -1)], 1686 'O' => $chars['O'][mt_rand(0, min(count($chars['O']), $config['captcha_gd_fonts']) -1)], 1687 'P' => $chars['P'][mt_rand(0, min(count($chars['P']), $config['captcha_gd_fonts']) -1)], 1688 'Q' => $chars['Q'][mt_rand(0, min(count($chars['Q']), $config['captcha_gd_fonts']) -1)], 1689 'R' => $chars['R'][mt_rand(0, min(count($chars['R']), $config['captcha_gd_fonts']) -1)], 1690 'S' => $chars['S'][mt_rand(0, min(count($chars['S']), $config['captcha_gd_fonts']) -1)], 1691 'T' => $chars['T'][mt_rand(0, min(count($chars['T']), $config['captcha_gd_fonts']) -1)], 1692 'U' => $chars['U'][mt_rand(0, min(count($chars['U']), $config['captcha_gd_fonts']) -1)], 1693 'V' => $chars['V'][mt_rand(0, min(count($chars['V']), $config['captcha_gd_fonts']) -1)], 1694 'W' => $chars['W'][mt_rand(0, min(count($chars['W']), $config['captcha_gd_fonts']) -1)], 1695 'X' => $chars['X'][mt_rand(0, min(count($chars['X']), $config['captcha_gd_fonts']) -1)], 1696 'Y' => $chars['Y'][mt_rand(0, min(count($chars['Y']), $config['captcha_gd_fonts']) -1)], 1697 'Z' => $chars['Z'][mt_rand(0, min(count($chars['Z']), $config['captcha_gd_fonts']) -1)], 1698 626 1699 '1' => array( 627 1700 array(0,0,0,1,1,0,0,0,0), -
trunk/forum/includes/constants.php
r400 r702 3 3 * 4 4 * @package phpBB3 5 * @version $Id : constants.php 9187 2008-12-12 14:47:03Z acydburn$5 * @version $Id$ 6 6 * @copyright (c) 2005 phpBB Group 7 7 * @license http://opensource.org/licenses/gpl-license.php GNU Public License … … 26 26 27 27 // phpBB Version 28 define('PHPBB_VERSION', '3.0. 4');28 define('PHPBB_VERSION', '3.0.7-PL1'); 29 29 30 30 // QA-related … … 92 92 define('FORUM_FLAG_ACTIVE_TOPICS', 16); 93 93 define('FORUM_FLAG_POST_REVIEW', 32); 94 define('FORUM_FLAG_QUICK_REPLY', 64); 95 96 // Forum Options... sequential order. Modifications should begin at number 10 (number 29 is maximum) 97 define('FORUM_OPTION_FEED_NEWS', 1); 98 define('FORUM_OPTION_FEED_EXCLUDE', 2); 94 99 95 100 // Optional text flags … … 161 166 define('NUM_CORE_BBCODES', 12); 162 167 168 // Smiley hard limit 169 define('SMILEY_LIMIT', 1000); 170 163 171 // Magic url types 164 172 define('MAGIC_URL_EMAIL', 1); … … 185 193 @define('CHMOD_WRITE', 2); 186 194 @define('CHMOD_EXECUTE', 1); 195 196 // Captcha code length 197 define('CAPTCHA_MIN_CHARS', 4); 198 define('CAPTCHA_MAX_CHARS', 7); 187 199 188 200 // Additional constants -
trunk/forum/includes/db/db_tools.php
r400 r702 3 3 * 4 4 * @package dbal 5 * @version $Id : db_tools.php 8814 2008-09-04 12:01:47Z acydburn$5 * @version $Id$ 6 6 * @copyright (c) 2007 phpBB Group 7 7 * @license http://opensource.org/licenses/gpl-license.php GNU Public License … … 31 31 var $sql_layer = ''; 32 32 33 /** 34 * @var object DB object 35 */ 36 var $db = NULL; 37 38 /** 39 * The Column types for every database we support 40 * @var array 41 */ 33 42 var $dbms_type_map = array( 34 43 'mysql_41' => array( … … 243 252 ); 244 253 245 // A list of types being unsigned for better reference in some db's 254 /** 255 * A list of types being unsigned for better reference in some db's 256 * @var array 257 */ 246 258 var $unsigned_types = array('UINT', 'UINT:', 'USINT', 'BOOL', 'TIMESTAMP'); 259 260 /** 261 * A list of supported DBMS. We change this class to support more DBMS, the DBMS itself only need to follow some rules. 262 * @var array 263 */ 247 264 var $supported_dbms = array('firebird', 'mssql', 'mysql_40', 'mysql_41', 'oracle', 'postgres', 'sqlite'); 248 265 249 266 /** 250 * Set this to true if you only want to return the 'to-be-executed' SQL statement(s) (as an array). 267 * This is set to true if user only wants to return the 'to-be-executed' SQL statement(s) (as an array). 268 * This mode has no effect on some methods (inserting of data for example). This is expressed within the methods command. 251 269 */ 252 270 var $return_statements = false; 253 271 254 272 /** 255 */ 256 function phpbb_db_tools(&$db) 273 * Constructor. Set DB Object and set {@link $return_statements return_statements}. 274 * 275 * @param phpbb_dbal $db DBAL object 276 * @param bool $return_statements True if only statements should be returned and no SQL being executed 277 */ 278 function phpbb_db_tools(&$db, $return_statements = false) 257 279 { 258 280 $this->db = $db; 281 $this->return_statements = $return_statements; 259 282 260 283 // Determine mapping database type … … 289 312 break; 290 313 } 314 } 315 316 /** 317 * Check if table exists 318 * 319 * 320 * @param string $table_name The table name to check for 321 * @return bool true if table exists, else false 322 */ 323 function sql_table_exists($table_name) 324 { 325 $this->db->sql_return_on_error(true); 326 $result = $this->db->sql_query_limit('SELECT * FROM ' . $table_name, 1); 327 $this->db->sql_return_on_error(false); 328 329 if ($result) 330 { 331 $this->db->sql_freeresult($result); 332 return true; 333 } 334 335 return false; 336 } 337 338 /** 339 * Create SQL Table 340 * 341 * @param string $table_name The table name to create 342 * @param array $table_data Array containing table data. 343 * @return array Statements if $return_statements is true. 344 */ 345 function sql_create_table($table_name, $table_data) 346 { 347 // holds the DDL for a column 348 $columns = $statements = array(); 349 350 if ($this->sql_table_exists($table_name)) 351 { 352 return $this->_sql_run_sql($statements); 353 } 354 355 // Begin transaction 356 $statements[] = 'begin'; 357 358 // Determine if we have created a PRIMARY KEY in the earliest 359 $primary_key_gen = false; 360 361 // Determine if the table must be created with TEXTIMAGE 362 $create_textimage = false; 363 364 // Determine if the table requires a sequence 365 $create_sequence = false; 366 367 // Begin table sql statement 368 switch ($this->sql_layer) 369 { 370 case 'mssql': 371 $table_sql = 'CREATE TABLE [' . $table_name . '] (' . "\n"; 372 break; 373 374 default: 375 $table_sql = 'CREATE TABLE ' . $table_name . ' (' . "\n"; 376 break; 377 } 378 379 // Iterate through the columns to create a table 380 foreach ($table_data['COLUMNS'] as $column_name => $column_data) 381 { 382 // here lies an array, filled with information compiled on the column's data 383 $prepared_column = $this->sql_prepare_column_data($table_name, $column_name, $column_data); 384 385 // here we add the definition of the new column to the list of columns 386 switch ($this->sql_layer) 387 { 388 case 'mssql': 389 $columns[] = "\t [{$column_name}] " . $prepared_column['column_type_sql_default']; 390 break; 391 392 default: 393 $columns[] = "\t {$column_name} " . $prepared_column['column_type_sql']; 394 break; 395 } 396 397 // see if we have found a primary key set due to a column definition if we have found it, we can stop looking 398 if (!$primary_key_gen) 399 { 400 $primary_key_gen = isset($prepared_column['primary_key_set']) && $prepared_column['primary_key_set']; 401 } 402 403 // create textimage DDL based off of the existance of certain column types 404 if (!$create_textimage) 405 { 406 $create_textimage = isset($prepared_column['textimage']) && $prepared_column['textimage']; 407 } 408 409 // create sequence DDL based off of the existance of auto incrementing columns 410 if (!$create_sequence && isset($prepared_column['auto_increment']) && $prepared_column['auto_increment']) 411 { 412 $create_sequence = $column_name; 413 } 414 } 415 416 // this makes up all the columns in the create table statement 417 $table_sql .= implode(",\n", $columns); 418 419 // Close the table for two DBMS and add to the statements 420 switch ($this->sql_layer) 421 { 422 case 'firebird': 423 $table_sql .= "\n);"; 424 $statements[] = $table_sql; 425 break; 426 427 case 'mssql': 428 $table_sql .= "\n) ON [PRIMARY]" . (($create_textimage) ? ' TEXTIMAGE_ON [PRIMARY]' : ''); 429 $statements[] = $table_sql; 430 break; 431 } 432 433 // we have yet to create a primary key for this table, 434 // this means that we can add the one we really wanted instead 435 if (!$primary_key_gen) 436 { 437 // Write primary key 438 if (isset($table_data['PRIMARY_KEY'])) 439 { 440 if (!is_array($table_data['PRIMARY_KEY'])) 441 { 442 $table_data['PRIMARY_KEY'] = array($table_data['PRIMARY_KEY']); 443 } 444 445 switch ($this->sql_layer) 446 { 447 case 'mysql_40': 448 case 'mysql_41': 449 case 'postgres': 450 case 'sqlite': 451 $table_sql .= ",\n\t PRIMARY KEY (" . implode(', ', $table_data['PRIMARY_KEY']) . ')'; 452 break; 453 454 case 'firebird': 455 case 'mssql': 456 // We need the data here 457 $old_return_statements = $this->return_statements; 458 $this->return_statements = true; 459 460 $primary_key_stmts = $this->sql_create_primary_key($table_name, $table_data['PRIMARY_KEY']); 461 foreach ($primary_key_stmts as $pk_stmt) 462 { 463 $statements[] = $pk_stmt; 464 } 465 466 $this->return_statements = $old_return_statements; 467 break; 468 469 case 'oracle': 470 $table_sql .= ",\n\t CONSTRAINT pk_{$table_name} PRIMARY KEY (" . implode(', ', $table_data['PRIMARY_KEY']) . ')'; 471 break; 472 } 473 } 474 } 475 476 // close the table 477 switch ($this->sql_layer) 478 { 479 case 'mysql_41': 480 // make sure the table is in UTF-8 mode 481 $table_sql .= "\n) CHARACTER SET `utf8` COLLATE `utf8_bin`;"; 482 $statements[] = $table_sql; 483 break; 484 485 case 'mysql_40': 486 case 'sqlite': 487 $table_sql .= "\n);"; 488 $statements[] = $table_sql; 489 break; 490 491 case 'postgres': 492 // do we need to add a sequence for auto incrementing columns? 493 if ($create_sequence) 494 { 495 $statements[] = "CREATE SEQUENCE {$table_name}_seq;"; 496 } 497 498 $table_sql .= "\n);"; 499 $statements[] = $table_sql; 500 break; 501 502 case 'oracle': 503 $table_sql .= "\n);"; 504 $statements[] = $table_sql; 505 506 // do we need to add a sequence and a tigger for auto incrementing columns? 507 if ($create_sequence) 508 { 509 // create the actual sequence 510 $statements[] = "CREATE SEQUENCE {$table_name}_seq"; 511 512 // the trigger is the mechanism by which we increment the counter 513 $trigger = "CREATE OR REPLACE TRIGGER t_{$table_name}\n"; 514 $trigger .= "BEFORE INSERT ON {$table_name}\n"; 515 $trigger .= "FOR EACH ROW WHEN (\n"; 516 $trigger .= "\tnew.{$create_sequence} IS NULL OR new.{$create_sequence} = 0\n"; 517 $trigger .= ")\n"; 518 $trigger .= "BEGIN\n"; 519 $trigger .= "\tSELECT {$table_name}_seq.nextval\n"; 520 $trigger .= "\tINTO :new.{$create_sequence}\n"; 521 $trigger .= "\tFROM dual\n"; 522 $trigger .= "END;"; 523 524 $statements[] = $trigger; 525 } 526 break; 527 528 case 'firebird': 529 if ($create_sequence) 530 { 531 $statements[] = "CREATE SEQUENCE {$table_name}_seq;"; 532 } 533 break; 534 } 535 536 // Write Keys 537 if (isset($table_data['KEYS'])) 538 { 539 foreach ($table_data['KEYS'] as $key_name => $key_data) 540 { 541 if (!is_array($key_data[1])) 542 { 543 $key_data[1] = array($key_data[1]); 544 } 545 546 $old_return_statements = $this->return_statements; 547 $this->return_statements = true; 548 549 $key_stmts = ($key_data[0] == 'UNIQUE') ? $this->sql_create_unique_index($table_name, $key_name, $key_data[1]) : $this->sql_create_index($table_name, $key_name, $key_data[1]); 550 551 foreach ($key_stmts as $key_stmt) 552 { 553 $statements[] = $key_stmt; 554 } 555 556 $this->return_statements = $old_return_statements; 557 } 558 } 559 560 // Commit Transaction 561 $statements[] = 'commit'; 562 563 return $this->_sql_run_sql($statements); 291 564 } 292 565 … … 309 582 * ) 310 583 * 311 * For more information have a look at /develop/create_schema_files.php (only available through CVS)584 * For more information have a look at /develop/create_schema_files.php (only available through SVN) 312 585 */ 313 586 function perform_schema_changes($schema_changes) … … 319 592 320 593 $statements = array(); 594 $sqlite = false; 595 596 // For SQLite we need to perform the schema changes in a much more different way 597 if ($this->db->sql_layer == 'sqlite' && $this->return_statements) 598 { 599 $sqlite_data = array(); 600 $sqlite = true; 601 } 321 602 322 603 // Change columns? … … 327 608 foreach ($columns as $column_name => $column_data) 328 609 { 329 $result = $this->sql_column_change($table, $column_name, $column_data); 330 331 if ($this->return_statements) 610 // If the column exists we change it, else we add it ;) 611 if ($column_exists = $this->sql_column_exists($table, $column_name)) 612 { 613 $result = $this->sql_column_change($table, $column_name, $column_data, true); 614 } 615 else 616 { 617 $result = $this->sql_column_add($table, $column_name, $column_data, true); 618 } 619 620 if ($sqlite) 621 { 622 if ($column_exists) 623 { 624 $sqlite_data[$table]['change_columns'][] = $result; 625 } 626 else 627 { 628 $sqlite_data[$table]['add_columns'][] = $result; 629 } 630 } 631 else if ($this->return_statements) 332 632 { 333 633 $statements = array_merge($statements, $result); … … 344 644 foreach ($columns as $column_name => $column_data) 345 645 { 346 // Only add the column if it does not exist yet 347 if (!$this->sql_column_exists($table, $column_name)) 348 { 349 $result = $this->sql_column_add($table, $column_name, $column_data); 350 351 if ($this->return_statements) 646 // Only add the column if it does not exist yet, else change it (to be consistent) 647 if ($column_exists = $this->sql_column_exists($table, $column_name)) 648 { 649 $result = $this->sql_column_change($table, $column_name, $column_data, true); 650 } 651 else 652 { 653 $result = $this->sql_column_add($table, $column_name, $column_data, true); 654 } 655 656 if ($sqlite) 657 { 658 if ($column_exists) 659 { 660 $sqlite_data[$table]['change_columns'][] = $result; 661 } 662 else 663 { 664 $sqlite_data[$table]['add_columns'][] = $result; 665 } 666 } 667 else if ($this->return_statements) 668 { 669 $statements = array_merge($statements, $result); 670 } 671 } 672 } 673 } 674 675 // Remove keys? 676 if (!empty($schema_changes['drop_keys'])) 677 { 678 foreach ($schema_changes['drop_keys'] as $table => $indexes) 679 { 680 foreach ($indexes as $index_name) 681 { 682 $result = $this->sql_index_drop($table, $index_name); 683 684 if ($this->return_statements) 685 { 686 $statements = array_merge($statements, $result); 687 } 688 } 689 } 690 } 691 692 // Drop columns? 693 if (!empty($schema_changes['drop_columns'])) 694 { 695 foreach ($schema_changes['drop_columns'] as $table => $columns) 696 { 697 foreach ($columns as $column) 698 { 699 // Only remove the column if it exists... 700 if ($this->sql_column_exists($table, $column)) 701 { 702 $result = $this->sql_column_remove($table, $column, true); 703 704 if ($sqlite) 705 { 706 $sqlite_data[$table]['drop_columns'][] = $result; 707 } 708 else if ($this->return_statements) 352 709 { 353 710 $statements = array_merge($statements, $result); … … 358 715 } 359 716 360 // Remove keys?361 if (!empty($schema_changes['drop_keys']))362 {363 foreach ($schema_changes['drop_keys'] as $table => $indexes)364 {365 foreach ($indexes as $index_name)366 {367 $result = $this->sql_index_drop($table, $index_name);368 369 if ($this->return_statements)370 {371 $statements = array_merge($statements, $result);372 }373 }374 }375 }376 377 // Drop columns?378 if (!empty($schema_changes['drop_columns']))379 {380 foreach ($schema_changes['drop_columns'] as $table => $columns)381 {382 foreach ($columns as $column)383 {384 $result = $this->sql_column_remove($table, $column);385 386 if ($this->return_statements)387 {388 $statements = array_merge($statements, $result);389 }390 }391 }392 }393 394 717 // Add primary keys? 395 718 if (!empty($schema_changes['add_primary_keys'])) … … 397 720 foreach ($schema_changes['add_primary_keys'] as $table => $columns) 398 721 { 399 $result = $this->sql_create_primary_key($table, $columns); 400 401 if ($this->return_statements) 722 $result = $this->sql_create_primary_key($table, $columns, true); 723 724 if ($sqlite) 725 { 726 $sqlite_data[$table]['primary_key'] = $result; 727 } 728 else if ($this->return_statements) 402 729 { 403 730 $statements = array_merge($statements, $result); … … 440 767 } 441 768 769 if ($sqlite) 770 { 771 foreach ($sqlite_data as $table_name => $sql_schema_changes) 772 { 773 // Create temporary table with original data 774 $statements[] = 'begin'; 775 776 $sql = "SELECT sql 777 FROM sqlite_master 778 WHERE type = 'table' 779 AND name = '{$table_name}' 780 ORDER BY type DESC, name;"; 781 $result = $this->db->sql_query($sql); 782 783 if (!$result) 784 { 785 continue; 786 } 787 788 $row = $this->db->sql_fetchrow($result); 789 $this->db->sql_freeresult($result); 790 791 // Create a backup table and populate it, destroy the existing one 792 $statements[] = preg_replace('#CREATE\s+TABLE\s+"?' . $table_name . '"?#i', 'CREATE TEMPORARY TABLE ' . $table_name . '_temp', $row['sql']); 793 $statements[] = 'INSERT INTO ' . $table_name . '_temp SELECT * FROM ' . $table_name; 794 $statements[] = 'DROP TABLE ' . $table_name; 795 796 // Get the columns... 797 preg_match('#\((.*)\)#s', $row['sql'], $matches); 798 799 $plain_table_cols = trim($matches[1]); 800 $new_table_cols = preg_split('/,(?![\s\w]+\))/m', $plain_table_cols); 801 $column_list = array(); 802 803 foreach ($new_table_cols as $declaration) 804 { 805 $entities = preg_split('#\s+#', trim($declaration)); 806 if ($entities[0] == 'PRIMARY') 807 { 808 continue; 809 } 810 $column_list[] = $entities[0]; 811 } 812 813 // note down the primary key notation because sqlite only supports adding it to the end for the new table 814 $primary_key = false; 815 $_new_cols = array(); 816 817 foreach ($new_table_cols as $key => $declaration) 818 { 819 $entities = preg_split('#\s+#', trim($declaration)); 820 if ($entities[0] == 'PRIMARY') 821 { 822 $primary_key = $declaration; 823 continue; 824 } 825 $_new_cols[] = $declaration; 826 } 827 828 $new_table_cols = $_new_cols; 829 830 // First of all... change columns 831 if (!empty($sql_schema_changes['change_columns'])) 832 { 833 foreach ($sql_schema_changes['change_columns'] as $column_sql) 834 { 835 foreach ($new_table_cols as $key => $declaration) 836 { 837 $entities = preg_split('#\s+#', trim($declaration)); 838 if (strpos($column_sql, $entities[0] . ' ') === 0) 839 { 840 $new_table_cols[$key] = $column_sql; 841 } 842 } 843 } 844 } 845 846 if (!empty($sql_schema_changes['add_columns'])) 847 { 848 foreach ($sql_schema_changes['add_columns'] as $column_sql) 849 { 850 $new_table_cols[] = $column_sql; 851 } 852 } 853 854 // Now drop them... 855 if (!empty($sql_schema_changes['drop_columns'])) 856 { 857 foreach ($sql_schema_changes['drop_columns'] as $column_name) 858 { 859 // Remove from column list... 860 $new_column_list = array(); 861 foreach ($column_list as $key => $value) 862 { 863 if ($value === $column_name) 864 { 865 continue; 866 } 867 868 $new_column_list[] = $value; 869 } 870 871 $column_list = $new_column_list; 872 873 // Remove from table... 874 $_new_cols = array(); 875 foreach ($new_table_cols as $key => $declaration) 876 { 877 $entities = preg_split('#\s+#', trim($declaration)); 878 if (strpos($column_name . ' ', $entities[0] . ' ') === 0) 879 { 880 continue; 881 } 882 $_new_cols[] = $declaration; 883 } 884 $new_table_cols = $_new_cols; 885 } 886 } 887 888 // Primary key... 889 if (!empty($sql_schema_changes['primary_key'])) 890 { 891 $new_table_cols[] = 'PRIMARY KEY (' . implode(', ', $sql_schema_changes['primary_key']) . ')'; 892 } 893 // Add a new one or the old primary key 894 else if ($primary_key !== false) 895 { 896 $new_table_cols[] = $primary_key; 897 } 898 899 $columns = implode(',', $column_list); 900 901 // create a new table and fill it up. destroy the temp one 902 $statements[] = 'CREATE TABLE ' . $table_name . ' (' . implode(',', $new_table_cols) . ');'; 903 $statements[] = 'INSERT INTO ' . $table_name . ' (' . $columns . ') SELECT ' . $columns . ' FROM ' . $table_name . '_temp;'; 904 $statements[] = 'DROP TABLE ' . $table_name . '_temp'; 905 906 $statements[] = 'commit'; 907 } 908 } 909 442 910 if ($this->return_statements) 443 911 { … … 448 916 /** 449 917 * Check if a specified column exist 918 * 919 * @param string $table Table to check the column at 920 * @param string $column_name The column to check 921 * 450 922 * @return bool True if column exists, else false 451 923 */ … … 520 992 $sql = "SELECT column_name 521 993 FROM user_tab_columns 522 WHERE table_name = '{$table}'";994 WHERE LOWER(table_name) = '" . strtolower($table) . "'"; 523 995 $result = $this->db->sql_query($sql); 524 996 while ($row = $this->db->sql_fetchrow($result)) … … 538 1010 $sql = "SELECT RDB\$FIELD_NAME as FNAME 539 1011 FROM RDB\$RELATION_FIELDS 540 WHERE RDB\$RELATION_NAME = ' {$table}'";1012 WHERE RDB\$RELATION_NAME = '" . strtoupper($table) . "'"; 541 1013 $result = $this->db->sql_query($sql); 542 1014 while ($row = $this->db->sql_fetchrow($result)) … … 633 1105 { 634 1106 list($orig_column_type, $column_length) = explode(':', $column_data[0]); 635 636 1107 if (!is_array($this->dbms_type_map[$this->sql_layer][$orig_column_type . ':'])) 637 1108 { … … 692 1163 case 'firebird': 693 1164 $sql .= " {$column_type} "; 1165 $return_array['column_type_sql_type'] = " {$column_type} "; 694 1166 695 1167 if (!is_null($column_data[1])) 696 1168 { 697 1169 $sql .= 'DEFAULT ' . ((is_numeric($column_data[1])) ? $column_data[1] : "'{$column_data[1]}'") . ' '; 1170 $return_array['column_type_sql_default'] = ((is_numeric($column_data[1])) ? $column_data[1] : "'{$column_data[1]}'") . ' '; 698 1171 } 699 1172 … … 704 1177 { 705 1178 $sql .= ' COLLATE UNICODE'; 1179 } 1180 1181 $return_array['auto_increment'] = false; 1182 if (isset($column_data[2]) && $column_data[2] == 'auto_increment') 1183 { 1184 $return_array['auto_increment'] = true; 706 1185 } 707 1186 … … 718 1197 if (strpos($column_data[1], '0x') === 0) 719 1198 { 720 $sql_default .= 'DEFAULT (' . $column_data[1] . ') '; 1199 $return_array['default'] = 'DEFAULT (' . $column_data[1] . ') '; 1200 $sql_default .= $return_array['default']; 721 1201 } 722 1202 else 723 1203 { 724 $sql_default .= 'DEFAULT (' . ((is_numeric($column_data[1])) ? $column_data[1] : "'{$column_data[1]}'") . ') '; 725 } 726 } 1204 $return_array['default'] = 'DEFAULT (' . ((is_numeric($column_data[1])) ? $column_data[1] : "'{$column_data[1]}'") . ') '; 1205 $sql_default .= $return_array['default']; 1206 } 1207 } 1208 1209 if (isset($column_data[2]) && $column_data[2] == 'auto_increment') 1210 { 1211 // $sql .= 'IDENTITY (1, 1) '; 1212 $sql_default .= 'IDENTITY (1, 1) '; 1213 } 1214 1215 $return_array['textimage'] = $column_type === '[text]'; 727 1216 728 1217 $sql .= 'NOT NULL'; … … 730 1219 731 1220 $return_array['column_type_sql_default'] = $sql_default; 1221 732 1222 break; 733 1223 … … 764 1254 // Therefore in oracle we allow NULL's for all DEFAULT '' entries 765 1255 // Oracle does not like setting NOT NULL on a column that is already NOT NULL (this happens only on number fields) 766 if ( preg_match('/number/i', $column_type))1256 if (!preg_match('/number/i', $column_type)) 767 1257 { 768 1258 $sql .= ($column_data[1] === '') ? '' : 'NOT NULL'; 769 1259 } 1260 1261 $return_array['auto_increment'] = false; 1262 if (isset($column_data[2]) && $column_data[2] == 'auto_increment') 1263 { 1264 $return_array['auto_increment'] = true; 1265 } 1266 770 1267 break; 771 1268 … … 775 1272 $sql .= " {$column_type} "; 776 1273 1274 $return_array['auto_increment'] = false; 777 1275 if (isset($column_data[2]) && $column_data[2] == 'auto_increment') 778 1276 { 779 1277 $default_val = "nextval('{$table_name}_seq')"; 1278 $return_array['auto_increment'] = true; 780 1279 } 781 1280 else if (!is_null($column_data[1])) … … 796 1295 $sql .= " CHECK ({$column_name} >= 0)"; 797 1296 } 1297 798 1298 break; 799 1299 800 1300 case 'sqlite': 1301 $return_array['primary_key_set'] = false; 801 1302 if (isset($column_data[2]) && $column_data[2] == 'auto_increment') 802 1303 { 803 1304 $sql .= ' INTEGER PRIMARY KEY'; 1305 $return_array['primary_key_set'] = true; 804 1306 } 805 1307 else … … 810 1312 $sql .= ' NOT NULL '; 811 1313 $sql .= (!is_null($column_data[1])) ? "DEFAULT '{$column_data[1]}'" : ''; 1314 812 1315 break; 813 1316 } … … 821 1324 * Add new column 822 1325 */ 823 function sql_column_add($table_name, $column_name, $column_data )1326 function sql_column_add($table_name, $column_name, $column_data, $inline = false) 824 1327 { 825 1328 $column_data = $this->sql_prepare_column_data($table_name, $column_name, $column_data); … … 829 1332 { 830 1333 case 'firebird': 831 $statements[] = 'ALTER TABLE "' . $table_name . '" ADD "' . $column_name. '" ' . $column_data['column_type_sql'];1334 $statements[] = 'ALTER TABLE ' . $table_name . ' ADD "' . strtoupper($column_name) . '" ' . $column_data['column_type_sql']; 832 1335 break; 833 1336 … … 846 1349 847 1350 case 'postgres': 848 $statements[] = 'ALTER TABLE ' . $table_name . ' ADD COLUMN "' . $column_name . '" ' . $column_data['column_type_sql']; 1351 if (version_compare($this->db->sql_server_info(true), '8.0', '>=')) 1352 { 1353 $statements[] = 'ALTER TABLE ' . $table_name . ' ADD COLUMN "' . $column_name . '" ' . $column_data['column_type_sql']; 1354 } 1355 else 1356 { 1357 // old versions cannot add columns with default and null information 1358 $statements[] = 'ALTER TABLE ' . $table_name . ' ADD COLUMN "' . $column_name . '" ' . $column_data['column_type'] . ' ' . $column_data['constraint']; 1359 1360 if (isset($column_data['null'])) 1361 { 1362 if ($column_data['null'] == 'NOT NULL') 1363 { 1364 $statements[] = 'ALTER TABLE ' . $table_name . ' ALTER COLUMN ' . $column_name . ' SET NOT NULL'; 1365 } 1366 } 1367 1368 if (isset($column_data['default'])) 1369 { 1370 $statements[] = 'ALTER TABLE ' . $table_name . ' ALTER COLUMN ' . $column_name . ' SET DEFAULT ' . $column_data['default']; 1371 } 1372 } 1373 849 1374 break; 850 1375 851 1376 case 'sqlite': 1377 1378 if ($inline && $this->return_statements) 1379 { 1380 return $column_name . ' ' . $column_data['column_type_sql']; 1381 } 1382 852 1383 if (version_compare(sqlite_libversion(), '3.0') == -1) 853 1384 { … … 914 1445 * Drop column 915 1446 */ 916 function sql_column_remove($table_name, $column_name )1447 function sql_column_remove($table_name, $column_name, $inline = false) 917 1448 { 918 1449 $statements = array(); … … 921 1452 { 922 1453 case 'firebird': 923 $statements[] = 'ALTER TABLE "' . $table_name . '" DROP "' . $column_name. '"';1454 $statements[] = 'ALTER TABLE ' . $table_name . ' DROP "' . strtoupper($column_name) . '"'; 924 1455 break; 925 1456 … … 942 1473 943 1474 case 'sqlite': 1475 1476 if ($inline && $this->return_statements) 1477 { 1478 return $column_name; 1479 } 1480 944 1481 if (version_compare(sqlite_libversion(), '3.0') == -1) 945 1482 { … … 984 1521 $columns = implode(',', $column_list); 985 1522 986 $new_table_cols = $new_table_cols =preg_replace('/' . $column_name . '[^,]+(?:,|$)/m', '', $new_table_cols);1523 $new_table_cols = preg_replace('/' . $column_name . '[^,]+(?:,|$)/m', '', $new_table_cols); 987 1524 988 1525 // create a new table and fill it up. destroy the temp one … … 1033 1570 1034 1571 /** 1035 * Add primary key1036 */ 1037 function sql_ create_primary_key($table_name, $column)1572 * Drop Table 1573 */ 1574 function sql_table_drop($table_name) 1038 1575 { 1039 1576 $statements = array(); 1040 1577 1578 if (!$this->sql_table_exists($table_name)) 1579 { 1580 return $this->_sql_run_sql($statements); 1581 } 1582 1583 // the most basic operation, get rid of the table 1584 $statements[] = 'DROP TABLE ' . $table_name; 1585 1586 switch ($this->sql_layer) 1587 { 1588 case 'firebird': 1589 $sql = 'SELECT RDB$GENERATOR_NAME as gen 1590 FROM RDB$GENERATORS 1591 WHERE RDB$SYSTEM_FLAG = 0 1592 AND RDB$GENERATOR_NAME = \'' . strtoupper($table_name) . "_GEN'"; 1593 $result = $this->db->sql_query($sql); 1594 1595 // does a generator exist? 1596 if ($row = $this->db->sql_fetchrow($result)) 1597 { 1598 $statements[] = "DROP GENERATOR {$row['gen']};"; 1599 } 1600 $this->db->sql_freeresult($result); 1601 break; 1602 1603 case 'oracle': 1604 $sql = 'SELECT A.REFERENCED_NAME 1605 FROM USER_DEPENDENCIES A, USER_TRIGGERS B 1606 WHERE A.REFERENCED_TYPE = \'SEQUENCE\' 1607 AND A.NAME = B.TRIGGER_NAME 1608 AND B.TABLE_NAME = \'' . strtoupper($table_name) . "'"; 1609 $result = $this->db->sql_query($sql); 1610 1611 // any sequences ref'd to this table's triggers? 1612 while ($row = $this->db->sql_fetchrow($result)) 1613 { 1614 $statements[] = "DROP SEQUENCE {$row['referenced_name']}"; 1615 } 1616 $this->db->sql_freeresult($result); 1617 1618 case 'postgres': 1619 // PGSQL does not "tightly" bind sequences and tables, we must guess... 1620 $sql = "SELECT relname 1621 FROM pg_class 1622 WHERE relkind = 'S' 1623 AND relname = '{$table_name}_seq'"; 1624 $result = $this->db->sql_query($sql); 1625 1626 // We don't even care about storing the results. We already know the answer if we get rows back. 1627 if ($this->db->sql_fetchrow($result)) 1628 { 1629 $statements[] = "DROP SEQUENCE {$table_name}_seq;\n"; 1630 } 1631 $this->db->sql_freeresult($result); 1632 break; 1633 } 1634 1635 return $this->_sql_run_sql($statements); 1636 } 1637 1638 /** 1639 * Add primary key 1640 */ 1641 function sql_create_primary_key($table_name, $column, $inline = false) 1642 { 1643 $statements = array(); 1644 1041 1645 switch ($this->sql_layer) 1042 1646 { 1043 1647 case 'firebird': 1044 1648 case 'postgres': 1649 case 'mysql_40': 1650 case 'mysql_41': 1045 1651 $statements[] = 'ALTER TABLE ' . $table_name . ' ADD PRIMARY KEY (' . implode(', ', $column) . ')'; 1046 1652 break; … … 1055 1661 break; 1056 1662 1057 case 'mysql_40':1058 case 'mysql_41':1059 $statements[] = 'ALTER TABLE ' . $table_name . ' ADD PRIMARY KEY (' . implode(', ', $column) . ')';1060 break;1061 1062 1663 case 'oracle': 1063 1664 $statements[] = 'ALTER TABLE ' . $table_name . 'add CONSTRAINT pk_' . $table_name . ' PRIMARY KEY (' . implode(', ', $column) . ')'; … … 1065 1666 1066 1667 case 'sqlite': 1668 1669 if ($inline && $this->return_statements) 1670 { 1671 return $column; 1672 } 1673 1067 1674 $sql = "SELECT sql 1068 1675 FROM sqlite_master … … 1205 1812 $sql = "SELECT LOWER(RDB\$INDEX_NAME) as index_name 1206 1813 FROM RDB\$INDICES 1207 WHERE RDB\$RELATION_NAME = " . strtoupper($table_name) . "1814 WHERE RDB\$RELATION_NAME = '" . strtoupper($table_name) . "' 1208 1815 AND RDB\$UNIQUE_FLAG IS NULL 1209 1816 AND RDB\$FOREIGN_KEY IS NULL"; … … 1232 1839 $sql = "SELECT index_name 1233 1840 FROM user_indexes 1234 WHERE table_name = '" . $table_name . "' 1235 AND generated = 'N'"; 1841 WHERE table_name = '" . strtoupper($table_name) . "' 1842 AND generated = 'N' 1843 AND uniqueness = 'NONUNIQUE'"; 1844 $col = 'index_name'; 1236 1845 break; 1237 1846 … … 1271 1880 * Change column type (not name!) 1272 1881 */ 1273 function sql_column_change($table_name, $column_name, $column_data )1882 function sql_column_change($table_name, $column_name, $column_data, $inline = false) 1274 1883 { 1275 1884 $column_data = $this->sql_prepare_column_data($table_name, $column_name, $column_data); … … 1280 1889 case 'firebird': 1281 1890 // Change type... 1282 $statements[] = 'ALTER TABLE "' . $table_name . '" ALTER COLUMN "' . $column_name . '" TYPE ' . ' ' . $column_data['column_type_sql']; 1891 if (!empty($column_data['column_type_sql_default'])) 1892 { 1893 $statements[] = 'ALTER TABLE ' . $table_name . ' ALTER COLUMN "' . strtoupper($column_name) . '" TYPE ' . ' ' . $column_data['column_type_sql_type']; 1894 $statements[] = 'ALTER TABLE ' . $table_name . ' ALTER COLUMN "' . strtoupper($column_name) . '" SET DEFAULT ' . ' ' . $column_data['column_type_sql_default']; 1895 } 1896 else 1897 { 1898 $statements[] = 'ALTER TABLE ' . $table_name . ' ALTER COLUMN "' . strtoupper($column_name) . '" TYPE ' . ' ' . $column_data['column_type_sql_type']; 1899 } 1283 1900 break; 1284 1901 1285 1902 case 'mssql': 1286 1903 $statements[] = 'ALTER TABLE [' . $table_name . '] ALTER COLUMN [' . $column_name . '] ' . $column_data['column_type_sql']; 1904 1905 if (!empty($column_data['default'])) 1906 { 1907 // Using TRANSACT-SQL for this statement because we do not want to have colliding data if statements are executed at a later stage 1908 $statements[] = "DECLARE @drop_default_name VARCHAR(100), @cmd VARCHAR(1000) 1909 SET @drop_default_name = 1910 (SELECT so.name FROM sysobjects so 1911 JOIN sysconstraints sc ON so.id = sc.constid 1912 WHERE object_name(so.parent_obj) = '{$table_name}' 1913 AND so.xtype = 'D' 1914 AND sc.colid = (SELECT colid FROM syscolumns 1915 WHERE id = object_id('{$table_name}') 1916 AND name = '{$column_name}')) 1917 IF @drop_default_name <> '' 1918 BEGIN 1919 SET @cmd = 'ALTER TABLE [{$table_name}] DROP CONSTRAINT [' + @drop_default_name + ']' 1920 EXEC(@cmd) 1921 END 1922 SET @cmd = 'ALTER TABLE [{$table_name}] ADD CONSTRAINT [DF_{$table_name}_{$column_name}_1] {$column_data['default']} FOR [{$column_name}]' 1923 EXEC(@cmd)"; 1924 } 1287 1925 break; 1288 1926 … … 1361 1999 case 'sqlite': 1362 2000 2001 if ($inline && $this->return_statements) 2002 { 2003 return $column_name . ' ' . $column_data['column_type_sql']; 2004 } 2005 1363 2006 $sql = "SELECT sql 1364 2007 FROM sqlite_master -
trunk/forum/includes/db/dbal.php
r400 r702 3 3 * 4 4 * @package dbal 5 * @version $Id : dbal.php 9178 2008-12-06 11:11:10Z acydburn$5 * @version $Id$ 6 6 * @copyright (c) 2005 phpBB Group 7 7 * @license http://opensource.org/licenses/gpl-license.php GNU Public License … … 236 236 function sql_like_expression($expression) 237 237 { 238 $expression = str_replace(array('_', '%'), array("\_", "\%"), $expression);239 $expression = str_replace(array(chr(0) . "\_", chr(0) . "\%"), array('_', '%'), $expression);238 $expression = utf8_str_replace(array('_', '%'), array("\_", "\%"), $expression); 239 $expression = utf8_str_replace(array(chr(0) . "\_", chr(0) . "\%"), array('_', '%'), $expression); 240 240 241 241 return $this->_sql_like_expression('LIKE \'' . $this->sql_escape($expression) . '\''); … … 413 413 414 414 /** 415 * Run binary AND operator on DB column. 416 * Results in sql statement: "{$column_name} & (1 << {$bit}) {$compare}" 417 * 418 * @param string $column_name The column name to use 419 * @param int $bit The value to use for the AND operator, will be converted to (1 << $bit). Is used by options, using the number schema... 0, 1, 2...29 420 * @param string $compare Any custom SQL code after the check (for example "= 0") 421 */ 422 function sql_bit_and($column_name, $bit, $compare = '') 423 { 424 if (method_exists($this, '_sql_bit_and')) 425 { 426 return $this->_sql_bit_and($column_name, $bit, $compare); 427 } 428 429 return $column_name . ' & ' . (1 << $bit) . (($compare) ? ' ' . $compare : ''); 430 } 431 432 /** 433 * Run binary OR operator on DB column. 434 * Results in sql statement: "{$column_name} | (1 << {$bit}) {$compare}" 435 * 436 * @param string $column_name The column name to use 437 * @param int $bit The value to use for the OR operator, will be converted to (1 << $bit). Is used by options, using the number schema... 0, 1, 2...29 438 * @param string $compare Any custom SQL code after the check (for example "= 0") 439 */ 440 function sql_bit_or($column_name, $bit, $compare = '') 441 { 442 if (method_exists($this, '_sql_bit_or')) 443 { 444 return $this->_sql_bit_or($column_name, $bit, $compare); 445 } 446 447 return $column_name . ' | ' . (1 << $bit) . (($compare) ? ' ' . $compare : ''); 448 } 449 450 /** 415 451 * Run more than one insert statement. 416 452 * … … 436 472 if (!is_array($_sql_ary)) 437 473 { 438 $this->sql_query('INSERT INTO ' . $table . ' ' . $this->sql_build_array('INSERT', $sql_ary)); 439 return true; 474 return $this->sql_query('INSERT INTO ' . $table . ' ' . $this->sql_build_array('INSERT', $sql_ary)); 440 475 } 441 476 … … 448 483 } 449 484 450 $this->sql_query('INSERT INTO ' . $table . ' ' . ' (' . implode(', ', array_keys($sql_ary[0])) . ') VALUES ' . implode(', ', $ary));485 return $this->sql_query('INSERT INTO ' . $table . ' ' . ' (' . implode(', ', array_keys($sql_ary[0])) . ') VALUES ' . implode(', ', $ary)); 451 486 } 452 487 else … … 459 494 } 460 495 461 $this->sql_query('INSERT INTO ' . $table . ' ' . $this->sql_build_array('INSERT', $ary)); 496 $result = $this->sql_query('INSERT INTO ' . $table . ' ' . $this->sql_build_array('INSERT', $ary)); 497 498 if (!$result) 499 { 500 return false; 501 } 462 502 } 463 503 } -
trunk/forum/includes/db/firebird.php
r400 r702 3 3 * 4 4 * @package dbal 5 * @version $Id : firebird.php 8967 2008-10-02 12:04:12Z acydburn$5 * @version $Id$ 6 6 * @copyright (c) 2005 phpBB Group 7 7 * @license http://opensource.org/licenses/gpl-license.php GNU Public License … … 21 21 /** 22 22 * Firebird/Interbase Database Abstraction Layer 23 * Minimum Requirement is Firebird 2. 023 * Minimum Requirement is Firebird 2.1 24 24 * @package dbal 25 25 */ … … 73 73 } 74 74 75 return ($raw) ? '2. 0' : 'Firebird/Interbase';75 return ($raw) ? '2.1' : 'Firebird/Interbase'; 76 76 } 77 77 … … 447 447 } 448 448 449 function _sql_bit_and($column_name, $bit, $compare = '') 450 { 451 return 'BIN_AND(' . $column_name . ', ' . (1 << $bit) . ')' . (($compare) ? ' ' . $compare : ''); 452 } 453 454 function _sql_bit_or($column_name, $bit, $compare = '') 455 { 456 return 'BIN_OR(' . $column_name . ', ' . (1 << $bit) . ')' . (($compare) ? ' ' . $compare : ''); 457 } 458 449 459 /** 450 460 * return sql error array -
trunk/forum/includes/db/mysql.php
r400 r702 3 3 * 4 4 * @package dbal 5 * @version $Id : mysql.php 8815 2008-09-04 13:37:01Z acydburn$5 * @version $Id$ 6 6 * @copyright (c) 2005 phpBB Group 7 7 * @license http://opensource.org/licenses/gpl-license.php GNU Public License … … 45 45 $this->sql_layer = 'mysql4'; 46 46 47 $this->db_connect_id = ($this->persistency) ? @mysql_pconnect($this->server, $this->user, $sqlpassword , $new_link) : @mysql_connect($this->server, $this->user, $sqlpassword, $new_link);47 $this->db_connect_id = ($this->persistency) ? @mysql_pconnect($this->server, $this->user, $sqlpassword) : @mysql_connect($this->server, $this->user, $sqlpassword, $new_link); 48 48 49 49 if ($this->db_connect_id && $this->dbname != '') … … 52 52 { 53 53 // Determine what version we are using and if it natively supports UNICODE 54 if (version_compare($this->sql_server_info(true), '4.1. 3', '>='))54 if (version_compare($this->sql_server_info(true), '4.1.0', '>=')) 55 55 { 56 56 @mysql_query("SET NAMES 'utf8'", $this->db_connect_id); … … 342 342 return $data; 343 343 } 344 344 345 345 /** 346 346 * return sql error array -
trunk/forum/includes/db/oracle.php
r400 r702 3 3 * 4 4 * @package dbal 5 * @version $Id : oracle.php 9175 2008-12-05 11:18:59Z acydburn$5 * @version $Id$ 6 6 * @copyright (c) 2005 phpBB Group 7 7 * @license http://opensource.org/licenses/gpl-license.php GNU Public License … … 137 137 function _rewrite_where($where_clause) 138 138 { 139 preg_match_all('/\s*(AND|OR)?\s*([\w_. ]++)\s*(?:(=|<[=>]?|>=?)\s*((?>\'(?>[^\']++|\'\')*+\'|[\d-.]+))|((NOT )?IN\s*\((?>\'(?>[^\']++|\'\')*+\',? ?|[\d-.]+,? ?)*+\)))/', $where_clause, $result, PREG_SET_ORDER);139 preg_match_all('/\s*(AND|OR)?\s*([\w_.()]++)\s*(?:(=|<[=>]?|>=?|LIKE)\s*((?>\'(?>[^\']++|\'\')*+\'|[\d-.()]+))|((NOT )?IN\s*\((?>\'(?>[^\']++|\'\')*+\',? ?|[\d-.]+,? ?)*+\)))/', $where_clause, $result, PREG_SET_ORDER); 140 140 $out = ''; 141 141 foreach ($result as $val) … … 256 256 if (strlen($query) > 4000) 257 257 { 258 if (preg_match('/^(INSERT INTO[^(]++)\\(([^()]+)\\) VALUES[^(]++\\((.*?)\\)$/s ', $query, $regs))258 if (preg_match('/^(INSERT INTO[^(]++)\\(([^()]+)\\) VALUES[^(]++\\((.*?)\\)$/sU', $query, $regs)) 259 259 { 260 260 if (strlen($regs[3]) > 4000) 261 261 { 262 262 $cols = explode(', ', $regs[2]); 263 263 264 preg_match_all('/\'(?:[^\']++|\'\')*+\'|[\d-.]+/', $regs[3], $vals, PREG_PATTERN_ORDER); 265 266 if (sizeof($cols) !== sizeof($vals)) 267 { 268 // Try to replace some common data we know is from our restore script or from other sources 269 $regs[3] = str_replace("'||chr(47)||'", '/', $regs[3]); 270 $_vals = explode(', ', $regs[3]); 271 272 $vals = array(); 273 $is_in_val = false; 274 $i = 0; 275 $string = ''; 276 277 foreach ($_vals as $value) 278 { 279 if (strpos($value, "'") === false && !$is_in_val) 280 { 281 $vals[$i++] = $value; 282 continue; 283 } 284 285 if (substr($value, -1) === "'") 286 { 287 $vals[$i] = $string . (($is_in_val) ? ', ' : '') . $value; 288 $string = ''; 289 $is_in_val = false; 290 291 if ($vals[$i][0] !== "'") 292 { 293 $vals[$i] = "''" . $vals[$i]; 294 } 295 $i++; 296 continue; 297 } 298 else 299 { 300 $string .= (($is_in_val) ? ', ' : '') . $value; 301 $is_in_val = true; 302 } 303 } 304 305 if ($string) 306 { 307 // New value if cols != value 308 $vals[(sizeof($cols) !== sizeof($vals)) ? $i : $i - 1] .= $string; 309 } 310 311 $vals = array(0 => $vals); 312 } 264 313 265 314 $inserts = $vals[0]; … … 569 618 } 570 619 620 function _sql_bit_and($column_name, $bit, $compare = '') 621 { 622 return 'BITAND(' . $column_name . ', ' . (1 << $bit) . ')' . (($compare) ? ' ' . $compare : ''); 623 } 624 625 function _sql_bit_or($column_name, $bit, $compare = '') 626 { 627 return 'BITOR(' . $column_name . ', ' . (1 << $bit) . ')' . (($compare) ? ' ' . $compare : ''); 628 } 629 571 630 /** 572 631 * return sql error array -
trunk/forum/includes/db/postgres.php
r400 r702 3 3 * 4 4 * @package dbal 5 * @version $Id : postgres.php 8814 2008-09-04 12:01:47Z acydburn$5 * @version $Id$ 6 6 * @copyright (c) 2005 phpBB Group 7 7 * @license http://opensource.org/licenses/gpl-license.php GNU Public License … … 27 27 { 28 28 var $last_query_text = ''; 29 29 30 30 /** 31 31 * Connect to server … … 56 56 $connect_string .= "host=$sqlserver "; 57 57 } 58 58 59 59 if ($port) 60 60 { … … 225 225 if ($total == 0) 226 226 { 227 $total = -1;227 $total = 'ALL'; 228 228 } 229 229 -
trunk/forum/includes/diff/diff.php
r400 r702 3 3 * 4 4 * @package diff 5 * @version $Id : diff.php 8765 2008-08-16 22:18:25Z aptx$5 * @version $Id$ 6 6 * @copyright (c) 2006 phpBB Group 7 7 * @license http://opensource.org/licenses/gpl-license.php GNU Public License … … 18 18 19 19 /** 20 * Code from pear.php.net, Text_Diff-1. 0.0 package20 * Code from pear.php.net, Text_Diff-1.1.0 package 21 21 * http://pear.php.net/package/Text_Diff/ 22 22 * … … 59 59 { 60 60 return $this->_edits; 61 } 62 63 /** 64 * returns the number of new (added) lines in a given diff. 65 * 66 * @since Text_Diff 1.1.0 67 * 68 * @return integer The number of new lines 69 */ 70 function count_added_lines() 71 { 72 $count = 0; 73 74 for ($i = 0, $size = sizeof($this->_edits); $i < $size; $i++) 75 { 76 $edit = $this->_edits[$i]; 77 78 if (is_a($edit, 'diff_op_add') || is_a($edit, 'diff_op_change')) 79 { 80 $count += $edit->nfinal(); 81 } 82 } 83 return $count; 84 } 85 86 /** 87 * Returns the number of deleted (removed) lines in a given diff. 88 * 89 * @since Text_Diff 1.1.0 90 * 91 * @return integer The number of deleted lines 92 */ 93 function count_deleted_lines() 94 { 95 $count = 0; 96 97 for ($i = 0, $size = sizeof($this->_edits); $i < $size; $i++) 98 { 99 $edit = $this->_edits[$i]; 100 101 if (is_a($edit, 'diff_op_delete') || is_a($edit, 'diff_op_change')) 102 { 103 $count += $edit->norig(); 104 } 105 } 106 return $count; 61 107 } 62 108 … … 87 133 $rev->_edits = array(); 88 134 89 foreach ($this->_edits as $edit) 90 { 135 for ($i = 0, $size = sizeof($this->_edits); $i < $size; $i++) 136 { 137 $edit = $this->_edits[$i]; 91 138 $rev->_edits[] = $edit->reverse(); 92 139 } … … 102 149 function is_empty() 103 150 { 104 foreach ($this->_edits as $edit) 105 { 106 if (!is_a($edit, 'diff_op_copy')) 107 { 151 for ($i = 0, $size = sizeof($this->_edits); $i < $size; $i++) 152 { 153 $edit = $this->_edits[$i]; 154 155 // skip diff_op_copy 156 if (is_a($edit, 'diff_op_copy')) 157 { 158 continue; 159 } 160 161 if (is_a($edit, 'diff_op_delete') || is_a($edit, 'diff_op_add')) 162 { 163 $orig = $edit->orig; 164 $final = $edit->final; 165 166 // We can simplify one case where the array is usually supposed to be empty... 167 if (sizeof($orig) == 1 && trim($orig[0]) === '') $orig = array(); 168 if (sizeof($final) == 1 && trim($final[0]) === '') $final = array(); 169 170 if (!$orig && !$final) 171 { 172 continue; 173 } 174 108 175 return false; 109 176 } 110 } 177 178 return false; 179 } 180 111 181 return true; 112 182 } … … 123 193 $lcs = 0; 124 194 125 foreach ($this->_edits as $edit) 126 { 195 for ($i = 0, $size = sizeof($this->_edits); $i < $size; $i++) 196 { 197 $edit = $this->_edits[$i]; 198 127 199 if (is_a($edit, 'diff_op_copy')) 128 200 { … … 144 216 $lines = array(); 145 217 146 foreach ($this->_edits as $edit) 147 { 218 for ($i = 0, $size = sizeof($this->_edits); $i < $size; $i++) 219 { 220 $edit = $this->_edits[$i]; 221 148 222 if ($edit->orig) 149 223 { … … 165 239 $lines = array(); 166 240 167 foreach ($this->_edits as $edit) 168 { 241 for ($i = 0, $size = sizeof($this->_edits); $i < $size; $i++) 242 { 243 $edit = $this->_edits[$i]; 244 169 245 if ($edit->final) 170 246 { … … 217 293 $prevtype = null; 218 294 219 foreach ($this->_edits as $edit) 220 { 295 for ($i = 0, $size = sizeof($this->_edits); $i < $size; $i++) 296 { 297 $edit = $this->_edits[$i]; 298 221 299 if ($prevtype == get_class($edit)) 222 300 { … … 415 493 * @param array $final2 The second version to compare to. 416 494 */ 417 function diff3(&$orig, &$final1, &$final2 )495 function diff3(&$orig, &$final1, &$final2, $preserve_cr = true) 418 496 { 419 497 $diff_engine = new diff_engine(); 420 498 421 $diff_1 = $diff_engine->diff($orig, $final1 );422 $diff_2 = $diff_engine->diff($orig, $final2 );423 424 unset($ engine);499 $diff_1 = $diff_engine->diff($orig, $final1, $preserve_cr); 500 $diff_2 = $diff_engine->diff($orig, $final2, $preserve_cr); 501 502 unset($diff_engine); 425 503 426 504 $this->_edits = $this->_diff3($diff_1, $diff_2); … … 428 506 429 507 /** 430 * Return merged output 508 * Return number of conflicts 509 */ 510 function get_num_conflicts() 511 { 512 $conflicts = 0; 513 514 for ($i = 0, $size = sizeof($this->_edits); $i < $size; $i++) 515 { 516 $edit = $this->_edits[$i]; 517 518 if ($edit->is_conflict()) 519 { 520 $conflicts++; 521 } 522 } 523 524 return $conflicts; 525 } 526 527 /** 528 * Get conflicts content for download. This is generally a merged file, but preserving conflicts and adding explanations to it. 529 * A user could then go through this file, search for the conflicts and changes the code accordingly. 431 530 * 432 531 * @param string $label1 the cvs file version/label from the original set of lines 433 532 * @param string $label2 the cvs file version/label from the new set of lines 434 533 * @param string $label_sep the explanation between label1 and label2 - more of a helper for the user 435 * @param bool $get_conflicts if set to true only the number of conflicts is returned436 * @param bool $merge_new if set to true the merged output will have the new file contents on a conflicting merge437 534 * 438 535 * @return mixed the merged output 439 536 */ 440 function merged_output($label1 = 'CURRENT_FILE', $label2 = 'NEW_FILE', $label_sep = 'DIFF_SEP_EXPLAIN', $get_conflicts = false, $merge_new = false)537 function get_conflicts_content($label1 = 'CURRENT_FILE', $label2 = 'NEW_FILE', $label_sep = 'DIFF_SEP_EXPLAIN') 441 538 { 442 539 global $user; 443 444 if ($get_conflicts)445 {446 foreach ($this->_edits as $edit)447 {448 if ($edit->is_conflict())449 {450 $this->_conflicting_blocks++;451 }452 }453 454 return $this->_conflicting_blocks;455 }456 540 457 541 $label1 = (!empty($user->lang[$label1])) ? $user->lang[$label1] : $label1; … … 461 545 $lines = array(); 462 546 463 foreach ($this->_edits as $edit) 464 { 547 for ($i = 0, $size = sizeof($this->_edits); $i < $size; $i++) 548 { 549 $edit = $this->_edits[$i]; 550 465 551 if ($edit->is_conflict()) 466 552 { 467 if (!$merge_new) 468 { 469 $lines = array_merge($lines, array('<<<<<<<' . ($label1 ? ' ' . $label1 : '')), $edit->final1, array('=======' . ($label_sep ? ' ' . $label_sep : '')), $edit->final2, array('>>>>>>>' . ($label2 ? ' ' . $label2 : ''))); 470 } 471 else 472 { 473 $lines = array_merge($lines, $edit->final1); 474 } 553 // Start conflict label 554 $label_start = array('<<<<<<< ' . $label1); 555 $label_mid = array('======= ' . $label_sep); 556 $label_end = array('>>>>>>> ' . $label2); 557 558 $lines = array_merge($lines, $label_start, $edit->final1, $label_mid, $edit->final2, $label_end); 475 559 $this->_conflicting_blocks++; 476 560 } … … 485 569 486 570 /** 571 * Return merged output (used by the renderer) 572 * 573 * @return mixed the merged output 574 */ 575 function merged_output() 576 { 577 return $this->get_conflicts_content(); 578 } 579 580 /** 487 581 * Merge the output and use the new file code for conflicts 488 582 */ … … 491 585 $lines = array(); 492 586 493 foreach ($this->_edits as $edit) 494 { 587 for ($i = 0, $size = sizeof($this->_edits); $i < $size; $i++) 588 { 589 $edit = $this->_edits[$i]; 590 495 591 if ($edit->is_conflict()) 496 592 { … … 513 609 $lines = array(); 514 610 515 foreach ($this->_edits as $edit) 516 { 611 for ($i = 0, $size = sizeof($this->_edits); $i < $size; $i++) 612 { 613 $edit = $this->_edits[$i]; 614 517 615 if ($edit->is_conflict()) 518 616 { … … 535 633 $conflicts = array(); 536 634 537 foreach ($this->_edits as $edit) 538 { 635 for ($i = 0, $size = sizeof($this->_edits); $i < $size; $i++) 636 { 637 $edit = $this->_edits[$i]; 638 539 639 if ($edit->is_conflict()) 540 640 { … … 660 760 if (!isset($this->_merged)) 661 761 { 762 // Prepare the arrays before we compare them. ;) 763 $this->solve_prepare(); 764 662 765 if ($this->final1 === $this->final2) 663 766 { … … 674 777 else 675 778 { 779 // The following tries to aggressively solve conflicts... 676 780 $this->_merged = false; 781 $this->solve_conflict(); 677 782 } 678 783 } … … 684 789 { 685 790 return ($this->merged() === false) ? true : false; 791 } 792 793 /** 794 * Function to prepare the arrays for comparing - we want to skip over newline changes 795 * @author acydburn 796 */ 797 function solve_prepare() 798 { 799 // We can simplify one case where the array is usually supposed to be empty... 800 if (sizeof($this->orig) == 1 && trim($this->orig[0]) === '') $this->orig = array(); 801 if (sizeof($this->final1) == 1 && trim($this->final1[0]) === '') $this->final1 = array(); 802 if (sizeof($this->final2) == 1 && trim($this->final2[0]) === '') $this->final2 = array(); 803 804 // Now we only can have the case where the only difference between arrays are newlines, so compare all cases 805 806 // First, some strings we can compare... 807 $orig = $final1 = $final2 = ''; 808 809 foreach ($this->orig as $null => $line) $orig .= trim($line); 810 foreach ($this->final1 as $null => $line) $final1 .= trim($line); 811 foreach ($this->final2 as $null => $line) $final2 .= trim($line); 812 813 // final1 === final2 814 if ($final1 === $final2) 815 { 816 // We preserve the part which will be used in the merge later 817 $this->final2 = $this->final1; 818 } 819 // final1 === orig 820 else if ($final1 === $orig) 821 { 822 // Here it does not really matter what we choose, but we will use the new code 823 $this->orig = $this->final1; 824 } 825 // final2 === orig 826 else if ($final2 === $orig) 827 { 828 // Here it does not really matter too (final1 will be used), but we will use the new code 829 $this->orig = $this->final2; 830 } 831 } 832 833 /** 834 * Find code portions from $orig in $final1 and use $final2 as merged instance if provided 835 * @author acydburn 836 */ 837 function _compare_conflict_seq($orig, $final1, $final2 = false) 838 { 839 $result = array('merge_found' => false, 'merge' => array()); 840 841 $_orig = &$this->$orig; 842 $_final1 = &$this->$final1; 843 844 // Ok, we basically search for $orig in $final1 845 $compare_seq = sizeof($_orig); 846 847 // Go through the conflict code 848 for ($i = 0, $j = 0, $size = sizeof($_final1); $i < $size; $i++, $j = $i) 849 { 850 $line = $_final1[$i]; 851 $skip = 0; 852 853 for ($x = 0; $x < $compare_seq; $x++) 854 { 855 // Try to skip all matching lines 856 if (trim($line) === trim($_orig[$x])) 857 { 858 $line = (++$j < $size) ? $_final1[$j] : $line; 859 $skip++; 860 } 861 } 862 863 if ($skip === $compare_seq) 864 { 865 $result['merge_found'] = true; 866 867 if ($final2 !== false) 868 { 869 $result['merge'] = array_merge($result['merge'], $this->$final2); 870 } 871 $i += ($skip - 1); 872 } 873 else if ($final2 !== false) 874 { 875 $result['merge'][] = $line; 876 } 877 } 878 879 return $result; 880 } 881 882 /** 883 * Tries to solve conflicts aggressively based on typical "assumptions" 884 * @author acydburn 885 */ 886 function solve_conflict() 887 { 888 $this->_merged = false; 889 890 // CASE ONE: orig changed into final2, but modified/unknown code in final1. 891 // IF orig is found "as is" in final1 we replace the code directly in final1 and populate this as final2/merge 892 if (sizeof($this->orig) && sizeof($this->final2)) 893 { 894 $result = $this->_compare_conflict_seq('orig', 'final1', 'final2'); 895 896 if ($result['merge_found']) 897 { 898 $this->final2 = $result['merge']; 899 $this->_merged = &$this->final2; 900 return; 901 } 902 903 $result = $this->_compare_conflict_seq('final2', 'final1'); 904 905 if ($result['merge_found']) 906 { 907 $this->_merged = &$this->final1; 908 return; 909 } 910 911 // Try to solve $Id$ issues. ;) 912 if (sizeof($this->orig) == 1 && sizeof($this->final1) == 1 && sizeof($this->final2) == 1) 913 { 914 $match = '#^' . preg_quote('* @version $Id: ', '#') . '[a-z\._\- ]+[0-9]+ [0-9]{4}-[0-9]{2}-[0-9]{2} [0-9\:Z]+ [a-z0-9_\- ]+\$$#'; 915 916 if (preg_match($match, $this->orig[0]) && preg_match($match, $this->final1[0]) && preg_match($match, $this->final2[0])) 917 { 918 $this->_merged = &$this->final2; 919 return; 920 } 921 } 922 923 $second_run = false; 924 925 // Try to solve issues where the only reason why the above did not work is a newline being removed in the final1 code but exist in the orig/final2 code 926 if (trim($this->orig[0]) === '' && trim($this->final2[0]) === '') 927 { 928 unset($this->orig[0], $this->final2[0]); 929 $this->orig = array_values($this->orig); 930 $this->final2 = array_values($this->final2); 931 932 $second_run = true; 933 } 934 935 // The same is true for a line at the end. ;) 936 if (sizeof($this->orig) && sizeof($this->final2) && sizeof($this->orig) === sizeof($this->final2) && trim($this->orig[sizeof($this->orig)-1]) === '' && trim($this->final2[sizeof($this->final2)-1]) === '') 937 { 938 unset($this->orig[sizeof($this->orig)-1], $this->final2[sizeof($this->final2)-1]); 939 $this->orig = array_values($this->orig); 940 $this->final2 = array_values($this->final2); 941 942 $second_run = true; 943 } 944 945 if ($second_run) 946 { 947 $result = $this->_compare_conflict_seq('orig', 'final1', 'final2'); 948 949 if ($result['merge_found']) 950 { 951 $this->final2 = $result['merge']; 952 $this->_merged = &$this->final2; 953 return; 954 } 955 956 $result = $this->_compare_conflict_seq('final2', 'final1'); 957 958 if ($result['merge_found']) 959 { 960 $this->_merged = &$this->final1; 961 return; 962 } 963 } 964 965 return; 966 } 967 968 // CASE TWO: Added lines from orig to final2 but final1 had added lines too. Just merge them. 969 if (!sizeof($this->orig) && $this->final1 !== $this->final2 && sizeof($this->final1) && sizeof($this->final2)) 970 { 971 $result = $this->_compare_conflict_seq('final2', 'final1'); 972 973 if ($result['merge_found']) 974 { 975 $this->final2 = $this->final1; 976 $this->_merged = &$this->final1; 977 } 978 else 979 { 980 $result = $this->_compare_conflict_seq('final1', 'final2'); 981 982 if (!$result['merge_found']) 983 { 984 $this->final2 = array_merge($this->final1, $this->final2); 985 $this->_merged = &$this->final2; 986 } 987 else 988 { 989 $this->final2 = $this->final1; 990 $this->_merged = &$this->final1; 991 } 992 } 993 994 return; 995 } 996 997 // CASE THREE: Removed lines (orig has the to-remove line(s), but final1 has additional lines which does not need to be removed). Just remove orig from final1 and then use final1 as final2/merge 998 if (!sizeof($this->final2) && sizeof($this->orig) && sizeof($this->final1) && $this->orig !== $this->final1) 999 { 1000 $result = $this->_compare_conflict_seq('orig', 'final1'); 1001 1002 if (!$result['merge_found']) 1003 { 1004 return; 1005 } 1006 1007 // First of all, try to find the code in orig in final1. ;) 1008 $compare_seq = sizeof($this->orig); 1009 $begin = $end = -1; 1010 $j = 0; 1011 1012 for ($i = 0, $size = sizeof($this->final1); $i < $size; $i++) 1013 { 1014 $line = $this->final1[$i]; 1015 1016 if (trim($line) === trim($this->orig[$j])) 1017 { 1018 // Mark begin 1019 if ($begin === -1) 1020 { 1021 $begin = $i; 1022 } 1023 1024 // End is always $i, the last found line 1025 $end = $i; 1026 1027 if (isset($this->orig[$j+1])) 1028 { 1029 $j++; 1030 } 1031 } 1032 } 1033 1034 if ($begin !== -1 && $begin + ($compare_seq - 1) == $end) 1035 { 1036 foreach ($this->final1 as $i => $line) 1037 { 1038 if ($i < $begin || $i > $end) 1039 { 1040 $merged[] = $line; 1041 } 1042 } 1043 1044 $this->final2 = $merged; 1045 $this->_merged = &$this->final2; 1046 } 1047 1048 return; 1049 } 1050 1051 return; 686 1052 } 687 1053 } -
trunk/forum/includes/diff/engine.php
r400 r702 3 3 * 4 4 * @package diff 5 * @version $Id : engine.php 8765 2008-08-16 22:18:25Z aptx$5 * @version $Id$ 6 6 * @copyright (c) 2006 phpBB Group 7 7 * @license http://opensource.org/licenses/gpl-license.php GNU Public License … … 18 18 19 19 /** 20 * Code from pear.php.net, Text_Diff-1. 0.0 package20 * Code from pear.php.net, Text_Diff-1.1.0 package 21 21 * http://pear.php.net/package/Text_Diff/ (native engine) 22 22 * … … 50 50 class diff_engine 51 51 { 52 /** 53 * If set to true we trim all lines before we compare them. This ensures that sole space/tab changes do not trigger diffs. 54 */ 55 var $skip_whitespace_changes = true; 56 52 57 function diff(&$from_lines, &$to_lines, $preserve_cr = true) 53 58 { … … 86 91 for ($skip = 0; $skip < $n_from && $skip < $n_to; $skip++) 87 92 { 88 if ( $from_lines[$skip] !== $to_lines[$skip])93 if (trim($from_lines[$skip]) !== trim($to_lines[$skip])) 89 94 { 90 95 break; … … 99 104 for ($endskip = 0; --$xi > $skip && --$yi > $skip; $endskip++) 100 105 { 101 if ( $from_lines[$xi] !== $to_lines[$yi])106 if (trim($from_lines[$xi]) !== trim($to_lines[$yi])) 102 107 { 103 108 break; … … 109 114 for ($xi = $skip; $xi < $n_from - $endskip; $xi++) 110 115 { 111 $xhash[$from_lines[$xi]] = 1;116 if ($this->skip_whitespace_changes) $xhash[trim($from_lines[$xi])] = 1; else $xhash[$from_lines[$xi]] = 1; 112 117 } 113 118 114 119 for ($yi = $skip; $yi < $n_to - $endskip; $yi++) 115 120 { 116 $line = $to_lines[$yi];121 $line = ($this->skip_whitespace_changes) ? trim($to_lines[$yi]) : $to_lines[$yi]; 117 122 118 123 if (($this->ychanged[$yi] = empty($xhash[$line]))) … … 127 132 for ($xi = $skip; $xi < $n_from - $endskip; $xi++) 128 133 { 129 $line = $from_lines[$xi];134 $line = ($this->skip_whitespace_changes) ? trim($from_lines[$xi]) : $from_lines[$xi]; 130 135 131 136 if (($this->xchanged[$xi] = empty($yhash[$line]))) … … 141 146 142 147 // Merge edits when possible. 143 $this->_shift_boundaries($from_lines, $this->xchanged, $this->ychanged); 144 $this->_shift_boundaries($to_lines, $this->ychanged, $this->xchanged); 148 if ($this->skip_whitespace_changes) 149 { 150 $from_lines_clean = array_map('trim', $from_lines); 151 $to_lines_clean = array_map('trim', $to_lines); 152 153 $this->_shift_boundaries($from_lines_clean, $this->xchanged, $this->ychanged); 154 $this->_shift_boundaries($to_lines_clean, $this->ychanged, $this->xchanged); 155 156 unset($from_lines_clean, $to_lines_clean); 157 } 158 else 159 { 160 $this->_shift_boundaries($from_lines, $this->xchanged, $this->ychanged); 161 $this->_shift_boundaries($to_lines, $this->ychanged, $this->xchanged); 162 } 145 163 146 164 // Compute the edit operations. -
trunk/forum/includes/diff/renderer.php
r400 r702 3 3 * 4 4 * @package diff 5 * @version $Id : renderer.php 8766 2008-08-16 22:24:54Z aptx$5 * @version $Id$ 6 6 * @copyright (c) 2006 phpBB Group 7 7 * @license http://opensource.org/licenses/gpl-license.php GNU Public License … … 18 18 19 19 /** 20 * Code from pear.php.net, Text_Diff-1. 0.0 package20 * Code from pear.php.net, Text_Diff-1.1.0 package 21 21 * http://pear.php.net/package/Text_Diff/ 22 22 * … … 537 537 function get_diff_content($diff) 538 538 { 539 return '<textarea style="height: 290px;" class="full">' . htmlspecialchars($this->render($diff)) . '</textarea>';539 return '<textarea style="height: 290px;" rows="15" cols="76" class="full">' . htmlspecialchars($this->render($diff)) . '</textarea>'; 540 540 } 541 541 -
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'; -
trunk/forum/includes/functions_admin.php
r400 r702 3 3 * 4 4 * @package acp 5 * @version $Id : functions_admin.php 9065 2008-11-13 17:32:55Z toonarmy$5 * @version $Id$ 6 6 * @copyright (c) 2005 phpBB Group 7 7 * @license http://opensource.org/licenses/gpl-license.php GNU Public License … … 18 18 19 19 /** 20 * Recalculate Binary Tree 21 function recalc_btree($sql_id, $sql_table, $module_class = '') 20 * Recalculate Nested Sets 21 * 22 * @param int $new_id first left_id (should start with 1) 23 * @param string $pkey primary key-column (containing the id for the parent_id of the children) 24 * @param string $table constant or fullname of the table 25 * @param int $parent_id parent_id of the current set (default = 0) 26 * @param array $where contains strings to compare closer on the where statement (additional) 27 * 28 * @author EXreaction 29 */ 30 function recalc_nested_sets(&$new_id, $pkey, $table, $parent_id = 0, $where = array()) 22 31 { 23 32 global $db; 24 33 25 if (!$sql_id || !$sql_table) 26 { 27 return; 28 } 29 30 $sql_where = ($module_class) ? " WHERE module_class = '" . $db->sql_escape($module_class) . "'" : ''; 31 32 // Reset to minimum possible left and right id 33 $sql = "SELECT MIN(left_id) as min_left_id, MIN(right_id) as min_right_id 34 FROM $sql_table 35 $sql_where"; 34 $sql = 'SELECT * 35 FROM ' . $table . ' 36 WHERE parent_id = ' . (int) $parent_id . 37 ((!empty($where)) ? ' AND ' . implode(' AND ', $where) : '') . ' 38 ORDER BY left_id ASC'; 36 39 $result = $db->sql_query($sql); 37 $row = $db->sql_fetchrow($result); 40 while ($row = $db->sql_fetchrow($result)) 41 { 42 // First we update the left_id for this module 43 if ($row['left_id'] != $new_id) 44 { 45 $db->sql_query('UPDATE ' . $table . ' SET ' . $db->sql_build_array('UPDATE', array('left_id' => $new_id)) . " WHERE $pkey = {$row[$pkey]}"); 46 } 47 $new_id++; 48 49 // Then we go through any children and update their left/right id's 50 recalc_nested_sets($new_id, $pkey, $table, $row[$pkey], $where); 51 52 // Then we come back and update the right_id for this module 53 if ($row['right_id'] != $new_id) 54 { 55 $db->sql_query('UPDATE ' . $table . ' SET ' . $db->sql_build_array('UPDATE', array('right_id' => $new_id)) . " WHERE $pkey = {$row[$pkey]}"); 56 } 57 $new_id++; 58 } 38 59 $db->sql_freeresult($result); 39 40 $substract = (int) (min($row['min_left_id'], $row['min_right_id']) - 1);41 42 if ($substract > 0)43 {44 $sql = "UPDATE $sql_table45 SET left_id = left_id - $substract, right_id = right_id - $substract46 $sql_where";47 $db->sql_query($sql);48 }49 50 $sql = "SELECT $sql_id, parent_id, left_id, right_id51 FROM $sql_table52 $sql_where53 ORDER BY left_id ASC, parent_id ASC, $sql_id ASC";54 $f_result = $db->sql_query($sql);55 56 while ($item_data = $db->sql_fetchrow($f_result))57 {58 if ($item_data['parent_id'])59 {60 $sql = "SELECT left_id, right_id61 FROM $sql_table62 $sql_where " . (($sql_where) ? 'AND' : 'WHERE') . "63 $sql_id = {$item_data['parent_id']}";64 $result = $db->sql_query($sql);65 66 if (!$row = $db->sql_fetchrow($result))67 {68 $sql = "UPDATE $sql_table SET parent_id = 0 WHERE $sql_id = " . $item_data[$sql_id];69 $db->sql_query($sql);70 }71 $db->sql_freeresult($result);72 73 $sql = "UPDATE $sql_table74 SET left_id = left_id + 2, right_id = right_id + 275 $sql_where " . (($sql_where) ? 'AND' : 'WHERE') . "76 left_id > {$row['right_id']}";77 $db->sql_query($sql);78 79 $sql = "UPDATE $sql_table80 SET right_id = right_id + 281 $sql_where " . (($sql_where) ? 'AND' : 'WHERE') . "82 {$row['left_id']} BETWEEN left_id AND right_id";83 $db->sql_query($sql);84 85 $item_data['left_id'] = $row['right_id'];86 $item_data['right_id'] = $row['right_id'] + 1;87 }88 else89 {90 $sql = "SELECT MAX(right_id) AS right_id91 FROM $sql_table92 $sql_where";93 $result = $db->sql_query($sql);94 $row = $db->sql_fetchrow($result);95 $db->sql_freeresult($result);96 97 $item_data['left_id'] = $row['right_id'] + 1;98 $item_data['right_id'] = $row['right_id'] + 2;99 }100 101 $sql = "UPDATE $sql_table102 SET left_id = {$item_data['left_id']}, right_id = {$item_data['right_id']}103 WHERE $sql_id = " . $item_data[$sql_id];104 $db->sql_query($sql);105 }106 $db->sql_freeresult($f_result);107 60 } 108 */109 61 110 62 /** … … 115 67 global $db, $user, $auth; 116 68 117 $acl = ($ignore_acl) ? '' : (($only_acl_post) ? 'f_post' : array('f_list', 'a_forum', 'a_forumadd', 'a_forumdel'));118 119 69 // This query is identical to the jumpbox one 120 $sql = 'SELECT forum_id, forum_name, parent_id, forum_type, left_id, right_id70 $sql = 'SELECT forum_id, forum_name, parent_id, forum_type, forum_flags, forum_options, left_id, right_id 121 71 FROM ' . FORUMS_TABLE . ' 122 72 ORDER BY left_id ASC'; … … 147 97 $disabled = false; 148 98 149 if ($acl && !$auth->acl_gets($acl, $row['forum_id'])) 150 { 151 // List permission? 152 if ($auth->acl_get('f_list', $row['forum_id'])) 99 if (!$ignore_acl && $auth->acl_get('f_list', $row['forum_id'])) 100 { 101 if ($only_acl_post && !$auth->acl_get('f_post', $row['forum_id']) || (!$auth->acl_get('m_approve', $row['forum_id']) && !$auth->acl_get('f_noapprove', $row['forum_id']))) 153 102 { 154 103 $disabled = true; 155 104 } 156 else 157 { 158 continue; 159 } 105 else if (!$only_acl_post && !$auth->acl_gets(array('f_list', 'a_forum', 'a_forumadd', 'a_forumdel'), $row['forum_id'])) 106 { 107 $disabled = true; 108 } 109 } 110 else if (!$ignore_acl) 111 { 112 continue; 160 113 } 161 114 … … 303 256 if ($acl_list == '' || ($acl_list != '' && $auth->acl_gets($acl_list, $row['forum_id']))) 304 257 { 305 $rowset[] = ($id_only) ? $row['forum_id'] : $row;258 $rowset[] = ($id_only) ? (int) $row['forum_id'] : $row; 306 259 } 307 260 } … … 356 309 357 310 /** 311 * Copies permissions from one forum to others 312 * 313 * @param int $src_forum_id The source forum we want to copy permissions from 314 * @param array $dest_forum_ids The destination forum(s) we want to copy to 315 * @param bool $clear_dest_perms True if destination permissions should be deleted 316 * @param bool $add_log True if log entry should be added 317 * 318 * @return bool False on error 319 * 320 * @author bantu 321 */ 322 function copy_forum_permissions($src_forum_id, $dest_forum_ids, $clear_dest_perms = true, $add_log = true) 323 { 324 global $db; 325 326 // Only one forum id specified 327 if (!is_array($dest_forum_ids)) 328 { 329 $dest_forum_ids = array($dest_forum_ids); 330 } 331 332 // Make sure forum ids are integers 333 $src_forum_id = (int) $src_forum_id; 334 $dest_forum_ids = array_map('intval', $dest_forum_ids); 335 336 // No source forum or no destination forums specified 337 if (empty($src_forum_id) || empty($dest_forum_ids)) 338 { 339 return false; 340 } 341 342 // Check if source forum exists 343 $sql = 'SELECT forum_name 344 FROM ' . FORUMS_TABLE . ' 345 WHERE forum_id = ' . $src_forum_id; 346 $result = $db->sql_query($sql); 347 $src_forum_name = $db->sql_fetchfield('forum_name'); 348 $db->sql_freeresult($result); 349 350 // Source forum doesn't exist 351 if (empty($src_forum_name)) 352 { 353 return false; 354 } 355 356 // Check if destination forums exists 357 $sql = 'SELECT forum_id, forum_name 358 FROM ' . FORUMS_TABLE . ' 359 WHERE ' . $db->sql_in_set('forum_id', $dest_forum_ids); 360 $result = $db->sql_query($sql); 361 362 $dest_forum_ids = $dest_forum_names = array(); 363 while ($row = $db->sql_fetchrow($result)) 364 { 365 $dest_forum_ids[] = (int) $row['forum_id']; 366 $dest_forum_names[] = $row['forum_name']; 367 } 368 $db->sql_freeresult($result); 369 370 // No destination forum exists 371 if (empty($dest_forum_ids)) 372 { 373 return false; 374 } 375 376 // From the mysql documentation: 377 // Prior to MySQL 4.0.14, the target table of the INSERT statement cannot appear 378 // in the FROM clause of the SELECT part of the query. This limitation is lifted in 4.0.14. 379 // Due to this we stay on the safe side if we do the insertion "the manual way" 380 381 // Rowsets we're going to insert 382 $users_sql_ary = $groups_sql_ary = array(); 383 384 // Query acl users table for source forum data 385 $sql = 'SELECT user_id, auth_option_id, auth_role_id, auth_setting 386 FROM ' . ACL_USERS_TABLE . ' 387 WHERE forum_id = ' . $src_forum_id; 388 $result = $db->sql_query($sql); 389 390 while ($row = $db->sql_fetchrow($result)) 391 { 392 $row = array( 393 'user_id' => (int) $row['user_id'], 394 'auth_option_id' => (int) $row['auth_option_id'], 395 'auth_role_id' => (int) $row['auth_role_id'], 396 'auth_setting' => (int) $row['auth_setting'], 397 ); 398 399 foreach ($dest_forum_ids as $dest_forum_id) 400 { 401 $users_sql_ary[] = $row + array('forum_id' => $dest_forum_id); 402 } 403 } 404 $db->sql_freeresult($result); 405 406 // Query acl groups table for source forum data 407 $sql = 'SELECT group_id, auth_option_id, auth_role_id, auth_setting 408 FROM ' . ACL_GROUPS_TABLE . ' 409 WHERE forum_id = ' . $src_forum_id; 410 $result = $db->sql_query($sql); 411 412 while ($row = $db->sql_fetchrow($result)) 413 { 414 $row = array( 415 'group_id' => (int) $row['group_id'], 416 'auth_option_id' => (int) $row['auth_option_id'], 417 'auth_role_id' => (int) $row['auth_role_id'], 418 'auth_setting' => (int) $row['auth_setting'], 419 ); 420 421 foreach ($dest_forum_ids as $dest_forum_id) 422 { 423 $groups_sql_ary[] = $row + array('forum_id' => $dest_forum_id); 424 } 425 } 426 $db->sql_freeresult($result); 427 428 $db->sql_transaction('begin'); 429 430 // Clear current permissions of destination forums 431 if ($clear_dest_perms) 432 { 433 $sql = 'DELETE FROM ' . ACL_USERS_TABLE . ' 434 WHERE ' . $db->sql_in_set('forum_id', $dest_forum_ids); 435 $db->sql_query($sql); 436 437 $sql = 'DELETE FROM ' . ACL_GROUPS_TABLE . ' 438 WHERE ' . $db->sql_in_set('forum_id', $dest_forum_ids); 439 $db->sql_query($sql); 440 } 441 442 $db->sql_multi_insert(ACL_USERS_TABLE, $users_sql_ary); 443 $db->sql_multi_insert(ACL_GROUPS_TABLE, $groups_sql_ary); 444 445 if ($add_log) 446 { 447 add_log('admin', 'LOG_FORUM_COPIED_PERMISSIONS', $src_forum_name, implode(', ', $dest_forum_names)); 448 } 449 450 $db->sql_transaction('commit'); 451 452 return true; 453 } 454 455 /** 358 456 * Get physical file listing 359 457 */ 360 458 function filelist($rootdir, $dir = '', $type = 'gif|jpg|jpeg|png') 361 459 { 362 $matches = array( );460 $matches = array($dir => array()); 363 461 364 462 // Remove initial / if present … … 620 718 if ($approved_topics) 621 719 { 622 set_config ('num_topics', $config['num_topics'] - $approved_topics, true);720 set_config_count('num_topics', $approved_topics * (-1), true); 623 721 } 624 722 … … 653 751 } 654 752 655 $where_clause = $db->sql_in_set($where_type, array_map('intval', $where_ids)); 753 $where_ids = array_map('intval', $where_ids); 754 755 /* Possible code for splitting post deletion 756 if (sizeof($where_ids) >= 1001) 757 { 758 // Split into chunks of 1000 759 $chunks = array_chunk($where_ids, 1000); 760 761 foreach ($chunks as $_where_ids) 762 { 763 delete_posts($where_type, $_where_ids, $auto_sync, $posted_sync, $post_count_sync, $call_delete_topics); 764 } 765 766 return; 767 }*/ 768 769 $where_clause = $db->sql_in_set($where_type, $where_ids); 656 770 } 657 771 … … 666 780 while ($row = $db->sql_fetchrow($result)) 667 781 { 668 $post_ids[] = $row['post_id'];669 $poster_ids[] = $row['poster_id'];670 $topic_ids[] = $row['topic_id'];671 $forum_ids[] = $row['forum_id'];782 $post_ids[] = (int) $row['post_id']; 783 $poster_ids[] = (int) $row['poster_id']; 784 $topic_ids[] = (int) $row['topic_id']; 785 $forum_ids[] = (int) $row['forum_id']; 672 786 673 787 if ($row['post_postcount'] && $post_count_sync && $row['post_approved']) … … 777 891 if ($approved_posts) 778 892 { 779 set_config ('num_posts', $config['num_posts'] - $approved_posts, true);893 set_config_count('num_posts', $approved_posts * (-1), true); 780 894 } 781 895 … … 800 914 global $db, $config; 801 915 802 if (is_array($ids) && sizeof($ids)) 916 // 0 is as bad as an empty array 917 if (empty($ids)) 918 { 919 return false; 920 } 921 922 if (is_array($ids)) 803 923 { 804 924 $ids = array_unique($ids); … … 810 930 } 811 931 812 if (!sizeof($ids)) 813 { 814 return false; 815 } 932 $sql_where = ''; 816 933 817 934 switch ($mode) … … 820 937 case 'message': 821 938 $sql_id = 'post_msg_id'; 939 $sql_where = ' AND in_message = ' . ($mode == 'message' ? 1 : 0); 822 940 break; 823 941 … … 843 961 FROM ' . ATTACHMENTS_TABLE . ' 844 962 WHERE ' . $db->sql_in_set($sql_id, $ids); 963 964 $sql .= $sql_where; 965 845 966 $result = $db->sql_query($sql); 846 967 … … 868 989 $sql = 'DELETE FROM ' . ATTACHMENTS_TABLE . ' 869 990 WHERE ' . $db->sql_in_set($sql_id, $ids); 991 992 $sql .= $sql_where; 993 870 994 $db->sql_query($sql); 871 995 $num_deleted = $db->sql_affectedrows(); … … 895 1019 if ($space_removed || $files_removed) 896 1020 { 897 set_config ('upload_dir_size', $config['upload_dir_size'] - $space_removed, true);898 set_config ('num_files', $config['num_files'] - $files_removed, true);1021 set_config_count('upload_dir_size', $space_removed * (-1), true); 1022 set_config_count('num_files', $files_removed * (-1), true); 899 1023 } 900 1024 … … 916 1040 if (sizeof($post_ids)) 917 1041 { 918 $sql = 'UPDATE ' . POSTS_TABLE . ' 919 SET post_attachment = 0 920 WHERE ' . $db->sql_in_set('post_id', $post_ids); 921 $db->sql_query($sql); 1042 // Just check which posts are still having an assigned attachment not orphaned by querying the attachments table 1043 $sql = 'SELECT post_msg_id 1044 FROM ' . ATTACHMENTS_TABLE . ' 1045 WHERE ' . $db->sql_in_set('post_msg_id', $post_ids) . ' 1046 AND in_message = 0 1047 AND is_orphan = 0'; 1048 $result = $db->sql_query($sql); 1049 1050 $remaining_ids = array(); 1051 while ($row = $db->sql_fetchrow($result)) 1052 { 1053 $remaining_ids[] = $row['post_msg_id']; 1054 } 1055 $db->sql_freeresult($result); 1056 1057 // Now only unset those ids remaining 1058 $post_ids = array_diff($post_ids, $remaining_ids); 1059 1060 if (sizeof($post_ids)) 1061 { 1062 $sql = 'UPDATE ' . POSTS_TABLE . ' 1063 SET post_attachment = 0 1064 WHERE ' . $db->sql_in_set('post_id', $post_ids); 1065 $db->sql_query($sql); 1066 } 922 1067 } 923 1068 … … 925 1070 if (sizeof($message_ids)) 926 1071 { 927 $sql = 'UPDATE ' . PRIVMSGS_TABLE . ' 928 SET message_attachment = 0 929 WHERE ' . $db->sql_in_set('msg_id', $message_ids); 930 $db->sql_query($sql); 1072 // Just check which messages are still having an assigned attachment not orphaned by querying the attachments table 1073 $sql = 'SELECT post_msg_id 1074 FROM ' . ATTACHMENTS_TABLE . ' 1075 WHERE ' . $db->sql_in_set('post_msg_id', $message_ids) . ' 1076 AND in_message = 1 1077 AND is_orphan = 0'; 1078 $result = $db->sql_query($sql); 1079 1080 $remaining_ids = array(); 1081 while ($row = $db->sql_fetchrow($result)) 1082 { 1083 $remaining_ids[] = $row['post_msg_id']; 1084 } 1085 $db->sql_freeresult($result); 1086 1087 // Now only unset those ids remaining 1088 $message_ids = array_diff($message_ids, $remaining_ids); 1089 1090 if (sizeof($message_ids)) 1091 { 1092 $sql = 'UPDATE ' . PRIVMSGS_TABLE . ' 1093 SET message_attachment = 0 1094 WHERE ' . $db->sql_in_set('msg_id', $message_ids); 1095 $db->sql_query($sql); 1096 } 931 1097 } 932 1098 … … 1074 1240 $sql = 'SELECT COUNT(attach_id) AS num_entries 1075 1241 FROM ' . ATTACHMENTS_TABLE . " 1076 WHERE physical_filename = '" . $db->sql_escape( basename($filename)) . "'";1242 WHERE physical_filename = '" . $db->sql_escape(utf8_basename($filename)) . "'"; 1077 1243 $result = $db->sql_query($sql); 1078 1244 $num_entries = (int) $db->sql_fetchfield('num_entries'); … … 1085 1251 } 1086 1252 1087 $filename = ($mode == 'thumbnail') ? 'thumb_' . basename($filename) :basename($filename);1253 $filename = ($mode == 'thumbnail') ? 'thumb_' . utf8_basename($filename) : utf8_basename($filename); 1088 1254 return @unlink($phpbb_root_path . $config['upload_path'] . '/' . $filename); 1089 1255 } … … 1169 1335 { 1170 1336 case 'topic_moved': 1337 $db->sql_transaction('begin'); 1171 1338 switch ($db->sql_layer) 1172 1339 { … … 1205 1372 break; 1206 1373 } 1207 break; 1374 1375 $db->sql_transaction('commit'); 1376 break; 1208 1377 1209 1378 case 'topic_approved': 1379 1380 $db->sql_transaction('begin'); 1210 1381 switch ($db->sql_layer) 1211 1382 { … … 1243 1414 break; 1244 1415 } 1245 break; 1416 1417 $db->sql_transaction('commit'); 1418 break; 1246 1419 1247 1420 case 'post_reported': 1248 1421 $post_ids = $post_reported = array(); 1422 1423 $db->sql_transaction('begin'); 1249 1424 1250 1425 $sql = 'SELECT p.post_id, p.post_reported … … 1298 1473 $db->sql_query($sql); 1299 1474 } 1300 break; 1475 1476 $db->sql_transaction('commit'); 1477 break; 1301 1478 1302 1479 case 'topic_reported': … … 1307 1484 1308 1485 $topic_ids = $topic_reported = array(); 1486 1487 $db->sql_transaction('begin'); 1309 1488 1310 1489 $sql = 'SELECT DISTINCT(t.topic_id) … … 1340 1519 $db->sql_query($sql); 1341 1520 } 1342 break; 1521 1522 $db->sql_transaction('commit'); 1523 break; 1343 1524 1344 1525 case 'post_attachment': 1345 1526 $post_ids = $post_attachment = array(); 1527 1528 $db->sql_transaction('begin'); 1346 1529 1347 1530 $sql = 'SELECT p.post_id, p.post_attachment … … 1395 1578 $db->sql_query($sql); 1396 1579 } 1397 break; 1580 1581 $db->sql_transaction('commit'); 1582 break; 1398 1583 1399 1584 case 'topic_attachment': … … 1404 1589 1405 1590 $topic_ids = $topic_attachment = array(); 1591 1592 $db->sql_transaction('begin'); 1406 1593 1407 1594 $sql = 'SELECT DISTINCT(t.topic_id) … … 1437 1624 $db->sql_query($sql); 1438 1625 } 1439 break; 1626 1627 $db->sql_transaction('commit'); 1628 1629 break; 1440 1630 1441 1631 case 'forum': 1632 1633 $db->sql_transaction('begin'); 1442 1634 1443 1635 // 1: Get the list of all forums … … 1641 1833 } 1642 1834 } 1643 break; 1835 1836 $db->sql_transaction('commit'); 1837 break; 1644 1838 1645 1839 case 'topic': 1646 1840 $topic_data = $post_ids = $approved_unapproved_ids = $resync_forums = $delete_topics = $delete_posts = $moved_topics = array(); 1841 1842 $db->sql_transaction('begin'); 1647 1843 1648 1844 $sql = 'SELECT t.topic_id, t.forum_id, t.topic_moved_id, t.topic_approved, ' . (($sync_extra) ? 't.topic_attachment, t.topic_reported, ' : '') . 't.topic_poster, t.topic_time, t.topic_replies, t.topic_replies_real, t.topic_first_post_id, t.topic_first_poster_name, t.topic_first_poster_colour, t.topic_last_post_id, t.topic_last_post_subject, t.topic_last_poster_id, t.topic_last_poster_name, t.topic_last_poster_colour, t.topic_last_post_time … … 1968 2164 unset($topic_data); 1969 2165 2166 $db->sql_transaction('commit'); 2167 1970 2168 // if some topics have been resync'ed then resync parent forums 1971 2169 // except when we're only syncing a range, we don't want to sync forums during … … 1975 2173 sync('forum', 'forum_id', array_values($resync_forums), true, true); 1976 2174 } 1977 break;2175 break; 1978 2176 } 1979 2177 … … 2161 2359 // Remove users who have group memberships with DENY moderator permissions 2162 2360 $sql = $db->sql_build_query('SELECT', array( 2163 'SELECT' => 'a.forum_id, ug.user_id ',2361 'SELECT' => 'a.forum_id, ug.user_id, g.group_id', 2164 2362 2165 2363 'FROM' => array( 2166 2364 ACL_OPTIONS_TABLE => 'o', 2167 2365 USER_GROUP_TABLE => 'ug', 2168 ACL_GROUPS_TABLE => 'a' 2366 GROUPS_TABLE => 'g', 2367 ACL_GROUPS_TABLE => 'a', 2169 2368 ), 2170 2369 … … 2180 2379 OR r.auth_setting = ' . ACL_NEVER . ') 2181 2380 AND a.group_id = ug.group_id 2381 AND g.group_id = ug.group_id 2382 AND NOT (ug.group_leader = 1 AND g.group_skip_auth = 1) 2182 2383 AND ' . $db->sql_in_set('ug.user_id', $ug_id_ary) . " 2183 2384 AND ug.user_pending = 0 … … 2299 2500 * View log 2300 2501 */ 2301 function view_log($mode, &$log, &$log_count, $limit = 0, $offset = 0, $forum_id = 0, $topic_id = 0, $user_id = 0, $limit_days = 0, $sort_by = 'l.log_time DESC' )2502 function view_log($mode, &$log, &$log_count, $limit = 0, $offset = 0, $forum_id = 0, $topic_id = 0, $user_id = 0, $limit_days = 0, $sort_by = 'l.log_time DESC', $keywords = '') 2302 2503 { 2303 2504 global $db, $user, $auth, $phpEx, $phpbb_root_path, $phpbb_admin_path; … … 2316 2517 case 'mod': 2317 2518 $log_type = LOG_MOD; 2519 $sql_forum = ''; 2318 2520 2319 2521 if ($topic_id) 2320 2522 { 2321 $sql_forum = 'AND l.topic_id = ' . intval($topic_id);2523 $sql_forum = 'AND l.topic_id = ' . (int) $topic_id; 2322 2524 } 2323 2525 else if (is_array($forum_id)) … … 2325 2527 $sql_forum = 'AND ' . $db->sql_in_set('l.forum_id', array_map('intval', $forum_id)); 2326 2528 } 2327 else 2328 { 2329 $sql_forum = ($forum_id) ? 'AND l.forum_id = ' . intval($forum_id) : '';2529 else if ($forum_id) 2530 { 2531 $sql_forum = 'AND l.forum_id = ' . (int) $forum_id; 2330 2532 } 2331 2533 break; … … 2348 2550 default: 2349 2551 return; 2552 } 2553 2554 // Use no preg_quote for $keywords because this would lead to sole backslashes being added 2555 // We also use an OR connection here for spaces and the | string. Currently, regex is not supported for searching (but may come later). 2556 $keywords = preg_split('#[\s|]+#u', utf8_strtolower($keywords), 0, PREG_SPLIT_NO_EMPTY); 2557 $sql_keywords = ''; 2558 2559 if (!empty($keywords)) 2560 { 2561 $keywords_pattern = array(); 2562 2563 // Build pattern and keywords... 2564 for ($i = 0, $num_keywords = sizeof($keywords); $i < $num_keywords; $i++) 2565 { 2566 $keywords_pattern[] = preg_quote($keywords[$i], '#'); 2567 $keywords[$i] = $db->sql_like_expression($db->any_char . $keywords[$i] . $db->any_char); 2568 } 2569 2570 $keywords_pattern = '#' . implode('|', $keywords_pattern) . '#ui'; 2571 2572 $operations = array(); 2573 foreach ($user->lang as $key => $value) 2574 { 2575 if (substr($key, 0, 4) == 'LOG_' && preg_match($keywords_pattern, $value)) 2576 { 2577 $operations[] = $key; 2578 } 2579 } 2580 2581 $sql_keywords = 'AND ('; 2582 if (!empty($operations)) 2583 { 2584 $sql_keywords .= $db->sql_in_set('l.log_operation', $operations) . ' OR '; 2585 } 2586 $sql_keywords .= 'LOWER(l.log_data) ' . implode(' OR LOWER(l.log_data) ', $keywords) . ')'; 2350 2587 } 2351 2588 … … 2355 2592 AND u.user_id = l.user_id 2356 2593 " . (($limit_days) ? "AND l.log_time >= $limit_days" : '') . " 2594 $sql_keywords 2357 2595 $sql_forum 2358 2596 ORDER BY $sort_by"; … … 2395 2633 if (!empty($row['log_data'])) 2396 2634 { 2397 $log_data_ary = unserialize($row['log_data']); 2635 $log_data_ary = @unserialize($row['log_data']); 2636 $log_data_ary = ($log_data_ary === false) ? array() : $log_data_ary; 2398 2637 2399 2638 if (isset($user->lang[$row['log_operation']])) … … 2418 2657 } 2419 2658 } 2420 else 2659 else if (!empty($log_data_ary)) 2421 2660 { 2422 2661 $log[$i]['action'] .= '<br />' . implode('', $log_data_ary); … … 2516 2755 2517 2756 $sql = 'SELECT COUNT(l.log_id) AS total_entries 2518 FROM ' . LOG_TABLE . " l2757 FROM ' . LOG_TABLE . ' l, ' . USERS_TABLE . " u 2519 2758 WHERE l.log_type = $log_type 2759 AND l.user_id = u.user_id 2520 2760 AND l.log_time >= $limit_days 2761 $sql_keywords 2521 2762 $sql_forum"; 2522 2763 $result = $db->sql_query($sql); … … 2661 2902 } 2662 2903 2663 $sql = 'SELECT user_id, username, user_regdate, user_lastvisit, user_inactive_time, user_inactive_reason2904 $sql = 'SELECT * 2664 2905 FROM ' . USERS_TABLE . ' 2665 2906 WHERE user_type = ' . USER_INACTIVE . … … 3030 3271 } 3031 3272 3273 /** 3274 * Obtains the latest version information 3275 * 3276 * @param bool $force_update Ignores cached data. Defaults to false. 3277 * @param bool $warn_fail Trigger a warning if obtaining the latest version information fails. Defaults to false. 3278 * @param int $ttl Cache version information for $ttl seconds. Defaults to 86400 (24 hours). 3279 * 3280 * @return string | false Version info on success, false on failure. 3281 */ 3282 function obtain_latest_version_info($force_update = false, $warn_fail = false, $ttl = 86400) 3283 { 3284 global $cache; 3285 3286 $info = $cache->get('versioncheck'); 3287 3288 if ($info === false || $force_update) 3289 { 3290 $errstr = ''; 3291 $errno = 0; 3292 3293 $info = get_remote_file('www.phpbb.com', '/updatecheck', 3294 ((defined('PHPBB_QA')) ? '30x_qa.txt' : '30x.txt'), $errstr, $errno); 3295 3296 if ($info === false) 3297 { 3298 $cache->destroy('versioncheck'); 3299 if ($warn_fail) 3300 { 3301 trigger_error($errstr, E_USER_WARNING); 3302 } 3303 return false; 3304 } 3305 3306 $cache->put('versioncheck', $info, $ttl); 3307 } 3308 3309 return $info; 3310 } 3311 3312 /** 3313 * Enables a particular flag in a bitfield column of a given table. 3314 * 3315 * @param string $table_name The table to update 3316 * @param string $column_name The column containing a bitfield to update 3317 * @param int $flag The binary flag which is OR-ed with the current column value 3318 * @param string $sql_more This string is attached to the sql query generated to update the table. 3319 * 3320 * @return void 3321 */ 3322 function enable_bitfield_column_flag($table_name, $column_name, $flag, $sql_more = '') 3323 { 3324 global $db; 3325 3326 $sql = 'UPDATE ' . $table_name . ' 3327 SET ' . $column_name . ' = ' . $db->sql_bit_or($column_name, $flag) . ' 3328 ' . $sql_more; 3329 $db->sql_query($sql); 3330 } 3331 3032 3332 ?> -
trunk/forum/includes/functions_compress.php
r400 r702 3 3 * 4 4 * @package phpBB3 5 * @version $Id : functions_compress.php 8780 2008-08-22 12:52:48Z acydburn$5 * @version $Id$ 6 6 * @copyright (c) 2005 phpBB Group 7 7 * @license http://opensource.org/licenses/gpl-license.php GNU Public License … … 81 81 } 82 82 } 83 else 84 { 85 // $src does not exist 86 return false; 87 } 83 88 84 89 return true; … … 90 95 function add_custom_file($src, $filename) 91 96 { 97 if (!file_exists($src)) 98 { 99 return false; 100 } 101 92 102 $this->data($filename, file_get_contents($src), false, stat($src)); 93 103 return true; … … 156 166 function compress_zip($mode, $file) 157 167 { 158 return $this->fp = @fopen($file, $mode . 'b'); 168 $this->fp = @fopen($file, $mode . 'b'); 169 170 if (!$this->fp) 171 { 172 trigger_error('Unable to open file ' . $file . ' [' . $mode . 'b]'); 173 } 159 174 } 160 175 -
trunk/forum/includes/functions_content.php
r400 r702 3 3 * 4 4 * @package phpBB3 5 * @version $Id : functions_content.php 9184 2008-12-11 14:46:38Z acydburn$5 * @version $Id$ 6 6 * @copyright (c) 2005 phpBB Group 7 7 * @license http://opensource.org/licenses/gpl-license.php GNU Public License … … 251 251 $text = preg_replace('/ +/', ' ', strtr($text, "\t\n\r\x0C ", ' ')); 252 252 253 // we need to turn the entities back into their original form, to not cut the message in between them 254 $entities = array('<', '>', '[', ']', '.', ':', ':'); 255 $characters = array('<', '>', '[', ']', '.', ':', ':'); 256 $text = str_replace($entities, $characters, $text); 257 253 258 $word_indizes = array(); 254 259 if (sizeof($words)) … … 262 267 if (preg_match('#(?:[^\w]|^)(' . $word . ')(?:[^\w]|$)#i', $text, $match)) 263 268 { 269 if (empty($match[1])) 270 { 271 continue; 272 } 273 264 274 $pos = utf8_strpos($text, $match[1]); 265 275 if ($pos !== false) … … 341 351 } 342 352 } 343 return $final_text;353 return str_replace($characters, $entities, $final_text); 344 354 } 345 355 } … … 347 357 if (!sizeof($words) || !sizeof($word_indizes)) 348 358 { 349 return (utf8_strlen($text) >= $length + 3) ? utf8_substr($text, 0, $length) . '...' : $text;359 return str_replace($characters, $entities, ((utf8_strlen($text) >= $length + 3) ? utf8_substr($text, 0, $length) . '...' : $text)); 350 360 } 351 361 } … … 676 686 static $censors; 677 687 688 // Nothing to do? 689 if ($text === '') 690 { 691 return ''; 692 } 693 678 694 // We moved the word censor checks in here because we call this function quite often - and then only need to do the check once 679 695 if (!isset($censors) || !is_array($censors)) … … 724 740 else 725 741 { 726 return preg_replace('#<!\-\- s(.*?) \-\-><img src="\{SMILIES_PATH\}\/(.*?) \/><!\-\- s\1 \-\->#', '<img src="' . $phpbb_root_path . $config['smilies_path'] . '/\2 />', $text); 742 $root_path = (defined('PHPBB_USE_BOARD_URL_PATH') && PHPBB_USE_BOARD_URL_PATH) ? generate_board_url() . '/' : $phpbb_root_path; 743 return preg_replace('#<!\-\- s(.*?) \-\-><img src="\{SMILIES_PATH\}\/(.*?) \/><!\-\- s\1 \-\->#', '<img src="' . $root_path . $config['smilies_path'] . '/\2 />', $text); 727 744 } 728 745 } … … 832 849 // Some basics... 833 850 $attachment['extension'] = strtolower(trim($attachment['extension'])); 834 $filename = $phpbb_root_path . $config['upload_path'] . '/' . basename($attachment['physical_filename']);835 $thumbnail_filename = $phpbb_root_path . $config['upload_path'] . '/thumb_' . basename($attachment['physical_filename']);851 $filename = $phpbb_root_path . $config['upload_path'] . '/' . utf8_basename($attachment['physical_filename']); 852 $thumbnail_filename = $phpbb_root_path . $config['upload_path'] . '/thumb_' . utf8_basename($attachment['physical_filename']); 836 853 837 854 $upload_icon = ''; … … 849 866 } 850 867 851 $filesize = $attachment['filesize']; 852 $size_lang = ($filesize >= 1048576) ? $user->lang['MIB'] : (($filesize >= 1024) ? $user->lang['KIB'] : $user->lang['BYTES']); 853 $filesize = get_formatted_filesize($filesize, false); 868 $filesize = get_formatted_filesize($attachment['filesize'], false); 854 869 855 870 $comment = bbcode_nl2br(censor_text($attachment['attach_comment'])); … … 857 872 $block_array += array( 858 873 'UPLOAD_ICON' => $upload_icon, 859 'FILESIZE' => $filesize ,860 'SIZE_LANG' => $ size_lang,861 'DOWNLOAD_NAME' => basename($attachment['real_filename']),874 'FILESIZE' => $filesize['value'], 875 'SIZE_LANG' => $filesize['unit'], 876 'DOWNLOAD_NAME' => utf8_basename($attachment['real_filename']), 862 877 'COMMENT' => $comment, 863 878 ); … … 951 966 'THUMB_IMAGE' => $thumbnail_link, 952 967 ); 968 969 $update_count[] = $attachment['attach_id']; 953 970 break; 954 971 … … 997 1014 'WIDTH' => $width, 998 1015 'HEIGHT' => $height, 1016 'U_VIEW_LINK' => $download_link . '&view=1', 999 1017 ); 1000 1018 … … 1089 1107 * @param int $max_length Maximum length of string (multibyte character count as 1 char / Html entity count as 1 char) 1090 1108 * @param int $max_store_length Maximum character length of string (multibyte character count as 1 char / Html entity count as entity chars). 1091 * @param bool $allow_reply Allow Re: in front of string 1109 * @param bool $allow_reply Allow Re: in front of string 1110 * NOTE: This parameter can cause undesired behavior (returning strings longer than $max_store_legnth) and is deprecated. 1092 1111 * @param string $append String to be appended 1093 1112 */ 1094 function truncate_string($string, $max_length = 60, $max_store_length = 255, $allow_reply = true, $append = '')1113 function truncate_string($string, $max_length = 60, $max_store_length = 255, $allow_reply = false, $append = '') 1095 1114 { 1096 1115 $chars = array(); … … 1127 1146 $string = implode('', $chars); 1128 1147 } 1129 while ( utf8_strlen($string) > $max_store_length || !sizeof($chars));1148 while (!empty($chars) && utf8_strlen($string) > $max_store_length); 1130 1149 } 1131 1150 … … 1160 1179 { 1161 1180 static $_profile_cache; 1162 static $_base_profile_url; 1163 1164 $cache_key = $user_id; 1165 1166 // If the get_username_string() function had been executed once with an (to us) unkown mode, all modes are pre-filled and we can just grab it. 1167 if ($user_id && $user_id != ANONYMOUS && isset($_profile_cache[$cache_key][$mode])) 1168 { 1169 // If the mode is 'no_profile', we simply construct the TPL code due to calls to this mode being very very rare 1170 if ($mode == 'no_profile') 1171 { 1172 $tpl = (!$_profile_cache[$cache_key]['colour']) ? '{USERNAME}' : '<span style="color: {USERNAME_COLOUR};" class="username-coloured">{USERNAME}</span>'; 1173 return str_replace(array('{USERNAME_COLOUR}', '{USERNAME}'), array($_profile_cache[$cache_key]['colour'], $_profile_cache[$cache_key]['username']), $tpl); 1174 } 1175 1176 return $_profile_cache[$cache_key][$mode]; 1177 } 1178 1179 global $phpbb_root_path, $phpEx, $user, $auth; 1180 1181 $username_colour = ($username_colour) ? '#' . $username_colour : ''; 1182 1183 if ($guest_username === false) 1184 { 1185 $username = ($username) ? $username : $user->lang['GUEST']; 1186 } 1187 else 1188 { 1189 $username = ($user_id && $user_id != ANONYMOUS) ? $username : ((!empty($guest_username)) ? $guest_username : $user->lang['GUEST']); 1190 } 1191 1192 // Build cache for all modes 1193 $_profile_cache[$cache_key]['colour'] = $username_colour; 1194 $_profile_cache[$cache_key]['username'] = $username; 1195 $_profile_cache[$cache_key]['no_profile'] = true; 1196 1197 // Profile url - only show if not anonymous and permission to view profile if registered user 1198 // For anonymous the link leads to a login page. 1199 if ($user_id && $user_id != ANONYMOUS && ($user->data['user_id'] == ANONYMOUS || $auth->acl_get('u_viewprofile'))) 1200 { 1201 if (empty($_base_profile_url)) 1202 { 1203 $_base_profile_url = append_sid("{$phpbb_root_path}memberlist.$phpEx", 'mode=viewprofile&u={USER_ID}'); 1204 } 1205 1206 $profile_url = ($custom_profile_url !== false) ? $custom_profile_url . '&u=' . (int) $user_id : str_replace('={USER_ID}', '=' . (int) $user_id, $_base_profile_url); 1207 $tpl = (!$username_colour) ? '<a href="{PROFILE_URL}">{USERNAME}</a>' : '<a href="{PROFILE_URL}" style="color: {USERNAME_COLOUR};" class="username-coloured">{USERNAME}</a>'; 1208 $_profile_cache[$cache_key]['full'] = str_replace(array('{PROFILE_URL}', '{USERNAME_COLOUR}', '{USERNAME}'), array($profile_url, $username_colour, $username), $tpl); 1209 } 1210 else 1211 { 1212 $tpl = (!$username_colour) ? '{USERNAME}' : '<span style="color: {USERNAME_COLOUR};" class="username-coloured">{USERNAME}</span>'; 1213 $_profile_cache[$cache_key]['full'] = str_replace(array('{USERNAME_COLOUR}', '{USERNAME}'), array($username_colour, $username), $tpl); 1214 $profile_url = ''; 1215 } 1216 1217 // Use the profile url from above 1218 $_profile_cache[$cache_key]['profile'] = $profile_url; 1219 1220 // If - by any chance - no_profile is called before any other mode, we need to do the calculation here 1221 if ($mode == 'no_profile') 1222 { 1223 $tpl = (!$_profile_cache[$cache_key]['colour']) ? '{USERNAME}' : '<span style="color: {USERNAME_COLOUR};" class="username-coloured">{USERNAME}</span>'; 1224 return str_replace(array('{USERNAME_COLOUR}', '{USERNAME}'), array($_profile_cache[$cache_key]['colour'], $_profile_cache[$cache_key]['username']), $tpl); 1225 } 1226 1227 return $_profile_cache[$cache_key][$mode]; 1181 1182 // We cache some common variables we need within this function 1183 if (empty($_profile_cache)) 1184 { 1185 global $phpbb_root_path, $phpEx; 1186 1187 $_profile_cache['base_url'] = append_sid("{$phpbb_root_path}memberlist.$phpEx", 'mode=viewprofile&u={USER_ID}'); 1188 $_profile_cache['tpl_noprofile'] = '{USERNAME}'; 1189 $_profile_cache['tpl_noprofile_colour'] = '<span style="color: {USERNAME_COLOUR};" class="username-coloured">{USERNAME}</span>'; 1190 $_profile_cache['tpl_profile'] = '<a href="{PROFILE_URL}">{USERNAME}</a>'; 1191 $_profile_cache['tpl_profile_colour'] = '<a href="{PROFILE_URL}" style="color: {USERNAME_COLOUR};" class="username-coloured">{USERNAME}</a>'; 1192 } 1193 1194 global $user, $auth; 1195 1196 // This switch makes sure we only run code required for the mode 1197 switch ($mode) 1198 { 1199 case 'full': 1200 case 'no_profile': 1201 case 'colour': 1202 1203 // Build correct username colour 1204 $username_colour = ($username_colour) ? '#' . $username_colour : ''; 1205 1206 // Return colour 1207 if ($mode == 'colour') 1208 { 1209 return $username_colour; 1210 } 1211 1212 // no break; 1213 1214 case 'username': 1215 1216 // Build correct username 1217 if ($guest_username === false) 1218 { 1219 $username = ($username) ? $username : $user->lang['GUEST']; 1220 } 1221 else 1222 { 1223 $username = ($user_id && $user_id != ANONYMOUS) ? $username : ((!empty($guest_username)) ? $guest_username : $user->lang['GUEST']); 1224 } 1225 1226 // Return username 1227 if ($mode == 'username') 1228 { 1229 return $username; 1230 } 1231 1232 // no break; 1233 1234 case 'profile': 1235 1236 // Build correct profile url - only show if not anonymous and permission to view profile if registered user 1237 // For anonymous the link leads to a login page. 1238 if ($user_id && $user_id != ANONYMOUS && ($user->data['user_id'] == ANONYMOUS || $auth->acl_get('u_viewprofile'))) 1239 { 1240 $profile_url = ($custom_profile_url !== false) ? $custom_profile_url . '&u=' . (int) $user_id : str_replace(array('={USER_ID}', '=%7BUSER_ID%7D'), '=' . (int) $user_id, $_profile_cache['base_url']); 1241 } 1242 else 1243 { 1244 $profile_url = ''; 1245 } 1246 1247 // Return profile 1248 if ($mode == 'profile') 1249 { 1250 return $profile_url; 1251 } 1252 1253 // no break; 1254 } 1255 1256 if (($mode == 'full' && !$profile_url) || $mode == 'no_profile') 1257 { 1258 return str_replace(array('{USERNAME_COLOUR}', '{USERNAME}'), array($username_colour, $username), (!$username_colour) ? $_profile_cache['tpl_noprofile'] : $_profile_cache['tpl_noprofile_colour']); 1259 } 1260 1261 return str_replace(array('{PROFILE_URL}', '{USERNAME_COLOUR}', '{USERNAME}'), array($profile_url, $username_colour, $username), (!$username_colour) ? $_profile_cache['tpl_profile'] : $_profile_cache['tpl_profile_colour']); 1228 1262 } 1229 1263 -
trunk/forum/includes/functions_convert.php
r400 r702 3 3 * 4 4 * @package install 5 * @version $Id : functions_convert.php 8876 2008-09-18 14:26:56Z acydburn$5 * @version $Id$ 6 6 * @copyright (c) 2006 phpBB Group 7 7 * @license http://opensource.org/licenses/gpl-license.php GNU Public License … … 206 206 /** 207 207 * Generate the email hash stored in the users table 208 * 209 * Note: Deprecated, calls should directly go to phpbb_email_hash() 208 210 */ 209 211 function gen_email_hash($email) 210 212 { 211 return (crc32(strtolower($email)) . strlen($email));213 return phpbb_email_hash($email); 212 214 } 213 215 … … 552 554 553 555 // copy file will prepend $phpBB_root_path 554 $target = $config[$config_var] . '/' . basename(($use_target === false) ? $source : $use_target);556 $target = $config[$config_var] . '/' . utf8_basename(($use_target === false) ? $source : $use_target); 555 557 556 558 if (!empty($convert->convertor[$config_var]) && strpos($source, $convert->convertor[$config_var]) !== 0) … … 568 570 if ($result['copied']) 569 571 { 570 $result['target'] = basename($target);572 $result['target'] = utf8_basename($target); 571 573 } 572 574 else 573 575 { 574 $result['target'] = ($use_target !== false) ? $result['orig_source'] : basename($target);576 $result['target'] = ($use_target !== false) ? $result['orig_source'] : utf8_basename($target); 575 577 } 576 578 … … 601 603 $thumb_dir = $convert->convertor['thumbnails'][0]; 602 604 $thumb_prefix = $convert->convertor['thumbnails'][1]; 603 $thumb_source = $thumb_dir . $thumb_prefix . basename($result['source']);605 $thumb_source = $thumb_dir . $thumb_prefix . utf8_basename($result['source']); 604 606 605 607 if (strpos($thumb_source, $convert->convertor['upload_path']) !== 0) … … 1233 1235 } 1234 1236 1237 if (isset($convert->config_schema['array_name'])) 1238 { 1239 unset($convert->config_schema['array_name']); 1240 } 1241 1235 1242 $convert_config = extract_variables_from_file($filename); 1236 1243 if (!empty($convert->config_schema['array_name'])) … … 1265 1272 1266 1273 $convert_config = get_config(); 1274 1267 1275 foreach ($schema['settings'] as $config_name => $src) 1268 1276 { … … 1275 1283 else 1276 1284 { 1277 $config_value = (isset($convert_config[$src])) ? $convert_config[$src] : ''; 1278 } 1285 if ($schema['table_format'] != 'file' || empty($schema['array_name'])) 1286 { 1287 $config_value = (isset($convert_config[$src])) ? $convert_config[$src] : ''; 1288 } 1289 else if (!empty($schema['array_name'])) 1290 { 1291 $src_ary = $schema['array_name']; 1292 $config_value = (isset($convert_config[$src_ary][$src])) ? $convert_config[$src_ary][$src] : ''; 1293 } 1294 } 1279 1295 1280 1296 if ($config_value !== '') … … 1699 1715 'GLOBAL_MODERATORS' => array('00AA00', 1, 0), 1700 1716 'ADMINISTRATORS' => array('AA0000', 1, 1), 1701 'BOTS' => array('9E8DA7', 0, 0) 1717 'BOTS' => array('9E8DA7', 0, 0), 1718 'NEWLY_REGISTERED' => array('', 0, 0), 1702 1719 ); 1703 1720 … … 2257 2274 if (substr($trg, -1) == '/') 2258 2275 { 2259 $trg .= basename($src);2276 $trg .= utf8_basename($src); 2260 2277 } 2261 2278 $src_path = relative_base($src, $source_relative_path, __LINE__, __FILE__); -
trunk/forum/includes/functions_display.php
r400 r702 3 3 * 4 4 * @package phpBB3 5 * @version $Id : functions_display.php 9082 2008-11-22 20:26:09Z acydburn$5 * @version $Id$ 6 6 * @copyright (c) 2005 phpBB Group 7 7 * @license http://opensource.org/licenses/gpl-license.php GNU Public License … … 103 103 $forum_tracking_info = array(); 104 104 $branch_root_id = $root_data['forum_id']; 105 106 // Check for unread global announcements (index page only) 107 $ga_unread = false; 108 if ($root_data['forum_id'] == 0) 109 { 110 $unread_ga_list = get_unread_topics($user->data['user_id'], 'AND t.forum_id = 0', '', 1); 111 112 if (!empty($unread_ga_list)) 113 { 114 $ga_unread = true; 115 } 116 } 117 105 118 while ($row = $db->sql_fetchrow($result)) 106 119 { … … 155 168 } 156 169 170 // Count the difference of real to public topics, so we can display an information to moderators 171 $row['forum_id_unapproved_topics'] = ($auth->acl_get('m_approve', $forum_id) && ($row['forum_topics_real'] != $row['forum_topics'])) ? $forum_id : 0; 157 172 $row['forum_topics'] = ($auth->acl_get('m_approve', $forum_id)) ? $row['forum_topics_real'] : $row['forum_topics']; 158 173 … … 211 226 { 212 227 $subforums[$parent_id][$row['parent_id']]['children'][] = $forum_id; 228 } 229 230 if (!$forum_rows[$parent_id]['forum_id_unapproved_topics'] && $row['forum_id_unapproved_topics']) 231 { 232 $forum_rows[$parent_id]['forum_id_unapproved_topics'] = $forum_id; 213 233 } 214 234 … … 238 258 if ($mark_read == 'forums' || $mark_read == 'all') 239 259 { 240 $redirect = build_url( 'mark', 'hash');260 $redirect = build_url(array('mark', 'hash')); 241 261 $token = request_var('hash', ''); 242 262 if (check_link_hash($token, 'global')) … … 249 269 else 250 270 { 271 // Add 0 to forums array to mark global announcements correctly 272 $forum_ids[] = 0; 251 273 markread('topics', $forum_ids); 252 274 $message = sprintf($user->lang['RETURN_FORUM'], '<a href="' . $redirect . '">', '</a>'); … … 300 322 301 323 $forum_unread = (isset($forum_tracking_info[$forum_id]) && $row['orig_forum_last_post_time'] > $forum_tracking_info[$forum_id]) ? true : false; 324 325 // Mark the first visible forum on index as unread if there's any unread global announcement 326 if ($ga_unread && !empty($forum_ids_moderator) && $forum_id == $forum_ids_moderator[0]) 327 { 328 $forum_unread = true; 329 } 302 330 303 331 $folder_image = $folder_alt = $l_subforums = ''; … … 429 457 'S_LIST_SUBFORUMS' => ($row['display_subforum_list']) ? true : false, 430 458 'S_SUBFORUMS' => (sizeof($subforums_list)) ? true : false, 459 'S_FEED_ENABLED' => ($config['feed_forum'] && !phpbb_optionget(FORUM_OPTION_FEED_EXCLUDE, $row['forum_options'])) ? true : false, 431 460 432 461 'FORUM_ID' => $row['forum_id'], … … 452 481 'L_MODERATOR_STR' => $l_moderator, 453 482 483 'U_UNAPPROVED_TOPICS' => ($row['forum_id_unapproved_topics']) ? append_sid("{$phpbb_root_path}mcp.$phpEx", 'i=queue&mode=unapproved_topics&f=' . $row['forum_id_unapproved_topics']) : '', 454 484 'U_VIEWFORUM' => $u_viewforum, 455 485 'U_LAST_POSTER' => get_username_string('profile', $row['forum_last_poster_id'], $row['forum_last_poster_name'], $row['forum_last_poster_colour']), … … 474 504 'S_HAS_SUBFORUM' => ($visible_forums) ? true : false, 475 505 'L_SUBFORUM' => ($visible_forums == 1) ? $user->lang['SUBFORUM'] : $user->lang['SUBFORUMS'], 476 'LAST_POST_IMG' => $user->img('icon_topic_latest', 'VIEW_LATEST_POST')) 477 ); 506 'LAST_POST_IMG' => $user->img('icon_topic_latest', 'VIEW_LATEST_POST'), 507 'UNAPPROVED_IMG' => $user->img('icon_topic_unapproved', 'TOPICS_UNAPPROVED'), 508 )); 478 509 479 510 if ($return_moderators) … … 515 546 function generate_forum_nav(&$forum_data) 516 547 { 517 global $db, $user, $template, $auth ;548 global $db, $user, $template, $auth, $config; 518 549 global $phpEx, $phpbb_root_path; 519 550 … … 562 593 'FORUM_ID' => $forum_data['forum_id'], 563 594 'FORUM_NAME' => $forum_data['forum_name'], 564 'FORUM_DESC' => generate_text_for_display($forum_data['forum_desc'], $forum_data['forum_desc_uid'], $forum_data['forum_desc_bitfield'], $forum_data['forum_desc_options'])) 565 ); 595 'FORUM_DESC' => generate_text_for_display($forum_data['forum_desc'], $forum_data['forum_desc_uid'], $forum_data['forum_desc_bitfield'], $forum_data['forum_desc_options']), 596 597 'S_ENABLE_FEEDS_FORUM' => ($config['feed_forum'] && $forum_data['forum_type'] == FORUM_POST && !phpbb_optionget(FORUM_OPTION_FEED_EXCLUDE, $forum_data['forum_options'])) ? true : false, 598 )); 566 599 567 600 return; … … 659 692 global $config, $template, $db, $phpbb_root_path, $phpEx, $user, $auth; 660 693 661 // Have we disabled the display of moderators? If so, then return 662 // from whence we came ... 663 if (!$config['load_moderators']) 664 { 665 return; 666 } 667 668 $forum_sql = ''; 694 $forum_id_ary = array(); 669 695 670 696 if ($forum_id !== false) … … 675 701 } 676 702 677 // If we don't have a forum then we can't have a moderator 678 if (!sizeof($forum_id)) 679 { 680 return; 681 } 682 683 $forum_sql = 'AND m.' . $db->sql_in_set('forum_id', $forum_id); 703 // Exchange key/value pair to be able to faster check for the forum id existence 704 $forum_id_ary = array_flip($forum_id); 684 705 } 685 706 … … 702 723 ), 703 724 704 'WHERE' => "m.display_on_index = 1 $forum_sql",725 'WHERE' => 'm.display_on_index = 1', 705 726 ); 706 727 728 // We query every forum here because for caching we should not have any parameter. 707 729 $sql = $db->sql_build_query('SELECT', $sql_array); 708 730 $result = $db->sql_query($sql, 3600); … … 710 732 while ($row = $db->sql_fetchrow($result)) 711 733 { 734 $f_id = (int) $row['forum_id']; 735 736 if (!isset($forum_id_ary[$f_id])) 737 { 738 continue; 739 } 740 712 741 if (!empty($row['user_id'])) 713 742 { 714 $forum_moderators[$ row['forum_id']][] = get_username_string('full', $row['user_id'], $row['username'], $row['user_colour']);743 $forum_moderators[$f_id][] = get_username_string('full', $row['user_id'], $row['username'], $row['user_colour']); 715 744 } 716 745 else … … 720 749 if ($user->data['user_id'] != ANONYMOUS && !$auth->acl_get('u_viewprofile')) 721 750 { 722 $forum_moderators[$ row['forum_id']][] = '<span' . (($row['group_colour']) ? ' style="color:#' . $row['group_colour'] . ';"' : '') . '>' . $group_name . '</span>';751 $forum_moderators[$f_id][] = '<span' . (($row['group_colour']) ? ' style="color:#' . $row['group_colour'] . ';"' : '') . '>' . $group_name . '</span>'; 723 752 } 724 753 else 725 754 { 726 $forum_moderators[$ row['forum_id']][] = '<a' . (($row['group_colour']) ? ' style="color:#' . $row['group_colour'] . ';"' : '') . ' href="' . append_sid("{$phpbb_root_path}memberlist.$phpEx", 'mode=group&g=' . $row['group_id']) . '">' . $group_name . '</a>';755 $forum_moderators[$f_id][] = '<a' . (($row['group_colour']) ? ' style="color:#' . $row['group_colour'] . ';"' : '') . ' href="' . append_sid("{$phpbb_root_path}memberlist.$phpEx", 'mode=group&g=' . $row['group_id']) . '">' . $group_name . '</a>'; 727 756 } 728 757 } … … 847 876 function display_custom_bbcodes() 848 877 { 849 global $db, $template ;878 global $db, $template, $user; 850 879 851 880 // Start counting from 22 for the bbcode ids (every bbcode takes two ids - opening/closing) … … 861 890 while ($row = $db->sql_fetchrow($result)) 862 891 { 892 // If the helpline is defined within the language file, we will use the localised version, else just use the database entry... 893 if (isset($user->lang[strtoupper($row['bbcode_helpline'])])) 894 { 895 $row['bbcode_helpline'] = $user->lang[strtoupper($row['bbcode_helpline'])]; 896 } 897 863 898 $template->assign_block_vars('custom_tags', array( 864 899 'BBCODE_NAME' => "'[{$row['bbcode_tag']}]', '[/" . str_replace('=', '', $row['bbcode_tag']) . "]'", … … 1195 1230 * @param string $avatar_height Height of users avatar 1196 1231 * @param string $alt Optional language string for alt tag within image, can be a language key or text 1232 * @param bool $ignore_config Ignores the config-setting, to be still able to view the avatar in the UCP 1197 1233 * 1198 1234 * @return string Avatar image 1199 1235 */ 1200 function get_user_avatar($avatar, $avatar_type, $avatar_width, $avatar_height, $alt = 'USER_AVATAR' )1236 function get_user_avatar($avatar, $avatar_type, $avatar_width, $avatar_height, $alt = 'USER_AVATAR', $ignore_config = false) 1201 1237 { 1202 1238 global $user, $config, $phpbb_root_path, $phpEx; 1203 1239 1204 if (empty($avatar) || !$avatar_type )1240 if (empty($avatar) || !$avatar_type || (!$config['allow_avatar'] && !$ignore_config)) 1205 1241 { 1206 1242 return ''; … … 1212 1248 { 1213 1249 case AVATAR_UPLOAD: 1250 if (!$config['allow_avatar_upload'] && !$ignore_config) 1251 { 1252 return ''; 1253 } 1214 1254 $avatar_img = $phpbb_root_path . "download/file.$phpEx?avatar="; 1215 1255 break; 1216 1256 1217 1257 case AVATAR_GALLERY: 1258 if (!$config['allow_avatar_local'] && !$ignore_config) 1259 { 1260 return ''; 1261 } 1218 1262 $avatar_img = $phpbb_root_path . $config['avatar_gallery_path'] . '/'; 1219 1263 break; 1264 1265 case AVATAR_REMOTE: 1266 if (!$config['allow_avatar_remote'] && !$ignore_config) 1267 { 1268 return ''; 1269 } 1270 break; 1220 1271 } 1221 1272 -
trunk/forum/includes/functions_install.php
r400 r702 3 3 * 4 4 * @package install 5 * @version $Id : functions_install.php 8507 2008-04-20 04:57:29Z davidmj$5 * @version $Id$ 6 6 * @copyright (c) 2006 phpBB Group 7 7 * @license http://opensource.org/licenses/gpl-license.php GNU Public License … … 22 22 function can_load_dll($dll) 23 23 { 24 return ((@ini_get('enable_dl') || strtolower(@ini_get('enable_dl')) == 'on') && (!@ini_get('safe_mode') || strtolower(@ini_get('safe_mode')) == 'off') && @dl($dll . '.' . PHP_SHLIB_SUFFIX)) ? true : false; 24 // SQLite2 is a tricky thing, from 5.0.0 it requires PDO; if PDO is not loaded we must state that SQLite is unavailable 25 // as the installer doesn't understand that the extension has a prerequisite. 26 // 27 // On top of this sometimes the SQLite extension is compiled for a different version of PDO 28 // by some Linux distributions which causes phpBB to bomb out with a blank page. 29 // 30 // Net result we'll disable automatic inclusion of SQLite support 31 // 32 // See: r9618 and #56105 33 if ($dll == 'sqlite') 34 { 35 return false; 36 } 37 return ((@ini_get('enable_dl') || strtolower(@ini_get('enable_dl')) == 'on') && (!@ini_get('safe_mode') || strtolower(@ini_get('safe_mode')) == 'off') && function_exists('dl') && @dl($dll . '.' . PHP_SHLIB_SUFFIX)) ? true : false; 25 38 } 26 39 … … 176 189 { 177 190 global $lang; 178 191 179 192 $available_dbms = get_available_dbms(false, false, $only_20x_options); 180 193 $dbms_options = ''; … … 397 410 else 398 411 { 399 $sql = "SELECT FIRST 0 char_length('')400 FROM RDB\$DATABASE";412 $sql = 'SELECT 1 FROM RDB$DATABASE 413 WHERE BIN_AND(10, 1) = 0'; 401 414 $result = $db->sql_query($sql); 402 if (!$result) // This can only fail if char_lengthis not defined415 if (!$result) // This can only fail if BIN_AND is not defined 403 416 { 404 417 $error[] = $lang['INST_ERR_DB_NO_FIREBIRD']; … … 441 454 } 442 455 break; 443 456 444 457 case 'oracle': 445 458 if ($unicode_check) … … 463 476 } 464 477 break; 465 478 466 479 case 'postgres': 467 480 if ($unicode_check) -
trunk/forum/includes/functions_jabber.php
r400 r702 3 3 * 4 4 * @package phpBB3 5 * @version $Id : functions_jabber.php 8979 2008-10-08 12:44:23Z acydburn$5 * @version $Id$ 6 6 * @copyright (c) 2007 phpBB Group 7 7 * @license http://opensource.org/licenses/gpl-license.php GNU Public License … … 477 477 else if (in_array('PLAIN', $methods) && ($this->session['ssl'] || !empty($this->session['tls']))) 478 478 { 479 // http://www.ietf.org/rfc/rfc4616.txt (PLAIN SASL Mechanism) 479 480 $this->send("<auth xmlns='urn:ietf:params:xml:ns:xmpp-sasl' mechanism='PLAIN'>" 480 . base64_encode( chr(0) . $this->username . '@' . $this->server. chr(0) . $this->password) .481 . base64_encode($this->username . '@' . $this->server . chr(0) . $this->username . chr(0) . $this->password) . 481 482 '</auth>'); 482 483 } -
trunk/forum/includes/functions_messenger.php
r400 r702 3 3 * 4 4 * @package phpBB3 5 * @version $Id : functions_messenger.php 9078 2008-11-22 19:55:00Z acydburn$5 * @version $Id$ 6 6 * @copyright (c) 2005 phpBB Group 7 7 * @license http://opensource.org/licenses/gpl-license.php GNU Public License … … 28 28 var $mail_priority = MAIL_NORMAL_PRIORITY; 29 29 var $use_queue = true; 30 31 var $tpl_obj = NULL; 30 32 var $tpl_msg = array(); 33 var $eol = "\n"; 31 34 32 35 /** … … 39 42 $this->use_queue = (!$config['email_package_size']) ? false : $use_queue; 40 43 $this->subject = ''; 44 45 // Determine EOL character (\n for UNIX, \r\n for Windows and \r for Mac) 46 $this->eol = (!defined('PHP_EOL')) ? (($eol = strtolower(substr(PHP_OS, 0, 3))) == 'win') ? "\r\n" : (($eol == 'mac') ? "\r" : "\n") : PHP_EOL; 47 $this->eol = (!$this->eol) ? "\n" : $this->eol; 41 48 } 42 49 … … 58 65 global $config; 59 66 67 if (!trim($address)) 68 { 69 return; 70 } 71 60 72 $pos = isset($this->addresses['to']) ? sizeof($this->addresses['to']) : 0; 61 73 … … 78 90 function cc($address, $realname = '') 79 91 { 92 if (!trim($address)) 93 { 94 return; 95 } 96 80 97 $pos = isset($this->addresses['cc']) ? sizeof($this->addresses['cc']) : 0; 81 98 $this->addresses['cc'][$pos]['email'] = trim($address); … … 88 105 function bcc($address, $realname = '') 89 106 { 107 if (!trim($address)) 108 { 109 return; 110 } 111 90 112 $pos = isset($this->addresses['bcc']) ? sizeof($this->addresses['bcc']) : 0; 91 113 $this->addresses['bcc'][$pos]['email'] = trim($address); … … 99 121 { 100 122 // IM-Addresses could be empty 101 if (! $address)123 if (!trim($address)) 102 124 { 103 125 return; … … 152 174 * Set email template to use 153 175 */ 154 function template($template_file, $template_lang = '' )155 { 156 global $config, $phpbb_root_path ;176 function template($template_file, $template_lang = '', $template_path = '') 177 { 178 global $config, $phpbb_root_path, $user; 157 179 158 180 if (!trim($template_file)) 159 181 { 160 trigger_error('No template file set', E_USER_ERROR);182 trigger_error('No template file for emailing set.', E_USER_ERROR); 161 183 } 162 184 163 185 if (!trim($template_lang)) 164 186 { 187 // fall back to board default language if the user's language is 188 // missing $template_file. If this does not exist either, 189 // $tpl->set_custom_template will do a trigger_error 165 190 $template_lang = basename($config['default_lang']); 166 191 } 167 192 168 if (empty($this->tpl_msg[$template_lang . $template_file])) 169 { 170 $tpl_file = "{$phpbb_root_path}language/$template_lang/email/$template_file.txt"; 171 172 if (!file_exists($tpl_file)) 173 { 174 trigger_error("Could not find email template file [ $tpl_file ]", E_USER_ERROR); 175 } 176 177 if (($data = @file_get_contents($tpl_file)) === false) 178 { 179 trigger_error("Failed opening template file [ $tpl_file ]", E_USER_ERROR); 180 } 181 182 $this->tpl_msg[$template_lang . $template_file] = $data; 183 } 184 185 $this->msg = $this->tpl_msg[$template_lang . $template_file]; 193 // tpl_msg now holds a template object we can use to parse the template file 194 if (!isset($this->tpl_msg[$template_lang . $template_file])) 195 { 196 $this->tpl_msg[$template_lang . $template_file] = new template(); 197 $tpl = &$this->tpl_msg[$template_lang . $template_file]; 198 199 $fallback_template_path = false; 200 201 if (!$template_path) 202 { 203 $template_path = (!empty($user->lang_path)) ? $user->lang_path : $phpbb_root_path . 'language/'; 204 $template_path .= $template_lang . '/email'; 205 206 // we can only specify default language fallback when the path is not a custom one for which we 207 // do not know the default language alternative 208 if ($template_lang !== basename($config['default_lang'])) 209 { 210 $fallback_template_path = (!empty($user->lang_path)) ? $user->lang_path : $phpbb_root_path . 'language/'; 211 $fallback_template_path .= basename($config['default_lang']) . '/email'; 212 } 213 } 214 215 $tpl->set_custom_template($template_path, $template_lang . '_email', $fallback_template_path); 216 217 $tpl->set_filenames(array( 218 'body' => $template_file . '.txt', 219 )); 220 } 221 222 $this->tpl_obj = &$this->tpl_msg[$template_lang . $template_file]; 223 $this->vars = &$this->tpl_obj->_rootref; 224 $this->tpl_msg = ''; 186 225 187 226 return true; … … 193 232 function assign_vars($vars) 194 233 { 195 $this->vars = (empty($this->vars)) ? $vars : $this->vars + $vars; 234 if (!is_object($this->tpl_obj)) 235 { 236 return; 237 } 238 239 $this->tpl_obj->assign_vars($vars); 240 } 241 242 function assign_block_vars($blockname, $vars) 243 { 244 if (!is_object($this->tpl_obj)) 245 { 246 return; 247 } 248 249 $this->tpl_obj->assign_block_vars($blockname, $vars); 196 250 } 197 251 … … 204 258 205 259 // We add some standard variables we always use, no need to specify them always 206 $this->vars['U_BOARD'] = (!isset($this->vars['U_BOARD'])) ? generate_board_url() : $this->vars['U_BOARD']; 207 $this->vars['EMAIL_SIG'] = (!isset($this->vars['EMAIL_SIG'])) ? str_replace('<br />', "\n", "-- \n" . htmlspecialchars_decode($config['board_email_sig'])) : $this->vars['EMAIL_SIG']; 208 $this->vars['SITENAME'] = (!isset($this->vars['SITENAME'])) ? htmlspecialchars_decode($config['sitename']) : $this->vars['SITENAME']; 209 210 // Escape all quotes, else the eval will fail. 211 $this->msg = str_replace ("'", "\'", $this->msg); 212 $this->msg = preg_replace('#\{([a-z0-9\-_]*?)\}#is', "' . ((isset(\$this->vars['\\1'])) ? \$this->vars['\\1'] : '') . '", $this->msg); 213 214 eval("\$this->msg = '$this->msg';"); 260 if (!isset($this->vars['U_BOARD'])) 261 { 262 $this->assign_vars(array( 263 'U_BOARD' => generate_board_url(), 264 )); 265 } 266 267 if (!isset($this->vars['EMAIL_SIG'])) 268 { 269 $this->assign_vars(array( 270 'EMAIL_SIG' => str_replace('<br />', "\n", "-- \n" . htmlspecialchars_decode($config['board_email_sig'])), 271 )); 272 } 273 274 if (!isset($this->vars['SITENAME'])) 275 { 276 $this->assign_vars(array( 277 'SITENAME' => htmlspecialchars_decode($config['sitename']), 278 )); 279 } 280 281 // Parse message through template 282 $this->msg = trim($this->tpl_obj->assign_display('body')); 283 284 // Because we use \n for newlines in the body message we need to fix line encoding errors for those admins who uploaded email template files in the wrong encoding 285 $this->msg = str_replace("\r\n", "\n", $this->msg); 215 286 216 287 // We now try and pull a subject from the email body ... if it exists, … … 310 381 global $config; 311 382 383 // We could use keys here, but we won't do this for 3.0.x to retain backwards compatibility 312 384 $headers = array(); 313 385 … … 335 407 $headers[] = 'X-Priority: ' . $this->mail_priority; 336 408 $headers[] = 'X-MSMail-Priority: ' . (($this->mail_priority == MAIL_LOW_PRIORITY) ? 'Low' : (($this->mail_priority == MAIL_NORMAL_PRIORITY) ? 'Normal' : 'High')); 337 $headers[] = 'X-Mailer: PhpBB3';409 $headers[] = 'X-Mailer: phpBB3'; 338 410 $headers[] = 'X-MimeOLE: phpBB3'; 339 411 $headers[] = 'X-phpBB-Origin: phpbb://' . str_replace(array('http://', 'https://'), array('', ''), generate_board_url()); 340 412 341 // We use \n here instead of \r\n because our smtp mailer is adjusting it to \r\n automatically, whereby the php mail function only works342 // if using \n.343 344 413 if (sizeof($this->extra_headers)) 345 414 { 346 $headers [] = implode("\n", $this->extra_headers);347 } 348 349 return implode("\n", $headers);415 $headers = array_merge($headers, $this->extra_headers); 416 } 417 418 return $headers; 350 419 } 351 420 … … 360 429 { 361 430 return false; 431 } 432 433 // Addresses to send to? 434 if (empty($this->addresses) || (empty($this->addresses['to']) && empty($this->addresses['cc']) && empty($this->addresses['bcc']))) 435 { 436 // Send was successful. ;) 437 return true; 362 438 } 363 439 … … 382 458 $this->from = '<' . $config['board_contact'] . '>'; 383 459 } 460 461 $encode_eol = ($config['smtp_delivery']) ? "\r\n" : $this->eol; 384 462 385 463 // Build to, cc and bcc strings … … 394 472 foreach ($address_ary as $which_ary) 395 473 { 396 $$type .= (($$type != '') ? ', ' : '') . (($which_ary['name'] != '') ? '"' . mail_encode($which_ary['name']) . '"<' . $which_ary['email'] . '>' : $which_ary['email']);474 $$type .= (($$type != '') ? ', ' : '') . (($which_ary['name'] != '') ? mail_encode($which_ary['name'], $encode_eol) . ' <' . $which_ary['email'] . '>' : $which_ary['email']); 397 475 } 398 476 } … … 413 491 else 414 492 { 415 ob_start(); 416 $result = $config['email_function_name']($mail_to, mail_encode($this->subject), wordwrap(utf8_wordwrap($this->msg), 997, "\n", true), $headers); 417 $err_msg = ob_get_clean(); 493 $result = phpbb_mail($mail_to, $this->subject, $this->msg, $headers, $this->eol, $err_msg); 418 494 } 419 495 … … 452 528 if (empty($this->addresses['im'])) 453 529 { 454 return false; 530 // Send was successful. ;) 531 return true; 455 532 } 456 533 … … 520 597 var $package_size = 0; 521 598 var $cache_file = ''; 599 var $eol = "\n"; 522 600 523 601 /** … … 530 608 $this->data = array(); 531 609 $this->cache_file = "{$phpbb_root_path}cache/queue.$phpEx"; 610 611 // Determine EOL character (\n for UNIX, \r\n for Windows and \r for Mac) 612 $this->eol = (!defined('PHP_EOL')) ? (($eol = strtolower(substr(PHP_OS, 0, 3))) == 'win') ? "\r\n" : (($eol == 'mac') ? "\r" : "\n") : PHP_EOL; 613 $this->eol = (!$this->eol) ? "\n" : $this->eol; 532 614 } 533 615 … … 652 734 else 653 735 { 654 ob_start(); 655 $result = $config['email_function_name']($to, mail_encode($subject), wordwrap(utf8_wordwrap($msg), 997, "\n", true), $headers); 656 $err_msg = ob_get_clean(); 736 $result = phpbb_mail($to, $subject, $msg, $headers, $this->eol, $err_msg); 657 737 } 658 738 … … 705 785 { 706 786 @flock($fp, LOCK_EX); 707 fwrite($fp, "<?php\n \$this->queue_data = unserialize(" . var_export(serialize($this->queue_data), true) . ");\n\n?>");787 fwrite($fp, "<?php\nif (!defined('IN_PHPBB')) exit;\n\$this->queue_data = unserialize(" . var_export(serialize($this->queue_data), true) . ");\n\n?>"); 708 788 @flock($fp, LOCK_UN); 709 789 fclose($fp); 710 790 711 phpbb_chmod($this->cache_file, CHMOD_ WRITE);791 phpbb_chmod($this->cache_file, CHMOD_READ | CHMOD_WRITE); 712 792 } 713 793 } … … 746 826 { 747 827 @flock($fp, LOCK_EX); 748 fwrite($fp, "<?php\n \$this->queue_data = unserialize(" . var_export(serialize($this->data), true) . ");\n\n?>");828 fwrite($fp, "<?php\nif (!defined('IN_PHPBB')) exit;\n\$this->queue_data = unserialize(" . var_export(serialize($this->data), true) . ");\n\n?>"); 749 829 @flock($fp, LOCK_UN); 750 830 fclose($fp); 751 831 752 phpbb_chmod($this->cache_file, CHMOD_ WRITE);832 phpbb_chmod($this->cache_file, CHMOD_READ | CHMOD_WRITE); 753 833 } 754 834 } … … 758 838 * Replacement or substitute for PHP's mail command 759 839 */ 760 function smtpmail($addresses, $subject, $message, &$err_msg, $headers = '')840 function smtpmail($addresses, $subject, $message, &$err_msg, $headers = false) 761 841 { 762 842 global $config, $user; … … 765 845 $message = preg_replace("#(?<!\r)\n#si", "\r\n", $message); 766 846 767 if ($headers != '') 768 { 769 if (is_array($headers)) 770 { 771 $headers = (sizeof($headers) > 1) ? join("\n", $headers) : $headers[0]; 772 } 773 $headers = chop($headers); 774 775 // Make sure there are no bare linefeeds in the headers 776 $headers = preg_replace('#(?<!\r)\n#si', "\r\n", $headers); 847 if ($headers !== false) 848 { 849 if (!is_array($headers)) 850 { 851 // Make sure there are no bare linefeeds in the headers 852 $headers = preg_replace('#(?<!\r)\n#si', "\n", $headers); 853 $headers = explode("\n", $headers); 854 } 777 855 778 856 // Ok this is rather confusing all things considered, 779 857 // but we have to grab bcc and cc headers and treat them differently 780 858 // Something we really didn't take into consideration originally 781 $header_array = explode("\r\n", $headers); 782 $headers = ''; 783 784 foreach ($header_array as $header) 859 $headers_used = array(); 860 861 foreach ($headers as $header) 785 862 { 786 863 if (strpos(strtolower($header), 'cc:') === 0 || strpos(strtolower($header), 'bcc:') === 0) 787 864 { 788 $header = '';789 } 790 $headers .= ($header != '') ? $header . "\r\n" : '';791 } 792 793 $headers = chop( $headers);865 continue; 866 } 867 $headers_used[] = trim($header); 868 } 869 870 $headers = chop(implode("\r\n", $headers_used)); 794 871 } 795 872 … … 947 1024 948 1025 // Now any custom headers.... 949 $smtp->server_send("$headers\r\n"); 1026 if ($headers !== false) 1027 { 1028 $smtp->server_send("$headers\r\n"); 1029 } 950 1030 951 1031 // Ok now we are ready for the message... … … 1068 1148 1069 1149 $err_msg = ''; 1070 $local_host = (function_exists('php_uname')) ? php_uname('n') : $user->host; 1150 1151 // Here we try to determine the *real* hostname (reverse DNS entry preferrably) 1152 $local_host = $user->host; 1153 1154 if (function_exists('php_uname')) 1155 { 1156 $local_host = php_uname('n'); 1157 1158 // Able to resolve name to IP 1159 if (($addr = @gethostbyname($local_host)) !== $local_host) 1160 { 1161 // Able to resolve IP back to name 1162 if (($name = @gethostbyaddr($addr)) !== $addr) 1163 { 1164 $local_host = $name; 1165 } 1166 } 1167 } 1071 1168 1072 1169 // If we are authenticating through pop-before-smtp, we … … 1406 1503 * 1407 1504 * Please note that this version fully supports RFC 2045 section 6.8. 1505 * 1506 * @param string $eol End of line we are using (optional to be backwards compatible) 1408 1507 */ 1409 function mail_encode($str )1508 function mail_encode($str, $eol = "\r\n") 1410 1509 { 1411 1510 // define start delimimter, end delimiter and spacer 1412 1511 $start = "=?UTF-8?B?"; 1413 1512 $end = "?="; 1414 $spacer = $end . ' ' . $start; 1415 $split_length = 64; 1416 1513 $delimiter = "$eol "; 1514 1515 // Maximum length is 75. $split_length *must* be a multiple of 4, but <= 75 - strlen($start . $delimiter . $end)!!! 1516 $split_length = 60; 1417 1517 $encoded_str = base64_encode($str); 1418 1518 … … 1426 1526 if (strlen($str) === utf8_strlen($str)) 1427 1527 { 1428 return $start . implode($ spacer, str_split($encoded_str, $split_length)) . $end;1528 return $start . implode($end . $delimiter . $start, str_split($encoded_str, $split_length)) . $end; 1429 1529 } 1430 1530 … … 1442 1542 } 1443 1543 1444 $str .= $start . base64_encode($text) . $end . ' ';1445 } 1446 1447 return substr($str, 0, - 1);1544 $str .= $start . base64_encode($text) . $end . $delimiter; 1545 } 1546 1547 return substr($str, 0, -strlen($delimiter)); 1448 1548 } 1449 1549 1550 /** 1551 * Wrapper for sending out emails with the PHP's mail function 1552 */ 1553 function phpbb_mail($to, $subject, $msg, $headers, $eol, &$err_msg) 1554 { 1555 global $config; 1556 1557 // We use the EOL character for the OS here because the PHP mail function does not correctly transform line endings. On Windows SMTP is used (SMTP is \r\n), on UNIX a command is used... 1558 // Reference: http://bugs.php.net/bug.php?id=15841 1559 $headers = implode($eol, $headers); 1560 1561 ob_start(); 1562 // On some PHP Versions mail() *may* fail if there are newlines within the subject. 1563 // Newlines are used as a delimiter for lines in mail_encode() according to RFC 2045 section 6.8. 1564 // Because PHP can't decide what is wanted we revert back to the non-RFC-compliant way of separating by one space (Use '' as parameter to mail_encode() results in SPACE used) 1565 $result = $config['email_function_name']($to, mail_encode($subject, ''), wordwrap(utf8_wordwrap($msg), 997, "\n", true), $headers); 1566 $err_msg = ob_get_clean(); 1567 1568 return $result; 1569 } 1570 1450 1571 ?> -
trunk/forum/includes/functions_posting.php
r400 r702 3 3 * 4 4 * @package phpBB3 5 * @version $Id : functions_posting.php 9166 2008-12-03 16:40:53Z acydburn$5 * @version $Id$ 6 6 * @copyright (c) 2005 phpBB Group 7 7 * @license http://opensource.org/licenses/gpl-license.php GNU Public License … … 25 25 global $phpEx, $phpbb_root_path; 26 26 27 $start = request_var('start', 0); 28 27 29 if ($mode == 'window') 28 30 { … … 45 47 page_header($user->lang['SMILIES']); 46 48 49 $sql = 'SELECT COUNT(smiley_id) AS item_count 50 FROM ' . SMILIES_TABLE . ' 51 GROUP BY smiley_url'; 52 $result = $db->sql_query($sql, 3600); 53 54 $smiley_count = 0; 55 while ($row = $db->sql_fetchrow($result)) 56 { 57 ++$smiley_count; 58 } 59 $db->sql_freeresult($result); 60 47 61 $template->set_filenames(array( 48 62 'body' => 'posting_smilies.html') 63 ); 64 65 $template->assign_var('PAGINATION', 66 generate_pagination(append_sid("{$phpbb_root_path}posting.$phpEx", 'mode=smilies&f=' . $forum_id), 67 $smiley_count, $config['smilies_per_page'], $start, true) 49 68 ); 50 69 } … … 65 84 } 66 85 67 $last_url = ''; 68 69 $sql = 'SELECT * 70 FROM ' . SMILIES_TABLE . 71 (($mode == 'inline') ? ' WHERE display_on_posting = 1 ' : '') . ' 72 ORDER BY smiley_order'; 73 $result = $db->sql_query($sql, 3600); 86 if ($mode == 'window') 87 { 88 $sql = 'SELECT smiley_url, MIN(emotion) as emotion, MIN(code) AS code, smiley_width, smiley_height 89 FROM ' . SMILIES_TABLE . ' 90 GROUP BY smiley_url, smiley_width, smiley_height 91 ORDER BY MIN(smiley_order)'; 92 $result = $db->sql_query_limit($sql, $config['smilies_per_page'], $start, 3600); 93 } 94 else 95 { 96 $sql = 'SELECT * 97 FROM ' . SMILIES_TABLE . ' 98 WHERE display_on_posting = 1 99 ORDER BY smiley_order'; 100 $result = $db->sql_query($sql, 3600); 101 } 74 102 75 103 $smilies = array(); … … 85 113 if (sizeof($smilies)) 86 114 { 115 $root_path = (defined('PHPBB_USE_BOARD_URL_PATH') && PHPBB_USE_BOARD_URL_PATH) ? generate_board_url() . '/' : $phpbb_root_path; 116 87 117 foreach ($smilies as $row) 88 118 { … … 90 120 'SMILEY_CODE' => $row['code'], 91 121 'A_SMILEY_CODE' => addslashes($row['code']), 92 'SMILEY_IMG' => $ phpbb_root_path . $config['smilies_path'] . '/' . $row['smiley_url'],122 'SMILEY_IMG' => $root_path . $config['smilies_path'] . '/' . $row['smiley_url'], 93 123 'SMILEY_WIDTH' => $row['smiley_width'], 94 124 'SMILEY_HEIGHT' => $row['smiley_height'], … … 615 645 616 646 // Do not create a thumbnail if the resulting width/height is bigger than the original one 617 if ($new_width > $width && $new_height >$height)647 if ($new_width >= $width && $new_height >= $height) 618 648 { 619 649 return false; … … 630 660 } 631 661 632 @passthru(escapeshellcmd($config['img_imagick']) . 'convert' . ((defined('PHP_OS') && preg_match('#^win#i', PHP_OS)) ? '.exe' : '') . ' -quality 85 - antialias -sample ' . $new_width . 'x' . $new_height . ' "' . str_replace('\\', '/', $source) . '" +profile "*" "' . str_replace('\\', '/', $destination) . '"');662 @passthru(escapeshellcmd($config['img_imagick']) . 'convert' . ((defined('PHP_OS') && preg_match('#^win#i', PHP_OS)) ? '.exe' : '') . ' -quality 85 -geometry ' . $new_width . 'x' . $new_height . ' "' . str_replace('\\', '/', $source) . '" "' . str_replace('\\', '/', $destination) . '"'); 633 663 634 664 if (file_exists($destination)) … … 657 687 658 688 case IMG_JPG: 689 @ini_set('gd.jpeg_ignore_warning', 1); 659 690 $image = @imagecreatefromjpeg($source); 660 691 break; … … 667 698 $image = @imagecreatefromwbmp($source); 668 699 break; 700 } 701 702 if (empty($image)) 703 { 704 return false; 669 705 } 670 706 … … 752 788 foreach ($attachment_data as $i => $attachment) 753 789 { 754 $s_inline_attachment_options .= '<option value="' . $i . '">' . basename($attachment['real_filename']) . '</option>';790 $s_inline_attachment_options .= '<option value="' . $i . '">' . utf8_basename($attachment['real_filename']) . '</option>'; 755 791 } 756 792 … … 786 822 { 787 823 $hidden = ''; 788 $attach_row['real_filename'] = basename($attach_row['real_filename']);824 $attach_row['real_filename'] = utf8_basename($attach_row['real_filename']); 789 825 790 826 foreach ($attach_row as $key => $value) … … 796 832 797 833 $template->assign_block_vars('attach_row', array( 798 'FILENAME' => basename($attach_row['real_filename']),799 'A_FILENAME' => addslashes( basename($attach_row['real_filename'])),834 'FILENAME' => utf8_basename($attach_row['real_filename']), 835 'A_FILENAME' => addslashes(utf8_basename($attach_row['real_filename'])), 800 836 'FILE_COMMENT' => $attach_row['attach_comment'], 801 837 'ATTACH_ID' => $attach_row['attach_id'], … … 819 855 * Load Drafts 820 856 */ 821 function load_drafts($topic_id = 0, $forum_id = 0, $id = 0 )857 function load_drafts($topic_id = 0, $forum_id = 0, $id = 0, $pm_action = '', $msg_id = 0) 822 858 { 823 859 global $user, $db, $template, $auth; … … 912 948 // Either display as PM draft if forum_id and topic_id are empty or if access to the forums has been denied afterwards... 913 949 $link_pm = true; 914 $insert_url = append_sid("{$phpbb_root_path}ucp.$phpEx", "i=$id&mode=compose&d={$draft['draft_id']}" );950 $insert_url = append_sid("{$phpbb_root_path}ucp.$phpEx", "i=$id&mode=compose&d={$draft['draft_id']}" . (($pm_action) ? "&action=$pm_action" : '') . (($msg_id) ? "&p=$msg_id" : '')); 915 951 } 916 952 … … 945 981 " . ((!$auth->acl_get('m_approve', $forum_id)) ? 'AND p.post_approved = 1' : '') . ' 946 982 ' . (($mode == 'post_review') ? " AND p.post_id > $cur_post_id" : '') . ' 983 ' . (($mode == 'post_review_edit') ? " AND p.post_id = $cur_post_id" : '') . ' 947 984 ORDER BY p.post_time '; 948 985 $sql .= ($mode == 'post_review') ? 'ASC' : 'DESC'; … … 963 1000 } 964 1001 1002 // Handle 'post_review_edit' like 'post_review' from now on 1003 if ($mode == 'post_review_edit') 1004 { 1005 $mode = 'post_review'; 1006 } 1007 965 1008 $sql = $db->sql_build_query('SELECT', array( 966 'SELECT' => 'u.username, u.user_id, u.user_colour, p.* ',1009 'SELECT' => 'u.username, u.user_id, u.user_colour, p.*, z.friend, z.foe', 967 1010 968 1011 'FROM' => array( 969 1012 USERS_TABLE => 'u', 970 1013 POSTS_TABLE => 'p', 1014 ), 1015 1016 'LEFT_JOIN' => array( 1017 array( 1018 'FROM' => array(ZEBRA_TABLE => 'z'), 1019 'ON' => 'z.user_id = ' . $user->data['user_id'] . ' AND z.zebra_id = p.poster_id' 1020 ) 971 1021 ), 972 1022 … … 1061 1111 $post_subject = censor_text($post_subject); 1062 1112 1113 $post_anchor = ($mode == 'post_review') ? 'ppr' . $row['post_id'] : 'pr' . $row['post_id']; 1114 $u_show_post = append_sid($phpbb_root_path . 'viewtopic.' . $phpEx, "f=$forum_id&t=$topic_id&p={$row['post_id']}&view=show#p{$row['post_id']}"); 1115 1063 1116 $template->assign_block_vars($mode . '_row', array( 1064 1117 'POST_AUTHOR_FULL' => get_username_string('full', $poster_id, $row['username'], $row['user_colour'], $row['post_username']), … … 1068 1121 1069 1122 'S_HAS_ATTACHMENTS' => (!empty($attachments[$row['post_id']])) ? true : false, 1123 'S_FRIEND' => ($row['friend']) ? true : false, 1124 'S_IGNORE_POST' => ($row['foe']) ? true : false, 1125 'L_IGNORE_POST' => ($row['foe']) ? sprintf($user->lang['POST_BY_FOE'], get_username_string('full', $poster_id, $row['username'], $row['user_colour'], $row['post_username']), "<a href=\"{$u_show_post}\" onclick=\"dE('{$post_anchor}', 1); return false;\">", '</a>') : '', 1070 1126 1071 1127 'POST_SUBJECT' => $post_subject, … … 1114 1170 if (!$topic_notification && !$forum_notification) 1115 1171 { 1116 trigger_error(' WRONG_NOTIFICATION_MODE');1172 trigger_error('NO_MODE'); 1117 1173 } 1118 1174 … … 1502 1558 } 1503 1559 1560 if (($post_mode == 'delete') || ($post_mode == 'delete_last_post') || ($post_mode == 'delete_first_post')) 1561 { 1562 $sql = 'SELECT 1 AS has_attachments 1563 FROM ' . ATTACHMENTS_TABLE . ' 1564 WHERE topic_id = ' . $topic_id; 1565 $result = $db->sql_query_limit($sql, 1); 1566 $has_attachments = (int) $db->sql_fetchfield('has_attachments'); 1567 $db->sql_freeresult($result); 1568 1569 if (!$has_attachments) 1570 { 1571 $sql_data[TOPICS_TABLE] .= ', topic_attachment = 0'; 1572 } 1573 } 1574 1504 1575 // $sql_data[USERS_TABLE] = ($data['post_postcount']) ? 'user_posts = user_posts - 1' : ''; 1505 1576 … … 1553 1624 /** 1554 1625 * Submit Post 1626 * @todo Split up and create lightweight, simple API for this. 1555 1627 */ 1556 function submit_post($mode, $subject, $username, $topic_type, &$poll, &$data, $update_message = true )1628 function submit_post($mode, $subject, $username, $topic_type, &$poll, &$data, $update_message = true, $update_search_index = true) 1557 1629 { 1558 1630 global $db, $auth, $user, $config, $phpEx, $template, $phpbb_root_path; … … 1606 1678 1607 1679 // This variable indicates if the user is able to post or put into the queue - it is used later for all code decisions regarding approval 1680 // The variable name should be $post_approved, because it indicates if the post is approved or not 1608 1681 $post_approval = 1; 1609 1682 1610 // Check the permissions for post approval, as well as the queue trigger where users are put on approval with a post count lower than specified. Moderators are not affected. 1611 if ((($config['enable_queue_trigger'] && $user->data['user_posts'] < $config['queue_trigger_posts']) || !$auth->acl_get('f_noapprove', $data['forum_id'])) && !$auth->acl_get('m_approve', $data['forum_id'])) 1612 { 1683 // Check the permissions for post approval. Moderators are not affected. 1684 if (!$auth->acl_get('f_noapprove', $data['forum_id']) && !$auth->acl_get('m_approve', $data['forum_id'])) 1685 { 1686 // Post not approved, but in queue 1613 1687 $post_approval = 0; 1688 } 1689 1690 // Mods are able to force approved/unapproved posts. True means the post is approved, false the post is unapproved 1691 if (isset($data['force_approved_state'])) 1692 { 1693 $post_approval = ($data['force_approved_state']) ? 1 : 0; 1614 1694 } 1615 1695 … … 1726 1806 'topic_poster' => (int) $user->data['user_id'], 1727 1807 'topic_time' => $current_time, 1808 'topic_last_view_time' => $current_time, 1728 1809 'forum_id' => ($topic_type == POST_GLOBAL) ? 0 : $data['forum_id'], 1729 1810 'icon_id' => $data['icon_id'], … … 1739 1820 if (isset($poll['poll_options']) && !empty($poll['poll_options'])) 1740 1821 { 1822 $poll_start = ($poll['poll_start']) ? $poll['poll_start'] : $current_time; 1823 $poll_length = $poll['poll_length'] * 86400; 1824 if ($poll_length < 0) 1825 { 1826 $poll_start = $poll_start + $poll_length; 1827 if ($poll_start < 0) 1828 { 1829 $poll_start = 0; 1830 } 1831 $poll_length = 1; 1832 } 1833 1741 1834 $sql_data[TOPICS_TABLE]['sql'] = array_merge($sql_data[TOPICS_TABLE]['sql'], array( 1742 1835 'poll_title' => $poll['poll_title'], 1743 'poll_start' => ($poll['poll_start']) ? $poll['poll_start'] : $current_time,1836 'poll_start' => $poll_start, 1744 1837 'poll_max_options' => $poll['poll_max_options'], 1745 'poll_length' => ($poll['poll_length'] * 86400),1838 'poll_length' => $poll_length, 1746 1839 'poll_vote_change' => $poll['poll_vote_change']) 1747 1840 ); … … 1761 1854 1762 1855 case 'reply': 1763 $sql_data[TOPICS_TABLE]['stat'][] = 'topic_replies_real = topic_replies_real + 1, topic_bumped = 0, topic_bumper = 0' . (($post_approval) ? ', topic_replies = topic_replies + 1' : '') . ((!empty($data['attachment_data']) || (isset($data['topic_attachment']) && $data['topic_attachment'])) ? ', topic_attachment = 1' : ''); 1856 $sql_data[TOPICS_TABLE]['stat'][] = 'topic_last_view_time = ' . $current_time . ', 1857 topic_replies_real = topic_replies_real + 1, 1858 topic_bumped = 0, 1859 topic_bumper = 0' . 1860 (($post_approval) ? ', topic_replies = topic_replies + 1' : '') . 1861 ((!empty($data['attachment_data']) || (isset($data['topic_attachment']) && $data['topic_attachment'])) ? ', topic_attachment = 1' : ''); 1862 1764 1863 $sql_data[USERS_TABLE]['stat'][] = "user_lastpost_time = $current_time" . (($auth->acl_get('f_postcount', $data['forum_id']) && $post_approval) ? ', user_posts = user_posts + 1' : ''); 1765 1864 … … 1772 1871 case 'edit_topic': 1773 1872 case 'edit_first_post': 1873 if (isset($poll['poll_options']) && !empty($poll['poll_options'])) 1874 { 1875 $poll_start = ($poll['poll_start']) ? $poll['poll_start'] : $current_time; 1876 $poll_length = $poll['poll_length'] * 86400; 1877 if ($poll_length < 0) 1878 { 1879 $poll_start = $poll_start + $poll_length; 1880 if ($poll_start < 0) 1881 { 1882 $poll_start = 0; 1883 } 1884 $poll_length = 1; 1885 } 1886 } 1774 1887 1775 1888 $sql_data[TOPICS_TABLE]['sql'] = array( … … 1782 1895 'topic_time_limit' => ($topic_type == POST_STICKY || $topic_type == POST_ANNOUNCE) ? ($data['topic_time_limit'] * 86400) : 0, 1783 1896 'poll_title' => (isset($poll['poll_options'])) ? $poll['poll_title'] : '', 1784 'poll_start' => (isset($poll['poll_options'])) ? (($poll['poll_start']) ? $poll['poll_start'] : $current_time): 0,1897 'poll_start' => (isset($poll['poll_options'])) ? $poll_start : 0, 1785 1898 'poll_max_options' => (isset($poll['poll_options'])) ? $poll['poll_max_options'] : 1, 1786 'poll_length' => (isset($poll['poll_options'])) ? ($poll['poll_length'] * 86400): 0,1899 'poll_length' => (isset($poll['poll_options'])) ? $poll_length : 0, 1787 1900 'poll_vote_change' => (isset($poll['poll_vote_change'])) ? $poll['poll_vote_change'] : 0, 1901 'topic_last_view_time' => $current_time, 1788 1902 1789 1903 'topic_attachment' => (!empty($data['attachment_data'])) ? 1 : (isset($data['topic_attachment']) ? $data['topic_attachment'] : 0), … … 1811 1925 $sql_data[FORUMS_TABLE]['stat'][] = 'forum_posts = forum_posts - ' . ($topic_row['topic_replies'] + 1); 1812 1926 1813 set_config ('num_topics', $config['num_topics'] -1, true);1814 set_config ('num_posts', $config['num_posts'] - ($topic_row['topic_replies'] +1), true);1927 set_config_count('num_topics', -1, true); 1928 set_config_count('num_posts', ($topic_row['topic_replies'] + 1) * (-1), true); 1815 1929 1816 1930 // Only decrement this post, since this is the one non-approved now … … 1829 1943 if (!$post_approval && $data['post_approved']) 1830 1944 { 1831 $sql_data[TOPICS_TABLE]['stat'][] = 'topic_replies = topic_replies - 1 ';1945 $sql_data[TOPICS_TABLE]['stat'][] = 'topic_replies = topic_replies - 1, topic_last_view_time = ' . $current_time; 1832 1946 $sql_data[FORUMS_TABLE]['stat'][] = 'forum_posts = forum_posts - 1'; 1833 1947 1834 set_config ('num_posts', $config['num_posts'] -1, true);1948 set_config_count('num_posts', -1, true); 1835 1949 1836 1950 if ($auth->acl_get('f_postcount', $data['forum_id'])) … … 2073 2187 { 2074 2188 // insert attachment into db 2075 if (!@file_exists($phpbb_root_path . $config['upload_path'] . '/' . basename($orphan_rows[$attach_row['attach_id']]['physical_filename'])))2189 if (!@file_exists($phpbb_root_path . $config['upload_path'] . '/' . utf8_basename($orphan_rows[$attach_row['attach_id']]['physical_filename']))) 2076 2190 { 2077 2191 continue; … … 2099 2213 if ($space_taken && $files_added) 2100 2214 { 2101 set_config ('upload_dir_size', $config['upload_dir_size'] +$space_taken, true);2102 set_config ('num_files', $config['num_files'] +$files_added, true);2215 set_config_count('upload_dir_size', $space_taken, true); 2216 set_config_count('num_files', $files_added, true); 2103 2217 } 2104 2218 } … … 2333 2447 if ($post_mode == 'post') 2334 2448 { 2335 set_config ('num_topics', $config['num_topics'] +1, true);2336 set_config ('num_posts', $config['num_posts'] +1, true);2449 set_config_count('num_topics', 1, true); 2450 set_config_count('num_posts', 1, true); 2337 2451 } 2338 2452 2339 2453 if ($post_mode == 'reply') 2340 2454 { 2341 set_config ('num_posts', $config['num_posts'] +1, true);2455 set_config_count('num_posts', 1, true); 2342 2456 } 2343 2457 } … … 2377 2491 2378 2492 // Index message contents 2379 if ($update_ message&& $data['enable_indexing'])2493 if ($update_search_index && $data['enable_indexing']) 2380 2494 { 2381 2495 // Select the search method and do some additional checks to ensure it can actually be utilised … … 2412 2526 $db->sql_query($sql); 2413 2527 } 2414 else if ( $data['notify_set'] && !$data['notify'])2528 else if (($config['email_enable'] || $config['jab_enable']) && $data['notify_set'] && !$data['notify']) 2415 2529 { 2416 2530 $sql = 'DELETE FROM ' . TOPICS_WATCH_TABLE . ' … … 2429 2543 // Mark this topic as read 2430 2544 // We do not use post_time here, this is intended (post_time can have a date in the past if editing a message) 2431 markread('topic', $data['forum_id'], $data['topic_id'], time());2545 markread('topic', (($topic_type == POST_GLOBAL) ? 0 : $data['forum_id']), $data['topic_id'], time()); 2432 2546 2433 2547 // … … 2437 2551 FROM ' . FORUMS_TRACK_TABLE . ' 2438 2552 WHERE user_id = ' . $user->data['user_id'] . ' 2439 AND forum_id = ' . $data['forum_id'];2553 AND forum_id = ' . (($topic_type == POST_GLOBAL) ? 0 : $data['forum_id']); 2440 2554 $result = $db->sql_query($sql); 2441 2555 $f_mark_time = (int) $db->sql_fetchfield('mark_time'); … … 2450 2564 { 2451 2565 // Update forum info 2452 $sql = 'SELECT forum_last_post_time 2453 FROM ' . FORUMS_TABLE . ' 2454 WHERE forum_id = ' . $data['forum_id']; 2566 if ($topic_type == POST_GLOBAL) 2567 { 2568 $sql = 'SELECT MAX(topic_last_post_time) as forum_last_post_time 2569 FROM ' . TOPICS_TABLE . ' 2570 WHERE forum_id = 0'; 2571 } 2572 else 2573 { 2574 $sql = 'SELECT forum_last_post_time 2575 FROM ' . FORUMS_TABLE . ' 2576 WHERE forum_id = ' . $data['forum_id']; 2577 } 2455 2578 $result = $db->sql_query($sql); 2456 2579 $forum_last_post_time = (int) $db->sql_fetchfield('forum_last_post_time'); 2457 2580 $db->sql_freeresult($result); 2458 2581 2459 update_forum_tracking_info( $data['forum_id'], $forum_last_post_time, $f_mark_time, false);2582 update_forum_tracking_info((($topic_type == POST_GLOBAL) ? 0 : $data['forum_id']), $forum_last_post_time, $f_mark_time, false); 2460 2583 } 2461 2584 -
trunk/forum/includes/functions_privmsgs.php
r400 r702 3 3 * 4 4 * @package phpBB3 5 * @version $Id : functions_privmsgs.php 8993 2008-10-10 17:38:17Z toonarmy$5 * @version $Id$ 6 6 * @copyright (c) 2005 phpBB Group 7 7 * @license http://opensource.org/licenses/gpl-license.php GNU Public License … … 895 895 case 'delete_marked': 896 896 897 global $auth; 898 899 if (!$auth->acl_get('u_pm_delete')) 900 { 901 trigger_error('NO_AUTH_DELETE_MESSAGE'); 902 } 903 897 904 if (confirm_box(true)) 898 905 { … … 1146 1153 $sql = 'SELECT user_id, username, user_colour 1147 1154 FROM ' . USERS_TABLE . ' 1148 WHERE ' . $db->sql_in_set('user_id', $u) . ' 1149 AND user_type IN (' . USER_NORMAL . ', ' . USER_FOUNDER . ')'; 1155 WHERE ' . $db->sql_in_set('user_id', $u); 1150 1156 $result = $db->sql_query($sql); 1151 1157 … … 1351 1357 AND ug.user_pending = 0 1352 1358 AND u.user_id = ug.user_id 1353 AND u.user_type IN (' . USER_NORMAL . ', ' . USER_FOUNDER . ')' . 1359 AND u.user_type IN (' . USER_NORMAL . ', ' . USER_FOUNDER . ')' . 1354 1360 $sql_allow_pm; 1355 1361 $result = $db->sql_query($sql); … … 1357 1363 while ($row = $db->sql_fetchrow($result)) 1358 1364 { 1365 // Additionally, do not include the sender if he is in the group he wants to send to. ;) 1366 if ($row['user_id'] === $user->data['user_id']) 1367 { 1368 continue; 1369 } 1370 1359 1371 $field = ($data['address_list']['g'][$row['group_id']] == 'to') ? 'to' : 'bcc'; 1360 1372 $recipients[$row['user_id']] = $field; … … 1406 1418 'bbcode_uid' => $data['bbcode_uid'], 1407 1419 'to_address' => implode(':', $to), 1408 'bcc_address' => implode(':', $bcc) 1420 'bcc_address' => implode(':', $bcc), 1421 'message_reported' => 0, 1409 1422 ); 1410 1423 break; … … 1546 1559 { 1547 1560 // insert attachment into db 1548 if (!@file_exists($phpbb_root_path . $config['upload_path'] . '/' . basename($orphan_rows[$attach_row['attach_id']]['physical_filename'])))1561 if (!@file_exists($phpbb_root_path . $config['upload_path'] . '/' . utf8_basename($orphan_rows[$attach_row['attach_id']]['physical_filename']))) 1549 1562 { 1550 1563 continue; … … 1572 1585 if ($space_taken && $files_added) 1573 1586 { 1574 set_config ('upload_dir_size', $config['upload_dir_size'] +$space_taken, true);1575 set_config ('num_files', $config['num_files'] +$files_added, true);1587 set_config_count('upload_dir_size', $space_taken, true); 1588 set_config_count('num_files', $files_added, true); 1576 1589 } 1577 1590 } … … 1692 1705 global $db, $user, $config, $template, $phpbb_root_path, $phpEx, $auth, $bbcode; 1693 1706 1707 // Select all receipts and the author from the pm we currently view, to only display their pm-history 1708 $sql = 'SELECT author_id, user_id 1709 FROM ' . PRIVMSGS_TO_TABLE . " 1710 WHERE msg_id = $msg_id 1711 AND folder_id <> " . PRIVMSGS_HOLD_BOX; 1712 $result = $db->sql_query($sql); 1713 1714 $recipients = array(); 1715 while ($row = $db->sql_fetchrow($result)) 1716 { 1717 $recipients[] = (int) $row['user_id']; 1718 $recipients[] = (int) $row['author_id']; 1719 } 1720 $db->sql_freeresult($result); 1721 $recipients = array_unique($recipients); 1722 1694 1723 // Get History Messages (could be newer) 1695 1724 $sql = 'SELECT t.*, p.*, u.* … … 1697 1726 WHERE t.msg_id = p.msg_id 1698 1727 AND p.author_id = u.user_id 1699 AND t.folder_id NOT IN (' . PRIVMSGS_NO_BOX . ', ' . PRIVMSGS_HOLD_BOX . ") 1728 AND t.folder_id NOT IN (' . PRIVMSGS_NO_BOX . ', ' . PRIVMSGS_HOLD_BOX . ') 1729 AND ' . $db->sql_in_set('t.author_id', $recipients, false, true) . " 1700 1730 AND t.user_id = $user_id"; 1731 1732 // We no longer need those. 1733 unset($recipients); 1701 1734 1702 1735 if (!$message_row['root_level']) … … 1764 1797 $next_history_pm = $previous_history_pm = $prev_id = 0; 1765 1798 1766 foreach ($rowset as $id => $row) 1767 { 1799 // Re-order rowset to be able to get the next/prev message rows... 1800 $rowset = array_values($rowset); 1801 1802 for ($i = 0, $size = sizeof($rowset); $i < $size; $i++) 1803 { 1804 $row = &$rowset[$i]; 1805 $id = (int) $row['msg_id']; 1806 1768 1807 $author_id = $row['author_id']; 1769 1808 $folder_id = (int) $row['folder_id']; … … 1776 1815 $decoded_message = false; 1777 1816 1778 if ($in_post_mode && $auth->acl_get('u_sendpm') && $author_id != ANONYMOUS && $author_id != $user->data['user_id'])1817 if ($in_post_mode && $auth->acl_get('u_sendpm') && $author_id != ANONYMOUS) 1779 1818 { 1780 1819 $decoded_message = $message; … … 1796 1835 if ($id == $msg_id) 1797 1836 { 1798 $next_history_pm = next($rowset); 1799 $next_history_pm = (sizeof($next_history_pm)) ? (int) $next_history_pm['msg_id'] : 0; 1837 $next_history_pm = (isset($rowset[$i + 1])) ? (int) $rowset[$i + 1]['msg_id'] : 0; 1800 1838 $previous_history_pm = $prev_id; 1801 1839 } … … 1820 1858 'MSG_ID' => $row['msg_id'], 1821 1859 'U_VIEW_MESSAGE' => "$url&f=$folder_id&p=" . $row['msg_id'], 1822 'U_QUOTE' => (!$in_post_mode && $auth->acl_get('u_sendpm') && $author_id != ANONYMOUS && $author_id != $user->data['user_id']) ? "$url&mode=compose&action=quote&f=" . $folder_id . "&p=" . $row['msg_id'] : '',1860 'U_QUOTE' => (!$in_post_mode && $auth->acl_get('u_sendpm') && $author_id != ANONYMOUS) ? "$url&mode=compose&action=quote&f=" . $folder_id . "&p=" . $row['msg_id'] : '', 1823 1861 'U_POST_REPLY_PM' => ($author_id != $user->data['user_id'] && $author_id != ANONYMOUS && $auth->acl_get('u_sendpm')) ? "$url&mode=compose&action=reply&f=$folder_id&p=" . $row['msg_id'] : '') 1824 1862 ); 1825 unset($rowset[$i d]);1863 unset($rowset[$i]); 1826 1864 $prev_id = $id; 1827 1865 } … … 1859 1897 } 1860 1898 1899 /** 1900 * Generates an array of coloured recipient names from a list of PMs - (groups & users) 1901 * 1902 * @param array $pm_by_id An array of rows from PRIVMSGS_TABLE, keys are the msg_ids. 1903 * 1904 * @return array 2D Array: array(msg_id => array('username or group string', ...), ...) 1905 * Usernames are generated with {@link get_username_string get_username_string} 1906 * Groups are coloured and have a link to the membership page 1907 */ 1908 function get_recipient_strings($pm_by_id) 1909 { 1910 global $db, $phpbb_root_path, $phpEx, $user; 1911 1912 $address_list = $recipient_list = $address = array(); 1913 1914 $_types = array('u', 'g'); 1915 1916 foreach ($pm_by_id as $message_id => $row) 1917 { 1918 $address[$message_id] = rebuild_header(array('to' => $row['to_address'], 'bcc' => $row['bcc_address'])); 1919 1920 foreach ($_types as $ug_type) 1921 { 1922 if (isset($address[$message_id][$ug_type]) && sizeof($address[$message_id][$ug_type])) 1923 { 1924 foreach ($address[$message_id][$ug_type] as $ug_id => $in_to) 1925 { 1926 $recipient_list[$ug_type][$ug_id] = array('name' => $user->lang['NA'], 'colour' => ''); 1927 } 1928 } 1929 } 1930 } 1931 1932 foreach ($_types as $ug_type) 1933 { 1934 if (!empty($recipient_list[$ug_type])) 1935 { 1936 if ($ug_type == 'u') 1937 { 1938 $sql = 'SELECT user_id as id, username as name, user_colour as colour 1939 FROM ' . USERS_TABLE . ' 1940 WHERE '; 1941 } 1942 else 1943 { 1944 $sql = 'SELECT group_id as id, group_name as name, group_colour as colour, group_type 1945 FROM ' . GROUPS_TABLE . ' 1946 WHERE '; 1947 } 1948 $sql .= $db->sql_in_set(($ug_type == 'u') ? 'user_id' : 'group_id', array_map('intval', array_keys($recipient_list[$ug_type]))); 1949 1950 $result = $db->sql_query($sql); 1951 1952 while ($row = $db->sql_fetchrow($result)) 1953 { 1954 if ($ug_type == 'g') 1955 { 1956 $row['name'] = ($row['group_type'] == GROUP_SPECIAL) ? $user->lang['G_' . $row['name']] : $row['name']; 1957 } 1958 1959 $recipient_list[$ug_type][$row['id']] = array('name' => $row['name'], 'colour' => $row['colour']); 1960 } 1961 $db->sql_freeresult($result); 1962 } 1963 } 1964 1965 foreach ($address as $message_id => $adr_ary) 1966 { 1967 foreach ($adr_ary as $type => $id_ary) 1968 { 1969 foreach ($id_ary as $ug_id => $_id) 1970 { 1971 if ($type == 'u') 1972 { 1973 $address_list[$message_id][] = get_username_string('full', $ug_id, $recipient_list[$type][$ug_id]['name'], $recipient_list[$type][$ug_id]['colour']); 1974 } 1975 else 1976 { 1977 $user_colour = ($recipient_list[$type][$ug_id]['colour']) ? ' style="font-weight: bold; color:#' . $recipient_list[$type][$ug_id]['colour'] . '"' : ''; 1978 $link = '<a href="' . append_sid("{$phpbb_root_path}memberlist.$phpEx", 'mode=group&g=' . $ug_id) . '"' . $user_colour . '>'; 1979 $address_list[$message_id][] = $link . $recipient_list[$type][$ug_id]['name'] . (($link) ? '</a>' : ''); 1980 } 1981 } 1982 } 1983 } 1984 1985 return $address_list; 1986 } 1987 1861 1988 ?> -
trunk/forum/includes/functions_profile_fields.php
r400 r702 3 3 * 4 4 * @package phpBB3 5 * @version $Id : functions_profile_fields.php 9127 2008-11-26 19:58:35Z acydburn$5 * @version $Id$ 6 6 * @copyright (c) 2005 phpBB Group 7 7 * @license http://opensource.org/licenses/gpl-license.php GNU Public License … … 40 40 { 41 41 case 'register': 42 // If the field is required we show it on the registration page and do not show hidden fields43 $sql_where .= ' AND f.field_show_on_reg = 1 AND f.field_no_view = 0';42 // If the field is required we show it on the registration page 43 $sql_where .= ' AND f.field_show_on_reg = 1'; 44 44 break; 45 45 … … 93 93 switch ($field_type) 94 94 { 95 case FIELD_INT:96 case FIELD_DROPDOWN:97 $field_value = (int) $field_value;98 break;99 100 case FIELD_BOOL:101 $field_value = (bool) $field_value;102 break;103 }104 105 switch ($field_type)106 {107 95 case FIELD_DATE: 108 96 $field_validate = explode('-', $field_value); … … 134 122 135 123 case FIELD_BOOL: 124 $field_value = (bool) $field_value; 125 136 126 if (!$field_value && $field_data['field_required']) 137 127 { … … 141 131 142 132 case FIELD_INT: 143 if ( empty($field_value)&& !$field_data['field_required'])133 if (trim($field_value) === '' && !$field_data['field_required']) 144 134 { 145 135 return false; 146 136 } 137 138 $field_value = (int) $field_value; 147 139 148 140 if ($field_value < $field_data['field_minlen']) … … 157 149 158 150 case FIELD_DROPDOWN: 151 $field_value = (int) $field_value; 152 159 153 if ($field_value == $field_data['field_novalue'] && $field_data['field_required']) 160 154 { … … 165 159 case FIELD_STRING: 166 160 case FIELD_TEXT: 167 if ( empty($field_value)&& !$field_data['field_required'])161 if (trim($field_value) === '' && !$field_data['field_required']) 168 162 { 169 163 return false; 170 164 } 171 else if ( empty($field_value)&& $field_data['field_required'])165 else if (trim($field_value) === '' && $field_data['field_required']) 172 166 { 173 167 return 'FIELD_REQUIRED'; … … 260 254 261 255 /** 262 * Submit profile field 256 * Submit profile field for validation 263 257 * @access public 264 258 */ … … 271 265 { 272 266 case 'register': 273 // If the field is required we show it on the registration page and do not show hidden fields274 $sql_where .= ' AND f.field_show_on_reg = 1 AND f.field_no_view = 0';267 // If the field is required we show it on the registration page 268 $sql_where .= ' AND f.field_show_on_reg = 1'; 275 269 break; 276 270 … … 351 345 352 346 /** 347 * Update profile field data directly 348 */ 349 function update_profile_field_data($user_id, &$cp_data) 350 { 351 global $db; 352 353 if (!sizeof($cp_data)) 354 { 355 return; 356 } 357 358 switch ($db->sql_layer) 359 { 360 case 'oracle': 361 case 'firebird': 362 case 'postgres': 363 $right_delim = $left_delim = '"'; 364 break; 365 366 case 'sqlite': 367 case 'mssql': 368 case 'mssql_odbc': 369 $right_delim = ']'; 370 $left_delim = '['; 371 break; 372 373 case 'mysql': 374 case 'mysql4': 375 case 'mysqli': 376 $right_delim = $left_delim = '`'; 377 break; 378 } 379 380 // use new array for the UPDATE; changes in the key do not affect the original array 381 $cp_data_sql = array(); 382 foreach ($cp_data as $key => $value) 383 { 384 // Firebird is case sensitive with delimiter 385 $cp_data_sql[$left_delim . (($db->sql_layer == 'firebird' || $db->sql_layer == 'oracle') ? strtoupper($key) : $key) . $right_delim] = $value; 386 } 387 388 $sql = 'UPDATE ' . PROFILE_FIELDS_DATA_TABLE . ' 389 SET ' . $db->sql_build_array('UPDATE', $cp_data_sql) . " 390 WHERE user_id = $user_id"; 391 $db->sql_query($sql); 392 393 if (!$db->sql_affectedrows()) 394 { 395 $cp_data_sql['user_id'] = (int) $user_id; 396 397 $db->sql_return_on_error(true); 398 399 $sql = 'INSERT INTO ' . PROFILE_FIELDS_DATA_TABLE . ' ' . $db->sql_build_array('INSERT', $cp_data_sql); 400 $db->sql_query($sql); 401 402 $db->sql_return_on_error(false); 403 } 404 } 405 406 /** 353 407 * Assign fields to template, used for viewprofile, viewtopic and memberlist (if load setting is enabled) 354 408 * This is directly connected to the user -> mode == grab is to grab the user specific fields, mode == show is for assigning the row to the template … … 455 509 { 456 510 case 'int': 457 if ($value == '')511 if ($value === '') 458 512 { 459 513 return NULL; … … 571 625 else 572 626 { 573 if (!$preview && isset($user->profile_fields[$user_ident]) && is_null($user->profile_fields[$user_ident]))627 if (!$preview && array_key_exists($user_ident, $user->profile_fields) && is_null($user->profile_fields[$user_ident])) 574 628 { 575 629 $value = NULL; … … 585 639 } 586 640 587 return (is_null($value) ) ? '' : (int) $value;641 return (is_null($value) || $value === '') ? '' : (int) $value; 588 642 } 589 643 else -
trunk/forum/includes/functions_template.php
r400 r702 3 3 * 4 4 * @package phpBB3 5 * @version $Id : functions_template.php 8813 2008-09-04 11:52:01Z aptx$5 * @version $Id$ 6 6 * @copyright (c) 2005 phpBB Group, sections (c) 2001 ispi of Lincoln Inc 7 7 * @license http://opensource.org/licenses/gpl-license.php GNU Public License … … 129 129 $code = preg_replace('#<!-- PHP -->.*?<!-- ENDPHP -->#s', '<!-- PHP -->', $code); 130 130 131 preg_match_all('#<!-- INCLUDE ( [a-zA-Z0-9\_\-\+\./]+) -->#', $code, $matches);131 preg_match_all('#<!-- INCLUDE (\{\$?[A-Z0-9\-_]+\}|[a-zA-Z0-9\_\-\+\./]+) -->#', $code, $matches); 132 132 $include_blocks = $matches[1]; 133 $code = preg_replace('#<!-- INCLUDE [a-zA-Z0-9\_\-\+\./]+-->#', '<!-- INCLUDE -->', $code);133 $code = preg_replace('#<!-- INCLUDE (?:\{\$?[A-Z0-9\-_]+\}|[a-zA-Z0-9\_\-\+\./]+) -->#', '<!-- INCLUDE -->', $code); 134 134 135 135 preg_match_all('#<!-- INCLUDEPHP ([a-zA-Z0-9\_\-\+\./]+) -->#', $code, $matches); … … 194 194 case 'INCLUDE': 195 195 $temp = array_shift($include_blocks); 196 197 // Dynamic includes 198 // Cheap match rather than a full blown regexp, we already know 199 // the format of the input so just use string manipulation. 200 if ($temp[0] == '{') 201 { 202 $file = false; 203 204 if ($temp[1] == '$') 205 { 206 $var = substr($temp, 2, -1); 207 //$file = $this->template->_tpldata['DEFINE']['.'][$var]; 208 $temp = "\$this->_tpldata['DEFINE']['.']['$var']"; 209 } 210 else 211 { 212 $var = substr($temp, 1, -1); 213 //$file = $this->template->_rootref[$var]; 214 $temp = "\$this->_rootref['$var']"; 215 } 216 } 217 else 218 { 219 $file = $temp; 220 } 221 196 222 $compile_blocks[] = '<?php ' . $this->compile_tag_include($temp) . ' ?>'; 197 $this->template->_tpl_include($temp, false); 223 224 // No point in checking variable includes 225 if ($file) 226 { 227 $this->template->_tpl_include($file, false); 228 } 198 229 break; 199 230 … … 221 252 } 222 253 254 // Remove unused opening/closing tags 255 $template_php = str_replace(' ?><?php ', ' ', $template_php); 256 257 // Now add a newline after each php closing tag which already has a newline 258 // PHP itself strips a newline if a closing tag is used (this is documented behaviour) and it is mostly not intended by style authors to remove newlines 259 $template_php = preg_replace('#\?\>([\r\n])#', '?>\1\1', $template_php); 260 223 261 // There will be a number of occasions where we switch into and out of 224 262 // PHP mode instantaneously. Rather than "burden" the parser with this 225 263 // we'll strip out such occurences, minimising such switching 226 $template_php = str_replace(' ?><?php ', ' ', $template_php); 227 228 return (!$no_echo) ? $template_php : "\$$echo_var .= '" . $template_php . "'"; 264 if ($no_echo) 265 { 266 return "\$$echo_var .= '" . $template_php . "'"; 267 } 268 269 return $template_php; 229 270 } 230 271 … … 254 295 if (strpos($text_blocks, '{L_') !== false) 255 296 { 256 $text_blocks = preg_replace('#\{L_([ a-z0-9\-_]*)\}#is', "<?php echo ((isset(\$this->_rootref['L_\\1'])) ? \$this->_rootref['L_\\1'] : ((isset(\$user->lang['\\1'])) ? \$user->lang['\\1'] : '{ \\1 }')); ?>", $text_blocks);297 $text_blocks = preg_replace('#\{L_([A-Z0-9\-_]+)\}#', "<?php echo ((isset(\$this->_rootref['L_\\1'])) ? \$this->_rootref['L_\\1'] : ((isset(\$user->lang['\\1'])) ? \$user->lang['\\1'] : '{ \\1 }')); ?>", $text_blocks); 257 298 } 258 299 … … 261 302 if (strpos($text_blocks, '{LA_') !== false) 262 303 { 263 $text_blocks = preg_replace('#\{LA_([ a-z0-9\-_]*)\}#is', "<?php echo ((isset(\$this->_rootref['LA_\\1'])) ? \$this->_rootref['LA_\\1'] : ((isset(\$this->_rootref['L_\\1'])) ? addslashes(\$this->_rootref['L_\\1']) : ((isset(\$user->lang['\\1'])) ? addslashes(\$user->lang['\\1']) : '{ \\1 }'))); ?>", $text_blocks);304 $text_blocks = preg_replace('#\{LA_([A-Z0-9\-_]+)\}#', "<?php echo ((isset(\$this->_rootref['LA_\\1'])) ? \$this->_rootref['LA_\\1'] : ((isset(\$this->_rootref['L_\\1'])) ? addslashes(\$this->_rootref['L_\\1']) : ((isset(\$user->lang['\\1'])) ? addslashes(\$user->lang['\\1']) : '{ \\1 }'))); ?>", $text_blocks); 264 305 } 265 306 266 307 // Handle remaining varrefs 267 $text_blocks = preg_replace('#\{([ a-z0-9\-_]+)\}#is', "<?php echo (isset(\$this->_rootref['\\1'])) ? \$this->_rootref['\\1'] : ''; ?>", $text_blocks);268 $text_blocks = preg_replace('#\{\$([ a-z0-9\-_]+)\}#is', "<?php echo (isset(\$this->_tpldata['DEFINE']['.']['\\1'])) ? \$this->_tpldata['DEFINE']['.']['\\1'] : ''; ?>", $text_blocks);308 $text_blocks = preg_replace('#\{([A-Z0-9\-_]+)\}#', "<?php echo (isset(\$this->_rootref['\\1'])) ? \$this->_rootref['\\1'] : ''; ?>", $text_blocks); 309 $text_blocks = preg_replace('#\{\$([A-Z0-9\-_]+)\}#', "<?php echo (isset(\$this->_tpldata['DEFINE']['.']['\\1'])) ? \$this->_tpldata['DEFINE']['.']['\\1'] : ''; ?>", $text_blocks); 269 310 270 311 return; … … 592 633 function compile_tag_include($tag_args) 593 634 { 635 // Process dynamic includes 636 if ($tag_args[0] == '$') 637 { 638 return "if (isset($tag_args)) { \$this->_tpl_include($tag_args); }"; 639 } 640 594 641 return "\$this->_tpl_include('$tag_args');"; 595 642 } … … 601 648 function compile_tag_include_php($tag_args) 602 649 { 603 return " include('" . $tag_args . "');";650 return "\$this->_php_include('$tag_args');"; 604 651 } 605 652 … … 749 796 $filename = $this->template->cachepath . str_replace('/', '.', $this->template->filename[$handle]) . '.' . $phpEx; 750 797 798 $data = "<?php if (!defined('IN_PHPBB')) exit;" . ((strpos($data, '<?php') === 0) ? substr($data, 5) : ' ?>' . $data); 799 751 800 if ($fp = @fopen($filename, 'wb')) 752 801 { … … 756 805 @fclose($fp); 757 806 758 phpbb_chmod($filename, CHMOD_ WRITE);807 phpbb_chmod($filename, CHMOD_READ | CHMOD_WRITE); 759 808 } 760 809 -
trunk/forum/includes/functions_transfer.php
r400 r702 3 3 * 4 4 * @package phpBB3 5 * @version $Id : functions_transfer.php 8479 2008-03-29 00:22:48Z naderman$5 * @version $Id$ 6 6 * @copyright (c) 2005 phpBB Group 7 7 * @license http://opensource.org/licenses/gpl-license.php GNU Public License … … 207 207 208 208 $this->_chdir($directory); 209 $result = $this->_ls( '');209 $result = $this->_ls(); 210 210 211 211 if ($result !== false && is_array($result)) … … 317 317 } 318 318 319 // login to the server 320 if (!@ftp_login($this->connection, $this->username, $this->password)) 321 { 322 return 'ERR_UNABLE_TO_LOGIN'; 323 } 324 319 325 // attempt to turn pasv mode on 320 326 @ftp_pasv($this->connection, true); 321 322 // login to the server323 if (!@ftp_login($this->connection, $this->username, $this->password))324 {325 return 'ERR_UNABLE_TO_LOGIN';326 }327 327 328 328 // change to the root directory … … 461 461 function _ls($dir = './') 462 462 { 463 return @ftp_nlist($this->connection, $dir); 463 $list = @ftp_nlist($this->connection, $dir); 464 465 // See bug #46295 - Some FTP daemons don't like './' 466 if ($dir === './') 467 { 468 // Let's try some alternatives 469 $list = (empty($list)) ? @ftp_nlist($this->connection, '.') : $list; 470 $list = (empty($list)) ? @ftp_nlist($this->connection, '') : $list; 471 } 472 473 // Return on error 474 if ($list === false) 475 { 476 return false; 477 } 478 479 // Remove path if prepended 480 foreach ($list as $key => $item) 481 { 482 // Use same separator for item and dir 483 $item = str_replace('\\', '/', $item); 484 $dir = str_replace('\\', '/', $dir); 485 486 if (!empty($dir) && strpos($item, $dir) === 0) 487 { 488 $item = substr($item, strlen($dir)); 489 } 490 491 $list[$key] = $item; 492 } 493 494 return $list; 464 495 } 465 496 … … 707 738 while (!@feof($this->data_connection)) 708 739 { 709 $list[] = preg_replace('#[\r\n]#', '', @fgets($this->data_connection, 512)); 740 $filename = preg_replace('#[\r\n]#', '', @fgets($this->data_connection, 512)); 741 742 if ($filename !== '') 743 { 744 $list[] = $filename; 745 } 710 746 } 711 747 $this->_close_data_connection(); 748 749 // Clear buffer 750 $this->_check_command(); 751 752 // See bug #46295 - Some FTP daemons don't like './' 753 if ($dir === './' && empty($list)) 754 { 755 // Let's try some alternatives 756 $list = $this->_ls('.'); 757 758 if (empty($list)) 759 { 760 $list = $this->_ls(''); 761 } 762 763 return $list; 764 } 765 766 // Remove path if prepended 767 foreach ($list as $key => $item) 768 { 769 // Use same separator for item and dir 770 $item = str_replace('\\', '/', $item); 771 $dir = str_replace('\\', '/', $dir); 772 773 if (!empty($dir) && strpos($item, $dir) === 0) 774 { 775 $item = substr($item, strlen($dir)); 776 } 777 778 $list[$key] = $item; 779 } 712 780 713 781 return $list; … … 792 860 $response .= $result; 793 861 } 794 while (substr($res ponse, 3, 1) != ' ');862 while (substr($result, 3, 1) !== ' '); 795 863 796 864 if (!preg_match('#^[123]#', $response)) -
trunk/forum/includes/functions_upload.php
r400 r702 3 3 * 4 4 * @package phpBB3 5 * @version $Id : functions_upload.php 8783 2008-08-23 17:23:40Z acydburn$5 * @version $Id$ 6 6 * @copyright (c) 2005 phpBB Group 7 7 * @license http://opensource.org/licenses/gpl-license.php GNU Public License … … 59 59 $this->filename = $upload_ary['tmp_name']; 60 60 $this->filesize = $upload_ary['size']; 61 $name = trim( htmlspecialchars(basename($upload_ary['name'])));61 $name = trim(utf8_htmlspecialchars(utf8_basename($upload_ary['name']))); 62 62 $this->realname = $this->uploadname = (STRIP) ? stripslashes($name) : $name; 63 63 $this->mimetype = $upload_ary['type']; … … 291 291 $upload_mode = (@ini_get('open_basedir') || @ini_get('safe_mode') || strtolower(@ini_get('safe_mode')) == 'on') ? 'move' : 'copy'; 292 292 $upload_mode = ($this->local) ? 'local' : $upload_mode; 293 $this->destination_file = $this->destination_path . '/' . basename($this->realname);293 $this->destination_file = $this->destination_path . '/' . utf8_basename($this->realname); 294 294 295 295 // Check if the file already exist, else there is something wrong... … … 314 314 { 315 315 $this->error[] = sprintf($user->lang[$this->upload->error_prefix . 'GENERAL_UPLOAD_ERROR'], $this->destination_file); 316 return false;317 316 } 318 317 } 319 320 @unlink($this->filename);321 318 322 319 break; … … 329 326 { 330 327 $this->error[] = sprintf($user->lang[$this->upload->error_prefix . 'GENERAL_UPLOAD_ERROR'], $this->destination_file); 331 return false;332 328 } 333 329 } 334 335 @unlink($this->filename);336 330 337 331 break; … … 342 336 { 343 337 $this->error[] = sprintf($user->lang[$this->upload->error_prefix . 'GENERAL_UPLOAD_ERROR'], $this->destination_file); 344 return false;345 338 } 346 @unlink($this->filename);347 339 348 340 break; 341 } 342 343 // Remove temporary filename 344 @unlink($this->filename); 345 346 if (sizeof($this->error)) 347 { 348 return false; 349 349 } 350 350 … … 418 418 if ($this->upload->max_filesize && ($this->get('filesize') > $this->upload->max_filesize || $this->filesize == 0)) 419 419 { 420 $size_lang = ($this->upload->max_filesize >= 1048576) ? $user->lang['MIB'] : (($this->upload->max_filesize >= 1024) ? $user->lang['KIB'] : $user->lang['BYTES'] );421 420 $max_filesize = get_formatted_filesize($this->upload->max_filesize, false); 422 421 423 $this->error[] = sprintf($user->lang[$this->upload->error_prefix . 'WRONG_FILESIZE'], $max_filesize , $size_lang);422 $this->error[] = sprintf($user->lang[$this->upload->error_prefix . 'WRONG_FILESIZE'], $max_filesize['value'], $max_filesize['unit']); 424 423 425 424 return false; … … 595 594 if ($file->get('filename') == 'none') 596 595 { 597 $file->error[] = (@ini_get('upload_max_filesize') == '') ? $user->lang[$this->error_prefix . 'PHP_SIZE_NA'] : sprintf($user->lang[$this->error_prefix . 'PHP_SIZE_OVERRUN'], @ini_get('upload_max_filesize')); 596 $max_filesize = @ini_get('upload_max_filesize'); 597 $unit = 'MB'; 598 599 if (!empty($max_filesize)) 600 { 601 $unit = strtolower(substr($max_filesize, -1, 1)); 602 $max_filesize = (int) $max_filesize; 603 604 $unit = ($unit == 'k') ? 'KB' : (($unit == 'g') ? 'GB' : 'MB'); 605 } 606 607 $file->error[] = (empty($max_filesize)) ? $user->lang[$this->error_prefix . 'PHP_SIZE_NA'] : sprintf($user->lang[$this->error_prefix . 'PHP_SIZE_OVERRUN'], $max_filesize, $user->lang[$unit]); 598 608 return $file; 599 609 } … … 625 635 if ($filedata === false) 626 636 { 627 $_FILES[$form_name]['name'] = basename($source_file);637 $_FILES[$form_name]['name'] = utf8_basename($source_file); 628 638 $_FILES[$form_name]['size'] = 0; 629 639 $mimetype = ''; … … 671 681 if ($file->get('filename') == 'none') 672 682 { 673 $file->error[] = (@ini_get('upload_max_filesize') == '') ? $user->lang[$this->error_prefix . 'PHP_SIZE_NA'] : sprintf($user->lang[$this->error_prefix . 'PHP_SIZE_OVERRUN'], @ini_get('upload_max_filesize')); 683 $max_filesize = @ini_get('upload_max_filesize'); 684 $unit = 'MB'; 685 686 if (!empty($max_filesize)) 687 { 688 $unit = strtolower(substr($max_filesize, -1, 1)); 689 $max_filesize = (int) $max_filesize; 690 691 $unit = ($unit == 'k') ? 'KB' : (($unit == 'g') ? 'GB' : 'MB'); 692 } 693 694 $file->error[] = (empty($max_filesize)) ? $user->lang[$this->error_prefix . 'PHP_SIZE_NA'] : sprintf($user->lang[$this->error_prefix . 'PHP_SIZE_OVERRUN'], $max_filesize, $user->lang[$unit]); 674 695 return $file; 675 696 } … … 726 747 727 748 $url['path'] = implode('', $url['path']); 728 $upload_ary['name'] = basename($url['path']) . (($ext) ? '.' . $ext : '');749 $upload_ary['name'] = utf8_basename($url['path']) . (($ext) ? '.' . $ext : ''); 729 750 $filename = $url['path']; 730 751 $filesize = 0; … … 819 840 { 820 841 case 1: 821 $error = (@ini_get('upload_max_filesize') == '') ? $user->lang[$this->error_prefix . 'PHP_SIZE_NA'] : sprintf($user->lang[$this->error_prefix . 'PHP_SIZE_OVERRUN'], @ini_get('upload_max_filesize')); 842 $max_filesize = @ini_get('upload_max_filesize'); 843 $unit = 'MB'; 844 845 if (!empty($max_filesize)) 846 { 847 $unit = strtolower(substr($max_filesize, -1, 1)); 848 $max_filesize = (int) $max_filesize; 849 850 $unit = ($unit == 'k') ? 'KB' : (($unit == 'g') ? 'GB' : 'MB'); 851 } 852 853 $error = (empty($max_filesize)) ? $user->lang[$this->error_prefix . 'PHP_SIZE_NA'] : sprintf($user->lang[$this->error_prefix . 'PHP_SIZE_OVERRUN'], $max_filesize, $user->lang[$unit]); 822 854 break; 823 855 824 856 case 2: 825 $size_lang = ($this->max_filesize >= 1048576) ? $user->lang['MIB'] : (($this->max_filesize >= 1024) ? $user->lang['KIB'] : $user->lang['BYTES']);826 857 $max_filesize = get_formatted_filesize($this->max_filesize, false); 827 858 828 $error = sprintf($user->lang[$this->error_prefix . 'WRONG_FILESIZE'], $max_filesize , $size_lang);859 $error = sprintf($user->lang[$this->error_prefix . 'WRONG_FILESIZE'], $max_filesize['value'], $max_filesize['unit']); 829 860 break; 830 861 … … 859 890 if ($this->max_filesize && ($file->get('filesize') > $this->max_filesize || $file->get('filesize') == 0)) 860 891 { 861 $size_lang = ($this->max_filesize >= 1048576) ? $user->lang['MIB'] : (($this->max_filesize >= 1024) ? $user->lang['KIB'] : $user->lang['BYTES']);862 892 $max_filesize = get_formatted_filesize($this->max_filesize, false); 863 893 864 $file->error[] = sprintf($user->lang[$this->error_prefix . 'WRONG_FILESIZE'], $max_filesize , $size_lang);894 $file->error[] = sprintf($user->lang[$this->error_prefix . 'WRONG_FILESIZE'], $max_filesize['value'], $max_filesize['unit']); 865 895 } 866 896 -
trunk/forum/includes/functions_user.php
r400 r702 3 3 * 4 4 * @package phpBB3 5 * @version $Id : functions_user.php 8949 2008-09-26 21:29:05Z toonarmy$5 * @version $Id$ 6 6 * @copyright (c) 2005 phpBB Group 7 7 * @license http://opensource.org/licenses/gpl-license.php GNU Public License … … 172 172 'user_pass_convert' => 0, 173 173 'user_email' => strtolower($user_row['user_email']), 174 'user_email_hash' => crc32(strtolower($user_row['user_email'])) . strlen($user_row['user_email']),174 'user_email_hash' => phpbb_email_hash($user_row['user_email']), 175 175 'group_id' => $user_row['group_id'], 176 176 'user_type' => $user_row['user_type'], … … 188 188 'user_regdate' => time(), 189 189 'user_passchg' => time(), 190 'user_options' => 895, 190 'user_options' => 230271, 191 // We do not set the new flag here - registration scripts need to specify it 192 'user_new' => 0, 191 193 192 194 'user_inactive_reason' => 0, … … 276 278 group_set_user_default($user_row['group_id'], array($user_id), false); 277 279 280 // Add to newly registered users group if user_new is 1 281 if ($config['new_member_post_limit'] && $sql_ary['user_new']) 282 { 283 $sql = 'SELECT group_id 284 FROM ' . GROUPS_TABLE . " 285 WHERE group_name = 'NEWLY_REGISTERED' 286 AND group_type = " . GROUP_SPECIAL; 287 $result = $db->sql_query($sql); 288 $add_group_id = (int) $db->sql_fetchfield('group_id'); 289 $db->sql_freeresult($result); 290 291 if ($add_group_id) 292 { 293 // Because these actions only fill the log unneccessarily we skip the add_log() entry with a little hack. :/ 294 $GLOBALS['skip_add_log'] = true; 295 296 // Add user to "newly registered users" group and set to default group if admin specified so. 297 if ($config['new_member_group_default']) 298 { 299 group_user_add($add_group_id, $user_id, false, false, true); 300 } 301 else 302 { 303 group_user_add($add_group_id, $user_id); 304 } 305 306 unset($GLOBALS['skip_add_log']); 307 } 308 } 309 278 310 // set the newest user and adjust the user count if the user is a normal user and no activation mail is sent 279 if ($user_row['user_type'] == USER_NORMAL )311 if ($user_row['user_type'] == USER_NORMAL || $user_row['user_type'] == USER_FOUNDER) 280 312 { 281 313 set_config('newest_user_id', $user_id, true); 282 314 set_config('newest_username', $user_row['username'], true); 283 set_config ('num_users', $config['num_users'] +1, true);315 set_config_count('num_users', 1, true); 284 316 285 317 $sql = 'SELECT group_colour … … 420 452 SET topic_last_poster_id = ' . ANONYMOUS . ", topic_last_poster_name = '" . $db->sql_escape($post_username) . "', topic_last_poster_colour = '' 421 453 WHERE topic_last_poster_id = $user_id"; 454 $db->sql_query($sql); 455 456 $sql = 'UPDATE ' . ATTACHMENTS_TABLE . ' 457 SET poster_id = ' . ANONYMOUS . " 458 WHERE poster_id = $user_id"; 422 459 $db->sql_query($sql); 423 460 … … 491 528 $db->sql_transaction('begin'); 492 529 493 $table_ary = array(USERS_TABLE, USER_GROUP_TABLE, TOPICS_WATCH_TABLE, FORUMS_WATCH_TABLE, ACL_USERS_TABLE, TOPICS_TRACK_TABLE, TOPICS_POSTED_TABLE, FORUMS_TRACK_TABLE, PROFILE_FIELDS_DATA_TABLE, MODERATOR_CACHE_TABLE, DRAFTS_TABLE, BOOKMARKS_TABLE );530 $table_ary = array(USERS_TABLE, USER_GROUP_TABLE, TOPICS_WATCH_TABLE, FORUMS_WATCH_TABLE, ACL_USERS_TABLE, TOPICS_TRACK_TABLE, TOPICS_POSTED_TABLE, FORUMS_TRACK_TABLE, PROFILE_FIELDS_DATA_TABLE, MODERATOR_CACHE_TABLE, DRAFTS_TABLE, BOOKMARKS_TABLE, SESSIONS_KEYS_TABLE); 494 531 495 532 foreach ($table_ary as $table) … … 501 538 502 539 $cache->destroy('sql', MODERATOR_CACHE_TABLE); 540 541 // Delete user log entries about this user 542 $sql = 'DELETE FROM ' . LOG_TABLE . ' 543 WHERE reportee_id = ' . $user_id; 544 $db->sql_query($sql); 545 546 // Change user_id to anonymous for this users triggered events 547 $sql = 'UPDATE ' . LOG_TABLE . ' 548 SET user_id = ' . ANONYMOUS . ' 549 WHERE user_id = ' . $user_id; 550 $db->sql_query($sql); 551 552 // Delete the user_id from the zebra table 553 $sql = 'DELETE FROM ' . ZEBRA_TABLE . ' 554 WHERE user_id = ' . $user_id . ' 555 OR zebra_id = ' . $user_id; 556 $db->sql_query($sql); 557 558 // Delete the user_id from the banlist 559 $sql = 'DELETE FROM ' . BANLIST_TABLE . ' 560 WHERE ban_userid = ' . $user_id; 561 $db->sql_query($sql); 562 563 // Delete the user_id from the session table 564 $sql = 'DELETE FROM ' . SESSIONS_TABLE . ' 565 WHERE session_user_id = ' . $user_id; 566 $db->sql_query($sql); 503 567 504 568 // Remove any undelivered mails... … … 570 634 if ($user_row['user_type'] != USER_INACTIVE && $user_row['user_type'] != USER_IGNORE) 571 635 { 572 set_config ('num_users', $config['num_users'] -1, true);636 set_config_count('num_users', -1, true); 573 637 } 574 638 … … 651 715 if ($deactivated) 652 716 { 653 set_config ('num_users', $config['num_users'] - $deactivated, true);717 set_config_count('num_users', $deactivated * (-1), true); 654 718 } 655 719 656 720 if ($activated) 657 721 { 658 set_config ('num_users', $config['num_users'] +$activated, true);722 set_config_count('num_users', $activated, true); 659 723 } 660 724 … … 895 959 } 896 960 } 897 else 961 962 if (empty($banlist_ary)) 898 963 { 899 964 trigger_error('NO_IPS_DEFINED'); … … 968 1033 while ($row = $db->sql_fetchrow($result)); 969 1034 970 $banlist_ary = array_unique(array_diff($banlist_ary, $banlist_ary_tmp)); 1035 $banlist_ary_tmp = array_intersect($banlist_ary, $banlist_ary_tmp); 1036 1037 if (sizeof($banlist_ary_tmp)) 1038 { 1039 // One or more entities are already banned/excluded, delete the existing bans, so they can be re-inserted with the given new length 1040 $sql = 'DELETE FROM ' . BANLIST_TABLE . ' 1041 WHERE ' . $db->sql_in_set($type, $banlist_ary_tmp) . ' 1042 AND ban_exclude = ' . (int) $ban_exclude; 1043 $db->sql_query($sql); 1044 } 1045 971 1046 unset($banlist_ary_tmp); 972 1047 } … … 1051 1126 $log_entry = ($ban_exclude) ? 'LOG_BAN_EXCLUDE_' : 'LOG_BAN_'; 1052 1127 1053 // Add to moderator and admin log1128 // Add to moderator log, admin log and user notes 1054 1129 add_log('admin', $log_entry . strtoupper($mode), $ban_reason, $ban_list_log); 1055 1130 add_log('mod', 0, 0, $log_entry . strtoupper($mode), $ban_reason, $ban_list_log); 1131 if ($mode == 'user') 1132 { 1133 foreach ($banlist_ary as $user_id) 1134 { 1135 add_log('user', $user_id, $log_entry . strtoupper($mode), $ban_reason, $ban_list_log); 1136 } 1137 } 1056 1138 1057 1139 $cache->destroy('sql', BANLIST_TABLE); … … 1092 1174 { 1093 1175 case 'user': 1094 $sql = 'SELECT u.username AS unban_info 1176 $sql = 'SELECT u.username AS unban_info, u.user_id 1095 1177 FROM ' . USERS_TABLE . ' u, ' . BANLIST_TABLE . ' b 1096 1178 WHERE ' . $db->sql_in_set('b.ban_id', $unban_sql) . ' … … 1113 1195 1114 1196 $l_unban_list = ''; 1197 $user_ids_ary = array(); 1115 1198 while ($row = $db->sql_fetchrow($result)) 1116 1199 { 1117 1200 $l_unban_list .= (($l_unban_list != '') ? ', ' : '') . $row['unban_info']; 1201 if ($mode == 'user') 1202 { 1203 $user_ids_ary[] = $row['user_id']; 1204 } 1118 1205 } 1119 1206 $db->sql_freeresult($result); … … 1123 1210 $db->sql_query($sql); 1124 1211 1125 // Add to moderator and admin log1212 // Add to moderator log, admin log and user notes 1126 1213 add_log('admin', 'LOG_UNBAN_' . strtoupper($mode), $l_unban_list); 1127 1214 add_log('mod', 0, 0, 'LOG_UNBAN_' . strtoupper($mode), $l_unban_list); 1215 if ($mode == 'user') 1216 { 1217 foreach ($user_ids_ary as $user_id) 1218 { 1219 add_log('user', $user_id, 'LOG_UNBAN_' . strtoupper($mode), $l_unban_list); 1220 } 1221 } 1128 1222 } 1129 1223 … … 1135 1229 /** 1136 1230 * Whois facility 1231 * 1232 * @link http://tools.ietf.org/html/rfc3912 RFC3912: WHOIS Protocol Specification 1137 1233 */ 1138 1234 function user_ipwhois($ip) … … 1147 1243 } 1148 1244 1149 $match = array(1150 '#RIPE\.NET#is' => 'whois.ripe.net',1151 '#whois\.apnic\.net#is' => 'whois.apnic.net',1152 '#nic\.ad\.jp#is' => 'whois.nic.ad.jp',1153 '#whois\.registro\.br#is' => 'whois.registro.br'1154 );1155 1156 1245 if (($fsk = @fsockopen('whois.arin.net', 43))) 1157 1246 { 1158 fputs($fsk, "$ip\n"); 1247 // CRLF as per RFC3912 1248 fputs($fsk, "$ip\r\n"); 1159 1249 while (!feof($fsk)) 1160 1250 { … … 1164 1254 } 1165 1255 1166 foreach (array_keys($match) as $server) 1167 { 1168 if (preg_match($server, $ipwhois)) 1169 { 1170 $ipwhois = ''; 1171 if (($fsk = @fsockopen($match[$server], 43))) 1172 { 1173 fputs($fsk, "$ip\n"); 1174 while (!feof($fsk)) 1175 { 1176 $ipwhois .= fgets($fsk, 1024); 1177 } 1178 @fclose($fsk); 1179 } 1180 break; 1181 } 1256 $match = array(); 1257 1258 // Test for referrals from ARIN to other whois databases, roll on rwhois 1259 if (preg_match('#ReferralServer: whois://(.+)#im', $ipwhois, $match)) 1260 { 1261 if (strpos($match[1], ':') !== false) 1262 { 1263 $pos = strrpos($match[1], ':'); 1264 $server = substr($match[1], 0, $pos); 1265 $port = (int) substr($match[1], $pos + 1); 1266 unset($pos); 1267 } 1268 else 1269 { 1270 $server = $match[1]; 1271 $port = 43; 1272 } 1273 1274 $buffer = ''; 1275 1276 if (($fsk = @fsockopen($server, $port))) 1277 { 1278 fputs($fsk, "$ip\r\n"); 1279 while (!feof($fsk)) 1280 { 1281 $buffer .= fgets($fsk, 1024); 1282 } 1283 @fclose($fsk); 1284 } 1285 1286 // Use the result from ARIN if we don't get any result here 1287 $ipwhois = (empty($buffer)) ? $ipwhois : $buffer; 1182 1288 } 1183 1289 … … 1415 1521 else if ($mbstring) 1416 1522 { 1417 $regex = '[-\]_+ [[:upper:][:lower:][:digit:]]+';1523 $regex = '[-\]_+ \[[:upper:][:lower:][:digit:]]+'; 1418 1524 } 1419 1525 else … … 1440 1546 else if ($mbstring) 1441 1547 { 1442 $matches = array(); 1443 mb_ereg_search_init('^' . $username . '$', $regex, $matches); 1548 mb_ereg_search_init($username, '^' . $regex . '$'); 1444 1549 if (!mb_ereg_search()) 1445 1550 { … … 1623 1728 $sql = 'SELECT user_email_hash 1624 1729 FROM ' . USERS_TABLE . " 1625 WHERE user_email_hash = " . (crc32($email) . strlen($email));1730 WHERE user_email_hash = " . $db->sql_escape(phpbb_email_hash($email)); 1626 1731 $result = $db->sql_query($sql); 1627 1732 $row = $db->sql_fetchrow($result); … … 2057 2162 { 2058 2163 $avatar_list[$file][$avatar_row_count][$avatar_col_count] = array( 2059 'file' => "$file/$sub_file",2060 'filename' => $sub_file,2164 'file' => rawurlencode($file) . '/' . rawurlencode($sub_file), 2165 'filename' => rawurlencode($sub_file), 2061 2166 'name' => ucfirst(str_replace('_', ' ', preg_replace('#^(.*)\..*$#', '\1', $sub_file))), 2062 2167 ); … … 2345 2450 2346 2451 $error = array(); 2347 $attribute_ary = array( 2348 'group_colour' => 'string', 2349 'group_rank' => 'int', 2350 'group_avatar' => 'string', 2351 'group_avatar_type' => 'int', 2352 'group_avatar_width' => 'int', 2353 'group_avatar_height' => 'int', 2354 2355 'group_receive_pm' => 'int', 2356 'group_legend' => 'int', 2357 'group_message_limit' => 'int', 2358 'group_max_recipients' => 'int', 2359 2360 'group_founder_manage' => 'int', 2361 ); 2362 2363 // Those are group-only attributes 2364 $group_only_ary = array('group_receive_pm', 'group_legend', 'group_message_limit', 'group_max_recipients', 'group_founder_manage'); 2452 2453 // Attributes which also affect the users table 2454 $user_attribute_ary = array('group_colour', 'group_rank', 'group_avatar', 'group_avatar_type', 'group_avatar_width', 'group_avatar_height'); 2365 2455 2366 2456 // Check data. Limit group name length. … … 2400 2490 if (sizeof($group_attributes)) 2401 2491 { 2402 foreach ($attribute_ary as $attribute => $_type) 2403 { 2404 if (isset($group_attributes[$attribute])) 2405 { 2406 settype($group_attributes[$attribute], $_type); 2407 $sql_ary[$attribute] = $group_attributes[$attribute]; 2408 } 2409 } 2492 // Merge them with $sql_ary to properly update the group 2493 $sql_ary = array_merge($sql_ary, $group_attributes); 2410 2494 } 2411 2495 … … 2432 2516 remove_default_avatar($group_id, $user_ary); 2433 2517 } 2518 2434 2519 if (isset($sql_ary['group_rank']) && !$sql_ary['group_rank']) 2435 2520 { … … 2447 2532 WHERE group_id = $group_id"; 2448 2533 $db->sql_query($sql); 2534 2535 // One special case is the group skip auth setting. If this was changed we need to purge permissions for this group 2536 if (isset($group_attributes['group_skip_auth'])) 2537 { 2538 // Get users within this group... 2539 $sql = 'SELECT user_id 2540 FROM ' . USER_GROUP_TABLE . ' 2541 WHERE group_id = ' . $group_id . ' 2542 AND user_pending = 0'; 2543 $result = $db->sql_query($sql); 2544 2545 $user_id_ary = array(); 2546 while ($row = $db->sql_fetchrow($result)) 2547 { 2548 $user_id_ary[] = $row['user_id']; 2549 } 2550 $db->sql_freeresult($result); 2551 2552 if (!empty($user_id_ary)) 2553 { 2554 global $auth; 2555 2556 // Clear permissions cache of relevant users 2557 $auth->acl_clear_prefetch($user_id_ary); 2558 } 2559 } 2449 2560 } 2450 2561 else … … 2457 2568 { 2458 2569 $group_id = $db->sql_nextid(); 2570 2459 2571 if (isset($sql_ary['group_avatar_type']) && $sql_ary['group_avatar_type'] == AVATAR_UPLOAD) 2460 2572 { … … 2467 2579 if (sizeof($group_attributes)) 2468 2580 { 2469 foreach ($attribute_ary as $attribute => $_type) 2470 { 2471 if (isset($group_attributes[$attribute]) && !in_array($attribute, $group_only_ary)) 2581 // Go through the user attributes array, check if a group attribute matches it and then set it. ;) 2582 foreach ($user_attribute_ary as $attribute) 2583 { 2584 if (!isset($group_attributes[$attribute])) 2472 2585 { 2473 // If we are about to set an avatar, we will not overwrite user avatars if no group avatar is set... 2474 if (strpos($attribute, 'group_avatar') === 0 && !$group_attributes[$attribute]) 2475 { 2476 continue; 2477 } 2478 2479 $sql_ary[$attribute] = $group_attributes[$attribute]; 2586 continue; 2480 2587 } 2588 2589 // If we are about to set an avatar, we will not overwrite user avatars if no group avatar is set... 2590 if (strpos($attribute, 'group_avatar') === 0 && !$group_attributes[$attribute]) 2591 { 2592 continue; 2593 } 2594 2595 $sql_ary[$attribute] = $group_attributes[$attribute]; 2481 2596 } 2482 2597 } … … 2682 2797 if ($default) 2683 2798 { 2684 group_ set_user_default($group_id, $user_id_ary, $group_attributes);2799 group_user_attributes('default', $group_id, $user_id_ary, false, $group_name, $group_attributes); 2685 2800 } 2686 2801 … … 2695 2810 } 2696 2811 2697 $log = ($leader) ? 'LOG_MODS_ADDED' : 'LOG_USERS_ADDED';2812 $log = ($leader) ? 'LOG_MODS_ADDED' : (($pending) ? 'LOG_USERS_PENDING' : 'LOG_USERS_ADDED'); 2698 2813 2699 2814 add_log('admin', $log, $group_name, implode(', ', $username_ary)); … … 2714 2829 function group_user_del($group_id, $user_id_ary = false, $username_ary = false, $group_name = false) 2715 2830 { 2716 global $db, $auth; 2717 2718 $group_order = array('ADMINISTRATORS', 'GLOBAL_MODERATORS', 'REGISTERED_COPPA', 'REGISTERED', 'BOTS', 'GUESTS'); 2831 global $db, $auth, $config; 2832 2833 if ($config['coppa_enable']) 2834 { 2835 $group_order = array('ADMINISTRATORS', 'GLOBAL_MODERATORS', 'NEWLY_REGISTERED', 'REGISTERED_COPPA', 'REGISTERED', 'BOTS', 'GUESTS'); 2836 } 2837 else 2838 { 2839 $group_order = array('ADMINISTRATORS', 'GLOBAL_MODERATORS', 'NEWLY_REGISTERED', 'REGISTERED', 'BOTS', 'GUESTS'); 2840 } 2719 2841 2720 2842 // We need both username and user_id info … … 2780 2902 while ($row = $db->sql_fetchrow($result)) 2781 2903 { 2782 if ($default_groups[$row['user_id']] == $group_id && (!isset($temp_ary[$row['user_id']]) || array_search($row['group_name'], $group_order)< $temp_ary[$row['user_id']]))2904 if ($default_groups[$row['user_id']] == $group_id && (!isset($temp_ary[$row['user_id']]) || $group_order_id[$row['group_name']] < $temp_ary[$row['user_id']])) 2783 2905 { 2784 2906 $temp_ary[$row['user_id']] = $row['group_id']; … … 2787 2909 $db->sql_freeresult($result); 2788 2910 2911 // sql_where_ary holds the new default groups and their users 2789 2912 $sql_where_ary = array(); 2790 2913 foreach ($temp_ary as $uid => $gid) … … 2820 2943 $log = 'LOG_GROUP_REMOVE'; 2821 2944 2822 add_log('admin', $log, $group_name, implode(', ', $username_ary)); 2945 if ($group_name) 2946 { 2947 add_log('admin', $log, $group_name, implode(', ', $username_ary)); 2948 } 2823 2949 2824 2950 group_update_listings($group_id); … … 3010 3136 3011 3137 case 'default': 3138 // We only set default group for approved members of the group 3139 $sql = 'SELECT user_id 3140 FROM ' . USER_GROUP_TABLE . " 3141 WHERE group_id = $group_id 3142 AND user_pending = 0 3143 AND " . $db->sql_in_set('user_id', $user_id_ary); 3144 $result = $db->sql_query($sql); 3145 3146 $user_id_ary = $username_ary = array(); 3147 while ($row = $db->sql_fetchrow($result)) 3148 { 3149 $user_id_ary[] = $row['user_id']; 3150 } 3151 $db->sql_freeresult($result); 3152 3153 $result = user_get_id_name($user_id_ary, $username_ary); 3154 if (!sizeof($user_id_ary) || $result !== false) 3155 { 3156 return 'NO_USERS'; 3157 } 3158 3012 3159 $sql = 'SELECT user_id, group_id FROM ' . USERS_TABLE . ' 3013 3160 WHERE ' . $db->sql_in_set('user_id', $user_id_ary, false, true); … … 3098 3245 function group_set_user_default($group_id, $user_id_ary, $group_attributes = false, $update_listing = false) 3099 3246 { 3100 global $ db;3247 global $cache, $db; 3101 3248 3102 3249 if (empty($user_id_ary)) … … 3198 3345 group_update_listings($group_id); 3199 3346 } 3347 3348 // Because some tables/caches use usercolour-specific data we need to purge this here. 3349 $cache->destroy('sql', MODERATOR_CACHE_TABLE); 3200 3350 } 3201 3351 … … 3214 3364 $db->sql_freeresult($result); 3215 3365 3216 if (!$row )3366 if (!$row || ($row['group_type'] == GROUP_SPECIAL && empty($user->lang))) 3217 3367 { 3218 3368 return ''; … … 3357 3507 } 3358 3508 3509 3510 3511 /** 3512 * Funtion to make a user leave the NEWLY_REGISTERED system group. 3513 * @access public 3514 * @param $user_id The id of the user to remove from the group 3515 */ 3516 function remove_newly_registered($user_id, $user_data = false) 3517 { 3518 global $db; 3519 3520 if ($user_data === false) 3521 { 3522 $sql = 'SELECT * 3523 FROM ' . USERS_TABLE . ' 3524 WHERE user_id = ' . $user_id; 3525 $result = $db->sql_query($sql); 3526 $user_row = $db->sql_fetchrow($result); 3527 $db->sql_freeresult($result); 3528 3529 if (!$user_row) 3530 { 3531 return false; 3532 } 3533 else 3534 { 3535 $user_data = $user_row; 3536 } 3537 } 3538 3539 if (empty($user_data['user_new'])) 3540 { 3541 return false; 3542 } 3543 3544 $sql = 'SELECT group_id 3545 FROM ' . GROUPS_TABLE . " 3546 WHERE group_name = 'NEWLY_REGISTERED' 3547 AND group_type = " . GROUP_SPECIAL; 3548 $result = $db->sql_query($sql); 3549 $group_id = (int) $db->sql_fetchfield('group_id'); 3550 $db->sql_freeresult($result); 3551 3552 if (!$group_id) 3553 { 3554 return false; 3555 } 3556 3557 // We need to call group_user_del here, because this function makes sure everything is correctly changed. 3558 // A downside for a call within the session handler is that the language is not set up yet - so no log entry 3559 group_user_del($group_id, $user_id); 3560 3561 // Set user_new to 0 to let this not be triggered again 3562 $sql = 'UPDATE ' . USERS_TABLE . ' 3563 SET user_new = 0 3564 WHERE user_id = ' . $user_id; 3565 $db->sql_query($sql); 3566 3567 // The new users group was the users default group? 3568 if ($user_data['group_id'] == $group_id) 3569 { 3570 // Which group is now the users default one? 3571 $sql = 'SELECT group_id 3572 FROM ' . USERS_TABLE . ' 3573 WHERE user_id = ' . $user_id; 3574 $result = $db->sql_query($sql); 3575 $user_data['group_id'] = $db->sql_fetchfield('group_id'); 3576 $db->sql_freeresult($result); 3577 } 3578 3579 return $user_data['group_id']; 3580 } 3581 3359 3582 ?> -
trunk/forum/includes/mcp/mcp_front.php
r400 r702 3 3 * 4 4 * @package mcp 5 * @version $Id : mcp_front.php 9029 2008-10-18 18:44:41Z toonarmy$5 * @version $Id$ 6 6 * @copyright (c) 2005 phpBB Group 7 7 * @license http://opensource.org/licenses/gpl-license.php GNU Public License … … 35 35 36 36 $template->assign_var('S_SHOW_UNAPPROVED', (!empty($forum_list)) ? true : false); 37 37 38 38 if (!empty($forum_list)) 39 39 { … … 120 120 } 121 121 122 $s_hidden_fields = build_hidden_fields(array( 123 'redirect' => append_sid("{$phpbb_root_path}mcp.$phpEx", 'i=main' . (($forum_id) ? '&f=' . $forum_id : '')) 124 )); 125 122 126 $template->assign_vars(array( 127 'S_HIDDEN_FIELDS' => $s_hidden_fields, 123 128 'S_MCP_QUEUE_ACTION' => append_sid("{$phpbb_root_path}mcp.$phpEx", "i=queue"), 124 129 )); … … 153 158 FROM ' . REPORTS_TABLE . ' r, ' . POSTS_TABLE . ' p 154 159 WHERE r.post_id = p.post_id 160 AND r.pm_id = 0 155 161 AND r.report_closed = 0 156 162 AND p.forum_id IN (0, ' . implode(', ', $forum_list) . ')'; … … 182 188 183 189 'WHERE' => 'r.post_id = p.post_id 190 AND r.pm_id = 0 184 191 AND r.report_closed = 0 185 192 AND r.reason_id = rr.reason_id … … 241 248 ); 242 249 } 250 } 251 } 252 253 // Latest 5 reported PMs 254 if ($module->loaded('pm_reports') && $auth->acl_getf_global('m_report')) 255 { 256 $template->assign_var('S_SHOW_PM_REPORTS', true); 257 $user->add_lang(array('ucp')); 258 259 $sql = 'SELECT COUNT(r.report_id) AS total 260 FROM ' . REPORTS_TABLE . ' r, ' . PRIVMSGS_TABLE . ' p 261 WHERE r.post_id = 0 262 AND r.pm_id = p.msg_id 263 AND r.report_closed = 0'; 264 $result = $db->sql_query($sql); 265 $total = (int) $db->sql_fetchfield('total'); 266 $db->sql_freeresult($result); 267 268 if ($total) 269 { 270 include($phpbb_root_path . 'includes/functions_privmsgs.' . $phpEx); 271 272 $sql = $db->sql_build_query('SELECT', array( 273 'SELECT' => 'r.report_id, r.report_time, p.msg_id, p.message_subject, p.message_time, p.to_address, p.bcc_address, u.username, u.username_clean, u.user_colour, u.user_id, u2.username as author_name, u2.username_clean as author_name_clean, u2.user_colour as author_colour, u2.user_id as author_id', 274 275 'FROM' => array( 276 REPORTS_TABLE => 'r', 277 REPORTS_REASONS_TABLE => 'rr', 278 USERS_TABLE => array('u', 'u2'), 279 PRIVMSGS_TABLE => 'p' 280 ), 281 282 'WHERE' => 'r.pm_id = p.msg_id 283 AND r.post_id = 0 284 AND r.report_closed = 0 285 AND r.reason_id = rr.reason_id 286 AND r.user_id = u.user_id 287 AND p.author_id = u2.user_id', 288 289 'ORDER_BY' => 'p.message_time DESC' 290 )); 291 $result = $db->sql_query_limit($sql, 5); 292 293 $pm_by_id = $pm_list = array(); 294 while ($row = $db->sql_fetchrow($result)) 295 { 296 $pm_by_id[(int) $row['msg_id']] = $row; 297 $pm_list[] = (int) $row['msg_id']; 298 } 299 300 $address_list = get_recipient_strings($pm_by_id); 301 302 foreach ($pm_list as $message_id) 303 { 304 $row = $pm_by_id[$message_id]; 305 306 $template->assign_block_vars('pm_report', array( 307 'U_PM_DETAILS' => append_sid("{$phpbb_root_path}mcp.$phpEx", 'r=' . $row['report_id'] . "&i=pm_reports&mode=pm_report_details"), 308 309 'REPORTER_FULL' => get_username_string('full', $row['user_id'], $row['username'], $row['user_colour']), 310 'REPORTER' => get_username_string('username', $row['user_id'], $row['username'], $row['user_colour']), 311 'REPORTER_COLOUR' => get_username_string('colour', $row['user_id'], $row['username'], $row['user_colour']), 312 'U_REPORTER' => get_username_string('profile', $row['user_id'], $row['username'], $row['user_colour']), 313 314 'PM_AUTHOR_FULL' => get_username_string('full', $row['author_id'], $row['author_name'], $row['author_colour']), 315 'PM_AUTHOR' => get_username_string('username', $row['author_id'], $row['author_name'], $row['author_colour']), 316 'PM_AUTHOR_COLOUR' => get_username_string('colour', $row['author_id'], $row['author_name'], $row['author_colour']), 317 'U_PM_AUTHOR' => get_username_string('profile', $row['author_id'], $row['author_name'], $row['author_colour']), 318 319 'PM_SUBJECT' => $row['message_subject'], 320 'REPORT_TIME' => $user->format_date($row['report_time']), 321 'PM_TIME' => $user->format_date($row['message_time']), 322 'RECIPIENTS' => implode(', ', $address_list[$row['msg_id']]), 323 )); 324 } 325 } 326 327 if ($total == 0) 328 { 329 $template->assign_vars(array( 330 'L_PM_REPORTS_TOTAL' => $user->lang['PM_REPORTS_ZERO_TOTAL'], 331 'S_HAS_PM_REPORTS' => false) 332 ); 333 } 334 else 335 { 336 $template->assign_vars(array( 337 'L_PM_REPORTS_TOTAL' => ($total == 1) ? $user->lang['PM_REPORT_TOTAL'] : sprintf($user->lang['PM_REPORTS_TOTAL'], $total), 338 'S_HAS_PM_REPORTS' => true) 339 ); 243 340 } 244 341 } -
trunk/forum/includes/mcp/mcp_logs.php
r400 r702 3 3 * 4 4 * @package mcp 5 * @version $Id : mcp_logs.php 9029 2008-10-18 18:44:41Z toonarmy$5 * @version $Id$ 6 6 * @copyright (c) 2005 phpBB Group 7 7 * @license http://opensource.org/licenses/gpl-license.php GNU Public License … … 165 165 $sql_sort = $sort_by_sql[$sort_key] . ' ' . (($sort_dir == 'd') ? 'DESC' : 'ASC'); 166 166 167 $keywords = utf8_normalize_nfc(request_var('keywords', '', true)); 168 $keywords_param = !empty($keywords) ? '&keywords=' . urlencode(htmlspecialchars_decode($keywords)) : ''; 169 167 170 // Grab log data 168 171 $log_data = array(); 169 172 $log_count = 0; 170 view_log('mod', $log_data, $log_count, $config['topics_per_page'], $start, $forum_list, $topic_id, 0, $sql_where, $sql_sort );173 view_log('mod', $log_data, $log_count, $config['topics_per_page'], $start, $forum_list, $topic_id, 0, $sql_where, $sql_sort, $keywords); 171 174 172 175 $template->assign_vars(array( 173 176 'PAGE_NUMBER' => on_page($log_count, $config['topics_per_page'], $start), 174 177 'TOTAL' => ($log_count == 1) ? $user->lang['TOTAL_LOG'] : sprintf($user->lang['TOTAL_LOGS'], $log_count), 175 'PAGINATION' => generate_pagination($this->u_action . "&$u_sort_param ", $log_count, $config['topics_per_page'], $start),178 'PAGINATION' => generate_pagination($this->u_action . "&$u_sort_param$keywords_param", $log_count, $config['topics_per_page'], $start), 176 179 177 180 'L_TITLE' => $user->lang['MCP_LOGS'], … … 183 186 'S_SELECT_SORT_DAYS' => $s_limit_days, 184 187 'S_LOGS' => ($log_count > 0), 188 'S_KEYWORDS' => $keywords, 185 189 ) 186 190 ); … … 189 193 { 190 194 $data = array(); 191 195 192 196 $checks = array('viewtopic', 'viewforum'); 193 197 foreach ($checks as $check) -
trunk/forum/includes/mcp/mcp_main.php
r400 r702 3 3 * 4 4 * @package mcp 5 * @version $Id : mcp_main.php 8950 2008-09-27 10:59:25Z toonarmy$5 * @version $Id$ 6 6 * @copyright (c) 2005 phpBB Group 7 7 * @license http://opensource.org/licenses/gpl-license.php GNU Public License … … 569 569 $additional_msg = $user->lang['FORUM_NOT_POSTABLE']; 570 570 } 571 else if (!$auth->acl_get('f_post', $to_forum_id) )571 else if (!$auth->acl_get('f_post', $to_forum_id) || (!$auth->acl_get('m_approve', $to_forum_id) && !$auth->acl_get('f_noapprove', $to_forum_id))) 572 572 { 573 573 $additional_msg = $user->lang['USER_CANNOT_POST']; … … 595 595 $leave_shadow = (isset($_POST['move_leave_shadow'])) ? true : false; 596 596 597 $topics_moved = sizeof($topic_ids);598 $topics_authed_moved = 0;599 597 $forum_sync_data = array(); 600 598 … … 602 600 $forum_sync_data[$to_forum_id] = $forum_data; 603 601 602 // Real topics added to target forum 603 $topics_moved = sizeof($topic_data); 604 605 // Approved topics added to target forum 606 $topics_authed_moved = 0; 607 608 // Posts (topic replies + topic post if approved) added to target forum 609 $topic_posts_added = 0; 610 611 // Posts (topic replies + topic post if approved and not global announcement) removed from source forum 612 $topic_posts_removed = 0; 613 614 // Real topics removed from source forum (all topics without global announcements) 615 $topics_removed = 0; 616 617 // Approved topics removed from source forum (except global announcements) 618 $topics_authed_removed = 0; 619 604 620 foreach ($topic_data as $topic_id => $topic_info) 605 621 { 606 if ($topic_info['topic_approved'] == '1')622 if ($topic_info['topic_approved']) 607 623 { 608 624 $topics_authed_moved++; 625 $topic_posts_added++; 626 } 627 628 $topic_posts_added += $topic_info['topic_replies']; 629 630 if ($topic_info['topic_type'] != POST_GLOBAL) 631 { 632 $topics_removed++; 633 $topic_posts_removed += $topic_info['topic_replies']; 634 635 if ($topic_info['topic_approved']) 636 { 637 $topics_authed_removed++; 638 $topic_posts_removed++; 639 } 609 640 } 610 641 } … … 612 643 $db->sql_transaction('begin'); 613 644 614 $sql = 'SELECT SUM(t.topic_replies + t.topic_approved) as topic_posts615 FROM ' . TOPICS_TABLE . ' t616 WHERE ' . $db->sql_in_set('t.topic_id', $topic_ids);617 $result = $db->sql_query($sql);618 $row_data = $db->sql_fetchrow($result);619 $db->sql_freeresult($result);620 621 645 $sync_sql = array(); 622 646 623 if ($row_data['topic_posts']) 624 { 625 $sync_sql[$forum_id][] = 'forum_posts = forum_posts - ' . (int) $row_data['topic_posts']; 626 $sync_sql[$to_forum_id][] = 'forum_posts = forum_posts + ' . (int) $row_data['topic_posts']; 647 if ($topic_posts_added) 648 { 649 $sync_sql[$to_forum_id][] = 'forum_posts = forum_posts + ' . $topic_posts_added; 627 650 } 628 651 629 652 if ($topics_authed_moved) 630 653 { 631 $sync_sql[$to_forum_id][] 632 } 633 634 $sync_sql[$to_forum_id][] 654 $sync_sql[$to_forum_id][] = 'forum_topics = forum_topics + ' . (int) $topics_authed_moved; 655 } 656 657 $sync_sql[$to_forum_id][] = 'forum_topics_real = forum_topics_real + ' . (int) $topics_moved; 635 658 636 659 // Move topics, but do not resync yet … … 693 716 $db->sql_query('INSERT INTO ' . TOPICS_TABLE . $db->sql_build_array('INSERT', $shadow)); 694 717 695 $topics_authed_moved--; 696 $topics_moved--; 718 // Shadow topics only count on new "topics" and not posts... a shadow topic alone has 0 posts 719 $topics_removed--; 720 $topics_authed_removed--; 697 721 } 698 722 } 699 723 unset($topic_data); 700 724 701 $sync_sql[$forum_id][] = 'forum_topics_real = forum_topics_real - ' . (int) $topics_moved; 702 703 if ($topics_authed_moved) 704 { 705 $sync_sql[$forum_id][] = 'forum_topics = forum_topics - ' . (int) $topics_authed_moved; 725 if ($topic_posts_removed) 726 { 727 $sync_sql[$forum_id][] = 'forum_posts = forum_posts - ' . $topic_posts_removed; 728 } 729 730 if ($topics_removed) 731 { 732 $sync_sql[$forum_id][] = 'forum_topics_real = forum_topics_real - ' . (int) $topics_removed; 733 } 734 735 if ($topics_authed_removed) 736 { 737 $sync_sql[$forum_id][] = 'forum_topics = forum_topics - ' . (int) $topics_authed_removed; 706 738 } 707 739 … … 782 814 foreach ($data as $topic_id => $row) 783 815 { 784 add_log('mod', $row['forum_id'], $topic_id, 'LOG_DELETE_' . ($row['topic_moved_id'] ? 'SHADOW_' : '') . 'TOPIC', $row['topic_title']); 816 if ($row['topic_moved_id']) 817 { 818 add_log('mod', $row['forum_id'], $topic_id, 'LOG_DELETE_SHADOW_TOPIC', $row['topic_title']); 819 } 820 else 821 { 822 add_log('mod', $row['forum_id'], $topic_id, 'LOG_DELETE_TOPIC', $row['topic_title'], $row['topic_first_poster_name']); 823 } 785 824 } 786 825 … … 866 905 foreach ($post_data as $id => $row) 867 906 { 868 add_log('mod', $row['forum_id'], $row['topic_id'], 'LOG_DELETE_POST', $row['post_subject']); 907 $post_username = ($row['poster_id'] == ANONYMOUS && !empty($row['post_username'])) ? $row['post_username'] : $row['username']; 908 add_log('mod', $row['forum_id'], $row['topic_id'], 'LOG_DELETE_POST', $row['post_subject'], $post_username); 869 909 } 870 910 … … 930 970 else 931 971 { 972 if ($affected_topics != 1 || $deleted_topics || !$topic_id) 973 { 974 $redirect = append_sid("{$phpbb_root_path}mcp.$phpEx", "f=$forum_id&i=main&mode=forum_view", false); 975 } 976 932 977 meta_refresh(3, $redirect); 933 978 trigger_error($success_msg . '<br /><br />' . sprintf($user->lang['RETURN_PAGE'], '<a href="' . $redirect . '">', '</a>') . '<br /><br />' . implode('<br /><br />', $return_link)); … … 1028 1073 'poll_title' => (string) $topic_row['poll_title'], 1029 1074 'poll_start' => (int) $topic_row['poll_start'], 1030 'poll_length' => (int) $topic_row['poll_length'] 1075 'poll_length' => (int) $topic_row['poll_length'], 1076 'poll_max_options' => (int) $topic_row['poll_max_options'], 1077 'poll_vote_change' => (int) $topic_row['poll_vote_change'], 1031 1078 ); 1032 1079 … … 1130 1177 'is_orphan' => (int) $attach_row['is_orphan'], 1131 1178 'poster_id' => (int) $attach_row['poster_id'], 1132 'physical_filename' => (string) basename($attach_row['physical_filename']),1133 'real_filename' => (string) basename($attach_row['real_filename']),1179 'physical_filename' => (string) utf8_basename($attach_row['physical_filename']), 1180 'real_filename' => (string) utf8_basename($attach_row['real_filename']), 1134 1181 'download_count' => (int) $attach_row['download_count'], 1135 1182 'attach_comment' => (string) $attach_row['attach_comment'], … … 1190 1237 1191 1238 sync('forum', 'forum_id', $to_forum_id); 1192 set_config ('num_topics', $config['num_topics'] +sizeof($new_topic_id_list), true);1193 set_config ('num_posts', $config['num_posts'] +$total_posts, true);1239 set_config_count('num_topics', sizeof($new_topic_id_list), true); 1240 set_config_count('num_posts', $total_posts, true); 1194 1241 1195 1242 foreach ($new_topic_id_list as $topic_id => $new_topic_id) -
trunk/forum/includes/mcp/mcp_notes.php
r400 r702 3 3 * 4 4 * @package mcp 5 * @version $Id : mcp_notes.php 8598 2008-06-04 15:37:06Z naderman$5 * @version $Id$ 6 6 * @copyright (c) 2005 phpBB Group 7 7 * @license http://opensource.org/licenses/gpl-license.php GNU Public License … … 194 194 $sql_sort = $sort_by_sql[$sk] . ' ' . (($sd == 'd') ? 'DESC' : 'ASC'); 195 195 196 $keywords = utf8_normalize_nfc(request_var('keywords', '', true)); 197 $keywords_param = !empty($keywords) ? '&keywords=' . urlencode(htmlspecialchars_decode($keywords)) : ''; 198 196 199 $log_data = array(); 197 200 $log_count = 0; 198 view_log('user', $log_data, $log_count, $config[' posts_per_page'], $start, 0, 0, $user_id, $sql_where, $sql_sort);201 view_log('user', $log_data, $log_count, $config['topics_per_page'], $start, 0, 0, $user_id, $sql_where, $sql_sort, $keywords); 199 202 200 203 if ($log_count) … … 220 223 'S_SELECT_SORT_KEY' => $s_sort_key, 221 224 'S_SELECT_SORT_DAYS' => $s_limit_days, 225 'S_KEYWORDS' => $keywords, 222 226 223 227 'L_TITLE' => $user->lang['MCP_NOTES_USER'], 224 228 225 'PAGE_NUMBER' => on_page($log_count, $config[' posts_per_page'], $start),226 'PAGINATION' => generate_pagination($this->u_action . "& st=$st&sk=$sk&sd=$sd", $log_count, $config['posts_per_page'], $start),229 'PAGE_NUMBER' => on_page($log_count, $config['topics_per_page'], $start), 230 'PAGINATION' => generate_pagination($this->u_action . "&$u_sort_param$keywords_param", $log_count, $config['topics_per_page'], $start), 227 231 'TOTAL_REPORTS' => ($log_count == 1) ? $user->lang['LIST_REPORT'] : sprintf($user->lang['LIST_REPORTS'], $log_count), 228 232 229 'USERNAME' => $userrow['username'],230 'USER_COLOR' => (!empty($userrow['user_colour'])) ? $userrow['user_colour'] : '',231 233 'RANK_TITLE' => $rank_title, 232 234 'JOINED' => $user->format_date($userrow['user_regdate']), 233 235 'POSTS' => ($userrow['user_posts']) ? $userrow['user_posts'] : 0, 234 236 'WARNINGS' => ($userrow['user_warnings']) ? $userrow['user_warnings'] : 0, 237 238 'USERNAME_FULL' => get_username_string('full', $userrow['user_id'], $userrow['username'], $userrow['user_colour']), 239 'USERNAME_COLOUR' => get_username_string('colour', $userrow['user_id'], $userrow['username'], $userrow['user_colour']), 240 'USERNAME' => get_username_string('username', $userrow['user_id'], $userrow['username'], $userrow['user_colour']), 241 'U_PROFILE' => get_username_string('profile', $userrow['user_id'], $userrow['username'], $userrow['user_colour']), 235 242 236 243 'AVATAR_IMG' => $avatar_img, -
trunk/forum/includes/mcp/mcp_queue.php
r400 r702 3 3 * 4 4 * @package mcp 5 * @version $Id : mcp_queue.php 9133 2008-11-30 12:03:43Z acydburn$5 * @version $Id$ 6 6 * @copyright (c) 2005 phpBB Group 7 7 * @license http://opensource.org/licenses/gpl-license.php GNU Public License … … 106 106 $template->assign_vars(array( 107 107 'S_TOPIC_REVIEW' => true, 108 'S_BBCODE_ALLOWED' => $post_info['enable_bbcode'], 108 109 'TOPIC_TITLE' => $post_info['topic_title']) 109 110 ); … … 492 493 493 494 $total_topics = $total_posts = 0; 494 $forum_topics_posts = $topic_approve_sql = $topic_replies_sql = $post_approve_sql = $topic_id_list = $forum_id_list = $approve_log = array(); 495 $user_posts_sql = array(); 496 497 $update_forum_information = false; 495 $topic_approve_sql = $post_approve_sql = $topic_id_list = $forum_id_list = $approve_log = array(); 496 $user_posts_sql = $post_approved_list = array(); 498 497 499 498 foreach ($post_info as $post_id => $post_data) 500 499 { 500 if ($post_data['post_approved']) 501 { 502 $post_approved_list[] = $post_id; 503 continue; 504 } 505 501 506 $topic_id_list[$post_data['topic_id']] = 1; 502 507 … … 518 523 if ($post_data['forum_id']) 519 524 { 520 if (!isset($forum_topics_posts[$post_data['forum_id']]))521 {522 $forum_topics_posts[$post_data['forum_id']] = array(523 'forum_posts' => 0,524 'forum_topics' => 0525 );526 }527 528 525 $total_topics++; 529 $forum_topics_posts[$post_data['forum_id']]['forum_topics']++;530 526 } 531 527 $topic_approve_sql[] = $post_data['topic_id']; … … 540 536 else 541 537 { 542 if (!isset($topic_replies_sql[$post_data['topic_id']]))543 {544 $topic_replies_sql[$post_data['topic_id']] = 0;545 }546 $topic_replies_sql[$post_data['topic_id']]++;547 548 538 $approve_log[] = array( 549 539 'type' => 'post', … … 556 546 if ($post_data['forum_id']) 557 547 { 558 if (!isset($forum_topics_posts[$post_data['forum_id']]))559 {560 $forum_topics_posts[$post_data['forum_id']] = array(561 'forum_posts' => 0,562 'forum_topics' => 0563 );564 }565 566 548 $total_posts++; 567 $forum_topics_posts[$post_data['forum_id']]['forum_posts']++;568 549 569 550 // Increment by topic_replies if we approve a topic... … … 572 553 { 573 554 $total_posts += $post_data['topic_replies']; 574 $forum_topics_posts[$post_data['forum_id']]['forum_posts'] += $post_data['topic_replies'];575 555 } 576 556 } 577 557 578 558 $post_approve_sql[] = $post_id; 579 580 // If the post is newer than the last post information stored we need to update the forum information 581 if ($post_data['post_time'] >= $post_data['forum_last_post_time'])582 {583 $update_forum_information = true;584 }559 } 560 561 $post_id_list = array_values(array_diff($post_id_list, $post_approved_list)); 562 for ($i = 0, $size = sizeof($post_approved_list); $i < $size; $i++) 563 { 564 unset($post_info[$post_approved_list[$i]]); 585 565 } 586 566 … … 601 581 } 602 582 583 unset($topic_approve_sql, $post_approve_sql); 584 603 585 foreach ($approve_log as $log_data) 604 586 { 605 587 add_log('mod', $log_data['forum_id'], $log_data['topic_id'], ($log_data['type'] == 'topic') ? 'LOG_TOPIC_APPROVED' : 'LOG_POST_APPROVED', $log_data['post_subject']); 606 }607 608 if (sizeof($topic_replies_sql))609 {610 foreach ($topic_replies_sql as $topic_id => $num_replies)611 {612 $sql = 'UPDATE ' . TOPICS_TABLE . "613 SET topic_replies = topic_replies + $num_replies614 WHERE topic_id = $topic_id";615 $db->sql_query($sql);616 }617 }618 619 if (sizeof($forum_topics_posts))620 {621 foreach ($forum_topics_posts as $forum_id => $row)622 {623 $sql = 'UPDATE ' . FORUMS_TABLE . '624 SET ';625 $sql .= ($row['forum_topics']) ? "forum_topics = forum_topics + {$row['forum_topics']}" : '';626 $sql .= ($row['forum_topics'] && $row['forum_posts']) ? ', ' : '';627 $sql .= ($row['forum_posts']) ? "forum_posts = forum_posts + {$row['forum_posts']}" : '';628 $sql .= " WHERE forum_id = $forum_id";629 630 $db->sql_query($sql);631 }632 588 } 633 589 … … 653 609 if ($total_topics) 654 610 { 655 set_config ('num_topics', $config['num_topics'] +$total_topics, true);611 set_config_count('num_topics', $total_topics, true); 656 612 } 657 613 658 614 if ($total_posts) 659 615 { 660 set_config('num_posts', $config['num_posts'] + $total_posts, true); 661 } 662 unset($topic_approve_sql, $topic_replies_sql, $post_approve_sql); 663 664 update_post_information('topic', array_keys($topic_id_list)); 665 666 if ($update_forum_information) 667 { 668 update_post_information('forum', array_keys($forum_id_list)); 669 } 616 set_config_count('num_posts', $total_posts, true); 617 } 618 619 sync('topic', 'topic_id', array_keys($topic_id_list), true); 620 sync('forum', 'forum_id', array_keys($forum_id_list), true, true); 670 621 unset($topic_id_list, $forum_id_list); 671 622 … … 734 685 else 735 686 { 736 $success_msg = (sizeof($post_id_list) == 1) ? 'POST_APPROVED_SUCCESS' : 'POSTS_APPROVED_SUCCESS';687 $success_msg = (sizeof($post_id_list) + sizeof($post_approved_list) == 1) ? 'POST_APPROVED_SUCCESS' : 'POSTS_APPROVED_SUCCESS'; 737 688 } 738 689 } … … 846 797 if (confirm_box(true)) 847 798 { 848 849 // If Topic -> forum_topics_real -= 1 850 // If Post -> topic_replies_real -= 1 851 852 $num_disapproved = 0; 853 $forum_topics_real = $topic_id_list = $forum_id_list = $topic_replies_real_sql = $post_disapprove_sql = $disapprove_log = array(); 854 799 $disapprove_log = $disapprove_log_topics = $disapprove_log_posts = array(); 800 $topic_replies_real = $post_disapprove_list = array(); 801 802 // Build a list of posts to be unapproved and get the related topics real replies count 855 803 foreach ($post_info as $post_id => $post_data) 856 804 { 857 $topic_id_list[$post_data['topic_id']] = 1; 858 859 if ($post_data['forum_id']) 860 { 861 $forum_id_list[$post_data['forum_id']] = 1; 862 } 863 864 // Topic or Post. ;) 865 /** 866 * @todo this probably is a different method than the one used by delete_posts, does this cause counter inconsistency? 867 */ 868 if ($post_data['topic_first_post_id'] == $post_id && $post_data['topic_last_post_id'] == $post_id) 869 { 870 if ($post_data['forum_id']) 871 { 872 if (!isset($forum_topics_real[$post_data['forum_id']])) 873 { 874 $forum_topics_real[$post_data['forum_id']] = 0; 875 } 876 $forum_topics_real[$post_data['forum_id']]++; 877 $num_disapproved++; 878 } 879 880 $disapprove_log[] = array( 881 'type' => 'topic', 882 'post_subject' => $post_data['post_subject'], 883 'forum_id' => $post_data['forum_id'], 884 'topic_id' => 0, // useless to log a topic id, as it will be deleted 805 $post_disapprove_list[$post_id] = $post_data['topic_id']; 806 if (!isset($topic_replies_real[$post_data['topic_id']])) 807 { 808 $topic_replies_real[$post_data['topic_id']] = $post_data['topic_replies_real']; 809 } 810 } 811 812 // Now we build the log array 813 foreach ($post_disapprove_list as $post_id => $topic_id) 814 { 815 // If the count of disapproved posts for the topic is greater 816 // than topic's real replies count, the whole topic is disapproved/deleted 817 if (sizeof(array_keys($post_disapprove_list, $topic_id)) > $topic_replies_real[$topic_id]) 818 { 819 // Don't write the log more than once for every topic 820 if (!isset($disapprove_log_topics[$topic_id])) 821 { 822 // Build disapproved topics log 823 $disapprove_log_topics[$topic_id] = array( 824 'type' => 'topic', 825 'post_subject' => $post_info[$post_id]['topic_title'], 826 'forum_id' => $post_info[$post_id]['forum_id'], 827 'topic_id' => 0, // useless to log a topic id, as it will be deleted 828 ); 829 } 830 } 831 else 832 { 833 // Build disapproved posts log 834 $disapprove_log_posts[] = array( 835 'type' => 'post', 836 'post_subject' => $post_info[$post_id]['post_subject'], 837 'forum_id' => $post_info[$post_id]['forum_id'], 838 'topic_id' => $post_info[$post_id]['topic_id'], 885 839 ); 886 } 887 else 888 { 889 if (!isset($topic_replies_real_sql[$post_data['topic_id']])) 890 { 891 $topic_replies_real_sql[$post_data['topic_id']] = 0; 892 } 893 $topic_replies_real_sql[$post_data['topic_id']]++; 894 895 $disapprove_log[] = array( 896 'type' => 'post', 897 'post_subject' => $post_data['post_subject'], 898 'forum_id' => $post_data['forum_id'], 899 'topic_id' => $post_data['topic_id'], 900 ); 901 } 902 903 $post_disapprove_sql[] = $post_id; 904 } 905 906 unset($post_data); 907 908 if (sizeof($forum_topics_real)) 909 { 910 foreach ($forum_topics_real as $forum_id => $topics_real) 911 { 912 $sql = 'UPDATE ' . FORUMS_TABLE . " 913 SET forum_topics_real = forum_topics_real - $topics_real 914 WHERE forum_id = $forum_id"; 915 $db->sql_query($sql); 916 } 917 } 918 919 if (sizeof($topic_replies_real_sql)) 920 { 921 foreach ($topic_replies_real_sql as $topic_id => $num_replies) 922 { 923 $sql = 'UPDATE ' . TOPICS_TABLE . " 924 SET topic_replies_real = topic_replies_real - $num_replies 925 WHERE topic_id = $topic_id"; 926 $db->sql_query($sql); 927 } 928 } 929 930 if (sizeof($post_disapprove_sql)) 840 841 } 842 } 843 844 // Get disapproved posts/topics counts separately 845 $num_disapproved_topics = sizeof($disapprove_log_topics); 846 $num_disapproved_posts = sizeof($disapprove_log_posts); 847 848 // Build the whole log 849 $disapprove_log = array_merge($disapprove_log_topics, $disapprove_log_posts); 850 851 // Unset unneeded arrays 852 unset($post_data, $disapprove_log_topics, $disapprove_log_posts); 853 854 // Let's do the job - delete disapproved posts 855 if (sizeof($post_disapprove_list)) 931 856 { 932 857 if (!function_exists('delete_posts')) … … 936 861 937 862 // We do not check for permissions here, because the moderator allowed approval/disapproval should be allowed to delete the disapproved posts 938 delete_posts('post_id', $post_disapprove_sql); 863 // Note: function delete_posts triggers related forums/topics sync, 864 // so we don't need to call update_post_information later and to adjust real topic replies or forum topics count manually 865 delete_posts('post_id', array_keys($post_disapprove_list)); 939 866 940 867 foreach ($disapprove_log as $log_data) … … 943 870 } 944 871 } 945 unset($post_disapprove_sql, $topic_replies_real_sql);946 947 update_post_information('topic', array_keys($topic_id_list));948 949 if (sizeof($forum_id_list))950 {951 update_post_information('forum', array_keys($forum_id_list));952 }953 unset($topic_id_list, $forum_id_list);954 872 955 873 $messenger = new messenger(); … … 980 898 // Load up the language pack 981 899 $lang = array(); 982 @include($phpbb_root_path . '/language/' . $post_data['user_lang']. '/mcp.' . $phpEx);900 @include($phpbb_root_path . '/language/' . basename($post_data['user_lang']) . '/mcp.' . $phpEx); 983 901 984 902 // If we find the reason in this language pack use it … … 1019 937 $messenger->save_queue(); 1020 938 1021 if ( sizeof($forum_topics_real))1022 { 1023 $success_msg = ($num_disapproved == 1) ? 'TOPIC_DISAPPROVED_SUCCESS' : 'TOPICS_DISAPPROVED_SUCCESS';939 if ($num_disapproved_topics) 940 { 941 $success_msg = ($num_disapproved_topics == 1) ? 'TOPIC_DISAPPROVED_SUCCESS' : 'TOPICS_DISAPPROVED_SUCCESS'; 1024 942 } 1025 943 else 1026 944 { 1027 $success_msg = ( sizeof($post_id_list)== 1) ? 'POST_DISAPPROVED_SUCCESS' : 'POSTS_DISAPPROVED_SUCCESS';945 $success_msg = ($num_disapproved_posts == 1) ? 'POST_DISAPPROVED_SUCCESS' : 'POSTS_DISAPPROVED_SUCCESS'; 1028 946 } 1029 947 } -
trunk/forum/includes/mcp/mcp_reports.php
r400 r702 3 3 * 4 4 * @package mcp 5 * @version $Id : mcp_reports.php 9015 2008-10-14 18:29:50Z toonarmy$5 * @version $Id$ 6 6 * @copyright (c) 2005 phpBB Group 7 7 * @license http://opensource.org/licenses/gpl-license.php GNU Public License … … 78 78 AND rr.reason_id = r.reason_id 79 79 AND r.user_id = u.user_id 80 AND r.pm_id = 0 80 81 ORDER BY report_closed ASC'; 81 82 $result = $db->sql_query_limit($sql, 1); … … 116 117 $template->assign_vars(array( 117 118 'S_TOPIC_REVIEW' => true, 119 'S_BBCODE_ALLOWED' => $post_info['enable_bbcode'], 118 120 'TOPIC_TITLE' => $post_info['topic_title']) 119 121 ); … … 150 152 if ($post_info['post_attachment'] && $auth->acl_get('u_download') && $auth->acl_get('f_download', $post_info['forum_id'])) 151 153 { 152 $extensions = $cache->obtain_attach_extensions($post_info['forum_id']);153 154 154 $sql = 'SELECT * 155 155 FROM ' . ATTACHMENTS_TABLE . ' 156 156 WHERE post_msg_id = ' . $post_id . ' 157 157 AND in_message = 0 158 ORDER BY filetime DESC , post_msg_id ASC';158 ORDER BY filetime DESC'; 159 159 $result = $db->sql_query($sql); 160 160 … … 259 259 unset($forum_list_read); 260 260 261 if ($topic_id && $forum_id)261 if ($topic_id) 262 262 { 263 263 $topic_info = get_topic_data(array($topic_id)); … … 268 268 } 269 269 270 $topic_info = $topic_info[$topic_id]; 271 $forum_id = $topic_info['forum_id']; 272 } 273 else if ($topic_id && !$forum_id) 274 { 275 $topic_id = 0; 270 if ($forum_id != $topic_info[$topic_id]['forum_id']) 271 { 272 $topic_id = 0; 273 } 274 else 275 { 276 $topic_info = $topic_info[$topic_id]; 277 $forum_id = (int) $topic_info['forum_id']; 278 } 276 279 } 277 280 … … 330 333 331 334 $forum_topics = ($total == -1) ? $forum_info['forum_topics'] : $total; 332 $limit_time_sql = ($sort_days) ? 'AND t.topic_last_post_time >= ' . (time() - ($sort_days * 86400)) : '';335 $limit_time_sql = ($sort_days) ? 'AND r.report_time >= ' . (time() - ($sort_days * 86400)) : ''; 333 336 334 337 if ($mode == 'reports') … … 347 350 AND r.post_id = p.post_id 348 351 " . (($sort_order_sql[0] == 'u') ? 'AND u.user_id = p.poster_id' : '') . ' 349 ' . (($sort_order_sql[0] == 'r') ? 'AND ru.user_id = p.poster_id' : '') . '352 ' . (($sort_order_sql[0] == 'r') ? 'AND ru.user_id = r.user_id' : '') . ' 350 353 ' . (($topic_id) ? 'AND p.topic_id = ' . $topic_id : '') . " 351 354 AND t.topic_id = p.topic_id 355 AND r.pm_id = 0 352 356 $limit_time_sql 353 357 ORDER BY $sort_order_sql"; … … 372 376 AND u.user_id = p.poster_id 373 377 AND ru.user_id = r.user_id 378 AND r.pm_id = 0 374 379 ORDER BY ' . $sort_order_sql; 375 380 $result = $db->sql_query($sql); … … 426 431 'TOPIC_ID' => $topic_id, 427 432 'TOTAL' => $total, 428 'TOTAL_REPORTS' => ($total == 1) ? $user->lang['LIST_REPORT'] : sprintf($user->lang['LIST_REPORTS'], $total), 433 'TOTAL_REPORTS' => ($total == 1) ? $user->lang['LIST_REPORT'] : sprintf($user->lang['LIST_REPORTS'], $total), 429 434 ) 430 435 ); … … 439 444 * Closes a report 440 445 */ 441 function close_report($report_id_list, $mode, $action )446 function close_report($report_id_list, $mode, $action, $pm = false) 442 447 { 443 global $db, $template, $user, $config ;448 global $db, $template, $user, $config, $auth; 444 449 global $phpEx, $phpbb_root_path; 445 450 446 $sql = 'SELECT r.post_id 447 FROM ' . REPORTS_TABLE . ' r 448 WHERE ' . $db->sql_in_set('r.report_id', $report_id_list); 451 $pm_where = ($pm) ? ' AND r.post_id = 0 ' : ' AND r.pm_id = 0 '; 452 $id_column = ($pm) ? 'pm_id' : 'post_id'; 453 $module = ($pm) ? 'pm_reports' : 'reports'; 454 $pm_prefix = ($pm) ? 'PM_' : ''; 455 456 $sql = "SELECT r.$id_column 457 FROM " . REPORTS_TABLE . ' r 458 WHERE ' . $db->sql_in_set('r.report_id', $report_id_list) . $pm_where; 449 459 $result = $db->sql_query($sql); 450 460 … … 452 462 while ($row = $db->sql_fetchrow($result)) 453 463 { 454 $post_id_list[] = $row[ 'post_id'];464 $post_id_list[] = $row[$id_column]; 455 465 } 456 466 $post_id_list = array_unique($post_id_list); 457 467 458 if (!check_ids($post_id_list, POSTS_TABLE, 'post_id', array('m_report'))) 459 { 460 trigger_error('NOT_AUTHORISED'); 468 if ($pm) 469 { 470 if (!$auth->acl_getf_global('m_report')) 471 { 472 trigger_error('NOT_AUTHORISED'); 473 } 474 } 475 else 476 { 477 if (!check_ids($post_id_list, POSTS_TABLE, 'post_id', array('m_report'))) 478 { 479 trigger_error('NOT_AUTHORISED'); 480 } 461 481 } 462 482 … … 465 485 $redirect = request_var('redirect', build_url(array('mode', 'r', 'quickmod')) . '&mode=reports'); 466 486 } 487 elseif ($action == 'delete' && strpos($user->data['session_page'], 'mode=pm_report_details') !== false) 488 { 489 $redirect = request_var('redirect', build_url(array('mode', 'r', 'quickmod')) . '&mode=pm_reports'); 490 } 467 491 else if ($action == 'close' && !request_var('r', 0)) 468 492 { 469 $redirect = request_var('redirect', build_url(array('mode', 'p', 'quickmod')) . '&mode= reports');493 $redirect = request_var('redirect', build_url(array('mode', 'p', 'quickmod')) . '&mode=' . $module); 470 494 } 471 495 else … … 478 502 479 503 $s_hidden_fields = build_hidden_fields(array( 480 'i' => 'reports',504 'i' => $module, 481 505 'mode' => $mode, 482 506 'report_id_list' => $report_id_list, … … 487 511 if (confirm_box(true)) 488 512 { 489 $post_info = get_post_data($post_id_list, 'm_report');490 491 $sql = 'SELECT r.report_id, r.post_id, r.report_closed, r.user_id, r.user_notify, u.username, u.username_clean, u.user_email, u.user_jabber, u.user_lang, u.user_notify_type492 FROM '. REPORTS_TABLE . ' r, ' . USERS_TABLE . ' u513 $post_info = ($pm) ? get_pm_data($post_id_list) : get_post_data($post_id_list, 'm_report'); 514 515 $sql = "SELECT r.report_id, r.$id_column, r.report_closed, r.user_id, r.user_notify, u.username, u.username_clean, u.user_email, u.user_jabber, u.user_lang, u.user_notify_type 516 FROM " . REPORTS_TABLE . ' r, ' . USERS_TABLE . ' u 493 517 WHERE ' . $db->sql_in_set('r.report_id', $report_id_list) . ' 494 518 ' . (($action == 'close') ? 'AND r.report_closed = 0' : '') . ' 495 AND r.user_id = u.user_id' ;519 AND r.user_id = u.user_id' . $pm_where; 496 520 $result = $db->sql_query($sql); 497 521 … … 504 528 if (!$report['report_closed']) 505 529 { 506 $close_report_posts[] = $report['post_id']; 507 $close_report_topics[] = $post_info[$report['post_id']]['topic_id']; 530 $close_report_posts[] = $report[$id_column]; 531 532 if (!$pm) 533 { 534 $close_report_topics[] = $post_info[$report['post_id']]['topic_id']; 535 } 508 536 } 509 537 … … 520 548 $close_report_topics = array_unique($close_report_topics); 521 549 522 if ( sizeof($close_report_posts))550 if (!$pm && sizeof($close_report_posts)) 523 551 { 524 552 // Get a list of topics that still contain reported posts … … 559 587 if (sizeof($close_report_posts)) 560 588 { 561 $sql = 'UPDATE ' . POSTS_TABLE . ' 562 SET post_reported = 0 563 WHERE ' . $db->sql_in_set('post_id', $close_report_posts); 564 $db->sql_query($sql); 565 566 if (sizeof($close_report_topics)) 567 { 568 $sql = 'UPDATE ' . TOPICS_TABLE . ' 569 SET topic_reported = 0 570 WHERE ' . $db->sql_in_set('topic_id', $close_report_topics) . ' 571 OR ' . $db->sql_in_set('topic_moved_id', $close_report_topics); 589 if ($pm) 590 { 591 $sql = 'UPDATE ' . PRIVMSGS_TABLE . ' 592 SET message_reported = 0 593 WHERE ' . $db->sql_in_set('msg_id', $close_report_posts); 572 594 $db->sql_query($sql); 595 596 if ($action == 'delete') 597 { 598 delete_pm(ANONYMOUS, $close_report_posts, PRIVMSGS_INBOX); 599 } 600 } 601 else 602 { 603 $sql = 'UPDATE ' . POSTS_TABLE . ' 604 SET post_reported = 0 605 WHERE ' . $db->sql_in_set('post_id', $close_report_posts); 606 $db->sql_query($sql); 607 608 if (sizeof($close_report_topics)) 609 { 610 $sql = 'UPDATE ' . TOPICS_TABLE . ' 611 SET topic_reported = 0 612 WHERE ' . $db->sql_in_set('topic_id', $close_report_topics) . ' 613 OR ' . $db->sql_in_set('topic_moved_id', $close_report_topics); 614 $db->sql_query($sql); 615 } 573 616 } 574 617 } … … 580 623 foreach ($reports as $report) 581 624 { 582 add_log('mod', $post_info[$report['post_id']]['forum_id'], $post_info[$report['post_id']]['topic_id'], 'LOG_REPORT_' . strtoupper($action) . 'D', $post_info[$report['post_id']]['post_subject']); 625 if ($pm) 626 { 627 add_log('mod', 0, 0, 'LOG_PM_REPORT_' . strtoupper($action) . 'D', $post_info[$report['pm_id']]['message_subject']); 628 } 629 else 630 { 631 add_log('mod', $post_info[$report['post_id']]['forum_id'], $post_info[$report['post_id']]['topic_id'], 'LOG_REPORT_' . strtoupper($action) . 'D', $post_info[$report['post_id']]['post_subject']); 632 } 583 633 } 584 634 … … 595 645 } 596 646 597 $post_id = $reporter[ 'post_id'];598 599 $messenger->template( 'report_'. $action . 'd', $reporter['user_lang']);647 $post_id = $reporter[$id_column]; 648 649 $messenger->template((($pm) ? 'pm_report_' : 'report_') . $action . 'd', $reporter['user_lang']); 600 650 601 651 $messenger->to($reporter['user_email'], $reporter['username']); 602 652 $messenger->im($reporter['user_jabber'], $reporter['username']); 603 653 604 $messenger->assign_vars(array( 605 'USERNAME' => htmlspecialchars_decode($reporter['username']), 606 'CLOSER_NAME' => htmlspecialchars_decode($user->data['username']), 607 'POST_SUBJECT' => htmlspecialchars_decode(censor_text($post_info[$post_id]['post_subject'])), 608 'TOPIC_TITLE' => htmlspecialchars_decode(censor_text($post_info[$post_id]['topic_title']))) 609 ); 654 if ($pm) 655 { 656 $messenger->assign_vars(array( 657 'USERNAME' => htmlspecialchars_decode($reporter['username']), 658 'CLOSER_NAME' => htmlspecialchars_decode($user->data['username']), 659 'PM_SUBJECT' => htmlspecialchars_decode(censor_text($post_info[$post_id]['message_subject'])), 660 )); 661 } 662 else 663 { 664 $messenger->assign_vars(array( 665 'USERNAME' => htmlspecialchars_decode($reporter['username']), 666 'CLOSER_NAME' => htmlspecialchars_decode($user->data['username']), 667 'POST_SUBJECT' => htmlspecialchars_decode(censor_text($post_info[$post_id]['post_subject'])), 668 'TOPIC_TITLE' => htmlspecialchars_decode(censor_text($post_info[$post_id]['topic_title']))) 669 ); 670 } 610 671 611 672 $messenger->send($reporter['user_notify_type']); 612 673 } 613 674 } 614 615 foreach ($post_info as $post) 616 { 617 $forum_ids[$post['forum_id']] = $post['forum_id']; 618 $topic_ids[$post['topic_id']] = $post['topic_id']; 619 } 620 675 676 if (!$pm) 677 { 678 foreach ($post_info as $post) 679 { 680 $forum_ids[$post['forum_id']] = $post['forum_id']; 681 $topic_ids[$post['topic_id']] = $post['topic_id']; 682 } 683 } 684 621 685 unset($notify_reporters, $post_info, $reports); 622 686 623 687 $messenger->save_queue(); 624 688 625 $success_msg = (sizeof($report_id_list) == 1) ? 'REPORT_' . strtoupper($action) . 'D_SUCCESS' : 'REPORTS_'. strtoupper($action) . 'D_SUCCESS';689 $success_msg = (sizeof($report_id_list) == 1) ? "{$pm_prefix}REPORT_" . strtoupper($action) . 'D_SUCCESS' : "{$pm_prefix}REPORTS_" . strtoupper($action) . 'D_SUCCESS'; 626 690 } 627 691 else 628 692 { 629 confirm_box(false, $user->lang[strtoupper($action) . '_REPORT'. ((sizeof($report_id_list) == 1) ? '' : 'S') . '_CONFIRM'], $s_hidden_fields);693 confirm_box(false, $user->lang[strtoupper($action) . "_{$pm_prefix}REPORT" . ((sizeof($report_id_list) == 1) ? '' : 'S') . '_CONFIRM'], $s_hidden_fields); 630 694 } 631 695 … … 640 704 { 641 705 meta_refresh(3, $redirect); 706 642 707 $return_forum = ''; 643 if (sizeof($forum_ids == 1))644 {645 $return_forum = sprintf($user->lang['RETURN_FORUM'], '<a href="' . append_sid("{$phpbb_root_path}viewforum.$phpEx", 'f=' . current($forum_ids)) . '">', '</a>') . '<br /><br />';646 }647 708 $return_topic = ''; 648 if (sizeof($topic_ids == 1)) 649 { 650 $return_topic = sprintf($user->lang['RETURN_TOPIC'], '<a href="' . append_sid("{$phpbb_root_path}viewtopic.$phpEx", 't=' . current($topic_ids) . '&f=' . current($forum_ids)) . '">', '</a>') . '<br /><br />'; 651 } 652 709 710 if (!$pm) 711 { 712 if (sizeof($forum_ids) === 1) 713 { 714 $return_forum = sprintf($user->lang['RETURN_FORUM'], '<a href="' . append_sid("{$phpbb_root_path}viewforum.$phpEx", 'f=' . current($forum_ids)) . '">', '</a>') . '<br /><br />'; 715 } 716 717 if (sizeof($topic_ids) === 1) 718 { 719 $return_topic = sprintf($user->lang['RETURN_TOPIC'], '<a href="' . append_sid("{$phpbb_root_path}viewtopic.$phpEx", 't=' . current($topic_ids) . '&f=' . current($forum_ids)) . '">', '</a>') . '<br /><br />'; 720 } 721 } 722 653 723 trigger_error($user->lang[$success_msg] . '<br /><br />' . $return_forum . $return_topic . sprintf($user->lang['RETURN_PAGE'], "<a href=\"$redirect\">", '</a>')); 654 724 } -
trunk/forum/includes/mcp/mcp_topic.php
r400 r702 3 3 * 4 4 * @package mcp 5 * @version $Id : mcp_topic.php 9030 2008-10-19 18:32:11Z acydburn$5 * @version $Id$ 6 6 * @copyright (c) 2005 phpBB Group 7 7 * @license http://opensource.org/licenses/gpl-license.php GNU Public License … … 107 107 if ($total == -1) 108 108 { 109 $total = $topic_info['topic_replies'] + 1; 109 if ($auth->acl_get('m_approve', $topic_info['forum_id'])) 110 { 111 $total = $topic_info['topic_replies_real'] + 1; 112 } 113 else 114 { 115 $total = $topic_info['topic_replies'] + 1; 116 } 110 117 } 111 118 … … 260 267 $s_topic_icons = false; 261 268 262 if ($auth->acl_get ('m_split',$topic_info['forum_id']))269 if ($auth->acl_gets('m_split', 'm_merge', (int) $topic_info['forum_id'])) 263 270 { 264 271 include_once($phpbb_root_path . 'includes/functions_posting.' . $phpEx); … … 302 309 'ACTION' => $action, 303 310 304 'REPORTED_IMG' => $user->img('icon_topic_reported', 'POST_REPORTED', false, true), 305 'UNAPPROVED_IMG' => $user->img('icon_topic_unapproved', 'POST_UNAPPROVED', false, true), 311 'REPORTED_IMG' => $user->img('icon_topic_reported', 'POST_REPORTED'), 312 'UNAPPROVED_IMG' => $user->img('icon_topic_unapproved', 'POST_UNAPPROVED'), 313 'INFO_IMG' => $user->img('icon_post_info', 'VIEW_INFO'), 306 314 307 315 'S_MCP_ACTION' => "$url&i=$id&mode=$mode&action=$action&start=$start", … … 502 510 503 511 // Update forum statistics 504 set_config ('num_topics', $config['num_topics'] +1, true);512 set_config_count('num_topics', 1, true); 505 513 506 514 // Link back to both topics -
trunk/forum/includes/mcp/mcp_warn.php
r400 r702 3 3 * 4 4 * @package mcp 5 * @version $Id : mcp_warn.php 9002 2008-10-11 17:01:43Z toonarmy$5 * @version $Id$ 6 6 * @copyright (c) 2005 phpBB Group 7 7 * @license http://opensource.org/licenses/gpl-license.php GNU Public License … … 205 205 $sql = 'SELECT u.*, p.* 206 206 FROM ' . POSTS_TABLE . ' p, ' . USERS_TABLE . " u 207 WHERE p ost_id = $post_id207 WHERE p.post_id = $post_id 208 208 AND u.user_id = p.poster_id"; 209 209 $result = $db->sql_query($sql); … … 421 421 'U_POST_ACTION' => $this->u_action, 422 422 423 'USERNAME' => $user_row['username'],424 'USER_COLOR' => (!empty($user_row['user_colour'])) ? $user_row['user_colour'] : '',425 423 'RANK_TITLE' => $rank_title, 426 424 'JOINED' => $user->format_date($user_row['user_regdate']), 427 425 'POSTS' => ($user_row['user_posts']) ? $user_row['user_posts'] : 0, 428 426 'WARNINGS' => ($user_row['user_warnings']) ? $user_row['user_warnings'] : 0, 427 428 'USERNAME_FULL' => get_username_string('full', $user_row['user_id'], $user_row['username'], $user_row['user_colour']), 429 'USERNAME_COLOUR' => get_username_string('colour', $user_row['user_id'], $user_row['username'], $user_row['user_colour']), 430 'USERNAME' => get_username_string('username', $user_row['user_id'], $user_row['username'], $user_row['user_colour']), 431 'U_PROFILE' => get_username_string('profile', $user_row['user_id'], $user_row['username'], $user_row['user_colour']), 429 432 430 433 'AVATAR_IMG' => $avatar_img, -
trunk/forum/includes/message_parser.php
r400 r702 3 3 * 4 4 * @package phpBB3 5 * @version $Id : message_parser.php 9034 2008-10-24 00:49:30Z toonarmy$5 * @version $Id$ 6 6 * @copyright (c) 2005 phpBB Group 7 7 * @license http://opensource.org/licenses/gpl-license.php GNU Public License … … 119 119 'img' => array('bbcode_id' => 4, 'regexp' => array('#\[img\](.*)\[/img\]#iUe' => "\$this->bbcode_img('\$1')")), 120 120 'size' => array('bbcode_id' => 5, 'regexp' => array('#\[size=([\-\+]?\d+)\](.*?)\[/size\]#ise' => "\$this->bbcode_size('\$1', '\$2')")), 121 'color' => array('bbcode_id' => 6, 'regexp' => array('!\[color=(#[0-9a-f]{ 6}|[a-z\-]+)\](.*?)\[/color\]!ise' => "\$this->bbcode_color('\$1', '\$2')")),121 'color' => array('bbcode_id' => 6, 'regexp' => array('!\[color=(#[0-9a-f]{3}|#[0-9a-f]{6}|[a-z\-]+)\](.*?)\[/color\]!ise' => "\$this->bbcode_color('\$1', '\$2')")), 122 122 'u' => array('bbcode_id' => 7, 'regexp' => array('#\[u\](.*?)\[/u\]#ise' => "\$this->bbcode_underline('\$1')")), 123 123 'list' => array('bbcode_id' => 9, 'regexp' => array('#\[list(?:=(?:[a-z0-9]|disc|circle|square))?].*\[/list]#ise' => "\$this->bbcode_parse_list('\$0')")), … … 696 696 * [quote="[quote]test[/quote]"]test[/quote] (correct: parsed - Username displayed as [quote]test[/quote]) 697 697 * #20735 - [quote]test[/[/b]quote] test [/quote][/quote] test - (correct: quoted: "test[/[/b]quote] test" / non-quoted: "[/quote] test" - also failed if layout distorted) 698 * #40565 - [quote="a"]a[/quote][quote="a]a[/quote] (correct: first quote tag parsed, second quote tag unparsed) 698 699 */ 699 700 … … 706 707 707 708 // To let the parser not catch tokens within quote_username quotes we encode them before we start this... 708 $in = preg_replace('#quote="(.*?)"\]#ie', "'quote="' . str_replace(array('[', ']' ), array('[', ']'), '\$1') . '"]'", $in);709 $in = preg_replace('#quote="(.*?)"\]#ie', "'quote="' . str_replace(array('[', ']', '\\\"'), array('[', ']', '\"'), '\$1') . '"]'", $in); 709 710 710 711 $tok = ']'; … … 859 860 while ($in); 860 861 862 $out .= $buffer; 863 861 864 if (sizeof($close_tags)) 862 865 { … … 1050 1053 // Init BBCode UID 1051 1054 $this->bbcode_uid = substr(base_convert(unique_id(), 16, 36), 0, BBCODE_UID_LEN); 1052 1053 if ($message) 1054 { 1055 $this->message = $message; 1056 } 1055 $this->message = $message; 1057 1056 } 1058 1057 … … 1064 1063 global $config, $db, $user; 1065 1064 1066 $mode = ($mode != 'post') ? 'sig' : 'post';1067 1068 1065 $this->mode = $mode; 1066 1067 foreach (array('chars', 'smilies', 'urls', 'font_size', 'img_height', 'img_width') as $key) 1068 { 1069 if (!isset($config['max_' . $mode . '_' . $key])) 1070 { 1071 $config['max_' . $mode . '_' . $key] = 0; 1072 } 1073 } 1069 1074 1070 1075 $this->allow_img_bbcode = $allow_img_bbcode; … … 1091 1096 $this->message = preg_replace($match, $replace, trim($this->message)); 1092 1097 1093 // Message length check. 0 disables this check completely. 1094 if ($config['max_' . $mode . '_chars'] > 0) 1095 { 1096 $msg_len = ($mode == 'post') ? utf8_strlen($this->message) : utf8_strlen(preg_replace('#\[\/?[a-z\*\+\-]+(=[\S]+)?\]#ius', ' ', $this->message)); 1097 1098 if ((!$msg_len && $mode !== 'sig') || $config['max_' . $mode . '_chars'] && $msg_len > $config['max_' . $mode . '_chars']) 1099 { 1100 $this->warn_msg[] = (!$msg_len) ? $user->lang['TOO_FEW_CHARS'] : sprintf($user->lang['TOO_MANY_CHARS_' . strtoupper($mode)], $msg_len, $config['max_' . $mode . '_chars']); 1098 // Store message length... 1099 $message_length = ($mode == 'post') ? utf8_strlen($this->message) : utf8_strlen(preg_replace('#\[\/?[a-z\*\+\-]+(=[\S]+)?\]#ius', ' ', $this->message)); 1100 1101 // Maximum message length check. 0 disables this check completely. 1102 if ((int) $config['max_' . $mode . '_chars'] > 0 && $message_length > (int) $config['max_' . $mode . '_chars']) 1103 { 1104 $this->warn_msg[] = sprintf($user->lang['TOO_MANY_CHARS_' . strtoupper($mode)], $message_length, (int) $config['max_' . $mode . '_chars']); 1105 return (!$update_this_message) ? $return_message : $this->warn_msg; 1106 } 1107 1108 // Minimum message length check for post only 1109 if ($mode === 'post') 1110 { 1111 if (!$message_length || $message_length < (int) $config['min_post_chars']) 1112 { 1113 $this->warn_msg[] = (!$message_length) ? $user->lang['TOO_FEW_CHARS'] : sprintf($user->lang['TOO_FEW_CHARS_LIMIT'], $message_length, (int) $config['min_post_chars']); 1101 1114 return (!$update_this_message) ? $return_message : $this->warn_msg; 1102 1115 } 1103 }1104 1105 // Check for "empty" message1106 if ($mode !== 'sig' && utf8_clean_string($this->message) === '')1107 {1108 $this->warn_msg[] = $user->lang['TOO_FEW_CHARS'];1109 return (!$update_this_message) ? $return_message : $this->warn_msg;1110 1116 } 1111 1117 … … 1150 1156 $num_urls += preg_match_all('#\<!-- ([lmwe]) --\>.*?\<!-- \1 --\>#', $this->message, $matches); 1151 1157 } 1158 } 1159 1160 // Check for "empty" message. We do not check here for maximum length, because bbcode, smilies, etc. can add to the length. 1161 // The maximum length check happened before any parsings. 1162 if ($mode === 'post' && utf8_clean_string($this->message) === '') 1163 { 1164 $this->warn_msg[] = $user->lang['TOO_FEW_CHARS']; 1165 return (!$update_this_message) ? $return_message : $this->warn_msg; 1152 1166 } 1153 1167 … … 1299 1313 1300 1314 // (assertion) 1301 $match[] = '(?<=^|[\n .])' . preg_quote($row['code'], '#') . '(?![^<>]*>)';1315 $match[] = preg_quote($row['code'], '#'); 1302 1316 $replace[] = '<!-- s' . $row['code'] . ' --><img src="{SMILIES_PATH}/' . $row['smiley_url'] . '" alt="' . $row['code'] . '" title="' . $row['emotion'] . '" /><!-- s' . $row['code'] . ' -->'; 1303 1317 } … … 1309 1323 if ($max_smilies) 1310 1324 { 1311 $num_matches = preg_match_all('# ' . implode('|', $match) . '#', $this->message, $matches);1325 $num_matches = preg_match_all('#(?<=^|[\n .])(?:' . implode('|', $match) . ')(?![^<>]*>)#', $this->message, $matches); 1312 1326 unset($matches); 1313 1327 … … 1320 1334 1321 1335 // Make sure the delimiter # is added in front and at the end of every element within $match 1322 $this->message = trim(preg_replace(explode(chr(0), '# ' . implode('#' . chr(0) . '#', $match) . '#'), $replace, $this->message));1336 $this->message = trim(preg_replace(explode(chr(0), '#(?<=^|[\n .])' . implode('(?![^<>]*>)#' . chr(0) . '#(?<=^|[\n .])', $match) . '(?![^<>]*>)#'), $replace, $this->message)); 1323 1337 } 1324 1338 } … … 1613 1627 $bbcode_bitfield = $this->bbcode_bitfield; 1614 1628 1615 $poll['poll_option_text'] = $this->parse($poll['enable_bbcode'], ($config['allow_post_links']) ? $poll['enable_urls'] : false, $poll['enable_smilies'], $poll['img_status'], false, false, $config['allow_post_links'], false );1629 $poll['poll_option_text'] = $this->parse($poll['enable_bbcode'], ($config['allow_post_links']) ? $poll['enable_urls'] : false, $poll['enable_smilies'], $poll['img_status'], false, false, $config['allow_post_links'], false, 'poll'); 1616 1630 1617 1631 $bbcode_bitfield = base64_encode(base64_decode($bbcode_bitfield) | base64_decode($this->bbcode_bitfield)); … … 1636 1650 $this->warn_msg[] = $user->lang['POLL_TITLE_TOO_LONG']; 1637 1651 } 1638 $poll['poll_title'] = $this->parse($poll['enable_bbcode'], ($config['allow_post_links']) ? $poll['enable_urls'] : false, $poll['enable_smilies'], $poll['img_status'], false, false, $config['allow_post_links'], false );1652 $poll['poll_title'] = $this->parse($poll['enable_bbcode'], ($config['allow_post_links']) ? $poll['enable_urls'] : false, $poll['enable_smilies'], $poll['img_status'], false, false, $config['allow_post_links'], false, 'poll'); 1639 1653 if (strlen($poll['poll_title']) > 255) 1640 1654 { -
trunk/forum/includes/search/fulltext_mysql.php
r400 r702 3 3 * 4 4 * @package search 5 * @version $Id : fulltext_mysql.php 8814 2008-09-04 12:01:47Z acydburn$5 * @version $Id$ 6 6 * @copyright (c) 2005 phpBB Group 7 7 * @license http://opensource.org/licenses/gpl-license.php GNU Public License … … 119 119 function split_keywords(&$keywords, $terms) 120 120 { 121 global $config ;121 global $config, $user; 122 122 123 123 if ($terms == 'all') … … 166 166 preg_match_all('#(?:[^\w*"()]|^)([+\-|]?(?:[\w*"()]+\'?)*[\w*"()])(?:[^\w*"()]|$)#u', $split_keywords, $matches); 167 167 $this->split_words = $matches[1]; 168 } 169 170 // We limit the number of allowed keywords to minimize load on the database 171 if ($config['max_num_search_keywords'] && sizeof($this->split_words) > $config['max_num_search_keywords']) 172 { 173 trigger_error($user->lang('MAX_NUM_SEARCH_KEYWORDS_REFINE', $config['max_num_search_keywords'], sizeof($this->split_words))); 168 174 } 169 175 … … 319 325 * 320 326 * @param string $type contains either posts or topics depending on what should be searched for 321 * @param string &$fields contains either titleonly (topic titles should be searched), msgonly (only message bodies should be searched), firstpost (only subject and body of the first post should be searched) or all (all post bodies and subjects should be searched) 322 * @param string &$terms is either 'all' (use query as entered, words without prefix should default to "have to be in field") or 'any' (ignore search query parts and just return all posts that contain any of the specified words) 323 * @param array &$sort_by_sql contains SQL code for the ORDER BY part of a query 324 * @param string &$sort_key is the key of $sort_by_sql for the selected sorting 325 * @param string &$sort_dir is either a or d representing ASC and DESC 326 * @param string &$sort_days specifies the maximum amount of days a post may be old 327 * @param array &$ex_fid_ary specifies an array of forum ids which should not be searched 328 * @param array &$m_approve_fid_ary specifies an array of forum ids in which the searcher is allowed to view unapproved posts 329 * @param int &$topic_id is set to 0 or a topic id, if it is not 0 then only posts in this topic should be searched 330 * @param array &$author_ary an array of author ids if the author should be ignored during the search the array is empty 327 * @param string $fields contains either titleonly (topic titles should be searched), msgonly (only message bodies should be searched), firstpost (only subject and body of the first post should be searched) or all (all post bodies and subjects should be searched) 328 * @param string $terms is either 'all' (use query as entered, words without prefix should default to "have to be in field") or 'any' (ignore search query parts and just return all posts that contain any of the specified words) 329 * @param array $sort_by_sql contains SQL code for the ORDER BY part of a query 330 * @param string $sort_key is the key of $sort_by_sql for the selected sorting 331 * @param string $sort_dir is either a or d representing ASC and DESC 332 * @param string $sort_days specifies the maximum amount of days a post may be old 333 * @param array $ex_fid_ary specifies an array of forum ids which should not be searched 334 * @param array $m_approve_fid_ary specifies an array of forum ids in which the searcher is allowed to view unapproved posts 335 * @param int $topic_id is set to 0 or a topic id, if it is not 0 then only posts in this topic should be searched 336 * @param array $author_ary an array of author ids if the author should be ignored during the search the array is empty 337 * @param string $author_name specifies the author match, when ANONYMOUS is also a search-match 331 338 * @param array &$id_ary passed by reference, to be filled with ids for the page specified by $start and $per_page, should be ordered 332 339 * @param int $start indicates the first index of the page … … 336 343 * @access public 337 344 */ 338 function keyword_search($type, &$fields, &$terms, &$sort_by_sql, &$sort_key, &$sort_dir, &$sort_days, &$ex_fid_ary, &$m_approve_fid_ary, &$topic_id, &$author_ary, &$id_ary, $start, $per_page)345 function keyword_search($type, $fields, $terms, $sort_by_sql, $sort_key, $sort_dir, $sort_days, $ex_fid_ary, $m_approve_fid_ary, $topic_id, $author_ary, $author_name, &$id_ary, $start, $per_page) 339 346 { 340 347 global $config, $db; … … 435 442 $sql_from = ($join_topic) ? TOPICS_TABLE . ' t, ' : ''; 436 443 $field = ($type == 'posts') ? 'post_id' : 'topic_id'; 437 $sql_author = (sizeof($author_ary) == 1) ? ' = ' . $author_ary[0] : 'IN (' . implode(', ', $author_ary) . ')'; 444 if (sizeof($author_ary) && $author_name) 445 { 446 // first one matches post of registered users, second one guests and deleted users 447 $sql_author = ' AND (' . $db->sql_in_set('p.poster_id', array_diff($author_ary, array(ANONYMOUS)), false, true) . ' OR p.post_username ' . $author_name . ')'; 448 } 449 else if (sizeof($author_ary)) 450 { 451 $sql_author = ' AND ' . $db->sql_in_set('p.poster_id', $author_ary); 452 } 453 else 454 { 455 $sql_author = ''; 456 } 438 457 439 458 $sql_where_options = $sql_sort_join; … … 442 461 $sql_where_options .= (sizeof($ex_fid_ary)) ? ' AND ' . $db->sql_in_set('p.forum_id', $ex_fid_ary, true) : ''; 443 462 $sql_where_options .= $m_approve_fid_sql; 444 $sql_where_options .= (sizeof($author_ary)) ? ' AND p.poster_id ' . $sql_author : '';463 $sql_where_options .= $sql_author; 445 464 $sql_where_options .= ($sort_days) ? ' AND p.post_time >= ' . (time() - ($sort_days * 86400)) : ''; 446 465 $sql_where_options .= $sql_match_where; … … 455 474 while ($row = $db->sql_fetchrow($result)) 456 475 { 457 $id_ary[] = $row[$field];476 $id_ary[] = (int) $row[$field]; 458 477 } 459 478 $db->sql_freeresult($result); … … 490 509 * Performs a search on an author's posts without caring about message contents. Depends on display specific params 491 510 * 492 * @param array &$id_ary passed by reference, to be filled with ids for the page specified by $start and $per_page, should be ordered 493 * @param int $start indicates the first index of the page 494 * @param int $per_page number of ids each page is supposed to contain 495 * @return total number of results 496 */ 497 function author_search($type, $firstpost_only, &$sort_by_sql, &$sort_key, &$sort_dir, &$sort_days, &$ex_fid_ary, &$m_approve_fid_ary, &$topic_id, &$author_ary, &$id_ary, $start, $per_page) 511 * @param string $type contains either posts or topics depending on what should be searched for 512 * @param boolean $firstpost_only if true, only topic starting posts will be considered 513 * @param array $sort_by_sql contains SQL code for the ORDER BY part of a query 514 * @param string $sort_key is the key of $sort_by_sql for the selected sorting 515 * @param string $sort_dir is either a or d representing ASC and DESC 516 * @param string $sort_days specifies the maximum amount of days a post may be old 517 * @param array $ex_fid_ary specifies an array of forum ids which should not be searched 518 * @param array $m_approve_fid_ary specifies an array of forum ids in which the searcher is allowed to view unapproved posts 519 * @param int $topic_id is set to 0 or a topic id, if it is not 0 then only posts in this topic should be searched 520 * @param array $author_ary an array of author ids 521 * @param string $author_name specifies the author match, when ANONYMOUS is also a search-match 522 * @param array &$id_ary passed by reference, to be filled with ids for the page specified by $start and $per_page, should be ordered 523 * @param int $start indicates the first index of the page 524 * @param int $per_page number of ids each page is supposed to contain 525 * @return boolean|int total number of results 526 * 527 * @access public 528 */ 529 function author_search($type, $firstpost_only, $sort_by_sql, $sort_key, $sort_dir, $sort_days, $ex_fid_ary, $m_approve_fid_ary, $topic_id, $author_ary, $author_name, &$id_ary, $start, $per_page) 498 530 { 499 531 global $config, $db; … … 517 549 implode(',', $ex_fid_ary), 518 550 implode(',', $m_approve_fid_ary), 519 implode(',', $author_ary) 551 implode(',', $author_ary), 552 $author_name, 520 553 ))); 521 554 … … 530 563 531 564 // Create some display specific sql strings 532 $sql_author = $db->sql_in_set('p.poster_id', $author_ary); 565 if ($author_name) 566 { 567 // first one matches post of registered users, second one guests and deleted users 568 $sql_author = '(' . $db->sql_in_set('p.poster_id', array_diff($author_ary, array(ANONYMOUS)), false, true) . ' OR p.post_username ' . $author_name . ')'; 569 } 570 else 571 { 572 $sql_author = $db->sql_in_set('p.poster_id', $author_ary); 573 } 533 574 $sql_fora = (sizeof($ex_fid_ary)) ? ' AND ' . $db->sql_in_set('p.forum_id', $ex_fid_ary, true) : ''; 534 575 $sql_topic_id = ($topic_id) ? ' AND p.topic_id = ' . (int) $topic_id : ''; … … 610 651 while ($row = $db->sql_fetchrow($result)) 611 652 { 612 $id_ary[] = $row[$field];653 $id_ary[] = (int) $row[$field]; 613 654 } 614 655 $db->sql_freeresult($result); -
trunk/forum/includes/search/fulltext_native.php
r400 r702 3 3 * 4 4 * @package search 5 * @version $Id : fulltext_native.php 9173 2008-12-04 17:01:39Z naderman$5 * @version $Id$ 6 6 * @copyright (c) 2005 phpBB Group 7 7 * @license http://opensource.org/licenses/gpl-license.php GNU Public License … … 82 82 function split_keywords($keywords, $terms) 83 83 { 84 global $db, $user ;84 global $db, $user, $config; 85 85 86 86 $keywords = trim($this->cleanup($keywords, '+-|()*')); … … 168 168 169 169 $keywords = preg_replace($match, $replace, $keywords); 170 $num_keywords = sizeof(explode(' ', $keywords)); 171 172 // We limit the number of allowed keywords to minimize load on the database 173 if ($config['max_num_search_keywords'] && $num_keywords > $config['max_num_search_keywords']) 174 { 175 trigger_error($user->lang('MAX_NUM_SEARCH_KEYWORDS_REFINE', $config['max_num_search_keywords'], $num_keywords)); 176 } 170 177 171 178 // $keywords input format: each word separated by a space, words in a bracket are not separated … … 196 203 $sql = 'SELECT word_id, word_text, word_common 197 204 FROM ' . SEARCH_WORDLIST_TABLE . ' 198 WHERE ' . $db->sql_in_set('word_text', $exact_words); 205 WHERE ' . $db->sql_in_set('word_text', $exact_words) . ' 206 ORDER BY word_count ASC'; 199 207 $result = $db->sql_query($sql); 200 208 … … 371 379 } 372 380 373 sort($this->must_contain_ids);374 sort($this->must_not_contain_ids);375 sort($this->must_exclude_one_ids);376 377 381 if (!empty($this->search_query)) 378 382 { … … 386 390 * 387 391 * @param string $type contains either posts or topics depending on what should be searched for 388 * @param string &$fields contains either titleonly (topic titles should be searched), msgonly (only message bodies should be searched), firstpost (only subject and body of the first post should be searched) or all (all post bodies and subjects should be searched) 389 * @param string &$terms is either 'all' (use query as entered, words without prefix should default to "have to be in field") or 'any' (ignore search query parts and just return all posts that contain any of the specified words) 390 * @param array &$sort_by_sql contains SQL code for the ORDER BY part of a query 391 * @param string &$sort_key is the key of $sort_by_sql for the selected sorting 392 * @param string &$sort_dir is either a or d representing ASC and DESC 393 * @param string &$sort_days specifies the maximum amount of days a post may be old 394 * @param array &$ex_fid_ary specifies an array of forum ids which should not be searched 395 * @param array &$m_approve_fid_ary specifies an array of forum ids in which the searcher is allowed to view unapproved posts 396 * @param int &$topic_id is set to 0 or a topic id, if it is not 0 then only posts in this topic should be searched 397 * @param array &$author_ary an array of author ids if the author should be ignored during the search the array is empty 392 * @param string $fields contains either titleonly (topic titles should be searched), msgonly (only message bodies should be searched), firstpost (only subject and body of the first post should be searched) or all (all post bodies and subjects should be searched) 393 * @param string $terms is either 'all' (use query as entered, words without prefix should default to "have to be in field") or 'any' (ignore search query parts and just return all posts that contain any of the specified words) 394 * @param array $sort_by_sql contains SQL code for the ORDER BY part of a query 395 * @param string $sort_key is the key of $sort_by_sql for the selected sorting 396 * @param string $sort_dir is either a or d representing ASC and DESC 397 * @param string $sort_days specifies the maximum amount of days a post may be old 398 * @param array $ex_fid_ary specifies an array of forum ids which should not be searched 399 * @param array $m_approve_fid_ary specifies an array of forum ids in which the searcher is allowed to view unapproved posts 400 * @param int $topic_id is set to 0 or a topic id, if it is not 0 then only posts in this topic should be searched 401 * @param array $author_ary an array of author ids if the author should be ignored during the search the array is empty 402 * @param string $author_name specifies the author match, when ANONYMOUS is also a search-match 398 403 * @param array &$id_ary passed by reference, to be filled with ids for the page specified by $start and $per_page, should be ordered 399 404 * @param int $start indicates the first index of the page … … 403 408 * @access public 404 409 */ 405 function keyword_search($type, &$fields, &$terms, &$sort_by_sql, &$sort_key, &$sort_dir, &$sort_days, &$ex_fid_ary, &$m_approve_fid_ary, &$topic_id, &$author_ary, &$id_ary, $start, $per_page)410 function keyword_search($type, $fields, $terms, $sort_by_sql, $sort_key, $sort_dir, $sort_days, $ex_fid_ary, $m_approve_fid_ary, $topic_id, $author_ary, $author_name, &$id_ary, $start, $per_page) 406 411 { 407 412 global $config, $db; … … 413 418 } 414 419 420 $must_contain_ids = $this->must_contain_ids; 421 $must_not_contain_ids = $this->must_not_contain_ids; 422 $must_exclude_one_ids = $this->must_exclude_one_ids; 423 424 sort($must_contain_ids); 425 sort($must_not_contain_ids); 426 sort($must_exclude_one_ids); 427 415 428 // generate a search_key from all the options to identify the results 416 429 $search_key = md5(implode('#', array( 417 serialize($ this->must_contain_ids),418 serialize($ this->must_not_contain_ids),419 serialize($ this->must_exclude_one_ids),430 serialize($must_contain_ids), 431 serialize($must_not_contain_ids), 432 serialize($must_exclude_one_ids), 420 433 $type, 421 434 $fields, … … 426 439 implode(',', $ex_fid_ary), 427 440 implode(',', $m_approve_fid_ary), 428 implode(',', $author_ary) 441 implode(',', $author_ary), 442 $author_name, 429 443 ))); 430 444 … … 617 631 if (sizeof($author_ary)) 618 632 { 619 $sql_where[] = $db->sql_in_set('p.poster_id', $author_ary); 633 if ($author_name) 634 { 635 // first one matches post of registered users, second one guests and deleted users 636 $sql_author = '(' . $db->sql_in_set('p.poster_id', array_diff($author_ary, array(ANONYMOUS)), false, true) . ' OR p.post_username ' . $author_name . ')'; 637 } 638 else 639 { 640 $sql_author = $db->sql_in_set('p.poster_id', $author_ary); 641 } 642 $sql_where[] = $sql_author; 620 643 } 621 644 … … 639 662 $sql_array_count = $sql_array; 640 663 664 if ($left_join_topics) 665 { 666 $sql_array_count['LEFT_JOIN'][] = array( 667 'FROM' => array(TOPICS_TABLE => 't'), 668 'ON' => 'p.topic_id = t.topic_id' 669 ); 670 } 671 641 672 switch ($db->sql_layer) 642 673 { … … 645 676 646 677 // 3.x does not support SQL_CALC_FOUND_ROWS 647 $sql_array['SELECT'] = 'SQL_CALC_FOUND_ROWS ' . $sql_array['SELECT'];678 // $sql_array['SELECT'] = 'SQL_CALC_FOUND_ROWS ' . $sql_array['SELECT']; 648 679 $is_mysql = true; 649 680 … … 694 725 break; 695 726 } 696 727 697 728 if ($left_join_topics) 698 729 { 699 $sql_array['LEFT_JOIN'][ $left_join_topics] = array(730 $sql_array['LEFT_JOIN'][] = array( 700 731 'FROM' => array(TOPICS_TABLE => 't'), 701 732 'ON' => 'p.topic_id = t.topic_id' … … 714 745 while ($row = $db->sql_fetchrow($result)) 715 746 { 716 $id_ary[] = $row[(($type == 'posts') ? 'post_id' : 'topic_id')];747 $id_ary[] = (int) $row[(($type == 'posts') ? 'post_id' : 'topic_id')]; 717 748 } 718 749 $db->sql_freeresult($result); … … 726 757 if (!$total_results && $is_mysql) 727 758 { 759 // Count rows for the executed queries. Replace $select within $sql with SQL_CALC_FOUND_ROWS, and run it. 760 $sql_array_copy = $sql_array; 761 $sql_array_copy['SELECT'] = 'SQL_CALC_FOUND_ROWS p.post_id '; 762 763 $sql = $db->sql_build_query('SELECT', $sql_array_copy); 764 unset($sql_array_copy); 765 766 $db->sql_query($sql); 767 $db->sql_freeresult($result); 768 728 769 $sql = 'SELECT FOUND_ROWS() as total_results'; 729 770 $result = $db->sql_query($sql); … … 749 790 * @param string $type contains either posts or topics depending on what should be searched for 750 791 * @param boolean $firstpost_only if true, only topic starting posts will be considered 751 * @param array &$sort_by_sql contains SQL code for the ORDER BY part of a query 752 * @param string &$sort_key is the key of $sort_by_sql for the selected sorting 753 * @param string &$sort_dir is either a or d representing ASC and DESC 754 * @param string &$sort_days specifies the maximum amount of days a post may be old 755 * @param array &$ex_fid_ary specifies an array of forum ids which should not be searched 756 * @param array &$m_approve_fid_ary specifies an array of forum ids in which the searcher is allowed to view unapproved posts 757 * @param int &$topic_id is set to 0 or a topic id, if it is not 0 then only posts in this topic should be searched 758 * @param array &$author_ary an array of author ids 792 * @param array $sort_by_sql contains SQL code for the ORDER BY part of a query 793 * @param string $sort_key is the key of $sort_by_sql for the selected sorting 794 * @param string $sort_dir is either a or d representing ASC and DESC 795 * @param string $sort_days specifies the maximum amount of days a post may be old 796 * @param array $ex_fid_ary specifies an array of forum ids which should not be searched 797 * @param array $m_approve_fid_ary specifies an array of forum ids in which the searcher is allowed to view unapproved posts 798 * @param int $topic_id is set to 0 or a topic id, if it is not 0 then only posts in this topic should be searched 799 * @param array $author_ary an array of author ids 800 * @param string $author_name specifies the author match, when ANONYMOUS is also a search-match 759 801 * @param array &$id_ary passed by reference, to be filled with ids for the page specified by $start and $per_page, should be ordered 760 802 * @param int $start indicates the first index of the page … … 764 806 * @access public 765 807 */ 766 function author_search($type, $firstpost_only, &$sort_by_sql, &$sort_key, &$sort_dir, &$sort_days, &$ex_fid_ary, &$m_approve_fid_ary, &$topic_id, &$author_ary, &$id_ary, $start, $per_page)808 function author_search($type, $firstpost_only, $sort_by_sql, $sort_key, $sort_dir, $sort_days, $ex_fid_ary, $m_approve_fid_ary, $topic_id, $author_ary, $author_name, &$id_ary, $start, $per_page) 767 809 { 768 810 global $config, $db; … … 786 828 implode(',', $ex_fid_ary), 787 829 implode(',', $m_approve_fid_ary), 788 implode(',', $author_ary) 830 implode(',', $author_ary), 831 $author_name, 789 832 ))); 790 833 … … 799 842 800 843 // Create some display specific sql strings 801 $sql_author = $db->sql_in_set('p.poster_id', $author_ary); 844 if ($author_name) 845 { 846 // first one matches post of registered users, second one guests and deleted users 847 $sql_author = '(' . $db->sql_in_set('p.poster_id', array_diff($author_ary, array(ANONYMOUS)), false, true) . ' OR p.post_username ' . $author_name . ')'; 848 } 849 else 850 { 851 $sql_author = $db->sql_in_set('p.poster_id', $author_ary); 852 } 802 853 $sql_fora = (sizeof($ex_fid_ary)) ? ' AND ' . $db->sql_in_set('p.forum_id', $ex_fid_ary, true) : ''; 803 854 $sql_time = ($sort_days) ? ' AND p.post_time >= ' . (time() - ($sort_days * 86400)) : ''; … … 849 900 case 'mysql4': 850 901 case 'mysqli': 851 $select = 'SQL_CALC_FOUND_ROWS ' . $select;902 // $select = 'SQL_CALC_FOUND_ROWS ' . $select; 852 903 $is_mysql = true; 853 904 break; … … 936 987 while ($row = $db->sql_fetchrow($result)) 937 988 { 938 $id_ary[] = $row[$field];989 $id_ary[] = (int) $row[$field]; 939 990 } 940 991 $db->sql_freeresult($result); … … 942 993 if (!$total_results && $is_mysql) 943 994 { 995 // Count rows for the executed queries. Replace $select within $sql with SQL_CALC_FOUND_ROWS, and run it. 996 $sql = str_replace('SELECT ' . $select, 'SELECT DISTINCT SQL_CALC_FOUND_ROWS p.post_id', $sql); 997 998 $db->sql_query($sql); 999 $db->sql_freeresult($result); 1000 944 1001 $sql = 'SELECT FOUND_ROWS() as total_results'; 945 1002 $result = $db->sql_query($sql); … … 1111 1168 // Get unique words from the above arrays 1112 1169 $unique_add_words = array_unique(array_merge($words['add']['post'], $words['add']['title'])); 1113 1170 1114 1171 // We now have unique arrays of all words to be added and removed and 1115 1172 // individual arrays of added and removed words for text and title. What -
trunk/forum/includes/session.php
r400 r702 3 3 * 4 4 * @package phpBB3 5 * @version $Id : session.php 9170 2008-12-04 12:56:12Z toonarmy$5 * @version $Id$ 6 6 * @copyright (c) 2005 phpBB Group 7 7 * @license http://opensource.org/licenses/gpl-license.php GNU Public License … … 214 214 $this->browser = (!empty($_SERVER['HTTP_USER_AGENT'])) ? htmlspecialchars((string) $_SERVER['HTTP_USER_AGENT']) : ''; 215 215 $this->referer = (!empty($_SERVER['HTTP_REFERER'])) ? htmlspecialchars((string) $_SERVER['HTTP_REFERER']) : ''; 216 $this->forwarded_for = (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) ? (string) $_SERVER['HTTP_X_FORWARDED_FOR']: '';216 $this->forwarded_for = (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) ? htmlspecialchars((string) $_SERVER['HTTP_X_FORWARDED_FOR']) : ''; 217 217 218 218 $this->host = $this->extract_current_hostname(); … … 222 222 if ($config['forwarded_for_check']) 223 223 { 224 $this->forwarded_for = preg_replace('# , +#', ', ', $this->forwarded_for);224 $this->forwarded_for = preg_replace('#[ ]{2,}#', ' ', str_replace(array(',', ' '), ' ', $this->forwarded_for)); 225 225 226 226 // split the list of IPs 227 $ips = explode(' ,', $this->forwarded_for);227 $ips = explode(' ', $this->forwarded_for); 228 228 foreach ($ips as $ip) 229 229 { … … 268 268 // Why no forwarded_for et al? Well, too easily spoofed. With the results of my recent requests 269 269 // it's pretty clear that in the majority of cases you'll at least be left with a proxy/cache ip. 270 $this->ip = (!empty($_SERVER['REMOTE_ADDR'])) ? htmlspecialchars($_SERVER['REMOTE_ADDR']) : ''; 270 $this->ip = (!empty($_SERVER['REMOTE_ADDR'])) ? htmlspecialchars((string) $_SERVER['REMOTE_ADDR']) : ''; 271 $this->ip = preg_replace('#[ ]{2,}#', ' ', str_replace(array(',', ' '), ' ', $this->ip)); 272 273 // split the list of IPs 274 $ips = explode(' ', $this->ip); 275 276 // Default IP if REMOTE_ADDR is invalid 277 $this->ip = '127.0.0.1'; 278 279 foreach ($ips as $ip) 280 { 281 // check IPv4 first, the IPv6 is hopefully only going to be used very seldomly 282 if (!empty($ip) && !preg_match(get_preg_expression('ipv4'), $ip) && !preg_match(get_preg_expression('ipv6'), $ip)) 283 { 284 // Just break 285 break; 286 } 287 288 // Use the last in chain 289 $this->ip = $ip; 290 } 291 271 292 $this->load = false; 272 293 … … 397 418 $db->sql_query($sql); 398 419 } 420 421 if ($this->data['user_id'] != ANONYMOUS && !empty($config['new_member_post_limit']) && $this->data['user_new'] && $config['new_member_post_limit'] <= $this->data['user_posts']) 422 { 423 $this->leave_newly_registered(); 424 } 399 425 } 400 426 … … 481 507 foreach (explode(',', $row['bot_ip']) as $bot_ip) 482 508 { 509 $bot_ip = trim($bot_ip); 510 511 if (!$bot_ip) 512 { 513 continue; 514 } 515 483 516 if (strpos($this->ip, $bot_ip) === 0) 484 517 { … … 595 628 else 596 629 { 597 $ips = explode(' ,', $this->forwarded_for);630 $ips = explode(' ', $this->forwarded_for); 598 631 $ips[] = $this->ip; 599 632 $this->check_ban($this->data['user_id'], $ips); … … 720 753 // $db->sql_return_on_error(false); 721 754 755 // Something quite important: session_page always holds the *last* page visited, except for the *first* visit. 756 // We are not able to simply have an empty session_page btw, therefore we need to tell phpBB how to detect this special case. 757 // If the session id is empty, we have a completely new one and will set an "identifier" here. This identifier is able to be checked later. 758 if (empty($this->data['session_id'])) 759 { 760 // This is a temporary variable, only set for the very first visit 761 $this->data['session_created'] = true; 762 } 763 722 764 $this->session_id = $this->data['session_id'] = md5(unique_id()); 723 765 … … 876 918 function session_gc() 877 919 { 878 global $db, $config ;920 global $db, $config, $phpbb_root_path, $phpEx; 879 921 880 922 $batch_size = 10; … … 934 976 $db->sql_query($sql); 935 977 } 936 $this->confirm_gc(); 978 979 // only called from CRON; should be a safe workaround until the infrastructure gets going 980 if (!class_exists('captcha_factory')) 981 { 982 include($phpbb_root_path . "includes/captcha/captcha_factory." . $phpEx); 983 } 984 phpbb_captcha_factory::garbage_collect($config['captcha_plugin']); 937 985 } 938 986 939 987 return; 940 988 } 941 942 function confirm_gc($type = 0)943 {944 global $db, $config;945 946 $sql = 'SELECT DISTINCT c.session_id947 FROM ' . CONFIRM_TABLE . ' c948 LEFT JOIN ' . SESSIONS_TABLE . ' s ON (c.session_id = s.session_id)949 WHERE s.session_id IS NULL' .950 ((empty($type)) ? '' : ' AND c.confirm_type = ' . (int) $type);951 $result = $db->sql_query($sql);952 953 if ($row = $db->sql_fetchrow($result))954 {955 $sql_in = array();956 do957 {958 $sql_in[] = (string) $row['session_id'];959 }960 while ($row = $db->sql_fetchrow($result));961 962 if (sizeof($sql_in))963 {964 $sql = 'DELETE FROM ' . CONFIRM_TABLE . '965 WHERE ' . $db->sql_in_set('session_id', $sql_in);966 $db->sql_query($sql);967 }968 }969 $db->sql_freeresult($result);970 }971 972 989 973 990 /** … … 1205 1222 1206 1223 $dnsbl_check = array( 1207 'sbl -xbl.spamhaus.org' => 'http://www.spamhaus.org/query/bl?ip=',1224 'sbl.spamhaus.org' => 'http://www.spamhaus.org/query/bl?ip=', 1208 1225 ); 1209 1226 … … 1339 1356 global $config, $db; 1340 1357 1341 $user_id = ($user_id === false) ? $this->data['user_id'] :$user_id;1358 $user_id = ($user_id === false) ? (int) $this->data['user_id'] : (int) $user_id; 1342 1359 1343 1360 $sql = 'DELETE FROM ' . SESSIONS_KEYS_TABLE . ' … … 1345 1362 $db->sql_query($sql); 1346 1363 1364 // If the user is logged in, update last visit info first before deleting sessions 1365 $sql = 'SELECT session_time, session_page 1366 FROM ' . SESSIONS_TABLE . ' 1367 WHERE session_user_id = ' . (int) $user_id . ' 1368 ORDER BY session_time DESC'; 1369 $result = $db->sql_query_limit($sql, 1); 1370 $row = $db->sql_fetchrow($result); 1371 $db->sql_freeresult($result); 1372 1373 if ($row) 1374 { 1375 $sql = 'UPDATE ' . USERS_TABLE . ' 1376 SET user_lastvisit = ' . (int) $row['session_time'] . ", user_lastpage = '" . $db->sql_escape($row['session_page']) . "' 1377 WHERE user_id = " . (int) $user_id; 1378 $db->sql_query($sql); 1379 } 1380 1347 1381 // Let's also clear any current sessions for the specified user_id 1348 1382 // If it's the current user then we'll leave this session intact 1349 1383 $sql_where = 'session_user_id = ' . (int) $user_id; 1350 $sql_where .= ($user_id === $this->data['user_id']) ? " AND session_id <> '" . $db->sql_escape($this->session_id) . "'" : '';1384 $sql_where .= ($user_id === (int) $this->data['user_id']) ? " AND session_id <> '" . $db->sql_escape($this->session_id) . "'" : ''; 1351 1385 1352 1386 $sql = 'DELETE FROM ' . SESSIONS_TABLE . " … … 1356 1390 // We're changing the password of the current user and they have a key 1357 1391 // Lets regenerate it to be safe 1358 if ($user_id === $this->data['user_id'] && $this->cookie_data['k'])1392 if ($user_id === (int) $this->data['user_id'] && $this->cookie_data['k']) 1359 1393 { 1360 1394 $this->set_login_key($user_id); … … 1369 1403 function validate_referer($check_script_path = false) 1370 1404 { 1405 global $config; 1406 1371 1407 // no referer - nothing to validate, user's fault for turning it off (we only check on POST; so meta can't be the reason) 1372 1408 if (empty($this->referer) || empty($this->host)) … … 1378 1414 $ref = substr($this->referer, strpos($this->referer, '://') + 3); 1379 1415 1380 if (!(stripos($ref, $host) === 0) )1416 if (!(stripos($ref, $host) === 0) && (!$config['force_server_vars'] || !(stripos($ref, $config['server_name']) === 0))) 1381 1417 { 1382 1418 return false; … … 1436 1472 var $img_array = array(); 1437 1473 1438 // Able to add new option (id 7)1439 var $keyoptions = array('viewimg' => 0, 'viewflash' => 1, 'viewsmilies' => 2, 'viewsigs' => 3, 'viewavatars' => 4, 'viewcensors' => 5, 'attachsig' => 6, 'bbcode' => 8, 'smilies' => 9, 'popuppm' => 10 );1474 // Able to add new options (up to id 31) 1475 var $keyoptions = array('viewimg' => 0, 'viewflash' => 1, 'viewsmilies' => 2, 'viewsigs' => 3, 'viewavatars' => 4, 'viewcensors' => 5, 'attachsig' => 6, 'bbcode' => 8, 'smilies' => 9, 'popuppm' => 10, 'sig_bbcode' => 15, 'sig_smilies' => 16, 'sig_links' => 17); 1440 1476 var $keyvalues = array(); 1441 1477 … … 1528 1564 $lang = &$this->lang; 1529 1565 1530 if ((@include $this->lang_path . $this->lang_name . "/common.$phpEx") === false) 1566 // Do not suppress error if in DEBUG_EXTRA mode 1567 $include_result = (defined('DEBUG_EXTRA')) ? (include $this->lang_path . $this->lang_name . "/common.$phpEx") : (@include $this->lang_path . $this->lang_name . "/common.$phpEx"); 1568 1569 if ($include_result === false) 1531 1570 { 1532 1571 die('Language file ' . $this->lang_path . $this->lang_name . "/common.$phpEx" . " couldn't be opened."); … … 1536 1575 unset($lang_set); 1537 1576 1538 if (!empty($_GET['style']) && $auth->acl_get('a_styles') )1577 if (!empty($_GET['style']) && $auth->acl_get('a_styles') && !defined('ADMIN_START')) 1539 1578 { 1540 1579 global $SID, $_EXTRA_URL; … … 1658 1697 $this->img_lang = (file_exists($phpbb_root_path . 'styles/' . $this->theme['imageset_path'] . '/imageset/' . $this->lang_name)) ? $this->lang_name : $config['default_lang']; 1659 1698 1660 $sql = 'SELECT image_name, image_filename, image_lang, image_height, image_width 1699 // Same query in style.php 1700 $sql = 'SELECT * 1661 1701 FROM ' . STYLES_IMAGESET_DATA_TABLE . ' 1662 1702 WHERE imageset_id = ' . $this->theme['imageset_id'] . " … … 1757 1797 // Disable board if the install/ directory is still present 1758 1798 // For the brave development army we do not care about this, else we need to comment out this everytime we develop locally 1759 if (!defined('DEBUG_EXTRA') && !defined('ADMIN_START') && !defined('IN_INSTALL') && !defined('IN_LOGIN') && file_exists($phpbb_root_path . 'install') )1799 if (!defined('DEBUG_EXTRA') && !defined('ADMIN_START') && !defined('IN_INSTALL') && !defined('IN_LOGIN') && file_exists($phpbb_root_path . 'install') && !is_file($phpbb_root_path . 'install')) 1760 1800 { 1761 1801 // Adjust the message slightly according to the permissions … … 1774 1814 if ($config['board_disable'] && !defined('IN_LOGIN') && !$auth->acl_gets('a_', 'm_') && !$auth->acl_getf_global('m_')) 1775 1815 { 1776 header('HTTP/1.1 503 Service Unavailable'); 1816 if ($this->data['is_bot']) 1817 { 1818 header('HTTP/1.1 503 Service Unavailable'); 1819 } 1777 1820 1778 1821 $message = (!empty($config['board_disable_msg'])) ? $config['board_disable_msg'] : 'BOARD_DISABLE'; … … 1790 1833 if (!$auth->acl_gets('a_', 'm_') && !$auth->acl_getf_global('m_')) 1791 1834 { 1792 header('HTTP/1.1 503 Service Unavailable'); 1835 if ($this->data['is_bot']) 1836 { 1837 header('HTTP/1.1 503 Service Unavailable'); 1838 } 1793 1839 trigger_error('BOARD_UNAVAILABLE'); 1794 1840 } … … 1828 1874 // Does the user need to change their password? If so, redirect to the 1829 1875 // ucp profile reg_details page ... of course do not redirect if we're already in the ucp 1830 if (!defined('IN_ADMIN') && !defined('ADMIN_START') && $config['chg_passforce'] && $this->data['is_registered']&& $auth->acl_get('u_chgpasswd') && $this->data['user_passchg'] < time() - ($config['chg_passforce'] * 86400))1876 if (!defined('IN_ADMIN') && !defined('ADMIN_START') && $config['chg_passforce'] && !empty($this->data['is_registered']) && $auth->acl_get('u_chgpasswd') && $this->data['user_passchg'] < time() - ($config['chg_passforce'] * 86400)) 1831 1877 { 1832 1878 if (strpos($this->page['query_string'], 'mode=reg_details') === false && $this->page['page_name'] != "ucp.$phpEx") … … 2001 2047 } 2002 2048 2003 if ((@include $language_filename) === false) 2049 if (!file_exists($language_filename)) 2050 { 2051 global $config; 2052 2053 if ($this->lang_name == 'en') 2054 { 2055 // The user's selected language is missing the file, the board default's language is missing the file, and the file doesn't exist in /en. 2056 $language_filename = str_replace($this->lang_path . 'en', $this->lang_path . $this->data['user_lang'], $language_filename); 2057 trigger_error('Language file ' . $language_filename . ' couldn\'t be opened.', E_USER_ERROR); 2058 } 2059 else if ($this->lang_name == basename($config['default_lang'])) 2060 { 2061 // Fall back to the English Language 2062 $this->lang_name = 'en'; 2063 $this->set_lang($lang, $help, $lang_file, $use_db, $use_help); 2064 } 2065 else if ($this->lang_name == $this->data['user_lang']) 2066 { 2067 // Fall back to the board default language 2068 $this->lang_name = basename($config['default_lang']); 2069 $this->set_lang($lang, $help, $lang_file, $use_db, $use_help); 2070 } 2071 2072 // Reset the lang name 2073 $this->lang_name = (file_exists($this->lang_path . $this->data['user_lang'] . "/common.$phpEx")) ? $this->data['user_lang'] : basename($config['default_lang']); 2074 return; 2075 } 2076 2077 // Do not suppress error if in DEBUG_EXTRA mode 2078 $include_result = (defined('DEBUG_EXTRA')) ? (include $language_filename) : (@include $language_filename); 2079 2080 if ($include_result === false) 2004 2081 { 2005 2082 trigger_error('Language file ' . $language_filename . ' couldn\'t be opened.', E_USER_ERROR); … … 2037 2114 $date_cache[$format] = array( 2038 2115 'is_short' => strpos($format, '|'), 2039 'zone_offset' => $this->timezone + $this->dst,2040 2116 'format_short' => substr($format, 0, strpos($format, '|')) . '||' . substr(strrchr($format, '|'), 1), 2041 2117 'format_long' => str_replace('|', '', $format), … … 2050 2126 } 2051 2127 2128 // Zone offset 2129 $zone_offset = $this->timezone + $this->dst; 2130 2052 2131 // Show date <= 1 hour ago as 'xx min ago' 2053 // A small tolerence is given for times in the future and times in the futurebut in the same minute are displayed as '< than a minute ago'2132 // A small tolerence is given for times in the future but in the same minute are displayed as '< than a minute ago' 2054 2133 if ($delta <= 3600 && ($delta >= -5 || (($now / 60) % 60) == (($gmepoch / 60) % 60)) && $date_cache[$format]['is_short'] !== false && !$forcedate && isset($this->lang['datetime']['AGO'])) 2055 2134 { … … 2059 2138 if (!$midnight) 2060 2139 { 2061 list($d, $m, $y) = explode(' ', gmdate('j n Y', time() + $ date_cache[$format]['zone_offset']));2062 $midnight = gmmktime(0, 0, 0, $m, $d, $y) - $ date_cache[$format]['zone_offset'];2063 } 2064 2065 if ($date_cache[$format]['is_short'] !== false && !$forcedate )2140 list($d, $m, $y) = explode(' ', gmdate('j n Y', time() + $zone_offset)); 2141 $midnight = gmmktime(0, 0, 0, $m, $d, $y) - $zone_offset; 2142 } 2143 2144 if ($date_cache[$format]['is_short'] !== false && !$forcedate && !($gmepoch < $midnight - 86400 || $gmepoch > $midnight + 172800)) 2066 2145 { 2067 2146 $day = false; … … 2082 2161 if ($day !== false) 2083 2162 { 2084 return str_replace('||', $this->lang['datetime'][$day], strtr(@gmdate($date_cache[$format]['format_short'], $gmepoch + $ date_cache[$format]['zone_offset']), $date_cache[$format]['lang']));2085 } 2086 } 2087 2088 return strtr(@gmdate($date_cache[$format]['format_long'], $gmepoch + $ date_cache[$format]['zone_offset']), $date_cache[$format]['lang']);2163 return str_replace('||', $this->lang['datetime'][$day], strtr(@gmdate($date_cache[$format]['format_short'], $gmepoch + $zone_offset), $date_cache[$format]['lang'])); 2164 } 2165 } 2166 2167 return strtr(@gmdate($date_cache[$format]['format_long'], $gmepoch + $zone_offset), $date_cache[$format]['lang']); 2089 2168 } 2090 2169 … … 2156 2235 } 2157 2236 2158 $img_data['src'] = $phpbb_root_path . 'styles/' . $this->theme['imageset_path'] . '/imageset/' . ($this->img_array[$img]['image_lang'] ? $this->img_array[$img]['image_lang'] .'/' : '') . $this->img_array[$img]['image_filename']; 2237 // Use URL if told so 2238 $root_path = (defined('PHPBB_USE_BOARD_URL_PATH') && PHPBB_USE_BOARD_URL_PATH) ? generate_board_url() . '/' : $phpbb_root_path; 2239 2240 $img_data['src'] = $root_path . 'styles/' . rawurlencode($this->theme['imageset_path']) . '/imageset/' . ($this->img_array[$img]['image_lang'] ? $this->img_array[$img]['image_lang'] .'/' : '') . $this->img_array[$img]['image_filename']; 2159 2241 $img_data['width'] = $this->img_array[$img]['image_width']; 2160 2242 $img_data['height'] = $this->img_array[$img]['image_height']; … … 2229 2311 } 2230 2312 } 2313 2314 /** 2315 * Funtion to make the user leave the NEWLY_REGISTERED system group. 2316 * @access public 2317 */ 2318 function leave_newly_registered() 2319 { 2320 global $db; 2321 2322 if (empty($this->data['user_new'])) 2323 { 2324 return false; 2325 } 2326 2327 if (!function_exists('remove_newly_registered')) 2328 { 2329 global $phpbb_root_path, $phpEx; 2330 2331 include($phpbb_root_path . 'includes/functions_user.' . $phpEx); 2332 } 2333 if ($group = remove_newly_registered($this->data['user_id'], $this->data)) 2334 { 2335 $this->data['group_id'] = $group; 2336 2337 } 2338 $this->data['user_permissions'] = ''; 2339 $this->data['user_new'] = 0; 2340 2341 return true; 2342 } 2231 2343 } 2232 2344 -
trunk/forum/includes/template.php
r400 r702 3 3 * 4 4 * @package phpBB3 5 * @version $Id : template.php 8943 2008-09-26 13:09:56Z acydburn$5 * @version $Id$ 6 6 * @copyright (c) 2005 phpBB Group, sections (c) 2001 ispi of Lincoln Inc 7 7 * @license http://opensource.org/licenses/gpl-license.php GNU Public License … … 40 40 var $files_template = array(); 41 41 var $inherit_root = ''; 42 var $orig_tpl_storedb; 43 var $orig_tpl_inherits_id; 42 44 43 45 // this will hash handle names to the compiled/uncompiled code for that handle. … … 56 58 $this->root = $phpbb_root_path . 'styles/' . $user->theme['template_path'] . '/template'; 57 59 $this->cachepath = $phpbb_root_path . 'cache/tpl_' . str_replace('_', '-', $user->theme['template_path']) . '_'; 58 60 61 if ($this->orig_tpl_storedb === null) 62 { 63 $this->orig_tpl_storedb = $user->theme['template_storedb']; 64 } 65 66 if ($this->orig_tpl_inherits_id === null) 67 { 68 $this->orig_tpl_inherits_id = $user->theme['template_inherits_id']; 69 } 70 71 $user->theme['template_storedb'] = $this->orig_tpl_storedb; 72 $user->theme['template_inherits_id'] = $this->orig_tpl_inherits_id; 73 59 74 if ($user->theme['template_inherits_id']) 60 75 { … … 76 91 * @access public 77 92 */ 78 function set_custom_template($template_path, $template_name) 79 { 80 global $phpbb_root_path; 93 function set_custom_template($template_path, $template_name, $fallback_template_path = false) 94 { 95 global $phpbb_root_path, $user; 96 97 // Make sure $template_path has no ending slash 98 if (substr($template_path, -1) == '/') 99 { 100 $template_path = substr($template_path, 0, -1); 101 } 81 102 82 103 $this->root = $template_path; 83 104 $this->cachepath = $phpbb_root_path . 'cache/ctpl_' . str_replace('_', '-', $template_name) . '_'; 84 105 106 if ($fallback_template_path !== false) 107 { 108 if (substr($fallback_template_path, -1) == '/') 109 { 110 $fallback_template_path = substr($fallback_template_path, 0, -1); 111 } 112 113 $this->inherit_root = $fallback_template_path; 114 $this->orig_tpl_inherits_id = true; 115 } 116 else 117 { 118 $this->orig_tpl_inherits_id = false; 119 } 120 121 // the database does not store the path or name of a custom template 122 // so there is no way we can properly store custom templates there 123 $this->orig_tpl_storedb = false; 124 125 $this->_rootref = &$this->_tpldata['.'][0]; 126 85 127 return true; 86 128 } … … 106 148 $this->filename[$handle] = $filename; 107 149 $this->files[$handle] = $this->root . '/' . $filename; 108 150 109 151 if ($this->inherit_root) 110 152 { … … 112 154 } 113 155 } 114 156 115 157 return true; 116 158 } … … 123 165 { 124 166 $this->_tpldata = array('.' => array(0 => array())); 167 $this->_rootref = &$this->_tpldata['.'][0]; 125 168 } 126 169 … … 210 253 return true; 211 254 } 212 255 213 256 /** 214 257 * Load a compiled template if possible, if not, recompile it … … 219 262 global $user, $phpEx, $config; 220 263 264 if (!isset($this->filename[$handle])) 265 { 266 trigger_error("template->_tpl_load(): No file specified for handle $handle", E_USER_ERROR); 267 } 268 269 // reload these settings to have the values they had when this object was initialised 270 // using set_template or set_custom_template, they might otherwise have been overwritten 271 // by other template class instances in between. 272 $user->theme['template_storedb'] = $this->orig_tpl_storedb; 273 $user->theme['template_inherits_id'] = $this->orig_tpl_inherits_id; 274 221 275 $filename = $this->cachepath . str_replace('/', '.', $this->filename[$handle]) . '.' . $phpEx; 222 $this->files_template[$handle] = $user->theme['template_id'];223 276 $this->files_template[$handle] = (isset($user->theme['template_id'])) ? $user->theme['template_id'] : 0; 277 224 278 $recompile = false; 225 279 if (!file_exists($filename) || @filesize($filename) === 0) … … 237 291 $recompile = (@filemtime($filename) < filemtime($this->files[$handle])) ? true : false; 238 292 } 239 293 240 294 // Recompile page if the original template is newer, otherwise load the compiled version 241 295 if (!$recompile) … … 250 304 include($phpbb_root_path . 'includes/functions_template.' . $phpEx); 251 305 } 252 306 253 307 // Inheritance - we point to another template file for this one. Equality is also used for store_db 254 308 if (isset($user->theme['template_inherits_id']) && $user->theme['template_inherits_id'] && !file_exists($this->files[$handle])) … … 257 311 $this->files_template[$handle] = $user->theme['template_inherits_id']; 258 312 } 259 313 260 314 $compile = new template_compile($this); 261 315 … … 283 337 } 284 338 $ids[] = $user->theme['template_id']; 285 339 286 340 foreach ($ids as $id) 287 341 { … … 291 345 AND (template_filename = '" . $db->sql_escape($this->filename[$handle]) . "' 292 346 OR template_included " . $db->sql_like_expression($db->any_char . $this->filename[$handle] . ':' . $db->any_char) . ')'; 293 347 294 348 $result = $db->sql_query($sql); 295 349 while ($row = $db->sql_fetchrow($result)) … … 299 353 $db->sql_freeresult($result); 300 354 } 301 355 302 356 if (sizeof($rows)) 303 357 { … … 327 381 $this->files_template[$row['template_filename']] = $user->theme['template_id']; 328 382 } 329 383 330 384 if ($force_reload || $row['template_mtime'] < filemtime($file)) 331 385 { … … 469 523 unset($this->_tpldata[$blockname][($s_row_count - 1)]['S_LAST_ROW']); 470 524 } 471 525 472 526 // Add a new iteration to this block with the variable assignments we were given. 473 527 $this->_tpldata[$blockname][] = $vararray; … … 512 566 return false; 513 567 } 514 568 515 569 // Change key to zero (change first position) if false and to last position if true 516 570 if ($key === false || $key === true) … … 615 669 } 616 670 } 671 672 /** 673 * Include a php-file 674 * @access private 675 */ 676 function _php_include($filename) 677 { 678 global $phpbb_root_path; 679 680 $file = $phpbb_root_path . $filename; 681 682 if (!file_exists($file)) 683 { 684 // trigger_error cannot be used here, as the output already started 685 echo 'template->_php_include(): File ' . htmlspecialchars($file) . ' does not exist or is empty'; 686 return; 687 } 688 include($file); 689 } 617 690 } 618 691 -
trunk/forum/includes/ucp/ucp_activate.php
r400 r702 3 3 * 4 4 * @package ucp 5 * @version $Id : ucp_activate.php 9067 2008-11-21 13:21:53Z Kellanved$5 * @version $Id$ 6 6 * @copyright (c) 2005 phpBB Group 7 7 * @license http://opensource.org/licenses/gpl-license.php GNU Public License … … 57 57 } 58 58 59 // Do not allow activating by non administrators when admin activation is on 60 // Only activation type the user should be able to do is INACTIVE_REMIND 61 // or activate a new password which is not an activation state :@ 62 if (!$user_row['user_newpasswd'] && $user_row['user_inactive_reason'] != INACTIVE_REMIND && $config['require_activation'] == USER_ACTIVATION_ADMIN && !$auth->acl_get('a_user')) 63 { 64 if (!$user->data['is_registered']) 65 { 66 login_box('', $user->lang['NO_AUTH_OPERATION']); 67 } 68 trigger_error('NO_AUTH_OPERATION'); 69 } 70 59 71 $update_password = ($user_row['user_newpasswd']) ? true : false; 60 72 … … 73 85 WHERE user_id = ' . $user_row['user_id']; 74 86 $db->sql_query($sql); 87 88 add_log('user', $user_row['user_id'], 'LOG_USER_NEW_PASSWORD', $user_row['username']); 75 89 } 76 90 -
trunk/forum/includes/ucp/ucp_attachments.php
r400 r702 3 3 * 4 4 * @package ucp 5 * @version $Id : ucp_attachments.php 8479 2008-03-29 00:22:48Z naderman$5 * @version $Id$ 6 6 * @copyright (c) 2005 phpBB Group 7 7 * @license http://opensource.org/licenses/gpl-license.php GNU Public License … … 185 185 'U_SORT_DOWNLOADS' => $this->u_action . "&sk=e&sd=" . (($sort_key == 'e' && $sort_dir == 'a') ? 'd' : 'a'), 186 186 'U_SORT_POST_TIME' => $this->u_action . "&sk=f&sd=" . (($sort_key == 'f' && $sort_dir == 'a') ? 'd' : 'a'), 187 'U_SORT_TOPIC_TITLE' => $this->u_action . "&sk=g&sd=" . (($sort_key == ' f' && $sort_dir == 'a') ? 'd' : 'a'),187 'U_SORT_TOPIC_TITLE' => $this->u_action . "&sk=g&sd=" . (($sort_key == 'g' && $sort_dir == 'a') ? 'd' : 'a'), 188 188 189 189 'S_DISPLAY_MARK_ALL' => ($num_attachments) ? true : false, -
trunk/forum/includes/ucp/ucp_confirm.php
r400 r702 3 3 * 4 4 * @package VC 5 * @version $Id : ucp_confirm.php 8655 2008-06-13 19:39:01Z acydburn$6 * @copyright (c) 2005 phpBB Group5 * @version $Id$ 6 * @copyright (c) 2005 2008 phpBB Group 7 7 * @license http://opensource.org/licenses/gpl-license.php GNU Public License 8 8 * … … 38 38 global $db, $user, $phpbb_root_path, $config, $phpEx; 39 39 40 // Do we have an id? No, then just exit 41 $confirm_id = request_var('id', ''); 42 $type = request_var('type', 0); 43 44 if (!$confirm_id || !$type) 45 { 46 exit; 47 } 48 49 // Try and grab code for this id and session 50 $sql = 'SELECT code, seed 51 FROM ' . CONFIRM_TABLE . " 52 WHERE session_id = '" . $db->sql_escape($user->session_id) . "' 53 AND confirm_id = '" . $db->sql_escape($confirm_id) . "' 54 AND confirm_type = $type"; 55 $result = $db->sql_query($sql); 56 $row = $db->sql_fetchrow($result); 57 $db->sql_freeresult($result); 58 59 // If we have a row then grab data else create a new id 60 if (!$row) 61 { 62 exit; 63 } 64 65 if ($config['captcha_gd']) 66 { 67 include($phpbb_root_path . 'includes/captcha/captcha_gd.' . $phpEx); 68 } 69 else 70 { 71 include($phpbb_root_path . 'includes/captcha/captcha_non_gd.' . $phpEx); 72 } 73 74 $captcha = new captcha(); 75 $captcha->execute($row['code'], $row['seed']); 40 include($phpbb_root_path . 'includes/captcha/captcha_factory.' . $phpEx); 41 $captcha = phpbb_captcha_factory::get_instance($config['captcha_plugin']); 42 $captcha->init(request_var('type', 0)); 43 $captcha->execute(); 76 44 77 45 garbage_collection(); -
trunk/forum/includes/ucp/ucp_groups.php
r400 r702 3 3 * 4 4 * @package ucp 5 * @version $Id : ucp_groups.php 9067 2008-11-21 13:21:53Z Kellanved$5 * @version $Id$ 6 6 * @copyright (c) 2005 phpBB Group 7 7 * @license http://opensource.org/licenses/gpl-license.php GNU Public License … … 42 42 { 43 43 case 'membership': 44 44 45 45 $this->page_title = 'UCP_USERGROUPS_MEMBER'; 46 46 … … 341 341 ); 342 342 343 $group_id_ary[] = $row['group_id'];343 $group_id_ary[] = (int) $row['group_id']; 344 344 } 345 345 $db->sql_freeresult($result); … … 415 415 $action = (isset($_POST['addusers'])) ? 'addusers' : request_var('action', ''); 416 416 $group_id = request_var('g', 0); 417 417 418 418 include($phpbb_root_path . 'includes/functions_display.' . $phpEx); 419 419 … … 439 439 trigger_error($user->lang['NOT_ALLOWED_MANAGE_GROUP'] . $return_page, E_USER_WARNING); 440 440 } 441 441 442 442 $group_name = $group_row['group_name']; 443 443 $group_type = $group_row['group_type']; 444 444 445 445 $avatar_img = (!empty($group_row['group_avatar'])) ? get_user_avatar($group_row['group_avatar'], $group_row['group_avatar_type'], $group_row['group_avatar_width'], $group_row['group_avatar_height'], 'GROUP_AVATAR') : '<img src="' . $phpbb_root_path . 'adm/images/no_avatar.gif" alt="" />'; 446 446 … … 451 451 'GROUP_DESC_DISP' => generate_text_for_display($group_row['group_desc'], $group_row['group_desc_uid'], $group_row['group_desc_bitfield'], $group_row['group_desc_options']), 452 452 'GROUP_TYPE' => $group_row['group_type'], 453 453 454 454 'AVATAR' => $avatar_img, 455 455 'AVATAR_IMAGE' => $avatar_img, … … 605 605 // group. This prevents existing group members being updated if no changes 606 606 // were made. 607 607 608 608 $group_attributes = array(); 609 $test_variables = array('rank', 'colour', 'avatar', 'avatar_type', 'avatar_width', 'avatar_height', 'receive_pm', 'legend', 'message_limit', 'max_recipients'); 610 foreach ($test_variables as $test) 611 { 612 if ($action == 'add' || (isset($submit_ary[$test]) && $group_row['group_' . $test] != $submit_ary[$test])) 609 $test_variables = array( 610 'rank' => 'int', 611 'colour' => 'string', 612 'avatar' => 'string', 613 'avatar_type' => 'int', 614 'avatar_width' => 'int', 615 'avatar_height' => 'int', 616 'receive_pm' => 'int', 617 'legend' => 'int', 618 'message_limit' => 'int', 619 'max_recipients'=> 'int', 620 ); 621 622 foreach ($test_variables as $test => $type) 623 { 624 if (isset($submit_ary[$test]) && ($action == 'add' || $group_row['group_' . $test] != $submit_ary[$test])) 613 625 { 626 settype($submit_ary[$test], $type); 614 627 $group_attributes['group_' . $test] = $group_row['group_' . $test] = $submit_ary[$test]; 615 628 } … … 676 689 $display_gallery = (isset($_POST['display_gallery'])) ? true : false; 677 690 678 if ($config['allow_avatar _local'] && $display_gallery)691 if ($config['allow_avatar'] && $config['allow_avatar_local'] && $display_gallery) 679 692 { 680 693 avatar_gallery($category, $avatar_select, 4); 681 694 } 682 683 $avatars_enabled = ($c an_upload || ($config['allow_avatar_local'] || $config['allow_avatar_remote'])) ? true : false;695 696 $avatars_enabled = ($config['allow_avatar'] && (($can_upload && ($config['allow_avatar_upload'] || $config['allow_avatar_remote_upload'])) || ($config['allow_avatar_local'] || $config['allow_avatar_remote']))) ? true : false; 684 697 685 698 $template->assign_vars(array( 686 699 'S_EDIT' => true, 687 700 'S_INCLUDE_SWATCH' => true, 688 'S_CAN_UPLOAD' => $can_upload, 689 'S_FORM_ENCTYPE' => ($can_upload) ? ' enctype="multipart/form-data"' : '', 701 'S_FORM_ENCTYPE' => ($config['allow_avatar'] && $can_upload && ($config['allow_avatar_upload'] || $config['allow_avatar_remote_upload'])) ? ' enctype="multipart/form-data"' : '', 690 702 'S_ERROR' => (sizeof($error)) ? true : false, 691 703 'S_SPECIAL_GROUP' => ($group_type == GROUP_SPECIAL) ? true : false, 692 704 'S_AVATARS_ENABLED' => $avatars_enabled, 693 'S_DISPLAY_GALLERY' => ($config['allow_avatar _local'] && !$display_gallery) ? true : false,705 'S_DISPLAY_GALLERY' => ($config['allow_avatar'] && $config['allow_avatar_local'] && !$display_gallery) ? true : false, 694 706 'S_IN_GALLERY' => ($config['allow_avatar_local'] && $display_gallery) ? true : false, 707 708 'S_UPLOAD_AVATAR_FILE' => ($config['allow_avatar'] && $config['allow_avatar_upload'] && $can_upload) ? true : false, 709 'S_UPLOAD_AVATAR_URL' => ($config['allow_avatar'] && $config['allow_avatar_remote_upload'] && $can_upload) ? true : false, 710 'S_LINK_AVATAR' => ($config['allow_avatar'] && $config['allow_avatar_remote']) ? true : false, 695 711 696 712 'ERROR_MSG' => (sizeof($error)) ? implode('<br />', $error) : '', … … 698 714 'GROUP_MESSAGE_LIMIT' => (isset($group_row['group_message_limit'])) ? $group_row['group_message_limit'] : 0, 699 715 'GROUP_MAX_RECIPIENTS' => (isset($group_row['group_max_recipients'])) ? $group_row['group_max_recipients'] : 0, 700 716 701 717 'GROUP_DESC' => $group_desc_data['text'], 702 718 'S_DESC_BBCODE_CHECKED' => $group_desc_data['allow_bbcode'], … … 840 856 841 857 'U_ACTION' => $this->u_action . "&g=$group_id", 858 'S_UCP_ACTION' => $this->u_action . "&g=$group_id", 842 859 'U_FIND_USERNAME' => append_sid("{$phpbb_root_path}memberlist.$phpEx", 'mode=searchuser&form=ucp&field=usernames'), 843 860 )); … … 897 914 { 898 915 $start = 0; 899 916 900 917 do 901 918 { … … 949 966 } 950 967 968 // redirect to last screen 969 redirect($this->u_action . '&action=list&g=' . $group_id); 970 951 971 break; 952 972 … … 995 1015 } 996 1016 1017 // redirect to last screen 1018 redirect($this->u_action . '&action=list&g=' . $group_id); 1019 997 1020 break; 998 1021 … … 1028 1051 1029 1052 $default = request_var('default', 0); 1030 1053 1031 1054 if (confirm_box(true)) 1032 1055 { -
trunk/forum/includes/ucp/ucp_main.php
r400 r702 3 3 * 4 4 * @package ucp 5 * @version $Id : ucp_main.php 9136 2008-11-30 14:36:59Z acydburn$5 * @version $Id$ 6 6 * @copyright (c) 2005 phpBB Group 7 7 * @license http://opensource.org/licenses/gpl-license.php GNU Public License … … 634 634 function assign_topiclist($mode = 'subscribed', $forbidden_forum_ary = array()) 635 635 { 636 global $user, $db, $template, $config, $ auth, $phpbb_root_path, $phpEx;636 global $user, $db, $template, $config, $cache, $auth, $phpbb_root_path, $phpEx; 637 637 638 638 $table = ($mode == 'subscribed') ? TOPICS_WATCH_TABLE : BOOKMARKS_TABLE; 639 639 $start = request_var('start', 0); 640 641 // Grab icons 642 $icons = $cache->obtain_icons(); 640 643 641 644 $sql_array = array( … … 777 780 topic_status($row, $replies, $unread_topic, $folder_img, $folder_alt, $topic_type); 778 781 779 $view_topic_url = append_sid("{$phpbb_root_path}viewtopic.$phpEx", "f=$forum_id&t=$topic_id"); 782 $view_topic_url_params = "f=$forum_id&t=$topic_id"; 783 $view_topic_url = append_sid("{$phpbb_root_path}viewtopic.$phpEx", $view_topic_url_params); 780 784 781 785 // Send vars to template … … 810 814 'TOPIC_FOLDER_IMG' => $user->img($folder_img, $folder_alt), 811 815 'TOPIC_FOLDER_IMG_SRC' => $user->img($folder_img, $folder_alt, false, '', 'src'), 816 'TOPIC_FOLDER_IMG_ALT' => $user->lang[$folder_alt], 812 817 'TOPIC_ICON_IMG' => (!empty($icons[$row['icon_id']])) ? $icons[$row['icon_id']]['img'] : '', 813 818 'TOPIC_ICON_IMG_WIDTH' => (!empty($icons[$row['icon_id']])) ? $icons[$row['icon_id']]['width'] : '', … … 819 824 'S_UNREAD_TOPIC' => $unread_topic, 820 825 821 'U_NEWEST_POST' => append_sid("{$phpbb_root_path}viewtopic.$phpEx", "f=$forum_id&t=$topic_id&view=unread") . '#unread',822 'U_LAST_POST' => $view_topic_url . '&p=' . $row['topic_last_post_id']. '#p' . $row['topic_last_post_id'],826 'U_NEWEST_POST' => append_sid("{$phpbb_root_path}viewtopic.$phpEx", $view_topic_url_params . '&view=unread') . '#unread', 827 'U_LAST_POST' => append_sid("{$phpbb_root_path}viewtopic.$phpEx", $view_topic_url_params . '&p=' . $row['topic_last_post_id']) . '#p' . $row['topic_last_post_id'], 823 828 'U_VIEW_TOPIC' => $view_topic_url, 824 829 'U_VIEW_FORUM' => append_sid("{$phpbb_root_path}viewforum.$phpEx", 'f=' . $forum_id), -
trunk/forum/includes/ucp/ucp_pm.php
r400 r702 2 2 /** 3 3 * @package ucp 4 * @version $Id : ucp_pm.php 8521 2008-04-21 13:20:13Z acydburn$4 * @version $Id$ 5 5 * @copyright (c) 2005 phpBB Group 6 6 * @license http://opensource.org/licenses/gpl-license.php GNU Public License … … 120 120 if (!$auth->acl_get('u_sendpm')) 121 121 { 122 trigger_error('NO_AUTH_SEND_MESSAGE'); 122 // trigger_error('NO_AUTH_SEND_MESSAGE'); 123 $template->assign_vars(array( 124 'S_NO_AUTH_SEND_MESSAGE' => true, 125 'S_COMPOSE_PM_VIEW' => true, 126 )); 127 128 $tpl_file = 'ucp_pm_viewfolder'; 129 break; 123 130 } 124 131 -
trunk/forum/includes/ucp/ucp_pm_compose.php
r400 r702 3 3 * 4 4 * @package ucp 5 * @version $Id : ucp_pm_compose.php 9168 2008-12-03 16:48:06Z acydburn$5 * @version $Id$ 6 6 * @copyright (c) 2005 phpBB Group 7 7 * @license http://opensource.org/licenses/gpl-license.php GNU Public License … … 47 47 $lastclick = request_var('lastclick', 0); 48 48 49 // Reply to all triggered (quote/reply) 50 $reply_to_all = request_var('reply_to_all', 0); 51 49 52 // Do NOT use request_var or specialchars here 50 53 $address_list = isset($_REQUEST['address_list']) ? $_REQUEST['address_list'] : array(); … … 85 88 redirect(append_sid("{$phpbb_root_path}ucp.$phpEx", 'i=pm')); 86 89 } 90 91 // Since viewtopic.php language entries are used in several modes, 92 // we include the language file here 93 $user->add_lang('viewtopic'); 87 94 88 95 // Output PM_TO box if message composing … … 311 318 if (($action == 'reply' || $action == 'quote' || $action == 'quotepost') && !sizeof($address_list) && !$refresh && !$submit && !$preview) 312 319 { 313 if ($action == 'quotepost') 320 // Add the original author as the recipient if quoting a post or only replying and not having checked "reply to all" 321 if ($action == 'quotepost' || !$reply_to_all) 314 322 { 315 323 $address_list = array('u' => array($post['author_id'] => 'to')); … … 317 325 else 318 326 { 319 // We try to include every previously listed member from the TO Header 327 // We try to include every previously listed member from the TO Header - Reply to all 320 328 $address_list = rebuild_header(array('to' => $post['to_address'])); 321 329 … … 440 448 441 449 // If this is a quote/reply "to all"... we may increase the max_recpients to the number of original recipients 442 if (($action == 'reply' || $action == 'quote') && $max_recipients )450 if (($action == 'reply' || $action == 'quote') && $max_recipients && $reply_to_all) 443 451 { 444 452 // We try to include every previously listed member from the TO Header … … 632 640 if ($load && $drafts) 633 641 { 634 load_drafts(0, 0, $id );642 load_drafts(0, 0, $id, $action, $msg_id); 635 643 } 636 644 … … 747 755 if (!sizeof($error) && $preview) 748 756 { 749 $user->add_lang('viewtopic');750 757 $preview_message = $message_parser->format_display($enable_bbcode, $enable_urls, $enable_smilies, false); 751 758 … … 761 768 $parse_sig->bbcode_bitfield = $preview_signature_bitfield; 762 769 763 $parse_sig->format_display($ enable_bbcode, $enable_urls, $enable_smilies);770 $parse_sig->format_display($config['allow_sig_bbcode'], $config['allow_sig_links'], $config['allow_sig_smilies']); 764 771 $preview_signature = $parse_sig->message; 765 772 unset($parse_sig); … … 805 812 806 813 // Decode text for message display 807 $bbcode_uid = (($action == 'quote' || $action == 'forward') && !$preview && !$refresh && !sizeof($error)) ? $bbcode_uid : $message_parser->bbcode_uid;814 $bbcode_uid = (($action == 'quote' || $action == 'forward') && !$preview && !$refresh && (!sizeof($error) || (sizeof($error) && !$submit))) ? $bbcode_uid : $message_parser->bbcode_uid; 808 815 809 816 $message_parser->decode_message($bbcode_uid); … … 851 858 $forward_text[] = $user->lang['FWD_ORIGINAL_MESSAGE']; 852 859 $forward_text[] = sprintf($user->lang['FWD_SUBJECT'], censor_text($message_subject)); 853 $forward_text[] = sprintf($user->lang['FWD_DATE'], $user->format_date($message_time ));860 $forward_text[] = sprintf($user->lang['FWD_DATE'], $user->format_date($message_time, false, true)); 854 861 $forward_text[] = sprintf($user->lang['FWD_FROM'], $quote_username_text); 855 862 $forward_text[] = sprintf($user->lang['FWD_TO'], implode(', ', $fwd_to_field['to'])); … … 1040 1047 'SMILIES_STATUS' => ($smilies_status) ? $user->lang['SMILIES_ARE_ON'] : $user->lang['SMILIES_ARE_OFF'], 1041 1048 'URL_STATUS' => ($url_status) ? $user->lang['URL_IS_ON'] : $user->lang['URL_IS_OFF'], 1049 'MAX_FONT_SIZE' => (int) $config['max_post_font_size'], 1042 1050 'MINI_POST_IMG' => $user->img('icon_post_target', $user->lang['PM']), 1043 1051 'ERROR' => (sizeof($error)) ? implode('<br />', $error) : '', … … 1125 1133 1126 1134 // Build usernames to add 1127 $usernames = (isset($_REQUEST['username'])) ? array(request_var('username', '', true)) : array(); 1135 $usernames = request_var('username', '', true); 1136 $usernames = (empty($usernames)) ? array() : array($usernames); 1137 1128 1138 $username_list = request_var('username_list', '', true); 1129 1139 if ($username_list) … … 1139 1149 global $refresh, $submit, $preview; 1140 1150 1141 $refresh = $preview =true;1151 $refresh = true; 1142 1152 $submit = false; 1153 1154 // Preview is only true if there was also a message entered 1155 if (request_var('message', '')) 1156 { 1157 $preview = true; 1158 } 1143 1159 } 1144 1160 -
trunk/forum/includes/ucp/ucp_pm_options.php
r400 r702 3 3 * 4 4 * @package ucp 5 * @version $Id : ucp_pm_options.php 8479 2008-03-29 00:22:48Z naderman$5 * @version $Id$ 6 6 * @copyright (c) 2005 phpBB Group 7 7 * @license http://opensource.org/licenses/gpl-license.php GNU Public License … … 109 109 $db->sql_query($sql); 110 110 $msg = $user->lang['FOLDER_ADDED']; 111 } 112 else 113 { 114 $msg = $user->lang['FOLDER_NAME_EMPTY']; 111 115 } 112 116 } … … 634 638 { 635 639 global $template; 640 global $module; 641 642 $exclude = array(); 643 644 if (!$module->loaded('zebra', 'friends')) 645 { 646 $exclude[RULE_IS_FRIEND] = true; 647 } 648 649 if (!$module->loaded('zebra', 'foes')) 650 { 651 $exclude[RULE_IS_FOE] = true; 652 } 636 653 637 654 $s_rule_options = ''; … … 640 657 foreach ($check_ary as $value => $_check) 641 658 { 659 if (isset($exclude[$value])) 660 { 661 continue; 662 } 642 663 $s_rule_options .= '<option value="' . $value . '"' . (($value == $rule_option) ? ' selected="selected"' : '') . '>' . $rule_lang[$value] . '</option>'; 643 664 } -
trunk/forum/includes/ucp/ucp_pm_viewfolder.php
r400 r702 3 3 * 4 4 * @package ucp 5 * @version $Id : ucp_pm_viewfolder.php 8795 2008-08-29 11:50:01Z Kellanved$5 * @version $Id$ 6 6 * @copyright (c) 2005 phpBB Group 7 7 * @license http://opensource.org/licenses/gpl-license.php GNU Public License … … 66 66 $mark_options = array('mark_important', 'delete_marked'); 67 67 68 // Minimise edits 69 if (!$auth->acl_get('u_pm_delete') && $key = array_search('delete_marked', $mark_options)) 70 { 71 unset($mark_options[$key]); 72 } 73 68 74 $s_mark_options = ''; 69 75 foreach ($mark_options as $mark_option) … … 116 122 if ($folder_id == PRIVMSGS_OUTBOX || $folder_id == PRIVMSGS_SENTBOX) 117 123 { 118 $recipient_list = $address = array(); 119 120 foreach ($folder_info['rowset'] as $message_id => $row) 121 { 122 $address[$message_id] = rebuild_header(array('to' => $row['to_address'], 'bcc' => $row['bcc_address'])); 123 $_save = array('u', 'g'); 124 foreach ($_save as $save) 125 { 126 if (isset($address[$message_id][$save]) && sizeof($address[$message_id][$save])) 127 { 128 foreach (array_keys($address[$message_id][$save]) as $ug_id) 129 { 130 $recipient_list[$save][$ug_id] = array('name' => $user->lang['NA'], 'colour' => ''); 131 } 132 } 133 } 134 } 135 136 $_types = array('u', 'g'); 137 foreach ($_types as $ug_type) 138 { 139 if (!empty($recipient_list[$ug_type])) 140 { 141 if ($ug_type == 'u') 142 { 143 $sql = 'SELECT user_id as id, username as name, user_colour as colour 144 FROM ' . USERS_TABLE . ' 145 WHERE '; 146 } 147 else 148 { 149 $sql = 'SELECT group_id as id, group_name as name, group_colour as colour, group_type 150 FROM ' . GROUPS_TABLE . ' 151 WHERE '; 152 } 153 $sql .= $db->sql_in_set(($ug_type == 'u') ? 'user_id' : 'group_id', array_map('intval', array_keys($recipient_list[$ug_type]))); 154 155 $result = $db->sql_query($sql); 156 157 while ($row = $db->sql_fetchrow($result)) 158 { 159 if ($ug_type == 'g') 160 { 161 $row['name'] = ($row['group_type'] == GROUP_SPECIAL) ? $user->lang['G_' . $row['name']] : $row['name']; 162 } 163 164 $recipient_list[$ug_type][$row['id']] = array('name' => $row['name'], 'colour' => $row['colour']); 165 } 166 $db->sql_freeresult($result); 167 } 168 } 169 170 foreach ($address as $message_id => $adr_ary) 171 { 172 foreach ($adr_ary as $type => $id_ary) 173 { 174 foreach ($id_ary as $ug_id => $_id) 175 { 176 if ($type == 'u') 177 { 178 $address_list[$message_id][] = get_username_string('full', $ug_id, $recipient_list[$type][$ug_id]['name'], $recipient_list[$type][$ug_id]['colour']); 179 } 180 else 181 { 182 $user_colour = ($recipient_list[$type][$ug_id]['colour']) ? ' style="font-weight: bold; color:#' . $recipient_list[$type][$ug_id]['colour'] . '"' : ''; 183 $link = '<a href="' . append_sid("{$phpbb_root_path}memberlist.$phpEx", 'mode=group&g=' . $ug_id) . '"' . $user_colour . '>'; 184 $address_list[$message_id][] = $link . $recipient_list[$type][$ug_id]['name'] . (($link) ? '</a>' : ''); 185 } 186 } 187 } 188 } 189 unset($recipient_list, $address); 124 $address_list = get_recipient_strings($folder_info['rowset']); 190 125 } 191 192 $data = array();193 126 194 127 foreach ($folder_info['pm_list'] as $message_id) … … 268 201 { 269 202 // Build Recipient List if in outbox/sentbox 270 $address = array(); 203 204 $address_temp = $address = $data = array(); 205 271 206 if ($folder_id == PRIVMSGS_OUTBOX || $folder_id == PRIVMSGS_SENTBOX) 272 207 { 273 208 foreach ($folder_info['rowset'] as $message_id => $row) 274 209 { 275 $address[$message_id] = rebuild_header(array('to' => $row['to_address'], 'bcc' => $row['bcc_address'])); 210 $address_temp[$message_id] = rebuild_header(array('to' => $row['to_address'], 'bcc' => $row['bcc_address'])); 211 $address[$message_id] = array(); 276 212 } 277 213 } … … 297 233 foreach ($_types as $ug_type) 298 234 { 299 if (isset($address [$message_id][$ug_type]) && sizeof($address[$message_id][$ug_type]))235 if (isset($address_temp[$message_id][$ug_type]) && sizeof($address_temp[$message_id][$ug_type])) 300 236 { 237 if (!isset($address[$message_id][$ug_type])) 238 { 239 $address[$message_id][$ug_type] = array(); 240 } 301 241 if ($ug_type == 'u') 302 242 { … … 311 251 WHERE '; 312 252 } 313 $sql .= $db->sql_in_set(($ug_type == 'u') ? 'user_id' : 'group_id', array_map('intval', array_keys($address [$message_id][$ug_type])));253 $sql .= $db->sql_in_set(($ug_type == 'u') ? 'user_id' : 'group_id', array_map('intval', array_keys($address_temp[$message_id][$ug_type]))); 314 254 315 255 $result = $db->sql_query($sql); … … 317 257 while ($info_row = $db->sql_fetchrow($result)) 318 258 { 319 $address[$message_id][$ug_type][$address [$message_id][$ug_type][$info_row['id']]][] = $info_row['name'];320 unset($address [$message_id][$ug_type][$info_row['id']]);259 $address[$message_id][$ug_type][$address_temp[$message_id][$ug_type][$info_row['id']]][] = $info_row['name']; 260 unset($address_temp[$message_id][$ug_type][$info_row['id']]); 321 261 } 322 262 $db->sql_freeresult($result); … … 324 264 } 325 265 266 // There is the chance that all recipients of the message got deleted. To avoid creating 267 // exports without recipients, we add a bogus "undisclosed recipient". 268 if (!(isset($address[$message_id]['g']) && sizeof($address[$message_id]['g'])) && 269 !(isset($address[$message_id]['u']) && sizeof($address[$message_id]['u']))) 270 { 271 $address[$message_id]['u'] = array(); 272 $address[$message_id]['u']['to'] = array(); 273 $address[$message_id]['u']['to'][] = $user->lang['UNDISCLOSED_RECIPIENT']; 274 } 275 326 276 decode_message($message_row['message_text'], $message_row['bbcode_uid']); 327 277 328 278 $data[] = array( 329 279 'subject' => censor_text($row['message_subject']), 330 280 'sender' => $row['username'], 331 'date' => $user->format_date($row['message_time']), 281 // ISO 8601 date. For PHP4 we are able to hardcode the timezone because $user->format_date() does not set it. 282 'date' => $user->format_date($row['message_time'], (PHP_VERSION >= 5) ? 'c' : "Y-m-d\TH:i:s+00:00", true), 332 283 'to' => ($folder_id == PRIVMSGS_OUTBOX || $folder_id == PRIVMSGS_SENTBOX) ? $address[$message_id] : '', 333 284 'message' => $message_row['message_text'] … … 457 408 { 458 409 $sort_by_text = array('t' => $user->lang['POST_TIME'], 's' => $user->lang['SUBJECT']); 459 $sort_by_sql = array('t' => 'p.m sg_id', 's' => 'p.message_subject');410 $sort_by_sql = array('t' => 'p.message_time', 's' => array('p.message_subject', 'p.message_time')); 460 411 } 461 412 else 462 413 { 463 414 $sort_by_text = array('a' => $user->lang['AUTHOR'], 't' => $user->lang['POST_TIME'], 's' => $user->lang['SUBJECT']); 464 $sort_by_sql = array('a' => 'u.username_clean', 't' => 'p.msg_id', 's' => 'p.message_subject');415 $sort_by_sql = array('a' => array('u.username_clean', 'p.message_time'), 't' => 'p.message_time', 's' => array('p.message_subject', 'p.message_time')); 465 416 } 466 417 … … 503 454 'TOTAL_MESSAGES' => (($pm_count == 1) ? $user->lang['VIEW_PM_MESSAGE'] : sprintf($user->lang['VIEW_PM_MESSAGES'], $pm_count)), 504 455 505 'POST_IMG' => (!$auth->acl_get('u_sendpm')) ? $user->img('button_topic_locked', 'P M_LOCKED') : $user->img('button_pm_new', 'POST_PM'),506 507 ' L_NO_MESSAGES' => (!$auth->acl_get('u_sendpm')) ? $user->lang['POST_PM_LOCKED'] : $user->lang['NO_MESSAGES'],456 'POST_IMG' => (!$auth->acl_get('u_sendpm')) ? $user->img('button_topic_locked', 'POST_PM_LOCKED') : $user->img('button_pm_new', 'POST_NEW_PM'), 457 458 'S_NO_AUTH_SEND_MESSAGE' => !$auth->acl_get('u_sendpm'), 508 459 509 460 'S_SELECT_SORT_DIR' => $s_sort_dir, … … 512 463 'S_TOPIC_ICONS' => ($config['enable_pm_icons']) ? true : false, 513 464 514 'U_POST_NEW_TOPIC' => ($auth->acl_get('u_sendpm')) ? append_sid("{$phpbb_root_path}ucp.$phpEx", 'i=pm&mode=compose') : '', 465 'U_POST_NEW_TOPIC' => ($auth->acl_get('u_sendpm')) ? append_sid("{$phpbb_root_path}ucp.$phpEx", 'i=pm&mode=compose') : '', 515 466 'S_PM_ACTION' => append_sid("{$phpbb_root_path}ucp.$phpEx", "i=pm&mode=view&action=view_folder&f=$folder_id" . (($start !== 0) ? "&start=$start" : '')), 516 467 )); … … 532 483 533 484 // Select the sort order 534 $ sql_sort_order = $sort_by_sql[$sort_key] . ' ' . (($sort_dir == 'd') ? 'ASC' : 'DESC');485 $direction = ($sort_dir == 'd') ? 'ASC' : 'DESC'; 535 486 $sql_start = max(0, $pm_count - $sql_limit - $start); 536 487 } … … 538 489 { 539 490 // Select the sort order 540 $ sql_sort_order = $sort_by_sql[$sort_key] . ' ' . (($sort_dir == 'd') ? 'DESC' : 'ASC');491 $direction = ($sort_dir == 'd') ? 'DESC' : 'ASC'; 541 492 $sql_start = $start; 493 } 494 495 // Sql sort order 496 if (is_array($sort_by_sql[$sort_key])) 497 { 498 $sql_sort_order = implode(' ' . $direction . ', ', $sort_by_sql[$sort_key]) . ' ' . $direction; 499 } 500 else 501 { 502 $sql_sort_order = $sort_by_sql[$sort_key] . ' ' . $direction; 542 503 } 543 504 -
trunk/forum/includes/ucp/ucp_pm_viewmessage.php
r400 r702 3 3 * 4 4 * @package ucp 5 * @version $Id : ucp_pm_viewmessage.php 9174 2008-12-04 19:58:42Z toonarmy$5 * @version $Id$ 6 6 * @copyright (c) 2005 phpBB Group 7 7 * @license http://opensource.org/licenses/gpl-license.php GNU Public License … … 30 30 $folder_id = (int) $folder_id; 31 31 $author_id = (int) $message_row['author_id']; 32 $view = request_var('view', ''); 32 33 33 34 // Not able to view message, it was deleted by the sender … … 169 170 $url = append_sid("{$phpbb_root_path}ucp.$phpEx", 'i=pm'); 170 171 172 // Number of "to" recipients 173 $num_recipients = (int) preg_match_all('/:?(u|g)_([0-9]+):?/', $message_row['to_address'], $match); 174 171 175 $template->assign_vars(array( 172 176 'MESSAGE_AUTHOR_FULL' => get_username_string('full', $author_id, $user_info['username'], $user_info['user_colour'], $user_info['username']), … … 179 183 'AUTHOR_AVATAR' => (isset($user_info['avatar'])) ? $user_info['avatar'] : '', 180 184 'AUTHOR_JOINED' => $user->format_date($user_info['user_regdate']), 181 'AUTHOR_POSTS' => ( !empty($user_info['user_posts'])) ? $user_info['user_posts'] : '',185 'AUTHOR_POSTS' => (int) $user_info['user_posts'], 182 186 'AUTHOR_FROM' => (!empty($user_info['user_from'])) ? $user_info['user_from'] : '', 183 187 … … 190 194 'QUOTE_IMG' => $user->img('icon_post_quote', $user->lang['POST_QUOTE_PM']), 191 195 'REPLY_IMG' => $user->img('button_pm_reply', $user->lang['POST_REPLY_PM']), 196 'REPORT_IMG' => $user->img('icon_post_report', 'REPORT_PM'), 192 197 'EDIT_IMG' => $user->img('icon_post_edit', $user->lang['POST_EDIT_PM']), 193 198 'MINI_POST_IMG' => $user->img('icon_post_target', $user->lang['PM']), 194 199 195 'SENT_DATE' => $user->format_date($message_row['message_time']),200 'SENT_DATE' => ($view == 'print') ? $user->format_date($message_row['message_time'], false, true) : $user->format_date($message_row['message_time']), 196 201 'SUBJECT' => $message_row['message_subject'], 197 202 'MESSAGE' => $message, … … 210 215 'U_DELETE' => ($auth->acl_get('u_pm_delete')) ? "$url&mode=compose&action=delete&f=$folder_id&p=" . $message_row['msg_id'] : '', 211 216 'U_EMAIL' => $user_info['email'], 217 'U_REPORT' => ($config['allow_pm_report']) ? append_sid("{$phpbb_root_path}report.$phpEx", "pm=" . $message_row['msg_id']) : '', 212 218 'U_QUOTE' => ($auth->acl_get('u_sendpm') && $author_id != ANONYMOUS) ? "$url&mode=compose&action=quote&f=$folder_id&p=" . $message_row['msg_id'] : '', 213 219 'U_EDIT' => (($message_row['message_time'] > time() - ($config['pm_edit_time'] * 60) || !$config['pm_edit_time']) && $folder_id == PRIVMSGS_OUTBOX && $auth->acl_get('u_pm_edit')) ? "$url&mode=compose&action=edit&f=$folder_id&p=" . $message_row['msg_id'] : '', 214 220 'U_POST_REPLY_PM' => ($auth->acl_get('u_sendpm') && $author_id != ANONYMOUS) ? "$url&mode=compose&action=reply&f=$folder_id&p=" . $message_row['msg_id'] : '', 221 'U_POST_REPLY_ALL' => ($auth->acl_get('u_sendpm') && $author_id != ANONYMOUS) ? "$url&mode=compose&action=reply&f=$folder_id&reply_to_all=1&p=" . $message_row['msg_id'] : '', 215 222 'U_PREVIOUS_PM' => "$url&f=$folder_id&p=" . $message_row['msg_id'] . "&view=previous", 216 223 'U_NEXT_PM' => "$url&f=$folder_id&p=" . $message_row['msg_id'] . "&view=next", 224 225 'U_PM_ACTION' => $url . '&mode=compose&f=' . $folder_id . '&p=' . $message_row['msg_id'], 217 226 218 227 'S_HAS_ATTACHMENTS' => (sizeof($attachments)) ? true : false, … … 220 229 'S_AUTHOR_DELETED' => ($author_id == ANONYMOUS) ? true : false, 221 230 'S_SPECIAL_FOLDER' => in_array($folder_id, array(PRIVMSGS_NO_BOX, PRIVMSGS_OUTBOX)), 231 'S_PM_RECIPIENTS' => $num_recipients, 222 232 223 233 'U_PRINT_PM' => ($config['print_pm'] && $auth->acl_get('u_pm_printpm')) ? "$url&f=$folder_id&p=" . $message_row['msg_id'] . "&view=print" : '', … … 287 297 if ($row) 288 298 { 289 $user_row['online'] = (time() - $update_time < $row['online_time'] && ($row['viewonline'] )) ? true : false;299 $user_row['online'] = (time() - $update_time < $row['online_time'] && ($row['viewonline'] || $auth->acl_get('u_viewonline'))) ? true : false; 290 300 } 291 301 } -
trunk/forum/includes/ucp/ucp_prefs.php
r400 r702 3 3 * 4 4 * @package ucp 5 * @version $Id : ucp_prefs.php 8990 2008-10-09 15:41:19Z acydburn$5 * @version $Id$ 6 6 * @copyright (c) 2005 phpBB Group 7 7 * @license http://opensource.org/licenses/gpl-license.php GNU Public License … … 283 283 'S_DISABLE_CENSORS' => $data['wordcensor'], 284 284 285 'S_CHANGE_CENSORS' => ($auth->acl_get('u_chgcensors') ) ? true : false,285 'S_CHANGE_CENSORS' => ($auth->acl_get('u_chgcensors') && $config['allow_nocensors']) ? true : false, 286 286 287 287 'S_TOPIC_SORT_DAYS' => $s_limit_topic_days, -
trunk/forum/includes/ucp/ucp_profile.php
r400 r702 3 3 * 4 4 * @package ucp 5 * @version $Id : ucp_profile.php 8990 2008-10-09 15:41:19Z acydburn$5 * @version $Id$ 6 6 * @copyright (c) 2005 phpBB Group 7 7 * @license http://opensource.org/licenses/gpl-license.php GNU Public License … … 111 111 'username_clean' => ($auth->acl_get('u_chgname') && $config['allow_namechange']) ? utf8_clean_string($data['username']) : $user->data['username_clean'], 112 112 'user_email' => ($auth->acl_get('u_chgemail')) ? $data['email'] : $user->data['user_email'], 113 'user_email_hash' => ($auth->acl_get('u_chgemail')) ? crc32($data['email']) . strlen($data['email']) : $user->data['user_email_hash'],113 'user_email_hash' => ($auth->acl_get('u_chgemail')) ? phpbb_email_hash($data['email']) : $user->data['user_email_hash'], 114 114 'user_password' => ($auth->acl_get('u_chgpasswd') && $data['new_password']) ? phpbb_hash($data['new_password']) : $user->data['user_password'], 115 115 'user_passchg' => ($auth->acl_get('u_chgpasswd') && $data['new_password']) ? time() : 0, … … 134 134 $message = 'PROFILE_UPDATED'; 135 135 136 if ($ config['email_enable'] && $data['email'] != $user->data['user_email'] && $user->data['user_type'] != USER_FOUNDER && ($config['require_activation'] == USER_ACTIVATION_SELF || $config['require_activation'] == USER_ACTIVATION_ADMIN))136 if ($auth->acl_get('u_chgemail') && $config['email_enable'] && $data['email'] != $user->data['user_email'] && $user->data['user_type'] != USER_FOUNDER && ($config['require_activation'] == USER_ACTIVATION_SELF || $config['require_activation'] == USER_ACTIVATION_ADMIN)) 137 137 { 138 138 $message = ($config['require_activation'] == USER_ACTIVATION_SELF) ? 'ACCOUNT_EMAIL_CHANGED' : 'ACCOUNT_EMAIL_CHANGED_ADMIN'; … … 350 350 $data['notify'] = $user->data['user_notify_type']; 351 351 352 if ( !$config['jab_enable'] || !$data['jabber'] || !@extension_loaded('xml'))352 if ($data['notify'] == NOTIFY_IM && (!$config['jab_enable'] || !$data['jabber'] || !@extension_loaded('xml'))) 353 353 { 354 354 // User has not filled in a jabber address (Or one of the modules is disabled or jabber is disabled) 355 355 // Disable notify by Jabber now for this user. 356 $data['notify'] = NOTIFY_ BOTH;356 $data['notify'] = NOTIFY_EMAIL; 357 357 } 358 358 … … 381 381 382 382 // Update Custom Fields 383 if (sizeof($cp_data)) 384 { 385 $sql = 'UPDATE ' . PROFILE_FIELDS_DATA_TABLE . ' 386 SET ' . $db->sql_build_array('UPDATE', $cp_data) . ' 387 WHERE user_id = ' . $user->data['user_id']; 388 $db->sql_query($sql); 389 390 if (!$db->sql_affectedrows()) 391 { 392 $cp_data['user_id'] = (int) $user->data['user_id']; 393 394 $db->sql_return_on_error(true); 395 396 $sql = 'INSERT INTO ' . PROFILE_FIELDS_DATA_TABLE . ' ' . $db->sql_build_array('INSERT', $cp_data); 397 $db->sql_query($sql); 398 399 $db->sql_return_on_error(false); 400 } 401 } 383 $cp->update_profile_field_data($user->data['user_id'], $cp_data); 402 384 403 385 meta_refresh(3, $this->u_action); … … 475 457 include($phpbb_root_path . 'includes/functions_display.' . $phpEx); 476 458 477 $enable_bbcode = ($config['allow_sig_bbcode']) ? ( (request_var('disable_bbcode', !$user->optionget('bbcode'))) ? false : true) : false;478 $enable_smilies = ($config['allow_sig_smilies']) ? ( (request_var('disable_smilies', !$user->optionget('smilies'))) ? false : true) : false;479 $enable_urls = ($config['allow_sig_links']) ? ( (request_var('disable_magic_url', false)) ? false : true) : false;459 $enable_bbcode = ($config['allow_sig_bbcode']) ? (bool) $user->optionget('sig_bbcode') : false; 460 $enable_smilies = ($config['allow_sig_smilies']) ? (bool) $user->optionget('sig_smilies') : false; 461 $enable_urls = ($config['allow_sig_links']) ? (bool) $user->optionget('sig_links') : false; 480 462 481 463 $signature = utf8_normalize_nfc(request_var('signature', (string) $user->data['user_sig'], true)); … … 486 468 { 487 469 include($phpbb_root_path . 'includes/message_parser.' . $phpEx); 470 471 $enable_bbcode = ($config['allow_sig_bbcode']) ? ((request_var('disable_bbcode', false)) ? false : true) : false; 472 $enable_smilies = ($config['allow_sig_smilies']) ? ((request_var('disable_smilies', false)) ? false : true) : false; 473 $enable_urls = ($config['allow_sig_links']) ? ((request_var('disable_magic_url', false)) ? false : true) : false; 488 474 489 475 if (!sizeof($error)) … … 506 492 if (!sizeof($error) && $submit) 507 493 { 494 $user->optionset('sig_bbcode', $enable_bbcode); 495 $user->optionset('sig_smilies', $enable_smilies); 496 $user->optionset('sig_links', $enable_urls); 497 508 498 $sql_ary = array( 509 499 'user_sig' => (string) $message_parser->message, 500 'user_options' => $user->data['user_options'], 510 501 'user_sig_bbcode_uid' => (string) $message_parser->bbcode_uid, 511 502 'user_sig_bbcode_bitfield' => $message_parser->bbcode_bitfield … … 550 541 'FLASH_STATUS' => ($config['allow_sig_flash']) ? $user->lang['FLASH_IS_ON'] : $user->lang['FLASH_IS_OFF'], 551 542 'URL_STATUS' => ($config['allow_sig_links']) ? $user->lang['URL_IS_ON'] : $user->lang['URL_IS_OFF'], 543 'MAX_FONT_SIZE' => (int) $config['max_sig_font_size'], 552 544 553 545 'L_SIGNATURE_EXPLAIN' => sprintf($user->lang['SIGNATURE_EXPLAIN'], $config['max_sig_chars']), … … 573 565 $category = basename(request_var('category', '')); 574 566 575 $can_upload = ( $config['allow_avatar_upload'] &&file_exists($phpbb_root_path . $config['avatar_path']) && @is_writable($phpbb_root_path . $config['avatar_path']) && $auth->acl_get('u_chgavatar') && (@ini_get('file_uploads') || strtolower(@ini_get('file_uploads')) == 'on')) ? true : false;567 $can_upload = (file_exists($phpbb_root_path . $config['avatar_path']) && @is_writable($phpbb_root_path . $config['avatar_path']) && $auth->acl_get('u_chgavatar') && (@ini_get('file_uploads') || strtolower(@ini_get('file_uploads')) == 'on')) ? true : false; 576 568 577 569 add_form_key('ucp_avatar'); … … 596 588 } 597 589 590 if (!$config['allow_avatar'] && $user->data['user_avatar_type']) 591 { 592 $error[] = $user->lang['AVATAR_NOT_ALLOWED']; 593 } 594 else if ((($user->data['user_avatar_type'] == AVATAR_UPLOAD) && !$config['allow_avatar_upload']) || 595 (($user->data['user_avatar_type'] == AVATAR_REMOTE) && !$config['allow_avatar_remote']) || 596 (($user->data['user_avatar_type'] == AVATAR_GALLERY) && !$config['allow_avatar_local'])) 597 { 598 $error[] = $user->lang['AVATAR_TYPE_NOT_ALLOWED']; 599 } 600 598 601 $template->assign_vars(array( 599 602 'ERROR' => (sizeof($error)) ? implode('<br />', $error) : '', 600 'AVATAR' => get_user_avatar($user->data['user_avatar'], $user->data['user_avatar_type'], $user->data['user_avatar_width'], $user->data['user_avatar_height'] ),603 'AVATAR' => get_user_avatar($user->data['user_avatar'], $user->data['user_avatar_type'], $user->data['user_avatar_width'], $user->data['user_avatar_height'], 'USER_AVATAR', true), 601 604 'AVATAR_SIZE' => $config['avatar_filesize'], 602 605 603 606 'U_GALLERY' => append_sid("{$phpbb_root_path}ucp.$phpEx", 'i=profile&mode=avatar&display_gallery=1'), 604 607 605 'S_FORM_ENCTYPE' => ($can_upload ) ? ' enctype="multipart/form-data"' : '',608 'S_FORM_ENCTYPE' => ($can_upload && ($config['allow_avatar_upload'] || $config['allow_avatar_remote_upload'])) ? ' enctype="multipart/form-data"' : '', 606 609 607 610 'L_AVATAR_EXPLAIN' => sprintf($user->lang['AVATAR_EXPLAIN'], $config['avatar_max_width'], $config['avatar_max_height'], $config['avatar_filesize'] / 1024), 608 611 )); 609 612 610 if ($ display_gallery && $auth->acl_get('u_chgavatar') && $config['allow_avatar_local'])613 if ($config['allow_avatar'] && $display_gallery && $auth->acl_get('u_chgavatar') && $config['allow_avatar_local']) 611 614 { 612 615 avatar_gallery($category, $avatar_select, 4); 613 616 } 614 else 615 { 616 $avatars_enabled = ( $can_upload|| ($auth->acl_get('u_chgavatar') && ($config['allow_avatar_local'] || $config['allow_avatar_remote']))) ? true : false;617 else if ($config['allow_avatar']) 618 { 619 $avatars_enabled = (($can_upload && ($config['allow_avatar_upload'] || $config['allow_avatar_remote_upload'])) || ($auth->acl_get('u_chgavatar') && ($config['allow_avatar_local'] || $config['allow_avatar_remote']))) ? true : false; 617 620 618 621 $template->assign_vars(array( … … 621 624 622 625 'S_AVATARS_ENABLED' => $avatars_enabled, 623 'S_UPLOAD_AVATAR_FILE' => $can_upload,624 'S_UPLOAD_AVATAR_URL' => $can_upload,626 'S_UPLOAD_AVATAR_FILE' => ($can_upload && $config['allow_avatar_upload']) ? true : false, 627 'S_UPLOAD_AVATAR_URL' => ($can_upload && $config['allow_avatar_remote_upload']) ? true : false, 625 628 'S_LINK_AVATAR' => ($auth->acl_get('u_chgavatar') && $config['allow_avatar_remote']) ? true : false, 626 629 'S_DISPLAY_GALLERY' => ($auth->acl_get('u_chgavatar') && $config['allow_avatar_local']) ? true : false) -
trunk/forum/includes/ucp/ucp_register.php
r400 r702 3 3 * 4 4 * @package ucp 5 * @version $Id : ucp_register.php 8782 2008-08-23 17:20:55Z acydburn$5 * @version $Id$ 6 6 * @copyright (c) 2005 phpBB Group 7 7 * @license http://opensource.org/licenses/gpl-license.php GNU Public License … … 38 38 include($phpbb_root_path . 'includes/functions_profile_fields.' . $phpEx); 39 39 40 $confirm_id = request_var('confirm_id', '');41 40 $coppa = (isset($_REQUEST['coppa'])) ? ((!empty($_REQUEST['coppa'])) ? 1 : 0) : false; 42 41 $agreed = (!empty($_POST['agreed'])) ? 1 : 0; … … 54 53 } 55 54 56 57 55 if ($change_lang || $user_lang != $config['default_lang']) 58 56 { … … 69 67 } 70 68 71 $user->lang_name = $ lang = $use_lang;69 $user->lang_name = $user_lang = $use_lang; 72 70 $user->lang = array(); 71 $user->data['user_lang'] = $user->lang_name; 73 72 $user->add_lang(array('common', 'ucp')); 74 73 } … … 80 79 } 81 80 81 82 82 $cp = new custom_profile(); 83 83 84 84 $error = $cp_data = $cp_error = array(); 85 86 85 87 86 if (!$agreed || ($coppa === false && $config['coppa_enable']) || ($coppa && !$config['coppa_enable'])) … … 90 89 $add_coppa = ($coppa !== false) ? '&coppa=' . $coppa : ''; 91 90 92 $s_hidden_fields = ($confirm_id) ? array('confirm_id' => $confirm_id) : array(); 91 $s_hidden_fields = array( 92 'change_lang' => $change_lang, 93 ); 93 94 94 95 // If we change the language, we want to pass on some more possible parameter. … … 100 101 'email' => strtolower(request_var('email', '')), 101 102 'email_confirm' => strtolower(request_var('email_confirm', '')), 102 'confirm_code' => request_var('confirm_code', ''),103 'confirm_id' => request_var('confirm_id', ''),104 103 'lang' => $user->lang_name, 105 104 'tz' => request_var('tz', (float) $config['board_timezone']), 106 105 )); 107 } 106 107 } 108 109 // Checking amount of available languages 110 $sql = 'SELECT lang_id 111 FROM ' . LANG_TABLE; 112 $result = $db->sql_query($sql); 113 114 $lang_row = array(); 115 while ($row = $db->sql_fetchrow($result)) 116 { 117 $lang_row[] = $row; 118 } 119 $db->sql_freeresult($result); 108 120 109 121 if ($coppa === false && $config['coppa_enable']) … … 114 126 115 127 $template->assign_vars(array( 128 'S_LANG_OPTIONS' => (sizeof($lang_row) > 1) ? language_select($user_lang) : '', 116 129 'L_COPPA_NO' => sprintf($user->lang['UCP_COPPA_BEFORE'], $coppa_birthday), 117 130 'L_COPPA_YES' => sprintf($user->lang['UCP_COPPA_ON_AFTER'], $coppa_birthday), … … 128 141 { 129 142 $template->assign_vars(array( 143 'S_LANG_OPTIONS' => (sizeof($lang_row) > 1) ? language_select($user_lang) : '', 130 144 'L_TERMS_OF_USE' => sprintf($user->lang['TERMS_OF_USE_CONTENT'], $config['sitename'], generate_board_url()), 131 145 … … 137 151 ); 138 152 } 153 unset($lang_row); 139 154 140 155 $this->tpl_name = 'ucp_agreement'; 141 156 return; 142 157 } 143 158 159 160 // The CAPTCHA kicks in here. We can't help that the information gets lost on language change. 161 if ($config['enable_confirm']) 162 { 163 include($phpbb_root_path . 'includes/captcha/captcha_factory.' . $phpEx); 164 $captcha =& phpbb_captcha_factory::get_instance($config['captcha_plugin']); 165 $captcha->init(CONFIRM_REG); 166 } 144 167 145 168 // Try to manually determine the timezone and adjust the dst if the server date/time complies with the default setting +/- 1 … … 168 191 'email' => strtolower(request_var('email', '')), 169 192 'email_confirm' => strtolower(request_var('email_confirm', '')), 170 'confirm_code' => request_var('confirm_code', ''),171 193 'lang' => basename(request_var('lang', $user->lang_name)), 172 194 'tz' => request_var('tz', (float) $timezone), … … 188 210 array('email')), 189 211 'email_confirm' => array('string', false, 6, 60), 190 'confirm_code' => array('string', !$config['enable_confirm'], 5, 8),191 212 'tz' => array('num', false, -14, 14), 192 213 'lang' => array('match', false, '#^[a-z_\-]{2,}$#i'), 193 214 )); 215 194 216 if (!check_form_key('ucp_register')) 195 217 { 196 218 $error[] = $user->lang['FORM_INVALID']; 197 219 } 220 198 221 // Replace "error" strings with their real, localised form 199 222 $error = preg_replace('#^([A-Z_]+)$#e', "(!empty(\$user->lang['\\1'])) ? \$user->lang['\\1'] : '\\1'", $error); 200 223 224 if ($config['enable_confirm']) 225 { 226 $vc_response = $captcha->validate($data); 227 if ($vc_response !== false) 228 { 229 $error[] = $vc_response; 230 } 231 232 if ($config['max_reg_attempts'] && $captcha->get_attempt_count() > $config['max_reg_attempts']) 233 { 234 $error[] = $user->lang['TOO_MANY_REGISTERS']; 235 } 236 } 237 201 238 // DNSBL check 202 239 if ($config['check_dnsbl']) … … 210 247 // validate custom profile fields 211 248 $cp->submit_cp_field('register', $user->get_iso_lang_id(), $cp_data, $error); 212 213 // Visual Confirmation handling214 $wrong_confirm = false;215 if ($config['enable_confirm'])216 {217 if (!$confirm_id)218 {219 $error[] = $user->lang['CONFIRM_CODE_WRONG'];220 $wrong_confirm = true;221 }222 else223 {224 $sql = 'SELECT code225 FROM ' . CONFIRM_TABLE . "226 WHERE confirm_id = '" . $db->sql_escape($confirm_id) . "'227 AND session_id = '" . $db->sql_escape($user->session_id) . "'228 AND confirm_type = " . CONFIRM_REG;229 $result = $db->sql_query($sql);230 $row = $db->sql_fetchrow($result);231 $db->sql_freeresult($result);232 233 if ($row)234 {235 if (strcasecmp($row['code'], $data['confirm_code']) === 0)236 {237 $sql = 'DELETE FROM ' . CONFIRM_TABLE . "238 WHERE confirm_id = '" . $db->sql_escape($confirm_id) . "'239 AND session_id = '" . $db->sql_escape($user->session_id) . "'240 AND confirm_type = " . CONFIRM_REG;241 $db->sql_query($sql);242 }243 else244 {245 $error[] = $user->lang['CONFIRM_CODE_WRONG'];246 $wrong_confirm = true;247 }248 }249 else250 {251 $error[] = $user->lang['CONFIRM_CODE_WRONG'];252 $wrong_confirm = true;253 }254 }255 }256 249 257 250 if (!sizeof($error)) … … 327 320 ); 328 321 322 if ($config['new_member_post_limit']) 323 { 324 $user_row['user_new'] = 1; 325 } 326 329 327 // Register user... 330 328 $user_id = user_add($user_row, $cp_data); … … 334 332 { 335 333 trigger_error('NO_USER', E_USER_ERROR); 334 } 335 336 // Okay, captcha, your job is done. 337 if ($config['enable_confirm'] && isset($captcha)) 338 { 339 $captcha->reset(); 336 340 } 337 341 … … 441 445 $s_hidden_fields['coppa'] = $coppa; 442 446 } 447 448 if ($config['enable_confirm']) 449 { 450 $s_hidden_fields = array_merge($s_hidden_fields, $captcha->get_hidden_fields()); 451 } 443 452 $s_hidden_fields = build_hidden_fields($s_hidden_fields); 444 445 453 $confirm_image = ''; 446 454 447 455 // Visual Confirmation - Show images 448 449 456 if ($config['enable_confirm']) 450 457 { 451 if ($change_lang) 452 { 453 $str = '&change_lang=' . $change_lang; 454 $sql = 'SELECT code 455 FROM ' . CONFIRM_TABLE . " 456 WHERE confirm_id = '" . $db->sql_escape($confirm_id) . "' 457 AND session_id = '" . $db->sql_escape($user->session_id) . "' 458 AND confirm_type = " . CONFIRM_REG; 459 $result = $db->sql_query($sql); 460 if (!$row = $db->sql_fetchrow($result)) 461 { 462 $confirm_id = ''; 463 } 464 $db->sql_freeresult($result); 465 } 466 else 467 { 468 $str = ''; 469 } 470 if (!$change_lang || !$confirm_id) 471 { 472 $user->confirm_gc(CONFIRM_REG); 473 474 $sql = 'SELECT COUNT(session_id) AS attempts 475 FROM ' . CONFIRM_TABLE . " 476 WHERE session_id = '" . $db->sql_escape($user->session_id) . "' 477 AND confirm_type = " . CONFIRM_REG; 478 $result = $db->sql_query($sql); 479 $attempts = (int) $db->sql_fetchfield('attempts'); 480 $db->sql_freeresult($result); 481 482 if ($config['max_reg_attempts'] && $attempts > $config['max_reg_attempts']) 483 { 484 trigger_error('TOO_MANY_REGISTERS'); 485 } 486 487 $code = gen_rand_string(mt_rand(5, 8)); 488 $confirm_id = md5(unique_id($user->ip)); 489 $seed = hexdec(substr(unique_id(), 4, 10)); 490 491 // compute $seed % 0x7fffffff 492 $seed -= 0x7fffffff * floor($seed / 0x7fffffff); 493 494 $sql = 'INSERT INTO ' . CONFIRM_TABLE . ' ' . $db->sql_build_array('INSERT', array( 495 'confirm_id' => (string) $confirm_id, 496 'session_id' => (string) $user->session_id, 497 'confirm_type' => (int) CONFIRM_REG, 498 'code' => (string) $code, 499 'seed' => (int) $seed) 500 ); 501 $db->sql_query($sql); 502 } 503 $confirm_image = '<img src="' . append_sid("{$phpbb_root_path}ucp.$phpEx", 'mode=confirm&id=' . $confirm_id . '&type=' . CONFIRM_REG . $str) . '" alt="" title="" />'; 504 $s_hidden_fields .= '<input type="hidden" name="confirm_id" value="' . $confirm_id . '" />'; 458 $template->assign_vars(array( 459 'CAPTCHA_TEMPLATE' => $captcha->get_template(), 460 )); 505 461 } 506 462 … … 525 481 'EMAIL' => $data['email'], 526 482 'EMAIL_CONFIRM' => $data['email_confirm'], 527 'CONFIRM_IMG' => $confirm_image, 528 529 'L_CONFIRM_EXPLAIN' => sprintf($user->lang['CONFIRM_EXPLAIN'], '<a href="mailto:' . htmlspecialchars($config['board_contact']) . '">', '</a>'), 483 530 484 'L_REG_COND' => $l_reg_cond, 531 485 'L_USERNAME_EXPLAIN' => sprintf($user->lang[$config['allow_name_chars'] . '_EXPLAIN'], $config['min_name_chars'], $config['max_name_chars']), … … 534 488 'S_LANG_OPTIONS' => language_select($data['lang']), 535 489 'S_TZ_OPTIONS' => tz_select($data['tz']), 536 'S_CONFIRM_CODE' => ($config['enable_confirm']) ? true : false, 490 'S_CONFIRM_REFRESH' => ($config['enable_confirm'] && $config['confirm_refresh']) ? true : false, 491 'S_REGISTRATION' => true, 537 492 'S_COPPA' => $coppa, 538 493 'S_HIDDEN_FIELDS' => $s_hidden_fields, 539 494 'S_UCP_ACTION' => append_sid("{$phpbb_root_path}ucp.$phpEx", 'mode=register'), 540 ) 541 ); 495 )); 542 496 543 497 // -
trunk/forum/includes/ucp/ucp_remind.php
r400 r702 3 3 * 4 4 * @package ucp 5 * @version $Id : ucp_remind.php 8977 2008-10-06 14:04:33Z acydburn$5 * @version $Id$ 6 6 * @copyright (c) 2005 phpBB Group 7 7 * @license http://opensource.org/licenses/gpl-license.php GNU Public License … … 39 39 $sql = 'SELECT user_id, username, user_permissions, user_email, user_jabber, user_notify_type, user_type, user_lang, user_inactive_reason 40 40 FROM ' . USERS_TABLE . " 41 WHERE user_email = '" . $db->sql_escape($email) . "'41 WHERE user_email_hash = '" . $db->sql_escape(phpbb_email_hash($email)) . "' 42 42 AND username_clean = '" . $db->sql_escape(utf8_clean_string($username)) . "'"; 43 43 $result = $db->sql_query($sql); -
trunk/forum/includes/ucp/ucp_resend.php
r400 r702 3 3 * 4 4 * @package ucp 5 * @version $Id : ucp_resend.php 8479 2008-03-29 00:22:48Z naderman$5 * @version $Id$ 6 6 * @copyright (c) 2005 phpBB Group 7 7 * @license http://opensource.org/licenses/gpl-license.php GNU Public License … … 46 46 $sql = 'SELECT user_id, group_id, username, user_email, user_type, user_lang, user_actkey, user_inactive_reason 47 47 FROM ' . USERS_TABLE . " 48 WHERE user_email = '" . $db->sql_escape($email) . "'48 WHERE user_email_hash = '" . $db->sql_escape(phpbb_email_hash($email)) . "' 49 49 AND username_clean = '" . $db->sql_escape(utf8_clean_string($username)) . "'"; 50 50 $result = $db->sql_query($sql); … … 134 134 $messenger->im($row['user_jabber'], $row['username']); 135 135 136 $messenger->headers('X-AntiAbuse: Board servername - ' . $config['server_name']); 137 $messenger->headers('X-AntiAbuse: User_id - ' . $user->data['user_id']); 138 $messenger->headers('X-AntiAbuse: Username - ' . $user->data['username']); 139 $messenger->headers('X-AntiAbuse: User IP - ' . $user->ip); 140 136 141 $messenger->assign_vars(array( 137 142 'USERNAME' => htmlspecialchars_decode($user_row['username']), … … 147 152 meta_refresh(3, append_sid("{$phpbb_root_path}index.$phpEx")); 148 153 149 $message = ($config['require_activation'] == USER_ACTIVATION_ADMIN) ? $user->lang['AC IVATION_EMAIL_SENT_ADMIN'] : $user->lang['ACTIVATION_EMAIL_SENT'];154 $message = ($config['require_activation'] == USER_ACTIVATION_ADMIN) ? $user->lang['ACTIVATION_EMAIL_SENT_ADMIN'] : $user->lang['ACTIVATION_EMAIL_SENT']; 150 155 $message .= '<br /><br />' . sprintf($user->lang['RETURN_INDEX'], '<a href="' . append_sid("{$phpbb_root_path}index.$phpEx") . '">', '</a>'); 151 156 trigger_error($message); -
trunk/forum/includes/ucp/ucp_zebra.php
r400 r702 3 3 * 4 4 * @package ucp 5 * @version $Id : ucp_zebra.php 8479 2008-03-29 00:22:48Z naderman$5 * @version $Id$ 6 6 * @copyright (c) 2005 phpBB Group 7 7 * @license http://opensource.org/licenses/gpl-license.php GNU Public License … … 53 53 if (confirm_box(true)) 54 54 { 55 // Remove users 56 if (!empty($data['usernames'])) 57 { 58 $sql = 'DELETE FROM ' . ZEBRA_TABLE . ' 59 WHERE user_id = ' . $user->data['user_id'] . ' 60 AND ' . $db->sql_in_set('zebra_id', $data['usernames']); 61 $db->sql_query($sql); 62 63 $updated = true; 64 } 65 66 // Add users 55 67 if ($data['add']) 56 68 { … … 125 137 $user_id_ary[] = $row['user_id']; 126 138 } 139 else if ($row['user_id'] != ANONYMOUS) 140 { 141 $error[] = $user->lang['NOT_ADDED_' . $l_mode . '_BOTS']; 142 } 127 143 else 128 144 { … … 183 199 } 184 200 } 185 }186 else if (sizeof($data['usernames']))187 {188 // Force integer values189 $data['usernames'] = array_map('intval', $data['usernames']);190 191 $sql = 'DELETE FROM ' . ZEBRA_TABLE . '192 WHERE user_id = ' . $user->data['user_id'] . '193 AND ' . $db->sql_in_set('zebra_id', $data['usernames']);194 $db->sql_query($sql);195 196 $updated = true;197 201 } 198 202 -
trunk/forum/includes/utf/utf_tools.php
r400 r702 3 3 * 4 4 * @package utf 5 * @version $Id : utf_tools.php 8510 2008-04-20 05:16:42Z davidmj$5 * @version $Id$ 6 6 * @copyright (c) 2006 phpBB Group 7 7 * @license http://opensource.org/licenses/gpl-license.php GNU Public License … … 71 71 $len = strlen($str); 72 72 $ret = ''; 73 73 74 74 while ($pos < $len) 75 75 { … … 253 253 { 254 254 $ar = explode($needle, $str); 255 255 256 256 if (sizeof($ar) > 1) 257 257 { … … 528 528 } 529 529 else 530 { 530 { 531 531 // offset == 0; just anchor the pattern 532 532 $op = '^'; … … 561 561 $lx = (int) ($length / 65535); 562 562 $ly = $length % 65535; 563 563 564 564 // negative length requires a captured group 565 565 // of length characters … … 633 633 return array($str); 634 634 } 635 635 636 636 preg_match_all('/.{' . $split_len . '}|[^\x00]{1,' . $split_len . '}$/us', $str, $ar); 637 637 return $ar[0]; … … 1918 1918 } 1919 1919 1920 /** 1921 * UTF8-safe basename() function 1922 * 1923 * basename() has some limitations and is dependent on the locale setting 1924 * according to the PHP manual. Therefore we provide our own locale independant 1925 * basename function. 1926 * 1927 * @param string $filename The filename basename() should be applied to 1928 * @return string The basenamed filename 1929 */ 1930 function utf8_basename($filename) 1931 { 1932 // We always check for forward slash AND backward slash 1933 // because they could be mixed or "sneaked" in. ;) 1934 // You know, never trust user input... 1935 if (strpos($filename, '/') !== false) 1936 { 1937 $filename = utf8_substr($filename, utf8_strrpos($filename, '/') + 1); 1938 } 1939 1940 if (strpos($filename, '\\') !== false) 1941 { 1942 $filename = utf8_substr($filename, utf8_strrpos($filename, '\\') + 1); 1943 } 1944 1945 return $filename; 1946 } 1947 1948 /** 1949 * UTF8-safe str_replace() function 1950 * 1951 * @param string $search The value to search for 1952 * @param string $replace The replacement string 1953 * @param string $subject The target string 1954 * @return string The resultant string 1955 */ 1956 function utf8_str_replace($search, $replace, $subject) 1957 { 1958 if (!is_array($search)) 1959 { 1960 $search = array($search); 1961 if (is_array($replace)) 1962 { 1963 $replace = (string) $replace; 1964 trigger_error('Array to string conversion', E_USER_NOTICE); 1965 } 1966 } 1967 1968 $length = sizeof($search); 1969 1970 if (!is_array($replace)) 1971 { 1972 $replace = array_fill(0, $length, $replace); 1973 } 1974 else 1975 { 1976 $replace = array_pad($replace, $length, ''); 1977 } 1978 1979 for ($i = 0; $i < $length; $i++) 1980 { 1981 $search_length = utf8_strlen($search[$i]); 1982 $replace_length = utf8_strlen($replace[$i]); 1983 1984 $offset = 0; 1985 while (($start = utf8_strpos($subject, $search[$i], $offset)) !== false) 1986 { 1987 $subject = utf8_substr($subject, 0, $start) . $replace[$i] . utf8_substr($subject, $start + $search_length); 1988 $offset = $start + $replace_length; 1989 } 1990 } 1991 1992 return $subject; 1993 } 1994 1920 1995 ?>
Note:
See TracChangeset
for help on using the changeset viewer.