Changeset 128
- Timestamp:
- May 26, 2006 9:29:19 PM (18 years ago)
- Location:
- branches/2.0singleton/lib
- Files:
-
- 15 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/2.0singleton/lib/ImageThumb.inc.php
r121 r128 95 95 function setParam($params) 96 96 { 97 $app =& App::getInstance(); 98 97 99 if (isset($params) && is_array($params)) { 98 100 … … 102 104 // Must be directory. 103 105 if (!is_dir($params['source_dir'])) { 104 App::logMsg(sprintf('Source directory invalid: %s', $params['source_dir']), LOG_ERR, __FILE__, __LINE__);106 $app->logMsg(sprintf('Source directory invalid: %s', $params['source_dir']), LOG_ERR, __FILE__, __LINE__); 105 107 trigger_error(sprintf('Source directory invalid: %s', $params['source_dir']), E_USER_ERROR); 106 108 } 107 109 // Must be readable. 108 110 if (!is_readable($params['source_dir'])) { 109 App::logMsg(sprintf('Source directory not readable: %s', $params['source_dir']), LOG_ERR, __FILE__, __LINE__);111 $app->logMsg(sprintf('Source directory not readable: %s', $params['source_dir']), LOG_ERR, __FILE__, __LINE__); 110 112 trigger_error(sprintf('Source directory not readable: %s', $params['source_dir']), E_USER_ERROR); 111 113 } … … 115 117 $this->_params = array_merge($this->_params, $params); 116 118 } else { 117 App::logMsg(sprintf('Parameters are not an array: %s', $params), LOG_ERR, __FILE__, __LINE__);119 $app->logMsg(sprintf('Parameters are not an array: %s', $params), LOG_ERR, __FILE__, __LINE__); 118 120 } 119 121 } … … 128 130 function getParam($param) 129 131 { 132 $app =& App::getInstance(); 133 130 134 if (isset($this->_params[$param])) { 131 135 return $this->_params[$param]; 132 136 } else { 133 App::logMsg(sprintf('Parameter is not set: %s', $param), LOG_DEBUG, __FILE__, __LINE__);137 $app->logMsg(sprintf('Parameter is not set: %s', $param), LOG_DEBUG, __FILE__, __LINE__); 134 138 return null; 135 139 } … … 144 148 function setSpec($spec, $index=null) 145 149 { 150 $app =& App::getInstance(); 151 146 152 // A little sanity checking. 147 153 if (!isset($spec['dest_dir']) || '' == $spec['dest_dir']) { 148 App::logMsg('setSpec error: dest_dir not specified.', LOG_ERR, __FILE__, __LINE__);154 $app->logMsg('setSpec error: dest_dir not specified.', LOG_ERR, __FILE__, __LINE__); 149 155 } 150 156 if (isset($spec['dest_file_type'])) { … … 152 158 case IMG_JPG : 153 159 if (imagetypes() & IMG_JPG == 0) { 154 App::logMsg(sprintf('IMG_JPG is not supported by this version of PHP GD.', null), LOG_ERR, __FILE__, __LINE__);160 $app->logMsg(sprintf('IMG_JPG is not supported by this version of PHP GD.', null), LOG_ERR, __FILE__, __LINE__); 155 161 } 156 162 $spec['dest_file_extention'] = 'jpg'; … … 158 164 case IMG_PNG : 159 165 if (imagetypes() & IMG_PNG == 0) { 160 App::logMsg(sprintf('IMG_PNG is not supported by this version of PHP GD.', null), LOG_ERR, __FILE__, __LINE__);166 $app->logMsg(sprintf('IMG_PNG is not supported by this version of PHP GD.', null), LOG_ERR, __FILE__, __LINE__); 161 167 } 162 168 $spec['dest_file_extention'] = 'png'; … … 164 170 case IMG_GIF : 165 171 if (imagetypes() & IMG_GIF == 0) { 166 App::logMsg(sprintf('IMG_GIF is not supported by this version of PHP GD.', null), LOG_ERR, __FILE__, __LINE__);172 $app->logMsg(sprintf('IMG_GIF is not supported by this version of PHP GD.', null), LOG_ERR, __FILE__, __LINE__); 167 173 } 168 174 $spec['dest_file_extention'] = 'gif'; … … 170 176 case IMG_WBMP : 171 177 if (imagetypes() & IMG_WBMP == 0) { 172 App::logMsg(sprintf('IMG_WBMP is not supported by this version of PHP GD.', null), LOG_ERR, __FILE__, __LINE__);178 $app->logMsg(sprintf('IMG_WBMP is not supported by this version of PHP GD.', null), LOG_ERR, __FILE__, __LINE__); 173 179 } 174 180 $spec['dest_file_extention'] = 'wbmp'; 175 181 break; 176 182 default : 177 App::logMsg(sprintf('Invalid dest_file_type: %s', $spec['dest_file_type']), LOG_ERR, __FILE__, __LINE__);183 $app->logMsg(sprintf('Invalid dest_file_type: %s', $spec['dest_file_type']), LOG_ERR, __FILE__, __LINE__); 178 184 break; 179 185 } 180 186 } 181 187 if (!isset($spec['width']) || !is_int($spec['width'])) { 182 App::logMsg('setSpec error: width not specified.', LOG_ERR, __FILE__, __LINE__);188 $app->logMsg('setSpec error: width not specified.', LOG_ERR, __FILE__, __LINE__); 183 189 } 184 190 if (!isset($spec['height']) || !is_int($spec['height'])) { 185 App::logMsg('setSpec error: height not specified.', LOG_ERR, __FILE__, __LINE__);191 $app->logMsg('setSpec error: height not specified.', LOG_ERR, __FILE__, __LINE__); 186 192 } 187 193 if (isset($spec['quality']) && IMG_JPG != $spec['dest_file_type']) { 188 App::logMsg('The "quality" specification is not used unless IMG_JPG is the dest_file_type.', LOG_INFO, __FILE__, __LINE__);194 $app->logMsg('The "quality" specification is not used unless IMG_JPG is the dest_file_type.', LOG_INFO, __FILE__, __LINE__); 189 195 } 190 196 if (isset($spec['progressive']) && IMG_JPG != $spec['dest_file_type']) { 191 App::logMsg('The "progressive" specification is not used unless IMG_JPG is the dest_file_type.', LOG_INFO, __FILE__, __LINE__);197 $app->logMsg('The "progressive" specification is not used unless IMG_JPG is the dest_file_type.', LOG_INFO, __FILE__, __LINE__); 192 198 } 193 199 … … 213 219 function processAll($runtime_specs=null) 214 220 { 221 $app =& App::getInstance(); 222 215 223 // Ensure we have a source. 216 224 if ('' == $this->getParam('source_dir')) { 217 App::logMsg(sprintf('Source directory not set before processing.'), LOG_ERR, __FILE__, __LINE__);225 $app->logMsg(sprintf('Source directory not set before processing.'), LOG_ERR, __FILE__, __LINE__); 218 226 return false; 219 227 } … … 237 245 return 0 === $return_val; 238 246 } else { 239 App::logMsg(sprintf('No images found to thumbnail in directory %s.', $this->getParam('source_dir')), LOG_NOTICE, __FILE__, __LINE__);247 $app->logMsg(sprintf('No images found to thumbnail in directory %s.', $this->getParam('source_dir')), LOG_NOTICE, __FILE__, __LINE__); 240 248 return false; 241 249 } … … 252 260 function processFile($file_name, $runtime_specs=null) 253 261 { 262 $app =& App::getInstance(); 263 254 264 // Source file determinted by provided file_name. 255 265 $source_file = realpath(sprintf('%s/%s', $this->getParam('source_dir'), $file_name)); … … 260 270 $this->setSpec($runtime_specs, 0); 261 271 } else { 262 App::logMsg(sprintf('Image specifications not set before processing.'), LOG_ERR, __FILE__, __LINE__);272 $app->logMsg(sprintf('Image specifications not set before processing.'), LOG_ERR, __FILE__, __LINE__); 263 273 return false; 264 274 } … … 267 277 // Ensure we have a source. 268 278 if ('' == $this->getParam('source_dir')) { 269 App::logMsg(sprintf('Source directory not set before processing.'), LOG_ERR, __FILE__, __LINE__);279 $app->logMsg(sprintf('Source directory not set before processing.'), LOG_ERR, __FILE__, __LINE__); 270 280 return false; 271 281 } … … 274 284 if (!file_exists($source_file)) { 275 285 $this->_raiseMsg(sprintf(_("Image resizing failed: source image %s was not found."), $file_name), MSG_ERR, __FILE__, __LINE__); 276 App::logMsg(sprintf('Source image not found: %s', $source_file), LOG_ALERT, __FILE__, __LINE__);286 $app->logMsg(sprintf('Source image not found: %s', $source_file), LOG_ALERT, __FILE__, __LINE__); 277 287 return false; 278 288 } … … 281 291 if (!is_readable($source_file)) { 282 292 $this->_raiseMsg(sprintf(_("Image resizing failed: source image %s is not readable."), $file_name), MSG_ERR, __FILE__, __LINE__); 283 App::logMsg(sprintf('Source image not readable: %s', $source_file), LOG_ALERT, __FILE__, __LINE__);293 $app->logMsg(sprintf('Source image not readable: %s', $source_file), LOG_ALERT, __FILE__, __LINE__); 284 294 return false; 285 295 } … … 288 298 if (filesize($source_file) <= 0) { 289 299 $this->_raiseMsg(sprintf(_("Image resizing failed: source image %s is zero bytes."), $file_name), MSG_ERR, __FILE__, __LINE__); 290 App::logMsg(sprintf('Source image is zero bytes: %s', $source_file), LOG_ALERT, __FILE__, __LINE__);300 $app->logMsg(sprintf('Source image is zero bytes: %s', $source_file), LOG_ALERT, __FILE__, __LINE__); 291 301 return false; 292 302 } … … 295 305 if (!$this->_validFileExtension($file_name)) { 296 306 $this->_raiseMsg(sprintf(_("Image resizing failed: source image %s not a valid type. It must have one of the following file name extensions: %s"), $file_name, join(', ', $this->getParam('valid_file_extensions'))), MSG_ERR, __FILE__, __LINE__); 297 App::logMsg(sprintf('Image resizing failed: source image not of valid type: %s', $source_file), LOG_ERR, __FILE__, __LINE__);307 $app->logMsg(sprintf('Image resizing failed: source image not of valid type: %s', $source_file), LOG_ERR, __FILE__, __LINE__); 298 308 return false; 299 309 } … … 324 334 $file_size = filesize($dest_file); 325 335 if (false !== $file_size && $file_size < $spec['keep_filesize']) { 326 App::logMsg(sprintf('Skipping thumbnail %s. File already exists and file size is less than %s bytes.', $spec['dest_dir'] . '/' . $file_name, $spec['keep_filesize']), LOG_DEBUG, __FILE__, __LINE__);336 $app->logMsg(sprintf('Skipping thumbnail %s. File already exists and file size is less than %s bytes.', $spec['dest_dir'] . '/' . $file_name, $spec['keep_filesize']), LOG_DEBUG, __FILE__, __LINE__); 327 337 continue; 328 338 } … … 333 343 if ($image_size['0'] <= $spec['width'] && $image_size['1'] <= $spec['height'] && !$spec['allow_upscaling']) { 334 344 $spec['scaling_type'] = IMAGETHUMB_NO_SCALE; 335 App::logMsg(sprintf('Image %s smaller than specified %s thumbnail size. Keeping original size.', $file_name, $spec['dest_dir']), LOG_DEBUG, __FILE__, __LINE__);345 $app->logMsg(sprintf('Image %s smaller than specified %s thumbnail size. Keeping original size.', $file_name, $spec['dest_dir']), LOG_DEBUG, __FILE__, __LINE__); 336 346 } 337 347 … … 339 349 if (IMAGETHUMB_METHOD_NETPBM === $this->getParam('resize_method') && file_exists($this->getParam('anytopnm_binary')) && file_exists($this->getParam('pnmscale_binary')) && file_exists($this->getParam('cjpeg_binary'))) { 340 350 // Resize using Netpbm binaries. 341 App::logMsg(sprintf('Resizing with Netpbm...', null), LOG_DEBUG, __FILE__, __LINE__);351 $app->logMsg(sprintf('Resizing with Netpbm...', null), LOG_DEBUG, __FILE__, __LINE__); 342 352 $return_val += $this->_resizeWithNetpbm($source_file, $dest_file, $spec); 343 353 } else if (IMAGETHUMB_METHOD_GD === $this->getParam('resize_method') && extension_loaded('gd')) { 344 354 // Resize with GD. 345 App::logMsg(sprintf('Resizing with GD...', null), LOG_DEBUG, __FILE__, __LINE__);355 $app->logMsg(sprintf('Resizing with GD...', null), LOG_DEBUG, __FILE__, __LINE__); 346 356 $return_val += $this->_resizeWithGD($source_file, $dest_file, $spec); 347 357 } else { 348 App::logMsg(sprintf('Image thumbnailing failed. Neither Netpbm or GD is available.', null), LOG_DEBUG, __FILE__, __LINE__);358 $app->logMsg(sprintf('Image thumbnailing failed. Neither Netpbm or GD is available.', null), LOG_DEBUG, __FILE__, __LINE__); 349 359 return false; 350 360 } … … 370 380 function _resizeWithNetpbm($source_file, $dest_file, $spec) 371 381 { 382 $app =& App::getInstance(); 383 372 384 // Define pnmscale arguments. 373 385 switch ($spec['scaling_type']) { … … 405 417 escapeshellcmd($file_name) 406 418 ); 407 App::logMsg(sprintf('ImageThumb Netpbm command: %s', $command), LOG_DEBUG, __FILE__, __LINE__);419 $app->logMsg(sprintf('ImageThumb Netpbm command: %s', $command), LOG_DEBUG, __FILE__, __LINE__); 408 420 409 421 // Execute! … … 414 426 // Make the thumbnail writable so the user can delete it over ftp without being 'apache'. 415 427 chmod($dest_file, $this->getParam('dest_file_perms')); 416 App::logMsg(sprintf('Successfully resized image %s', $spec['dest_dir'] . '/' . basename($dest_file), $return_val), LOG_DEBUG, __FILE__, __LINE__);428 $app->logMsg(sprintf('Successfully resized image %s', $spec['dest_dir'] . '/' . basename($dest_file), $return_val), LOG_DEBUG, __FILE__, __LINE__); 417 429 } else { 418 430 // An error occurred. 419 App::logMsg(sprintf('Image %s failed resizing with return value: %s%s', $spec['dest_dir'] . '/' . basename($dest_file), $return_val, empty($output) ? '' : ' (' . getDump($output) . ')'), LOG_ERR, __FILE__, __LINE__);431 $app->logMsg(sprintf('Image %s failed resizing with return value: %s%s', $spec['dest_dir'] . '/' . basename($dest_file), $return_val, empty($output) ? '' : ' (' . getDump($output) . ')'), LOG_ERR, __FILE__, __LINE__); 420 432 } 421 433 … … 438 450 function _resizeWithGD($source_file, $dest_file, $spec) 439 451 { 452 $app =& App::getInstance(); 453 440 454 // Get original file dimensions and type. 441 455 list($source_image_width, $source_image_height, $source_image_type) = getimagesize($source_file); … … 487 501 $source_image_resource = imagecreatefromwbmp($source_file); 488 502 default : 489 App::logMsg(sprintf('Source image type %s not supported.', $source_image_type), LOG_WARNING, __FILE__, __LINE__);503 $app->logMsg(sprintf('Source image type %s not supported.', $source_image_type), LOG_WARNING, __FILE__, __LINE__); 490 504 return 1; 491 505 break; 492 506 } 493 507 if (!$source_image_resource) { 494 App::logMsg(sprintf('Error creating %s image in memory from %s', $source_image_type, $source_file), LOG_WARNING, __FILE__, __LINE__);508 $app->logMsg(sprintf('Error creating %s image in memory from %s', $source_image_type, $source_file), LOG_WARNING, __FILE__, __LINE__); 495 509 return 1; 496 510 } … … 501 515 // Resample! 502 516 if (!imagecopyresampled($dest_image_resource, $source_image_resource, 0, 0, 0, 0, $dest_image_width, $dest_image_height, $source_image_width, $source_image_height)) { 503 App::logMsg(sprintf('Error resampling image %s', $source_file), LOG_WARNING, __FILE__, __LINE__);517 $app->logMsg(sprintf('Error resampling image %s', $source_file), LOG_WARNING, __FILE__, __LINE__); 504 518 return 1; 505 519 } … … 528 542 break; 529 543 default : 530 App::logMsg(sprintf('Destination image type %s not supported for image %s.', $spec['dest_file_type'], $dest_file), LOG_WARNING, __FILE__, __LINE__);544 $app->logMsg(sprintf('Destination image type %s not supported for image %s.', $spec['dest_file_type'], $dest_file), LOG_WARNING, __FILE__, __LINE__); 531 545 return 1; 532 546 break; … … 537 551 // Make the thumbnail writable so the user can delete it over ftp without being 'apache'. 538 552 chmod($dest_file, $this->getParam('dest_file_perms')); 539 App::logMsg(sprintf('Successfully resized image %s', $dest_file), LOG_DEBUG, __FILE__, __LINE__);553 $app->logMsg(sprintf('Successfully resized image %s', $dest_file), LOG_DEBUG, __FILE__, __LINE__); 540 554 return 0; 541 555 } else { 542 556 // An error occurred. 543 App::logMsg(sprintf('Image %s failed resizing.', $dest_file), LOG_ERR, __FILE__, __LINE__);557 $app->logMsg(sprintf('Image %s failed resizing.', $dest_file), LOG_ERR, __FILE__, __LINE__); 544 558 return 1; 545 559 } … … 555 569 function deleteThumbs($file_name) 556 570 { 571 $app =& App::getInstance(); 572 557 573 // Ensure we have a source. 558 574 if ('' == $this->getParam('source_dir')) { 559 App::logMsg(sprintf('Source directory not set before processing.'), LOG_ERR, __FILE__, __LINE__);575 $app->logMsg(sprintf('Source directory not set before processing.'), LOG_ERR, __FILE__, __LINE__); 560 576 return false; 561 577 } … … 567 583 if (!unlink($dest_file)) { 568 584 $return_val++; 569 App::logMsg(sprintf(_("Delete thumbs failed: %s"), $dest_file), LOG_WARNING, __FILE__, __LINE__);585 $app->logMsg(sprintf(_("Delete thumbs failed: %s"), $dest_file), LOG_WARNING, __FILE__, __LINE__); 570 586 } 571 587 } … … 584 600 function deleteOriginal($file_name) 585 601 { 602 $app =& App::getInstance(); 603 586 604 // Ensure we have a source. 587 605 if ('' == $this->getParam('source_dir')) { 588 App::logMsg(sprintf('Source directory not set before processing.'), LOG_ERR, __FILE__, __LINE__);606 $app->logMsg(sprintf('Source directory not set before processing.'), LOG_ERR, __FILE__, __LINE__); 589 607 return false; 590 608 } … … 592 610 $source_file = realpath(sprintf('%s/%s', $this->getParam('source_dir'), $file_name)); 593 611 if (!unlink($source_file)) { 594 App::logMsg(sprintf(_("Delete original failed: %s"), $source_file), LOG_WARNING, __FILE__, __LINE__);612 $app->logMsg(sprintf(_("Delete original failed: %s"), $source_file), LOG_WARNING, __FILE__, __LINE__); 595 613 return false; 596 614 } … … 608 626 function exists($file_name) 609 627 { 628 $app =& App::getInstance(); 629 610 630 // Ensure we have a source. 611 631 if ('' == $this->getParam('source_dir')) { 612 App::logMsg(sprintf('Source directory not set before processing.'), LOG_ERR, __FILE__, __LINE__);632 $app->logMsg(sprintf('Source directory not set before processing.'), LOG_ERR, __FILE__, __LINE__); 613 633 return false; 614 634 } … … 639 659 function _createDestDirs() 640 660 { 661 $app =& App::getInstance(); 662 641 663 static $already_checked = false; 642 664 … … 644 666 // Ensure we have a source. 645 667 if ('' == $this->getParam('source_dir')) { 646 App::logMsg(sprintf('Source directory not set before creating destination directories.'), LOG_ERR, __FILE__, __LINE__);668 $app->logMsg(sprintf('Source directory not set before creating destination directories.'), LOG_ERR, __FILE__, __LINE__); 647 669 return false; 648 670 } … … 654 676 if (!mkdir($this->getParam('source_dir') . '/' . $spec['dest_dir'], $this->getParam('dest_dir_perms'))) { 655 677 $return_val++; 656 App::logMsg(sprintf('mkdir failure: %s', $this->getParam('source_dir') . '/' . $spec['dest_dir']), LOG_ERR, __FILE__, __LINE__);678 $app->logMsg(sprintf('mkdir failure: %s', $this->getParam('source_dir') . '/' . $spec['dest_dir']), LOG_ERR, __FILE__, __LINE__); 657 679 } 658 680 } … … 667 689 668 690 /** 669 * An alias for App::raiseMsg that only sends messages configured by display_messages.691 * An alias for $app->raiseMsg that only sends messages configured by display_messages. 670 692 * 671 693 * @access public … … 679 701 function _raiseMsg($message, $type, $file, $line) 680 702 { 703 $app =& App::getInstance(); 704 681 705 if ($this->getParam('display_messages') === true || (is_int($this->getParam('display_messages')) && $this->getParam('display_messages') & $type > 0)) { 682 App::raiseMsg($message, $type, $file, $line);706 $app->raiseMsg($message, $type, $file, $line); 683 707 } 684 708 } -
branches/2.0singleton/lib/MCVE.inc.php
r116 r128 22 22 function MCVE($username, $password) 23 23 { 24 $app =& App::getInstance(); 25 24 26 // Ensure PHP was compiled with the MCVE functions. 25 27 if (!extension_loaded('mcve')) { … … 27 29 } 28 30 if ('' == $username || '' == $password) { 29 App::logMsg(sprintf('Empty username or password provided.', null), LOG_ERR, __FILE__, __LINE__);31 $app->logMsg(sprintf('Empty username or password provided.', null), LOG_ERR, __FILE__, __LINE__); 30 32 } 31 33 $this->username = $username; … … 35 37 function _connect() 36 38 { 39 $app =& App::getInstance(); 40 37 41 if ($this->connected) { 38 42 return true; … … 49 53 case 'ip' : 50 54 if (!MCVE_SetIP($this->conn, $this->host, $this->ip_port)) { 51 App::logMsg('Could not set method to IP.', LOG_ERR, __FILE__, __LINE__);55 $app->logMsg('Could not set method to IP.', LOG_ERR, __FILE__, __LINE__); 52 56 return false; 53 57 } … … 55 59 case 'ssl' : 56 60 if (!MCVE_SetSSL($this->conn, $this->host, $this->ssl_port)) { 57 App::logMsg('Could not set method to IP.', LOG_ERR, __FILE__, __LINE__);61 $app->logMsg('Could not set method to IP.', LOG_ERR, __FILE__, __LINE__); 58 62 return false; 59 63 } … … 61 65 case 'dropfile' : 62 66 if (!MCVE_SetDropFile($this->conn, '/var/mcve/trans')) { 63 App::logMsg('Could not set method to IP.', LOG_ERR, __FILE__, __LINE__);67 $app->logMsg('Could not set method to IP.', LOG_ERR, __FILE__, __LINE__); 64 68 return false; 65 69 } 66 70 break; 67 71 default : 68 App::logMsg('Connection method not defined.', LOG_ERR, __FILE__, __LINE__);72 $app->logMsg('Connection method not defined.', LOG_ERR, __FILE__, __LINE__); 69 73 return false; 70 74 } … … 75 79 // non-blocking, but future versions of php_mcve will default to blocking. 76 80 if (!MCVE_SetBlocking($this->conn, $this->blocking)) { 77 App::logMsg('Could not set blocking mode.', LOG_ERR, __FILE__, __LINE__);81 $app->logMsg('Could not set blocking mode.', LOG_ERR, __FILE__, __LINE__); 78 82 return false; 79 83 } … … 81 85 // Maximum of 30s per transaction allowed. Timeout occurs on server-end, not client-end 82 86 if (!MCVE_SetTimeout($this->conn, $this->timeout)) { 83 App::logMsg('Could not set timeout.', LOG_ERR, __FILE__, __LINE__);87 $app->logMsg('Could not set timeout.', LOG_ERR, __FILE__, __LINE__); 84 88 return false; 85 89 } … … 88 92 if (!MCVE_Connect($this->conn)) { 89 93 $error = MCVE_ConnectionError($this->conn); 90 App::logMsg("Connection failed: $error. Are you sure the MCVE engine is running?", LOG_ERR, __FILE__, __LINE__);94 $app->logMsg("Connection failed: $error. Are you sure the MCVE engine is running?", LOG_ERR, __FILE__, __LINE__); 91 95 return false; 92 96 } … … 117 121 function sendTrans($tid, $type='', $hide_msg=false) 118 122 { 123 $app =& App::getInstance(); 124 119 125 // Finalize structuring of to MCVE and ready it to be sent 120 126 if (!MCVE_TransSend($this->conn, $tid)) { 121 App::logMsg('Transaction improperly structured, possibly not enough info.', LOG_ERR, __FILE__, __LINE__);127 $app->logMsg('Transaction improperly structured, possibly not enough info.', LOG_ERR, __FILE__, __LINE__); 122 128 return false; 123 129 } … … 139 145 // Check to see if transaction was successful or not using a strict success/fail function 140 146 if ($ret_status == MCVE_FAIL) { 141 App::raiseMsg(sprintf('MCVE %s failure: %s %s', $type, $ret_text, ('' == $verbiage ? '' : '(' . trim($verbiage) . ')')), MSG_WARNING, __FILE__, __LINE__);147 $app->raiseMsg(sprintf('MCVE %s failure: %s %s', $type, $ret_text, ('' == $verbiage ? '' : '(' . trim($verbiage) . ')')), MSG_WARNING, __FILE__, __LINE__); 142 148 return false; 143 149 } else if ($ret_status == MCVE_SUCCESS) { 144 150 if (!$hide_msg) { 145 App::raiseMsg(sprintf(_("MCVE %s success: %s %s"), $type, $ret_text, ('' == $verbiage ? '' : '(' . trim($verbiage) . ')')), MSG_SUCCESS, __FILE__, __LINE__);151 $app->raiseMsg(sprintf(_("MCVE %s success: %s %s"), $type, $ret_text, ('' == $verbiage ? '' : '(' . trim($verbiage) . ')')), MSG_SUCCESS, __FILE__, __LINE__); 146 152 } 147 App::logMsg(sprintf(_("MCVE success details. Auth: %s; Batch: %s; Item: %s; TTID: %s; AVS: %s; CV: %s."),153 $app->logMsg(sprintf(_("MCVE success details. Auth: %s; Batch: %s; Item: %s; TTID: %s; AVS: %s; CV: %s."), 148 154 MCVE_TransactionAuth($this->conn, $tid), 149 155 MCVE_TransactionBatch($this->conn, $tid), … … 155 161 return true; 156 162 } else { 157 App::logMsg(sprintf('Transaction failed. Unknown return code: %s', $ret_status), LOG_ERR, __FILE__, __LINE__);163 $app->logMsg(sprintf('Transaction failed. Unknown return code: %s', $ret_status), LOG_ERR, __FILE__, __LINE__); 158 164 return false; 159 165 } -
branches/2.0singleton/lib/Nav.inc.php
r44 r128 201 201 function getBreadcrumbs($page_id=null) 202 202 { 203 $app =& App::getInstance(); 204 203 205 $page_id = $this->_calculatePageID($page_id); 204 206 … … 219 221 } else if ($crumb_count > $this->getFeature('chop_breadcrumb_links')) { 220 222 // A normal linked crumb. 221 $breadcrumbs .= oTxt($pathmark, true) . '<a href="' . App::oHREF($page['url']) . '">' . sprintf($this->last_crumb_format, oTxt($page['title'], true)) . '</a>';223 $breadcrumbs .= oTxt($pathmark, true) . '<a href="' . $app->oHREF($page['url']) . '">' . sprintf($this->last_crumb_format, oTxt($page['title'], true)) . '</a>'; 222 224 } 223 225 } else { … … 227 229 } else { 228 230 // A normal linked crumb. 229 $breadcrumbs .= oTxt($pathmark, true) . '<a href="' . App::oHREF($page['url']) . '">' . oTxt($page['title'], true) . '</a>';231 $breadcrumbs .= oTxt($pathmark, true) . '<a href="' . $app->oHREF($page['url']) . '">' . oTxt($page['title'], true) . '</a>'; 230 232 } 231 233 } -
branches/2.0singleton/lib/PEdit.inc.php
r121 r128 95 95 function setParam($params) 96 96 { 97 $app =& App::getInstance(); 98 97 99 if (isset($params) && is_array($params)) { 98 100 // Merge new parameters with old overriding only those passed. 99 101 $this->_params = array_merge($this->_params, $params); 100 102 } else { 101 App::logMsg(sprintf('Parameters are not an array: %s', $params), LOG_WARNING, __FILE__, __LINE__);103 $app->logMsg(sprintf('Parameters are not an array: %s', $params), LOG_WARNING, __FILE__, __LINE__); 102 104 } 103 105 } … … 112 114 function getParam($param) 113 115 { 116 $app =& App::getInstance(); 117 114 118 if (isset($this->_params[$param])) { 115 119 return $this->_params[$param]; 116 120 } else { 117 App::logMsg(sprintf('Parameter is not set: %s', $param), LOG_NOTICE, __FILE__, __LINE__);121 $app->logMsg(sprintf('Parameter is not set: %s', $param), LOG_NOTICE, __FILE__, __LINE__); 118 122 return null; 119 123 } … … 129 133 function start($initialize_data_file=false) 130 134 { 135 $app =& App::getInstance(); 136 131 137 if (!is_dir($this->getParam('data_dir'))) { 132 138 trigger_error(sprintf('PEdit data directory not found: %s', $this->getParam('data_dir')), E_USER_WARNING); … … 143 149 case 'Save' : 144 150 if ($this->_writeData()) { 145 App::dieURL($_SERVER['PHP_SELF']);151 $app->dieURL($_SERVER['PHP_SELF']); 146 152 } 147 153 break; 148 154 case 'Restore' : 149 155 if ($this->_restoreVersion(getFormData('version'))) { 150 App::dieURL($_SERVER['PHP_SELF']);156 $app->dieURL($_SERVER['PHP_SELF']); 151 157 } 152 158 break; 153 159 case 'View' : 154 160 $this->_data_file = sprintf('%s%s__%s.xml', $this->getParam('data_dir'), $_SERVER['PHP_SELF'], getFormData('version')); 155 App::raiseMsg(sprintf(_("This is <em><strong>only a preview</strong></em> of version %s."), getFormData('version')), MSG_NOTICE, __FILE__, __LINE__);161 $app->raiseMsg(sprintf(_("This is <em><strong>only a preview</strong></em> of version %s."), getFormData('version')), MSG_NOTICE, __FILE__, __LINE__); 156 162 break; 157 163 } … … 176 182 function set($name, $options=array()) 177 183 { 184 $app =& App::getInstance(); 185 178 186 $name = preg_replace('/\s/', '_', $name); 179 187 if (!isset($this->_data[$name])) { 180 188 $this->_data[$name] = array_merge(array('content' => ''), $options); 181 189 } else { 182 App::logMsg(sprintf('Duplicate set data: %s', $name), LOG_NOTICE, __FILE__, __LINE__);190 $app->logMsg(sprintf('Duplicate set data: %s', $name), LOG_NOTICE, __FILE__, __LINE__); 183 191 } 184 192 } … … 208 216 function formBegin() 209 217 { 218 $app =& App::getInstance(); 219 210 220 if (!$this->_authorized || empty($this->_data)) { 211 221 return false; … … 216 226 <input type="hidden" name="file_hash" value="<?php echo $this->_fileHash(); ?>" /> 217 227 <?php 218 App::printHiddenSession();228 $app->printHiddenSession(); 219 229 switch ($this->op) { 220 230 case 'Edit' : … … 345 355 function printVersions() 346 356 { 357 $app =& App::getInstance(); 358 347 359 if ($this->_authorized && $this->op == 'Versions') { 348 360 // Print versions and commands to view/restore. … … 362 374 ?> 363 375 <tr> 364 <td><?php echo date( App::getParam('date_format'), $v['unixtime']); ?></td>365 <td><?php echo date( App::getParam('time_format'), $v['unixtime']); ?></td>376 <td><?php echo date($app->getParam('date_format'), $v['unixtime']); ?></td> 377 <td><?php echo date($app->getParam('time_format'), $v['unixtime']); ?></td> 366 378 <td><?php echo humanFileSize($v['filesize']); ?></td> 367 <td class="sc-nowrap"><a href="<?php echo App::oHREF($_SERVER['PHP_SELF'] . '?op=View&version=' . $v['unixtime'] . '&file_hash=' . $this->_fileHash()); ?>"><?php echo _("View"); ?></a> <?php echo _("or"); ?> <a href="<?php echo App::oHREF($_SERVER['PHP_SELF'] . '?op=Restore&version=' . $v['unixtime'] . '&file_hash=' . $this->_fileHash()); ?>"><?php echo _("Restore"); ?></a></td>379 <td class="sc-nowrap"><a href="<?php echo $app->oHREF($_SERVER['PHP_SELF'] . '?op=View&version=' . $v['unixtime'] . '&file_hash=' . $this->_fileHash()); ?>"><?php echo _("View"); ?></a> <?php echo _("or"); ?> <a href="<?php echo $app->oHREF($_SERVER['PHP_SELF'] . '?op=Restore&version=' . $v['unixtime'] . '&file_hash=' . $this->_fileHash()); ?>"><?php echo _("Restore"); ?></a></td> 368 380 </tr> 369 381 <?php … … 386 398 function _fileHash() 387 399 { 388 return md5(App::getParam('signing_key') . $_SERVER['PHP_SELF']); 400 $app =& App::getInstance(); 401 402 return md5($app->getParam('signing_key') . $_SERVER['PHP_SELF']); 389 403 } 390 404 … … 399 413 function _loadDataFile() 400 414 { 415 $app =& App::getInstance(); 416 401 417 if (!file_exists($this->_data_file)) { 402 418 if (!$this->_initializeDataFile()) { 403 App::logMsg(sprintf('Initializing content file failed: %s', $this->_data_file), LOG_WARNING, __FILE__, __LINE__);419 $app->logMsg(sprintf('Initializing content file failed: %s', $this->_data_file), LOG_WARNING, __FILE__, __LINE__); 404 420 return false; 405 421 } … … 408 424 $status = $this->xml_unserializer->unserialize($xml_file_contents, false); 409 425 if (PEAR::isError($status)) { 410 App::logMsg(sprintf('XML_Unserialize error: %s', $status->getMessage()), LOG_WARNING, __FILE__, __LINE__);426 $app->logMsg(sprintf('XML_Unserialize error: %s', $status->getMessage()), LOG_WARNING, __FILE__, __LINE__); 411 427 return false; 412 428 } … … 436 452 function _initializeDataFile() 437 453 { 438 App::logMsg(sprintf('Initializing data file: %s', $this->_data_file), LOG_INFO, __FILE__, __LINE__); 454 $app =& App::getInstance(); 455 456 $app->logMsg(sprintf('Initializing data file: %s', $this->_data_file), LOG_INFO, __FILE__, __LINE__); 439 457 $xml_file_contents = $this->xml_serializer->serialize($this->_data); 440 458 return $this->_filePutContents($this->_data_file, $xml_file_contents); … … 450 468 function _writeData() 451 469 { 470 $app =& App::getInstance(); 471 452 472 if (!$this->_authorized) { 453 473 return false; … … 455 475 if ($this->_fileHash() != getFormData('file_hash')) { 456 476 // Posted data is NOT for this file! 457 App::logMsg(sprintf('File_hash does not match current file.', null), LOG_WARNING, __FILE__, __LINE__);477 $app->logMsg(sprintf('File_hash does not match current file.', null), LOG_WARNING, __FILE__, __LINE__); 458 478 return false; 459 479 } … … 466 486 $this->_deleteOldVersions(); 467 487 if (!$this->_createVersion()) { 468 App::logMsg(sprintf('Failed creating new version of file.', null), LOG_NOTICE, __FILE__, __LINE__);488 $app->logMsg(sprintf('Failed creating new version of file.', null), LOG_NOTICE, __FILE__, __LINE__); 469 489 return false; 470 490 } … … 496 516 function _filePutContents($filename, $content) 497 517 { 518 $app =& App::getInstance(); 519 498 520 // Ensure requested filename is within the pedit data dir. 499 521 if (strpos($filename, $this->getParam('data_dir')) === false) { 500 App::logMsg(sprintf('Failed writing file outside pedit _data_dir: %s', $filename), LOG_ERR, __FILE__, __LINE__);522 $app->logMsg(sprintf('Failed writing file outside pedit _data_dir: %s', $filename), LOG_ERR, __FILE__, __LINE__); 501 523 return false; 502 524 } … … 510 532 if (!is_dir($curr_path)) { 511 533 if (!mkdir($curr_path)) { 512 App::logMsg(sprintf('Failed mkdir: %s', $curr_path), LOG_ERR, __FILE__, __LINE__);534 $app->logMsg(sprintf('Failed mkdir: %s', $curr_path), LOG_ERR, __FILE__, __LINE__); 513 535 return false; 514 536 } … … 522 544 flock($fp, LOCK_UN); 523 545 } else { 524 App::logMsg(sprintf('Could not lock file for writing: %s', $filename), LOG_ERR, __FILE__, __LINE__);546 $app->logMsg(sprintf('Could not lock file for writing: %s', $filename), LOG_ERR, __FILE__, __LINE__); 525 547 return false; 526 548 } 527 549 fclose($fp); 528 550 // Success! 529 App::logMsg(sprintf('Wrote to file: %s', $filename), LOG_DEBUG, __FILE__, __LINE__);551 $app->logMsg(sprintf('Wrote to file: %s', $filename), LOG_DEBUG, __FILE__, __LINE__); 530 552 return true; 531 553 } else { 532 App::logMsg(sprintf('Could not open file for writing: %s', $filename), LOG_ERR, __FILE__, __LINE__);554 $app->logMsg(sprintf('Could not open file for writing: %s', $filename), LOG_ERR, __FILE__, __LINE__); 533 555 return false; 534 556 } … … 544 566 function _createVersion() 545 567 { 568 $app =& App::getInstance(); 569 546 570 if (!$this->_authorized) { 547 571 return false; … … 549 573 if ($this->_fileHash() != getFormData('file_hash')) { 550 574 // Posted data is NOT for this file! 551 App::logMsg(sprintf('File_hash does not match current file.', null), LOG_ERR, __FILE__, __LINE__);575 $app->logMsg(sprintf('File_hash does not match current file.', null), LOG_ERR, __FILE__, __LINE__); 552 576 return false; 553 577 } … … 555 579 // Ensure current data file exists. 556 580 if (!file_exists($this->_data_file)) { 557 App::logMsg(sprintf('Data file does not yet exist: %s', $this->_data_file), LOG_NOTICE, __FILE__, __LINE__);581 $app->logMsg(sprintf('Data file does not yet exist: %s', $this->_data_file), LOG_NOTICE, __FILE__, __LINE__); 558 582 return false; 559 583 } … … 563 587 $version_file = sprintf('%s__%s.xml', preg_replace('/\.xml$/', '', $this->_data_file), time()); 564 588 if (!copy($this->_data_file, $version_file)) { 565 App::logMsg(sprintf('Failed copying new version: %s -> %s', $this->_data_file, $version_file), LOG_ERR, __FILE__, __LINE__);589 $app->logMsg(sprintf('Failed copying new version: %s -> %s', $this->_data_file, $version_file), LOG_ERR, __FILE__, __LINE__); 566 590 return false; 567 591 } … … 580 604 function _deleteOldVersions() 581 605 { 606 $app =& App::getInstance(); 607 582 608 $version_files = $this->_getVersions(); 583 609 if (is_array($version_files) && sizeof($version_files) > $this->getParam('versions_min_qty')) { … … 590 616 $del_file = dirname($this->_data_file) . '/' . $oldest['filename']; 591 617 if (!unlink($del_file)) { 592 App::logMsg(sprintf('Failed deleting version: %s', $del_file), LOG_ERR, __FILE__, __LINE__);618 $app->logMsg(sprintf('Failed deleting version: %s', $del_file), LOG_ERR, __FILE__, __LINE__); 593 619 } 594 620 $oldest = array_pop($version_files); … … 637 663 function _restoreVersion($version) 638 664 { 665 $app =& App::getInstance(); 666 639 667 if (!$this->_authorized) { 640 668 return false; … … 646 674 // Ensure specified version exists. 647 675 if (!file_exists($version_file)) { 648 App::logMsg(sprintf('Cannot restore non-existant file: %s', $version_file), LOG_NOTICE, __FILE__, __LINE__);676 $app->logMsg(sprintf('Cannot restore non-existant file: %s', $version_file), LOG_NOTICE, __FILE__, __LINE__); 649 677 return false; 650 678 } … … 652 680 // Make certain a version is created. 653 681 if (!$this->_createVersion()) { 654 App::logMsg(sprintf('Failed creating new version of file.', null), LOG_ERR, __FILE__, __LINE__);682 $app->logMsg(sprintf('Failed creating new version of file.', null), LOG_ERR, __FILE__, __LINE__); 655 683 return false; 656 684 } … … 658 686 // Do the actual copy. 659 687 if (!copy($version_file, $this->_data_file)) { 660 App::logMsg(sprintf('Failed copying old version: %s -> %s', $version_file, $this->_data_file), LOG_ERR, __FILE__, __LINE__);688 $app->logMsg(sprintf('Failed copying old version: %s -> %s', $version_file, $this->_data_file), LOG_ERR, __FILE__, __LINE__); 661 689 return false; 662 690 } 663 691 664 692 // Success! 665 App::raiseMsg(sprintf(_("Page has been restored to version %s."), $version), MSG_SUCCESS, __FILE__, __LINE__);693 $app->raiseMsg(sprintf(_("Page has been restored to version %s."), $version), MSG_SUCCESS, __FILE__, __LINE__); 666 694 return true; 667 695 } -
branches/2.0singleton/lib/PageNumbers.inc.php
r111 r128 137 137 function calculate() 138 138 { 139 $app =& App::getInstance(); 140 139 141 if (!$this->set_per_page_initialized) { 140 App::logMsg(sprintf('set_per_page not initialized'), LOG_ERR, __FILE__, __LINE__);142 $app->logMsg(sprintf('set_per_page not initialized'), LOG_ERR, __FILE__, __LINE__); 141 143 } 142 144 if (!$this->set_page_number_initialized) { 143 App::logMsg(sprintf('set_page_number not initialized'), LOG_ERR, __FILE__, __LINE__);145 $app->logMsg(sprintf('set_page_number not initialized'), LOG_ERR, __FILE__, __LINE__); 144 146 } 145 147 if (!$this->set_total_items_initialized) { 146 App::logMsg(sprintf('set_total_items not initialized'), LOG_ERR, __FILE__, __LINE__);148 $app->logMsg(sprintf('set_total_items not initialized'), LOG_ERR, __FILE__, __LINE__); 147 149 } 148 150 … … 189 191 function getLimitSQL() 190 192 { 193 $app =& App::getInstance(); 194 191 195 if (is_numeric($this->first_item) && is_numeric($this->_per_page)) { 192 196 return ' LIMIT ' . DB::escapeString($this->first_item) . ', ' . DB::escapeString($this->_per_page) . ' '; 193 197 } else { 194 App::logMsg(sprintf('Could not find SQL to LIMIT by %s %s.', $this->first_item, $this->_per_page), LOG_WARNING, __FILE__, __LINE__);198 $app->logMsg(sprintf('Could not find SQL to LIMIT by %s %s.', $this->first_item, $this->_per_page), LOG_WARNING, __FILE__, __LINE__); 195 199 return ''; 196 200 } … … 204 208 function printPerPageLinks($query_key='per_page') 205 209 { 210 $app =& App::getInstance(); 211 206 212 $sp = ''; 207 213 for ($i=0; $i<sizeof($this->per_page_options); $i++) { … … 209 215 printf('%s<a href="%s">%s</a>', 210 216 $sp, 211 App::oHREF($_SERVER['PHP_SELF'] . '?' . $query_key . '=' . $this->per_page_options[$i]),217 $app->oHREF($_SERVER['PHP_SELF'] . '?' . $query_key . '=' . $this->per_page_options[$i]), 212 218 $this->per_page_options[$i] 213 219 ); … … 220 226 221 227 /** 222 * Outputs an App::oHREF compatible url that goes to the page $page_number.228 * Outputs an $app->oHREF compatible url that goes to the page $page_number. 223 229 * Depends on $this->base_url to build the url onto. This is used in the 224 230 * page_number.ihtml template. … … 232 238 function getPageNumURL($page_number, $carry_args=null) 233 239 { 234 return App::oHREF($this->url_base . $page_number, $carry_args); 240 $app =& App::getInstance(); 241 242 return $app->oHREF($this->url_base . $page_number, $carry_args); 235 243 } 236 244 function printPageNumURL($page_number, $carry_args=null) -
branches/2.0singleton/lib/PageSequence.inc.php
r42 r128 133 133 function setCurrent($step_id) 134 134 { 135 $app =& App::getInstance(); 136 135 137 if (false !== ($pos = $this->getPosition($step_id))) { 136 138 // Specified step exists (even if numeric). … … 138 140 } else { 139 141 // Step with specified key does not exist. 140 App::logMsg(sprintf(_("Step %s not defined in sequence %s"), $step_id, $this->sequence_title), LOG_INFO, __FILE__, __LINE__);142 $app->logMsg(sprintf(_("Step %s not defined in sequence %s"), $step_id, $this->sequence_title), LOG_INFO, __FILE__, __LINE__); 141 143 return false; 142 144 } … … 257 259 function printEditLink($step_id=null) 258 260 { 261 $app =& App::getInstance(); 262 259 263 $pos = isset($step_id) ? $this->getPosition($step_id) : $this->getPosition(); 260 264 if ($_SESSION[$this->seq]['steps'][$pos]['editable']) { 261 printf('[<a href="%s">%s</a>]', App::oHREF($_SERVER['PHP_SELF'] . '?step=' . $pos . '&boomerang=confirmation'), _("edit"));265 printf('[<a href="%s">%s</a>]', $app->oHREF($_SERVER['PHP_SELF'] . '?step=' . $pos . '&boomerang=confirmation'), _("edit")); 262 266 } 263 267 } … … 320 324 function _auto_timeout() 321 325 { 326 $app =& App::getInstance(); 327 322 328 if (isset($_SESSION[$this->seq]['last_access_time']) 323 329 && $_SESSION[$this->seq]['last_access_time'] < time() - $this->idle_timeout) { 324 330 // Session has expired, flush all vars to start over. 325 331 $this->startOver(); 326 App::dieURL($this->start_url);332 $app->dieURL($this->start_url); 327 333 } else { 328 334 // Set timer. -
branches/2.0singleton/lib/PayPal.inc.php
r42 r128 74 74 function setButtonDefaults($type, $options) 75 75 { 76 $app =& App::getInstance(); 77 76 78 if (!is_array($options) || empty($options)) { 77 App::logMsg(sprintf('Invalid options: %s', getDump($options)), LOG_WARNING, __FILE__, __LINE__);79 $app->logMsg(sprintf('Invalid options: %s', getDump($options)), LOG_WARNING, __FILE__, __LINE__); 78 80 return false; 79 81 } … … 82 84 $this->_default_button_options['_global'] = array_merge($this->_default_button_options['_global'], $options); 83 85 } else if (!isset($this->_default_button_options[$type])) { 84 App::logMsg(sprintf('Invalid button type: %s', $type), LOG_WARNING, __FILE__, __LINE__);86 $app->logMsg(sprintf('Invalid button type: %s', $type), LOG_WARNING, __FILE__, __LINE__); 85 87 return false; 86 88 } … … 104 106 function newButton($type, $name, $options=null) 105 107 { 108 $app =& App::getInstance(); 109 106 110 if (!isset($this->_default_button_options[$type])) { 107 App::logMsg(sprintf('Invalid button type: %s', $type), LOG_WARNING, __FILE__, __LINE__);111 $app->logMsg(sprintf('Invalid button type: %s', $type), LOG_WARNING, __FILE__, __LINE__); 108 112 return false; 109 113 } 110 114 111 115 if (!is_array($options) || empty($options)) { 112 App::logMsg(sprintf('Invalid options: %s', getDump($options)), LOG_WARNING, __FILE__, __LINE__);116 $app->logMsg(sprintf('Invalid options: %s', getDump($options)), LOG_WARNING, __FILE__, __LINE__); 113 117 return false; 114 118 } 115 119 116 120 if (isset($this->_buttons[$name])) { 117 App::logMsg(sprintf('Overwriting existing button name: %s', getDump($this->_buttons[$name])), LOG_DEBUG, __FILE__, __LINE__);121 $app->logMsg(sprintf('Overwriting existing button name: %s', getDump($this->_buttons[$name])), LOG_DEBUG, __FILE__, __LINE__); 118 122 } 119 123 … … 137 141 function getLink($name) 138 142 { 143 $app =& App::getInstance(); 144 139 145 if (!isset($this->_buttons[$name])) { 140 App::logMsg(sprintf('Button does not exist: %s', $name), LOG_WARNING, __FILE__, __LINE__);146 $app->logMsg(sprintf('Button does not exist: %s', $name), LOG_WARNING, __FILE__, __LINE__); 141 147 return false; 142 148 } … … 207 213 function setParam($params) 208 214 { 215 $app =& App::getInstance(); 216 209 217 if (isset($params) && is_array($params)) { 210 218 // Merge new parameters with old overriding only those passed. 211 219 $this->_params = array_merge($this->_params, $params); 212 220 } else { 213 App::logMsg(sprintf('Parameters are not an array: %s', $params), LOG_ERR, __FILE__, __LINE__);221 $app->logMsg(sprintf('Parameters are not an array: %s', $params), LOG_ERR, __FILE__, __LINE__); 214 222 } 215 223 } … … 224 232 function getParam($param) 225 233 { 234 $app =& App::getInstance(); 235 226 236 if (isset($this->_params[$param])) { 227 237 return $this->_params[$param]; 228 238 } else { 229 App::logMsg(sprintf('Parameter is not set: %s', $param), LOG_DEBUG, __FILE__, __LINE__);239 $app->logMsg(sprintf('Parameter is not set: %s', $param), LOG_DEBUG, __FILE__, __LINE__); 230 240 return null; 231 241 } … … 259 269 function processIPN() 260 270 { 271 $app =& App::getInstance(); 272 261 273 if (getPost('test_ipn') == '1' || $this->getParam('test_mode')) { 262 App::logMsg(sprintf('Processing PayPal IPN in test mode: %s', getDump(getFormData())), LOG_DEBUG, __FILE__, __LINE__);274 $app->logMsg(sprintf('Processing PayPal IPN in test mode: %s', getDump(getFormData())), LOG_DEBUG, __FILE__, __LINE__); 263 275 $url = parse_url('https://www.sandbox.paypal.com/cgi-bin/webscr'); 264 276 } else { 265 App::logMsg(sprintf('Processing PayPal IPN: %s', getDump(getFormData())), LOG_DEBUG, __FILE__, __LINE__);277 $app->logMsg(sprintf('Processing PayPal IPN: %s', getDump(getFormData())), LOG_DEBUG, __FILE__, __LINE__); 266 278 $url = parse_url($this->getParam('paypal_url')); 267 279 } … … 287 299 288 300 if (!$fp) { 289 App::logMsg(sprintf('Connection to PayPal URL %s failed with error: %s (%s)', $ssl . $url['host'], $errstr, $errnum), LOG_WARNING, __FILE__, __LINE__);301 $app->logMsg(sprintf('Connection to PayPal URL %s failed with error: %s (%s)', $ssl . $url['host'], $errstr, $errnum), LOG_WARNING, __FILE__, __LINE__); 290 302 return false; 291 303 } else { … … 304 316 fclose($fp); 305 317 306 App::logMsg(sprintf('IPN response received: %s', $this->_ipn_response), LOG_NOTICE, __FILE__, __LINE__);318 $app->logMsg(sprintf('IPN response received: %s', $this->_ipn_response), LOG_NOTICE, __FILE__, __LINE__); 307 319 return true; 308 320 } … … 318 330 function verifiedIPN() 319 331 { 332 $app =& App::getInstance(); 333 320 334 if (!isset($this->_ipn_response)) { 321 App::logMsg(sprintf('Cannot verify IPN, response not received.', null), LOG_WARNING, __FILE__, __LINE__);335 $app->logMsg(sprintf('Cannot verify IPN, response not received.', null), LOG_WARNING, __FILE__, __LINE__); 322 336 return false; 323 337 } 324 338 325 339 if (empty($this->_ipn_response)) { 326 App::logMsg(sprintf('Cannot verify IPN, response empty.', null), LOG_WARNING, __FILE__, __LINE__);340 $app->logMsg(sprintf('Cannot verify IPN, response empty.', null), LOG_WARNING, __FILE__, __LINE__); 327 341 return false; 328 342 } 329 343 330 344 if (preg_match('/VERIFIED/', $this->_ipn_response)) { 331 App::logMsg(sprintf('IPN verified!', null), LOG_DEBUG, __FILE__, __LINE__);345 $app->logMsg(sprintf('IPN verified!', null), LOG_DEBUG, __FILE__, __LINE__); 332 346 return true; 333 347 } else if (preg_match('/INVALID/', $this->_ipn_response)) { 334 App::logMsg(sprintf('IPN invalid.', null), LOG_DEBUG, __FILE__, __LINE__);335 return false; 336 } else { 337 App::logMsg(sprintf('IPN unknown.', null), LOG_WARNING, __FILE__, __LINE__);348 $app->logMsg(sprintf('IPN invalid.', null), LOG_DEBUG, __FILE__, __LINE__); 349 return false; 350 } else { 351 $app->logMsg(sprintf('IPN unknown.', null), LOG_WARNING, __FILE__, __LINE__); 338 352 return false; 339 353 } -
branches/2.0singleton/lib/Prefs.inc.php
r42 r128 207 207 function store($prefs=array()) 208 208 { 209 $app =& App::getInstance(); 210 209 211 // If we are not storing prefs in perpetually. 210 212 if (!$_perpetual) { … … 223 225 224 226 if (!is_array($prefs) || empty($prefs)) { 225 App::raiseMsg(_("No preferences are available."), MSG_ERR, __FILE__, __LINE__);226 App::dieBoomerangURL();227 $app->raiseMsg(_("No preferences are available."), MSG_ERR, __FILE__, __LINE__); 228 $app->dieBoomerangURL(); 227 229 } 228 230 -
branches/2.0singleton/lib/RecordLock.inc.php
r111 r128 48 48 function RecordLock($auth_object) 49 49 { 50 $app =& App::getInstance(); 51 50 52 if (!is_a($auth_object, 'Auth_SQL')) { 51 53 trigger_error('Constructor not provided a valid Auth_SQL object.', E_USER_ERROR); … … 55 57 56 58 // Get create tables config from global context. 57 if (!is_null( App::getParam('db_create_tables'))) {58 $this->setParam(array('create_table' => App::getParam('db_create_tables')));59 if (!is_null($app->getParam('db_create_tables'))) { 60 $this->setParam(array('create_table' => $app->getParam('db_create_tables'))); 59 61 } 60 62 } … … 69 71 function initDB($recreate_db=false) 70 72 { 73 $app =& App::getInstance(); 74 71 75 static $_db_tested = false; 72 76 … … 74 78 if ($recreate_db) { 75 79 DB::query("DROP TABLE IF EXISTS " . $this->getParam('db_table')); 76 App::logMsg(sprintf('Dropping and recreating table %s.', $this->getParam('db_table')), LOG_DEBUG, __FILE__, __LINE__);80 $app->logMsg(sprintf('Dropping and recreating table %s.', $this->getParam('db_table')), LOG_DEBUG, __FILE__, __LINE__); 77 81 } 78 82 DB::query("CREATE TABLE IF NOT EXISTS " . $this->getParam('db_table') . " ( … … 99 103 'lock_datetime', 100 104 ), false, false)) { 101 App::logMsg(sprintf('Database table %s has invalid columns. Please update this table manually.', $this->getParam('db_table')), LOG_ALERT, __FILE__, __LINE__);105 $app->logMsg(sprintf('Database table %s has invalid columns. Please update this table manually.', $this->getParam('db_table')), LOG_ALERT, __FILE__, __LINE__); 102 106 trigger_error(sprintf('Database table %s has invalid columns. Please update this table manually.', $this->getParam('db_table')), E_USER_ERROR); 103 107 } … … 128 132 function getParam($param) 129 133 { 134 $app =& App::getInstance(); 135 130 136 if (isset($this->_params[$param])) { 131 137 return $this->_params[$param]; 132 138 } else { 133 App::logMsg(sprintf('Parameter is not set: %s', $param), LOG_DEBUG, __FILE__, __LINE__);139 $app->logMsg(sprintf('Parameter is not set: %s', $param), LOG_DEBUG, __FILE__, __LINE__); 134 140 return null; 135 141 } … … 147 153 function select($record_table_or_lock_id, $record_key=null, $record_val=null) 148 154 { 155 $app =& App::getInstance(); 156 149 157 $this->initDB(); 150 158 … … 168 176 } 169 177 if ($this->data = mysql_fetch_assoc($qid)) { 170 App::logMsg(sprintf('Selecting %slocked record: %s %s %s', ($this->data['set_by_admin_id'] == $this->_auth->getVal('user_id') ? 'self-' : ''), $record_table_or_lock_id, $record_key, $record_val), LOG_DEBUG, __FILE__, __LINE__);178 $app->logMsg(sprintf('Selecting %slocked record: %s %s %s', ($this->data['set_by_admin_id'] == $this->_auth->getVal('user_id') ? 'self-' : ''), $record_table_or_lock_id, $record_key, $record_val), LOG_DEBUG, __FILE__, __LINE__); 171 179 /// FIX ME: What if admin set lock, but public user is current lock user? 172 180 $this->data['editor'] = $this->_auth->getUsername($this->data['set_by_admin_id']); 173 181 return true; 174 182 } else { 175 App::logMsg(sprintf('No locked record: %s %s %s', $record_table_or_lock_id, $record_key, $record_val), LOG_DEBUG, __FILE__, __LINE__);183 $app->logMsg(sprintf('No locked record: %s %s %s', $record_table_or_lock_id, $record_key, $record_val), LOG_DEBUG, __FILE__, __LINE__); 176 184 return false; 177 185 } … … 266 274 function remove() 267 275 { 276 $app =& App::getInstance(); 277 268 278 $this->initDB(); 269 279 … … 277 287 "); 278 288 279 App::logMsg(sprintf('Removing lock: %s', $this->data['lock_id']), LOG_DEBUG, __FILE__, __LINE__);289 $app->logMsg(sprintf('Removing lock: %s', $this->data['lock_id']), LOG_DEBUG, __FILE__, __LINE__); 280 290 } 281 291 … … 285 295 function removeAll($user_id=null) 286 296 { 297 $app =& App::getInstance(); 298 287 299 $this->initDB(); 288 300 … … 293 305 // Delete specific user's locks. 294 306 DB::query("DELETE FROM " . $this->getParam('db_table') . " WHERE set_by_admin_id = '" . DB::escapeString($user_id) . "'"); 295 App::logMsg(sprintf('Record locks owned by %s %s have been deleted', $this->_auth->getVal('auth_name'), $this->_auth->getUsername($user_id)), LOG_DEBUG, __FILE__, __LINE__);307 $app->logMsg(sprintf('Record locks owned by %s %s have been deleted', $this->_auth->getVal('auth_name'), $this->_auth->getUsername($user_id)), LOG_DEBUG, __FILE__, __LINE__); 296 308 } else { 297 309 // Delete ALL locks. 298 310 DB::query("DELETE FROM " . $this->getParam('db_table') . ""); 299 App::logMsg(sprintf('All record locks deleted by %s %s', $this->_auth->getVal('auth_name'), $this->_auth->getVal('username')), LOG_DEBUG, __FILE__, __LINE__);311 $app->logMsg(sprintf('All record locks deleted by %s %s', $this->_auth->getVal('auth_name'), $this->_auth->getVal('username')), LOG_DEBUG, __FILE__, __LINE__); 300 312 } 301 313 } … … 325 337 function dieErrorPage() 326 338 { 327 App::dieURL(sprintf('%s?lock_id=%s&boomerang=%s', $this->getParam('error_url'), $this->data['lock_id'], urlencode(absoluteMe()))); 339 $app =& App::getInstance(); 340 341 $app->dieURL(sprintf('%s?lock_id=%s&boomerang=%s', $this->getParam('error_url'), $this->data['lock_id'], urlencode(absoluteMe()))); 328 342 } 329 343 … … 333 347 function printErrorHTML() 334 348 { 349 $app =& App::getInstance(); 350 335 351 ?> 336 352 <form method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>"> 337 <?php App::printHiddenSession() ?>353 <?php $app->printHiddenSession() ?> 338 354 <input type="hidden" name="lock_id" value="<?php echo $this->getID(); ?>" /> 339 355 -
branches/2.0singleton/lib/RecordVersion.inc.php
r111 r128 55 55 function RecordVersion($auth_object) 56 56 { 57 $app =& App::getInstance(); 58 57 59 if (!is_a($auth_object, 'Auth_SQL')) { 58 60 trigger_error('Constructor not provided a valid Auth_SQL object.', E_USER_ERROR); … … 62 64 63 65 // Get create tables config from global context. 64 if (!is_null( App::getParam('db_create_tables'))) {65 $this->setParam(array('create_table' => App::getParam('db_create_tables')));66 if (!is_null($app->getParam('db_create_tables'))) { 67 $this->setParam(array('create_table' => $app->getParam('db_create_tables'))); 66 68 } 67 69 } … … 76 78 function initDB($recreate_db=false) 77 79 { 80 $app =& App::getInstance(); 81 78 82 static $_db_tested = false; 79 83 … … 81 85 if ($recreate_db) { 82 86 DB::query("DROP TABLE IF EXISTS " . $this->getParam('db_table')); 83 App::logMsg(sprintf('Dropping and recreating table %s.', $this->getParam('db_table')), LOG_DEBUG, __FILE__, __LINE__);87 $app->logMsg(sprintf('Dropping and recreating table %s.', $this->getParam('db_table')), LOG_DEBUG, __FILE__, __LINE__); 84 88 } 85 89 DB::query("CREATE TABLE IF NOT EXISTS " . $this->getParam('db_table') . " ( … … 110 114 'version_datetime', 111 115 ), false, false)) { 112 App::logMsg(sprintf('Database table %s has invalid columns. Please update this table manually.', $this->getParam('db_table')), LOG_ALERT, __FILE__, __LINE__);116 $app->logMsg(sprintf('Database table %s has invalid columns. Please update this table manually.', $this->getParam('db_table')), LOG_ALERT, __FILE__, __LINE__); 113 117 trigger_error(sprintf('Database table %s has invalid columns. Please update this table manually.', $this->getParam('db_table')), E_USER_ERROR); 114 118 } … … 139 143 function getParam($param) 140 144 { 145 $app =& App::getInstance(); 146 141 147 if (isset($this->_params[$param])) { 142 148 return $this->_params[$param]; 143 149 } else { 144 App::logMsg(sprintf('Parameter is not set: %s', $param), LOG_DEBUG, __FILE__, __LINE__);150 $app->logMsg(sprintf('Parameter is not set: %s', $param), LOG_DEBUG, __FILE__, __LINE__); 145 151 return null; 146 152 } … … 159 165 function create($record_table, $record_key, $record_val, $title='', $notes='') 160 166 { 167 $app =& App::getInstance(); 168 161 169 $this->initDB(); 162 170 163 171 // Get current record. 164 172 if (!$record = $this->getCurrent($record_table, $record_key, $record_val)) { 165 App::logMsg(sprintf('Could not create %s version, record not found: %s, %s, %s.', $title, $record_table, $record_key, $record_val), LOG_ERR, __FILE__, __LINE__);173 $app->logMsg(sprintf('Could not create %s version, record not found: %s, %s, %s.', $title, $record_table, $record_key, $record_val), LOG_ERR, __FILE__, __LINE__); 166 174 return false; 167 175 } … … 205 213 function restore($version_id) 206 214 { 215 $app =& App::getInstance(); 216 207 217 $this->initDB(); 208 218 … … 213 223 "); 214 224 if (!$record = mysql_fetch_assoc($qid)) { 215 App::raiseMsg(sprintf(_("Version ID %s%s not found."), $version_id, (empty($record['version_title']) ? '' : ' (' . $record['version_title'] . ')')), MSG_WARNING, __FILE__, __LINE__);216 App::logMsg(sprintf(_("Version ID %s%s not found."), $version_id, (empty($record['version_title']) ? '' : ' (' . $record['version_title'] . ')')), LOG_WARNING, __FILE__, __LINE__);225 $app->raiseMsg(sprintf(_("Version ID %s%s not found."), $version_id, (empty($record['version_title']) ? '' : ' (' . $record['version_title'] . ')')), MSG_WARNING, __FILE__, __LINE__); 226 $app->logMsg(sprintf(_("Version ID %s%s not found."), $version_id, (empty($record['version_title']) ? '' : ' (' . $record['version_title'] . ')')), LOG_WARNING, __FILE__, __LINE__); 217 227 return false; 218 228 } … … 221 231 // Ensure saved db columns match current table schema. 222 232 if (!DB::columnExists($record['record_table'], array_keys($data), $this->getParam('db_schema_strict'))) { 223 App::raiseMsg(sprintf(_("Version ID %s%s is not compatible with the current database table."), $version_id, (empty($record['version_title']) ? '' : ' (' . $record['version_title'] . ')')), MSG_ERR, __FILE__, __LINE__);224 App::logMsg(sprintf(_("Version ID %s%s restoration failed, DB schema does not match for table %s."), $version_id, (empty($record['version_title']) ? '' : ' (' . $record['version_title'] . ')'), $record['record_table']), LOG_ALERT, __FILE__, __LINE__);233 $app->raiseMsg(sprintf(_("Version ID %s%s is not compatible with the current database table."), $version_id, (empty($record['version_title']) ? '' : ' (' . $record['version_title'] . ')')), MSG_ERR, __FILE__, __LINE__); 234 $app->logMsg(sprintf(_("Version ID %s%s restoration failed, DB schema does not match for table %s."), $version_id, (empty($record['version_title']) ? '' : ' (' . $record['version_title'] . ')'), $record['record_table']), LOG_ALERT, __FILE__, __LINE__); 225 235 return false; 226 236 } -
branches/2.0singleton/lib/SessionCache.inc.php
r119 r128 44 44 function setParam($params) 45 45 { 46 $app =& App::getInstance(); 47 46 48 if (!isset($_this) || !is_a($_this, 'SessionCache') && !is_subclass_of($_this, 'SessionCache')) { 47 49 $_this =& SessionCache::getInstance(); … … 52 54 $_this->_params = array_merge($_this->_params, $params); 53 55 } else { 54 App::logMsg(sprintf('Parameters are not an array: %s', $params), LOG_ERR, __FILE__, __LINE__);56 $app->logMsg(sprintf('Parameters are not an array: %s', $params), LOG_ERR, __FILE__, __LINE__); 55 57 } 56 58 } … … 65 67 function getParam($param) 66 68 { 69 $app =& App::getInstance(); 70 67 71 if (!isset($_this) || !is_a($_this, 'SessionCache') && !is_subclass_of($_this, 'SessionCache')) { 68 72 $_this =& SessionCache::getInstance(); … … 72 76 return $_this->_params[$param]; 73 77 } else { 74 App::logMsg(sprintf('Parameter is not set: %s', $param), LOG_DEBUG, __FILE__, __LINE__);78 $app->logMsg(sprintf('Parameter is not set: %s', $param), LOG_DEBUG, __FILE__, __LINE__); 75 79 return null; 76 80 } … … 95 99 function putCache($var, $var_id, $force_it_in=false) 96 100 { 101 $app =& App::getInstance(); 102 97 103 if (!isset($_this) || !is_a($_this, 'SessionCache') && !is_subclass_of($_this, 'SessionCache')) { 98 104 $_this =& SessionCache::getInstance(); … … 100 106 101 107 if (!$_this->getParam('enabled')) { 102 App::logMsg(sprintf('SessionCache not enabled, not saving data.', null), LOG_DEBUG, __FILE__, __LINE__);108 $app->logMsg(sprintf('SessionCache not enabled, not saving data.', null), LOG_DEBUG, __FILE__, __LINE__); 103 109 return false; 104 110 } … … 109 115 110 116 if ($serialized_var_len >= $_this->getParam('soft_limit') && !$force_it_in) { 111 App::logMsg(sprintf('Serialized variable (%s bytes) more than soft_limit (%s bytes).', $serialized_var_len, $_this->getParam('soft_limit')), LOG_NOTICE, __FILE__, __LINE__);117 $app->logMsg(sprintf('Serialized variable (%s bytes) more than soft_limit (%s bytes).', $serialized_var_len, $_this->getParam('soft_limit')), LOG_NOTICE, __FILE__, __LINE__); 112 118 return false; 113 119 } 114 120 115 121 if ($serialized_var_len >= $_this->getParam('hard_limit')) { 116 App::logMsg(sprintf('Serialized variable (%s bytes) more than hard_limit (%s bytes).', $serialized_var_len, $_this->getParam('hard_limit')), LOG_NOTICE, __FILE__, __LINE__);122 $app->logMsg(sprintf('Serialized variable (%s bytes) more than hard_limit (%s bytes).', $serialized_var_len, $_this->getParam('hard_limit')), LOG_NOTICE, __FILE__, __LINE__); 117 123 return false; 118 124 } … … 131 137 132 138 if ($serialized_var_len >= 1024000) { 133 App::logMsg(sprintf('Successfully cached oversized variable (%s bytes).', $serialized_var_len), LOG_DEBUG, __FILE__, __LINE__);139 $app->logMsg(sprintf('Successfully cached oversized variable (%s bytes).', $serialized_var_len), LOG_DEBUG, __FILE__, __LINE__); 134 140 } 135 141 -
branches/2.0singleton/lib/SortOrder.inc.php
r119 r128 128 128 function getSortOrderSQL() 129 129 { 130 $app =& App::getInstance(); 131 130 132 if (!isset($this->_columns[strtolower($this->sort_by)])) { 131 133 $this->sort_by = $this->default_sort; … … 139 141 return sprintf(' ORDER BY %s ', DB::escapeString($this->_columns[strtolower($this->sort_by)][strtolower($this->order)])); 140 142 } else { 141 App::logMsg(sprintf('Could not find SQL to sort by %s %s.', $this->sort_by, $this->order), LOG_WARNING, __FILE__, __LINE__);143 $app->logMsg(sprintf('Could not find SQL to sort by %s %s.', $this->sort_by, $this->order), LOG_WARNING, __FILE__, __LINE__); 142 144 return ''; 143 145 } … … 155 157 function printSortHeader($col, $col_name, $default_order='ASC') 156 158 { 159 $app =& App::getInstance(); 160 157 161 if ($this->sort_by == $col) { 158 162 if (strtolower($this->order) == 'desc') { 159 ?><a href="<?php echo App::oHREF($_SERVER['PHP_SELF'] . '?sort=' . $col . '&order=ASC'); ?>" title="<?php echo _("Change to ascending sort order"); ?>"><?php echo $this->desc_widget; ?></a><?php echo $col_name; ?><?php163 ?><a href="<?php echo $app->oHREF($_SERVER['PHP_SELF'] . '?sort=' . $col . '&order=ASC'); ?>" title="<?php echo _("Change to ascending sort order"); ?>"><?php echo $this->desc_widget; ?></a><?php echo $col_name; ?><?php 160 164 } else { 161 ?><a href="<?php echo App::oHREF($_SERVER['PHP_SELF'] . '?sort=' . $col . '&order=DESC'); ?>" title="<?php echo _("Change to descending sort order"); ?>"><?php echo $this->asc_widget; ?></a><?php echo $col_name; ?><?php165 ?><a href="<?php echo $app->oHREF($_SERVER['PHP_SELF'] . '?sort=' . $col . '&order=DESC'); ?>" title="<?php echo _("Change to descending sort order"); ?>"><?php echo $this->asc_widget; ?></a><?php echo $col_name; ?><?php 162 166 } 163 167 } else { 164 ?><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><?php168 ?><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 165 169 } 166 170 } -
branches/2.0singleton/lib/SpellCheck.inc.php
r42 r128 62 62 function SpellCheck($params) 63 63 { 64 $app =& App::getInstance(); 65 64 66 if (!is_array($params) || empty($params)) { 65 67 trigger_error('SpellCheck parameters not set properly', E_USER_ERROR); … … 75 77 if ('' != $this->getParam('personal_wordlist')) { 76 78 if (!is_writable(dirname($this->getParam('personal_wordlist'))) || !is_writable($this->getParam('personal_wordlist'))) { 77 App::logMsg(sprintf('Personal wordlist file not writable: %s', $this->getParam('personal_wordlist')), LOG_WARNING, __FILE__, __LINE__);79 $app->logMsg(sprintf('Personal wordlist file not writable: %s', $this->getParam('personal_wordlist')), LOG_WARNING, __FILE__, __LINE__); 78 80 } else { 79 81 pspell_config_personal($this->_pspell_cfg_handle, $this->getParam('personal_wordlist')); 80 82 $this->_use_personal_wordlist = true; 81 App::logMsg(sprintf('Using personal wordlist: %s', $this->getParam('personal_wordlist')), LOG_DEBUG, __FILE__, __LINE__);83 $app->logMsg(sprintf('Using personal wordlist: %s', $this->getParam('personal_wordlist')), LOG_DEBUG, __FILE__, __LINE__); 82 84 } 83 85 } … … 94 96 function setParam($params) 95 97 { 98 $app =& App::getInstance(); 99 96 100 if (isset($params) && is_array($params)) { 97 101 // Merge new parameters with old overriding only those passed. 98 102 $this->_params = array_merge($this->_params, $params); 99 103 } else { 100 App::logMsg(sprintf('Parameters are not an array: %s', $params), LOG_ERR, __FILE__, __LINE__);104 $app->logMsg(sprintf('Parameters are not an array: %s', $params), LOG_ERR, __FILE__, __LINE__); 101 105 } 102 106 } … … 111 115 function getParam($param) 112 116 { 117 $app =& App::getInstance(); 118 113 119 if (isset($this->_params[$param])) { 114 120 return $this->_params[$param]; 115 121 } else { 116 App::logMsg(sprintf('Parameter is not set: %s', $param), LOG_DEBUG, __FILE__, __LINE__);122 $app->logMsg(sprintf('Parameter is not set: %s', $param), LOG_DEBUG, __FILE__, __LINE__); 117 123 return null; 118 124 } … … 184 190 function add($word) 185 191 { 192 $app =& App::getInstance(); 193 186 194 if ($this->_use_personal_wordlist) { 187 195 if (pspell_add_to_personal($this->_pspell_handle, $word)) { 188 App::logMsg(sprintf('Added "%s" to personal wordlist: %s', $word, $this->getParam('personal_wordlist')), LOG_DEBUG, __FILE__, __LINE__);196 $app->logMsg(sprintf('Added "%s" to personal wordlist: %s', $word, $this->getParam('personal_wordlist')), LOG_DEBUG, __FILE__, __LINE__); 189 197 return true; 190 198 } else { 191 App::logMsg(sprintf('Failed adding "%s" to personal wordlist: %s', $word, $this->getParam('personal_wordlist')), LOG_WARNING, __FILE__, __LINE__);199 $app->logMsg(sprintf('Failed adding "%s" to personal wordlist: %s', $word, $this->getParam('personal_wordlist')), LOG_WARNING, __FILE__, __LINE__); 192 200 return false; 193 201 } … … 207 215 function save() 208 216 { 217 $app =& App::getInstance(); 218 209 219 if ($this->_use_personal_wordlist) { 210 220 if (pspell_save_wordlist($this->_pspell_handle)) { 211 App::logMsg(sprintf('Saved personal wordlist: %s', $this->getParam('personal_wordlist')), LOG_DEBUG, __FILE__, __LINE__);221 $app->logMsg(sprintf('Saved personal wordlist: %s', $this->getParam('personal_wordlist')), LOG_DEBUG, __FILE__, __LINE__); 212 222 return true; 213 223 } else { 214 App::logMsg(sprintf('Failed saving personal wordlist: %s', $this->getParam('personal_wordlist')), LOG_ERR, __FILE__, __LINE__);224 $app->logMsg(sprintf('Failed saving personal wordlist: %s', $this->getParam('personal_wordlist')), LOG_ERR, __FILE__, __LINE__); 215 225 return false; 216 226 } -
branches/2.0singleton/lib/TemplateGlue.inc.php
r111 r128 66 66 function getSetEnumFieldValues($db_table, $db_col) 67 67 { 68 $app =& App::getInstance(); 69 68 70 $qid = DB::query("SHOW COLUMNS FROM " . DB::escapeString($db_table) . " LIKE '" . DB::escapeString($db_col) . "'",false); 69 71 … … 72 74 return $enum[1]; 73 75 } else { 74 App::logMsg(sprintf('No set or enum fields found.', null), LOG_ERR, __FILE__, __LINE__);76 $app->logMsg(sprintf('No set or enum fields found.', null), LOG_ERR, __FILE__, __LINE__); 75 77 return false; 76 78 } -
branches/2.0singleton/lib/Upload.inc.php
r121 r128 56 56 function setParam($params) 57 57 { 58 $app =& App::getInstance(); 59 58 60 if (isset($params) && is_array($params)) { 59 61 … … 63 65 // Must be directory. 64 66 if (!is_dir($params['upload_path'])) { 65 App::logMsg(sprintf('Attempting to auto-create upload directory: %s', $params['upload_path']), LOG_NOTICE, __FILE__, __LINE__);67 $app->logMsg(sprintf('Attempting to auto-create upload directory: %s', $params['upload_path']), LOG_NOTICE, __FILE__, __LINE__); 66 68 mkdir($params['upload_path'], $this->getParam('dest_dir_perms')); 67 69 if (!is_dir($params['upload_path'])) { 68 App::logMsg(sprintf('Upload directory invalid: %s', $params['upload_path']), LOG_ERR, __FILE__, __LINE__);70 $app->logMsg(sprintf('Upload directory invalid: %s', $params['upload_path']), LOG_ERR, __FILE__, __LINE__); 69 71 trigger_error(sprintf('Upload directory invalid: %s', $params['upload_path']), E_USER_ERROR); 70 72 } … … 72 74 // Must be writable. 73 75 if (!is_writable($params['upload_path'])) { 74 App::logMsg(sprintf('Upload directory not writable: %s', $params['upload_path']), LOG_ERR, __FILE__, __LINE__);76 $app->logMsg(sprintf('Upload directory not writable: %s', $params['upload_path']), LOG_ERR, __FILE__, __LINE__); 75 77 trigger_error(sprintf('Upload directory not writable: %s', $params['upload_path']), E_USER_ERROR); 76 78 } … … 80 82 $this->_params = array_merge($this->_params, $params); 81 83 } else { 82 App::logMsg(sprintf('Parameters are not an array: %s', $params), LOG_ERR, __FILE__, __LINE__);84 $app->logMsg(sprintf('Parameters are not an array: %s', $params), LOG_ERR, __FILE__, __LINE__); 83 85 } 84 86 } … … 93 95 function getParam($param) 94 96 { 97 $app =& App::getInstance(); 98 95 99 if (isset($this->_params[$param])) { 96 100 return $this->_params[$param]; 97 101 } else { 98 App::logMsg(sprintf('Parameter is not set: %s', $param), LOG_DEBUG, __FILE__, __LINE__);102 $app->logMsg(sprintf('Parameter is not set: %s', $param), LOG_DEBUG, __FILE__, __LINE__); 99 103 return null; 100 104 } … … 117 121 function process($form_name, $custom_file_name=null) 118 122 { 123 $app =& App::getInstance(); 124 119 125 // Ensure we have a upload directory. 120 126 if (!$this->getParam('upload_path')) { 121 App::logMsg(sprintf('Upload directory not set before processing.'), LOG_ERR, __FILE__, __LINE__);127 $app->logMsg(sprintf('Upload directory not set before processing.'), LOG_ERR, __FILE__, __LINE__); 122 128 $this->_raiseMsg(_("There was a problem with the file upload. Please try again later."), MSG_ERR, __FILE__, __LINE__); 123 129 return false; … … 126 132 // Ensure the file form element specified actually exists. 127 133 if (!isset($_FILES[$form_name])) { 128 App::logMsg(sprintf(_("Form element %s does not exist."), $form_name), LOG_ERR, __FILE__, __LINE__);134 $app->logMsg(sprintf(_("Form element %s does not exist."), $form_name), LOG_ERR, __FILE__, __LINE__); 129 135 $this->_raiseMsg(_("There was a problem with the file upload. Please try again later."), MSG_ERR, __FILE__, __LINE__); 130 136 return false; … … 167 173 $file_name = $custom_file_name; 168 174 $this->_raiseMsg(sprintf(_("The file %s has been renamed to %s."), $files['name'][$i], $file_name), MSG_NOTICE, __FILE__, __LINE__); 169 App::logMsg(sprintf('Using custom file name: %s', $file_name), LOG_DEBUG, __FILE__, __LINE__);175 $app->logMsg(sprintf('Using custom file name: %s', $file_name), LOG_DEBUG, __FILE__, __LINE__); 170 176 } else { 171 177 // Invalid custom file name provided. Use uploaded file name. 172 178 $file_name = $files['name'][$i]; 173 App::logMsg(sprintf('Using uploaded file name: %s', $file_name), LOG_DEBUG, __FILE__, __LINE__);179 $app->logMsg(sprintf('Using uploaded file name: %s', $file_name), LOG_DEBUG, __FILE__, __LINE__); 174 180 } 175 181 } else { … … 179 185 $file_name = $custom_file_name[$i]; 180 186 $this->_raiseMsg(sprintf(_("The file %s has been renamed to %s."), $files['name'][$i], $file_name), MSG_NOTICE, __FILE__, __LINE__); 181 App::logMsg(sprintf('Using custom file name: %s', $file_name), LOG_DEBUG, __FILE__, __LINE__);187 $app->logMsg(sprintf('Using custom file name: %s', $file_name), LOG_DEBUG, __FILE__, __LINE__); 182 188 } else { 183 189 // Invalid custom file name provided. Use uploaded file name. 184 190 $file_name = $files['name'][$i]; 185 App::logMsg(sprintf('Using uploaded file name: %s', $file_name), LOG_DEBUG, __FILE__, __LINE__);191 $app->logMsg(sprintf('Using uploaded file name: %s', $file_name), LOG_DEBUG, __FILE__, __LINE__); 186 192 } 187 193 } … … 190 196 if (UPLOAD_ERR_INI_SIZE === $files['error'][$i]) { 191 197 $this->_raiseMsg(sprintf(_("The file %s failed uploading: it exceeds the maximum allowed upload file size of %s."), $file_name, ini_get('upload_max_filesize')), MSG_ERR, __FILE__, __LINE__); 192 App::logMsg(sprintf(_("The file %s failed uploading with PHP error %s UPLOAD_ERR_INI_SIZE (currently %s)."), $files['error'][$i], $file_name, ini_get('upload_max_filesize')), LOG_ERR, __FILE__, __LINE__);198 $app->logMsg(sprintf(_("The file %s failed uploading with PHP error %s UPLOAD_ERR_INI_SIZE (currently %s)."), $files['error'][$i], $file_name, ini_get('upload_max_filesize')), LOG_ERR, __FILE__, __LINE__); 193 199 $this->errors[] = array('filename' => $file_name, 'errortype' => UPLOAD_ERR_INI_SIZE); 194 200 continue; … … 196 202 if (UPLOAD_ERR_FORM_SIZE === $files['error'][$i]) { 197 203 $this->_raiseMsg(sprintf(_("The file %s failed uploading: it exceeds the maximum allowed upload file size of %s."), $file_name, $_POST['MAX_FILE_SIZE']), MSG_ERR, __FILE__, __LINE__); 198 App::logMsg(sprintf(_("The file %s failed uploading with PHP error %s UPLOAD_ERR_FORM_SIZE (currently %s)."), $files['error'][$i], $file_name, $_POST['MAX_FILE_SIZE']), LOG_ERR, __FILE__, __LINE__);204 $app->logMsg(sprintf(_("The file %s failed uploading with PHP error %s UPLOAD_ERR_FORM_SIZE (currently %s)."), $files['error'][$i], $file_name, $_POST['MAX_FILE_SIZE']), LOG_ERR, __FILE__, __LINE__); 199 205 $this->errors[] = array('filename' => $file_name, 'errortype' => UPLOAD_ERR_FORM_SIZE); 200 206 continue; … … 202 208 if (UPLOAD_ERR_PARTIAL === $files['error'][$i]) { 203 209 $this->_raiseMsg(sprintf(_("The file %s failed uploading: it was only partially uploaded."), $file_name), MSG_ERR, __FILE__, __LINE__); 204 App::logMsg(sprintf(_("The file %s failed uploading with PHP error %s UPLOAD_ERR_PARTIAL."), $files['error'][$i], $file_name), LOG_ERR, __FILE__, __LINE__);210 $app->logMsg(sprintf(_("The file %s failed uploading with PHP error %s UPLOAD_ERR_PARTIAL."), $files['error'][$i], $file_name), LOG_ERR, __FILE__, __LINE__); 205 211 $this->errors[] = array('filename' => $file_name, 'errortype' => UPLOAD_ERR_PARTIAL); 206 212 continue; … … 208 214 if (UPLOAD_ERR_NO_FILE === $files['error'][$i]) { 209 215 $this->_raiseMsg(sprintf(_("The file %s failed uploading: no file was uploaded."), $file_name), MSG_ERR, __FILE__, __LINE__); 210 App::logMsg(sprintf(_("The file %s failed uploading with PHP error %s UPLOAD_ERR_NO_FILE."), $files['error'][$i], $file_name), LOG_ERR, __FILE__, __LINE__);216 $app->logMsg(sprintf(_("The file %s failed uploading with PHP error %s UPLOAD_ERR_NO_FILE."), $files['error'][$i], $file_name), LOG_ERR, __FILE__, __LINE__); 211 217 $this->errors[] = array('filename' => $file_name, 'errortype' => UPLOAD_ERR_NO_FILE); 212 218 continue; … … 214 220 if (UPLOAD_ERR_NO_TMP_DIR === $files['error'][$i]) { 215 221 $this->_raiseMsg(sprintf(_("The file %s failed uploading: temporary upload directory missing."), $file_name), MSG_ERR, __FILE__, __LINE__); 216 App::logMsg(sprintf(_("The file %s failed uploading with PHP error %s UPLOAD_ERR_NO_TMP_DIR."), $files['error'][$i], $file_name), LOG_ERR, __FILE__, __LINE__);222 $app->logMsg(sprintf(_("The file %s failed uploading with PHP error %s UPLOAD_ERR_NO_TMP_DIR."), $files['error'][$i], $file_name), LOG_ERR, __FILE__, __LINE__); 217 223 $this->errors[] = array('filename' => $file_name, 'errortype' => UPLOAD_ERR_NO_TMP_DIR); 218 224 continue; … … 222 228 if (!is_uploaded_file($files['tmp_name'][$i])) { 223 229 $this->_raiseMsg(sprintf(_("The file %s failed uploading."), $file_name), MSG_ERR, __FILE__, __LINE__); 224 App::logMsg(sprintf(_("The file %s failed is_uploaded_file."), $file_name), LOG_ERR, __FILE__, __LINE__);230 $app->logMsg(sprintf(_("The file %s failed is_uploaded_file."), $file_name), LOG_ERR, __FILE__, __LINE__); 225 231 $this->errors[] = array('filename' => $file_name, 'errortype' => UPLOAD_USER_ERR_NOT_UPLOADED_FILE); 226 232 continue; … … 230 236 if ($files['size'][$i] <= 0) { 231 237 $this->_raiseMsg(sprintf(_("The file %s failed uploading: it contains zero bytes."), $file_name), MSG_ERR, __FILE__, __LINE__); 232 App::logMsg(sprintf(_("The uploaded file %s contains zero bytes."), $file_name), LOG_ERR, __FILE__, __LINE__);238 $app->logMsg(sprintf(_("The uploaded file %s contains zero bytes."), $file_name), LOG_ERR, __FILE__, __LINE__); 233 239 $this->errors[] = array('filename' => $file_name, 'errortype' => UPLOAD_USER_ERR_EMPTY_FILE); 234 240 continue; … … 238 244 if (!in_array(strtolower($this->getFilenameExtension($file_name)), $this->getParam('valid_file_extensions'))) { 239 245 $this->_raiseMsg(sprintf(_("The file %s failed uploading: it is an unrecognized type. Files must have one of the following file name extensions: %s."), $file_name, join(', ', $this->getParam('valid_file_extensions'))), MSG_ERR, __FILE__, __LINE__); 240 App::logMsg(sprintf(_("The uploaded file %s has an unrecognized file name extension."), $file_name), LOG_WARNING, __FILE__, __LINE__);246 $app->logMsg(sprintf(_("The uploaded file %s has an unrecognized file name extension."), $file_name), LOG_WARNING, __FILE__, __LINE__); 241 247 $this->errors[] = array('filename' => $file_name, 'errortype' => UPLOAD_USER_ERR_INVALID_EXTENSION); 242 248 continue; … … 246 252 if (!$this->getParam('allow_overwriting') && $this->exists($file_name)) { 247 253 $this->_raiseMsg(sprintf(_("The file %s failed uploading: a file with that name already exists."), $file_name), MSG_ERR, __FILE__, __LINE__); 248 App::logMsg(sprintf(_("The uploaded file %s doesn't have a unique filename."), $file_name), LOG_WARNING, __FILE__, __LINE__);254 $app->logMsg(sprintf(_("The uploaded file %s doesn't have a unique filename."), $file_name), LOG_WARNING, __FILE__, __LINE__); 249 255 $this->errors[] = array('filename' => $file_name, 'errortype' => UPLOAD_USER_ERR_NOT_UNIQUE); 250 256 continue; … … 269 275 if (move_uploaded_file($files['tmp_name'][$i], $file_path_name)) { 270 276 chmod($file_path_name, $this->getParam('dest_file_perms')); 271 App::logMsg(sprintf('File uploaded: %s', $file_path_name), LOG_INFO, __FILE__, __LINE__);277 $app->logMsg(sprintf('File uploaded: %s', $file_path_name), LOG_INFO, __FILE__, __LINE__); 272 278 $this->_raiseMsg(sprintf(_("The file %s uploaded successfully."), $file_name), MSG_SUCCESS, __FILE__, __LINE__); 273 279 if (!isset($custom_file_name) && $files['name'][$i] != $file_name) { … … 284 290 } else { 285 291 $this->_raiseMsg(sprintf(_("The file %s failed uploading."), $file_name), MSG_ERR, __FILE__, __LINE__); 286 App::logMsg(sprintf(_("Moving file failed: %s -> %s"), $files['tmp_name'][$i], $file_path_name), LOG_ALERT, __FILE__, __LINE__);292 $app->logMsg(sprintf(_("Moving file failed: %s -> %s"), $files['tmp_name'][$i], $file_path_name), LOG_ALERT, __FILE__, __LINE__); 287 293 $this->errors[] = array('filename' => $file_name, 'errortype' => UPLOAD_USER_ERR_MOVE_FAILED); 288 294 } … … 290 296 // Check file extension with browsers interpretation of file type. 291 297 if (isset($this->mime_extension_map[$file_extension]) && $files['type'][$i] != $this->mime_extension_map[$file_extension]) { 292 App::logMsg(sprintf('File extension (%s) does not match mime type (%s).', $file_extension, $files['type'][$i]), LOG_NOTICE, __FILE__, __LINE__);298 $app->logMsg(sprintf('File extension (%s) does not match mime type (%s).', $file_extension, $files['type'][$i]), LOG_NOTICE, __FILE__, __LINE__); 293 299 } 294 300 } … … 307 313 function deleteFile($file_name) 308 314 { 315 $app =& App::getInstance(); 316 309 317 // Ensure we have a upload directory. 310 318 if (!$this->getParam('upload_path')) { 311 App::logMsg(sprintf('Upload directory not set before processing.'), LOG_ERR, __FILE__, __LINE__);319 $app->logMsg(sprintf('Upload directory not set before processing.'), LOG_ERR, __FILE__, __LINE__); 312 320 return false; 313 321 } … … 316 324 317 325 if (!is_file($file_path_name)) { 318 App::logMsg(sprintf(_("Error deleting nonexistent file: %s"), $file_path_name), LOG_ERR, __FILE__, __LINE__);326 $app->logMsg(sprintf(_("Error deleting nonexistent file: %s"), $file_path_name), LOG_ERR, __FILE__, __LINE__); 319 327 return false; 320 328 } else if (unlink($file_path_name)) { 321 App::logMsg(sprintf('Deleted file: %s', $file_path_name), LOG_INFO, __FILE__, __LINE__);329 $app->logMsg(sprintf('Deleted file: %s', $file_path_name), LOG_INFO, __FILE__, __LINE__); 322 330 } else { 323 331 $this->_raiseMsg(sprintf(_("The file %s could not be deleted."), $file_name), MSG_ERR, __FILE__, __LINE__); 324 App::logMsg(sprintf(_("Failed deleting file: %s"), $file_path_name), LOG_ERR, __FILE__, __LINE__);332 $app->logMsg(sprintf(_("Failed deleting file: %s"), $file_path_name), LOG_ERR, __FILE__, __LINE__); 325 333 return false; 326 334 } … … 337 345 function moveFile($old_name, $new_name) 338 346 { 347 $app =& App::getInstance(); 348 339 349 // Ensure we have an upload directory. 340 350 if (!$this->getParam('upload_path')) { 341 App::logMsg(sprintf('Upload directory not set before processing.'), LOG_ERR, __FILE__, __LINE__);351 $app->logMsg(sprintf('Upload directory not set before processing.'), LOG_ERR, __FILE__, __LINE__); 342 352 return false; 343 353 } … … 348 358 if (rename($old_file_path_name, $new_file_path_name)) { 349 359 $this->_raiseMsg(sprintf(_("The file %s has been renamed to %s."), basename($old_file_path_name), basename($new_file_path_name)), MSG_NOTICE, __FILE__, __LINE__); 350 App::logMsg(sprintf('File renamed from %s to %s', $old_file_path_name, $new_file_path_name), LOG_DEBUG, __FILE__, __LINE__);360 $app->logMsg(sprintf('File renamed from %s to %s', $old_file_path_name, $new_file_path_name), LOG_DEBUG, __FILE__, __LINE__); 351 361 } else { 352 362 $this->_raiseMsg(sprintf(_("Error renaming file to %s"), $new_file_path_name), MSG_WARNING, __FILE__, __LINE__); 353 App::logMsg(sprintf(_("Error renaming file to %s"), $new_file_path_name), LOG_WARNING, __FILE__, __LINE__);363 $app->logMsg(sprintf(_("Error renaming file to %s"), $new_file_path_name), LOG_WARNING, __FILE__, __LINE__); 354 364 return false; 355 365 } 356 366 } else { 357 367 $this->_raiseMsg(sprintf(_("Couldn't rename nonexistent file %s."), $old_name), MSG_WARNING, __FILE__, __LINE__); 358 App::logMsg(sprintf(_("Error renaming nonexistent file: %s"), $old_file_path_name), LOG_WARNING, __FILE__, __LINE__);368 $app->logMsg(sprintf(_("Error renaming nonexistent file: %s"), $old_file_path_name), LOG_WARNING, __FILE__, __LINE__); 359 369 return false; 360 370 } … … 370 380 function exists($file_name) 371 381 { 382 $app =& App::getInstance(); 383 372 384 // Ensure we have a upload directory. 373 385 if (!$this->getParam('upload_path')) { 374 App::logMsg(sprintf('Upload directory not set before processing.'), LOG_ERR, __FILE__, __LINE__);386 $app->logMsg(sprintf('Upload directory not set before processing.'), LOG_ERR, __FILE__, __LINE__); 375 387 return false; 376 388 } … … 453 465 454 466 /** 455 * An alias for App::raiseMsg that only sends messages configured by display_messages.467 * An alias for $app->raiseMsg that only sends messages configured by display_messages. 456 468 * 457 469 * @access public … … 465 477 function _raiseMsg($message, $type, $file, $line) 466 478 { 479 $app =& App::getInstance(); 480 467 481 if ($this->getParam('display_messages') === true || (is_int($this->getParam('display_messages')) && $this->getParam('display_messages') & $type > 0)) { 468 App::raiseMsg($message, $type, $file, $line);482 $app->raiseMsg($message, $type, $file, $line); 469 483 } 470 484 }
Note: See TracChangeset
for help on using the changeset viewer.