⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 xmlrpcserver.class.php

📁 一个用PHP编写的
💻 PHP
📖 第 1 页 / 共 4 页
字号:
                    $blogSettings = $blogInfo->getSettings();                                        // Add article notifcations if this is specified by the default setting.                    if ($blogSettings->getValue( "default_send_notification" ))                    {                        require_once( PLOG_CLASS_PATH."class/dao/articlenotifications.class.php" );                            $artNotifications = new ArticleNotifications();                        $artNotifications->addNotification( $postid, $blogid, $userInfo->getId());                    } 					$this->setResponseCharset( $blogInfo );                                       return sprintf( "%d", $postid );                } else                {                return new IXR_Error(-1, 'Internal error occured creating your post!');                }            } else            {                return new IXR_Error(-1, 'You did not provide the correct password');            }        }			/**		 * @private		 * sets the character set for responses		 */		function setResponseCharset( $blog )		{			$locale = $blog->getLocale();			$this->defencoding = $locale->getCharset();		}					/** 		 * NOTE: this method does not perform permission checking since if it did,		 * it would be impossible to post: no categories would be available if the	     * view_categories is not available. This is in line with the browser-based UI,	     * there it is not necessary to have this permission in order to post new articles,		 * only add_post is needed		 */	    function metaWeblogGetCategories($args)	    {			$users = new Users();			$category = new ArticleCategories();			$blogsG = new Blogs();		        $blogid     = $args[0];	        $username   = $args[1];	        $password   = $args[2];	        $auth = $users->authenticateUser( $username, $password );	        if ($auth)	        {                $blogInfo = $blogsG->getBlogInfo( $blogid );				if( !$blogInfo ) {					return new IXR_Error(-1, 'Incorrect blog id');				}			            $cats = $category->getBlogCategories($blogid);				$url = $blogInfo->getBlogRequestGenerator();	            $ret = array();		            foreach($cats as $cat)	            {	                $dummy                   = array();	                $dummy["description"]    = $cat->getDescription();	                // disable the generation of xhtml content or else the IXR_XMLRPC library will	                // escape things twice!	                $url->setXHTML( false );	                $dummy["htmlUrl"]        = $url->categoryLink( $cat );	                $dummy["rssUrl"]         = "http://";	                $ret[$cat->getName()]    = $dummy;	            }					$this->setResponseCharset( $blogInfo );		            return $ret;	        } else	        {	            return new IXR_Error(-1, 'You did not provide the correct password');	        }	    }	    function mtGetCategoryList($args)	    {			$users = new Users();			$category = new ArticleCategories();			$blogsG = new Blogs();		        $blogid     = $args[0];	        $username   = $args[1];	        $password   = $args[2];	        $auth = $users->authenticateUser( $username, $password );	        if ($auth)	        {                $blogInfo = $blogsG->getBlogInfo( $blogid );				if( !$blogInfo ) {					return new IXR_Error(-1, 'Incorrect blog id');				}			            $cats = $category->getBlogCategories($blogid);				$url = $blogInfo->getBlogRequestGenerator();	            $ret = array();		            foreach($cats as $cat)	            {	                $dummy                   = array();	                $dummy["categoryId"]     = $cat->getId();	                $dummy["categoryName"]   = $cat->getName();	                $ret[]                   = $dummy;	            }					$this->setResponseCharset( $blogInfo );		            return $ret;	        } else	        {	            return new IXR_Error(-1, 'You did not provide the correct password');	        }	    }	    function getPost($args)	    {	        include_once( PLOG_CLASS_PATH."class/data/timestamp.class.php" );							$users = new Users();			$articles = new Articles();		        $appkey     = $args[0];	        $postid     = $args[1];	        $username   = $args[2];	        $password   = $args[3];	        /*	            "userid" =>	            "dateCreated" =>	            "content" =>	            "postid" =>	        */	        $userInfo = $users->getUserInfo($username,$password);	        if( $userInfo ) {	            $item = $articles->getBlogArticle($postid,	                                                 -1, // blogId	                                                 true, // includeHiddenFields	                                                 -1, // date	                                                 -1, // categoryId	                                                 $userInfo->getId());	            $dateObject = $item->getDateObject();	            // Get the unix time stamp 	            $time = $dateObject->getTimestamp(DATE_FORMAT_UNIXTIME);	            $dummy                  = array();				$userInfo               = $item->getUserInfo();	            $dummy["userid"]        = $userInfo->getId();	            $dummy["dateCreated"]   = new IXR_Date($time);	            $dummy["content"]       = $item->getTopic() . "\r\n" . $item->getText(false) . " ";	            $dummy["postid"]        = $item->getId();				$blogInfo = $item->getBlogInfo();								// check the permissions				if( !$this->userHasPermission( $userInfo, $blogInfo, "view_posts" )) {					return new IXR_Error(-1, 'This user does not have enough permissions' );				}								$this->setResponseCharset( $blogInfo );	            return $dummy;	        } else	        {	            return new IXR_Error(-1, 'You did not provide the correct password');	        }	    }	    function metaWeblogGetPost($args)	    {	        $users = new Users();			$articles = new Articles();		        $postid     = $args[0];	        $username   = $args[1];	        $password   = $args[2];	        $userInfo = $users->getUserInfo( $username, $password );	        if( $userInfo )	        {	            lt_include( PLOG_CLASS_PATH."class/data/timestamp.class.php" );	            $item = $articles->getBlogArticle($postid,	                                              -1, // blogId	                                              true, // includeHiddenFields	                                              -1, // date	                                              -1, // categoryId	                                              $userInfo->getId());					// check if the article is valid				if( !$item ) {					return( new IXR_Error(-1, 'The article is not valid' ));				}								// check permissions	            $blogInfo = $item->getBlogInfo();								if( !$this->userHasPermission( $userInfo, $blogInfo, "view_posts" )) {					return( new IXR_Error(-1, 'This user does not have enough permissions' ));				}		            $dateObject = $item->getDateObject();	            // Get the unix time stamp 	            $time = $dateObject->getTimestamp(DATE_FORMAT_UNIXTIME);	            $articleCat = $item->getCategory();	            $blogId = $item->getBlog();	            $blogs = new Blogs();	            $url = $blogInfo->getBlogRequestGenerator();	            $dummy                  = array();				$userInfo               = $item->getUserInfo();	            $dummy["userid"]        = $userInfo->getId();	            $dummy["dateCreated"]   = new IXR_Date($time);	            $dummy["title"]         = $item->getTopic();                $blogSettings = $blogInfo->getSettings();                                $dummy["description"]   = $item->getIntroText(); 	            $dummy["postid"]        = $item->getId();	            $dummy["link"]          = $url->postLink( $item );	            $dummy["permaLink"]     = $url->postPermalink( $item );	            $catArray               = array();	            foreach( $item->getCategories() as $category ) {	                $catArray[]             = $category->getName();	            }	            $dummy["categories"]      = $catArray;	            // The MovableType Extensions	            $dummy["mt_text_more"]       = $item->getExtendedText(); 	            $dummy["mt_allow_comments"]  = $item->getCommentsEnabled(); 	            					$this->setResponseCharset( $blogInfo );		            return $dummy;	        } else	        {	            return new IXR_Error(-1, 'You did not provide the correct password');	        }	    }	    function editPost($args)	    {			$users = new Users();			$articles = new Articles();			$blogsG = new Blogs();	        $appkey     = $args[0];	        $postid     = $args[1];	        $username   = $args[2];	        $password   = $args[3];	        $content    = $args[4];	        $publish    = $args[5];	        /*	            boolean, true or false	        */	        $userInfo = $users->getUserInfo( $username, $password );	        if( $userInfo ) {	            // fake topic	            $dummy = explode("\n", $content);				if( count($dummy) == 1 ) {					$title = substr( $content, 0, 60 );				}				else {		            $title = $dummy[0];		            unset($dummy[0]);		            $content = implode("\n", $dummy);		            unset($dummy);				}	            $article = $articles->getBlogArticle($postid,	                                                 -1, // blogId	                                                 true, // includeHiddenFields	                                                 -1, // date	                                                 -1, // categoryId	                                                 $userInfo->getId());					if( !$article ) {					return( new IXR_Error(-1, 'The article is not correct' ));				}								$blogInfo = $article->getBlogInfo();												// check the permissions				if( !$this->userHasPermission( $userInfo, $blogInfo, "update_post" )) {					return new IXR_Error(-1, 'This user does not have enough permissions' );				}						            if ($publish) {	                $status = POST_STATUS_PUBLISHED;	            } 				else {	                $status = POST_STATUS_DRAFT;	            }		            $article->setText($content);	            $article->setTopic($title);	            $article->setStatus($status);				// Get the plugin manager				$plugMgr =& PluginManager::getPluginManager();				$plugMgr->setBlogInfo( $blogInfo );				$plugMgr->setUserInfo( $userInfo );				$plugMgr->loadPlugins();				// Send the EVENT_PRE_POST_UPDATE message				$plugMgr->notifyEvent( EVENT_PRE_POST_UPDATE, Array( "article" => &$article ));            	            $articles->updateArticle($article);	            // Send the EVENT_POST_POST_UPDATE messages to the plugins	            $plugMgr->notifyEvent( EVENT_POST_POST_UPDATE, Array( "article" => &$article ));				

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -