HEX
Server: Apache/2.4.59 (Debian)
System: Linux skycube.cz 4.19.0-25-amd64 #1 SMP Debian 4.19.289-2 (2023-08-08) x86_64
User: ilya (534)
PHP: 7.3.31-1~deb10u7
Disabled: pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,
Upload Files
File: /var/www/ilya/data/www/irk2.ru/classes/actions/ActionRss.class.php
<?
/*-------------------------------------------------------
*
*   LiveStreet Engine Social Networking
*   Copyright © 2008 Mzhelskiy Maxim
*
*--------------------------------------------------------
*
*   Official site: www.livestreet.ru
*   Contact e-mail: rus.engine@gmail.com
*
*   GNU General Public License, version 2:
*   http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
*
---------------------------------------------------------
*/

/**
 * Обрабатывает RSS
 * Автор класса vovazol(http://livestreet.ru/profile/vovazol/)
 *
 */
class ActionRss extends Action {

	public function Init() {		
		$this->SetDefaultEvent('index');
		Router::SetIsShowStats(false);
		header('Content-Type: application/rss+xml; charset=utf-8');
	}

	protected function RegisterEvent() {
		$this->AddEvent('index','RssGood');
		$this->AddEvent('new','RssNew');
		$this->AddEvent('allcomments','RssComments');
		$this->AddEvent('comments','RssTopicComments');
		$this->AddEvent('tag','RssTag');
		$this->AddEvent('blog','RssColectiveBlog');
		$this->AddEvent('log','RssPersonalBlog');
	}

	protected function RssGood() {
		$aResult=$this->Topic_GetTopicsGood(1,BLOG_TOPIC_PER_PAGE*2);
		$aTopics=$aResult['collection'];
		
		$aChannel['title']=SITE_NAME;
		$aChannel['link']=DIR_WEB_ROOT;
		$aChannel['description']=SITE_NAME.' / RSS channel';
		$aChannel['language']='ru';
		$aChannel['managingEditor']=RSS_EDITOR_MAIL;
		$aChannel['generator']=SITE_NAME;
		
		$topics=array();
		foreach ($aTopics as $oTopic){
			$item['title']=$oTopic->getTitle();
			$item['guid']=$oTopic->getUrl();
			$item['link']=$oTopic->getUrl();
			$item['description']=$oTopic->getTextShort();
			$item['pubDate']=$oTopic->getDateAdd();
			$item['author']=$oTopic->getUserLogin();
			$item['category']=$oTopic->getTags();
			$topics[]=$item;
		}
		$this->Viewer_Assign('aChannel',$aChannel);
		$this->Viewer_Assign('aItems',$topics);
		$this->SetTemplateAction('index');
	}

	protected function RssNew() {
		$aResult=$this->Topic_GetTopicsNew(1,BLOG_TOPIC_PER_PAGE*2);			
		$aTopics=$aResult['collection'];
		
		$aChannel['title']=SITE_NAME;
		$aChannel['link']=DIR_WEB_ROOT;
		$aChannel['description']=SITE_NAME.' / RSS channel';
		$aChannel['language']='ru';
		$aChannel['managingEditor']=RSS_EDITOR_MAIL;
		$aChannel['generator']=SITE_NAME;
		
		$topics = array();
		foreach ($aTopics as $oTopic){
			$item['title']=$oTopic->getTitle();
			$item['guid']=$oTopic->getUrl();
			$item['link']=$oTopic->getUrl(); 
			$item['description']=$oTopic->getTextShort();
			$item['pubDate']=$oTopic->getDateAdd();
			$item['author']=$oTopic->getUserLogin();
			$item['category']=$oTopic->getTags();
			$topics[]=$item;
		}
		$this->Viewer_Assign('aChannel',$aChannel);
		$this->Viewer_Assign('aItems',$topics);
		$this->SetTemplateAction('index');
	}

	protected function RssComments() {
		$aResult=$this->Comment_GetCommentsAll(0,1,BLOG_COMMENT_PER_PAGE*2);
		$aComments=$aResult['collection'];
		
		$aChannel['title']=SITE_NAME;
		$aChannel['link']=DIR_WEB_ROOT;
		$aChannel['description']=SITE_NAME.' / RSS channel';
		$aChannel['language']='ru';
		$aChannel['managingEditor']=RSS_EDITOR_MAIL;
		$aChannel['generator']=SITE_NAME;
		
		$comments=array();
		foreach ($aComments as $oComment){
			$item['title']='комментарии к: '.$oComment->getTopicTitle();
			$item['guid']=$oComment->getTopicUrl().'#comment'.$oComment->getId();
			$item['link']=$oComment->getTopicUrl().'#comment'.$oComment->getId();
			$item['description']=$oComment->getText();
			$item['pubDate']=$oComment->getDate();
			$item['author']=$oComment->getUserLogin(); 
			$item['category']='comments';
			$comments[]=$item;
		}
		$this->Viewer_Assign('aChannel',$aChannel);
		$this->Viewer_Assign('aItems',$comments);
		$this->SetTemplateAction('index');
	}

