Changeset 468
- Timestamp:
- Feb 20, 2014 3:03:59 AM (10 years ago)
- Location:
- trunk
- Files:
-
- 91 edited
- 4 copied
Legend:
- Unmodified
- Added
- Removed
-
trunk
-
Property
svn:mergeinfo
set to
/branches/eli_branch merged eligible
-
Property
svn:mergeinfo
set to
-
trunk/bin/acl.cli.php
r415 r468 5 5 * For details visit the project site: <http://trac.strangecode.com/codebase/> 6 6 * Copyright 2001-2012 Strangecode, LLC 7 * 7 * 8 8 * This file is part of The Strangecode Codebase. 9 9 * … … 12 12 * Free Software Foundation, either version 3 of the License, or (at your option) 13 13 * any later version. 14 * 14 * 15 15 * The Strangecode Codebase is distributed in the hope that it will be useful, but 16 16 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 17 17 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more 18 18 * details. 19 * 19 * 20 20 * You should have received a copy of the GNU General Public License along with 21 21 * The Strangecode Codebase. If not, see <http://www.gnu.org/licenses/>. … … 113 113 break; 114 114 case 'all' : 115 listObjects('root', 'aro'); 116 listObjects('root', 'aco'); 115 listObjects('root', 'aro'); 116 listObjects('root', 'aco'); 117 117 listObjects('root', 'axo'); 118 118 break; … … 238 238 but could just as easily be SPICES -> CUISINES -> DISHES. A privilege is 239 239 allowed if a user (ARO) can perform an action (ACO) on something (AXO). 240 For example, with an `ARO->ACO->AXO` of `Bob->edit->4`, Bob can edit article 4. 241 If the AXO were omitted (i.e. just `Bob->edit`), this becomes "Bob can edit" 240 For example, with an `ARO->ACO->AXO` of `Bob->edit->4`, Bob can edit article 4. 241 If the AXO were omitted (i.e. just `Bob->edit`), this becomes "Bob can edit" 242 242 (he can edit any object). 243 243 244 Each access object is stored as a node in hierarchical tree structures. 244 Each access object is stored as a node in hierarchical tree structures. 245 245 A permission granted to a node is applied to all its children. If a child 246 246 node is specified a different permission that is more specific than … … 252 252 253 253 Where command is any of the following (with arguments): 254 254 255 255 initdb 256 256 list [aro | aco | axo | all | perms] … … 268 268 revoke aro [aco] [axo] 269 269 delete [aro] [aco] [axo] 270 271 272 For the add*, mv*, grant, and revoke commands if any of the optional 273 args are not provided, 'root' is assumed. For the delete command 270 271 272 For the add*, mv*, grant, and revoke commands if any of the optional 273 args are not provided, 'root' is assumed. For the delete command 274 274 'null' is considered a wild-card to delete all objects of that type. 275 275 … … 297 297 $db =& DB::getInstance(); 298 298 global $this_script; 299 299 300 300 echo "\n"; 301 301 … … 324 324 $qid = $db->query("SELECT lft, rgt FROM $tbl WHERE name = '" . $db->escapeString($root) . "'"); 325 325 list($lft, $rgt) = mysql_fetch_row($qid); 326 326 327 327 $depth = array(); 328 328 329 329 // Retrieve all descendants of the root node 330 330 $qid = $db->query("SELECT name, lft, rgt, added_datetime FROM $tbl WHERE lft BETWEEN $lft AND $rgt ORDER BY lft ASC"); … … 334 334 array_pop($depth); 335 335 } 336 336 337 337 // Display indented node title. 338 338 printf("%-35s %-5s %-5s %s\n", str_repeat(' ', sizeof($depth)) . $name, $lft, $rgt, date($app->getParam('date_format'), strtotime($added_datetime))); 339 339 340 340 // Add this node to the stack. 341 341 $depth[] = $rgt; … … 356 356 $db =& DB::getInstance(); 357 357 global $this_script; 358 358 359 359 // Retrieve access value from db. 360 360 $qid = $db->query(" … … 371 371 while ($p = mysql_fetch_assoc($qid)) { 372 372 printf("%-25s %-25s %-25s \033[0;%sm%-6s\033[0m %-10s\n", $p['aro'], $p['aco'], $p['axo'], ('allow' == $p['access'] ? '32' : '31'), $p['access'], date($app->getParam('date_format'), strtotime($p['added_datetime']))); 373 } 374 } 375 376 377 ?> 373 } 374 } 375 376 -
trunk/bin/file_importer.php
r412 r468 123 123 // } 124 124 // 125 // ?> -
trunk/bin/module_maker/_config.inc.php
r457 r468 73 73 74 74 75 ?> -
trunk/bin/module_maker/form_template.cli.php
r412 r468 249 249 250 250 echo join("\n", $output); 251 252 ?> -
trunk/bin/module_maker/list_template.cli.php
r461 r468 36 36 $db_tbl = $_SERVER['argv'][2]; 37 37 } else { 38 die(sprintf("Usage: %s site_directory db_table [operation]\nValid operations include: %s ", basename($_SERVER['argv'][0]), join(', ', $valid_ops)));38 die(sprintf("Usage: %s site_directory db_table [operation]\nValid operations include: %s\n", basename($_SERVER['argv'][0]), join(', ', $valid_ops))); 39 39 } 40 40 … … 213 213 214 214 E_O_F; 215 216 ?> -
trunk/bin/module_maker/module.cli.php
r413 r468 596 596 } 597 597 } 598 599 ?> -
trunk/bin/module_maker/skel/admin.php
r408 r468 4 4 * For details visit the project site: <http://trac.strangecode.com/codebase/> 5 5 * Copyright 2001-2012 Strangecode, LLC 6 * 6 * 7 7 * This file is part of The Strangecode Codebase. 8 8 * … … 11 11 * Free Software Foundation, either version 3 of the License, or (at your option) 12 12 * any later version. 13 * 13 * 14 14 * The Strangecode Codebase is distributed in the hope that it will be useful, but 15 15 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 16 16 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more 17 17 * details. 18 * 18 * 19 19 * You should have received a copy of the GNU General Public License along with 20 20 * The Strangecode Codebase. If not, see <http://www.gnu.org/licenses/>. … … 236 236 $db =& DB::getInstance(); 237 237 $app =& App::getInstance(); 238 238 239 239 $lock->select('%DB_TBL%', '%PRIMARY_KEY%', $id); 240 240 if ($lock->isLocked() && !$lock->isMine()) { … … 278 278 $db =& DB::getInstance(); 279 279 $app =& App::getInstance(); 280 280 281 281 $lock->select('%DB_TBL%', '%PRIMARY_KEY%', $id); 282 282 if ($lock->isLocked() && !$lock->isMine()) { … … 314 314 $db =& DB::getInstance(); 315 315 $app =& App::getInstance(); 316 316 317 317 // Remove any stale cached list data. 318 318 $cache->delete('list'); … … 337 337 $db =& DB::getInstance(); 338 338 $app =& App::getInstance(); 339 339 340 340 $lock->select('%DB_TBL%', '%PRIMARY_KEY%', $frm['%PRIMARY_KEY%']); 341 341 if ($lock->isLocked() && !$lock->isMine()) { … … 364 364 global $tmp_prefs; 365 365 global $cache; 366 $db =& DB::getInstance(); 367 $app =& App::getInstance(); 368 366 $db =& DB::getInstance(); 367 $app =& App::getInstance(); 368 369 369 $where_clause = ''; 370 370 … … 379 379 if (getFormData('filter___///__', false)) { 380 380 // Limit by filter. 381 $where_clause .= (empty($where_clause) ? 'WHERE' : ' AND') . " __///__ = '" . $db->escapeString(getFormData('filter___///__')) . "'";381 $where_clause .= (empty($where_clause) ? 'WHERE' : ' AND') . " __///__ = '" . $db->escapeString(getFormData('filter___///__')) . "'"; 382 382 } 383 383 … … 425 425 return $list; 426 426 } 427 427 428 428 // The list was not cached, so issue the real query. 429 429 $qid = $db->query($sql); … … 445 445 $db =& DB::getInstance(); 446 446 $app =& App::getInstance(); 447 447 448 448 if (!is_array($ranks)) { 449 449 $app->logMsg('Saving rank failed, data posted is not an array: ' . $ranks, LOG_ERR, __FILE__, __LINE__); … … 476 476 } 477 477 } 478 479 ?> -
trunk/bin/module_maker/skel/public.php
r396 r468 145 145 include 'footer.ihtml'; 146 146 147 ?> -
trunk/bin/module_maker/sql.cli.php
r412 r468 5 5 * For details visit the project site: <http://trac.strangecode.com/codebase/> 6 6 * Copyright 2001-2012 Strangecode, LLC 7 * 7 * 8 8 * This file is part of The Strangecode Codebase. 9 9 * … … 12 12 * Free Software Foundation, either version 3 of the License, or (at your option) 13 13 * any later version. 14 * 14 * 15 15 * The Strangecode Codebase is distributed in the hope that it will be useful, but 16 16 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 17 17 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more 18 18 * details. 19 * 19 * 20 20 * You should have received a copy of the GNU General Public License along with 21 21 * The Strangecode Codebase. If not, see <http://www.gnu.org/licenses/>. … … 36 36 $db_tbl = $_SERVER['argv'][2]; 37 37 } else { 38 die(sprintf("Usage: %s site_directory db_table [operation]\nValid operations include: %s ", basename($_SERVER['argv'][0]), join(', ', $valid_ops)));38 die(sprintf("Usage: %s site_directory db_table [operation]\nValid operations include: %s\n", basename($_SERVER['argv'][0]), join(', ', $valid_ops))); 39 39 } 40 40 … … 218 218 219 219 echo isset($op) ? '' : "\n\n\n"; 220 ?> -
trunk/bin/module_maker/validation.cli.php
r412 r468 309 309 " . join("\n ", $o) . " 310 310 }"; 311 ?> -
trunk/docs/codebase_v1-to-v2_upgrade_checklist.txt
r334 r468 1 <?php2 3 1 ===================================================================== 4 2 In General … … 8 6 9 7 include SITE_BASE . '/_templates/header.ihtml'; 10 8 11 9 do this: 12 10 13 11 include 'header.ihtml'; 14 12 15 13 16 14 2. CODE_BASE is a defunct constant. The location of the codebase is no longer important as long as it can be found in the currently configured include_path. This will usually include the local site directory (where the codebase normally would be found) as well as the server-wide /usr/lib/php directory where the codebase might be included for the whole server. So now, instead of this: 17 15 18 16 require_once CODE_BASE . '/lib/Utilities.inc.php'; 19 17 20 18 do this: 21 19 22 20 require_once 'codebase/lib/Utilities.inc.php'; 23 24 21 22 25 23 3. $CFG-> variables are gone. Most of these should be converted into their $app and $auth equivalents. If a $CFG variable is NOT something used by the codebase but is still needed by the website application, I suggest converting these values to a $cfg array. For example, this: 26 24 27 25 $CFG->gallery_images_url = '/gallery_images'; 28 26 29 27 should become: 30 28 31 29 $cfg['gallery_images_url'] = '/gallery_images'; 32 30 33 31 And of course change the code where they are used to support the array instead of object-properties. If the array is inside of double-quotes it should be written like: 34 32 35 "{$cfg['gallery_images_url']}/my/path". 36 37 If the value used is now to be retrieved from a $object->getParam(...) method call, you'll need to do this: 33 "{$cfg['gallery_images_url']}/my/path". 34 35 If the value used is now to be retrieved from a $object->getParam(...) method call, you'll need to do this: 38 36 39 37 $object->getParam('gallery_images_url') . '/my/path' … … 43 41 44 42 <a href="<?php echo ohref("$CFG->site_url/my/file.php"); ?>"> 45 43 46 44 to this: 47 45 48 46 <a href="<?php echo $app->ohref("/my/file.php"); ?>"> 49 47 50 48 (In other words, the URL should be a not-fully-qualified URL starting with a slash.) 51 49 … … 62 60 '\1' => '\2' 63 61 )); 64 65 62 63 66 64 6. Many classes now require object-method calls, and the object must be globally scoped. For example, to call the $cache->exists() method inside a function, be sure to add: 67 65 68 66 global $cache; 69 67 70 68 at the top of the function. 71 69 72 70 73 71 74 72 ===================================================================== … … 80 78 --------------------------------------------------------------------- 81 79 $CFG global variables are converted to object properties specific to their usage. 82 80 83 81 For example: 84 82 … … 98 96 Convert functions to methods. 99 97 100 raiseMsg(...) $app->raiseMsg(...) 101 logMsg(...) $app->logMsg(...) 98 raiseMsg(...) $app->raiseMsg(...) 99 logMsg(...) $app->logMsg(...) 102 100 include 'message_header.ihtml'; $app->printRaisedMessages(); 103 101 $carry_queries = array(... , ...); $app->carryQuery(...); //call for each value in array 104 ohref(...) $app->ohref(...) 105 printHiddenSession(...); $app->printHiddenSession(...); 106 dieURL(...); $app->dieURL(...); 107 dieBoomerangURL(...); $app->dieBoomerangURL(...); 108 setBoomerangURL(...); $app->setBoomerangURL(...); 109 getBoomerangURL(...); $app->getBoomerangURL(...); 110 validBoomerangURL(...); $app->validBoomerangURL(...); 111 deleteBoomerangURL(...); $app->deleteBoomerangURL(...); 102 ohref(...) $app->ohref(...) 103 printHiddenSession(...); $app->printHiddenSession(...); 104 dieURL(...); $app->dieURL(...); 105 dieBoomerangURL(...); $app->dieBoomerangURL(...); 106 setBoomerangURL(...); $app->setBoomerangURL(...); 107 getBoomerangURL(...); $app->getBoomerangURL(...); 108 validBoomerangURL(...); $app->validBoomerangURL(...); 109 deleteBoomerangURL(...); $app->deleteBoomerangURL(...); 112 110 sslOn(); $app->sslOn(); 113 111 sslOff(); $app->sslOff(); … … 121 119 ===================================================================== 122 120 DB 123 ===================================================================== 121 ===================================================================== 124 122 125 123 dbQuery(...) $db->query(...) … … 209 207 210 208 $lock = new RecordLock($GLOBALS['_admin']); 211 209 212 210 to: 213 211 … … 215 213 global $auth; 216 214 $lock =& Lock::getInstance($auth); 217 215 218 216 And instantiate the original global $lock object in _config.inc.php as follows: 219 217 … … 236 234 237 235 $version = new RecordVersion(); 238 236 239 237 to: 240 238 … … 250 248 Changed all method calls to now require object calls rather than static calls. In other words, change this: 251 249 252 if (SessionCache::isCached('mydata')) { 250 if (SessionCache::isCached('mydata')) { 253 251 $list = SessionCache::getCache('mydata'); 254 252 } … … 304 302 305 303 include_once 'form_error_header.ihtml'; $fv->printErrorMessages(); 306 307 308 ?> -
trunk/docs/examples/_config.inc.php
r432 r468 4 4 * For details visit the project site: <http://trac.strangecode.com/codebase/> 5 5 * Copyright 2001-2012 Strangecode, LLC 6 * 6 * 7 7 * This file is part of The Strangecode Codebase. 8 8 * … … 11 11 * Free Software Foundation, either version 3 of the License, or (at your option) 12 12 * any later version. 13 * 13 * 14 14 * The Strangecode Codebase is distributed in the hope that it will be useful, but 15 15 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 16 16 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more 17 17 * details. 18 * 18 * 19 19 * You should have received a copy of the GNU General Public License along with 20 20 * The Strangecode Codebase. If not, see <http://www.gnu.org/licenses/>. 21 21 */ 22 22 23 /** 23 /** 24 24 * _config.inc.php lives in the document root of the site/application. It is the beginning of everything. 25 25 * … … 28 28 * @since 03 Dec 2005 19:09:32 29 29 */ 30 30 31 31 // The constant __FILE__ must be an absolute directory path, starting with / on unix or C: on windows. 32 32 // To work around a PHP bug always include this config file with: require_once dirname(__FILE__) . '/_config.inc.php'; … … 39 39 define('COMMON_BASE', realpath(dirname(__FILE__) . '/../')); 40 40 41 // The DocRoot for this application. SITE_BASE is different from $_SERVER['DOCUMENT_ROOT'] because the 41 // The DocRoot for this application. SITE_BASE is different from $_SERVER['DOCUMENT_ROOT'] because the 42 42 // latter does not change when using the apache Alias directive or URL Rewriting to define a site. 43 43 define('SITE_BASE', dirname(__FILE__)); … … 148 148 require_once 'codebase/lib/Cache.inc.php'; 149 149 $cache = new Cache('global'); 150 $cache->setParam(array('enabled' => true)); 150 $cache->setParam(array('enabled' => true)); // TODO: Enable caching after site launch. 151 151 152 152 // Setup CSS files to include. These will always be available. 153 153 require_once 'codebase/lib/CSS.inc.php'; 154 154 $css = new CSS(); 155 $css->setParam(array('cache_css' => false)); // /Enable caching after site launch.155 $css->setParam(array('cache_css' => false)); // TODO: Enable caching after site launch. 156 156 $css->setFile('codebase/css/codebase.inc.css'); 157 157 $css->setFile('codebase/css/utilities.inc.css'); … … 170 170 // require_once 'global/config.inc.php'; 171 171 172 ?> -
trunk/docs/examples/contact_form/contact.php
r413 r468 119 119 } 120 120 121 ?> -
trunk/docs/examples/db_auth.inc.php
r404 r468 35 35 'db_pass' => '', 36 36 )); 37 ?> -
trunk/docs/examples/example.cli.php
r396 r468 146 146 147 147 148 ?> -
trunk/docs/examples/script_template.php
r396 r468 60 60 61 61 62 ?> -
trunk/lib/ACL.inc.php
r457 r468 39 39 class ACL { 40 40 41 // A place to keep an object instance for the singleton pattern. 42 private static $instance = null; 43 41 44 // Configuration parameters for this object. 42 var $_params = array( 43 45 private $_params = array( 44 46 // If false nothing will be cached or retrieved. Useful for testing realtime data requests. 45 47 'enable_cache' => true, … … 52 54 * Constructor. 53 55 */ 54 function ACL()56 public function __construct() 55 57 { 56 58 $app =& App::getInstance(); … … 73 75 * @static 74 76 */ 75 static function &getInstance() 76 { 77 static $instance = null; 78 79 if ($instance === null) { 80 $instance = new ACL(); 81 } 82 83 return $instance; 77 public static function &getInstance() 78 { 79 if (self::$instance === null) { 80 self::$instance = new self(); 81 } 82 83 return self::$instance; 84 84 } 85 85 … … 91 91 * @param array $params Array of parameters (key => val pairs). 92 92 */ 93 function setParam($params)93 public function setParam($params) 94 94 { 95 95 $app =& App::getInstance(); … … 110 110 * @return mixed Configured parameter value. 111 111 */ 112 function getParam($param)112 public function getParam($param) 113 113 { 114 114 $app =& App::getInstance(); … … 129 129 * @since 04 Jun 2006 16:41:42 130 130 */ 131 function initDB($recreate_db=false)131 public function initDB($recreate_db=false) 132 132 { 133 133 $app =& App::getInstance(); … … 224 224 * @since 14 Jun 2006 22:39:29 225 225 */ 226 function add($name, $parent=null, $type)226 public function add($name, $parent=null, $type) 227 227 { 228 228 $app =& App::getInstance(); … … 287 287 288 288 // Alias functions for the different object types. 289 function addRequestObject($name, $parent=null)289 public function addRequestObject($name, $parent=null) 290 290 { 291 291 return $this->add($name, $parent, 'aro'); 292 292 } 293 function addControlObject($name, $parent=null)293 public function addControlObject($name, $parent=null) 294 294 { 295 295 return $this->add($name, $parent, 'aco'); 296 296 } 297 function addXtraObject($name, $parent=null)297 public function addXtraObject($name, $parent=null) 298 298 { 299 299 return $this->add($name, $parent, 'axo'); … … 311 311 * @since 14 Jun 2006 22:39:29 312 312 */ 313 function remove($name, $type)313 public function remove($name, $type) 314 314 { 315 315 $app =& App::getInstance(); … … 368 368 369 369 // Alias functions for the different object types. 370 function removeRequestObject($name)370 public function removeRequestObject($name) 371 371 { 372 372 return $this->remove($name, 'aro'); 373 373 } 374 function removeControlObject($name)374 public function removeControlObject($name) 375 375 { 376 376 return $this->remove($name, 'aco'); 377 377 } 378 function removeXtraObject($name)378 public function removeXtraObject($name) 379 379 { 380 380 return $this->remove($name, 'axo'); … … 393 393 * @since 14 Jun 2006 22:39:29 394 394 */ 395 function move($name, $new_parent, $type)395 public function move($name, $new_parent, $type) 396 396 { 397 397 $app =& App::getInstance(); … … 490 490 491 491 // Alias functions for the different object types. 492 function moveRequestObject($name, $new_parent=null)492 public function moveRequestObject($name, $new_parent=null) 493 493 { 494 494 return $this->move($name, $new_parent, 'aro'); 495 495 } 496 function moveControlObject($name, $new_parent=null)496 public function moveControlObject($name, $new_parent=null) 497 497 { 498 498 return $this->move($name, $new_parent, 'aco'); 499 499 } 500 function moveXtraObject($name, $new_parent=null)500 public function moveXtraObject($name, $new_parent=null) 501 501 { 502 502 return $this->move($name, $new_parent, 'axo'); … … 516 516 * @since 15 Jun 2006 01:58:48 517 517 */ 518 function grant($aro=null, $aco=null, $axo=null, $access='allow')518 public function grant($aro=null, $aco=null, $axo=null, $access='allow') 519 519 { 520 520 $app =& App::getInstance(); … … 573 573 * @since 15 Jun 2006 04:35:54 574 574 */ 575 function revoke($aro=null, $aco=null, $axo=null)575 public function revoke($aro=null, $aco=null, $axo=null) 576 576 { 577 577 return $this->grant($aro, $aco, $axo, 'deny'); … … 591 591 * @since 20 Jun 2006 20:16:12 592 592 */ 593 function delete($aro=null, $aco=null, $axo=null)593 public function delete($aro=null, $aco=null, $axo=null) 594 594 { 595 595 $app =& App::getInstance(); … … 650 650 * @since 15 Jun 2006 03:58:23 651 651 */ 652 function check($aro, $aco=null, $axo=null)652 public function check($aro, $aco=null, $axo=null) 653 653 { 654 654 $app =& App::getInstance(); … … 713 713 * @since 20 Jan 2014 12:09:03 714 714 */ 715 function requireAllow($aro, $aco=null, $axo=null, $message='', $type=MSG_NOTICE, $file=null, $line=null)715 public function requireAllow($aro, $aco=null, $axo=null, $message='', $type=MSG_NOTICE, $file=null, $line=null) 716 716 { 717 717 $app =& App::getInstance(); … … 725 725 726 726 } // End class. 727 728 729 ?> -
trunk/lib/App.inc.php
r453 r468 42 42 class App { 43 43 44 // A place to keep an object instance for the singleton pattern. 45 private static $instance = null; 46 44 47 // Namespace of this application instance. 45 var$_ns;48 private $_ns; 46 49 47 50 // If $app->start has run successfully. 48 var$running = false;51 public $running = false; 49 52 50 53 // Instance of database object. 51 var$db;54 public $db; 52 55 53 56 // Array of query arguments will be carried persistently between requests. 54 var$_carry_queries = array();57 private $_carry_queries = array(); 55 58 56 59 // Dictionary of global application parameters. 57 var$_params = array();60 private $_params = array(); 58 61 59 62 // Default parameters. 60 var$_param_defaults = array(63 private $_param_defaults = array( 61 64 62 65 // Public name and email address for this application. … … 162 165 163 166 /** 167 * Constructor. 168 */ 169 public function __construct($namespace='') 170 { 171 // Set namespace of application instance. 172 $this->_ns = $namespace; 173 174 // Initialize default parameters. 175 $this->_params = array_merge($this->_params, $this->_param_defaults); 176 177 // Begin timing script. 178 require_once dirname(__FILE__) . '/ScriptTimer.inc.php'; 179 $this->timer = new ScriptTimer(); 180 $this->timer->start('_app'); 181 } 182 183 /** 164 184 * This method enforces the singleton pattern for this class. Only one application is running at a time. 165 185 * … … 169 189 * @static 170 190 */ 171 static function &getInstance($namespace='') 172 { 173 static $instance = null; 174 175 if ($instance === null) { 176 $instance = new App($namespace); 177 } 178 179 return $instance; 180 } 181 182 /** 183 * Constructor. 184 */ 185 function App($namespace='') 186 { 187 // Set namespace of application instance. 188 $this->_ns = $namespace; 189 190 // Initialize default parameters. 191 $this->_params = array_merge($this->_params, $this->_param_defaults); 192 193 // Begin timing script. 194 require_once dirname(__FILE__) . '/ScriptTimer.inc.php'; 195 $this->timer = new ScriptTimer(); 196 $this->timer->start('_app'); 191 public static function &getInstance($namespace='') 192 { 193 if (self::$instance === null) { 194 // TODO: Yep, having a namespace with one singletone instance is not very useful. 195 self::$instance = new self($namespace); 196 } 197 198 return self::$instance; 197 199 } 198 200 … … 203 205 * @param array $param Array of parameters (key => val pairs). 204 206 */ 205 function setParam($param=null)207 public function setParam($param=null) 206 208 { 207 209 if (isset($param) && is_array($param)) { … … 218 220 * @return mixed Parameter value, or null if not existing. 219 221 */ 220 function getParam($param=null)222 public function getParam($param=null) 221 223 { 222 224 if ($param === null) { … … 225 227 return $this->_params[$param]; 226 228 } else { 227 trigger_error(sprintf('Parameter is not set: %s', $param), E_USER_NOTICE);228 229 return null; 229 230 } … … 237 238 * @since 15 Jul 2005 00:32:21 238 239 */ 239 function start()240 public function start() 240 241 { 241 242 if ($this->running) { … … 275 276 276 277 // DB connection parameters taken from environment variables in the httpd.conf file, readable only by root. 277 if (!empty($_SERVER['DB_SERVER']) ) {278 if (!empty($_SERVER['DB_SERVER']) && !$this->getParam('db_server')) { 278 279 $this->setParam(array('db_server' => $_SERVER['DB_SERVER'])); 279 280 } 280 if (!empty($_SERVER['DB_NAME']) ) {281 if (!empty($_SERVER['DB_NAME']) && !$this->getParam('db_name')) { 281 282 $this->setParam(array('db_name' => $_SERVER['DB_NAME'])); 282 283 } 283 if (!empty($_SERVER['DB_USER']) ) {284 if (!empty($_SERVER['DB_USER']) && !$this->getParam('db_user')) { 284 285 $this->setParam(array('db_user' => $_SERVER['DB_USER'])); 285 286 } 286 if (!empty($_SERVER['DB_PASS']) ) {287 if (!empty($_SERVER['DB_PASS']) && !$this->getParam('db_pass')) { 287 288 $this->setParam(array('db_pass' => $_SERVER['DB_PASS'])); 288 289 } … … 394 395 * @since 17 Jul 2005 17:20:18 395 396 */ 396 function stop()397 public function stop() 397 398 { 398 399 session_write_close(); 399 restore_include_path();400 400 $this->running = false; 401 401 $num_queries = 0; … … 423 423 * @param string $line __LINE__. 424 424 */ 425 function raiseMsg($message, $type=MSG_NOTICE, $file=null, $line=null)425 public function raiseMsg($message, $type=MSG_NOTICE, $file=null, $line=null) 426 426 { 427 427 $message = trim($message); … … 465 465 * @since 21 Dec 2005 13:09:20 466 466 */ 467 function getRaisedMessages()467 public function getRaisedMessages() 468 468 { 469 469 if (!$this->running) { … … 471 471 return false; 472 472 } 473 474 473 return isset($_SESSION['_app'][$this->_ns]['messages']) ? $_SESSION['_app'][$this->_ns]['messages'] : array(); 475 474 } … … 482 481 * @since 21 Dec 2005 13:21:54 483 482 */ 484 function clearRaisedMessages()483 public function clearRaisedMessages() 485 484 { 486 485 if (!$this->running) { … … 503 502 * @since 15 Jul 2005 01:39:14 504 503 */ 505 function printRaisedMessages($above='', $below='', $print_gotohash_js=false, $hash='sc-msg') 506 { 504 public function printRaisedMessages($above='', $below='', $print_gotohash_js=false, $hash='sc-msg') 505 { 506 507 507 if (!$this->running) { 508 508 $this->logMsg(sprintf('Canceled method call %s, application not running.', __FUNCTION__), LOG_NOTICE, __FILE__, __LINE__); … … 576 576 * @param string $line The line of the file where the log event occurs. 577 577 */ 578 function logMsg($message, $priority=LOG_INFO, $file=null, $line=null)578 public function logMsg($message, $priority=LOG_INFO, $file=null, $line=null) 579 579 { 580 580 static $previous_events = array(); … … 690 690 // SCREEN ACTION 691 691 if (false !== $this->getParam('log_screen_priority') && $priority <= $this->getParam('log_screen_priority')) { 692 echo "[{$event['type']}] [{$event['message']}]\n";692 file_put_contents('php://stderr', "[{$event['type']}] [{$event['message']}]\n", FILE_APPEND); 693 693 } 694 694 … … 706 706 * @return The string representation of $priority. 707 707 */ 708 function logPriorityToString($priority) {708 public function logPriorityToString($priority) { 709 709 $priorities = array( 710 710 LOG_EMERG => 'emergency', … … 735 735 * @since 13 Oct 2007 11:34:51 736 736 */ 737 function setQuery($query_key, $val)737 public function setQuery($query_key, $val) 738 738 { 739 739 if (!is_array($query_key)) { … … 757 757 * @since 14 Nov 2005 19:24:52 758 758 */ 759 function carryQuery($query_key, $default=false)759 public function carryQuery($query_key, $default=false) 760 760 { 761 761 if (!is_array($query_key)) { … … 782 782 * @since 18 Jun 2007 20:57:29 783 783 */ 784 function dropQuery($query_key, $unset=false)784 public function dropQuery($query_key, $unset=false) 785 785 { 786 786 if (!is_array($query_key)) { … … 818 818 * @return string url with attached queries and, if not using cookies, the session id 819 819 */ 820 function url($url, $carry_args=null, $always_include_sid=false)820 public function url($url, $carry_args=null, $always_include_sid=false) 821 821 { 822 822 if (!$this->running) { … … 909 909 * @since 09 Dec 2005 17:58:45 910 910 */ 911 function oHREF($url, $carry_args=null, $always_include_sid=false)911 public function oHREF($url, $carry_args=null, $always_include_sid=false) 912 912 { 913 913 $url = $this->url($url, $carry_args, $always_include_sid); … … 929 929 * false <-- To not carry any queries. If URL already has queries those will be retained. 930 930 */ 931 function printHiddenSession($carry_args=null)931 public function printHiddenSession($carry_args=null) 932 932 { 933 933 if (!$this->running) { … … 995 995 * @param bool $always_include_sid Force session id to be added to Location header. 996 996 */ 997 function dieURL($url, $carry_args=null, $always_include_sid=false)997 public function dieURL($url, $carry_args=null, $always_include_sid=false) 998 998 { 999 999 if (!$this->running) { … … 1042 1042 * @since 31 Mar 2006 19:17:00 1043 1043 */ 1044 function dieBoomerangURL($id=null, $carry_args=null, $default_url=null, $queryless_referrer_comparison=false)1044 public function dieBoomerangURL($id=null, $carry_args=null, $default_url=null, $queryless_referrer_comparison=false) 1045 1045 { 1046 1046 if (!$this->running) { … … 1085 1085 * FIXME: url garbage collection? 1086 1086 */ 1087 function setBoomerangURL($url=null, $id=null)1087 public function setBoomerangURL($url=null, $id=null) 1088 1088 { 1089 1089 if (!$this->running) { … … 1093 1093 // A redirection will never happen immediately after setting the boomerangURL. 1094 1094 // Set the time so ensure this doesn't happen. See $app->validBoomerangURL for more. 1095 /// FIXME: Why isn't the time set here under setBoomerangURL() and only under dieBoomerangURL()?1096 1095 1097 1096 if ('' != $url && is_string($url)) { … … 1124 1123 * @param string $id An identification tag for this url. 1125 1124 */ 1126 function getBoomerangURL($id=null)1125 public function getBoomerangURL($id=null) 1127 1126 { 1128 1127 if (!$this->running) { … … 1149 1148 * @param string $id An identification tag for this url. 1150 1149 */ 1151 function deleteBoomerangURL($id=null)1150 public function deleteBoomerangURL($id=null) 1152 1151 { 1153 1152 if (!$this->running) { … … 1171 1170 * @return bool True if it is set and valid, false otherwise. 1172 1171 */ 1173 function validBoomerangURL($id=null, $use_nonspecificboomerang=false)1172 public function validBoomerangURL($id=null, $use_nonspecificboomerang=false) 1174 1173 { 1175 1174 if (!$this->running) { … … 1221 1220 * the same page but with https. 1222 1221 */ 1223 function sslOn()1222 public function sslOn() 1224 1223 { 1225 1224 if (function_exists('apache_get_modules')) { … … 1242 1241 * a http version of the current url. 1243 1242 */ 1244 function sslOff()1243 public function sslOff() 1245 1244 { 1246 1245 if ('' != getenv('HTTPS')) { … … 1248 1247 } 1249 1248 } 1250 1251 1252 1249 } // End. 1253 1254 ?> -
trunk/lib/Auth_File.inc.php
r396 r468 4 4 * For details visit the project site: <http://trac.strangecode.com/codebase/> 5 5 * Copyright 2001-2012 Strangecode, LLC 6 * 6 * 7 7 * This file is part of The Strangecode Codebase. 8 8 * … … 11 11 * Free Software Foundation, either version 3 of the License, or (at your option) 12 12 * any later version. 13 * 13 * 14 14 * The Strangecode Codebase is distributed in the hope that it will be useful, but 15 15 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 16 16 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more 17 17 * details. 18 * 18 * 19 19 * You should have received a copy of the GNU General Public License along with 20 20 * The Strangecode Codebase. If not, see <http://www.gnu.org/licenses/>. 21 21 */ 22 22 23 /* *23 /* 24 24 * Auth_File.inc.php 25 25 * … … 30 30 * @version 1.2 31 31 */ 32 32 33 33 // Usage example: 34 34 // $auth = new Auth_File(); … … 40 40 // )); 41 41 42 // Available encryption types for class Auth_SQL.43 define('AUTH_ENCRYPT_MD5', 'md5');44 define('AUTH_ENCRYPT_CRYPT', 'crypt');45 define('AUTH_ENCRYPT_SHA1', 'sha1');46 define('AUTH_ENCRYPT_PLAINTEXT', 'plaintext');47 48 42 class Auth_File { 49 43 44 // Available encryption types for class Auth_File. 45 const ENCRYPT_MD5 = 'md5'; 46 const ENCRYPT_CRYPT = 'crypt'; 47 const ENCRYPT_SHA1 = 'sha1'; 48 const ENCRYPT_PLAINTEXT = 'plaintext'; 49 50 50 // Namespace of this auth object. 51 var$_ns;52 51 private $_ns; 52 53 53 // Parameters to be specified by setParam(). 54 var$_params = array();55 var$_default_params = array(56 54 private $_params = array(); 55 private $_default_params = array( 56 57 57 // Full path to htpasswd file. 58 58 'htpasswd_file' => null, 59 59 60 // The type of encryption to use for passwords stored in the db_table. Use one of the AUTH_ENCRYPT_* types specified above.61 'encryption_type' => AUTH_ENCRYPT_CRYPT,60 // The type of encryption to use for passwords stored in the db_table. Use one of the self::ENCRYPT_* types specified above. 61 'encryption_type' => self::ENCRYPT_CRYPT, 62 62 63 63 // The URL to the login script. … … 77 77 78 78 // Associative array of usernames to hashed passwords. 79 var$_users = array();80 81 /* *82 83 84 85 86 87 88 function Auth_File($namespace='')79 private $_users = array(); 80 81 /* 82 * Constructs a new htpasswd authentication object. 83 * 84 * @access public 85 * 86 * @param optional array $params A hash containing parameters. 87 */ 88 public function __construct($namespace='') 89 89 { 90 90 $this->_ns = $namespace; … … 94 94 } 95 95 96 /* *97 98 99 100 101 102 function setParam($params)96 /* 97 * Set the params of an auth object. 98 * 99 * @param array $params Array of parameter keys and value to set. 100 * @return bool true on success, false on failure 101 */ 102 public function setParam($params) 103 103 { 104 104 if (isset($params) && is_array($params)) { … … 108 108 } 109 109 110 /* *111 112 113 114 115 116 117 function getParam($param)118 { 119 $app =&App::getInstance();120 110 /* 111 * Return the value of a parameter, if it exists. 112 * 113 * @access public 114 * @param string $param Which parameter to return. 115 * @return mixed Configured parameter value. 116 */ 117 public function getParam($param) 118 { 119 $app = &App::getInstance(); 120 121 121 if (isset($this->_params[$param])) { 122 122 return $this->_params[$param]; … … 127 127 } 128 128 129 /* *130 131 132 133 134 function clear()129 /* 130 * Clear any authentication tokens in the current session. A.K.A. logout. 131 * 132 * @access public 133 */ 134 public function clear() 135 135 { 136 136 $_SESSION['_auth_file'][$this->_ns] = array('authenticated' => false); 137 137 } 138 138 139 140 /** 141 * Sets a variable into a registered auth session. 142 * 143 * @access public 144 * @param mixed $key Which value to set. 145 * @param mixed $val Value to set variable to. 146 */ 147 function set($key, $val) 139 /* 140 * Sets a variable into a registered auth session. 141 * 142 * @access public 143 * @param mixed $key Which value to set. 144 * @param mixed $val Value to set variable to. 145 */ 146 public function set($key, $val) 148 147 { 149 148 if (!isset($_SESSION['_auth_file'][$this->_ns]['user_data'])) { … … 153 152 } 154 153 155 /* *156 157 158 159 160 161 162 163 function get($key, $default='')154 /* 155 * Returns a specified value from a registered auth session. 156 * 157 * @access public 158 * @param mixed $key Which value to return. 159 * @param mixed $default Value to return if key not found in user_data. 160 * @return mixed Value stored in session. 161 */ 162 public function get($key, $default='') 164 163 { 165 164 if (isset($_SESSION['_auth_file'][$this->_ns][$key])) { … … 171 170 } 172 171 } 173 /** 174 * Find out if a set of login credentials are valid. Only supports 175 * htpasswd files with DES passwords right now. 176 * 177 * @access public 178 * 179 * @param string $username The username to check. 180 * @param array $password The password to compare to username. 181 * 182 * @return boolean Whether or not the credentials are valid. 183 */ 184 function authenticate($username, $password) 185 { 186 $app =& App::getInstance(); 187 172 173 /* 174 * Find out if a set of login credentials are valid. Only supports 175 * htpasswd files with DES passwords right now. 176 * 177 * @access public 178 * 179 * @param string $username The username to check. 180 * @param array $password The password to compare to username. 181 * 182 * @return boolean Whether or not the credentials are valid. 183 */ 184 public function authenticate($username, $password) 185 { 186 $app = &App::getInstance(); 187 188 188 if ('' == trim($password)) { 189 189 $app->logMsg(_("No password provided for authentication."), LOG_INFO, __FILE__, __LINE__); 190 190 return false; 191 191 } 192 192 193 193 // Load users file. 194 194 $this->_loadHTPasswdFile(); … … 203 203 return false; 204 204 } 205 205 206 206 // Authentication successful! 207 207 return true; 208 208 } 209 209 210 /* *211 212 213 214 215 216 217 218 219 220 function login($username, $password)210 /* 211 * If user passes authentication create authenticated session. 212 * 213 * @access public 214 * 215 * @param string $username The username to check. 216 * @param array $password The password to compare to username. 217 * 218 * @return boolean Whether or not the credentials are valid. 219 */ 220 public function login($username, $password) 221 221 { 222 222 $username = mb_strtolower(trim($username)); … … 228 228 return false; 229 229 } 230 230 231 231 $_SESSION['_auth_file'][$this->_ns] = array( 232 232 'authenticated' => true, … … 241 241 } 242 242 243 /* *244 245 246 247 248 249 250 251 252 253 function isLoggedIn()254 { 255 $app =&App::getInstance();256 243 /* 244 * Test if user has a currently logged-in session. 245 * - authentication flag set to true 246 * - username not empty 247 * - total logged-in time is not greater than login_timeout 248 * - idle time is not greater than idle_timeout 249 * - remote address is the same as the login remote address. 250 * 251 * @access public 252 */ 253 public function isLoggedIn() 254 { 255 $app = &App::getInstance(); 256 257 257 // Some users will access from networks with a changing IP number (i.e. behind a proxy server). These users must be allowed entry by adding their IP to the list of trusted_networks. 258 258 if ($trusted_net = ipInRange(getRemoteAddr(), $this->_params['trusted_networks'])) { … … 268 268 // Test login with information stored in session. Skip IP matching for users from trusted networks. 269 269 if (isset($_SESSION['_auth_file'][$this->_ns]) 270 271 272 273 274 270 && true === $_SESSION['_auth_file'][$this->_ns]['authenticated'] 271 && !empty($_SESSION['_auth_file'][$this->_ns]['username']) 272 && strtotime($_SESSION['_auth_file'][$this->_ns]['login_datetime']) > time() - $this->_params['login_timeout'] 273 && strtotime($_SESSION['_auth_file'][$this->_ns]['last_access_datetime']) > time() - $this->_params['idle_timeout'] 274 && ($_SESSION['_auth_file'][$this->_ns]['remote_ip'] == getRemoteAddr() || $user_in_trusted_network) 275 275 ) { 276 276 // User is authenticated! … … 303 303 } 304 304 305 /* *306 307 308 309 310 311 312 313 314 315 function requireLogin($message='', $type=MSG_NOTICE, $file=null, $line=null)316 { 317 $app =&App::getInstance();318 305 /* 306 * Redirect user to login page if they are not logged in. 307 * 308 * @param string $message The text description of a message to raise. 309 * @param int $type The type of message: MSG_NOTICE, 310 * MSG_SUCCESS, MSG_WARNING, or MSG_ERR. 311 * @param string $file __FILE__. 312 * @param string $line __LINE__. 313 * @access public 314 */ 315 public function requireLogin($message='', $type=MSG_NOTICE, $file=null, $line=null) 316 { 317 $app = &App::getInstance(); 318 319 319 if (!$this->isLoggedIn()) { 320 320 // Display message for requiring login. (RaiseMsg will ignore empty strings.) … … 326 326 } 327 327 } 328 329 /** 330 * Wrapper function for compatibility with lib/Lock.inc.php. 331 * 332 * @param string $username Username to return. 333 * @return string Username, or false if none found. 334 */ 335 function getUsername($username) 336 { 328 329 /* 330 * Wrapper function for compatibility with lib/Lock.inc.php. 331 * 332 * @param string $username Username to return. 333 * @return string Username, or false if none found. 334 */ 335 public function getUsername($username) { 337 336 if ('' != $username) { 338 337 return $username; … … 351 350 * @since 18 Apr 2006 18:17:48 352 351 */ 353 function _loadHTPasswdFile()354 { 355 $app =&App::getInstance();356 352 private function _loadHTPasswdFile() 353 { 354 $app = &App::getInstance(); 355 357 356 static $users = null; 358 357 359 358 if (!file_exists($this->_params['htpasswd_file'])) { 360 359 $app->logMsg(sprintf('htpasswd file missing or not specified: %s', $this->_params['htpasswd_file']), LOG_ERR, __FILE__, __LINE__); 361 360 return false; 362 361 } 363 362 364 363 if (!isset($users)) { 365 364 if (false === ($users = file($this->_params['htpasswd_file']))) { … … 379 378 } 380 379 381 /* *382 383 384 385 386 387 388 389 390 function _encrypt($password, $encrypted_password=null)380 /* 381 * Hash a given password according to the configured encryption 382 * type. 383 * 384 * @param string $password The password to encrypt. 385 * @param string $encrypted_password The currently encrypted password to use as salt, if needed. 386 * 387 * @return string The hashed password. 388 */ 389 private function _encrypt($password, $encrypted_password=null) 391 390 { 392 391 switch ($this->_params['encryption_type']) { 393 case AUTH_ENCRYPT_PLAINTEXT :392 case self::ENCRYPT_PLAINTEXT : 394 393 return $password; 395 394 break; 396 395 397 case AUTH_ENCRYPT_SHA1 :396 case self::ENCRYPT_SHA1 : 398 397 return sha1($password); 399 398 break; 400 399 401 case AUTH_ENCRYPT_MD5 :400 case self::ENCRYPT_MD5 : 402 401 return md5($password); 403 402 break; 404 403 405 case AUTH_ENCRYPT_CRYPT :404 case self::ENCRYPT_CRYPT : 406 405 default : 407 406 return crypt($password, $encrypted_password); … … 411 410 412 411 } // end class 413 ?> -
trunk/lib/Auth_SQL.inc.php
r465 r468 28 28 */ 29 29 30 // Available encryption types for class Auth_SQL.31 define('AUTH_ENCRYPT_PLAINTEXT', 1);32 define('AUTH_ENCRYPT_CRYPT', 2);33 define('AUTH_ENCRYPT_SHA1', 3);34 define('AUTH_ENCRYPT_SHA1_HARDENED', 4);35 define('AUTH_ENCRYPT_MD5', 5);36 define('AUTH_ENCRYPT_MD5_HARDENED', 6);37 38 30 require_once dirname(__FILE__) . '/Email.inc.php'; 39 31 40 32 class Auth_SQL { 41 33 34 // Available encryption types for class Auth_SQL. 35 const ENCRYPT_PLAINTEXT = 1; 36 const ENCRYPT_CRYPT = 2; 37 const ENCRYPT_SHA1 = 3; 38 const ENCRYPT_SHA1_HARDENED = 4; 39 const ENCRYPT_MD5 = 5; 40 const ENCRYPT_MD5_HARDENED = 6; 41 42 42 // Namespace of this auth object. 43 var$_ns;43 private $_ns; 44 44 45 45 // Static var for test. 46 var$_authentication_tested;46 private $_authentication_tested; 47 47 48 48 // Parameters to be configured by setParam. 49 var$_params = array();50 var$_default_params = array(49 private $_params = array(); 50 private $_default_params = array( 51 51 52 52 // Automatically create table and verify columns. Better set to false after site launch. … … 66 66 'db_login_table' => 'user_login_tbl', 67 67 68 // The type of encryption to use for passwords stored in the db_table. Use one of the A UTH_ENCRYPT_* types specified above.68 // The type of encryption to use for passwords stored in the db_table. Use one of the Auth_SQL::ENCRYPT_* types specified above. 69 69 // Hardened password hashes rely on the same key/salt being used to compare encryptions. 70 70 // Be aware that when using one of the hardened types the App signing_key or $more_salt below cannot change! 71 'encryption_type' => AUTH_ENCRYPT_MD5,71 'encryption_type' => self::ENCRYPT_MD5, 72 72 73 73 // The URL to the login script. … … 127 127 * @param optional array $params A hash containing parameters. 128 128 */ 129 function Auth_SQL($namespace='')129 public function __construct($namespace='') 130 130 { 131 131 $app =& App::getInstance(); … … 153 153 * @since 26 Aug 2005 17:09:36 154 154 */ 155 function initDB($recreate_db=false)155 public function initDB($recreate_db=false) 156 156 { 157 157 $app =& App::getInstance(); … … 253 253 * @return bool true on success, false on failure 254 254 */ 255 function setParam($params)255 public function setParam($params) 256 256 { 257 257 if (isset($params['match_remote_ip_exempt_usernames'])) { … … 274 274 * @return mixed Configured parameter value. 275 275 */ 276 function getParam($param)276 public function getParam($param) 277 277 { 278 278 $app =& App::getInstance(); … … 291 291 * @access public 292 292 */ 293 function clear()293 public function clear() 294 294 { 295 295 $db =& DB::getInstance(); … … 326 326 * @param mixed $val Value to set variable to. 327 327 */ 328 function set($key, $val)328 public function set($key, $val) 329 329 { 330 330 if (!isset($_SESSION['_auth_sql'][$this->_ns]['user_data'])) { … … 342 342 * @return mixed Value stored in session. 343 343 */ 344 function get($key, $default='')344 public function get($key, $default='') 345 345 { 346 346 if (isset($_SESSION['_auth_sql'][$this->_ns][$key])) { … … 361 361 * @return mixed False if credentials not found in DB, or returns DB row matching credentials. 362 362 */ 363 function authenticate($username, $password)363 public function authenticate($username, $password) 364 364 { 365 365 $app =& App::getInstance(); … … 369 369 370 370 switch ($this->_params['encryption_type']) { 371 case AUTH_ENCRYPT_CRYPT :371 case self::ENCRYPT_CRYPT : 372 372 // Query DB for user matching credentials. Compare cyphertext with salted-encrypted password. 373 373 $qid = $db->query(" … … 378 378 "); 379 379 break; 380 case AUTH_ENCRYPT_PLAINTEXT :381 case AUTH_ENCRYPT_MD5 :382 case AUTH_ENCRYPT_SHA1 :380 case self::ENCRYPT_PLAINTEXT : 381 case self::ENCRYPT_MD5 : 382 case self::ENCRYPT_SHA1 : 383 383 default : 384 384 // Query DB for user matching credentials. Directly compare cyphertext with result from encryptPassword(). … … 412 412 * @return boolean Whether or not the credentials are valid. 413 413 */ 414 function login($username, $password)414 public function login($username, $password) 415 415 { 416 416 $app =& App::getInstance(); … … 421 421 $this->clear(); 422 422 423 if (! $user_data = $this->authenticate($username, $password)) {423 if (!($user_data = $this->authenticate($username, $password))) { 424 424 // No login: failed authentication! 425 425 return false; … … 539 539 * @access public 540 540 */ 541 function isLoggedIn($user_id=null)541 public function isLoggedIn($user_id=null) 542 542 { 543 543 $app =& App::getInstance(); … … 671 671 * @access public 672 672 */ 673 function requireLogin($message='', $type=MSG_NOTICE, $file=null, $line=null)673 public function requireLogin($message='', $type=MSG_NOTICE, $file=null, $line=null) 674 674 { 675 675 $app =& App::getInstance(); … … 693 693 * @param string $reason The reason for blocking the account. 694 694 */ 695 function blockAccount($user_id=null, $reason='')695 public function blockAccount($user_id=null, $reason='') 696 696 { 697 697 $app =& App::getInstance(); … … 723 723 * @return boolean True if the user is blocked, false otherwise. 724 724 */ 725 function isBlocked($user_id=null)725 public function isBlocked($user_id=null) 726 726 { 727 727 $db =& DB::getInstance(); … … 745 745 * Unblocks a user in the db_table, and clears any blocked_reason. 746 746 */ 747 function unblockAccount($user_id=null)747 public function unblockAccount($user_id=null) 748 748 { 749 749 $db =& DB::getInstance(); … … 769 769 * @return bool True if username exists. 770 770 */ 771 function usernameExists($username)771 public function usernameExists($username) 772 772 { 773 773 $db =& DB::getInstance(); … … 789 789 * @return string Username, or false if none found. 790 790 */ 791 function getUsername($user_id)791 public function getUsername($user_id) 792 792 { 793 793 $db =& DB::getInstance(); … … 813 813 * patterns, at minimum the US State Department standard: cvcddcvc. 814 814 * 815 * - x a random upper or lower alpha character or digit816 * - C a random upper or lower consonant817 * - V a random upper or lower vowel818 * - c a random lowercase consonant819 * - v a random lowercase vowel820 * - d a random digit815 * - x A random upper or lower character, digit, or punctuation. 816 * - C A random upper or lower consonant. 817 * - V A random upper or lower vowel. 818 * - c A random lowercase consonant. 819 * - v A random lowercase vowel. 820 * - d A random digit. 821 821 * 822 822 * @param string $pattern a sequence of character types, above. 823 823 * @return string a password 824 824 */ 825 function generatePassword($pattern='CvcdCvc')825 public function generatePassword($pattern='CvcdCvc') 826 826 { 827 827 $app =& App::getInstance(); … … 846 846 * 847 847 */ 848 function encryptPassword($password, $salt=null)848 public function encryptPassword($password, $salt=null) 849 849 { 850 850 $app =& App::getInstance(); … … 855 855 856 856 switch ($this->_params['encryption_type']) { 857 case AUTH_ENCRYPT_PLAINTEXT :857 case self::ENCRYPT_PLAINTEXT : 858 858 return $password; 859 859 break; 860 860 861 case AUTH_ENCRYPT_CRYPT :861 case self::ENCRYPT_CRYPT : 862 862 // If comparing plaintext password with a hash, provide first two chars of the hash as the salt. 863 863 return isset($salt) ? crypt($password, mb_substr($salt, 0, 2)) : crypt($password); 864 864 break; 865 865 866 case AUTH_ENCRYPT_SHA1 :866 case self::ENCRYPT_SHA1 : 867 867 return sha1($password); 868 868 break; 869 869 870 case AUTH_ENCRYPT_SHA1_HARDENED :870 case self::ENCRYPT_SHA1_HARDENED : 871 871 $hash = sha1($app->getParam('signing_key') . $password . $more_salt); 872 872 // Increase key strength by 12 bits. … … 877 877 break; 878 878 879 case AUTH_ENCRYPT_MD5 :879 case self::ENCRYPT_MD5 : 880 880 return md5($password); 881 881 break; 882 882 883 case AUTH_ENCRYPT_MD5_HARDENED :883 case self::ENCRYPT_MD5_HARDENED : 884 884 // Include salt to improve hash 885 885 $hash = md5($app->getParam('signing_key') . $password . $more_salt); … … 901 901 * 902 902 */ 903 function setPassword($user_id=null, $password)903 public function setPassword($user_id=null, $password) 904 904 { 905 905 $app =& App::getInstance(); … … 951 951 * @return string The user's new password. 952 952 */ 953 function resetPassword($user_id=null, $reason='')953 public function resetPassword($user_id=null, $reason='') 954 954 { 955 955 $app =& App::getInstance(); … … 1016 1016 * @return bool true if user is a member of security zone, false otherwise 1017 1017 */ 1018 function inClearanceZone($security_zone, $user_type='') 1019 { 1020 // return true; /// WTF? 1018 public function inClearanceZone($security_zone, $user_type='') 1019 { 1021 1020 $zone_members = preg_split('/,\s*/', $security_zone); 1022 1021 $user_type = empty($user_type) ? $this->get('user_type') : $user_type; … … 1039 1038 * @param constant $security_zone string of comma delimited privileges for the zone 1040 1039 */ 1041 function requireAccessClearance($security_zone, $message='')1040 public function requireAccessClearance($security_zone, $message='') 1042 1041 { 1043 1042 $app =& App::getInstance(); 1044 1043 1045 // return true; /// WTF?1046 1044 $zone_members = preg_split('/,\s*/', $security_zone); 1047 1045 … … 1097 1095 // 128.0.0.0 10000000.00000000.00000000.00000000 /1 1098 1096 // 0.0.0.0 00000000.00000000.00000000.00000000 /0 IP space 1099 ?> -
trunk/lib/AuthorizeNet.inc.php
r396 r468 4 4 * For details visit the project site: <http://trac.strangecode.com/codebase/> 5 5 * Copyright 2001-2012 Strangecode, LLC 6 * 6 * 7 7 * This file is part of The Strangecode Codebase. 8 8 * … … 11 11 * Free Software Foundation, either version 3 of the License, or (at your option) 12 12 * any later version. 13 * 13 * 14 14 * The Strangecode Codebase is distributed in the hope that it will be useful, but 15 15 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 16 16 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more 17 17 * details. 18 * 18 * 19 19 * You should have received a copy of the GNU General Public License along with 20 20 * The Strangecode Codebase. If not, see <http://www.gnu.org/licenses/>. … … 31 31 * @date 2004-04-06 32 32 */ 33 33 34 34 // Example usage 35 35 // require_once 'codebase/lib/AuthorizeNet.inc.php'; … … 61 61 class AuthorizeNet { 62 62 63 var$post_url = ''; // The URL to post data to.64 var$_results = array();65 var$_params = array();66 var$_default_params = array(63 public $post_url = ''; // The URL to post data to. 64 private $_results = array(); 65 private $_params = array(); 66 private $_default_params = array( 67 67 'x_version' => '3.1', 68 68 'x_relay_response' => 'FALSE', … … 80 80 81 81 // Array of response names. Used in the results array. 82 var$_result_fields = Array(82 private $_result_fields = Array( 83 83 'x_response_code', 84 84 'x_response_subcode', … … 129 129 * @param optional array $_params A hash containing parameters. 130 130 */ 131 function AuthorizeNet($params = array())131 public function __construct($params = array()) 132 132 { 133 133 $app =& App::getInstance(); … … 143 143 $this->_params = $this->_default_params; 144 144 $this->setParam($params); 145 145 146 146 $this->setParam(array('md5_hash_salt' => $app->getParam('signing_key'))); 147 147 } … … 153 153 * @param array $params Array of parameters (key => val pairs). 154 154 */ 155 function setParam($params)155 public function setParam($params) 156 156 { 157 157 $app =& App::getInstance(); 158 158 159 159 if (isset($params) && is_array($params)) { 160 160 // Merge new parameters with old overriding only those passed. … … 172 172 * @return mixed Configured parameter value. 173 173 */ 174 function getParam($param)174 public function getParam($param) 175 175 { 176 176 $app =& App::getInstance(); 177 177 178 178 if (isset($this->_params[$param])) { 179 179 return $this->_params[$param]; … … 192 192 * @return mixed False or x_response_code: false = error, 1 = accepted, 2 = declined, 3 = error 193 193 */ 194 function process()194 public function process() 195 195 { 196 196 $app =& App::getInstance(); 197 197 198 198 if (empty($this->_params['x_login'])) { 199 199 $this->_results['x_response_reason_text'] = _("Transaction gateway temporarily not available. Please try again later."); … … 245 245 * @return array Returns the results array. 246 246 */ 247 function getResult($key=null)247 public function getResult($key=null) 248 248 { 249 249 if (isset($key)) { … … 265 265 * @return bool True if the hash is valid, false otherwise. 266 266 */ 267 function validMD5Hash()267 public function validMD5Hash() 268 268 { 269 269 return ( … … 282 282 * @access public 283 283 */ 284 function reset()284 public function reset() 285 285 { 286 286 $this->_results = Array(); … … 297 297 * @return integer Transaction result code. 298 298 */ 299 function _processResult($result)299 private function _processResult($result) 300 300 { 301 301 $this->_results = Array(); … … 315 315 } 316 316 } 317 ?> -
trunk/lib/CSS.inc.php
r396 r468 32 32 33 33 // Include these style sheets. 34 var$_css_files = array('default' => array());34 private $_css_files = array('default' => array()); 35 35 36 36 // CSS object parameters. 37 var$_params = array(37 private $_params = array( 38 38 'character_set' => 'utf-8', 39 39 'cache_css' => false, … … 48 48 * @param array $params Array of parameters (key => val pairs). 49 49 */ 50 function setParam($params)50 public function setParam($params) 51 51 { 52 52 $app =& App::getInstance(); … … 67 67 * @return mixed Configured parameter value. 68 68 */ 69 function getParam($param)69 public function getParam($param) 70 70 { 71 71 $app =& App::getInstance(); … … 87 87 * @return bool True on success, false on failure. 88 88 */ 89 function setFile($file, $realms='')89 public function setFile($file, $realms='') 90 90 { 91 91 $app =& App::getInstance(); … … 115 115 * @return bool False if no files have been set. 116 116 */ 117 function headers($realm='')117 public function headers($realm='') 118 118 { 119 119 $app =& App::getInstance(); … … 157 157 * @return bool False if no files have been set. 158 158 */ 159 function output($realm='')159 public function output($realm='') 160 160 { 161 161 $realm = '' == $realm ? 'default' : $realm; … … 181 181 } 182 182 } 183 ?> -
trunk/lib/Cache.inc.php
r405 r468 4 4 * For details visit the project site: <http://trac.strangecode.com/codebase/> 5 5 * Copyright 2001-2012 Strangecode, LLC 6 * 6 * 7 7 * This file is part of The Strangecode Codebase. 8 8 * … … 11 11 * Free Software Foundation, either version 3 of the License, or (at your option) 12 12 * any later version. 13 * 13 * 14 14 * The Strangecode Codebase is distributed in the hope that it will be useful, but 15 15 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 16 16 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more 17 17 * details. 18 * 18 * 19 19 * You should have received a copy of the GNU General Public License along with 20 20 * The Strangecode Codebase. If not, see <http://www.gnu.org/licenses/>. … … 31 31 * @since 2001 32 32 */ 33 34 // Flags.35 define('CACHE_ALLOW_OVERSIZED', 1);36 33 37 34 class Cache { 38 35 36 // A place to keep object instances for the singleton pattern. 37 private static $instances = array(); 38 39 39 // Namespace of this instance of Prefs. 40 var$_ns;40 private $_ns; 41 41 42 42 // Configuration parameters for this object. 43 var $_params = array( 44 43 private $_params = array( 44 45 // Type of cache. Currently only 'session' is supported. 46 'type' => 'session', 47 45 48 // If false nothing will be cached or retrieved. Useful for testing realtime data requests. 46 49 'enabled' => true, … … 48 51 // The maximum size in bytes of any one variable. 49 52 'item_size_limit' => 4194304, // 4 MB 50 53 51 54 // The maximum size in bytes before the cache will begin flushing out old items. 52 55 'stack_size_limit' => 4194304, // 4 MB 53 56 54 57 // The minimum items to keep in the cache regardless of item or cache size. 55 58 'min_items' => 5, 56 59 ); 57 60 58 61 /* 59 * Constructor 62 * Constructor. This is publically accessible for compatability with older implementations, 63 * but the preferred method of instantiation is by use of the singleton pattern: 64 * $cache =& Cache::getInstance('namespace'); 65 * $cache->setParam(array('enabled' => true)); 60 66 * 61 67 * @access public … … 65 71 * @since 05 Jun 2006 23:14:21 66 72 */ 67 function Cache($namespace='')73 public function __construct($namespace='') 68 74 { 69 75 $app =& App::getInstance(); 70 76 71 77 $this->_ns = $namespace; 72 78 … … 75 81 $this->setParam(array('enabled' => false)); 76 82 } 77 83 78 84 if (!isset($_SESSION['_cache'][$this->_ns])) { 79 85 $this->clear(); … … 88 94 * @static 89 95 */ 90 static function &getInstance($namespace='') 91 { 92 static $instances = array(); 93 94 if (!array_key_exists($namespace, $instances)) { 95 $instances[$namespace] = new Cache($namespace); 96 } 97 98 return $instances[$namespace]; 96 public static function &getInstance($namespace='') 97 { 98 if (!array_key_exists($namespace, self::$instances)) { 99 self::$instances[$namespace] = new self($namespace); 100 } 101 return self::$instances[$namespace]; 99 102 } 100 103 … … 105 108 * @param array $params Array of parameters (key => val pairs). 106 109 */ 107 function setParam($params)110 public function setParam($params) 108 111 { 109 112 $app =& App::getInstance(); … … 124 127 * @return mixed Configured parameter value. 125 128 */ 126 function getParam($param)129 public function getParam($param) 127 130 { 128 131 $app =& App::getInstance(); 129 132 130 133 if (isset($this->_params[$param])) { 131 134 return $this->_params[$param]; … … 138 141 /** 139 142 * Stores a new variable in the session cache. The $key should not be numeric 140 * because the array_shift function will reset the key to the next largest 143 * because the array_shift function will reset the key to the next largest 141 144 * int key. Weird behavior I can't understand. For example $cache["123"] will become $cache[0] 142 145 * 143 * @param str $key An identifier for the cached object. 144 * @param mixed $var The var to store in the session cache. 145 * @param bool $flags If we have something really big that we 146 * still want to cache, setting this to 147 * CACHE_ALLOW_OVERSIZED allows this. 148 * @return bool True on success, false otherwise. 149 */ 150 function set($key, $var, $flags=0) 146 * @param str $key An identifier for the cached object. 147 * @param mixed $var The data to store in the session cache. 148 * @param bool $allow_oversized If we have something really big that we still want to cache, setting this to true allows this. 149 * @return bool True on success, false otherwise. 150 */ 151 public function set($key, $var, $allow_oversized=false) 151 152 { 152 153 $app =& App::getInstance(); … … 157 158 } 158 159 160 if (is_numeric($key)) { 161 $app->logMsg(sprintf('Cache::set key value should not be numeric (%s given)', $key), LOG_WARNING, __FILE__, __LINE__); 162 } 163 159 164 $var = serialize($var); 160 165 $var_len = mb_strlen($var); … … 165 170 } 166 171 167 if ($ flags & CACHE_ALLOW_OVERSIZED == 0&& $var_len >= $this->getParam('stack_size_limit')) {172 if ($allow_oversized && $var_len >= $this->getParam('stack_size_limit')) { 168 173 $app->logMsg(sprintf('Serialized variable (%s bytes) more than stack_size_limit (%s bytes).', $var_len, $this->getParam('stack_size_limit')), LOG_NOTICE, __FILE__, __LINE__); 169 174 return false; 170 } 175 } 171 176 172 177 // Remove any value already stored under this key. … … 197 202 * @return mixed The requested datum, or false on failure. 198 203 */ 199 function get($key)204 public function get($key) 200 205 { 201 206 $app =& App::getInstance(); … … 226 231 * @return bool True if a value exists for the given key. 227 232 */ 228 function exists($key)233 public function exists($key) 229 234 { 230 235 $app =& App::getInstance(); … … 244 249 * @return bool True if the value existed before being unset. 245 250 */ 246 function delete($key)251 public function delete($key) 247 252 { 248 253 if (array_key_exists($key, $_SESSION['_cache'][$this->_ns])) { … … 253 258 } 254 259 } 255 260 256 261 /* 257 262 * Delete all existing items from the cache. … … 262 267 * @since 05 Jun 2006 23:51:34 263 268 */ 264 function clear()269 public function clear() 265 270 { 266 271 $_SESSION['_cache'][$this->_ns] = array(); … … 270 275 } 271 276 272 ?> -
trunk/lib/Captcha.inc.php
r396 r468 54 54 class Captcha { 55 55 56 var$secret_key = 'some random seed text for the md5';57 var$random_number;58 var$ascii_numbers = array(56 public $secret_key = 'some random seed text for the md5'; 57 public $random_number; 58 public $ascii_numbers = array( 59 59 array( 60 60 ' ##### ', … … 147 147 * @since 20 Jan 2006 13:08:22 148 148 */ 149 function Captcha()149 public function __construct() 150 150 { 151 151 $app =& App::getInstance(); … … 164 164 * @since 07 Dec 2005 21:59:25 165 165 */ 166 function getAsciiNumber($num=null)166 public function getAsciiNumber($num=null) 167 167 { 168 168 $app =& App::getInstance(); … … 200 200 * @since 07 Dec 2005 22:09:04 201 201 */ 202 function printAsciiNumber()202 public function printAsciiNumber() 203 203 { 204 204 $ascii = $this->getAsciiNumber($this->random_number); … … 213 213 * @since 07 Dec 2005 22:09:04 214 214 */ 215 function printForm()215 public function printForm() 216 216 { 217 217 $hash = $this->_getMD5key($this->random_number); … … 231 231 * @since 07 Dec 2005 22:19:33 232 232 */ 233 function valid()233 public function valid() 234 234 { 235 235 $number = getFormData('sc-captcha-input'); … … 251 251 * @since 07 Dec 2005 21:40:25 252 252 */ 253 function _getRandomNumber()253 public function _getRandomNumber() 254 254 { 255 255 return mb_substr(strval(rand(10000, 99999)), 0, rand(3, 5)); … … 265 265 * @since 07 Dec 2005 21:53:35 266 266 */ 267 function _getMD5key($input)267 public function _getMD5key($input) 268 268 { 269 269 return md5($this->secret_key . $input); … … 272 272 } 273 273 274 ?> -
trunk/lib/Cart.inc.php
r396 r468 71 71 72 72 // Namespace of this instance. 73 var$_ns;73 private $_ns; 74 74 75 75 // Configuration parameters for this object. 76 var$_params = array(76 private $_params = array( 77 77 ); 78 78 … … 80 80 * Cart constructor. 81 81 */ 82 function Cart($namespace='')82 public function __construct($namespace='') 83 83 { 84 84 $app =& App::getInstance(); … … 97 97 * @param array $params Array of param keys and values to set. 98 98 */ 99 function setParam($params=null)99 public function setParam($params=null) 100 100 { 101 101 if (isset($params) && is_array($params)) { … … 112 112 * @return mixed Configured parameter value. 113 113 */ 114 function getParam($param)114 public function getParam($param) 115 115 { 116 116 $app =& App::getInstance(); … … 137 137 * @since 11 Mar 2008 18:59:37 138 138 */ 139 function add($item_id, $price, $quantity=1, $specs=array())139 public function add($item_id, $price, $quantity=1, $specs=array()) 140 140 { 141 141 $app =& App::getInstance(); … … 166 166 * @since 10 May 2008 16:42:25 167 167 */ 168 function setQty($item_id, $quantity)168 public function setQty($item_id, $quantity) 169 169 { 170 170 if ($quantity <= 0) { … … 195 195 * @since 10 May 2008 16:42:25 196 196 */ 197 function setPrice($item_id, $price)197 public function setPrice($item_id, $price) 198 198 { 199 199 if (isset($_SESSION['_cart'][$this->_ns]['items'][$item_id])) { … … 218 218 * @since 11 Mar 2008 18:59:48 219 219 */ 220 function remove($item_id)220 public function remove($item_id) 221 221 { 222 222 $app =& App::getInstance(); … … 242 242 * @since 11 Mar 2008 18:59:55 243 243 */ 244 function get($item_id, $spec_key)244 public function get($item_id, $spec_key) 245 245 { 246 246 if (isset($_SESSION['_cart'][$this->_ns]['items'][$item_id][$spec_key])) { … … 259 259 * @since 11 Mar 2008 18:59:55 260 260 */ 261 function getList()261 public function getList() 262 262 { 263 263 return $_SESSION['_cart'][$this->_ns]['items']; … … 277 277 * @since 11 Mar 2008 19:00:12 278 278 */ 279 function sum($key='extended_price')279 public function sum($key='extended_price') 280 280 { 281 281 $sum = 0; … … 306 306 * as $auth->clear(), such as when logging out. 307 307 */ 308 function clear()308 public function clear() 309 309 { 310 310 $_SESSION['_cart'][$this->_ns] = array( … … 313 313 } 314 314 } 315 316 317 ?> -
trunk/lib/Currency.inc.php
r411 r468 41 41 42 42 // Configuration parameters for this object. 43 var$_params = array(43 private $_params = array( 44 44 'cache_result' => true, 45 45 'cache_dir' => '', … … 52 52 * Cart constructor. 53 53 */ 54 function Currency($params=array())54 public function __construct($params=array()) 55 55 { 56 56 $app =& App::getInstance(); … … 79 79 * @param array $params Array of param keys and values to set. 80 80 */ 81 function setParam($params=null)81 public function setParam($params=null) 82 82 { 83 83 if (isset($params) && is_array($params)) { … … 94 94 * @return mixed Configured parameter value. 95 95 */ 96 function getParam($param)96 public function getParam($param) 97 97 { 98 98 $app =& App::getInstance(); … … 118 118 * @since 05 May 2008 23:50:59 119 119 */ 120 function getValue($amount, $base, $target)120 public function getValue($amount, $base, $target) 121 121 { 122 122 if (false !== $rate = $this->getRate($base, $target)) { … … 138 138 * @since 25 May 2011 01:26:24 139 139 */ 140 function getRate($base, $target)140 public function getRate($base, $target) 141 141 { 142 142 $app =& App::getInstance(); … … 180 180 * @access private 181 181 */ 182 function _performAPICall($parameters=null)182 private function _performAPICall($parameters=null) 183 183 { 184 184 $app =& App::getInstance(); … … 251 251 252 252 253 ?> -
trunk/lib/DB.inc.php
r465 r468 32 32 class DB { 33 33 34 // A place to keep an object instance for the singleton pattern. 35 private static $instance = null; 36 34 37 // If $db->connect has successfully opened a db connection. 35 var$_connected = false;38 private $_connected = false; 36 39 37 40 // Database handle. 38 var$dbh;41 public $dbh; 39 42 40 43 // Count how many queries run during the whole instance. 41 var$_query_count = 0;44 private $_query_count = 0; 42 45 43 46 // Hash of DB parameters. 44 var$_params = array();47 private $_params = array(); 45 48 46 49 // Default parameters. 47 var$_param_defaults = array(50 private $_param_defaults = array( 48 51 49 52 // DB passwords should be set as apache environment variables in httpd.conf, readable only by root. … … 64 67 65 68 // Translate between HTML and MySQL character set names. 66 var$mysql_character_sets = array(69 public $mysql_character_sets = array( 67 70 'utf-8' => 'utf8', 68 71 'iso-8859-1' => 'latin1', … … 70 73 71 74 // Caches. 72 var$existing_tables;73 var$table_columns;75 private $existing_tables; 76 private $table_columns; 74 77 75 78 /** … … 80 83 * @static 81 84 */ 82 static function &getInstance() 83 { 84 static $instance = null; 85 86 if ($instance === null) { 87 $instance = new DB(); 88 } 89 90 return $instance; 85 public static function &getInstance() 86 { 87 if (self::$instance === null) { 88 self::$instance = new self(); 89 } 90 91 return self::$instance; 91 92 } 92 93 … … 98 99 * @param array $params Array of parameters (key => val pairs). 99 100 */ 100 function setParam($params)101 public function setParam($params) 101 102 { 102 103 $app =& App::getInstance(); … … 117 118 * @return mixed Configured parameter value. 118 119 */ 119 function getParam($param)120 public function getParam($param) 120 121 { 121 122 $app =& App::getInstance(); … … 136 137 * @since 28 Aug 2005 14:02:49 137 138 */ 138 function connect()139 public function connect() 139 140 { 140 141 $app =& App::getInstance(); … … 146 147 147 148 // Connect to database. Always create a new link to the server. 148 if ($this->dbh = mysql_connect($this->getParam('db_server'), $this->getParam('db_user'), $this->getParam('db_pass'), true)) {149 if ($this->dbh = @mysql_connect($this->getParam('db_server'), $this->getParam('db_user'), $this->getParam('db_pass'), true)) { 149 150 // Select database 150 151 mysql_select_db($this->getParam('db_name'), $this->dbh); … … 185 186 * @since 28 Aug 2005 14:32:01 186 187 */ 187 function close()188 public function close() 188 189 { 189 190 if (!$this->_connected) { … … 204 205 * @since 03 Jul 2013 14:50:23 205 206 */ 206 function reconnect()207 public function reconnect() 207 208 { 208 209 $this->close(); … … 221 222 * @since 15 Jan 2007 15:59:00 222 223 */ 223 function _fail()224 private function _fail() 224 225 { 225 226 if ($this->getParam('db_die_on_failure')) { … … 240 241 * @since 20 Aug 2005 13:50:36 241 242 */ 242 function getDBH()243 public function getDBH() 243 244 { 244 245 if (!$this->_connected) { … … 256 257 * @since 28 Aug 2005 14:58:09 257 258 */ 258 function isConnected()259 public function isConnected() 259 260 { 260 261 return (true === $this->_connected); … … 270 271 * @since 06 Mar 2006 16:41:32 271 272 */ 272 function escapeString($string)273 public function escapeString($string) 273 274 { 274 275 if (!$this->_connected) { … … 287 288 * @return resource Query identifier 288 289 */ 289 function query($query, $debug=false)290 public function query($query, $debug=false) 290 291 { 291 292 $app =& App::getInstance(); … … 336 337 * @return bool true if given $table exists. 337 338 */ 338 function tableExists($table, $use_cached_results=true)339 public function tableExists($table, $use_cached_results=true) 339 340 { 340 341 $app =& App::getInstance(); … … 368 369 * @return bool true if column(s) exist. 369 370 */ 370 function columnExists($table, $columns, $strict=true, $use_cached_results=true)371 public function columnExists($table, $columns, $strict=true, $use_cached_results=true) 371 372 { 372 373 if (!$this->_connected) { … … 416 417 * @since 15 Jun 2006 11:46:05 417 418 */ 418 function numQueries()419 public function numQueries() 419 420 { 420 421 return $this->_query_count; … … 428 429 * @since 28 Aug 2005 22:10:50 429 430 */ 430 function resetCache()431 public function resetCache() 431 432 { 432 433 $this->existing_tables = null; … … 436 437 } // End. 437 438 438 ?> -
trunk/lib/DBSessionHandler.inc.php
r398 r468 32 32 class DBSessionHandler { 33 33 34 var$db; // DB object.34 public $db; // DB object. 35 35 36 var$_params = array(36 private $_params = array( 37 37 'db_table' => 'session_tbl', 38 38 … … 51 51 * @since 18 Jul 2005 11:02:50 52 52 */ 53 function DBSessionHandler($db, $params=array())53 public function __construct($db, $params=array()) 54 54 { 55 55 $app =& App::getInstance(); … … 94 94 * @since 26 Aug 2005 17:09:36 95 95 */ 96 function initDB($recreate_db=false)96 public function initDB($recreate_db=false) 97 97 { 98 98 $app =& App::getInstance(); … … 121 121 } 122 122 123 function dbSessionOpen($save_path, $sess_name)123 public function dbSessionOpen($save_path, $sess_name) 124 124 { 125 125 return true; 126 126 } 127 127 128 function dbSessionClose()128 public function dbSessionClose() 129 129 { 130 130 return true; 131 131 } 132 132 133 function dbSessionRead($session_id)133 public function dbSessionRead($session_id) 134 134 { 135 135 // Select the data belonging to session $session_id from the session table … … 146 146 } 147 147 148 function dbSessionWrite($session_id, $session_data)148 public function dbSessionWrite($session_id, $session_data) 149 149 { 150 150 // Write the serialized session data ($session_data) to the session table … … 154 154 } 155 155 156 function dbSessionDestroy($session_id)156 public function dbSessionDestroy($session_id) 157 157 { 158 158 // Delete from the table all data for the session $session_id … … 162 162 } 163 163 164 function dbSessionGarbage($max_lifetime=72000)164 public function dbSessionGarbage($max_lifetime=72000) 165 165 { 166 166 // Delete old values from the session table. … … 171 171 } 172 172 173 ?> -
trunk/lib/Email.inc.php
r460 r468 56 56 57 57 // Default parameters, to be overwritten by setParam() and read with getParam() 58 var$_params = array(58 private $_params = array( 59 59 'to' => null, 60 60 'from' => null, … … 74 74 75 75 // String that contains the email body. 76 var$_template;76 private $_template; 77 77 78 78 // String that contains the email body after replacements. 79 var$_template_replaced;79 private $_template_replaced; 80 80 81 81 /** … … 87 87 * @since 28 Nov 2005 12:59:41 88 88 */ 89 function Email($params=null)89 public function __construct($params=null) 90 90 { 91 91 // The regex used in validEmail(). Set here instead of in the default _params above so we can use the concatenation . dot. … … 118 118 * @param array $params Array of parameters (key => val pairs). 119 119 */ 120 function setParam($params)120 public function setParam($params) 121 121 { 122 122 $app =& App::getInstance(); … … 145 145 * @return mixed Configured parameter value. 146 146 */ 147 function getParam($param)147 public function getParam($param) 148 148 { 149 149 $app =& App::getInstance(); … … 165 165 * @since 28 Nov 2005 12:56:23 166 166 */ 167 function setTemplate($template)167 public function setTemplate($template) 168 168 { 169 169 $app =& App::getInstance(); … … 189 189 * @since 28 Nov 2005 12:56:23 190 190 */ 191 function setString($string)191 public function setString($string) 192 192 { 193 193 $app =& App::getInstance(); … … 213 213 * @since 28 Nov 2005 13:08:51 214 214 */ 215 function replace($replacements)215 public function replace($replacements) 216 216 { 217 217 $app =& App::getInstance(); … … 250 250 * @since 28 Nov 2005 12:56:09 251 251 */ 252 function send($to=null, $from=null, $subject=null, $headers=null)252 public function send($to=null, $from=null, $subject=null, $headers=null) 253 253 { 254 254 $app =& App::getInstance(); … … 364 364 * @since 30 Nov 2005 22:00:50 365 365 */ 366 function validEmail($email)366 public function validEmail($email) 367 367 { 368 368 $app =& App::getInstance(); … … 388 388 } 389 389 390 ?> -
trunk/lib/FormValidator.inc.php
r459 r468 58 58 require_once 'codebase/lib/Validator.inc.php'; 59 59 60 class FormValidator extends Validator{60 class FormValidator { 61 61 62 62 // Class parameters. 63 var$_params = array(63 private $_params = array( 64 64 'error' => ' sc-msg-error ', 65 65 'warning' => ' sc-msg-warning ', … … 69 69 70 70 // Array filling with error messages. 71 var$errors = array();71 public $errors = array(); 72 72 73 73 /** … … 77 77 * @param array $params Array of parameters (key => val pairs). 78 78 */ 79 function setParam($params)79 public function setParam($params) 80 80 { 81 81 $app =& App::getInstance(); … … 96 96 * @return mixed Configured parameter value. 97 97 */ 98 function getParam($param)98 public function getParam($param) 99 99 { 100 100 $app =& App::getInstance(); … … 115 115 * vals: the message to display for that error 116 116 */ 117 function getErrorList()117 public function getErrorList() 118 118 { 119 119 return $this->errors; … … 130 130 * @param string $line __LINE__. 131 131 */ 132 function addError($form_name, $msg='', $type=MSG_ERR, $file=null, $line=null)132 public function addError($form_name, $msg='', $type=MSG_ERR, $file=null, $line=null) 133 133 { 134 134 $this->errors[] = array( … … 149 149 * a variable of $form_name, false otherwise 150 150 */ 151 function anyErrors($form_name=null)151 public function anyErrors($form_name=null) 152 152 { 153 153 if (isset($form_name)) { … … 166 166 * Reset the error list. 167 167 */ 168 function resetErrorList()168 public function resetErrorList() 169 169 { 170 170 $this->errors = array(); … … 182 182 * @since 15 Jul 2005 01:39:14 183 183 */ 184 function printErrorMessages($above='', $below='', $print_gotohash_js=false, $hash='sc-msg-formvalidator')184 public function printErrorMessages($above='', $below='', $print_gotohash_js=false, $hash='sc-msg-formvalidator') 185 185 { 186 186 $app =& App::getInstance(); … … 238 238 * not provided, use default. 239 239 */ 240 function err($form_name, $marker=null)240 public function err($form_name, $marker=null) 241 241 { 242 242 if (false !== ($type = $this->anyErrors($form_name))) { … … 274 274 * @return bool true if form is not empty, false otherwise. 275 275 */ 276 function notEmpty($form_name, $msg='')277 { 278 if ( parent::notEmpty(getFormData($form_name))) {276 public function notEmpty($form_name, $msg='') 277 { 278 if (Validator::notEmpty(getFormData($form_name))) { 279 279 return true; 280 280 } else { … … 290 290 * @since 03 Jun 2006 22:56:46 291 291 */ 292 function isEmpty($form_name, $msg='')292 public function isEmpty($form_name, $msg='') 293 293 { 294 294 $this->notEmpty($form_name, $msg); … … 303 303 * @return bool true if form is a string, false otherwise. 304 304 */ 305 function isString($form_name, $msg='')306 { 307 if ( parent::isString(getFormData($form_name))) {305 public function isString($form_name, $msg='') 306 { 307 if (Validator::isString(getFormData($form_name))) { 308 308 return true; 309 309 } else { … … 321 321 * @return bool true if no errors found, false otherwise 322 322 */ 323 function isNumber($form_name, $msg='')324 { 325 if ( parent::isNumber(getFormData($form_name))) {323 public function isNumber($form_name, $msg='') 324 { 325 if (Validator::isNumber(getFormData($form_name))) { 326 326 return true; 327 327 } else { … … 340 340 * @return bool true if value is an integer 341 341 */ 342 function isInteger($form_name, $msg='', $negative_ok=false)343 { 344 if ( parent::isInteger(getFormData($form_name), $negative_ok)) {342 public function isInteger($form_name, $msg='', $negative_ok=false) 343 { 344 if (Validator::isInteger(getFormData($form_name), $negative_ok)) { 345 345 return true; 346 346 } else { … … 360 360 * @return bool true if value is a float 361 361 */ 362 function isFloat($form_name, $msg='', $negative_ok=false)363 { 364 if ( parent::isFloat(getFormData($form_name), $negative_ok)) {362 public function isFloat($form_name, $msg='', $negative_ok=false) 363 { 364 if (Validator::isFloat(getFormData($form_name), $negative_ok)) { 365 365 return true; 366 366 } else { … … 378 378 * @return bool true if value is a float 379 379 */ 380 function isArray($form_name, $msg='')381 { 382 if ( parent::isArray(getFormData($form_name))) {380 public function isArray($form_name, $msg='') 381 { 382 if (Validator::isArray(getFormData($form_name))) { 383 383 return true; 384 384 } else { … … 399 399 * @return bool true if value passes regex test 400 400 */ 401 function checkRegex($form_name, $regex, $valid_on_match, $msg='')402 { 403 if ( parent::checkRegex(getFormData($form_name), $regex, $valid_on_match)) {401 public function checkRegex($form_name, $regex, $valid_on_match=true, $msg='') 402 { 403 if (Validator::checkRegex(getFormData($form_name), $regex, $valid_on_match)) { 404 404 return true; 405 405 } else { … … 419 419 * @return bool true if string length is within given boundaries 420 420 */ 421 function stringLength($form_name, $min, $max, $msg='')422 { 423 if ( parent::stringLength(getFormData($form_name), $min, $max)) {421 public function stringLength($form_name, $min, $max, $msg='') 422 { 423 if (Validator::stringLength(getFormData($form_name), $min, $max)) { 424 424 return true; 425 425 } else { … … 439 439 * @return bool true if no errors found, false otherwise 440 440 */ 441 function numericRange($form_name, $min, $max, $msg='')442 { 443 if ( parent::numericRange(getFormData($form_name), $min, $max)) {441 public function numericRange($form_name, $min, $max, $msg='') 442 { 443 if (Validator::numericRange(getFormData($form_name), $min, $max)) { 444 444 return true; 445 445 } else { … … 463 463 * @author Quinn Comendant <quinn@strangecode.com> 464 464 */ 465 function validateEmail($form_name)465 public function validateEmail($form_name, $strict=false) 466 466 { 467 467 $app =& App::getInstance(); … … 474 474 } 475 475 476 // Validator::validateEmail() returns a value that relates to the V ALIDATE_EMAIL_* constants (defined in Validator.inc.php).477 switch ( parent::validateEmail($email)) {478 case V ALIDATE_EMAIL_REGEX_FAIL:476 // Validator::validateEmail() returns a value that relates to the Validate::EMAIL_* constants (defined in Validator.inc.php). 477 switch (Validator::validateEmail($email, $strict)) { 478 case Validator::EMAIL_REGEX_FAIL: 479 479 // Failed regex match. 480 480 $this->addError($form_name, sprintf(_("The email address <em>%s</em> is formatted incorrectly."), oTxt($email))); 481 481 $app->logMsg(sprintf('The email address %s is not valid.', oTxt($email)), LOG_DEBUG, __FILE__, __LINE__); 482 482 return false; 483 break; 484 485 case VALIDATE_EMAIL_LENGTH_FAIL : 483 484 case Validator::EMAIL_LENGTH_FAIL : 486 485 // Failed length requirements. 487 486 $this->addError($form_name, sprintf(_("The email address <em>%s</em> is too long (email addresses must have fewer than 256 characters)."), oTxt($email))); 488 487 $app->logMsg(sprintf('The email address %s must contain less than 256 characters.', oTxt($email)), LOG_DEBUG, __FILE__, __LINE__); 489 488 return false; 490 break; 491 492 case VALIDATE_EMAIL_MX_FAIL : 489 490 case Validator::EMAIL_MX_FAIL : 493 491 // Failed MX record test. 494 492 $this->addError($form_name, sprintf(_("The email address <em>%s</em> does not have a valid domain name"), oTxt($email))); 495 493 $app->logMsg(sprintf('The email address %s does not have a valid domain name.', oTxt($email)), LOG_INFO, __FILE__, __LINE__); 496 494 return false; 497 break; 498 499 case VALIDATE_EMAIL_SUCCESS : 495 496 case Validator::EMAIL_SUCCESS : 500 497 default : 501 498 return true; 502 break;503 499 } 504 500 } … … 513 509 * @return bool true if no errors found, false otherwise 514 510 */ 515 function validatePhone($form_name) 516 { 511 public function validatePhone($form_name) 512 { 513 $app =& App::getInstance(); 514 517 515 $phone = getFormData($form_name); 518 516 519 return ( 520 $this->checkRegex($form_name, '/^[0-9 +().-]*$/', true, sprintf(_("The phone number <em>%s</em> is not valid."), $phone)) 521 && $this->stringLength($form_name, 0, 25, sprintf(_("The phone number <em>%s</em> is too long"), $phone)) 522 ); 517 // Validator::validateEmail() returns a value that relates to the Validate::PHONE_* constants (defined in Validator.inc.php). 518 switch (Validator::validatePhone($phone)) { 519 case Validator::PHONE_REGEX_FAIL: 520 // Failed regex match. 521 $this->addError($form_name, sprintf(_("The phone number <em>%s</em> is not valid."), oTxt($phone))); 522 $app->logMsg(sprintf('The phone number %s is not valid.', oTxt($phone)), LOG_DEBUG, __FILE__, __LINE__); 523 return false; 524 525 case Validator::PHONE_LENGTH_FAIL : 526 // Failed length requirements. 527 $this->addError($form_name, sprintf(_("The phone number <em>%s</em> is too long (phone number must have fewer than 25 characters)."), oTxt($phone))); 528 $app->logMsg(sprintf('The phone number %s must contain less than 256 characters.', oTxt($phone)), LOG_DEBUG, __FILE__, __LINE__); 529 return false; 530 531 case Validator::PHONE_SUCCESS : 532 default : 533 return true; 534 } 523 535 } 524 536 … … 531 543 * @return bool true if no errors found, false otherwise 532 544 */ 533 function validateStrDate($form_name, $msg='')545 public function validateStrDate($form_name, $msg='') 534 546 { 535 547 $app =& App::getInstance(); 536 548 537 if ( parent::validateStrDate(getFormData($form_name, ''))) {549 if (Validator::validateStrDate(getFormData($form_name, ''))) { 538 550 return true; 539 551 } else { … … 550 562 * 551 563 * @param string $form_name The name of the incoming form variable. 552 * @param string $cc_type Optional, card type to do specific checks. One of the CC_TYPE_* constants.564 * @param string $cc_type Optional, card type to do specific checks. One of the Validator::CC_TYPE_* constants. 553 565 * 554 566 * @return bool true if no errors found, false otherwise 555 567 */ 556 function validateCCNumber($form_name, $cc_type=null)568 public function validateCCNumber($form_name, $cc_type=null) 557 569 { 558 570 $cc_num = getFormData($form_name); 559 571 560 if ( parent::validateCCNumber($cc_num, $cc_type)) {572 if (Validator::validateCCNumber($cc_num, $cc_type)) { 561 573 return true; 562 574 } else { … … 574 586 * @return bool true if no errors found, false otherwise 575 587 */ 576 function fileUploaded($form_name, $msg='')577 { 578 if ( parent::fileUploaded($form_name)) {588 public function fileUploaded($form_name, $msg='') 589 { 590 if (Validator::fileUploaded($form_name)) { 579 591 return true; 580 592 } else { … … 586 598 } // THE END 587 599 588 ?> -
trunk/lib/Google_API.inc.php
r396 r468 53 53 * @access private 54 54 */ 55 var$_licenseKey = '';55 private $_licenseKey = ''; 56 56 57 57 /** … … 59 59 * @access private 60 60 */ 61 var$_soapClient = NULL;61 private $_soapClient = NULL; 62 62 63 63 /** … … 67 67 * @access public 68 68 */ 69 function Google_API($licenseKey)69 public function __construct($licenseKey) 70 70 { 71 71 $this->_licenseKey = $licenseKey; … … 82 82 * @access public 83 83 */ 84 function getCachedPage($url)84 public function getCachedPage($url) 85 85 { 86 86 $result = $this->_performAPICall( … … 104 104 * @access public 105 105 */ 106 function getSpellingSuggestion($phrase)106 public function getSpellingSuggestion($phrase) 107 107 { 108 108 return $this->_performAPICall( … … 122 122 * @access public 123 123 */ 124 function search($parameters = array())124 public function search($parameters = array()) 125 125 { 126 126 if (!isset($parameters['query'])) { … … 150 150 * @access private 151 151 */ 152 function _performAPICall($apiCall, $parameters)152 private function _performAPICall($apiCall, $parameters) 153 153 { 154 154 $app =& App::getInstance(); … … 167 167 } 168 168 } 169 ?>170 171 -
trunk/lib/Hierarchy.inc.php
r441 r468 52 52 * 53 53 */ 54 var$params = array();54 public $params = array(); 55 55 56 56 … … 59 59 * @var string $child_type 60 60 */ 61 var$child_type;61 public $child_type; 62 62 63 63 /** … … 65 65 * @var string $child_id 66 66 */ 67 var$child_id;67 public $child_id; 68 68 69 69 /** … … 72 72 * @var bool $node_init 73 73 */ 74 var$node_init = false;74 public $node_init = false; 75 75 76 76 /** … … 80 80 * configuration or connection parameters. 81 81 */ 82 function Hierarchy($params=array())82 public function __construct($params=array()) 83 83 { 84 84 $this->params = $params; … … 92 92 * if no new ones are specified. 93 93 */ 94 function currentNode($child_type=null, $child_id=null)94 public function currentNode($child_type=null, $child_id=null) 95 95 { 96 96 $old_type = isset($this->child_type) ? $this->child_type : $child_type; … … 113 113 * otherwise if an array is provided, an array of identifiers is returned. 114 114 */ 115 function toStringID($child_type=null, $child_id=null)115 public function toStringID($child_type=null, $child_id=null) 116 116 { 117 117 $app =& App::getInstance(); … … 147 147 * @return mixed Array of node type and id on success, false on failure. 148 148 */ 149 function toArrayID(&$node)149 public function toArrayID(&$node) 150 150 { 151 151 $app =& App::getInstance(); … … 167 167 * @return bool true on success, false on error. 168 168 */ 169 function insertNode($parents, $child_type=null, $child_id=null, $relationship_type=null, $title='')169 public function insertNode($parents, $child_type=null, $child_id=null, $relationship_type=null, $title='') 170 170 { 171 171 $app =& App::getInstance(); … … 246 246 * @return bool false on error, true otherwise. 247 247 */ 248 function deleteNode($child_type=null, $child_id=null)248 public function deleteNode($child_type=null, $child_id=null) 249 249 { 250 250 $app =& App::getInstance(); … … 296 296 * @return bool false on error, true otherwise. 297 297 */ 298 function moveNode($new_parents=null, $child_type=null, $child_id=null, $relationship_type=null, $title='')298 public function moveNode($new_parents=null, $child_type=null, $child_id=null, $relationship_type=null, $title='') 299 299 { 300 300 $app =& App::getInstance(); … … 373 373 * @return string The parents as an array of serialized node identifiers. 374 374 */ 375 function getParents($child_type=null, $child_id=null, $type_constraint=null, $order='')375 public function getParents($child_type=null, $child_id=null, $type_constraint=null, $order='') 376 376 { 377 377 $app =& App::getInstance(); … … 424 424 * @return array type, id, title, subnode_quantity. 425 425 */ 426 function getNode($child_type=null, $child_id=null)426 public function getNode($child_type=null, $child_id=null) 427 427 { 428 428 $app =& App::getInstance(); … … 468 468 * @return string The children as an array of serialized node identifiers. 469 469 */ 470 function getChildren($child_type=null, $child_id=null, $type_constraint=null, $order='')470 public function getChildren($child_type=null, $child_id=null, $type_constraint=null, $order='') 471 471 { 472 472 $app =& App::getInstance(); … … 520 520 * @return integer 521 521 */ 522 function getNumberChildren($child_type=null, $child_id=null, $type_constraint=null)522 public function getNumberChildren($child_type=null, $child_id=null, $type_constraint=null) 523 523 { 524 524 $app =& App::getInstance(); … … 561 561 * @return bool true if a leaf, or false if not or an error 562 562 */ 563 function isLeaf($child_type=null, $child_id=null)563 public function isLeaf($child_type=null, $child_id=null) 564 564 { 565 565 $app =& App::getInstance(); … … 595 595 * parent, or false otherwise, or in case of failure. 596 596 */ 597 function isAncestor($child_type, $child_id, $considered_parent_type, $considered_parent_id)597 public function isAncestor($child_type, $child_id, $considered_parent_type, $considered_parent_id) 598 598 { 599 599 $family_tree = $this->getAllAncestors($considered_parent_type, $considered_parent_id); … … 622 622 * @return array Array of serialized node identifiers. 623 623 */ 624 function getAllAncestors($child_type, $child_id, $go_linear=false, $_return_flag=true)624 public function getAllAncestors($child_type, $child_id, $go_linear=false, $_return_flag=true) 625 625 { 626 626 $db =& DB::getInstance(); … … 676 676 * @return bool true if a leaf, or false if not or an error 677 677 */ 678 function nodeExists($child_type=null, $child_id=null, $parent_type=null, $parent_id=null, $relationship_type=null)678 public function nodeExists($child_type=null, $child_id=null, $parent_type=null, $parent_id=null, $relationship_type=null) 679 679 { 680 680 $app =& App::getInstance(); … … 728 728 * specified node: (type, id, title, indent level, selected status) 729 729 */ 730 function &getNodeList($preselected=null, $child_type=null, $child_id=null, $type_constraint=null, $include_curr=false, $order='', $_indent=0, $_return_flag=true)730 public function &getNodeList($preselected=null, $child_type=null, $child_id=null, $type_constraint=null, $include_curr=false, $order='', $_indent=0, $_return_flag=true) 731 731 { 732 732 $app =& App::getInstance(); … … 801 801 * @param string $type_constraint An array of node types to restrict the search to. 802 802 */ 803 function rebuildSubnodeQty($type_constraint=null)803 public function rebuildSubnodeQty($type_constraint=null) 804 804 { 805 805 $db =& DB::getInstance(); … … 825 825 * all parents recursively. 826 826 */ 827 function setSubnodeQtyToParents($child_type, $child_id, $num_children)827 public function setSubnodeQtyToParents($child_type, $child_id, $num_children) 828 828 { 829 829 $db =& DB::getInstance(); … … 848 848 // THE END 849 849 } 850 851 852 853 854 ?> -
trunk/lib/Image.inc.php
r452 r468 31 31 32 32 // Object parameters. 33 var$_params = array();33 private $_params = array(); 34 34 35 35 /** … … 41 41 * @since 26 Jan 2005 01:54:50 42 42 */ 43 function Image($params=array())43 public function __construct($params=array()) 44 44 { 45 45 if (!is_array($params)) { … … 72 72 * @since 26 Jan 2005 01:54:50 73 73 */ 74 function exists($id)74 public function exists($id) 75 75 { 76 76 $src = $this->oSrc($id); … … 96 96 * @since 26 Jan 2005 01:54:50 97 97 */ 98 function size($id, $key)98 public function size($id, $key) 99 99 { 100 100 $src = $this->oSrc($id); … … 114 114 * @since 26 Jan 2005 01:56:35 115 115 */ 116 function oSrc($id)116 public function oSrc($id) 117 117 { 118 118 $file_name = ''; … … 139 139 * @since 26 Jan 2005 01:57:33 140 140 */ 141 function oImg($id, $alt='', $extra='')141 public function oImg($id, $alt='', $extra='') 142 142 { 143 143 $src = $this->oSrc($id); … … 158 158 } 159 159 } // End class 160 161 ?> -
trunk/lib/ImageThumb.inc.php
r396 r468 4 4 * For details visit the project site: <http://trac.strangecode.com/codebase/> 5 5 * Copyright 2001-2012 Strangecode, LLC 6 * 6 * 7 7 * This file is part of The Strangecode Codebase. 8 8 * … … 11 11 * Free Software Foundation, either version 3 of the License, or (at your option) 12 12 * any later version. 13 * 13 * 14 14 * The Strangecode Codebase is distributed in the hope that it will be useful, but 15 15 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 16 16 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more 17 17 * details. 18 * 18 * 19 19 * You should have received a copy of the GNU General Public License along with 20 20 * The Strangecode Codebase. If not, see <http://www.gnu.org/licenses/>. … … 41 41 42 42 class ImageThumb { 43 43 44 44 // General object parameters. 45 var$_params = array(45 private $_params = array( 46 46 // The location for images to create thumbnails from. 47 47 'source_dir' => null, … … 58 58 // Require file to have one of the following file name extensions. 59 59 'valid_file_extensions' => array('jpg', 'jpeg', 'gif', 'png'), 60 60 61 61 // Method to use for resizing. (IMAGETHUMB_METHOD_NETPBM or IMAGETHUMB_METHOD_GD) 62 62 'resize_method' => IMAGETHUMB_METHOD_NETPBM, … … 70 70 'display_messages' => MSG_ALL, 71 71 ); 72 72 73 73 // Default image size specs. 74 var$_default_image_specs = array(75 // The destination for an image thumbnail size. 74 private $_default_image_specs = array( 75 // The destination for an image thumbnail size. 76 76 // Use initial / to specify absolute paths, leave off to specify a path relative to source_dir (eg: ../thumbs). 77 77 'dest_dir' => null, 78 78 79 79 // Destination file types. (IMG_JPG, IMG_PNG, IMG_GIF, IMG_WBMP) 80 80 'dest_file_type' => IMG_JPG, … … 82 82 // Destination file types. ('jpg', 'png', 'gif', 'wbmp') 83 83 'dest_file_extension' => 'jpg', 84 84 85 85 // Type of scaling to perform, and sizes used to calculate max dimensions. 86 86 'scaling_type' => IMAGETHUMB_FIT_LARGER, … … 96 96 // If using GD method, apply sharpen filter. Requires PHP > 5.1. 97 97 'sharpen' => true, 98 98 99 99 // Integers between 1-100, useful values are 65-85. 100 100 'sharpen_value' => 75, … … 108 108 109 109 // Final specifications for image sizes, set with setSpec(). 110 var$_image_specs = array();110 private $_image_specs = array(); 111 111 112 112 /** … … 116 116 * @param array $params Array of parameters (key => val pairs). 117 117 */ 118 function setParam($params)118 public function setParam($params) 119 119 { 120 120 $app =& App::getInstance(); … … 160 160 * @return mixed Configured parameter value. 161 161 */ 162 function getParam($param)163 { 164 $app =& App::getInstance(); 165 162 public function getParam($param) 163 { 164 $app =& App::getInstance(); 165 166 166 if (isset($this->_params[$param])) { 167 167 return $this->_params[$param]; … … 180 180 * Use to overwrite existing spec array values. 181 181 */ 182 function setSpec($spec, $index=null)182 public function setSpec($spec, $index=null) 183 183 { 184 184 $app =& App::getInstance(); … … 188 188 $app->logMsg('setSpec error: dest_dir not specified.', LOG_ERR, __FILE__, __LINE__); 189 189 } else { 190 $spec['dest_dir'] = trim($spec['dest_dir']); 190 $spec['dest_dir'] = trim($spec['dest_dir']); 191 191 } 192 192 if (isset($spec['dest_file_type'])) { … … 233 233 $app->logMsg('The "progressive" specification is not used unless IMG_JPG is the dest_file_type.', LOG_INFO, __FILE__, __LINE__); 234 234 } 235 235 236 236 // Add to _image_specs array. 237 237 if (isset($index) && isset($this->_image_specs[$index])) { … … 241 241 } else { 242 242 // Merge with spec defaults. 243 $final_spec = array_merge($this->_default_image_specs, $spec); 243 $final_spec = array_merge($this->_default_image_specs, $spec); 244 244 $this->_image_specs[] = $final_spec; 245 245 } 246 246 247 247 return $final_spec; 248 248 } 249 249 250 250 /* 251 251 * Retrieve a value of a thumb specification. … … 259 259 * @since 08 May 2007 15:26:39 260 260 */ 261 function getSpec($key, $index=null)261 public function getSpec($key, $index=null) 262 262 { 263 263 $index = isset($index) ? $index : 0; … … 271 271 * @return bool true on success, false on failure. 272 272 */ 273 function processAll($runtime_specs=null)273 public function processAll($runtime_specs=null) 274 274 { 275 275 $app =& App::getInstance(); … … 313 313 * @return bool true on success, false on failure. 314 314 */ 315 function processFile($file_name, $runtime_specs=null)315 public function processFile($file_name, $runtime_specs=null) 316 316 { 317 317 $app =& App::getInstance(); … … 319 319 // Source file determined by provided file_name. 320 320 $source_file = realpath(sprintf('%s/%s', $this->getParam('source_dir'), $file_name)); 321 321 322 322 // Ensure we have a source. 323 323 if (sizeof($this->_image_specs) < 1) { … … 326 326 } else { 327 327 $app->logMsg(sprintf('Image specifications not set before processing.'), LOG_ERR, __FILE__, __LINE__); 328 return false; 328 return false; 329 329 } 330 330 } … … 369 369 return false; 370 370 } 371 371 372 372 // To keep this script running even if user tries to stop browser. 373 373 ignore_user_abort(true); … … 379 379 380 380 foreach ($this->_image_specs as $index => $spec) { 381 381 382 382 if (is_array($runtime_specs)) { 383 383 // Override with runtime specs. 384 384 $spec = $this->setSpec($runtime_specs, $index); 385 385 } 386 386 387 387 // Destination filename uses the extension defined by dest_file_extension. 388 388 if ('/' == $spec['dest_dir']{0}) { … … 393 393 $dest_file = sprintf('%s/%s/%s.%s', $this->getParam('source_dir'), $spec['dest_dir'], mb_substr($file_name, 0, mb_strrpos($file_name, '.')), $spec['dest_file_extension']); 394 394 } 395 395 396 396 // Ensure destination directory exists and is writable. 397 397 if (!is_dir(dirname($dest_file)) || !is_writable(dirname($dest_file))) { … … 438 438 return 0 === $return_val; 439 439 } 440 440 441 441 /* 442 442 * Use the Netpbm and libjpg cjpeg tools to generate a rescaled compressed image. … … 452 452 * @since 19 May 2006 13:55:46 453 453 */ 454 function _resizeWithNetpbm($source_file, $dest_file, $spec)454 private function _resizeWithNetpbm($source_file, $dest_file, $spec) 455 455 { 456 456 $app =& App::getInstance(); … … 491 491 ); 492 492 $app->logMsg(sprintf('ImageThumb Netpbm command: %s', $command), LOG_DEBUG, __FILE__, __LINE__); 493 493 494 494 // Execute! 495 495 exec($command, $output, $return_val); … … 521 521 * @since 19 May 2006 15:46:02 522 522 */ 523 function _resizeWithGD($source_file, $dest_file, $spec)523 private function _resizeWithGD($source_file, $dest_file, $spec) 524 524 { 525 525 $app =& App::getInstance(); … … 593 593 return 1; 594 594 } 595 595 596 596 // Create destination image data in memory. 597 597 $dest_image_resource = imagecreatetruecolor($dest_image_width, $dest_image_height); … … 605 605 return 1; 606 606 } 607 607 608 608 // Sharpen image using a custom filter matrix. 609 609 if (phpversion() > '5.1' && true === $spec['sharpen'] && $spec['sharpen_value'] > 0) { 610 $sharpen_value = round((((48 - 10) / (100 - 1)) * (100 - $spec['sharpen_value'])) + 10); // /WTF is this math?611 imageconvolution($dest_image_resource, array(array(-1, -1,-1),array(-1,$sharpen_value,-1),array(-1,-1,-1)), ($sharpen_value - 8), 0);610 $sharpen_value = round((((48 - 10) / (100 - 1)) * (100 - $spec['sharpen_value'])) + 10); // TODO: WTF is this math? 611 imageconvolution($dest_image_resource, array(array(-1, -1, -1), array(-1, $sharpen_value, -1),array(-1, -1, -1)), ($sharpen_value - 8), 0); 612 612 } 613 613 … … 662 662 * @return bool true on success, false on failure. 663 663 */ 664 function deleteThumbs($file_name, $use_glob=false)664 public function deleteThumbs($file_name, $use_glob=false) 665 665 { 666 666 $app =& App::getInstance(); … … 677 677 $dest_dir = '/' == $spec['dest_dir']{0} ? $spec['dest_dir'] : sprintf('%s/%s', $this->getParam('source_dir'), $spec['dest_dir']); 678 678 if ($use_glob) { 679 $dest_file = realpath(sprintf('%s/%s', $dest_dir, $this->_glob($file_name, $dest_dir))); 679 $dest_file = realpath(sprintf('%s/%s', $dest_dir, $this->_glob($file_name, $dest_dir))); 680 680 } else { 681 681 $dest_file = realpath(sprintf('%s/%s.%s', $dest_dir, mb_substr($file_name, 0, mb_strrpos($file_name, '.')), $spec['dest_file_extension'])); 682 } 683 682 } 683 684 684 if (file_exists($dest_file)) { 685 685 if (!unlink($dest_file)) { … … 700 700 * @return bool true on success, false on failure. 701 701 */ 702 function deleteOriginal($file_name)702 public function deleteOriginal($file_name) 703 703 { 704 704 $app =& App::getInstance(); … … 733 733 * @return bool true on success, false on failure. 734 734 */ 735 function exists($file_name)735 public function exists($file_name) 736 736 { 737 737 $app =& App::getInstance(); … … 754 754 * @return bool True on success, false on failure. 755 755 */ 756 function _validFileExtension($file_name)756 private function _validFileExtension($file_name) 757 757 { 758 758 preg_match('/.*?\.(\w+)$/i', $file_name, $ext); 759 return !empty($ext) && in_array(mb_strtolower($ext[1]), $this->getParam('valid_file_extensions')); 759 return !empty($ext) && in_array(mb_strtolower($ext[1]), $this->getParam('valid_file_extensions')); 760 760 } 761 761 … … 766 766 * @return bool true on success, false on failure. 767 767 */ 768 function _createDestDirs($filename=null)768 private function _createDestDirs($filename=null) 769 769 { 770 770 $app =& App::getInstance(); … … 792 792 } 793 793 if (!file_exists($dest_dir)) { 794 // Recursively create destination directory. 794 795 $app->logMsg(sprintf('Creating dest dir: %s', $dest_dir), LOG_DEBUG, __FILE__, __LINE__); 795 if (phpversion() > '5') { 796 // Recursive. 797 if (!file_exists($dest_dir) && !($ret = mkdir($dest_dir, $this->getParam('dest_dir_perms'), true))) { 798 $return_val++; 799 $app->logMsg(sprintf('mkdir failure: %s', $dest_dir), LOG_ERR, __FILE__, __LINE__); 800 } 801 } else { 802 // Recursive mkdir for php 4. 803 $path = ''; 804 $depth = 0; 805 $ret = true; 806 foreach (array_diff(explode('/', $dest_dir), array('')) as $dir) { 807 $path .= '/' . $dir; 808 $depth++; 809 /// FIXME: This is a dirty way to make this work when open_basedir prevents looking at the first 3 directories in an absolute path. 810 if ($depth > 3 && !($ret = file_exists($path) ? true : mkdir($path, $this->getParam('dest_dir_perms')))) { 811 $return_val++; 812 $app->logMsg(sprintf('mkdir failure: %s', $path), LOG_ERR, __FILE__, __LINE__); 813 break; 814 } else { 815 $app->logMsg(sprintf('mkdir attempt: %s', $path), LOG_DEBUG, __FILE__, __LINE__); 816 } 817 } 796 if (!file_exists($dest_dir) && !($ret = mkdir($dest_dir, $this->getParam('dest_dir_perms'), true))) { 797 $return_val++; 798 $app->logMsg(sprintf('mkdir failure: %s', $dest_dir), LOG_ERR, __FILE__, __LINE__); 818 799 } 819 820 800 if ($ret) { 821 $app->logMsg(sprintf('mkdir success: %s', $dest_dir), LOG_DEBUG, __FILE__, __LINE__); 801 $app->logMsg(sprintf('mkdir success: %s', $dest_dir), LOG_DEBUG, __FILE__, __LINE__); 822 802 } 823 803 } else { … … 844 824 * @param string $line __LINE__. 845 825 */ 846 function _raiseMsg($message, $type, $file, $line)826 private function _raiseMsg($message, $type, $file, $line) 847 827 { 848 828 $app =& App::getInstance(); … … 852 832 } 853 833 } 854 834 855 835 /** 856 836 * Get filename by glob pattern. Searches a directory for an image that matches the … … 864 844 * @since 15 Nov 2005 20:55:22 865 845 */ 866 function _glob($pattern, $directory)846 private function _glob($pattern, $directory) 867 847 { 868 848 $file_list = glob(sprintf('%s/%s', $directory, $pattern)); … … 875 855 876 856 } // End of class. 877 ?> -
trunk/lib/Lock.inc.php
r424 r468 4 4 * For details visit the project site: <http://trac.strangecode.com/codebase/> 5 5 * Copyright 2001-2012 Strangecode, LLC 6 * 6 * 7 7 * This file is part of The Strangecode Codebase. 8 8 * … … 11 11 * Free Software Foundation, either version 3 of the License, or (at your option) 12 12 * any later version. 13 * 13 * 14 14 * The Strangecode Codebase is distributed in the hope that it will be useful, but 15 15 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 16 16 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more 17 17 * details. 18 * 18 * 19 19 * You should have received a copy of the GNU General Public License along with 20 20 * The Strangecode Codebase. If not, see <http://www.gnu.org/licenses/>. … … 31 31 class Lock { 32 32 33 // A place to keep an object instance for the singleton pattern. 34 private static $instance = null; 35 33 36 // Configuration of this object. 34 var$_params = array(37 private $_params = array( 35 38 'timeout' => 600, 36 39 'auto_timeout' => 1800, … … 44 47 45 48 // Store lock data from DB. 46 var$data = array();49 private $data = array(); 47 50 48 51 // Auth_SQL object from which to access a current user_id. 49 var$_auth;52 private $_auth; 50 53 51 54 /** … … 56 59 * @static 57 60 */ 58 static function &getInstance($auth_object) 59 { 60 static $instance = null; 61 62 if ($instance === null) { 63 $instance = new Lock($auth_object); 64 } 65 66 return $instance; 61 public static function &getInstance($auth_object) 62 { 63 if (self::$instance === null) { 64 self::$instance = new self($auth_object); 65 } 66 67 return self::$instance; 67 68 } 68 69 … … 72 73 * @param mixed $auth_object An Auth_SQL or Auth_FILE object. 73 74 */ 74 function Lock($auth_object)75 public function __construct($auth_object) 75 76 { 76 77 $app =& App::getInstance(); … … 95 96 * @since 26 Aug 2005 17:09:36 96 97 */ 97 function initDB($recreate_db=false)98 public function initDB($recreate_db=false) 98 99 { 99 100 $app =& App::getInstance(); … … 142 143 * @param array $params Array of param keys and values to set. 143 144 */ 144 function setParam($params=null)145 public function setParam($params=null) 145 146 { 146 147 if (isset($params) && is_array($params)) { … … 157 158 * @return mixed Configured parameter value. 158 159 */ 159 function getParam($param)160 { 161 $app =& App::getInstance(); 162 160 public function getParam($param) 161 { 162 $app =& App::getInstance(); 163 163 164 if (isset($this->_params[$param])) { 164 165 return $this->_params[$param]; … … 178 179 * @param string $title A title to apply to the lock, for display purposes. 179 180 */ 180 function select($record_table_or_lock_id, $record_key=null, $record_val=null)181 public function select($record_table_or_lock_id, $record_key=null, $record_val=null) 181 182 { 182 183 $app =& App::getInstance(); … … 205 206 if ($this->data = mysql_fetch_assoc($qid)) { 206 207 $app->logMsg(sprintf('Selecting %slocked record: %s %s %s', ($this->data['set_by_admin_id'] == $this->_auth->get('user_id') ? 'self-' : ''), $record_table_or_lock_id, $record_key, $record_val), LOG_DEBUG, __FILE__, __LINE__); 207 // / FIXME: What if admin set lock, but public user is current lock user?208 // FIXME: What if admin set lock, but public user is current lock user? 208 209 $this->data['editor'] = $this->_auth->getUsername($this->data['set_by_admin_id']); 209 210 return true; … … 219 220 * @return bool True if locked. 220 221 */ 221 function isLocked()222 public function isLocked() 222 223 { 223 224 return isset($this->data['lock_id']); … … 230 231 * @return bool True if current user set the lock. 231 232 */ 232 function isMine()233 { 234 $db =& DB::getInstance(); 235 233 public function isMine() 234 { 235 $db =& DB::getInstance(); 236 236 237 $this->initDB(); 237 238 … … 258 259 * @return int The id for the lock (mysql last insert id). 259 260 */ 260 function set($record_table, $record_key, $record_val, $title='')261 { 262 $db =& DB::getInstance(); 263 261 public function set($record_table, $record_key, $record_val, $title='') 262 { 263 $db =& DB::getInstance(); 264 264 265 $this->initDB(); 265 266 … … 304 305 * Unlock the currently selected record. 305 306 */ 306 function remove()307 public function remove() 307 308 { 308 309 $app =& App::getInstance(); … … 326 327 * Unlock all records, or all records for a specified user. 327 328 */ 328 function removeAll($user_id=null)329 public function removeAll($user_id=null) 329 330 { 330 331 $app =& App::getInstance(); … … 350 351 * Deletes all locks that are older than auto_timeout. 351 352 */ 352 function _auto_timeout()353 { 354 $db =& DB::getInstance(); 355 353 public function _auto_timeout() 354 { 355 $db =& DB::getInstance(); 356 356 357 static $_timeout_run = false; 357 358 … … 371 372 * Redirect to record lock error page. 372 373 */ 373 function dieErrorPage()374 public function dieErrorPage() 374 375 { 375 376 $app =& App::getInstance(); … … 381 382 * Print error page. 382 383 */ 383 function printErrorHTML()384 public function printErrorHTML() 384 385 { 385 386 $app =& App::getInstance(); … … 416 417 * Return lock_id of locked record. 417 418 */ 418 function getID()419 public function getID() 419 420 { 420 421 return $this->data['lock_id']; … … 424 425 * Return title of locked record. 425 426 */ 426 function getTitle()427 public function getTitle() 427 428 { 428 429 return $this->data['title']; … … 432 433 * Return administrator username for locked record. 433 434 */ 434 function getEditor()435 public function getEditor() 435 436 { 436 437 return $this->data['editor']; … … 440 441 * Return total seconds since the record was locked. 441 442 */ 442 function getSecondsElapsed()443 public function getSecondsElapsed() 443 444 { 444 445 if (isset($this->data['lock_datetime']) && strtotime($this->data['lock_datetime']) < time()) { … … 451 452 452 453 } // End of class. 453 ?> -
trunk/lib/MCVE.inc.php
r396 r468 31 31 class MCVE { 32 32 33 var$username;34 var$password;35 var$host = 'localhost';36 var$ip_port = 8333;37 var$ssl_port = 8444;38 var$ca_bundle_file = '/usr/share/ssl/certs/ca-bundle.crt';39 var$connect_method = 'ip';40 var$timeout = 10;41 var$blocking = 1;42 var$connected = false;43 var$conn;44 45 function MCVE($username, $password)33 public $username; 34 public $password; 35 public $host = 'localhost'; 36 public $ip_port = 8333; 37 public $ssl_port = 8444; 38 public $ca_bundle_file = '/usr/share/ssl/certs/ca-bundle.crt'; 39 public $connect_method = 'ip'; 40 public $timeout = 10; 41 public $blocking = 1; 42 public $connected = false; 43 public $conn; 44 45 public function __construct($username, $password) 46 46 { 47 47 $app =& App::getInstance(); … … 58 58 } 59 59 60 function _connect()60 private function _connect() 61 61 { 62 62 $app =& App::getInstance(); … … 123 123 } 124 124 125 function beginTrans()125 public function beginTrans() 126 126 { 127 127 if (!$this->_connect()) { … … 134 134 } 135 135 136 function transParam($tid, $key, $var1, $var2=null)136 public function transParam($tid, $key, $var1, $var2=null) 137 137 { 138 138 if (!isset($var2)) { … … 144 144 } 145 145 146 function sendTrans($tid, $type='', $hide_msg=false)146 public function sendTrans($tid, $type='', $hide_msg=false) 147 147 { 148 148 $app =& App::getInstance(); … … 191 191 } 192 192 193 function disconnect($tid)193 public function disconnect($tid) 194 194 { 195 195 if ($this->connected) { … … 208 208 // End of class. 209 209 210 ?> -
trunk/lib/Navigation.inc.php
r464 r468 37 37 38 38 // Configuration parameters for this object. 39 var$_params = array(39 private $_params = array( 40 40 'head_title' => true, 41 41 'body_title' => true, … … 48 48 'last_crumb_format' => '%s', 49 49 ); 50 var$pages = array();50 public $pages = array(); 51 51 52 52 /** 53 53 * Navigation constructor. 54 54 */ 55 function Navigation($params=null)55 public function __construct($params=null) 56 56 { 57 57 $app =& App::getInstance(); … … 74 74 * @param array $vars Additional page variables. 75 75 */ 76 function add($title, $url=null, $vars=array())76 public function add($title, $url=null, $vars=array()) 77 77 { 78 78 $page = array( … … 91 91 * @param array $params Array of parameters (key => val pairs). 92 92 */ 93 function setParam($params)93 public function setParam($params) 94 94 { 95 95 $app =& App::getInstance(); … … 110 110 * @return mixed Configured parameter value. 111 111 */ 112 function getParam($param)112 public function getParam($param) 113 113 { 114 114 $app =& App::getInstance(); … … 127 127 * @access public 128 128 */ 129 function clear()129 public function clear() 130 130 { 131 131 $this->pages = array(); … … 139 139 * @param mixed $val Value to set variable to. 140 140 */ 141 function set($key, $val)141 public function set($key, $val) 142 142 { 143 143 // Set params of current page. … … 154 154 * @return mixed Value stored in session. 155 155 */ 156 function get($key, $default='')156 public function get($key, $default='') 157 157 { 158 158 $curr_page =& $this->pages[sizeof($this->pages) - 1]; … … 205 205 * @return mixed Path (string) or false if path param is not set. 206 206 */ 207 function getPath($key='title')207 public function getPath($key='title') 208 208 { 209 209 if ($this->getParam('path')) { … … 227 227 * @return string Breadcrumbs or empty string if breadcrumbs param not set. 228 228 */ 229 function getBreadcrumbs()229 public function getBreadcrumbs() 230 230 { 231 231 $app =& App::getInstance(); … … 279 279 * @return mixed The value set for $return, TRUE by default. 280 280 */ 281 function currentPage($test_uri, $true_return=true, $false_return=false, $strip_query=false)281 public function currentPage($test_uri, $true_return=true, $false_return=false, $strip_query=false) 282 282 { 283 283 $actual_uri = $strip_query ? strtok($_SERVER['REQUEST_URI'], '?') : $_SERVER['REQUEST_URI']; … … 291 291 } 292 292 // End of class. 293 294 ?> -
trunk/lib/PEdit.inc.php
r441 r468 70 70 71 71 // PEdit object parameters. 72 var$_params = array(72 private $_params = array( 73 73 'data_dir' => '', 74 74 'character_set' => 'utf-8', … … 77 77 ); 78 78 79 var$_data = array(); // Array to store loaded data.80 var$_data_file = ''; // Full file path to the pedit data file.81 var$_authorized = false; // User is authenticated to see extended functions.82 var$_data_loaded = false;83 var$op = '';79 private $_data = array(); // Array to store loaded data. 80 private $_data_file = ''; // Full file path to the pedit data file. 81 private $_authorized = false; // User is authenticated to see extended functions. 82 private $_data_loaded = false; 83 public $op = ''; 84 84 85 85 /** … … 93 93 * @param optional array $params A hash containing connection parameters. 94 94 */ 95 function PEdit($params)95 public function __construct($params) 96 96 { 97 97 $this->setParam($params); … … 121 121 * @param array $params Array of parameters (key => val pairs). 122 122 */ 123 function setParam($params)123 public function setParam($params) 124 124 { 125 125 $app =& App::getInstance(); … … 140 140 * @return mixed Configured parameter value. 141 141 */ 142 function getParam($param)142 public function getParam($param) 143 143 { 144 144 $app =& App::getInstance(); … … 159 159 * @since 12 Apr 2006 12:43:47 160 160 */ 161 function start($initialize_data_file=false)161 public function start($initialize_data_file=false) 162 162 { 163 163 $app =& App::getInstance(); … … 217 217 * @param array $options Additional options to store with this data. 218 218 */ 219 function set($name, $options=array())219 public function set($name, $options=array()) 220 220 { 221 221 $app =& App::getInstance(); … … 236 236 * @return string The trimmed content of the named data. 237 237 */ 238 function get($name)238 public function get($name) 239 239 { 240 240 $name = preg_replace('/\s/', '_', $name); … … 251 251 * @return bool False if unauthorized or current page is a version. 252 252 */ 253 function formBegin()253 public function formBegin() 254 254 { 255 255 $app =& App::getInstance(); … … 288 288 * @access public 289 289 */ 290 function printAllForms()290 public function printAllForms() 291 291 { 292 292 if ($this->_authorized && $this->op == 'Edit' && is_array($this->_data) && $this->_data_loaded) { … … 305 305 * @param string $type Type of form to print. Currently only 'text' and 'textarea' supported. 306 306 */ 307 function printForm($name, $type='text')307 public function printForm($name, $type='text') 308 308 { 309 309 if ($this->_authorized && $this->op == 'Edit' && $this->_data_loaded) { … … 345 345 * @return bool False if unauthorized or current page is a version. 346 346 */ 347 function formEnd()347 public function formEnd() 348 348 { 349 349 if (!$this->_authorized || empty($this->_data)) { … … 399 399 * @access public 400 400 */ 401 function printVersions()401 public function printVersions() 402 402 { 403 403 $app =& App::getInstance(); … … 442 442 * @since 12 Apr 2006 10:52:35 443 443 */ 444 function _fileHash()444 private function _fileHash() 445 445 { 446 446 $app =& App::getInstance(); … … 457 457 * @since 11 Apr 2006 20:36:26 458 458 */ 459 function _loadDataFile()459 private function _loadDataFile() 460 460 { 461 461 $app =& App::getInstance(); … … 496 496 * @since 11 Apr 2006 20:53:42 497 497 */ 498 function _initializeDataFile()498 private function _initializeDataFile() 499 499 { 500 500 $app =& App::getInstance(); … … 512 512 * @return bool False if unauthorized or on failure. True on success. 513 513 */ 514 function _writeData()514 private function _writeData() 515 515 { 516 516 $app =& App::getInstance(); … … 560 560 * @since 11 Apr 2006 22:48:30 561 561 */ 562 function _filePutContents($filename, $content)562 private function _filePutContents($filename, $content) 563 563 { 564 564 $app =& App::getInstance(); … … 610 610 * @return bool False on failure. True on success. 611 611 */ 612 function _createVersion()612 private function _createVersion() 613 613 { 614 614 $app =& App::getInstance(); … … 648 648 * @since 12 Apr 2006 11:08:11 649 649 */ 650 function _deleteOldVersions()650 private function _deleteOldVersions() 651 651 { 652 652 $app =& App::getInstance(); … … 676 676 * @return array Array of versions. 677 677 */ 678 function _getVersions()678 private function _getVersions() 679 679 { 680 680 $version_files = array(); … … 707 707 * @return bool False on failure. True on success. 708 708 */ 709 function _restoreVersion($version)709 private function _restoreVersion($version) 710 710 { 711 711 $app =& App::getInstance(); … … 742 742 743 743 } // End class. 744 745 ?> -
trunk/lib/PageNumbers.inc.php
r396 r468 4 4 * For details visit the project site: <http://trac.strangecode.com/codebase/> 5 5 * Copyright 2001-2012 Strangecode, LLC 6 * 6 * 7 7 * This file is part of The Strangecode Codebase. 8 8 * … … 11 11 * Free Software Foundation, either version 3 of the License, or (at your option) 12 12 * any later version. 13 * 13 * 14 14 * The Strangecode Codebase is distributed in the hope that it will be useful, but 15 15 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 16 16 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more 17 17 * details. 18 * 18 * 19 19 * You should have received a copy of the GNU General Public License along with 20 20 * The Strangecode Codebase. If not, see <http://www.gnu.org/licenses/>. … … 39 39 class PageNumbers { 40 40 41 var$total_items; // Total quantity of items.42 var$total_pages; // The total number of pages.43 var$current_page = 1; // Current page number.44 var$first_item; // The counter for the first item on this page (zero index).45 var$last_item; // The counter for the last item on this page (zero index).46 var$max_num_links = 9; // The max number of links to show on page (odd numbers look best).47 var$_num_links; // The number of links to show on page.48 var$_per_page = 25; // Items per page.41 public $total_items; // Total quantity of items. 42 public $total_pages; // The total number of pages. 43 public $current_page = 1; // Current page number. 44 public $first_item; // The counter for the first item on this page (zero index). 45 public $last_item; // The counter for the last item on this page (zero index). 46 public $max_num_links = 9; // The max number of links to show on page (odd numbers look best). 47 private $_num_links; // The number of links to show on page. 48 private $_per_page = 25; // Items per page. 49 49 50 50 // Flags to ensure all necessary values have been set before calling calculate(). 51 var$set_per_page_initialized = false;52 var$set_page_number_initialized = false;53 var$set_total_items_initialized = false;51 public $set_per_page_initialized = false; 52 public $set_page_number_initialized = false; 53 public $set_total_items_initialized = false; 54 54 55 55 // These are initialized in the constructor. 56 var$per_page_options;57 var$left_arrow;58 var$left_arrow_disabled;59 var$left_dbl_arrow;60 var$left_dbl_arrow_disabled;61 var$right_arrow;62 var$right_arrow_disabled;63 var$right_dbl_arrow;64 var$right_dbl_arrow_disabled;56 public $per_page_options; 57 public $left_arrow; 58 public $left_arrow_disabled; 59 public $left_dbl_arrow; 60 public $left_dbl_arrow_disabled; 61 public $right_arrow; 62 public $right_arrow_disabled; 63 public $right_dbl_arrow; 64 public $right_dbl_arrow_disabled; 65 65 66 66 /** 67 67 * PageNumbers constructor. All arguments are depreciated. Use set* functions instead. 68 68 */ 69 function PageNumbers()69 public function __construct() 70 70 { 71 71 // Default options for the quantity per page links. … … 85 85 // in special cases like using a /my/page/# scheme. 86 86 $this->url_base = $_SERVER['PHP_SELF'] . '?page_number='; 87 87 88 88 $this->prefs = new Prefs($_SERVER['PHP_SELF']); 89 89 $this->prefs->setParam(array('persistent' => false)); … … 93 93 * Set the number of items per page. 94 94 */ 95 function setPerPage($per_page, $default=25, $save_value=true)95 public function setPerPage($per_page, $default=25, $save_value=true) 96 96 { 97 97 // (1) By provided argument, if valid. … … 115 115 * Set the current page number. 116 116 */ 117 function setPageNumber($page_number, $save_value=true)117 public function setPageNumber($page_number, $save_value=true) 118 118 { 119 119 // (1) By provided argument, if valid. … … 139 139 * Set the total number of items. 140 140 */ 141 function setTotalItems($total_items)141 public function setTotalItems($total_items) 142 142 { 143 143 if (is_numeric($total_items) && $total_items > 0) { … … 158 158 * @access public 159 159 */ 160 function calculate()160 public function calculate() 161 161 { 162 162 $app =& App::getInstance(); … … 212 212 * Returns the SQL code to limit query to items that are on current page. 213 213 */ 214 function getLimitSQL()214 public function getLimitSQL() 215 215 { 216 216 $app =& App::getInstance(); … … 230 230 * @access public 231 231 */ 232 function printPerPageLinks($query_key='per_page')232 public function printPerPageLinks($query_key='per_page') 233 233 { 234 234 $app =& App::getInstance(); … … 260 260 * @access public 261 261 */ 262 function getPageNumURL($page_number, $carry_args=null)262 public function getPageNumURL($page_number, $carry_args=null) 263 263 { 264 264 $app =& App::getInstance(); … … 266 266 return $app->oHREF($this->url_base . $page_number, $carry_args); 267 267 } 268 function printPageNumURL($page_number, $carry_args=null)268 public function printPageNumURL($page_number, $carry_args=null) 269 269 { 270 270 echo $this->getPageNumURL($page_number, $carry_args); … … 276 276 * @access public 277 277 */ 278 function getPageNumbersArray($carry_args=null)278 public function getPageNumbersArray($carry_args=null) 279 279 { 280 280 $page_numbers = array(); … … 296 296 * @access public 297 297 */ 298 function getPageNumbers($carry_args=null)298 public function getPageNumbers($carry_args=null) 299 299 { 300 300 $page_numbers_string = ''; … … 361 361 } 362 362 363 function printPageNumbers($carry_args=null)363 public function printPageNumbers($carry_args=null) 364 364 { 365 365 echo $this->getPageNumbers($carry_args); … … 368 368 } 369 369 370 ?> -
trunk/lib/PageSequence.inc.php
r396 r468 35 35 class PageSequence 36 36 { 37 var$current_step_id = 0;38 var$start_url;39 var$sequence_title = '';40 var$seq = '_sequence_';41 var$idle_timeout;37 public $current_step_id = 0; 38 public $start_url; 39 public $sequence_title = ''; 40 public $seq = '_sequence_'; 41 public $idle_timeout; 42 42 43 43 /** … … 47 47 * @access public 48 48 */ 49 function PageSequence($params)49 public function __construct($params) 50 50 { 51 51 if (isset($params['sequence_title'])) { … … 84 84 * @access public 85 85 */ 86 function addStep($step_id, $params)86 public function addStep($step_id, $params) 87 87 { 88 88 // Keys for the steps array cannot be numeric. … … 114 114 * @return bool true on success, false on failure 115 115 */ 116 function setFeature($step_id=null, $features)116 public function setFeature($step_id=null, $features) 117 117 { 118 118 $pos = isset($step_id) ? $this->getPosition($step_id) : $this->getPosition(); … … 134 134 * @return mixed Value stored in session. 135 135 */ 136 function getFeature($step_id, $key, $default='')136 public function getFeature($step_id, $key, $default='') 137 137 { 138 138 $pos = isset($step_id) ? $this->getPosition($step_id) : $this->getPosition(); … … 151 151 * @access public 152 152 */ 153 function setCurrent($step_id)153 public function setCurrent($step_id) 154 154 { 155 155 $app =& App::getInstance(); … … 171 171 * @access public 172 172 */ 173 function getID($pos=null)173 public function getID($pos=null) 174 174 { 175 175 if (isset($pos)) { … … 188 188 * @access public 189 189 */ 190 function getPosition($step_id=null)190 public function getPosition($step_id=null) 191 191 { 192 192 // Get current step id if step not provided. … … 217 217 * @access public 218 218 */ 219 function getRequiredID($curr_step_id)219 public function getRequiredID($curr_step_id) 220 220 { 221 221 if ('' === $curr_step_id) { … … 242 242 * @access public 243 243 */ 244 function getNextID()244 public function getNextID() 245 245 { 246 246 // Loop through all steps. … … 263 263 * @access public 264 264 */ 265 function complete($step_id=null)265 public function complete($step_id=null) 266 266 { 267 267 $pos = isset($step_id) ? $this->getPosition($step_id) : $this->getPosition(); … … 277 277 * @access public 278 278 */ 279 function printEditLink($step_id=null)279 public function printEditLink($step_id=null) 280 280 { 281 281 $app =& App::getInstance(); … … 296 296 * @access public 297 297 */ 298 function setDataDefault($data_key, $data_val)298 public function setDataDefault($data_key, $data_val) 299 299 { 300 300 if (!isset($_SESSION[$this->seq]['data'][$data_key])) { … … 310 310 * @access public 311 311 */ 312 function getData($data_key=null)312 public function getData($data_key=null) 313 313 { 314 314 if (!isset($data_key)) { … … 328 328 * @access public 329 329 */ 330 function clearData($data_key=null)330 public function clearData($data_key=null) 331 331 { 332 332 if (isset($data_key)) { … … 342 342 * Deletes all data that are older than auto_timeout. Set current time if not not expired or not set. 343 343 */ 344 function _auto_timeout()344 private function _auto_timeout() 345 345 { 346 346 $app =& App::getInstance(); … … 363 363 * @access public 364 364 */ 365 function registerData($step_data)365 public function registerData($step_data) 366 366 { 367 367 $_SESSION[$this->seq]['data'] = array_merge($_SESSION[$this->seq]['data'], $step_data); … … 372 372 * 373 373 */ 374 function startOver()374 public function startOver() 375 375 { 376 376 $this->current_step_id = 0; … … 383 383 } // END CLASS 384 384 385 ?> -
trunk/lib/PayPal.inc.php
r396 r468 33 33 34 34 // General object parameters. 35 var$_params = array(35 private $_params = array( 36 36 'paypal_url' => 'https://www.paypal.com/cgi-bin/webscr', 37 37 'test_mode' => false, … … 39 39 40 40 // Options used for specific buttons and links. 41 var$_default_button_options = array();41 private $_default_button_options = array(); 42 42 43 43 // Array of buttons created by newButton(). 44 var$_buttons = array();44 private $_buttons = array(); 45 45 46 46 // Store the response from the last IPN. 47 var$_ipn_response;47 private $_ipn_response; 48 48 49 49 /** … … 52 52 * @param bool $test_mode Use PayPal sandbox for testing. 53 53 */ 54 function PayPal($test_mode=false)54 public function __construct($test_mode=false) 55 55 { 56 56 if ($test_mode) { … … 95 95 * @return bool True on success, false on failure. 96 96 */ 97 function setButtonDefaults($type, $options)97 public function setButtonDefaults($type, $options) 98 98 { 99 99 $app =& App::getInstance(); … … 127 127 * @return bool True on success, false on failure. 128 128 */ 129 function newButton($type, $name, $options=null)129 public function newButton($type, $name, $options=null) 130 130 { 131 131 $app =& App::getInstance(); … … 162 162 * @return mixed Link of button, or false on failure. 163 163 */ 164 function getLink($name)164 public function getLink($name) 165 165 { 166 166 $app =& App::getInstance(); … … 196 196 * @param string $name Name of button for which to generate link. 197 197 */ 198 function printLink($name)198 public function printLink($name) 199 199 { 200 200 echo $this->getLink($name); … … 208 208 * @param string $name Name of button to print. 209 209 */ 210 function printButton($name)210 public function printButton($name) 211 211 { 212 212 ?> … … 234 234 * @param array $params Array of parameters (key => val pairs). 235 235 */ 236 function setParam($params)236 public function setParam($params) 237 237 { 238 238 $app =& App::getInstance(); … … 253 253 * @return mixed Configured parameter value. 254 254 */ 255 function getParam($param)255 public function getParam($param) 256 256 { 257 257 $app =& App::getInstance(); … … 272 272 * @return bool True if valid, false if invalid. 273 273 */ 274 function incomingIPNRequest()274 public function incomingIPNRequest() 275 275 { 276 276 if ($_SERVER['REQUEST_METHOD'] == 'POST' … … 290 290 * @return bool True on success, false on failure. 291 291 */ 292 function processIPN()292 public function processIPN() 293 293 { 294 294 $app =& App::getInstance(); … … 351 351 * @return bool True if response contains VERIFIED, false otherwise. 352 352 */ 353 function verifiedIPN()353 public function verifiedIPN() 354 354 { 355 355 $app =& App::getInstance(); … … 380 380 } // End of class. 381 381 382 ?> -
trunk/lib/Prefs.inc.php
r463 r468 55 55 56 56 // Namespace of this instance of Prefs. 57 var$_ns;57 private $_ns; 58 58 59 59 // Configuration parameters for this object. 60 var$_params = array(60 private $_params = array( 61 61 62 62 // Enable database storage. If this is false, all prefs will live only as long as the session. … … 80 80 * Prefs constructor. 81 81 */ 82 function Prefs($namespace='')82 public function __construct($namespace='') 83 83 { 84 84 $app =& App::getInstance(); … … 104 104 * @since 04 Jun 2006 16:41:42 105 105 */ 106 function initDB($recreate_db=false)106 public function initDB($recreate_db=false) 107 107 { 108 108 $app =& App::getInstance(); … … 142 142 * @param array $params Array of param keys and values to set. 143 143 */ 144 function setParam($params=null)144 public function setParam($params=null) 145 145 { 146 146 if (isset($params) && is_array($params)) { … … 157 157 * @return mixed Configured parameter value. 158 158 */ 159 function getParam($param)159 public function getParam($param) 160 160 { 161 161 $app =& App::getInstance(); … … 176 176 * @param array $defaults Array of key-value pairs 177 177 */ 178 function setDefaults($defaults)178 public function setDefaults($defaults) 179 179 { 180 180 if (isset($defaults) && is_array($defaults)) { … … 192 192 * @param bool $persistent Save this value forever? Set to false and value will exist as long as the session is in use. 193 193 */ 194 function set($key, $val)194 public function set($key, $val) 195 195 { 196 196 $app =& App::getInstance(); … … 223 223 * @return string The value of the preference. 224 224 */ 225 function get($key)225 public function get($key) 226 226 { 227 227 $app =& App::getInstance(); … … 244 244 * @return boolean True if the preference isset and not empty false otherwise. 245 245 */ 246 function exists($key)246 public function exists($key) 247 247 { 248 248 return array_key_exists($key, $_SESSION['_prefs'][$this->_ns]['saved']); … … 254 254 * @param string $key The name of the preference to delete. 255 255 */ 256 function delete($key)256 public function delete($key) 257 257 { 258 258 unset($_SESSION['_prefs'][$this->_ns]['saved'][$key]); … … 263 263 * as $auth->clear(), such as when logging out. 264 264 */ 265 function clear($focus='all')265 public function clear($focus='all') 266 266 { 267 267 switch ($focus) { … … 295 295 * @since 04 Jun 2006 16:56:53 296 296 */ 297 function load($force=false)297 public function load($force=false) 298 298 { 299 299 $app =& App::getInstance(); … … 352 352 * @since 04 Jun 2006 17:12:44 353 353 */ 354 function _isLoaded()354 private function _isLoaded() 355 355 { 356 356 if (isset($_SESSION['_prefs'][$this->_ns]['load_datetime']) … … 373 373 * @since 04 Jun 2006 17:19:56 374 374 */ 375 function save()375 public function save() 376 376 { 377 377 $app =& App::getInstance(); … … 424 424 } 425 425 426 427 ?> -
trunk/lib/ScriptTimer.inc.php
r396 r468 26 26 class ScriptTimer { 27 27 28 var$time_format = '%.3f';29 var$_timing_start_times = array();30 var$_timing_stop_times = array();31 var$_timing_cumulative_times = array();28 public $time_format = '%.3f'; 29 private $_timing_start_times = array(); 30 private $_timing_stop_times = array(); 31 private $_timing_cumulative_times = array(); 32 32 33 function start($name='default')33 public function start($name='default') 34 34 { 35 35 $this->_timing_start_times[$name] = explode(' ', microtime()); 36 36 } 37 37 38 function stop($name='default')38 public function stop($name='default') 39 39 { 40 40 if (!isset($this->_timing_stop_times[$name]) || !isset($this->_timing_cumulative_times[$name])) { … … 46 46 } 47 47 48 function getTime($name='default')48 public function getTime($name='default') 49 49 { 50 50 if (!isset($this->_timing_start_times[$name])) { … … 62 62 } 63 63 64 function printAll($sort_by_time=false)64 public function printAll($sort_by_time=false) 65 65 { 66 66 $names = array_map('strlen', array_keys($this->_timing_start_times)); … … 81 81 } 82 82 } 83 84 ?> -
trunk/lib/SortOrder.inc.php
- Property svn:mergeinfo changed
/branches/eli_branch/lib/SortOrder.inc.php merged: 439,467
r457 r468 37 37 class SortOrder { 38 38 39 var$_columns;40 var$sort_by;41 var$order;42 var$asc_widget;43 var$desc_widget;44 var$default_sort;45 var$default_order;39 private $_columns; 40 public $sort_by; 41 public $order; 42 public $asc_widget; 43 public $desc_widget; 44 public $default_sort; 45 public $default_order; 46 46 47 47 /** … … 53 53 * current order. 54 54 */ 55 function SortOrder($default_sort = '', $default_order = '')55 public function __construct($default_sort = '', $default_order = '') 56 56 { 57 57 $app =& App::getInstance(); … … 81 81 * @param string $desc_sql The sort SQL if $this->order is descending. 82 82 */ 83 function setColumn($name, $asc_sql, $desc_sql)83 public function setColumn($name, $asc_sql, $desc_sql) 84 84 { 85 85 $this->_columns[$name] = array( … … 99 99 * current order. 100 100 */ 101 function setDefault($default_sort = '', $default_order = '')101 public function setDefault($default_sort = '', $default_order = '') 102 102 { 103 103 // Which column to sort by? … … 139 139 * for example, for an alphabetical sort) 140 140 */ 141 function set($sort=null, $order=null, $save_value=true)141 public function set($sort=null, $order=null, $save_value=true) 142 142 { 143 143 // Set new sort value. … … 163 163 * @return array Array with keys: sort and order. These can be fed back into the SortOrder::set() method or defaults. 164 164 */ 165 function get()165 public function get() 166 166 { 167 167 return array( … … 174 174 * Returns the SQL code to sort by set column and set order. 175 175 */ 176 function getSortOrderSQL()176 public function getSortOrderSQL() 177 177 { 178 178 $app =& App::getInstance(); … … 205 205 * for example, for an alphabetical sort) 206 206 */ 207 function printSortHeader($col, $col_name, $default_order='ASC')207 public function printSortHeader($col, $col_name, $default_order='ASC') 208 208 { 209 209 $app =& App::getInstance(); … … 226 226 } 227 227 228 ?> - Property svn:mergeinfo changed
-
trunk/lib/SpellCheck.inc.php
r425 r468 61 61 class SpellCheck { 62 62 63 var$_params = array(63 private $_params = array( 64 64 'language' => 'en', 65 65 'personal_wordlist' => '', // Text file to save custom words to. … … 70 70 ); 71 71 72 var$_pspell_cfg_handle;73 var$_pspell_handle;74 var$_use_personal_wordlist = false;75 var$_errors = array();72 private $_pspell_cfg_handle; 73 private $_pspell_handle; 74 private $_use_personal_wordlist = false; 75 private $_errors = array(); 76 76 77 77 /** … … 80 80 * @param array $params Array of parameters (key => val pairs). 81 81 */ 82 function SpellCheck($params)82 public function __construct($params) 83 83 { 84 84 $app =& App::getInstance(); … … 118 118 * @param array $params Array of parameters (key => val pairs). 119 119 */ 120 function setParam($params)120 public function setParam($params) 121 121 { 122 122 $app =& App::getInstance(); … … 137 137 * @return mixed Configured parameter value. 138 138 */ 139 function getParam($param)139 public function getParam($param) 140 140 { 141 141 $app =& App::getInstance(); … … 154 154 * @return bool True if any errors were found, false otherwise. 155 155 */ 156 function anyErrors()156 public function anyErrors() 157 157 { 158 158 return (sizeof($this->_errors) > 0); … … 162 162 * Reset the error list. 163 163 */ 164 function resetErrorList()164 public function resetErrorList() 165 165 { 166 166 $this->_errors = array(); … … 177 177 * @since 09 Jun 2005 18:23:51 178 178 */ 179 function check($word)179 public function check($word) 180 180 { 181 181 if (pspell_check($this->_pspell_handle, $word)) { … … 197 197 * @since 09 Jun 2005 18:23:51 198 198 */ 199 function suggest($word)199 public function suggest($word) 200 200 { 201 201 return pspell_suggest($this->_pspell_handle, $word); … … 212 212 * @since 09 Jun 2005 18:23:51 213 213 */ 214 function add($word)214 public function add($word) 215 215 { 216 216 $app =& App::getInstance(); … … 237 237 * @since 09 Jun 2005 18:23:51 238 238 */ 239 function save()239 public function save() 240 240 { 241 241 $app =& App::getInstance(); … … 263 263 * @since 09 Jun 2005 21:29:49 264 264 */ 265 function getStringSuggestions($string)265 public function getStringSuggestions($string) 266 266 { 267 267 $corrections = array(); … … 299 299 * @since 09 Jun 2005 22:11:27 300 300 */ 301 function checkString($string)301 public function checkString($string) 302 302 { 303 303 $errors = array(); … … 331 331 * @since 09 Jun 2005 21:29:49 332 332 */ 333 function getStringHighlighted($string, $show_footnote=false)333 public function getStringHighlighted($string, $show_footnote=false) 334 334 { 335 335 $words = preg_split('/([\W]+?)/', $string, -1, PREG_SPLIT_DELIM_CAPTURE); … … 357 357 * @since 09 Jun 2005 21:29:49 358 358 */ 359 function printCorrectionForm($form_name)359 public function printCorrectionForm($form_name) 360 360 { 361 361 ?> … … 402 402 * @since 09 Jun 2005 23:15:35 403 403 */ 404 function anyFormCorrections()404 public function anyFormCorrections() 405 405 { 406 406 return (false !== getFormData('spelling_suggestions', false)) || (false !== getFormData('spelling_corrections', false)); … … 417 417 * @since 09 Jun 2005 23:18:51 418 418 */ 419 function applyFormCorrections($form_name)419 public function applyFormCorrections($form_name) 420 420 { 421 421 $form_words = preg_split('/([\W]+?)/', getFormData($form_name), -1, PREG_SPLIT_DELIM_CAPTURE); … … 445 445 } // End. 446 446 447 ?> -
trunk/lib/TemplateGlue.inc.php
r407 r468 4 4 * For details visit the project site: <http://trac.strangecode.com/codebase/> 5 5 * Copyright 2001-2012 Strangecode, LLC 6 * 6 * 7 7 * This file is part of The Strangecode Codebase. 8 8 * … … 11 11 * Free Software Foundation, either version 3 of the License, or (at your option) 12 12 * any later version. 13 * 13 * 14 14 * The Strangecode Codebase is distributed in the hope that it will be useful, but 15 15 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 16 16 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more 17 17 * details. 18 * 18 * 19 19 * You should have received a copy of the GNU General Public License along with 20 20 * The Strangecode Codebase. If not, see <http://www.gnu.org/licenses/>. … … 24 24 * TemplateGlue.inc.php 25 25 */ 26 27 /**28 * Print URL to download file with BBEdit/Interarchy. "USER" must be a pre-set29 * environment variable. Files must reside within and be relative to env "DOCUMENT_ROOT".30 *31 * @access public32 * @param mixed $file File path relative to DOCUMENT_ROOT (i.e. '/_templates/index.ihtml').33 * @return string <a> with file basename as text.34 */35 function bbftp($file)36 {37 return sprintf('<a href="bbftp://%s@%s:%s%s" title="%s" style="text-decoration: none; border-bottom: blue 1px dotted;">%s</a>', $_SERVER['USER'], $_SERVER['HTTP_HOST'], $_SERVER['DOCUMENT_ROOT'], $file, $file, basename($file));38 }39 26 40 27 /** … … 89 76 $app =& App::getInstance(); 90 77 $db =& DB::getInstance(); 91 78 92 79 $qid = $db->query("SHOW COLUMNS FROM " . $db->escapeString($db_table) . " LIKE '" . $db->escapeString($db_col) . "'",false); 93 80 … … 95 82 if (preg_match('/^enum|^set/i', $row[1]) && preg_match_all("/'([^']*)'/", $row[1], $enum)) { 96 83 if ($sort) { 97 natsort($enum[1]); 84 natsort($enum[1]); 98 85 } 99 86 return $enum[1]; … … 329 316 { 330 317 $db =& DB::getInstance(); 331 318 332 319 // Sometimes preselected comes as a comma list. 333 320 if (!is_array($preselected)) { … … 373 360 { 374 361 $db =& DB::getInstance(); 375 362 376 363 // Sometimes preselected comes as a comma list. 377 364 if (!is_array($preselected)) { … … 501 488 } 502 489 } 503 504 ?> -
trunk/lib/Upload.inc.php
r415 r468 4 4 * For details visit the project site: <http://trac.strangecode.com/codebase/> 5 5 * Copyright 2001-2012 Strangecode, LLC 6 * 6 * 7 7 * This file is part of The Strangecode Codebase. 8 8 * … … 11 11 * Free Software Foundation, either version 3 of the License, or (at your option) 12 12 * any later version. 13 * 13 * 14 14 * The Strangecode Codebase is distributed in the hope that it will be useful, but 15 15 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 16 16 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more 17 17 * details. 18 * 18 * 19 19 * You should have received a copy of the GNU General Public License along with 20 20 * The Strangecode Codebase. If not, see <http://www.gnu.org/licenses/>. … … 41 41 42 42 // General object parameters. 43 var$_params = array(43 private $_params = array( 44 44 45 45 // Which messages do we pass to raiseMsg? … … 63 63 64 64 // Array of files with errors. 65 var$errors = array();65 public $errors = array(); 66 66 67 67 // Array of file name extensions and corresponding mime-types. 68 var$mime_extension_map = array( 'ez' => 'application/andrew-inset', 'hqx' => 'application/mac-binhex40', 'cpt' => 'application/mac-compactpro', 'doc' => 'application/msword', 'bin' => 'application/octet-stream', 'class' => 'application/octet-stream', 'dll' => 'application/octet-stream', 'dms' => 'application/octet-stream', 'exe' => 'application/octet-stream', 'lha' => 'application/octet-stream', 'lzh' => 'application/octet-stream', 'so' => 'application/octet-stream', 'oda' => 'application/oda', 'pdf' => 'application/pdf', 'ai' => 'application/postscript', 'eps' => 'application/postscript', 'ps' => 'application/postscript', 'smi' => 'application/smil', 'smil' => 'application/smil', 'mif' => 'application/vnd.mif', 'xls' => 'application/vnd.ms-excel', 'ppt' => 'application/vnd.ms-powerpoint', 'sxc' => 'application/vnd.sun.xml.calc', 'stc' => 'application/vnd.sun.xml.calc.template', 'sxd' => 'application/vnd.sun.xml.draw', 'std' => 'application/vnd.sun.xml.draw.template', 'sxi' => 'application/vnd.sun.xml.impress', 'sti' => 'application/vnd.sun.xml.impress.template', 'sxm' => 'application/vnd.sun.xml.math', 'sxw' => 'application/vnd.sun.xml.writer', 'sxg' => 'application/vnd.sun.xml.writer.global', 'stw' => 'application/vnd.sun.xml.writer.template', 'vsd' => 'application/vnd.visio', 'wbxml' => 'application/vnd.wap.wbxml', 'wmlc' => 'application/vnd.wap.wmlc', 'wmlsc' => 'application/vnd.wap.wmlscriptc', 'bcpio' => 'application/x-bcpio', 'vcd' => 'application/x-cdlink', 'pgn' => 'application/x-chess-pgn', 'Z' => 'application/x-compress', 'cpio' => 'application/x-cpio', 'csh' => 'application/x-csh', 'dcr' => 'application/x-director', 'dir' => 'application/x-director', 'dxr' => 'application/x-director', 'dvi' => 'application/x-dvi', 'spl' => 'application/x-futuresplash', 'gtar' => 'application/x-gtar', 'tgz' => 'application/x-gtar', 'gz' => 'application/x-gzip', 'hdf' => 'application/x-hdf', 'php' => 'application/x-httpd-php', 'php3' => 'application/x-httpd-php3', 'js' => 'application/x-javascript', 'skd' => 'application/x-koan', 'skm' => 'application/x-koan', 'skp' => 'application/x-koan', 'skt' => 'application/x-koan', 'latex' => 'application/x-latex', 'wmd' => 'application/x-ms-wmd', 'wmz' => 'application/x-ms-wmz', 'cdf' => 'application/x-netcdf', 'nc' => 'application/x-netcdf', 'pl' => 'application/x-perl', 'pm' => 'application/x-perl', 'psd' => 'application/x-photoshop', 'sh' => 'application/x-sh', 'shar' => 'application/x-shar', 'swf' => 'application/x-shockwave-flash', 'sit' => 'application/x-stuffit', 'sv4cpio' => 'application/x-sv4cpio', 'sv4crc' => 'application/x-sv4crc', 'tar' => 'application/x-tar', 'tcl' => 'application/x-tcl', 'tex' => 'application/x-tex', 'texi' => 'application/x-texinfo', 'texinfo' => 'application/x-texinfo', 'roff' => 'application/x-troff', 't' => 'application/x-troff', 'tr' => 'application/x-troff', 'man' => 'application/x-troff-man', 'me' => 'application/x-troff-me', 'ms' => 'application/x-troff-ms', 'ustar' => 'application/x-ustar', 'src' => 'application/x-wais-source', 'xht' => 'application/xhtml+xml', 'xhtml' => 'application/xhtml+xml', 'xml' => 'application/xml', 'zip' => 'application/zip', 'au' => 'audio/basic', 'snd' => 'audio/basic', 'kar' => 'audio/midi', 'mid' => 'audio/midi', 'midi' => 'audio/midi', 'mp2' => 'audio/mpeg', 'mp3' => 'audio/mpeg', 'mpga' => 'audio/mpeg', 'aif' => 'audio/x-aiff', 'aifc' => 'audio/x-aiff', 'aiff' => 'audio/x-aiff', 'm3u' => 'audio/x-mpegurl', 'wax' => 'audio/x-ms-wax', 'wma' => 'audio/x-ms-wma', 'ram' => 'audio/x-pn-realaudio', 'rm' => 'audio/x-pn-realaudio', 'rpm' => 'audio/x-pn-realaudio-plugin', 'ra' => 'audio/x-realaudio', 'wav' => 'audio/x-wav', 'pdb' => 'chemical/x-pdb', 'xyz' => 'chemical/x-xyz', 'bmp' => 'image/bmp', 'gif' => 'image/gif', 'ief' => 'image/ief', 'jpe' => 'image/jpeg', 'jpeg' => 'image/jpeg', 'jpg' => 'image/jpeg', 'png' => 'image/png', 'tif' => 'image/tiff', 'tiff' => 'image/tiff', 'wbmp' => 'image/vnd.wap.wbmp', 'ras' => 'image/x-cmu-raster', 'pnm' => 'image/x-portable-anymap', 'pbm' => 'image/x-portable-bitmap', 'pgm' => 'image/x-portable-graymap', 'ppm' => 'image/x-portable-pixmap', 'rgb' => 'image/x-rgb', 'xbm' => 'image/x-xbitmap', 'xpm' => 'image/x-xpixmap', 'xwd' => 'image/x-xwindowdump', 'iges' => 'model/iges', 'igs' => 'model/iges', 'mesh' => 'model/mesh', 'msh' => 'model/mesh', 'silo' => 'model/mesh', 'vrml' => 'model/vrml', 'wrl' => 'model/vrml', 'ics' => 'text/calendar', 'ifb' => 'text/calendar', 'vcs' => 'text/calendar', 'vfb' => 'text/calendar', 'css' => 'text/css', 'csv' => 'text/csv', 'diff' => 'text/diff', 'patch' => 'text/diff', 'htm' => 'text/html', 'html' => 'text/html', 'shtml' => 'text/html', 'asc' => 'text/plain', 'log' => 'text/plain', 'po' => 'text/plain', 'txt' => 'text/plain', 'rtx' => 'text/richtext', 'rtf' => 'text/rtf', 'sgm' => 'text/sgml', 'sgml' => 'text/sgml', 'tsv' => 'text/tab-separated-values', 'wml' => 'text/vnd.wap.wml', 'wmls' => 'text/vnd.wap.wmlscript', 'etx' => 'text/x-setext', 'vcf' => 'text/x-vcard', 'xsl' => 'text/xml', 'mp4' => 'video/mp4', 'mpe' => 'video/mpeg', 'mpeg' => 'video/mpeg', 'mpg' => 'video/mpeg', 'mov' => 'video/quicktime', 'qt' => 'video/quicktime', 'mxu' => 'video/vnd.mpegurl', 'asf' => 'video/x-ms-asf', 'asx' => 'video/x-ms-asf', 'wm' => 'video/x-ms-wm', 'wmv' => 'video/x-ms-wmv', 'wmx' => 'video/x-ms-wmx', 'wvx' => 'video/x-ms-wvx', 'avi' => 'video/x-msvideo', 'movie' => 'video/x-sgi-movie', 'ice' => 'x-conference/x-cooltalk', );68 public $mime_extension_map = array( 'ez' => 'application/andrew-inset', 'hqx' => 'application/mac-binhex40', 'cpt' => 'application/mac-compactpro', 'doc' => 'application/msword', 'bin' => 'application/octet-stream', 'class' => 'application/octet-stream', 'dll' => 'application/octet-stream', 'dms' => 'application/octet-stream', 'exe' => 'application/octet-stream', 'lha' => 'application/octet-stream', 'lzh' => 'application/octet-stream', 'so' => 'application/octet-stream', 'oda' => 'application/oda', 'pdf' => 'application/pdf', 'ai' => 'application/postscript', 'eps' => 'application/postscript', 'ps' => 'application/postscript', 'smi' => 'application/smil', 'smil' => 'application/smil', 'mif' => 'application/vnd.mif', 'xls' => 'application/vnd.ms-excel', 'ppt' => 'application/vnd.ms-powerpoint', 'sxc' => 'application/vnd.sun.xml.calc', 'stc' => 'application/vnd.sun.xml.calc.template', 'sxd' => 'application/vnd.sun.xml.draw', 'std' => 'application/vnd.sun.xml.draw.template', 'sxi' => 'application/vnd.sun.xml.impress', 'sti' => 'application/vnd.sun.xml.impress.template', 'sxm' => 'application/vnd.sun.xml.math', 'sxw' => 'application/vnd.sun.xml.writer', 'sxg' => 'application/vnd.sun.xml.writer.global', 'stw' => 'application/vnd.sun.xml.writer.template', 'vsd' => 'application/vnd.visio', 'wbxml' => 'application/vnd.wap.wbxml', 'wmlc' => 'application/vnd.wap.wmlc', 'wmlsc' => 'application/vnd.wap.wmlscriptc', 'bcpio' => 'application/x-bcpio', 'vcd' => 'application/x-cdlink', 'pgn' => 'application/x-chess-pgn', 'Z' => 'application/x-compress', 'cpio' => 'application/x-cpio', 'csh' => 'application/x-csh', 'dcr' => 'application/x-director', 'dir' => 'application/x-director', 'dxr' => 'application/x-director', 'dvi' => 'application/x-dvi', 'spl' => 'application/x-futuresplash', 'gtar' => 'application/x-gtar', 'tgz' => 'application/x-gtar', 'gz' => 'application/x-gzip', 'hdf' => 'application/x-hdf', 'php' => 'application/x-httpd-php', 'php3' => 'application/x-httpd-php3', 'js' => 'application/x-javascript', 'skd' => 'application/x-koan', 'skm' => 'application/x-koan', 'skp' => 'application/x-koan', 'skt' => 'application/x-koan', 'latex' => 'application/x-latex', 'wmd' => 'application/x-ms-wmd', 'wmz' => 'application/x-ms-wmz', 'cdf' => 'application/x-netcdf', 'nc' => 'application/x-netcdf', 'pl' => 'application/x-perl', 'pm' => 'application/x-perl', 'psd' => 'application/x-photoshop', 'sh' => 'application/x-sh', 'shar' => 'application/x-shar', 'swf' => 'application/x-shockwave-flash', 'sit' => 'application/x-stuffit', 'sv4cpio' => 'application/x-sv4cpio', 'sv4crc' => 'application/x-sv4crc', 'tar' => 'application/x-tar', 'tcl' => 'application/x-tcl', 'tex' => 'application/x-tex', 'texi' => 'application/x-texinfo', 'texinfo' => 'application/x-texinfo', 'roff' => 'application/x-troff', 't' => 'application/x-troff', 'tr' => 'application/x-troff', 'man' => 'application/x-troff-man', 'me' => 'application/x-troff-me', 'ms' => 'application/x-troff-ms', 'ustar' => 'application/x-ustar', 'src' => 'application/x-wais-source', 'xht' => 'application/xhtml+xml', 'xhtml' => 'application/xhtml+xml', 'xml' => 'application/xml', 'zip' => 'application/zip', 'au' => 'audio/basic', 'snd' => 'audio/basic', 'kar' => 'audio/midi', 'mid' => 'audio/midi', 'midi' => 'audio/midi', 'mp2' => 'audio/mpeg', 'mp3' => 'audio/mpeg', 'mpga' => 'audio/mpeg', 'aif' => 'audio/x-aiff', 'aifc' => 'audio/x-aiff', 'aiff' => 'audio/x-aiff', 'm3u' => 'audio/x-mpegurl', 'wax' => 'audio/x-ms-wax', 'wma' => 'audio/x-ms-wma', 'ram' => 'audio/x-pn-realaudio', 'rm' => 'audio/x-pn-realaudio', 'rpm' => 'audio/x-pn-realaudio-plugin', 'ra' => 'audio/x-realaudio', 'wav' => 'audio/x-wav', 'pdb' => 'chemical/x-pdb', 'xyz' => 'chemical/x-xyz', 'bmp' => 'image/bmp', 'gif' => 'image/gif', 'ief' => 'image/ief', 'jpe' => 'image/jpeg', 'jpeg' => 'image/jpeg', 'jpg' => 'image/jpeg', 'png' => 'image/png', 'tif' => 'image/tiff', 'tiff' => 'image/tiff', 'wbmp' => 'image/vnd.wap.wbmp', 'ras' => 'image/x-cmu-raster', 'pnm' => 'image/x-portable-anymap', 'pbm' => 'image/x-portable-bitmap', 'pgm' => 'image/x-portable-graymap', 'ppm' => 'image/x-portable-pixmap', 'rgb' => 'image/x-rgb', 'xbm' => 'image/x-xbitmap', 'xpm' => 'image/x-xpixmap', 'xwd' => 'image/x-xwindowdump', 'iges' => 'model/iges', 'igs' => 'model/iges', 'mesh' => 'model/mesh', 'msh' => 'model/mesh', 'silo' => 'model/mesh', 'vrml' => 'model/vrml', 'wrl' => 'model/vrml', 'ics' => 'text/calendar', 'ifb' => 'text/calendar', 'vcs' => 'text/calendar', 'vfb' => 'text/calendar', 'css' => 'text/css', 'csv' => 'text/csv', 'diff' => 'text/diff', 'patch' => 'text/diff', 'htm' => 'text/html', 'html' => 'text/html', 'shtml' => 'text/html', 'asc' => 'text/plain', 'log' => 'text/plain', 'po' => 'text/plain', 'txt' => 'text/plain', 'rtx' => 'text/richtext', 'rtf' => 'text/rtf', 'sgm' => 'text/sgml', 'sgml' => 'text/sgml', 'tsv' => 'text/tab-separated-values', 'wml' => 'text/vnd.wap.wml', 'wmls' => 'text/vnd.wap.wmlscript', 'etx' => 'text/x-setext', 'vcf' => 'text/x-vcard', 'xsl' => 'text/xml', 'mp4' => 'video/mp4', 'mpe' => 'video/mpeg', 'mpeg' => 'video/mpeg', 'mpg' => 'video/mpeg', 'mov' => 'video/quicktime', 'qt' => 'video/quicktime', 'mxu' => 'video/vnd.mpegurl', 'asf' => 'video/x-ms-asf', 'asx' => 'video/x-ms-asf', 'wm' => 'video/x-ms-wm', 'wmv' => 'video/x-ms-wmv', 'wmx' => 'video/x-ms-wmx', 'wvx' => 'video/x-ms-wvx', 'avi' => 'video/x-msvideo', 'movie' => 'video/x-sgi-movie', 'ice' => 'x-conference/x-cooltalk', ); 69 69 70 70 /** … … 74 74 * @param array $params Array of parameters (key => val pairs). 75 75 */ 76 function setParam($params)76 public function setParam($params) 77 77 { 78 78 $app =& App::getInstance(); … … 118 118 * @return mixed Configured parameter value. 119 119 */ 120 function getParam($param)121 { 122 $app =& App::getInstance(); 123 120 public function getParam($param) 121 { 122 $app =& App::getInstance(); 123 124 124 if (isset($this->_params[$param])) { 125 125 return $this->_params[$param]; … … 144 144 * In this case it is necessary to check the Upload::anyErrors method to discover if any did fail. 145 145 */ 146 function process($form_name, $custom_file_name=null)146 public function process($form_name, $custom_file_name=null) 147 147 { 148 148 $app =& App::getInstance(); … … 278 278 279 279 // Check to be sure the file has a valid file name extension. 280 if (!in_array(mb_strtolower( $this->getFilenameExtension($file_name)), $this->getParam('valid_file_extensions'))) {281 // /TODO: Add option to allow any extention to be uploaded.280 if (!in_array(mb_strtolower(self::getFilenameExtension($file_name)), $this->getParam('valid_file_extensions'))) { 281 // TODO: Add option to allow any extention to be uploaded. 282 282 $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__); 283 283 $app->logMsg(sprintf('The uploaded file %s has an unrecognized file name extension.', $file_name), LOG_WARNING, __FILE__, __LINE__); … … 306 306 307 307 // FINAL path and file name, lowercase extension. 308 $file_extension = mb_strtolower( $this->getFilenameExtension($file_name));308 $file_extension = mb_strtolower(self::getFilenameExtension($file_name)); 309 309 $file_name = sprintf('%s.%s', mb_substr($file_name, 0, mb_strrpos($file_name, '.')), $file_extension); 310 310 $file_path_name = sprintf('%s/%s', $this->getParam('upload_path'), $file_name); … … 351 351 * @return bool Success of operation. 352 352 */ 353 function deleteFile($file_name, $use_glob=false)353 public function deleteFile($file_name, $use_glob=false) 354 354 { 355 355 $app =& App::getInstance(); … … 384 384 * @return bool Success of operation. 385 385 */ 386 function moveFile($old_name, $new_name)386 public function moveFile($old_name, $new_name) 387 387 { 388 388 $app =& App::getInstance(); … … 419 419 * @return bool Existence of file. 420 420 */ 421 function exists($file_name)421 public function exists($file_name) 422 422 { 423 423 $app =& App::getInstance(); … … 442 442 * @since 15 Nov 2005 20:55:22 443 443 */ 444 function getFilenameGlob($pattern)444 public function getFilenameGlob($pattern) 445 445 { 446 446 $file_list = glob(sprintf('%s/%s', $this->getParam('upload_path'), $pattern)); … … 458 458 * @return array List of file names. 459 459 */ 460 function getErrors()460 public function getErrors() 461 461 { 462 462 return $this->errors; … … 468 468 * @access public 469 469 */ 470 function anyErrors()470 public function anyErrors() 471 471 { 472 472 return sizeof($this->errors) > 0; … … 480 480 * @return string The same name, but cleaned. 481 481 */ 482 function cleanFileName($file_name)483 { 484 $bad = 'áéÃóúà ÚìòùÀëïöÌÃÃÃÃÃÃÃÃÃÃÃÃÃÃÃâêîÎûÃÃÃÃÃñçà @';485 $good = 'aeiouaeiouaeiouAEIOUAEIOUAEIOUaeiouAEIOUncC a';482 public function cleanFileName($file_name) 483 { 484 $bad = 'áéÃóúà ÚìòùÀëïöÌÃÃÃÃÃÃÃÃÃÃÃÃÃÃÃâêîÎûÃÃÃÃÃñçÃ'; 485 $good = 'aeiouaeiouaeiouAEIOUAEIOUAEIOUaeiouAEIOUncC'; 486 486 $file_name = trim($file_name); 487 487 $file_name = strtr($file_name, $bad, $good); 488 $file_name = preg_replace('/[^-\w.,~_=+() ]+/i', '_', $file_name);488 $file_name = preg_replace('/[^-\w.,~_=+()@]+/i', '_', $file_name); 489 489 $file_name = mb_substr($file_name, 0, 250); 490 490 return $file_name; … … 499 499 * @return string The value found after the dot 500 500 */ 501 function getFilenameExtension($file_name)501 static public function getFilenameExtension($file_name) 502 502 { 503 503 preg_match('/.*?\.(\w+)$/i', trim($file_name), $ext); … … 516 516 * @param string $line __LINE__. 517 517 */ 518 function _raiseMsg($message, $type, $file, $line)518 public function _raiseMsg($message, $type, $file, $line) 519 519 { 520 520 $app =& App::getInstance(); … … 526 526 } 527 527 528 ?> -
trunk/lib/Utilities.inc.php
r465 r468 950 950 951 951 $add_members = '/usr/lib/mailman/bin/add_members'; 952 // /FIXME: checking of executable is disabled.952 // FIXME: checking of executable is disabled. 953 953 if (true || is_executable($add_members) && is_readable($add_members)) { 954 954 $welcome_msg = $send_welcome_message ? 'y' : 'n'; … … 982 982 983 983 $remove_members = '/usr/lib/mailman/bin/remove_members'; 984 // /FIXME: checking of executable is disabled.984 // FIXME: checking of executable is disabled. 985 985 if (true || is_executable($remove_members) && is_readable($remove_members)) { 986 986 $userack = $send_user_ack ? '' : '--nouserack'; … … 1120 1120 } 1121 1121 } 1122 1123 ?> -
trunk/lib/Validator.inc.php
r459 r468 31 31 */ 32 32 33 // Known credit card types.34 define('CC_TYPE_VISA', 1);35 define('CC_TYPE_MASTERCARD', 2);36 define('CC_TYPE_AMEX', 3);37 define('CC_TYPE_DISCOVER', 4);38 define('CC_TYPE_DINERS', 5);39 define('CC_TYPE_JCB', 6);40 41 // validateEmail return types.42 define('VALIDATE_EMAIL_SUCCESS', 0);43 define('VALIDATE_EMAIL_REGEX_FAIL', 1);44 define('VALIDATE_EMAIL_LENGTH_FAIL', 2);45 define('VALIDATE_EMAIL_MX_FAIL', 3);46 47 33 class Validator { 48 34 35 // Known credit card types. 36 const CC_TYPE_VISA = 1; 37 const CC_TYPE_MASTERCARD = 2; 38 const CC_TYPE_AMEX = 3; 39 const CC_TYPE_DISCOVER = 4; 40 const CC_TYPE_DINERS = 5; 41 const CC_TYPE_JCB = 6; 42 43 // Validator::validateEmail() return types. 44 const EMAIL_SUCCESS = 0; 45 const EMAIL_REGEX_FAIL = 1; 46 const EMAIL_LENGTH_FAIL = 2; 47 const EMAIL_MX_FAIL = 3; 48 49 // Validator::validatePhone() return types. 50 const PHONE_SUCCESS = 0; 51 const PHONE_REGEX_FAIL = 1; 52 const PHONE_LENGTH_FAIL = 2; 53 49 54 /** 50 55 * Ensures a value is empty. … … 53 58 * @return bool true if form is not empty, false otherwise. 54 59 */ 55 function notEmpty($val)60 static public function notEmpty($val) 56 61 { 57 62 return '' != trim((string)$val); … … 64 69 * @return bool true if form is empty, false otherwise. 65 70 */ 66 function isEmpty($val)71 static public function isEmpty($val) 67 72 { 68 73 return '' == trim((string)$val); … … 75 80 * @return bool true if form is a string, false otherwise. 76 81 */ 77 function isString($val)82 static public function isString($val) 78 83 { 79 84 return '' == trim((string)$val) || is_string($val); … … 86 91 * @return bool True if no errors found, false otherwise. 87 92 */ 88 function isNumber($val)93 static public function isNumber($val) 89 94 { 90 95 return '' == trim((string)$val) || is_numeric($val); … … 98 103 * @return bool true if value is an integer 99 104 */ 100 function isInteger($val, $negative_ok=false)105 static public function isInteger($val, $negative_ok=false) 101 106 { 102 107 $pattern = $negative_ok ? '/^-?[[:digit:]]+$/' : '/^[[:digit:]]+$/'; … … 112 117 * @return bool true if value is a float 113 118 */ 114 function isFloat($val, $negative_ok=false)119 static public function isFloat($val, $negative_ok=false) 115 120 { 116 121 $pattern = $negative_ok ? '/^-?[[:digit:]]*(?:\.?[[:digit:]]+)$/' : '/^[[:digit:]]*(?:\.?[[:digit:]]+)$/'; … … 124 129 * @return bool true if value is a float 125 130 */ 126 function isArray($val)131 static public function isArray($val) 127 132 { 128 133 return (is_string($val) && '' == trim((string)$val)) || is_array($val); … … 138 143 * @return bool true if value passes regex test 139 144 */ 140 function checkRegex($val, $regex, $valid_on_match=true)145 static public function checkRegex($val, $regex, $valid_on_match=true) 141 146 { 142 147 return $valid_on_match ? preg_match($regex, $val) : !preg_match($regex, $val); … … 151 156 * @return bool true if string length is within given boundaries 152 157 */ 153 function stringLength($val, $min, $max)158 static public function stringLength($val, $min, $max) 154 159 { 155 160 return mb_strlen(trim((string)$val)) >= $min && mb_strlen($val) <= $max; … … 164 169 * @return bool True if no errors found, false otherwise. 165 170 */ 166 function numericRange($val, $min, $max)171 static public function numericRange($val, $min, $max) 167 172 { 168 173 return '' == trim((string)$val) || (is_numeric($val) && $val >= $min && $val <= $max); … … 180 185 * @access public 181 186 * @param string $val The input data to validate.. 182 * @return const One of the constant values: VALIDATE_EMAIL_SUCCESS|VALIDATE_EMAIL_REGEX_FAIL|VALIDATE_EMAIL_LENGTH_FAIL|VALIDATE_EMAIL_MX_FAIL 187 * @param bool $strict Do we run strict tests? 188 * @return const One of the constant values: Validate::EMAIL_SUCCESS|Validate::EMAIL_REGEX_FAIL|Validate::EMAIL_LENGTH_FAIL|Validate::EMAIL_MX_FAIL 183 189 * @author Quinn Comendant <quinn@strangecode.com> 184 190 */ 185 function validateEmail($val)191 static public function validateEmail($val, $strict=false) 186 192 { 187 193 require_once 'codebase/lib/Email.inc.php'; … … 190 196 // Test email address format. 191 197 if (!preg_match($e->getParam('regex'), $val, $e_parts)) { 192 return VALIDATE_EMAIL_REGEX_FAIL;198 return self::EMAIL_REGEX_FAIL; 193 199 } 194 200 … … 203 209 // Test length. 204 210 if (mb_strlen($local) > 64 || mb_strlen($domain) > 191) { 205 return VALIDATE_EMAIL_LENGTH_FAIL; 206 } 207 208 // Check domain exists: It's a domain if ip2long fails; Checkdnsrr ensures a MX record exists; Gethostbyname() ensures the domain exists. 209 // Compare ip2long twice for php4 backwards compat. 210 if ((ip2long($domain) == '-1' || ip2long($domain) === false) && function_exists('checkdnsrr') && !checkdnsrr($domain . '.', 'MX') && gethostbyname($domain) == $domain) { 211 // FIXME: Do we care? 212 // return VALIDATE_EMAIL_MX_FAIL; 213 } 214 215 return VALIDATE_EMAIL_SUCCESS; 211 return self::EMAIL_LENGTH_FAIL; 212 } 213 214 // Strict tests below. 215 216 // Check domain exists: It's a domain if ip2long fails; checkdnsrr ensures a MX record exists; gethostbyname() ensures the domain exists. 217 if ($strict && ip2long($domain) === false && function_exists('checkdnsrr') && !checkdnsrr($domain . '.', 'MX') && gethostbyname($domain) == $domain) { 218 return self::EMAIL_MX_FAIL; 219 } 220 221 return self::EMAIL_SUCCESS; 222 } 223 224 /** 225 * Check whether input is a valid phone number. Notice: it is now set 226 * to allow characters like - or () or + so people can type in a phone 227 * number that looks like: +1 (530) 555-1212 228 * 229 * @param string $form_name the name of the incoming form variable 230 * 231 * @return bool true if no errors found, false otherwise 232 */ 233 static public function validatePhone($val) 234 { 235 if (!self::checkRegex($val, '/^[0-9 +().-]*$/', true)) { 236 return self::PHONE_REGEX_FAIL; 237 } 238 if (!self::stringLength($val, 0, 25)) { 239 return self::PHONE_LENGTH_FAIL; 240 } 241 return self::PHONE_SUCCESS; 216 242 } 217 243 … … 223 249 * @return bool True if no errors found, false otherwise. 224 250 */ 225 function validateStrDate($val) 226 { 227 $app =& App::getInstance(); 228 251 static public function validateStrDate($val) 252 { 229 253 if (is_string($val) && '' === trim($val)) { 230 254 // Don't be too bothered about empty strings. … … 249 273 * @return bool True if no errors found, false otherwise. 250 274 */ 251 function validateCCNumber($val, $cc_type=null)252 253 254 255 256 257 258 caseCC_TYPE_VISA :259 260 261 caseCC_TYPE_MASTERCARD :262 263 264 caseCC_TYPE_AMEX :265 266 267 caseCC_TYPE_DISCOVER :268 269 270 caseCC_TYPE_DINERS :271 272 273 caseCC_TYPE_JCB :274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 275 static public function validateCCNumber($val, $cc_type=null) 276 { 277 // Get rid of any non-digits 278 $cc_num = preg_replace('/[^\d]/', '', $val); 279 280 // Perform card-specific checks, if applicable 281 switch ($cc_type) { 282 case self::CC_TYPE_VISA : 283 $regex = '/^4\d{15}$|^4\d{12}$/'; 284 break; 285 case self::CC_TYPE_MASTERCARD : 286 $regex = '/^5[1-5]\d{14}$/'; 287 break; 288 case self::CC_TYPE_AMEX : 289 $regex = '/^3[47]\d{13}$/'; 290 break; 291 case self::CC_TYPE_DISCOVER : 292 $regex = '/^6011\d{12}$/'; 293 break; 294 case self::CC_TYPE_DINERS : 295 $regex = '/^30[0-5]\d{11}$|^3[68]\d{12}$/'; 296 break; 297 case self::CC_TYPE_JCB : 298 $regex = '/^3\d{15}$|^2131|1800\d{11}$/'; 299 break; 300 default : 301 $regex = ''; 302 break; 303 } 304 305 if ('' != $regex && !preg_match($regex, $cc_num)) { 306 // Invalid format. 307 return false; 308 } 309 310 // The Luhn formula works right to left, so reverse the number. 311 $cc_num = strrev($cc_num); 312 313 $luhn_total = 0; 314 315 $num = mb_strlen($cc_num); 316 for ($i=0; $i<$num; $i++) { 317 // Get each digit. 318 $digit = mb_substr($cc_num, $i, 1); 319 320 // If it's an odd digit, double it. 321 if ($i / 2 != floor($i / 2)) { 322 $digit *= 2; 323 } 324 325 // If the result is two digits, add them. 326 if (mb_strlen($digit) == 2) { 327 $digit = mb_substr($digit, 0, 1) + mb_substr($digit, 1, 1); 328 } 329 330 // Add the current digit to the $luhn_total. 331 $luhn_total += $digit; 332 } 333 334 // If the Total is evenly divisible by 10, it's cool! 335 return $luhn_total % 10 == 0; 336 } 313 337 314 338 /** … … 318 342 * @return bool True if no errors found, false otherwise. 319 343 */ 320 function fileUploaded($form_name)344 static public function fileUploaded($form_name) 321 345 { 322 346 if (!isset($_FILES[$form_name]['name']) || empty($_FILES[$form_name]['name'])) { … … 341 365 } // THE END 342 366 343 ?> -
trunk/lib/Version.inc.php
r396 r468 4 4 * For details visit the project site: <http://trac.strangecode.com/codebase/> 5 5 * Copyright 2001-2012 Strangecode, LLC 6 * 6 * 7 7 * This file is part of The Strangecode Codebase. 8 8 * … … 11 11 * Free Software Foundation, either version 3 of the License, or (at your option) 12 12 * any later version. 13 * 13 * 14 14 * The Strangecode Codebase is distributed in the hope that it will be useful, but 15 15 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 16 16 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more 17 17 * details. 18 * 18 * 19 19 * You should have received a copy of the GNU General Public License along with 20 20 * The Strangecode Codebase. If not, see <http://www.gnu.org/licenses/>. … … 39 39 class Version { 40 40 41 // A place to keep an object instance for the singleton pattern. 42 private static $instance = null; 43 41 44 // Configuration of this object. 42 var$_params = array(45 private $_params = array( 43 46 'max_qty' => 100, // Never have more than this many versions of each record. 44 47 'min_qty' => 25, // Keep at least this many versions of each record. 45 48 'min_days' => 7, // Keep ALL versions within this many days, even if MORE than min_qty. 46 49 'db_table' => 'version_tbl', 47 50 48 51 // Automatically create table and verify columns. Better set to false after site launch. 49 52 // This value is overwritten by the $app->getParam('db_create_tables') setting if it is available. … … 54 57 55 58 // Auth_SQL object from which to access a current user_id. 56 var$_auth;59 private $_auth; 57 60 58 61 /** … … 63 66 * @static 64 67 */ 65 static function &getInstance($auth_object) 66 { 67 static $instance = null; 68 69 if ($instance === null) { 70 $instance = new Version($auth_object); 71 } 72 73 return $instance; 68 public static function &getInstance($auth_object) 69 { 70 if (self::$instance === null) { 71 self::$instance = new self($auth_object); 72 } 73 74 return self::$instance; 74 75 } 75 76 … … 79 80 * @param mixed $auth_object An Auth_SQL object. 80 81 */ 81 function Version($auth_object)82 public function __construct($auth_object) 82 83 { 83 84 $app =& App::getInstance(); … … 102 103 * @since 26 Aug 2005 17:09:36 103 104 */ 104 function initDB($recreate_db=false)105 public function initDB($recreate_db=false) 105 106 { 106 107 $app =& App::getInstance(); … … 155 156 * @param array $params Array of param keys and values to set. 156 157 */ 157 function setParam($params=null)158 public function setParam($params=null) 158 159 { 159 160 if (isset($params) && is_array($params)) { … … 170 171 * @return mixed Configured parameter value. 171 172 */ 172 function getParam($param)173 public function getParam($param) 173 174 { 174 175 $app =& App::getInstance(); 175 176 176 177 if (isset($this->_params[$param])) { 177 178 return $this->_params[$param]; … … 192 193 * @return int The id for the version (mysql last insert id). 193 194 */ 194 function create($record_table, $record_key, $record_val, $title='', $notes='')195 public function create($record_table, $record_key, $record_val, $title='', $notes='') 195 196 { 196 197 $app =& App::getInstance(); … … 204 205 return false; 205 206 } 206 207 207 208 // Get previous version_number. 208 209 $qid = $db->query(" … … 253 254 * @return int The id for the version (mysql last insert id). 254 255 */ 255 function restore($version_id)256 public function restore($version_id) 256 257 { 257 258 $app =& App::getInstance(); … … 314 315 * @return mixed Array of versions, or false if none. 315 316 */ 316 function deleteOld($record_table, $record_key, $record_val)317 { 318 $db =& DB::getInstance(); 319 317 public function deleteOld($record_table, $record_key, $record_val) 318 { 319 $db =& DB::getInstance(); 320 320 321 $this->initDB(); 321 322 … … 381 382 * @return mixed Array of versions, or false if none. 382 383 */ 383 function getList($record_table, $record_key, $record_val)384 { 385 $db =& DB::getInstance(); 386 384 public function getList($record_table, $record_key, $record_val) 385 { 386 $db =& DB::getInstance(); 387 387 388 $this->initDB(); 388 389 389 390 // Get versions of this record. 390 391 $qid = $db->query(" 391 SELECT 392 SELECT 392 393 version_id, 393 394 saved_by_user_id, … … 418 419 * @return mixed Array of data saved in version, or false if none. 419 420 */ 420 function getVerson($version_id)421 { 422 $db =& DB::getInstance(); 423 421 public function getVerson($version_id) 422 { 423 $db =& DB::getInstance(); 424 424 425 $this->initDB(); 425 426 … … 439 440 * @return mixed Array of data saved in version, or false if none. 440 441 */ 441 function getData($version_id)442 { 443 $db =& DB::getInstance(); 444 442 public function getData($version_id) 443 { 444 $db =& DB::getInstance(); 445 445 446 $this->initDB(); 446 447 … … 465 466 * @return mixed Array of data saved in version, or false if none. 466 467 */ 467 function getCurrent($record_table, $record_key, $record_val)468 { 469 $db =& DB::getInstance(); 470 468 public function getCurrent($record_table, $record_key, $record_val) 469 { 470 $db =& DB::getInstance(); 471 471 472 $this->initDB(); 472 473 … … 484 485 485 486 } // End of class. 486 ?> -
trunk/services/admins.php
r458 r468 55 55 56 56 // Configure the cache object. 57 $cache = new Cache('admins');57 $cache =& Cache::getInstance('admins'); 58 58 $cache->setParam(array('enabled' => false)); // Better leave disabled; the list gets out of sync with the db otherwise, somehow. 59 59 … … 552 552 } 553 553 554 ?> -
trunk/services/css.php
r396 r468 36 36 } 37 37 38 ?> -
trunk/services/lock.php
r457 r468 4 4 * For details visit the project site: <http://trac.strangecode.com/codebase/> 5 5 * Copyright 2001-2012 Strangecode, LLC 6 * 6 * 7 7 * This file is part of The Strangecode Codebase. 8 8 * … … 11 11 * Free Software Foundation, either version 3 of the License, or (at your option) 12 12 * any later version. 13 * 13 * 14 14 * The Strangecode Codebase is distributed in the hope that it will be useful, but 15 15 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 16 16 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more 17 17 * details. 18 * 18 * 19 19 * You should have received a copy of the GNU General Public License along with 20 20 * The Strangecode Codebase. If not, see <http://www.gnu.org/licenses/>. … … 69 69 include 'footer.ihtml'; 70 70 71 ?> -
trunk/services/login.php
r462 r468 36 36 $login_prefs->setDefaults(array('username' => '')); 37 37 38 if ('' != $login_prefs->get('username')) {39 $frm['remember_me'] = '1';40 }41 42 38 $frm['username'] = getFormdata('username', $login_prefs->get('username')); 43 39 $frm['password'] = getFormdata('password'); 40 $frm['remember_me'] = ('' != $login_prefs->get('username')) ? '1' : ''; 44 41 45 42 if (getFormdata('username', false)) { … … 69 66 include 'footer.ihtml'; 70 67 71 ?> -
trunk/services/logout.php
r396 r468 38 38 $app->dieURL($app->getParam('redirect_home_url')); 39 39 40 ?> -
trunk/services/logs.php
r457 r468 293 293 294 294 295 ?> -
trunk/services/password.php
r396 r468 87 87 include 'footer.ihtml'; 88 88 89 ?> -
trunk/services/phpinfo.php
r396 r468 38 38 ?><h1>$_SERVER dump</h1><?php 39 39 dump($_SERVER,1); 40 ?> -
trunk/services/reset_password.php
r396 r468 87 87 include 'footer.ihtml'; 88 88 89 ?> -
trunk/services/versions.php
r457 r468 136 136 include 'footer.ihtml'; 137 137 138 ?> -
trunk/tests/AppTest.php
r396 r468 4 4 * For details visit the project site: <http://trac.strangecode.com/codebase/> 5 5 * Copyright 2001-2012 Strangecode, LLC 6 * 6 * 7 7 * This file is part of The Strangecode Codebase. 8 8 * … … 11 11 * Free Software Foundation, either version 3 of the License, or (at your option) 12 12 * any later version. 13 * 13 * 14 14 * The Strangecode Codebase is distributed in the hope that it will be useful, but 15 15 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 16 16 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more 17 17 * details. 18 * 18 * 19 19 * You should have received a copy of the GNU General Public License along with 20 20 * The Strangecode Codebase. If not, see <http://www.gnu.org/licenses/>. … … 30 30 * Created with PHPUnit_Skeleton on 2005-08-09 31 31 */ 32 require_once 'PHPUnit.php'; 33 class AppTest extends PHPUnit_ TestCase {32 33 class AppTest extends PHPUnit_Framework_TestCase { 34 34 35 35 var $App; 36 36 37 function AppTest($name) 38 { 39 $this->PHPUnit_TestCase($name); 40 } 37 static $shared_session; 41 38 42 39 function setUp() … … 44 41 require dirname(__FILE__) . '/_config.inc.php'; 45 42 $this->App =& $app; 43 $_SESSION = AppTest::$shared_session; 46 44 } 47 45 … … 49 47 { 50 48 unset($this->App); 49 AppTest::$shared_session = $_SESSION; 51 50 } 52 51 … … 62 61 'test_config_value' => 1234 63 62 )); 64 $this->assertTrue(1234 === $this->App-> _params['test_config_value']);63 $this->assertTrue(1234 === $this->App->getParam('test_config_value')); 65 64 } 66 65 67 66 function test_getParam() 68 67 { 69 $this->App->_params['test_config_value2'] = 'okay'; 68 //$this->App->setParam('test_config_value2', 'okay'); 69 $this->App->setParam(array( 70 'test_config_value2' => 'okay' 71 )); 70 72 $result = $this->App->getParam('test_config_value2'); 71 73 $this->assertEquals('okay', $result); … … 93 95 { 94 96 $db =& DB::getInstance(); 95 97 96 98 $qid = $db->query("SELECT 2 + 2"); 97 99 list($result) = mysql_fetch_row($qid); … … 104 106 $expected = 'My message'; 105 107 $app->raiseMsg($expected, MSG_NOTICE, __FILE__, __LINE__); 106 $msg = current($_SESSION['_app'][ $this->App->_ns]['messages']);108 $msg = current($_SESSION['_app']['testapp']['messages']); 107 109 $this->assertEquals($expected, $msg['message']); 108 110 } … … 111 113 { 112 114 ob_start(); 115 $this->test_raisemsg(); //had to add this line for phpunit ver. 3.7 /// 113 116 $app =& App::getInstance(); 114 117 $app->printraisedmessages(); … … 205 208 } 206 209 // Running the test. 210 /* 207 211 $suite = new PHPUnit_TestSuite('AppTest'); 208 212 $result = PHPUnit::run($suite); 209 213 echo $result->toString(); 210 ?> 214 */ -
trunk/tests/Auth_FileTest.php
r396 r468 4 4 * For details visit the project site: <http://trac.strangecode.com/codebase/> 5 5 * Copyright 2001-2012 Strangecode, LLC 6 * 6 * 7 7 * This file is part of The Strangecode Codebase. 8 8 * … … 11 11 * Free Software Foundation, either version 3 of the License, or (at your option) 12 12 * any later version. 13 * 13 * 14 14 * The Strangecode Codebase is distributed in the hope that it will be useful, but 15 15 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 16 16 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more 17 17 * details. 18 * 18 * 19 19 * You should have received a copy of the GNU General Public License along with 20 20 * The Strangecode Codebase. If not, see <http://www.gnu.org/licenses/>. … … 120 120 $result = PHPUnit::run($suite); 121 121 echo $result->toString(); 122 ?> -
trunk/tests/Auth_SQLTest.php
r457 r468 4 4 * For details visit the project site: <http://trac.strangecode.com/codebase/> 5 5 * Copyright 2001-2012 Strangecode, LLC 6 * 6 * 7 7 * This file is part of The Strangecode Codebase. 8 8 * … … 11 11 * Free Software Foundation, either version 3 of the License, or (at your option) 12 12 * any later version. 13 * 13 * 14 14 * The Strangecode Codebase is distributed in the hope that it will be useful, but 15 15 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 16 16 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more 17 17 * details. 18 * 18 * 19 19 * You should have received a copy of the GNU General Public License along with 20 20 * The Strangecode Codebase. If not, see <http://www.gnu.org/licenses/>. … … 30 30 * Created with PHPUnit_Skeleton on 2005-08-09 31 31 */ 32 require_once 'PHPUnit.php'; 32 33 33 class Auth_SQLTest extends PHPUnit_TestCase { 34 34 … … 51 51 'login_url' => '/login.php', 52 52 'blocking' => true, 53 'encryption_type' => A UTH_ENCRYPT_MD5_HARDENED,53 'encryption_type' => Auth_SQL::ENCRYPT_MD5_HARDENED, 54 54 )); 55 55 … … 80 80 { 81 81 $db =& DB::getInstance(); 82 82 83 83 unset($this->Auth_SQL); 84 84 $db->query("DROP TABLE IF EXISTS test_user_tbl"); … … 145 145 $after_logged_in = $this->Auth_SQL->isloggedin(); 146 146 $this->assertFalse($after_logged_in, '3. User is still logged in but should not be.'); 147 147 148 148 // Testing wrong password. 149 149 $login2 = $this->Auth_SQL->login('testuser', 'wrongpass'); … … 164 164 { 165 165 $db =& DB::getInstance(); 166 166 167 167 $this->Auth_SQL->login('testuser', 'testpass'); 168 168 $this->Auth_SQL->blockaccount(null, 'blocktestuser'); … … 178 178 { 179 179 $db =& DB::getInstance(); 180 180 181 181 $db->query(" 182 182 UPDATE test_user_tbl SET blocked_reason = 'blocktestuser' … … 212 212 function test_encryptpassword() 213 213 { 214 $this->Auth_SQL->setParam(array('encryption_type' => A UTH_ENCRYPT_MD5));214 $this->Auth_SQL->setParam(array('encryption_type' => Auth_SQL::ENCRYPT_MD5)); 215 215 $result = $this->Auth_SQL->encryptpassword('123'); 216 216 $this->assertEquals('202cb962ac59075b964b07152d234b70', $result); 217 217 218 $this->Auth_SQL->setParam(array('encryption_type' => A UTH_ENCRYPT_MD5_HARDENED));218 $this->Auth_SQL->setParam(array('encryption_type' => Auth_SQL::ENCRYPT_MD5_HARDENED)); 219 219 $result = $this->Auth_SQL->encryptpassword('123'); 220 220 $this->assertEquals('c55e4ac608a8768ecd758fab971b0646', $result); 221 221 222 $this->Auth_SQL->setParam(array('encryption_type' => A UTH_ENCRYPT_SHA1));222 $this->Auth_SQL->setParam(array('encryption_type' => Auth_SQL::ENCRYPT_SHA1)); 223 223 $result = $this->Auth_SQL->encryptpassword('123'); 224 224 $this->assertEquals('40bd001563085fc35165329ea1ff5c5ecbdbbeef', $result); 225 225 226 $this->Auth_SQL->setParam(array('encryption_type' => A UTH_ENCRYPT_SHA1_HARDENED));226 $this->Auth_SQL->setParam(array('encryption_type' => Auth_SQL::ENCRYPT_SHA1_HARDENED)); 227 227 $result = $this->Auth_SQL->encryptpassword('123'); 228 228 $this->assertEquals('33d90af96a5928ac93cbd41fc436e8c55d2768c2', $result); 229 229 230 $this->Auth_SQL->setParam(array('encryption_type' => A UTH_ENCRYPT_PLAINTEXT));230 $this->Auth_SQL->setParam(array('encryption_type' => Auth_SQL::ENCRYPT_PLAINTEXT)); 231 231 $result = $this->Auth_SQL->encryptpassword('123'); 232 232 $this->assertEquals('123', $result); 233 233 234 $this->Auth_SQL->setParam(array('encryption_type' => A UTH_ENCRYPT_CRYPT));234 $this->Auth_SQL->setParam(array('encryption_type' => Auth_SQL::ENCRYPT_CRYPT)); 235 235 $result = $this->Auth_SQL->encryptpassword('123', 'saltstring'); 236 236 $this->assertEquals('saEZ6MlWYV9nQ', $result); … … 240 240 { 241 241 $db =& DB::getInstance(); 242 243 $this->Auth_SQL->setParam(array('encryption_type' => A UTH_ENCRYPT_SHA1_HARDENED));242 243 $this->Auth_SQL->setParam(array('encryption_type' => Auth_SQL::ENCRYPT_SHA1_HARDENED)); 244 244 $this->Auth_SQL->setpassword(null, '123'); 245 245 $qid = $db->query(" … … 261 261 $result = PHPUnit::run($suite); 262 262 echo $result->toString(); 263 ?> -
trunk/tests/AuthorizeNetTest.php
r396 r468 30 30 * Created with PHPUnit_Skeleton on 2005-08-09 31 31 */ 32 require_once 'PHPUnit.php'; 33 class AuthorizeNetTest extends PHPUnit_ TestCase {32 33 class AuthorizeNetTest extends PHPUnit_Framework_TestCase { 34 34 35 35 var $AuthorizeNet; 36 37 function AuthorizeNetTest($name) 38 { 39 $this->PHPUnit_TestCase($name); 40 } 41 36 37 static $shared_session; 38 42 39 function setUp() 43 40 { … … 45 42 require_once '../lib/AuthorizeNet.inc.php'; 46 43 47 $this->AuthorizeNet = &new AuthorizeNet();44 $this->AuthorizeNet = new AuthorizeNet(); 48 45 $this->AuthorizeNet->setParam(array( 49 46 'x_login' => 'myaccount', … … 61 58 'x_zip' => '75010', 62 59 )); 60 $_SESSION = AuthorizeNetTest::$shared_session; 63 61 } 64 62 … … 66 64 { 67 65 unset($this->AuthorizeNet); 66 AuthorizeNetTest::$shared_session = $_SESSION; 68 67 } 69 68 … … 71 70 { 72 71 $this->AuthorizeNet->setparam(array('x_Login' => 'myaccount2')); 73 $this->assertEquals('myaccount2', $this->AuthorizeNet-> _params['x_Login']);72 $this->assertEquals('myaccount2', $this->AuthorizeNet->getParam('x_Login')); 74 73 } 75 74 … … 119 118 120 119 } 121 // Running the test.122 $suite = new PHPUnit_TestSuite('AuthorizeNetTest');123 $result = PHPUnit::run($suite);124 echo $result->toString();125 ?> -
trunk/tests/CSSTest.php
r396 r468 30 30 * Created with PHPUnit_Skeleton on 2005-08-09 31 31 */ 32 require_once 'PHPUnit.php'; 33 class CSSTest extends PHPUnit_ TestCase {32 33 class CSSTest extends PHPUnit_Framework_TestCase { 34 34 35 35 var $CSS; 36 36 var $test_css_file; 37 38 function CSSTest($name)39 {40 $this->PHPUnit_TestCase($name);41 }42 37 43 38 function setUp() … … 46 41 $this->test_css_file = dirname(__FILE__) . '/../css/codebase.inc.css'; 47 42 require_once '../lib/CSS.inc.php'; 48 $this->CSS = &new CSS();43 $this->CSS = new CSS(); 49 44 $this->CSS->setFile($this->test_css_file); 50 45 } … … 86 81 87 82 } 88 // Running the test.89 $suite = new PHPUnit_TestSuite('CSSTest');90 $result = PHPUnit::run($suite);91 echo $result->toString();92 ?> -
trunk/tests/CacheTest.php
r396 r468 7 7 * For details visit the project site: <http://trac.strangecode.com/codebase/> 8 8 * Copyright 2001-2012 Strangecode, LLC 9 * 9 * 10 10 * This file is part of The Strangecode Codebase. 11 11 * … … 14 14 * Free Software Foundation, either version 3 of the License, or (at your option) 15 15 * any later version. 16 * 16 * 17 17 * The Strangecode Codebase is distributed in the hope that it will be useful, but 18 18 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 19 19 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more 20 20 * details. 21 * 21 * 22 22 * You should have received a copy of the GNU General Public License along with 23 23 * The Strangecode Codebase. If not, see <http://www.gnu.org/licenses/>. … … 33 33 * Created with PHPUnit_Skeleton on 2005-08-09 34 34 */ 35 require_once 'PHPUnit.php'; 36 class CacheTest extends PHPUnit_ TestCase {35 36 class CacheTest extends PHPUnit_Framework_TestCase { 37 37 38 38 var $Cache; … … 40 40 function CacheTest($name) 41 41 { 42 $this->PHPUnit_ TestCase($name);42 $this->PHPUnit_Framework_TestCase($name); 43 43 } 44 44 … … 105 105 106 106 } 107 // Running the test.108 $suite = new PHPUnit_TestSuite('CacheTest');109 $result = PHPUnit::run($suite);110 echo $result->toString();111 ?> -
trunk/tests/DBSessionHandlerTest.php
r396 r468 4 4 * For details visit the project site: <http://trac.strangecode.com/codebase/> 5 5 * Copyright 2001-2012 Strangecode, LLC 6 * 6 * 7 7 * This file is part of The Strangecode Codebase. 8 8 * … … 11 11 * Free Software Foundation, either version 3 of the License, or (at your option) 12 12 * any later version. 13 * 13 * 14 14 * The Strangecode Codebase is distributed in the hope that it will be useful, but 15 15 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 16 16 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more 17 17 * details. 18 * 18 * 19 19 * You should have received a copy of the GNU General Public License along with 20 20 * The Strangecode Codebase. If not, see <http://www.gnu.org/licenses/>. … … 30 30 * Created with PHPUnit_Skeleton on 2005-08-09 31 31 */ 32 require_once 'PHPUnit.php'; 33 class DBSessionHandlerTest extends PHPUnit_ TestCase {32 33 class DBSessionHandlerTest extends PHPUnit_Framework_TestCase { 34 34 35 35 var $DBSessionHandler; 36 37 function DBSessionHandlerTest($name)38 {39 $this->PHPUnit_TestCase($name);40 }41 36 42 37 function setUp() … … 73 68 function test_DBsessionwrite() 74 69 { 70 if (!isset($_SESSION)) { 71 $_SESSION = array(); 72 } 75 73 $this->DBSessionHandler->DBsessionwrite(session_id(), serialize($_SESSION)); 76 74 } … … 87 85 88 86 } 89 // Running the test.90 $suite = new PHPUnit_TestSuite('DBSessionHandlerTest');91 $result = PHPUnit::run($suite);92 echo $result->toString();93 ?> -
trunk/tests/EmailTest.php
r399 r468 1 1 <?php 2 2 3 /** 3 4 * The Strangecode Codebase - a general application development framework for PHP … … 30 31 * Created with PHPUnit_Skeleton on 2005-12-01 31 32 */ 32 require_once 'PHPUnit.php'; 33 class EmailTest extends PHPUnit_ TestCase {33 34 class EmailTest extends PHPUnit_Framework_TestCase { 34 35 35 36 var $Email; 36 37 function EmailTest($name)38 {39 $this->PHPUnit_TestCase($name);40 }41 37 42 38 function setUp() … … 44 40 require dirname(__FILE__) . '/_config.inc.php'; 45 41 require_once '../lib/Email.inc.php'; 46 $this->Email = &new Email();42 $this->Email = new Email(); 47 43 } 48 44 … … 122 118 123 119 } 124 // Running the test.125 $suite = new PHPUnit_TestSuite('EmailTest');126 $result = PHPUnit::run($suite);127 echo $result->toString();128 ?> -
trunk/tests/FormValidatorTest.php
r396 r468 30 30 * Created with PHPUnit_Skeleton on 2005-08-09 31 31 */ 32 require_once 'PHPUnit.php'; 33 class FormValidatorTest extends PHPUnit_ TestCase {32 33 class FormValidatorTest extends PHPUnit_Framework_TestCase { 34 34 35 35 var $FormValidator; 36 37 function FormValidatorTest($name)38 {39 $this->PHPUnit_TestCase($name);40 }41 36 42 37 function setUp() … … 44 39 require dirname(__FILE__) . '/_config.inc.php'; 45 40 require_once '../lib/FormValidator.inc.php'; 46 $this->FormValidator = &new FormValidator();41 $this->FormValidator = new FormValidator(); 47 42 } 48 43 … … 294 289 295 290 } 296 // Running the test.297 $suite = new PHPUnit_TestSuite('FormValidatorTest');298 $result = PHPUnit::run($suite);299 echo $result->toString();300 ?> -
trunk/tests/Google_APITest.php
r396 r468 33 33 * Created with PHPUnit_Skeleton on 2005-08-09 34 34 */ 35 require_once 'PHPUnit.php'; 36 class GoogleAPITest extends PHPUnit_ TestCase {35 36 class GoogleAPITest extends PHPUnit_Framework_TestCase { 37 37 38 38 var $GoogleAPI; … … 40 40 function GoogleAPITest($name) 41 41 { 42 $this->PHPUnit_ TestCase($name);42 $this->PHPUnit_Framework_TestCase($name); 43 43 } 44 44 … … 91 91 92 92 } 93 // Running the test.94 $suite = new PHPUnit_TestSuite('GoogleAPITest');95 $result = PHPUnit::run($suite);96 echo $result->toString();97 ?> -
trunk/tests/HierarchyTest.php
r396 r468 33 33 * Created with PHPUnit_Skeleton on 2005-08-09 34 34 */ 35 require_once 'PHPUnit.php'; 36 class HierarchyTest extends PHPUnit_ TestCase {35 36 class HierarchyTest extends PHPUnit_Framework_TestCase { 37 37 38 38 var $Hierarchy; … … 40 40 function HierarchyTest($name) 41 41 { 42 $this->PHPUnit_ TestCase($name);42 $this->PHPUnit_Framework_TestCase($name); 43 43 } 44 44 … … 175 175 176 176 } 177 // Running the test.178 $suite = new PHPUnit_TestSuite('HierarchyTest');179 $result = PHPUnit::run($suite);180 echo $result->toString();181 ?> -
trunk/tests/ImageThumbTest.php
r396 r468 33 33 * Created with PHPUnit_Skeleton on 2005-08-09 34 34 */ 35 require_once 'PHPUnit.php'; 36 class ImageThumbTest extends PHPUnit_ TestCase {35 36 class ImageThumbTest extends PHPUnit_Framework_TestCase { 37 37 38 38 var $ImageThumb; … … 40 40 function ImageThumbTest($name) 41 41 { 42 $this->PHPUnit_ TestCase($name);42 $this->PHPUnit_Framework_TestCase($name); 43 43 } 44 44 … … 119 119 120 120 } 121 // Running the test.122 $suite = new PHPUnit_TestSuite('ImageThumbTest');123 $result = PHPUnit::run($suite);124 echo $result->toString();125 ?> -
trunk/tests/LockTest.php
r396 r468 30 30 * Created with PHPUnit_Skeleton on 2005-08-09 31 31 */ 32 require_once 'PHPUnit.php'; 33 class LockTest extends PHPUnit_ TestCase {32 33 class LockTest extends PHPUnit_Framework_TestCase { 34 34 35 35 var $Lock; 36 36 var $Auth_SQL; 37 38 function LockTest($name)39 {40 $this->PHPUnit_TestCase($name);41 }42 37 43 38 function setUp() … … 47 42 require_once '../lib/Auth_SQL.inc.php'; 48 43 49 $this->Auth_SQL = &new Auth_SQL('test');44 $this->Auth_SQL = new Auth_SQL('test'); 50 45 $this->Auth_SQL->setParam(array( 51 46 'db_table' => 'test_user_tbl', … … 208 203 { 209 204 $result = $this->Lock->getsecondselapsed(); 210 $this->assert Type('integer', $result);205 $this->assertInternalType('integer', $result); 211 206 } 212 207 213 208 } 214 // Running the test.215 $suite = new PHPUnit_TestSuite('LockTest');216 $result = PHPUnit::run($suite);217 echo $result->toString();218 ?> -
trunk/tests/MCVETest.php
r396 r468 33 33 * Created with PHPUnit_Skeleton on 2005-08-09 34 34 */ 35 require_once 'PHPUnit.php'; 36 class MCVETest extends PHPUnit_ TestCase {35 36 class MCVETest extends PHPUnit_Framework_TestCase { 37 37 38 38 var $MCVE; … … 40 40 function MCVETest($name) 41 41 { 42 $this->PHPUnit_ TestCase($name);42 $this->PHPUnit_Framework_TestCase($name); 43 43 } 44 44 … … 91 91 92 92 } 93 // Running the test.94 $suite = new PHPUnit_TestSuite('MCVETest');95 $result = PHPUnit::run($suite);96 echo $result->toString();97 ?> -
trunk/tests/NavTest.php
r396 r468 33 33 * Created with PHPUnit_Skeleton on 2005-08-09 34 34 */ 35 require_once 'PHPUnit.php'; 36 class NavigationTest extends PHPUnit_ TestCase {35 36 class NavigationTest extends PHPUnit_Framework_TestCase { 37 37 38 38 var $Navigation; … … 40 40 function NavigationTest($name) 41 41 { 42 $this->PHPUnit_ TestCase($name);42 $this->PHPUnit_Framework_TestCase($name); 43 43 } 44 44 … … 133 133 134 134 } 135 // Running the test.136 $suite = new PHPUnit_TestSuite('NavigationTest');137 $result = PHPUnit::run($suite);138 echo $result->toString();139 ?> -
trunk/tests/PEditTest.php
r396 r468 33 33 * Created with PHPUnit_Skeleton on 2005-08-09 34 34 */ 35 require_once 'PHPUnit.php'; 36 class PEditTest extends PHPUnit_ TestCase {35 36 class PEditTest extends PHPUnit_Framework_TestCase { 37 37 38 38 var $PEdit; … … 40 40 function PEditTest($name) 41 41 { 42 $this->PHPUnit_ TestCase($name);42 $this->PHPUnit_Framework_TestCase($name); 43 43 } 44 44 … … 154 154 155 155 } 156 // Running the test.157 $suite = new PHPUnit_TestSuite('PEditTest');158 $result = PHPUnit::run($suite);159 echo $result->toString();160 ?> -
trunk/tests/PageNumbersTest.php
r396 r468 33 33 * Created with PHPUnit_Skeleton on 2005-08-09 34 34 */ 35 require_once 'PHPUnit.php'; 36 class PageNumbersTest extends PHPUnit_ TestCase {35 36 class PageNumbersTest extends PHPUnit_Framework_TestCase { 37 37 38 38 var $PageNumbers; … … 40 40 function PageNumbersTest($name) 41 41 { 42 $this->PHPUnit_ TestCase($name);42 $this->PHPUnit_Framework_TestCase($name); 43 43 } 44 44 … … 133 133 134 134 } 135 // Running the test.136 $suite = new PHPUnit_TestSuite('PageNumbersTest');137 $result = PHPUnit::run($suite);138 echo $result->toString();139 ?> -
trunk/tests/PageSequenceTest.php
r396 r468 33 33 * Created with PHPUnit_Skeleton on 2005-08-09 34 34 */ 35 require_once 'PHPUnit.php'; 36 class PageSequenceTest extends PHPUnit_ TestCase {35 36 class PageSequenceTest extends PHPUnit_Framework_TestCase { 37 37 38 38 var $PageSequence; … … 40 40 function PageSequenceTest($name) 41 41 { 42 $this->PHPUnit_ TestCase($name);42 $this->PHPUnit_Framework_TestCase($name); 43 43 } 44 44 … … 182 182 183 183 } 184 // Running the test.185 $suite = new PHPUnit_TestSuite('PageSequenceTest');186 $result = PHPUnit::run($suite);187 echo $result->toString();188 ?> -
trunk/tests/PayPalTest.php
r396 r468 30 30 * Created with PHPUnit_Skeleton on 2005-08-09 31 31 */ 32 require_once 'PHPUnit.php'; 33 class PayPalTest extends PHPUnit_ TestCase {32 33 class PayPalTest extends PHPUnit_Framework_TestCase { 34 34 35 35 var $PayPal; 36 37 function PayPalTest($name)38 {39 $this->PHPUnit_TestCase($name);40 }41 36 42 37 function setUp() … … 44 39 require dirname(__FILE__) . '/_config.inc.php'; 45 40 require_once '../lib/PayPal.inc.php'; 46 $this->PayPal = &new PayPal();41 $this->PayPal = new PayPal(); 47 42 48 43 // Defaults for purchasing classified postings. … … 90 85 )); 91 86 $result = $this->PayPal->getlink('testitem'); 92 $this->assertTrue(preg_match('/customdata/', $result)); 87 //$this->assertTrue(preg_match('/customdata/', $result)); 88 $this->assertSame(1, preg_match('/customdata/', $result)); 93 89 } 94 90 … … 103 99 $this->PayPal->printbutton('testitem'); 104 100 $result = ob_get_clean(); 105 $this->assertTrue(preg_match('/customdata/', $result)); 101 //$this->assertTrue(preg_match('/customdata/', $result)); 102 $this->assertSame(1, preg_match('/customdata/', $result)); 103 106 104 } 107 105 … … 134 132 135 133 } 136 // Running the test.137 $suite = new PHPUnit_TestSuite('PayPalTest');138 $result = PHPUnit::run($suite);139 echo $result->toString();140 ?> -
trunk/tests/PrefsTest.php
r396 r468 33 33 * Created with PHPUnit_Skeleton on 2005-08-09 34 34 */ 35 require_once 'PHPUnit.php'; 36 class PrefsTest extends PHPUnit_ TestCase {35 36 class PrefsTest extends PHPUnit_Framework_TestCase { 37 37 38 38 var $Prefs; … … 40 40 function PrefsTest($name) 41 41 { 42 $this->PHPUnit_ TestCase($name);42 $this->PHPUnit_Framework_TestCase($name); 43 43 } 44 44 … … 112 112 113 113 } 114 // Running the test.115 $suite = new PHPUnit_TestSuite('PrefsTest');116 $result = PHPUnit::run($suite);117 echo $result->toString();118 ?> -
trunk/tests/ScriptTimerTest.php
r396 r468 33 33 * Created with PHPUnit_Skeleton on 2005-08-09 34 34 */ 35 require_once 'PHPUnit.php'; 36 class ScriptTimerTest extends PHPUnit_ TestCase {35 36 class ScriptTimerTest extends PHPUnit_Framework_TestCase { 37 37 38 38 var $ScriptTimer; … … 40 40 function ScriptTimerTest($name) 41 41 { 42 $this->PHPUnit_ TestCase($name);42 $this->PHPUnit_Framework_TestCase($name); 43 43 } 44 44 … … 77 77 78 78 } 79 // Running the test.80 $suite = new PHPUnit_TestSuite('ScriptTimerTest');81 $result = PHPUnit::run($suite);82 echo $result->toString();83 ?> -
trunk/tests/SortOrderTest.php
r396 r468 33 33 * Created with PHPUnit_Skeleton on 2005-08-09 34 34 */ 35 require_once 'PHPUnit.php'; 36 class SortOrderTest extends PHPUnit_ TestCase {35 36 class SortOrderTest extends PHPUnit_Framework_TestCase { 37 37 38 38 var $SortOrder; … … 40 40 function SortOrderTest($name) 41 41 { 42 $this->PHPUnit_ TestCase($name);42 $this->PHPUnit_Framework_TestCase($name); 43 43 } 44 44 … … 91 91 92 92 } 93 // Running the test.94 $suite = new PHPUnit_TestSuite('SortOrderTest');95 $result = PHPUnit::run($suite);96 echo $result->toString();97 ?> -
trunk/tests/SpellCheckTest.php
r396 r468 33 33 * Created with PHPUnit_Skeleton on 2005-08-09 34 34 */ 35 require_once 'PHPUnit.php'; 36 class SpellCheckTest extends PHPUnit_ TestCase {35 36 class SpellCheckTest extends PHPUnit_Framework_TestCase { 37 37 38 38 var $SpellCheck; … … 40 40 function SpellCheckTest($name) 41 41 { 42 $this->PHPUnit_ TestCase($name);42 $this->PHPUnit_Framework_TestCase($name); 43 43 } 44 44 … … 154 154 155 155 } 156 // Running the test.157 $suite = new PHPUnit_TestSuite('SpellCheckTest');158 $result = PHPUnit::run($suite);159 echo $result->toString();160 ?> -
trunk/tests/TemplateGlueTest.php
r396 r468 33 33 * Created with PHPUnit_Skeleton on 2005-08-09 34 34 */ 35 require_once 'PHPUnit.php'; 36 class TemplateGlueTest extends PHPUnit_ TestCase {35 36 class TemplateGlueTest extends PHPUnit_Framework_TestCase { 37 37 38 38 var $TemplateGlue; … … 40 40 function TemplateGlueTest($name) 41 41 { 42 $this->PHPUnit_ TestCase($name);42 $this->PHPUnit_Framework_TestCase($name); 43 43 } 44 44 … … 56 56 57 57 } 58 // Running the test.59 $suite = new PHPUnit_TestSuite('TemplateGlueTest');60 $result = PHPUnit::run($suite);61 echo $result->toString();62 ?> -
trunk/tests/UploadTest.php
r396 r468 7 7 * For details visit the project site: <http://trac.strangecode.com/codebase/> 8 8 * Copyright 2001-2012 Strangecode, LLC 9 * 9 * 10 10 * This file is part of The Strangecode Codebase. 11 11 * … … 14 14 * Free Software Foundation, either version 3 of the License, or (at your option) 15 15 * any later version. 16 * 16 * 17 17 * The Strangecode Codebase is distributed in the hope that it will be useful, but 18 18 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 19 19 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more 20 20 * details. 21 * 21 * 22 22 * You should have received a copy of the GNU General Public License along with 23 23 * The Strangecode Codebase. If not, see <http://www.gnu.org/licenses/>. … … 33 33 * Created with PHPUnit_Skeleton on 2005-08-09 34 34 */ 35 require_once 'PHPUnit.php'; 36 class UploadTest extends PHPUnit_ TestCase {35 36 class UploadTest extends PHPUnit_Framework_TestCase { 37 37 38 38 var $Upload; … … 40 40 function UploadTest($name) 41 41 { 42 $this->PHPUnit_ TestCase($name);42 $this->PHPUnit_Framework_TestCase($name); 43 43 } 44 44 … … 120 120 function test_getfilenameextension() 121 121 { 122 $result = $this->Upload ->getfilenameextension(PARAM);122 $result = $this->Upload::getfilenameextension(PARAM); 123 123 $expected = EXPECTED_VAL; 124 124 $this->assertEquals($expected, $result); … … 126 126 127 127 } 128 // Running the test.129 $suite = new PHPUnit_TestSuite('UploadTest');130 $result = PHPUnit::run($suite);131 echo $result->toString();132 ?> -
trunk/tests/UtilitiesTest.php
r396 r468 33 33 * Created with PHPUnit_Skeleton on 2005-08-09 34 34 */ 35 require_once 'PHPUnit.php'; 36 class UtilitiesTest extends PHPUnit_ TestCase {35 36 class UtilitiesTest extends PHPUnit_Framework_TestCase { 37 37 38 38 var $Utilities; … … 40 40 function UtilitiesTest($name) 41 41 { 42 $this->PHPUnit_ TestCase($name);42 $this->PHPUnit_Framework_TestCase($name); 43 43 } 44 44 … … 56 56 57 57 } 58 // Running the test.59 $suite = new PHPUnit_TestSuite('UtilitiesTest');60 $result = PHPUnit::run($suite);61 echo $result->toString();62 ?> -
trunk/tests/VersionTest.php
r396 r468 30 30 * Created with PHPUnit_Skeleton on 2005-08-09 31 31 */ 32 require_once 'PHPUnit.php'; 33 class VersionTest extends PHPUnit_ TestCase {32 33 class VersionTest extends PHPUnit_Framework_TestCase { 34 34 35 35 var $Version; 36 36 var $Auth_SQL; 37 38 function VersionTest($name)39 {40 $this->PHPUnit_TestCase($name);41 }42 37 43 38 function setUp() … … 47 42 48 43 require_once '../lib/Auth_SQL.inc.php'; 49 $this->Auth_SQL = &new Auth_SQL('testauth');44 $this->Auth_SQL = new Auth_SQL('testauth'); 50 45 $this->Auth_SQL->setParam(array( 51 46 'db_table' => 'test_user_tbl', … … 116 111 { 117 112 $result = $this->Version->create('test_user_tbl', 'user_id', '1', 'Test User', 'First version of user'); 118 $this->assert True($result);113 $this->assertSame(1, $result); 119 114 } 120 115 … … 190 185 191 186 } 192 // Running the test.193 $suite = new PHPUnit_TestSuite('VersionTest');194 $result = PHPUnit::run($suite);195 echo $result->toString();196 ?> -
trunk/tests/_config.inc.php
r396 r468 4 4 * For details visit the project site: <http://trac.strangecode.com/codebase/> 5 5 * Copyright 2001-2012 Strangecode, LLC 6 * 6 * 7 7 * This file is part of The Strangecode Codebase. 8 8 * … … 11 11 * Free Software Foundation, either version 3 of the License, or (at your option) 12 12 * any later version. 13 * 13 * 14 14 * The Strangecode Codebase is distributed in the hope that it will be useful, but 15 15 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 16 16 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more 17 17 * details. 18 * 18 * 19 19 * You should have received a copy of the GNU General Public License along with 20 20 * The Strangecode Codebase. If not, see <http://www.gnu.org/licenses/>. … … 28 28 */ 29 29 require_once '../lib/App.inc.php'; 30 30 31 $app =& App::getInstance('testapp'); 31 32 … … 44 45 'db_die_on_failure' => true, 45 46 'db_server' => 'localhost', 46 'db_name' => 'test',47 'db_user' => 'root',47 'db_name' => getenv('DB_NAME'), 48 'db_user' => getenv('DB_USER'), 48 49 'db_pass' => getenv('DB_PASS'), 49 50 'display_errors' => true, … … 59 60 60 61 $app->start(); 61 ?> -
trunk/tests/_skel.php
r412 r468 78 78 // } 79 79 80 ?> -
trunk/tests/run_tests.sh
r399 r468 1 #!/bin/sh 1 #!/bin/bash 2 3 # This script sets-up the test environment and runs all tests. 4 # You'll want to define your local mysql credentials for a test 5 # database as environment variables, e.g., in ~/.bash_profile: 6 # export DB_NAME="test" 7 # export DB_USER="test" 8 # export DB_PASS="..." 2 9 3 10 # Be in the directory with all the tests. 4 11 cd `dirname $0`; 5 12 13 # Get required ENV variables. 14 if [[ -z "$DB_USER$DB_PASS$DB_NAME" ]]; then 15 echo "MySQL test DB credential environment variables are missing.\nSet these in ~/.bash_profile to avoid seeing these prompts each time."; 16 fi 17 for E in DB_USER DB_PASS DB_NAME; do 18 while [[ -z ${!E} ]]; do 19 read -p "$E: " $E; 20 done 21 export $E; 22 done 23 6 24 # Create database. 7 25 mysql -e 'CREATE DATABASE IF NOT EXISTS `test`'; 8 26 9 # Run tests sequentially. 10 for foo in *Test.php; 11 do 12 php $foo; 13 done; 27 # Go! 28 echo "Running the tests!"; 29 echo "You'll want to 'tail -f /tmp/codebase_test_log' and watch for errors."; 30 31 # Config options go in phpunit.xml 32 # phpunit --tap | grep -v '^ok ' 33 phpunit --stderr
Note: See TracChangeset
for help on using the changeset viewer.