- Timestamp:
- Nov 17, 2005 3:00:00 AM (19 years ago)
- Location:
- trunk/lib
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/lib/App.inc.php
r19 r20 29 29 // Instance of database object. 30 30 var $db; 31 32 // Array of query arguments will be carried persistently between requests. 33 var $_carry_queries = array(); 31 34 32 35 // Hash of global application parameters. … … 47 50 'ssl_enabled' => false, 48 51 49 // Character set for page output. Set in the Content-Type header and anHTML <meta content-type> tag.52 // Character set for page output. Used in the Content-Type header and the HTML <meta content-type> tag. 50 53 'character_set' => 'utf-8', 51 54 … … 534 537 535 538 /** 539 * Sets which query arguments will be carried persistently between requests. 540 * Values in the _carry_queries array will be copied to URLs (via oHREF()) and 541 * to hidden input values (via printHiddenSession()). 542 * 543 * @access public 544 * @param string $query_key The key of the query argument to save. 545 * @author Quinn Comendant <quinn@strangecode.com> 546 * @since 14 Nov 2005 19:24:52 547 */ 548 function carryQuery($query_key) 549 { 550 if (!isset($this) || !is_a($this, 'App')) { 551 $this =& App::getInstance(); 552 } 553 554 // If not already set, and there is a non-empty value provided in the request... 555 if (!isset($this->_carry_queries[$query_key]) && getFormData($query_key, false)) { 556 // Copy the value of the specified query argument into the _carry_queries array. 557 $this->_carry_queries[$query_key] = getFormData($query_key); 558 } 559 } 560 561 /** 536 562 * Outputs a fully qualified URL with a query of all the used (ie: not empty) 537 563 * keys and values, including optional queries. This allows simple printing of 538 564 * links without needing to know which queries to add to it. If cookies are not 539 565 * used, the session id will be propogated in the URL. 540 *541 * @global string $carry_queries An array of keys to define which values to542 * carry through from the POST or GET.543 * $carry_queries = array('qry'); for example.544 566 * 545 567 * @param string $url The initial url … … 565 587 return false; 566 588 } 567 568 static $_using_trans_sid; 569 global $carry_queries; 570 571 // Save the trans_sid setting. 572 if (!isset($_using_trans_sid)) { 573 $_using_trans_sid = ini_get('session.use_trans_sid'); 574 } 575 576 // Initialize the carried queries. 577 if (!isset($carry_queries['_carry_queries_init'])) { 578 if (!is_array($carry_queries)) { 579 $carry_queries = array($carry_queries); 580 } 581 $tmp = $carry_queries; 582 $carry_queries = array(); 583 foreach ($tmp as $key) { 584 if (!empty($key) && getFormData($key, false)) { 585 $carry_queries[$key] = getFormData($key); 586 } 587 } 588 $carry_queries['_carry_queries_init'] = true; 589 } 590 591 // Get any additional query arguments to add to the $carry_queries array. 592 // If FALSE is a function argument, DO NOT carry the queries. 589 590 // Get any provided query arguments to include in the final URL. 591 // If FALSE is a provided here, DO NOT carry the queries. 593 592 $do_carry_queries = true; 594 593 $one_time_carry_queries = array(); … … 611 610 } 612 611 } 613 612 614 613 // Get the first delimiter that is needed in the url. 615 614 $delim = preg_match('/\?/', $url) ? ini_get('arg_separator.output') : '?'; … … 617 616 $q = ''; 618 617 if ($do_carry_queries) { 619 // Join the perm and temp carry_queries and filter out the _carry_queries_init element for the final query args.620 $query_args = array_diff_assoc(urlEncodeArray(array_merge($carry_queries, $one_time_carry_queries)), array('_carry_queries_init' => true));618 // Join the global _carry_queries and local one_time_carry_queries. 619 $query_args = urlEncodeArray(array_merge($this->_carry_queries, $one_time_carry_queries)); 621 620 foreach ($query_args as $key=>$val) { 622 621 // Check value is set and value does not already exist in the url. … … 648 647 && 649 648 ( 650 ! $_using_trans_sid649 !ini_get('session.use_trans_sid') 651 650 || preg_match('!^(http|https)://!i', $url) 652 651 ) … … 668 667 * as hidden form elements for GET_VARS that might be in use. 669 668 * 670 * @global string $carry_queries An array of keys to define which values to671 * carry through from the POST or GET.672 * $carry_queries = array('qry'); for example673 *674 669 * @param mixed $carry_args Additional url arguments to carry in the query, 675 670 * or FALSE to prevent carrying queries. Can be any of the following formats: … … 679 674 */ 680 675 function printHiddenSession($carry_args=null) 681 { 676 { 682 677 if (!isset($this) || !is_a($this, 'App')) { 683 678 $this =& App::getInstance(); … … 687 682 return false; 688 683 } 689 690 static $_using_trans_sid; 691 global $carry_queries; 692 693 // Save the trans_sid setting. 694 if (!isset($_using_trans_sid)) { 695 $_using_trans_sid = ini_get('session.use_trans_sid'); 696 } 697 698 // Initialize the carried queries. 699 if (!isset($carry_queries['_carry_queries_init'])) { 700 if (!is_array($carry_queries)) { 701 $carry_queries = array($carry_queries); 702 } 703 $tmp = $carry_queries; 704 $carry_queries = array(); 705 foreach ($tmp as $key) { 706 if (!empty($key) && getFormData($key, false)) { 707 $carry_queries[$key] = getFormData($key); 708 } 709 } 710 $carry_queries['_carry_queries_init'] = true; 711 } 712 713 // Get any additional query names to add to the $carry_queries array 714 // that are found as function arguments. 715 // If FALSE is a function argument, DO NOT carry the queries. 684 685 // Get any provided query arguments to include in the final hidden form data. 686 // If FALSE is a provided here, DO NOT carry the queries. 716 687 $do_carry_queries = true; 717 688 $one_time_carry_queries = array(); … … 737 708 // For each existing POST value, we create a hidden input to carry it through a form. 738 709 if ($do_carry_queries) { 739 // Join the perm and temp carry_queries and filter out the _carry_queries_init element for the final query args. 740 $query_args = array_diff_assoc(urlEncodeArray(array_merge($carry_queries, $one_time_carry_queries)), array('_carry_queries_init' => true)); 710 // Join the global _carry_queries and local one_time_carry_queries. 711 // urlencode is not used here, not for form data! 712 $query_args = array_merge($this->_carry_queries, $one_time_carry_queries); 741 713 foreach ($query_args as $key=>$val) { 742 714 echo '<input type="hidden" name="' . $key . '" value="' . $val . '" />'; … … 745 717 746 718 // Include the SID if cookies are disabled. 747 if (!isset($_COOKIE[session_name()]) && ! $_using_trans_sid) {719 if (!isset($_COOKIE[session_name()]) && !ini_get('session.use_trans_sid')) { 748 720 echo '<input type="hidden" name="' . session_name() . '" value="' . session_id() . '" />'; 749 721 } -
trunk/lib/PayPal.inc.php
r19 r20 188 188 if (!in_array($key, array('button_url', 'link_url', 'submit_img', 'submit_text'))) { 189 189 ?> 190 <input type="hidden" name="<?php echo $key; ?>" value="<?php echo $val; ?>" >190 <input type="hidden" name="<?php echo $key; ?>" value="<?php echo $val; ?>" /> 191 191 <?php 192 192 } … … 194 194 } 195 195 ?> 196 <input type="image" src="<?php echo $this->_buttons[$name]['options']['submit_img']; ?>" border="0" name="submit" alt="<?php echo $this->_buttons[$name]['options']['submit_text']; ?>" >196 <input type="image" src="<?php echo $this->_buttons[$name]['options']['submit_img']; ?>" border="0" name="submit" alt="<?php echo $this->_buttons[$name]['options']['submit_text']; ?>" /> 197 197 </form> 198 198 <?php -
trunk/lib/RecordLock.inc.php
r19 r20 345 345 <?php if ($this->getSecondsElapsed() > $this->getParam('timeout')) { ?> 346 346 <p><?php printf(_("You can forcibly unlock the record if you believe the editing session has expired. You might want to confirm with %s before doing this."), $this->getEditor()) ?></p> 347 <input type="submit" class="formsubmitbutton" name="unlock" value="<?php echo _("Unlock"); ?>" >347 <input type="submit" class="formsubmitbutton" name="unlock" value="<?php echo _("Unlock"); ?>" /> 348 348 <?php } ?> 349 349 350 <input type="submit" class="formsubmitbutton" name="cancel" value="<?php echo _("Cancel"); ?>" >350 <input type="submit" class="formsubmitbutton" name="cancel" value="<?php echo _("Cancel"); ?>" /> 351 351 </form> 352 352 <?php -
trunk/lib/RecordVersion.inc.php
r19 r20 40 40 { 41 41 static $instances = array(); 42 43 if (!is_a($auth_object, 'Auth_SQL')) {44 trigger_error('Constructor not provided a valid Auth_SQL object.', E_USER_ERROR);45 }46 42 47 43 if (!isset($instances[$auth_object->getVal('auth_name')])) { … … 60 56 { 61 57 if (!is_a($auth_object, 'Auth_SQL')) { 62 trigger_error('Passed argument is nota valid Auth_SQL object.', E_USER_ERROR);58 trigger_error('Constructor not provided a valid Auth_SQL object.', E_USER_ERROR); 63 59 } 64 60 -
trunk/lib/SortOrder.inc.php
r19 r20 15 15 * 16 16 * @author Quinn Comendant <quinn@strangecode.com> 17 * @version 1.6 17 * @version 1.6.1 18 18 */ 19 19 require_once dirname(__FILE__) . '/App.inc.php'; … … 26 26 var $sort_by; 27 27 var $order; 28 var $asc_widget ;29 var $desc_widget ;28 var $asc_widget = '<img src="/admin/_widgets/sort_ascending.gif" alt="" width="11" height="7" border="0">'; 29 var $desc_widget = '<img src="/admin/_widgets/sort_descending.gif" alt="" width="11" height="7" border="0">'; 30 30 var $default_sort; 31 31 var $default_order; … … 41 41 function SortOrder($default_sort = '', $default_order = '') 42 42 { 43 $this->asc_widget = '<img src="/_widgets/sort_ascending.gif" alt="" width="11" height="7" border="0">';44 $this->desc_widget = '<img src="/_widgets/sort_descending.gif" alt="" width="11" height="7" border="0">';45 46 43 $this->setDefault($default_sort, $default_order); 47 44 … … 146 143 } 147 144 148 if (!empty($this->_columns[strtolower($this->sort_by)][strtolower( strtolower($this->order))])) {149 return ' ORDER BY ' . addslashes($this->_columns[strtolower($this->sort_by)][strtolower( strtolower($this->order))]);145 if (!empty($this->_columns[strtolower($this->sort_by)][strtolower($this->order)])) { 146 return ' ORDER BY ' . addslashes($this->_columns[strtolower($this->sort_by)][strtolower($this->order)]); 150 147 } else { 151 148 App::logMsg(sprintf('Could not find SQL to sort by %s %s.', $this->sort_by, $this->order), LOG_WARNING, __FILE__, __LINE__); -
trunk/lib/SpellCheck.inc.php
r19 r20 346 346 ?> 347 347 </select> 348 <input type="text" name="spelling_corrections[<?php echo $form_name ?>][<?php echo $i ?>]" value="<?php echo $original_word ?>" size="20" >348 <input type="text" name="spelling_corrections[<?php echo $form_name ?>][<?php echo $i ?>]" value="<?php echo $original_word ?>" size="20" /> 349 349 <?php if ($this->_use_personal_wordlist) { ?> 350 350 <input name="save_to_personal_wordlist[]" type="checkbox" value="<?php echo $i ?>" /><?php echo _("Learn spelling") ?> -
trunk/lib/Upload.inc.php
r19 r20 3 3 * Upload.inc.php 4 4 * Code by Strangecode :: www.strangecode.com :: This document contains copyrighted information 5 */ 6 7 /** 5 * 8 6 * The Upload class provides an interface to deal with http uploaded files. 9 7 * 10 8 * @author Quinn Comendant <quinn@strangecode.com> 11 9 * @requires App.inc.php 12 * @version 1. 010 * @version 1.2 13 11 */ 14 12 … … 19 17 // General object parameters. 20 18 var $_params = array( 19 20 // Display message with raiseMsg? 21 21 'display_messages' => true, 22 23 // Existing files will be overwritten when there is a name conflict? 22 24 'allow_overwriting' => false, 25 26 // The filesystem path to the final upload directory. 27 'upload_path' => null, 28 29 // The file permissions of the uploaded files. Remember, files will be owned by the web server user. 30 'dest_file_perms' => 0600, 31 32 // Require file to have one of the following file extentions. 33 'valid_file_extensions' => array('jpg', 'jpeg', 'gif', 'png', 'pdf', 'txt', 'text', 'html', 'htm'), 23 34 ); 24 25 // Disk path where new image(s) will be uploaded.26 var $upload_directory_path = null;27 35 28 36 // Array of files with errors. 29 37 var $errors = array(); 30 31 // Array of acceptable file extensions (lowercase). 32 var $valid_file_extensions = array('jpg', 'jpeg', 'gif', 'png', 'pdf', 'txt', 'text', 'html', 'htm'); 33 34 // The uploaded files will normally be owned by user 'apache'. Set world-read/write 35 // if the website admin needs to read/delete these files. 36 var $dest_file_perms = 0600; 37 38 38 39 // Array of file extensions and corresponding mime-types. 39 40 var $mime_extension_map = array( … … 223 224 { 224 225 if (isset($params) && is_array($params)) { 226 227 // Enforce valid upload_path parameter. 228 if (isset($params['upload_path'])) { 229 $params['upload_path'] = realpath($params['upload_path']); 230 // Must be directory. 231 if (!is_dir($params['upload_path'])) { 232 App::logMsg(sprintf('Upload directory invalid: %s', $params['upload_path']), LOG_ERR, __FILE__, __LINE__); 233 trigger_error(sprintf('Upload directory invalid: %s', $params['upload_path']), E_USER_ERROR); 234 } 235 // Must be writable. 236 if (!is_writable($params['upload_path'])) { 237 App::logMsg(sprintf('Upload directory not writable: %s', $params['upload_path']), LOG_ERR, __FILE__, __LINE__); 238 trigger_error(sprintf('Upload directory not writable: %s', $params['upload_path']), E_USER_ERROR); 239 } 240 // Set the default upload path, stripping any extra slashes if needed. 241 $params['upload_path'] = preg_replace('!/+$!', '', $params['upload_path']); 242 } 243 225 244 // Merge new parameters with old overriding only those passed. 226 245 $this->_params = array_merge($this->_params, $params); … … 250 269 * 251 270 */ 252 function setUploadPath($path)253 {254 $path = realpath($path);255 256 if (!is_dir($path)) {257 App::logMsg(sprintf('Upload directory invalid: %s', $path), LOG_ERR, __FILE__, __LINE__);258 }259 if (!is_writable($path)) {260 App::logMsg(sprintf('Upload directory not writable: %s', $path), LOG_ERR, __FILE__, __LINE__);261 }262 263 // Set the default upload path, stripping any extra slashes if needed.264 $this->upload_directory_path = preg_replace('!/+$!', '', $path);265 }266 267 /**268 *269 */270 271 function process($form_name, $custom_file_name=null) 271 272 { 272 273 // Ensure we have a upload directory. 273 if (! isset($this->upload_directory_path)) {274 if (!$this->getParam('upload_path')) { 274 275 App::logMsg(sprintf('Upload directory not set before processing.'), LOG_ERR, __FILE__, __LINE__); 275 276 $this->raiseMsg(_("There was a problem with the file upload. Please try again later."), MSG_ERR, __FILE__, __LINE__); … … 364 365 365 366 // Check to be sure the file has a valid file extension. 366 if (!in_array(strtolower($this->getFilenameExtension($files['name'][$i])), $this-> valid_file_extensions)) {367 $this->raiseMsg(sprintf(_("The file <strong>%s</strong> failed uploading: it is an unrecognized type. Files must have one of the following file extensions: %s."), $files['name'][$i], join(', ', $this-> valid_file_extensions)), MSG_ERR, __FILE__, __LINE__);367 if (!in_array(strtolower($this->getFilenameExtension($files['name'][$i])), $this->getParam('valid_file_extensions'))) { 368 $this->raiseMsg(sprintf(_("The file <strong>%s</strong> failed uploading: it is an unrecognized type. Files must have one of the following file extensions: %s."), $files['name'][$i], join(', ', $this->getParam('valid_file_extensions'))), MSG_ERR, __FILE__, __LINE__); 368 369 App::logMsg(sprintf(_("The uploaded file %s has an unrecognized file extension."), $files['name'][$i]), LOG_WARNING, __FILE__, __LINE__); 369 370 $this->errors[] = $files['name'][$i]; … … 417 418 418 419 // Set the path and file name. 419 $file_path_name = $this-> upload_directory_path. '/' . $file_name;420 $file_path_name = $this->getParam('upload_path') . '/' . $file_name; 420 421 421 422 // Move the file to the final place. 422 423 if (move_uploaded_file($files['tmp_name'][$i], $file_path_name)) { 423 chmod($file_path_name, $this-> dest_file_perms);424 chmod($file_path_name, $this->getParam('dest_file_perms')); 424 425 $this->raiseMsg(sprintf(_("The file <strong>%s</strong> uploaded successfully."), $files['name'][$i]), MSG_SUCCESS, __FILE__, __LINE__); 425 426 if (!isset($custom_file_name) && $files['name'][$i] != $file_name) { … … 449 450 { 450 451 // Ensure we have a upload directory. 451 if (! isset($this->upload_directory_path)) {452 if (!$this->getParam('upload_path')) { 452 453 App::logMsg(sprintf('Upload directory not set before processing.'), LOG_ERR, __FILE__, __LINE__); 453 454 return false; 454 455 } 455 456 456 $file_path_name = $this-> upload_directory_path. '/' . $file_name;457 $file_path_name = $this->getParam('upload_path') . '/' . $file_name; 457 458 458 459 if (!is_file($file_path_name)) { … … 474 475 { 475 476 // Ensure we have an upload directory. 476 if (! isset($this->upload_directory_path)) {477 if (!$this->getParam('upload_path')) { 477 478 App::logMsg(sprintf('Upload directory not set before processing.'), LOG_ERR, __FILE__, __LINE__); 478 479 return false; 479 480 } 480 481 481 $old_file_path_name = $this-> upload_directory_path. '/' . $old_name;482 $new_file_path_name = $this-> upload_directory_path. '/' . $new_name;482 $old_file_path_name = $this->getParam('upload_path') . '/' . $old_name; 483 $new_file_path_name = $this->getParam('upload_path') . '/' . $new_name; 483 484 if (file_exists($old_file_path_name)) { 484 if (!rename($old_file_path_name, $new_file_path_name)) { 485 if (rename($old_file_path_name, $new_file_path_name)) { 486 $this->raiseMsg(sprintf(_("The file <strong>%s</strong> has been renamed to <strong>%s</strong>."), basename($old_file_path_name), basename($new_file_path_name)), MSG_NOTICE, __FILE__, __LINE__); 487 App::logMsg(sprintf('File renamed from %s to %s', $old_file_path_name, $new_file_path_name), LOG_DEBUG, __FILE__, __LINE__); 488 } else { 485 489 $this->raiseMsg(sprintf(_("Error renaming file to %s"), $new_file_path_name), MSG_ERR, __FILE__, __LINE__); 486 490 App::logMsg(sprintf(_("Error renaming file to %s"), $new_file_path_name), LOG_ERR, __FILE__, __LINE__); … … 500 504 { 501 505 // Ensure we have a upload directory. 502 if (! isset($this->upload_directory_path)) {506 if (!$this->getParam('upload_path')) { 503 507 App::logMsg(sprintf('Upload directory not set before processing.'), LOG_ERR, __FILE__, __LINE__); 504 508 return false; 505 509 } 506 510 507 return file_exists($this->upload_directory_path . '/' . $file_name); 511 return file_exists($this->getParam('upload_path') . '/' . $file_name); 512 } 513 514 /** 515 * Get filename by glob pattern. Searches a directory for an image that matches the 516 * specified glob pattern and returns the filename of the first file found. 517 * 518 * @access public 519 * @param string $pattern Pattern to match filename. 520 * @return string filename on success, empty string on failure. 521 * @author Quinn Comendant <quinn@strangecode.com> 522 * @since 15 Nov 2005 20:55:22 523 */ 524 function getFilenameGlob($pattern) 525 { 526 $file_list = glob(sprintf('%s/%s', $this->getParam('upload_path'), $pattern)); 527 if (isset($file_list[0])) { 528 return basename($file_list[0]); 529 } else { 530 return ''; 531 } 508 532 } 509 533 -
trunk/lib/Utilities.inc.php
r19 r20 298 298 } 299 299 } else { 300 // We've come to the last dimention of the array, save the "array" and it 's value.300 // We've come to the last dimention of the array, save the "array" and its value. 301 301 $args[$prefix] = urlencode($data); 302 302 }
Note: See TracChangeset
for help on using the changeset viewer.