Changeset 6537
- Timestamp:
- 08/08/08 00:01:01 (5 months ago)
- Location:
- trunk/library
- Files:
-
- 5 modified
-
auth.php (modified) (2 diffs)
-
components/Textcube.Control.Openid.php (modified) (1 diff)
-
components/Textcube.Model.Session.php (modified) (13 diffs)
-
initialize.php (modified) (1 diff)
-
view/ownerView.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/library/auth.php
r6533 r6537 21 21 22 22 if( in_array( "group.writers", Acl::getCurrentPrivilege() ) ) { 23 Session::authorize Session($blogid, $userid);23 Session::authorize($blogid, $userid); 24 24 } 25 25 return true; … … 116 116 117 117 function requirePrivilege($AC) { 118 requireComponent('Textcube.Control.Auth');119 118 if(Acl::check($AC)) return true; 120 119 else header('HTTP/1.1 404 Not found'); -
trunk/library/components/Textcube.Control.Openid.php
r6476 r6537 457 457 458 458 if( !empty($userid) && in_array( "group.writers", Acl::getCurrentPrivilege() ) ) { 459 authorizeSession($blogid, $userid);460 } else { 461 authorizeSession($blogid, SESSION_OPENID_USERID );459 Session::authorize($blogid, $userid); 460 } else { 461 Session::authorize($blogid, SESSION_OPENID_USERID ); 462 462 } 463 463 } -
trunk/library/components/Textcube.Model.Session.php
r6533 r6537 14 14 } 15 15 16 public static function open Session($savePath, $sessionName) {16 public static function open($savePath, $sessionName) { 17 17 return true; 18 18 } 19 19 20 public static function close Session() {20 public static function close() { 21 21 return true; 22 22 } 23 23 24 public static function get SessionName() {24 public static function getName() { 25 25 global $service; 26 26 if( self::$sessionName == null ) { … … 35 35 } 36 36 37 public static function read Session($id) {37 public static function read($id) { 38 38 global $database, $service; 39 if ($result = self:: sessionQuery("SELECT data FROM {$database['prefix']}Sessions39 if ($result = self::query("SELECT data FROM {$database['prefix']}Sessions 40 40 WHERE id = '$id' AND address = '{$_SERVER['REMOTE_ADDR']}' AND updated >= (UNIX_TIMESTAMP() - {$service['timeout']})")) { 41 41 return $result; … … 44 44 } 45 45 46 public static function write Session($id, $data) {46 public static function write($id, $data) { 47 47 global $database; 48 48 if (strlen($id) < 32) … … 66 66 } 67 67 68 public static function destroy Session($id, $setCookie = false) {68 public static function destroy($id, $setCookie = false) { 69 69 global $database; 70 70 @POD::query("DELETE FROM {$database['prefix']}Sessions 71 71 WHERE id = '$id' AND address = '{$_SERVER['REMOTE_ADDR']}'"); 72 self::g cSession();73 } 74 75 public static function g cSession($maxLifeTime = false) {72 self::getCurrent(); 73 } 74 75 public static function getCurrent($maxLifeTime = false) { 76 76 global $database, $service; 77 77 @POD::query("DELETE FROM {$database['prefix']}Sessions 78 78 WHERE updated < (UNIX_TIMESTAMP() - {$service['timeout']})"); 79 $result = @self:: sessionQueryAll("SELECT DISTINCT v.id, v.address79 $result = @self::queryAll("SELECT DISTINCT v.id, v.address 80 80 FROM {$database['prefix']}SessionVisits v 81 81 LEFT JOIN {$database['prefix']}Sessions s ON v.id = s.id AND v.address = s.address … … 91 91 } 92 92 93 p ublicstatic function getAnonymousSession() {94 global $database; 95 $result = self:: sessionQuery("SELECT id FROM {$database['prefix']}Sessions WHERE address = '{$_SERVER['REMOTE_ADDR']}' AND userid IS NULL AND preexistence IS NULL");93 private static function getAnonymousSession() { 94 global $database; 95 $result = self::query("SELECT id FROM {$database['prefix']}Sessions WHERE address = '{$_SERVER['REMOTE_ADDR']}' AND userid IS NULL AND preexistence IS NULL"); 96 96 if ($result) 97 97 return $result; … … 99 99 } 100 100 101 p ublicstatic function newAnonymousSession() {101 private static function newAnonymousSession() { 102 102 global $database; 103 103 for ($i = 0; $i < 100; $i++) { … … 127 127 } 128 128 129 public static function is SessionAuthorized($id) {129 public static function isAuthorized($id) { 130 130 /* OpenID and Admin sessions are treated as authorized ones*/ 131 131 global $database; … … 151 151 } 152 152 153 public static function set Session() {153 public static function set() { 154 154 self::$sessionMicrotime = Timer::getMicroTime(); 155 155 if( !empty($_GET['TSSESSION']) ) { … … 161 161 $id = ''; 162 162 } 163 if ((strlen($id) < 32) || !self::is SessionAuthorized($id)) {163 if ((strlen($id) < 32) || !self::isAuthorized($id)) { 164 164 self::setSessionAnonymous($id); 165 165 } 166 166 } 167 167 168 public static function authorize Session($blogid, $userid) {168 public static function authorize($blogid, $userid) { 169 169 global $database, $service; 170 170 $session_cookie_path = "/"; … … 185 185 } 186 186 } 187 if (self::is SessionAuthorized(session_id()))187 if (self::isAuthorized(session_id())) 188 188 return true; 189 189 for ($i = 0; $i < 100; $i++) { … … 195 195 @session_id($id); 196 196 //$service['domain'] = $service['domain'].':8888'; 197 setcookie( self::get SessionName(), $id, 0, $session_cookie_path, $service['session_cookie_domain']);197 setcookie( self::getName(), $id, 0, $session_cookie_path, $service['session_cookie_domain']); 198 198 return true; 199 199 } … … 202 202 } 203 203 204 public static function sessionQuery($sql) {204 public static function query($sql) { 205 205 global $database, $sessionDBRepair; 206 206 $result = POD::queryCell($sql); … … 215 215 } 216 216 217 public static function sessionQueryAll($sql) {217 public static function queryAll($sql) { 218 218 global $database, $sessionDBRepair; 219 219 $result = POD::queryAll($sql); -
trunk/library/initialize.php
r6533 r6537 25 25 /* Session initializing */ 26 26 if (!defined('NO_SESSION')) { 27 session_name(Session::get SessionName());28 Session::set Session();29 session_set_save_handler('Session::open Session', 'Session::closeSession', 'Session::readSession', 'Session::writeSession', 'Session::destroySession', 'Session::gcSession');27 session_name(Session::getName()); 28 Session::set(); 29 session_set_save_handler('Session::open', 'Session::close', 'Session::read', 'Session::write', 'Session::destroy', 'Session::getCurrent'); 30 30 session_cache_expire(1); 31 31 session_set_cookie_params(0, '/', $service['domain']); -
trunk/library/view/ownerView.php
r6476 r6537 797 797 + '&labelingPath=<?php echo $param['labelingPath'];?>' 798 798 + entryManager.entryId 799 + '&maxSize=<?php echo $maxSize;?>&sessionName=TSSESSION&sessionValue=<?php echo $_COOKIE[ getSessionName()];?>" />'799 + '&maxSize=<?php echo $maxSize;?>&sessionName=TSSESSION&sessionValue=<?php echo $_COOKIE[Session::getName()];?>" />' 800 800 + '<embed id="uploader2" src="<?php echo $service['path'];?>/resources/script/uploader/uploader.swf" flashvars="uploadPath=<?php echo $param['uploadPath'];?>' 801 801 + entryManager.entryId 802 802 + '&labelingPath=<?php echo $param['labelingPath'];?>' 803 803 + entryManager.entryId 804 + '&maxSize=<?php echo $maxSize;?>&sessionName=TSSESSION&sessionValue=<?php echo $_COOKIE[ getSessionName()];?>" width="1" height="1" align="middle" wmode="transparent" quality="high" bgcolor="#ffffff" scale="noScale" allowscriptaccess="always" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" /><\/embed><\/object>';804 + '&maxSize=<?php echo $maxSize;?>&sessionName=TSSESSION&sessionValue=<?php echo $_COOKIE[Session::getName()];?>" width="1" height="1" align="middle" wmode="transparent" quality="high" bgcolor="#ffffff" scale="noScale" allowscriptaccess="always" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" /><\/embed><\/object>'; 805 805 if (hasRightVersion && (isMoz || isIE)) { 806 806 if(<?php echo (isset($service['flashuploader']) && $service['flashuploader'] === false) ? 'false' : 'true';?>) { writeCode(uploaderStr,'uploaderNest'); }
