Changeset 452
- Timestamp:
- Dec 25, 2013 12:47:12 AM (10 years ago)
- Location:
- trunk/lib
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/lib/App.inc.php
r441 r452 4 4 * For details visit the project site: <http://trac.strangecode.com/codebase/> 5 5 * Copyright 2001-2012 Strangecode, LLC 6 * 6 * 7 7 * This file is part of The Strangecode Codebase. 8 8 * … … 11 11 * Free Software Foundation, either version 3 of the License, or (at your option) 12 12 * any later version. 13 * 13 * 14 14 * The Strangecode Codebase is distributed in the hope that it will be useful, but 15 15 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 16 16 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more 17 17 * details. 18 * 18 * 19 19 * You should have received a copy of the GNU General Public License along with 20 20 * The Strangecode Codebase. If not, see <http://www.gnu.org/licenses/>. … … 86 86 'session_name' => '_session', 87 87 'session_use_cookies' => true, 88 88 89 89 // Pass the session-id through URLs if cookies are not enabled? 90 90 // Disable this to prevent session ID theft. … … 190 190 // Initialize default parameters. 191 191 $this->_params = array_merge($this->_params, $this->_param_defaults); 192 192 193 193 // Begin timing script. 194 194 require_once dirname(__FILE__) . '/ScriptTimer.inc.php'; … … 362 362 $this->setParam(array('site_url' => sprintf('%s://%s', ('on' == getenv('HTTPS') ? 'https' : 'http'), getenv('HTTP_HOST')))); 363 363 } 364 364 365 365 // In case site_email isn't set, use something halfway presentable. 366 366 if (isset($_SERVER['HTTP_HOST']) && '' != $_SERVER['HTTP_HOST'] && '' == $this->getParam('site_email')) { … … 375 375 // Character set. This should also be printed in the html header template. 376 376 header('Content-type: text/html; charset=' . $this->getParam('character_set')); 377 377 378 378 // Set the version of the codebase we're using. 379 379 $codebase_version_file = dirname(__FILE__) . '/../docs/version.txt'; … … 404 404 $this->db->close(); 405 405 } 406 $mem_current = memory_get_usage(); 407 $mem_peak = memory_get_peak_usage(); 406 408 $this->timer->stop('_app'); 407 $this->logMsg(sprintf('Script ended gracefully. Execution time: %s. Number of db queries: %s. ', $this->timer->getTime('_app'), $num_queries), LOG_DEBUG, __FILE__, __LINE__);409 $this->logMsg(sprintf('Script ended gracefully. Execution time: %s. Number of db queries: %s. Memory usage: %s. Peak memory: %s.', $this->timer->getTime('_app'), $num_queries, $mem_current, $mem_peak), LOG_DEBUG, __FILE__, __LINE__); 408 410 } 409 411 … … 434 436 return false; 435 437 } 436 438 437 439 // Avoid duplicate full-stops.. 438 440 $message = trim(preg_replace('/\.{2}$/', '.', $message)); … … 454 456 } 455 457 } 456 458 457 459 /** 458 460 * Returns an array of the raised messages. … … 472 474 return isset($_SESSION['_app'][$this->_ns]['messages']) ? $_SESSION['_app'][$this->_ns]['messages'] : array(); 473 475 } 474 476 475 477 /** 476 478 * Resets the message list. … … 486 488 return false; 487 489 } 488 490 489 491 $_SESSION['_app'][$this->_ns]['messages'] = array(); 490 492 } … … 507 509 return false; 508 510 } 509 511 510 512 $messages = $this->getRaisedMessages(); 511 513 if (!empty($messages)) { … … 590 592 trigger_error(sprintf('Codebase error: log directory (%s) not found or writable.', $this->getParam('log_directory')), E_USER_NOTICE); 591 593 } 592 594 593 595 // Before we get any further, let's see if ANY log events are configured to be reported. 594 596 if ((false === $this->getParam('log_file_priority') || $priority > $this->getParam('log_file_priority')) … … 626 628 $site_hash = md5(empty($_SERVER['SERVER_NAME']) ? $_SERVER['SCRIPT_FILENAME'] : $_SERVER['SERVER_NAME']); 627 629 $lock_dir = $this->getParam('tmp_dir') . "/codebase_msgs_$site_hash/"; 628 // Just use the file and line for the msg_id to limit the number of possible messages 630 // Just use the file and line for the msg_id to limit the number of possible messages 629 631 // (the message string itself shan't be used as it may contain innumerable combinations). 630 632 $lock_file = $lock_dir . md5($file . ':' . $line); … … 647 649 } 648 650 } 649 651 650 652 // Data to be stored for a log event. 651 653 $event = array( … … 685 687 mb_send_mail($this->getParam('log_to_sms_address'), $subject, $sms_msg, $headers); 686 688 } 687 689 688 690 // SCREEN ACTION 689 691 if (false !== $this->getParam('log_screen_priority') && $priority <= $this->getParam('log_screen_priority')) { … … 693 695 // Restore original locale. 694 696 setlocale(LC_TIME, $locale); 695 697 696 698 return true; 697 699 } … … 771 773 772 774 /** 773 * dropQuery() is the opposite of carryQuery(). The specified value will not appear in 775 * dropQuery() is the opposite of carryQuery(). The specified value will not appear in 774 776 * url()/ohref()/printHiddenSession() modified URLs unless explicitly written in. 775 * 777 * 776 778 * @access public 777 779 * @param mixed $query_key The key (or keys, as an array) of the query argument to remove. -
trunk/lib/Image.inc.php
r396 r452 4 4 * For details visit the project site: <http://trac.strangecode.com/codebase/> 5 5 * Copyright 2001-2012 Strangecode, LLC 6 * 6 * 7 7 * This file is part of The Strangecode Codebase. 8 8 * … … 11 11 * Free Software Foundation, either version 3 of the License, or (at your option) 12 12 * any later version. 13 * 13 * 14 14 * The Strangecode Codebase is distributed in the hope that it will be useful, but 15 15 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 16 16 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more 17 17 * details. 18 * 18 * 19 19 * You should have received a copy of the GNU General Public License along with 20 20 * The Strangecode Codebase. If not, see <http://www.gnu.org/licenses/>. … … 49 49 // Pattern passed to glob() with $id to match image filenames. 50 50 'filename_pattern' => '%s*', 51 51 52 52 // The path to the image source directory. (Ex: /var/www/htdocs/images) 53 53 'base_path' => '', 54 54 55 55 // The URL to the image directory. (Ex: /images) 56 56 'base_url' => '', 57 57 58 58 // Image to use in the case of a missing image. 59 59 'default_image_file' => '', … … 61 61 $this->_params = array_merge($defaults, $params); 62 62 } 63 63 64 64 /** 65 65 * Tests if an image with specified id exists on the file system. … … 77 77 $filepath = preg_match('!://!', $src) ? $src : getenv('DOCUMENT_ROOT') . $src; 78 78 // Use exif_imagetype to check not only file existence but that of a valid image. 79 // The return value is the same value that getimagesize() returns in index 2 but exif_imagetype() is much faster. 79 80 return false != @exif_imagetype($filepath); 80 81 } 81 82 82 83 /** 83 84 * Returns the value from getimagesize(). … … 85 86 * @access public 86 87 * @param string $id Unique image identifier. 87 * @param int $key Which element from the array returned by getimagesize: 88 * - Index 0 contains the width of the image in pixels. 89 * - Index 1 contains the height. 90 * - Index 2 is the type of the image. 88 * @param int $key Which element from the array returned by getimagesize: 89 * - Index 0 contains the width of the image in pixels. 90 * - Index 1 contains the height. 91 * - Index 2 is the type of the image. 91 92 * - Index 3 is height="yyy" width="xxx" string. 92 93 * @return mixed return value of getimagesize. … … 102 103 return isset($img_size[$key]) ? $img_size[$key] : false; 103 104 } 104 105 105 106 /** 106 107 * Returns the URL to the source of image specified by id. … … 126 127 127 128 /** 128 * Returns an HTML <img> tag with the src set to an image specified by id. 129 * Returns an HTML <img> tag with the src set to an image specified by id. 129 130 * Automatically prints image width and height. 130 131 * … … 142 143 $src = $this->oSrc($id); 143 144 $filepath = preg_match('!://!', $src) ? $src : getenv('DOCUMENT_ROOT') . $src; 144 145 145 146 if (false === ($gis = @getimagesize($filepath)) || preg_match('/width|height/', $extra)) { 146 147 $image_size = ''; … … 148 149 $image_size = $gis[3]; 149 150 } 150 151 151 152 return sprintf('<img src="%s" %s alt="%s" %s />', 152 153 $src, -
trunk/lib/SortOrder.inc.php
-
Property
svn:mergeinfo
set to
/branches/eli_branch/lib/SortOrder.inc.php merged eligible
r396 r452 4 4 * For details visit the project site: <http://trac.strangecode.com/codebase/> 5 5 * Copyright 2001-2012 Strangecode, LLC 6 * 6 * 7 7 * This file is part of The Strangecode Codebase. 8 8 * … … 11 11 * Free Software Foundation, either version 3 of the License, or (at your option) 12 12 * any later version. 13 * 13 * 14 14 * The Strangecode Codebase is distributed in the hope that it will be useful, but 15 15 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 16 16 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more 17 17 * details. 18 * 18 * 19 19 * You should have received a copy of the GNU General Public License along with 20 20 * The Strangecode Codebase. If not, see <http://www.gnu.org/licenses/>. … … 24 24 * SortOrder.inc.php 25 25 * 26 * SortOrder can determin ghow to sort results of a database query for display26 * SortOrder can determine how to sort results of a database query for display 27 27 * on a listing. It can print column headers that will be links to 28 28 * automatically change the sort and order. … … 56 56 { 57 57 $app =& App::getInstance(); 58 58 59 59 // Setup the HTML for printing ASC/DESC paths. 60 60 // This should be converted to CSS someday. … … 62 62 $this->asc_widget = sprintf('<img src="%s/sort_ascending.gif" alt="%s" width="11" height="7" border="0" />', $images_path, _("Ascending")); 63 63 $this->desc_widget = sprintf('<img src="%s/sort_descending.gif" alt="%s" width="11" height="7" border="0" />', $images_path, _("Ascending")); 64 64 65 65 // Setup prefs object. 66 66 $this->prefs = new Prefs($_SERVER['PHP_SELF']); … … 154 154 } 155 155 156 /** 157 * Get the current sort and order values. 158 * 159 * @return array Array with keys: sort and order. These can be fed back into the SortOrder::set() method or defaults. 160 */ 161 function get() 162 { 163 return array( 164 'sort' => $this->prefs->get('sort_by'), 165 'order' => $this->prefs->get('sort_order'), 166 ); 167 } 156 168 157 169 /** … … 202 214 } else { 203 215 ?><a href="<?php echo $app->oHREF($_SERVER['PHP_SELF'] . '?sort=' . $col . '&order=' . $default_order); ?>" title="<?php echo sprintf(_("Sort by %s"), $col_name); ?>"><?php echo $col_name; ?></a><?php 204 } 216 } 205 217 } else { 206 218 echo $col_name; -
Property
svn:mergeinfo
set to
Note: See TracChangeset
for help on using the changeset viewer.