- Timestamp:
- May 1, 2015 1:15:16 AM (9 years ago)
- Location:
- trunk/lib
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/lib/App.inc.php
r505 r518 61 61 protected $_carry_queries = array(); 62 62 63 // Array of raised message counters. 64 protected $_raised_msg_counter = array(MSG_NOTICE => 0, MSG_SUCCESS => 0, MSG_WARNING => 0, MSG_ERR => 0); 65 63 66 // Dictionary of global application parameters. 64 67 protected $_params = array(); … … 514 517 if (!in_array($type, array(MSG_NOTICE, MSG_SUCCESS, MSG_WARNING, MSG_ERR))) { 515 518 $this->logMsg(sprintf('Invalid MSG_* type: %s', $type), LOG_NOTICE, __FILE__, __LINE__); 519 } 520 521 // Increment the counter for this message type. 522 $this->_raised_msg_counter[$type] += 1; 523 } 524 525 /* 526 * Returns the number of raised message (all, or by type) for the current script execution (this number may not match the total number of messages stored in session for multiple script executions) 527 * 528 * @access public 529 * @param 530 * @return 531 * @author Quinn Comendant <quinn@strangecode.com> 532 * @version 1.0 533 * @since 30 Apr 2015 17:13:03 534 */ 535 public function getRaisedMessageCount($type='all') 536 { 537 if ('all' == $type) { 538 return array_sum($this->_raised_msg_counter); 539 } else if (isset($this->_raised_msg_counter[$type])) { 540 return $this->_raised_msg_counter[$type]; 541 } else { 542 $this->logMsg(sprintf('Cannot return count of unknown raised message type: %s', $type), LOG_WARNING, __FILE__, __LINE__); 543 return false; 516 544 } 517 545 } -
trunk/lib/Upload.inc.php
r502 r518 304 304 305 305 // Clean the file name of bad characters. 306 $file_name = $this->cleanFileName($file_name);306 $file_name = cleanFileName($file_name); 307 307 308 308 // FINAL path and file name, lowercase extension. … … 475 475 476 476 /** 477 * Removes non-latin characters from file name, using htmlentities to convert known weirdos into regular squares.478 *479 * @access public480 * @param string $file_name A name of a file.481 * @return string The same name, but cleaned.482 */483 public function cleanFileName($file_name)484 {485 $file_name = preg_replace(array(486 '/&([a-z]{1,2})(?:acute|cedil|circ|grave|lig|orn|ring|slash|th|tilde|uml|caron);/ui',487 '/&(?:amp);/ui',488 '/[&;]+/u',489 '/[^a-zA-Z0-9()@._=+-]+/u',490 '/^_+|_+$/u'491 ), array(492 '$1',493 'and',494 '',495 '_',496 ''497 ), htmlentities($file_name, ENT_NOQUOTES | ENT_IGNORE, 'UTF-8'));498 return mb_substr($file_name, 0, 250);499 }500 501 502 /**503 477 * Returns the extension of a file name, or an empty string if non exists. 504 478 * -
trunk/lib/Utilities.inc.php
r507 r518 82 82 if (!empty($var)) { 83 83 ?> 84 <script type="text/javascript" charset="utf-8">84 <script type="text/javascript"> 85 85 /* <![CDATA[ */ 86 window.console &&console.log('<?php printf('%s: %s (on line %s of %s)', $prefix, str_replace("'", "\\'", getDump($var, true)), $line, $file); ?>');86 console.log('<?php printf('%s: %s (on line %s of %s)', $prefix, str_replace("'", "\\'", getDump($var, true)), $line, $file); ?>'); 87 87 /* ]]> */ 88 88 </script> … … 536 536 } 537 537 538 /** 539 * Removes non-latin characters from file name, using htmlentities to convert known weirdos into regular squares. 540 * 541 * @access public 542 * @param string $file_name A name of a file. 543 * @return string The same name, but cleaned. 544 */ 545 function cleanFileName($file_name) 546 { 547 $app =& App::getInstance(); 548 549 $file_name = preg_replace(array( 550 '/&([a-z]{1,2})(?:acute|cedil|circ|grave|lig|orn|ring|slash|th|tilde|uml|caron);/ui', 551 '/&(?:amp);/ui', 552 '/[&;]+/u', 553 '/[^a-zA-Z0-9()@._=+-]+/u', 554 '/^_+|_+$/u' 555 ), array( 556 '$1', 557 'and', 558 '', 559 '_', 560 '' 561 ), htmlentities($file_name, ENT_NOQUOTES | ENT_IGNORE, $app->getParam('character_set'))); 562 return mb_substr($file_name, 0, 250); 563 } 564 538 565 /* 539 566 * Convert a php.ini value (8M, 512K, etc), into integer value of bytes.
Note: See TracChangeset
for help on using the changeset viewer.