rssexport.php

来自「sabreipb 2.1.6 utf-8中文版本!」· PHP 代码 · 共 305 行

PHP
305
字号
<?php/*+--------------------------------------------------------------------------|   Invision Power Board v2.1.5|   =============================================|   by Matthew Mecham|   (c) 2001 - 2005 Invision Power Services, Inc.|   |   =============================================|   Web: |   Time: Wed, 01 Mar 2006 19:11:27 GMT|   Release: |   Licence Info: +---------------------------------------------------------------------------|   > $Date: 2006-3-6|   > $Revision: 23 $|   > $Author: matt $+---------------------------------------------------------------------------||   > Components Functions|   > Module written by Matt Mecham|   > Date started: 12th April 2005 (13:09)+--------------------------------------------------------------------------*/if ( ! defined( 'IN_ACP' ) ){	print "<h1>Incorrect access</h1>You cannot access this file directly. If you have recently upgraded, make sure you upgraded 'admin.php'.";	exit();}class ad_rssexport{	# Globals	var $ipsclass;		var $perm_main  = 'content';	var $perm_child = 'rssexport';		var $use_sockets = 1;		/*-------------------------------------------------------------------------*/	// Main handler	/*-------------------------------------------------------------------------*/		function auto_run() 	{		$this->html = $this->ipsclass->acp_load_template('cp_skin_rss');				switch($this->ipsclass->input['code'])		{			case 'rssexport_overview':				$this->ipsclass->admin->cp_permission_check( $this->perm_main.'|'.$this->perm_child.':' );				$this->rssexport_overview();				break;						case 'rssexport_add':				$this->ipsclass->admin->cp_permission_check( $this->perm_main.'|'.$this->perm_child.':add' );				$this->rssexport_form('add');				break;							case 'rssexport_edit':				$this->ipsclass->admin->cp_permission_check( $this->perm_main.'|'.$this->perm_child.':edit' );				$this->rssexport_form('edit');				break;							case 'rssexport_add_save':				$this->ipsclass->admin->cp_permission_check( $this->perm_main.'|'.$this->perm_child.':add' );				$this->rssexport_save('add');				break;							case 'rssexport_edit_save':				$this->ipsclass->admin->cp_permission_check( $this->perm_main.'|'.$this->perm_child.':edit' );				$this->rssexport_save('edit');				break;							case 'rssexport_recache':				$this->ipsclass->admin->cp_permission_check( $this->perm_main.'|'.$this->perm_child.':recache' );				$this->rssexport_rebuild_cache();				break;						case 'rssexport_delete':				$this->ipsclass->admin->cp_permission_check( $this->perm_main.'|'.$this->perm_child.':remove' );				$this->rssexport_delete();				break;							default:				$this->ipsclass->admin->cp_permission_check( $this->perm_main.'|'.$this->perm_child.':' );				$this->rssexport_overview();				break;		}	}		/*-------------------------------------------------------------------------*/	// RSS Export: Rebuild cache	/*-------------------------------------------------------------------------*/		function rssexport_rebuild_cache( $rss_export_id='', $return=1 )	{		//--------------------------------------------		// INIT		//--------------------------------------------				if ( ! $rss_export_id )		{			$rss_export_id = $this->ipsclass->input['rss_export_id'] == 'all' ? 'all' : intval($this->ipsclass->input['rss_export_id']);		}				//--------------------------------------------		// Check		//--------------------------------------------				if ( ! $rss_export_id )		{			$this->ipsclass->main_msg = "No ID was passed, please try again";			$this->rssexport_overview();			return;		}				//--------------------------------------------		// Require classes		//--------------------------------------------				require_once( KERNEL_PATH . 'class_rss.php' );		$class_rss              =  new class_rss();		$class_rss->ipsclass    =& $this->ipsclass;		$class_rss->use_sockets =  $this->use_sockets;		$class_rss->doc_type    =  $this->ipsclass->vars['gb_char_set'];				//-----------------------------------------        // Load and config the post parser        //  and load up the editor for the custom        //  bbcode parsing        //-----------------------------------------                require_once( ROOT_PATH."sources/handlers/han_parse_bbcode.php" );        $this->parser                      = new parse_bbcode();        $this->parser->ipsclass            = $this->ipsclass;        $this->parser->allow_update_caches = 1;        $this->parser->bypass_badwords     = 0;        		//--------------------------------------------		// Reset rss_export cache		//--------------------------------------------				$this->ipsclass->cache['rss_export'] = array();				//--------------------------------------------		// Go loopy		//--------------------------------------------				$this->ipsclass->DB->build_query( array( 'select' => '*', 'from' => 'rss_export' ) );		$outer = $this->ipsclass->DB->exec_query();				while( $row = $this->ipsclass->DB->fetch_row( $outer ) )		{			//--------------------------------------------			// Update RSS cache			//--------------------------------------------						if ( $row['rss_export_enabled'] )			{				$this->ipsclass->cache['rss_export'][] = array( 'url'   => $this->ipsclass->vars['board_url'].'/index.php?act=rssout&amp;id='.$row['rss_export_id'],																'title' => $row['rss_export_title'] );			}						if ( $rss_export_id == 'all' OR $row['rss_export_id'] == $rss_export_id )			{				//--------------------------------------------				// Build DB query				//--------------------------------------------								if ( $row['rss_export_include_post'] )				{					$this->ipsclass->DB->build_query( array( 'select' => 't.*',															 'from'   => array( 'topics' => 't' ),															 'where'  => 't.forum_id IN( '.$row['rss_export_forums'].' ) AND t.state != "link" AND t.approved=1',															 'order'  => 't.'.$row['rss_export_order'].' '. $row['rss_export_sort'],															 'limit'  => array( 0, $row['rss_export_count'] ),															 'add_join' => array( 0 => array( 'select' => 'p.post',																							  'from'   => array( 'posts' => 'p' ),																							  'where'  => 't.topic_firstpost=p.pid',																							  'type'   => 'left'																				)           )													)      );				}				else				{					$this->ipsclass->DB->build_query( array( 'select' => '*',															 'from'   => 'topics',															 'where'  => 'forum_id IN( '.$row['rss_export_forums'].' ) AND state != "link" AND approved=1',															 'order'  => $row['rss_export_order'].' '. $row['rss_export_sort'],															 'limit'  => array( 0, $row['rss_export_count'] )													)      );				}								//--------------------------------------------				// Exec Query				//--------------------------------------------								$inner = $this->ipsclass->DB->exec_query();								//--------------------------------------------				// Create Channel				//--------------------------------------------								$channel_id = $class_rss->create_add_channel( array( 'title'       => $row['rss_export_title'],																	 'description' => $row['rss_export_desc'],																	 'link'        => $this->ipsclass->vars['board_url'].'/index.php',																	 'pubDate'     => $class_rss->rss_unix_to_rfc( time() ),																	 'ttl'         => $row['rss_export_cache_time']															)      );																			//--------------------------------------------				// Loop through topics and display				//--------------------------------------------								while( $topic = $this->ipsclass->DB->fetch_row( $inner ) )				{					//--------------------------------------------					// Parse...					//--------------------------------------------										$this->parser->parse_html  = 0;					$this->parser->parse_nl2br = 1;										$topic['post'] = $this->parser->pre_db_parse( $topic['post'] );					$topic['post'] = $this->parser->pre_display_parse( $topic['post'] );										$topic['post'] = preg_replace( "#\[attachmentid=(\d+?)\]#is", "<a href='".$this->ipsclass->vars['board_url']."/index.php?act=Attach&type=post&id=\\1'>".$this->ipsclass->vars['board_url']."/index.php?act=Attach&type=post&id=\\1</a>", $topic['post'] );								//-----------------------------------------					// Get the macros and replace them					//-----------------------------------------										if ( is_array( $this->ipsclass->skin['_macros'] ) )					{						foreach( $this->ipsclass->skin['_macros'] as $i => $rowm )						{							if ( $row['macro_value'] != "" )							{								$topic['post'] = str_replace( "<{".$rowm['macro_value']."}>", $rowm['macro_replace'], $topic['post'] );							}						}					}										//-----------------------------------------					// Fix up relative URLS					//-----------------------------------------										$topic['post'] = preg_replace( "#([^/])style_images/(<\#IMG_DIR\#>)#is", "\\1".$this->ipsclass->vars['board_url']."/style_images/\\2" , $topic['post'] );					$topic['post'] = preg_replace( "#([\"'])style_emoticons/#is"			, "\\1".$this->ipsclass->vars['board_url']."/style_emoticons/", $topic['post'] );										//-----------------------------------------					// Convert smilies and emos					//-----------------------------------------										$topic['post'] = str_replace( "<#IMG_DIR#>", $this->ipsclass->skin['_imagedir'], $topic['post'] );					$topic['post'] = str_replace( "<#EMO_DIR#>", $this->ipsclass->skin['_emodir']  , $topic['post'] );										//-----------------------------------------					// Add item					//-----------------------------------------										$class_rss->create_add_item( $channel_id, array( 'title'           => $topic['title'],																	 'link'            => $this->ipsclass->vars['board_url'].'/index.php?showtopic='.$topic['tid'],																	 'description'     => $topic['post'],//$topic['description'],																	// 'content:encoded' => $topic['post'],																	 'pubDate'	       => $class_rss->rss_unix_to_rfc( $topic['start_date'] ),																	 'guid'            => $topic['tid']											  )                    );				}								//--------------------------------------------				// Build document				//--------------------------------------------								$class_rss->rss_create_document();								//--------------------------------------------				// Update the cache				//--------------------------------------------								$this->ipsclass->DB->do_update( 'rss_export', array( 'rss_export_cache_last'    => time(),																	 'rss_export_cache_content' => $class_rss->rss_document ), 'rss_export_id='.$row['rss_export_id'] ); 			}		}				//header( "Content-type: text/plain");		//print $class_rss->rss_document; exit();				//--------------------------------------------		// Update cache		//--------------------------------------------				$this->ipsclass->update_cache( array( 'name' => 'rss_export', 'deletefirst' => 1, 'donow' => 1, 'array' => 1 ) );				//--------------------------------------------		// Return		//--------------------------------------------				if ( $return )		{			$this->ipsclass->main_msg = "RSS 瀵煎嚭宸查噸鏂扮紦瀛樸

⌨️ 快捷键说明

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