[pLog-svn] r6492 - plugins/branches/lifetype-1.2/mobile/class/action
jondaley at devel.lifetype.net
jondaley at devel.lifetype.net
Fri May 30 06:33:30 EDT 2008
Author: jondaley
Date: 2008-05-30 06:33:30 -0400 (Fri, 30 May 2008)
New Revision: 6492
Modified:
plugins/branches/lifetype-1.2/mobile/class/action/mobileaction.class.php
Log:
mainminh provided the subdomain code (looks like the core code was copied, which doesn't contain validation for the request inputs. http://bugs.lifetype.net/view.php?id=1374
Modified: plugins/branches/lifetype-1.2/mobile/class/action/mobileaction.class.php
===================================================================
--- plugins/branches/lifetype-1.2/mobile/class/action/mobileaction.class.php 2008-05-30 10:26:51 UTC (rev 6491)
+++ plugins/branches/lifetype-1.2/mobile/class/action/mobileaction.class.php 2008-05-30 10:33:30 UTC (rev 6492)
@@ -36,13 +36,81 @@
function _getBlogInfo()
{
lt_include( PLOG_CLASS_PATH."class/dao/blogs.class.php" );
+
+ // see if we're using subdomains
+ $config =& Config::getConfig();
+ if( $config->getValue( "subdomains_enabled" )) {
+ lt_include( PLOG_CLASS_PATH."class/net/http/subdomains.class.php" );
+
+ $subdomainInfo = Subdomains::getSubdomainInfoFromRequest();
+
+ if( !empty($subdomainInfo["blogdomain"]) && $this->_request->getValue( 'blogDomain' ) == "" ) {
+ $this->_request->setValue( 'blogDomain', $subdomainInfo["blogdomain"] );
+ }
+ if( !empty($subdomainInfo["username"]) && $this->_request->getValue( 'blogUserName' ) == "" ) {
+ $this->_request->setValue( 'blogUserName', $subdomainInfo["username"] );
+ }
+ if( !empty($subdomainInfo["blogname"]) && $this->_request->getValue( 'blogName' ) == "" ) {
+ $this->_request->setValue( 'blogName', $subdomainInfo["blogname"] );
+ }
+ }
+
$blogId = $this->_request->getValue( "blogId" );
+ $blogName = $this->_request->getValue( 'blogName' );
+ $userId = $this->_request->getValue( 'userId' );
+ $userName = $this->_request->getValue( 'blogUserName' );
+ $blogDomain = $this->_request->getValue( 'blogDomain' );
+
+ // if there is a "blogId" parameter, it takes precedence over the
+ // "user" parameter.
+ if( !$blogId && !$blogName && !$blogDomain) {
+ // check if there was a user parameter
+ if( !empty($userName) ) {
+ lt_include( PLOG_CLASS_PATH."class/dao/users.class.php" );
+ // if so, check to which blogs the user belongs
+ $users = new Users();
+ $userInfo = $users->getUserInfoFromUsername( $userName );
+ // if the user exists and is valid...
+ if( $userInfo ) {
+ $userBlogs = $users->getUsersBlogs( $userInfo->getId(), BLOG_STATUS_ACTIVE );
+ // check all the blogs and pick the first one that is owned. If none is owned, then pick a random
+ // one (the last one that was processed)
+ if( !empty($userBlogs)) {
+ $i = 0;
+ $found = false;
+ while( $i < count($userBlogs) && !$found ) {
+ $blog = $userBlogs[$i];
+ if( $blog->getOwnerId() == $userInfo->getId()) $found = true;
+ $i++;
+ }
+ $blogId = $blog->getId();
+ }
+ else {
+ $blogId = $this->_config->getValue('default_blog_id');
+ }
+ }
+ else {
+ $blogId = $this->_config->getValue('default_blog_id');
+ }
+ }
+ else {
+ // if there is no user parameter, we take the blogId from the session
+ if( $this->_session->getValue('blogId') != '' ) {
+ $blogId = $this->_session->getValue('blogId');
+ }
+ else {
+ // get the default blog id from the database
+ $blogId = $this->_config->getValue('default_blog_id');
+ }
+ }
+ }
+
$val = new IntegerValidator();
if( !$val->validate( $blogId )) {
$config =& Config::getConfig();
$blogId = $config->getValue( "default_blog_id" );
}
-
+
// try to load the blog
$blogs = new Blogs();
$blogInfo = $blogs->getBlogInfo( $blogId );
More information about the pLog-svn
mailing list