	protected function RssTopicComments() {
		$sTopicId=$this->GetParam(0);
		
		if (!($oTopic=$this->Topic_GetTopicById($sTopicId))) {
			return parent::EventNotFound();
		}
		
		$aComments=$this->Comment_GetCommentsByTopicId($oTopic->getId());
		$aComments=$aComments['comments'];
		
		$aChannel['title']=SITE_NAME;
		$aChannel['link']=DIR_WEB_ROOT;
		$aChannel['description']=SITE_NAME.' / RSS channel';
		$aChannel['language']='ru';
		$aChannel['managingEditor']=RSS_EDITOR_MAIL;
		$aChannel['generator']=SITE_NAME;
		
		$comments=array();
		foreach ($aComments as $oComment){
			$item['title']='комментарии к: '.$oTopic->getTitle();
			$item['guid']=$oTopic->getUrl().'#comment'.$oComment->getId();
			$item['link']=$oTopic->getUrl().'#comment'.$oComment->getId();
			$item['description']=$oComment->getText();
			$item['pubDate']=$oComment->getDate();
			$item['author']=$oComment->getUserLogin();
			$item['category']='comments';
			$comments[]=$item;
		}
		$this->Viewer_Assign('aChannel',$aChannel);
		$this->Viewer_Assign('aItems',$comments);
		$this->SetTemplateAction('index');	
	}

	protected function RssTag() {
		$sTag=urldecode($this->GetParam(0));
		$aResult=$this->Topic_GetTopicsByTag($sTag,0,1,BLOG_TOPIC_PER_PAGE*2);
		$aTopics=$aResult['collection'];
		
		$aChannel['title']=SITE_NAME;
		$aChannel['link']=DIR_WEB_ROOT;
		$aChannel['description']=SITE_NAME.' / RSS channel';
		$aChannel['language']='ru';
		$aChannel['managingEditor']=RSS_EDITOR_MAIL;
		$aChannel['generator']=SITE_NAME;
		
		$topics=array();
		foreach ($aTopics as $oTopic){
			$item['title']=$oTopic->getTitle();
			$item['guid']=$oTopic->getUrl();
			$item['link']=$oTopic->getUrl();
			$item['description']=$oTopic->getTextShort();
			$item['pubDate']=$oTopic->getDateAdd();
			$item['author']=$oTopic->getUserLogin();
			$item['category']=$oTopic->getTags();
			$topics[]=$item;
		}
		$this->Viewer_Assign('aChannel',$aChannel);
		$this->Viewer_Assign('aItems',$topics);
		$this->SetTemplateAction('index');
	}

	protected function RssColectiveBlog() {
		$sBlogUrl=$this->GetParam(0);		
		if (!$sBlogUrl or !($oBlog=$this->Blog_GetBlogByUrl($sBlogUrl))) {			
			return parent::EventNotFound();
		}else{	
			$aResult=$this->Topic_GetTopicsByBlogGood($oBlog,0,1,BLOG_TOPIC_PER_PAGE*2);
		}
		$aTopics=$aResult['collection'];
		
		$aChannel['title']=SITE_NAME;
		$aChannel['link']=DIR_WEB_ROOT;
		$aChannel['description']=SITE_NAME.' / '.$oBlog->getTitle().' / RSS channel';
		$aChannel['language']='ru';
		$aChannel['managingEditor']=RSS_EDITOR_MAIL;
		$aChannel['generator']=SITE_NAME;
		
		$topics=array();
		foreach ($aTopics as $oTopic){
			$item['title']=$oTopic->getTitle();
			$item['guid']=$oTopic->getUrl();
			$item['link']=$oTopic->getUrl();
			$item['description']=$oTopic->getTextShort();
			$item['pubDate']=$oTopic->getDateAdd();
			$item['author']=$oTopic->getUserLogin();
			$item['category']=$oTopic->getTags();
			$topics[]=$item;
		}
		$this->Viewer_Assign('aChannel',$aChannel);
		$this->Viewer_Assign('aItems',$topics);
		$this->SetTemplateAction('index');
	}

	protected function RssPersonalBlog() {
		$this->sUserLogin=$this->GetParam(0);		
		if (!$this->sUserLogin or !($oUser=$this->User_GetUserByLogin($this->sUserLogin))) {			
			return parent::EventNotFound();
		}else{	
			$aResult=$this->Topic_GetTopicsPersonalByUser($oUser->getId(),1,0,1,BLOG_TOPIC_PER_PAGE*2);
		}
		$aTopics=$aResult['collection'];
		
		$aChannel['title']=SITE_NAME;
		$aChannel['link']=DIR_WEB_ROOT;
		$aChannel['description']=SITE_NAME.' / '.$oUser->getLogin().' / RSS channel';
		$aChannel['language']='ru';
		$aChannel['managingEditor']=RSS_EDITOR_MAIL;
		$aChannel['generator']=SITE_NAME;
		
		$topics=array();
		foreach ($aTopics as $oTopic){
			$item['title']=$oTopic->getTitle();
			$item['guid']=$oTopic->getUrl();
			$item['link']=$oTopic->getUrl();
			$item['description']=$oTopic->getTextShort();
			$item['pubDate']=$oTopic->getDateAdd();
			$item['author']=$oTopic->getUserLogin();
			$item['category']=$oTopic->getTags();
			$topics[]=$item;
		}
		$this->Viewer_Assign('aChannel',$aChannel);
		$this->Viewer_Assign('aItems',$topics);
		$this->SetTemplateAction('index');
	}

}
?>