Changeset 174
- Timestamp:
- Jun 18, 2006 8:50:35 AM (18 years ago)
- Location:
- trunk
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/bin/acl.cli.php
r173 r174 14 14 ********************************************************************/ 15 15 16 $this_script = basename($_SERVER['argv'][0]); 17 16 18 // Give them a fighting chance. Show the help message. ;P 17 19 if ($_SERVER['argc'] <= 1) { … … 23 25 $db_quth_file = COMMON_BASE . '/global/db_auth.inc.php'; 24 26 if (!file_exists($db_quth_file)) { 25 die(sprintf("%s error: the current directory must be common site directory (i.e. the parent directory of the document root) AND the global/db_auth.inc.php file must exist.\n", $ _SERVER['argv'][0]));27 die(sprintf("%s error: the current directory must be common site directory (i.e. the parent directory of the document root) AND the global/db_auth.inc.php file must exist.\n", $this_script)); 26 28 } 27 29 28 30 if (fileowner($db_quth_file) != getmyuid()) { 29 die(sprintf("%s error: you must execute this script as the owner of the web files.\n", $ _SERVER['argv'][0]));31 die(sprintf("%s error: you must execute this script as the owner of the web files.\n", $this_script)); 30 32 } 31 33 … … 55 57 'display_errors' => true, 56 58 'error_reporting' => E_ALL, 57 'log_file_priority' => LOG_ DEBUG,58 'log_screen_priority' => LOG_ NOTICE,59 'log_file_priority' => LOG_INFO, 60 'log_screen_priority' => LOG_ERR, 59 61 'log_directory' => COMMON_BASE . '/log', 60 62 'log_filename' => 'site_log', … … 82 84 switch ($op) { 83 85 case 'list' : 84 $type = isset($_SERVER['argv'][2]) ? $_SERVER['argv'][2] : null; 85 if (isset($type)) { 86 listACL('root', $type); 87 } else { 88 89 echo "\n_______________________Access Request Objects________________________\n\n"; 90 listACL('root', 'aro'); 91 echo "\n_______________________Access Control Objects________________________\n\n"; 92 listACL('root', 'aco'); 93 echo "\n______________________Access eXtension Objects_______________________\n\n"; 94 listACL('root', 'axo'); 95 } 96 break; 86 $type = isset($_SERVER['argv'][2]) ? $_SERVER['argv'][2] : null; 87 switch ($type) { 88 case 'aro' : 89 case 'aco' : 90 case 'axo' : 91 listObjects('root', $type); 92 break; 93 case 'all' : 94 listObjects('root', 'aro'); 95 listObjects('root', 'aco'); 96 listObjects('root', 'axo'); 97 break; 98 case 'perms' : 99 default : 100 listPerms(); 101 break; 102 } 103 break; 97 104 98 105 case 'addaro' : … … 107 114 break; 108 115 116 case 'mvaro' : 117 case 'mvaco' : 118 case 'mvaxo' : 119 $object = isset($_SERVER['argv'][2]) ? $_SERVER['argv'][2] : null; 120 $parent = isset($_SERVER['argv'][3]) ? $_SERVER['argv'][3] : null; 121 if (!isset($object)) { 122 echo "'mv*' commands require at least one argument. Try 'help' if you are lost.\n"; 123 } 124 echo $acl->move($object, $parent, str_replace('mv', '', $op)) ? "Ok\n" : "Error!\n"; 125 break; 126 109 127 case 'rmaro' : 110 128 case 'rmaco' : … … 167 185 function help() 168 186 { 187 global $this_script; 188 169 189 ?> 170 190 Access Control List command line tool. … … 176 196 177 197 Three types of objects are managed by this interface: ARO - Access 178 Request Objects, ACO - Access Control Objects, and AXO - Access eXtention198 Request Objects, ACO - Access Control Objects, and AXO - Access Xtra 179 199 Objects. These are most often used as a USER -> ACTION -> OBJECT model, 180 200 but can just as easily be SPICES -> CUISINES -> DISHES A privilege is … … 190 210 "anything" since it is at the top of all branches. 191 211 192 Usage: <?php echo $_SERVER['argv'][0]; ?> <command> [args] 193 194 195 <?php echo $_SERVER['argv'][0]; ?> initdb 196 <?php echo $_SERVER['argv'][0]; ?> list [aro | aco | axo] 197 <?php echo $_SERVER['argv'][0]; ?> addaro <aro_object> [parent] 198 <?php echo $_SERVER['argv'][0]; ?> addaco <aco_object> [parent] 199 <?php echo $_SERVER['argv'][0]; ?> addaxo <axo_object> [parent] 200 <?php echo $_SERVER['argv'][0]; ?> rmaro <aro_object> 201 <?php echo $_SERVER['argv'][0]; ?> rmaco <aco_object> 202 <?php echo $_SERVER['argv'][0]; ?> rmaxo <axo_object> 203 <?php echo $_SERVER['argv'][0]; ?> grant <aro_object> [aco_object] [axo_object] 204 <?php echo $_SERVER['argv'][0]; ?> revoke <aro_object> [aco_object] [axo_object] 205 206 For the add*, grant, and revoke commands, if any of the optional 212 Usage: <?php echo $this_script; ?> <command> [args] 213 214 Where <command> is any of the following (with arguments): 215 216 initdb 217 list [aro | aco | axo | all | perms] 218 addaro <aro_object> [parent] 219 addaco <aco_object> [parent] 220 addaxo <axo_object> [parent] 221 mvaro <aro_object> [parent] 222 mvaco <aco_object> [parent] 223 mvaxo <axo_object> [parent] 224 rmaro <aro_object> 225 rmaco <aco_object> 226 rmaxo <axo_object> 227 grant <aro_object> [aco_object] [axo_object] 228 revoke <aro_object> [aco_object] [axo_object] 229 230 For the add*, mv*, grant, and revoke commands if any of the optional 207 231 args are not provided, 'root' is assumed. 208 232 … … 213 237 214 238 215 function listACL($root, $type) 239 /* 240 * Print the tree structure of a specified table (aro_tbl, aco_tbl, or axo_tbl). 241 * 242 * @access public 243 * @param string $root Root node from which to begin calculating. 244 * @param string $type Table to call, one of: aro, aco, or axo. 245 * @return bool Returns false on error. 246 * @author Quinn Comendant <quinn@strangecode.com> 247 * @version 1.0 248 * @since 17 Jun 2006 23:41:22 249 */ 250 function listObjects($root, $type) 216 251 { 217 252 $app =& App::getInstance(); 218 253 $db =& DB::getInstance(); 219 254 global $this_script; 255 256 echo "\n"; 257 220 258 switch ($type) { 221 259 case 'aro' : 222 260 $tbl = 'aro_tbl'; 261 printf("%-35s %-5s %-5s %s\n", 'Request objects', 'lft', 'rgt', 'Added'); 223 262 break; 224 263 case 'aco' : 225 264 $tbl = 'aco_tbl'; 265 printf("%-35s %-5s %-5s %s\n", 'Control objects', 'lft', 'rgt', 'Added'); 226 266 break; 227 267 case 'axo' : 228 268 $tbl = 'axo_tbl'; 269 printf("%-35s %-5s %-5s %s\n", 'Xtra objects', 'lft', 'rgt', 'Added'); 229 270 break; 230 271 default : … … 233 274 break; 234 275 } 235 276 277 echo "-----------------------------------------------------------\n"; 278 236 279 // Retrieve the left and right value of the $root node. 237 280 $qid = $db->query("SELECT lft, rgt FROM $tbl WHERE name = '" . $db->escapeString($root) . "'"); … … 249 292 250 293 // Display indented node title. 251 printf("%- 20s %-5s %-5s %s\n", str_repeat(' ', sizeof($depth)) . $name, $lft, $rgt, $added_datetime);294 printf("%-35s %-5s %-5s %s\n", str_repeat(' ', sizeof($depth)) . $name, $lft, $rgt, date($app->getParam('date_format'), strtotime($added_datetime))); 252 295 253 296 // Add this node to the stack. … … 256 299 } 257 300 301 /* 302 * List all entries in the acl_tbl. 303 * 304 * @access public 305 * @author Quinn Comendant <quinn@strangecode.com> 306 * @version 1.0 307 * @since 17 Jun 2006 15:11:53 308 */ 309 function listPerms() 310 { 311 $app =& App::getInstance(); 312 $db =& DB::getInstance(); 313 global $this_script; 314 315 // Retreive access value from db. 316 $qid = $db->query(" 317 SELECT aro_tbl.name AS aro, aco_tbl.name AS aco, axo_tbl.name AS axo, acl_tbl.access, acl_tbl.added_datetime 318 FROM acl_tbl 319 LEFT JOIN aro_tbl ON (acl_tbl.aro_id = aro_tbl.aro_id) 320 LEFT JOIN aco_tbl ON (acl_tbl.aco_id = aco_tbl.aco_id) 321 LEFT JOIN axo_tbl ON (acl_tbl.axo_id = axo_tbl.axo_id) 322 ORDER BY aro_tbl.aro_id ASC, aco_tbl.aco_id ASC, axo_tbl.axo_id ASC 323 "); 324 echo "\n"; 325 printf("%-25s %-25s %-25s %-6s %-10s\n", 'Request objects', 'Control objects', 'Xtra objects', '', 'Added'); 326 echo "------------------------------------------------------------------------------------------------\n"; 327 while ($p = mysql_fetch_assoc($qid)) { 328 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']))); 329 } 330 } 331 258 332 259 333 ?> -
trunk/lib/ACL.inc.php
r173 r174 6 6 * Uses Modified Preorder Tree Traversal to maintain a tree-structure. 7 7 * See: http://www.sitepoint.com/print/hierarchical-data-database 8 * Includes a command-line tool for managing rights .8 * Includes a command-line tool for managing rights (codebase/bin/acl.cli.php). 9 9 * 10 10 * Code by Strangecode :: www.strangecode.com :: This document contains copyrighted information. … … 29 29 30 30 /** 31 * Prefs constructor.31 * Constructor. 32 32 */ 33 33 function ACL() … … 102 102 103 103 /** 104 * Setup the database table for this class.104 * Setup the database tables for this class. 105 105 * 106 106 * @access public … … 192 192 193 193 /* 194 * 194 * Add a node to one of the aro/aco/axo tables. 195 195 * 196 196 * @access public 197 * @param 198 * @return 197 * @param string $name A unique identifier for the new node. 198 * @param string $parent The name of the parent under-which to attach the new node. 199 * @param string $type The tree to add to, one of: aro, aco, axo. 200 * @return bool | int False on error, or the last_insert_id primary key of the new node. 199 201 * @author Quinn Comendant <quinn@strangecode.com> 200 202 * @version 1.0 … … 244 246 // Select the rgt of $parent. 245 247 $qid = $db->query("SELECT rgt FROM $tbl WHERE name = '" . $db->escapeString($parent) . "'"); 246 if (!list($ rgt) = mysql_fetch_row($qid)) {248 if (!list($parent_rgt) = mysql_fetch_row($qid)) { 247 249 $app->logMsg(sprintf('Cannot add %s node to nonexistant parent: %s', $type, $parent), LOG_WARNING, __FILE__, __LINE__); 248 250 return false; 249 251 } 252 250 253 // Update transversal numbers for all nodes to the rgt of $parent. 251 $db->query("UPDATE $tbl SET lft = lft + 2 WHERE lft >= $ rgt");252 $db->query("UPDATE $tbl SET rgt = rgt + 2 WHERE rgt >= $ rgt");254 $db->query("UPDATE $tbl SET lft = lft + 2 WHERE lft >= $parent_rgt"); 255 $db->query("UPDATE $tbl SET rgt = rgt + 2 WHERE rgt >= $parent_rgt"); 253 256 254 257 // Insert new node just below parent. Lft is parent's old rgt. 255 258 $db->query(" 256 259 INSERT INTO $tbl (name, lft, rgt, added_datetime) 257 VALUES ('" . $db->escapeString($name) . "', $ rgt, $rgt + 1, NOW())260 VALUES ('" . $db->escapeString($name) . "', $parent_rgt, $parent_rgt + 1, NOW()) 258 261 "); 259 262 … … 263 266 264 267 // Alias functions for the different object types. 265 function add ARO($name, $parent=null)268 function addRequestObject($name, $parent=null) 266 269 { 267 270 return $this->add($name, $parent, 'aro'); 268 271 } 269 function add ACO($name, $parent=null)272 function addControlObject($name, $parent=null) 270 273 { 271 274 return $this->add($name, $parent, 'aco'); 272 275 } 273 function add AXO($name, $parent=null)276 function addXtraObject($name, $parent=null) 274 277 { 275 278 return $this->add($name, $parent, 'axo'); … … 277 280 278 281 /* 279 * 282 * Remove a node from one of the aro/aco/axo tables. 280 283 * 281 284 * @access public 282 * @param 283 * @return 285 * @param string $name The identifier for the node to remove. 286 * @param string $type The tree to modify, one of: aro, aco, axo. 287 * @return bool | int False on error, or true on success. 284 288 * @author Quinn Comendant <quinn@strangecode.com> 285 289 * @version 1.0 … … 296 300 case 'aro' : 297 301 $tbl = 'aro_tbl'; 302 $primary_key = 'aro_id'; 298 303 break; 299 304 case 'aco' : 300 305 $tbl = 'aco_tbl'; 306 $primary_key = 'aco_id'; 301 307 break; 302 308 case 'axo' : 303 309 $tbl = 'axo_tbl'; 310 $primary_key = 'axo_id'; 304 311 break; 305 312 default : … … 315 322 } 316 323 317 // Select the lft of $name324 // Select the lft and rgt of $name to use for selecting children and reordering transversals. 318 325 $qid = $db->query("SELECT lft, rgt FROM $tbl WHERE name = '" . $db->escapeString($name) . "'"); 319 326 if (!list($lft, $rgt) = mysql_fetch_row($qid)) { … … 322 329 } 323 330 324 // Remove node and all children of node. 325 $db->query("DELETE FROM $tbl WHERE lft BETWEEN $lft AND $rgt"); 331 // Remove node and all children of node, as well as acl_tbl links. 332 $db->query(" 333 DELETE $tbl, acl_tbl 334 FROM $tbl 335 LEFT JOIN acl_tbl ON ($tbl.$primary_key = acl_tbl.$primary_key) 336 WHERE $tbl.lft BETWEEN $lft AND $rgt 337 "); 326 338 $num_deleted_nodes = mysql_affected_rows($db->getDBH()); 327 339 … … 335 347 336 348 // Alias functions for the different object types. 337 function removeUser($name, $parent=null) 338 { 339 return $this->remove($name, $parent, 'aro'); 340 } 341 function removeAction($name, $parent=null) 342 { 343 return $this->remove($name, $parent, 'aco'); 344 } 345 function removeObject($name, $parent=null) 346 { 347 return $this->remove($name, $parent, 'axo'); 349 function removeRequestObject($name) 350 { 351 return $this->remove($name, 'aro'); 352 } 353 function removeControlObject($name) 354 { 355 return $this->remove($name, 'aco'); 356 } 357 function removeXtraObject($name) 358 { 359 return $this->remove($name, 'axo'); 360 } 361 362 /* 363 * Move a node to a new parent in one of the aro/aco/axo tables. 364 * 365 * @access public 366 * @param string $name The identifier for the node to remove. 367 * @param string $new_parent The name of the parent under-which to attach the new node. 368 * @param string $type The tree to modify, one of: aro, aco, axo. 369 * @return bool | int False on error, or the last_insert_id primary key of the new node. 370 * @author Quinn Comendant <quinn@strangecode.com> 371 * @version 1.0 372 * @since 14 Jun 2006 22:39:29 373 */ 374 function move($name, $new_parent, $type) 375 { 376 $app =& App::getInstance(); 377 $db =& DB::getInstance(); 378 379 $this->initDB(); 380 381 switch ($type) { 382 case 'aro' : 383 $tbl = 'aro_tbl'; 384 $primary_key = 'aro_id'; 385 break; 386 case 'aco' : 387 $tbl = 'aco_tbl'; 388 $primary_key = 'aco_id'; 389 break; 390 case 'axo' : 391 $tbl = 'axo_tbl'; 392 $primary_key = 'axo_id'; 393 break; 394 default : 395 $app->logMsg(sprintf('Invalid access object type: %s', $type), LOG_ERR, __FILE__, __LINE__); 396 return false; 397 break; 398 } 399 400 // If $parent is null, use root object. 401 if (is_null($parent)) { 402 $parent = 'root'; 403 } 404 405 // Ensure node and parent name aren't empty. 406 if ('' == trim($name) || '' == trim($parent)) { 407 $app->logMsg(sprintf('Cannot add node, parent (%s) or name (%s) missing.', $name, $parent), LOG_WARNING, __FILE__, __LINE__); 408 return false; 409 } 410 411 // Select the lft and rgt of $name to use for selecting children and reordering transversals. 412 $qid = $db->query("SELECT lft, rgt FROM $tbl WHERE name = '" . $db->escapeString($name) . "'"); 413 if (!list($lft, $rgt) = mysql_fetch_row($qid)) { 414 $app->logMsg(sprintf('Cannot delete nonexistant %s name: %s', $type, $name), LOG_NOTICE, __FILE__, __LINE__); 415 return false; 416 } 417 418 // Total number of transversal values (that is, the count of self plus all children times two). 419 $total_transversal_value = ($rgt - $lft + 1); 420 421 // Select the rgt of the new parent. 422 $qid = $db->query("SELECT rgt FROM $tbl WHERE name = '" . $db->escapeString($new_parent) . "'"); 423 if (!list($new_parent_rgt) = mysql_fetch_row($qid)) { 424 $app->logMsg(sprintf('Cannot move %s node to nonexistant parent: %s', $type, $new_parent), LOG_WARNING, __FILE__, __LINE__); 425 return false; 426 } 427 428 // Ensure the new parent is not a child of the node being moved. 429 if ($new_parent_rgt <= $rgt && $new_parent_rgt >= $lft) { 430 $app->logMsg(sprintf('Cannot move %s node %s to parent %s because it is a child of itself.', $type, $name, $new_parent), LOG_WARNING, __FILE__, __LINE__); 431 return false; 432 } 433 434 // Collect unique ids of all nodes being moved. The transversal numbers will become duplicated so these will be needed to identify these. 435 $qid = $db->query(" 436 SELECT $primary_key 437 FROM $tbl 438 WHERE lft BETWEEN $lft AND $rgt 439 AND rgt BETWEEN $lft AND $rgt 440 "); 441 $ids = array(); 442 while (list($id) = mysql_fetch_row($qid)) { 443 $ids[] = $id; 444 } 445 446 // Update transversal numbers for all nodes to the rgt of the node being moved, taking in to account the absence of it's children. 447 // This will temporarily "remove" the node from the tree, and its transversal values will be duplicated. 448 $db->query("UPDATE $tbl SET lft = lft - $total_transversal_value WHERE lft > $rgt"); 449 $db->query("UPDATE $tbl SET rgt = rgt - $total_transversal_value WHERE rgt > $rgt"); 450 // Apply transformation to new parent rgt also. 451 $new_parent_rgt = $new_parent_rgt > $rgt ? $new_parent_rgt - $total_transversal_value : $new_parent_rgt; 452 453 // Update transversal values of moved node and children. 454 $db->query(" 455 UPDATE $tbl SET 456 lft = lft - ($lft - $new_parent_rgt), 457 rgt = rgt - ($lft - $new_parent_rgt) 458 WHERE $primary_key IN ('" . join("','", $ids) . "') 459 "); 460 461 // Update transversal values of all nodes to the rgt of moved node. 462 $db->query("UPDATE $tbl SET lft = lft + $total_transversal_value WHERE lft >= $new_parent_rgt AND $primary_key NOT IN ('" . join("','", $ids) . "')"); 463 $db->query("UPDATE $tbl SET rgt = rgt + $total_transversal_value WHERE rgt >= $new_parent_rgt AND $primary_key NOT IN ('" . join("','", $ids) . "')"); 464 465 die; 466 $app->logMsg(sprintf('Moved %s node %s to new parent %s.', $type, $name, $new_parent), LOG_DEBUG, __FILE__, __LINE__); 467 return true; 468 } 469 470 // Alias functions for the different object types. 471 function moveRequestObject($name, $new_parent=null) 472 { 473 return $this->move($name, $new_parent, 'aro'); 474 } 475 function moveControlObject($name, $new_parent=null) 476 { 477 return $this->move($name, $new_parent, 'aco'); 478 } 479 function moveXtraObject($name, $new_parent=null) 480 { 481 return $this->move($name, $new_parent, 'axo'); 348 482 } 349 483 350 484 /* 351 * 485 * Add an entry to the acl_tbl to allow (or deny) a truple with the specified 486 * ARO -> ACO -> AXO entry. 352 487 * 353 488 * @access public 354 * @param 355 * @return 489 * @param string $aro Identifier of an existing ARO object. 490 * @param string $aco Identifier of an existing ACO object (or null to use root). 491 * @param string $axo Identifier of an existing AXO object (or null to use root). 492 * @return bool False on error, true on success. 356 493 * @author Quinn Comendant <quinn@strangecode.com> 357 494 * @version 1.0 … … 397 534 398 535 /* 399 * 536 * Add an entry to the acl_tbl to deny a truple with the specified 537 * ARO -> ACO -> AXO entry. This calls the ACL::grant function to create the entry 538 * but uses 'deny' as the fourth argument. 400 539 * 401 540 * @access public 402 * @param 403 * @return 541 * @param string $aro Identifier of an existing ARO object. 542 * @param string $aco Identifier of an existing ACO object (or null to use root). 543 * @param string $axo Identifier of an existing AXO object (or null to use root). 544 * @return bool False on error, true on success. 404 545 * @author Quinn Comendant <quinn@strangecode.com> 405 546 * @version 1.0 … … 412 553 413 554 /* 414 * 555 * Calculates the most specific cascading privilege found for a requested 556 * ARO -> ACO -> AXO entry. Returns FALSE if the entry is denied. By default, 557 * all entries are denied, unless some point in the hierarchy is set ao "allow." 415 558 * 416 559 * @access public 417 * @param 418 * @return 560 * @param string $aro Identifier of an existing ARO object. 561 * @param string $aco Identifier of an existing ACO object (or null to use root). 562 * @param string $axo Identifier of an existing AXO object (or null to use root). 563 * @return bool False if denied, true on allowed. 419 564 * @author Quinn Comendant <quinn@strangecode.com> 420 565 * @version 1.0 -
trunk/lib/App.inc.php
r172 r174 110 110 // LOG_INFO informational message 111 111 // LOG_DEBUG debug-level message 112 'log_file_priority' => false,112 'log_file_priority' => LOG_INFO, 113 113 'log_email_priority' => false, 114 114 'log_sms_priority' => false, -
trunk/lib/Auth_SQL.inc.php
r159 r174 711 711 * @return string a password 712 712 */ 713 function generatePassword($pattern='CvccvCdd') 714 { 713 function generatePassword($pattern='CvcdCvc') 714 { 715 $app =& App::getInstance(); 716 if (preg_match('/[^xCVcvd]/', $pattern)) { 717 $app->logMsg(sprintf('Invalid pattern: %s', $pattern), LOG_WARNING, __FILE__, __LINE__); 718 $pattern='CvcdCvc'; 719 } 715 720 $str = ''; 716 721 for ($i=0; $i<strlen($pattern); $i++) { -
trunk/lib/Cache.inc.php
r172 r174 117 117 118 118 /** 119 * Stores a new variable in the session cache. The $key is is md5'ed 120 * because if a key is numeric, the array_shift function 121 * will reset the key to the next largest int key. Weird behavior I can't 122 * understand. For example $cache["123"] will become $cache[0] 119 * Stores a new variable in the session cache. The $key should not be numberic 120 * because the array_shift function will reset the key to the next largest 121 * int key. Weird behavior I can't understand. For example $cache["123"] will become $cache[0] 123 122 * 124 123 * @param str $key An identifier for the cached object. … … 138 137 } 139 138 140 $keyhash = md5($key);141 139 $var = serialize($var); 142 140 $var_len = strlen($var); … … 153 151 154 152 // Remove any value already stored under this key. 155 unset($_SESSION['_cache'][$this->_ns][$key hash]);153 unset($_SESSION['_cache'][$this->_ns][$key]); 156 154 157 155 // Continue to prune the cache if its size is greater than stack_size_limit, but keep at least min_items. … … 161 159 162 160 // Save this value under the specified key. 163 $_SESSION['_cache'][$this->_ns][$key hash] =& $var;161 $_SESSION['_cache'][$this->_ns][$key] =& $var; 164 162 165 163 if ($var_len >= 1024000) { … … 188 186 } 189 187 190 $keyhash = md5($key); 191 if (isset($_SESSION['_cache'][$this->_ns][$keyhash])) { 188 if (isset($_SESSION['_cache'][$this->_ns][$key])) { 192 189 $app->logMsg(sprintf('Retreiving %s from cache.', $key), LOG_DEBUG, __FILE__, __LINE__); 193 190 // Move the accessed cached datum to the top of the stack. Maybe somebody knows a better way to do this? 194 $tmp =& $_SESSION['_cache'][$this->_ns][$key hash];195 unset($_SESSION['_cache'][$this->_ns][$key hash]);196 $_SESSION['_cache'][$this->_ns][$key hash] =& $tmp;191 $tmp =& $_SESSION['_cache'][$this->_ns][$key]; 192 unset($_SESSION['_cache'][$this->_ns][$key]); 193 $_SESSION['_cache'][$this->_ns][$key] =& $tmp; 197 194 // Return the unserialized datum. 198 return unserialize($_SESSION['_cache'][$this->_ns][$key hash]);195 return unserialize($_SESSION['_cache'][$this->_ns][$key]); 199 196 } else { 200 197 $app->logMsg(sprintf('Missing %s from cache.', $key), LOG_DEBUG, __FILE__, __LINE__); … … 215 212 } 216 213 217 $keyhash = md5($key); 218 return array_key_exists($keyhash, $_SESSION['_cache'][$this->_ns]); 214 return array_key_exists($key, $_SESSION['_cache'][$this->_ns]); 219 215 } 220 216 … … 227 223 function delete($key) 228 224 { 229 $keyhash = md5($key); 230 unset($_SESSION['_cache'][$this->_ns][$keyhash]); 225 unset($_SESSION['_cache'][$this->_ns][$key]); 231 226 } 232 227 -
trunk/lib/Prefs.inc.php
r159 r174 186 186 if (!isset($_SESSION['_prefs'][$this->_ns]['defaults'][$key]) || $_SESSION['_prefs'][$this->_ns]['defaults'][$key] != $val || isset($_SESSION['_prefs'][$this->_ns]['persistent'][$key])) { 187 187 $_SESSION['_prefs'][$this->_ns]['persistent'][$key] = $val; 188 $app->logMsg(sprintf('Setting preference %s to%s', $key, $val), LOG_DEBUG, __FILE__, __LINE__);188 $app->logMsg(sprintf('Setting preference %s => %s', $key, $val), LOG_DEBUG, __FILE__, __LINE__); 189 189 } else { 190 $app->logMsg(sprintf('not setting %s to%s', $key, $val), LOG_DEBUG, __FILE__, __LINE__);190 $app->logMsg(sprintf('not setting %s => %s', $key, $val), LOG_DEBUG, __FILE__, __LINE__); 191 191 } 192 192 }
Note: See TracChangeset
for help on using the changeset viewer.