xmlout.php

来自「sabreipb 2.1.6 utf-8中文版本!」· PHP 代码 · 共 1,314 行 · 第 1/3 页

PHP
1,314
字号
		# Prevent polls from being edited		$this->post->can_add_poll = 0;				# Prevent titles from being edited		$this->post->edit_title   = 0;				$this->post->convert_open_close_times();		$this->post->post = $this->post->compile_post();				# Errors?		if ( $this->post->obj['post_errors'] )		{			$this->post_edit_show( $this->ipsclass->lang[ $this->post->obj['post_errors'] ] );		}		else		{			$this->post->save_post();		}				//-----------------------------------------		// Prep for display		//-----------------------------------------					$raw_post = $this->post->show_post_preview( $this->post->post['post'] );				if( stristr( $raw_post, "[attachmentid=" ) )		{			$raw_post = preg_replace( "#\[attachmentid=(\d+)\]#is", "", $raw_post );		}				if( $this->post->post['append_edit'] == 1 AND $this->post->post['edit_time'] AND $this->post->post['edit_name'] )		{			$this->ipsclass->load_language( 'lang_topic' );			$e_time = $this->ipsclass->get_date( $this->post->post['edit_time'] , 'LONG' );			$raw_post .= "<br /><br /><span class='edit'>".sprintf($this->ipsclass->lang['edited_by'], $this->post->post['edit_name'], $e_time)."</span>";		}				foreach( $this->ipsclass->skin['_macros'] as $i => $row )      	{			if ( $row['macro_value'] != "" )			{				$raw_post = str_replace( "<{".$row['macro_value']."}>", $row['macro_replace'], $raw_post );			}		}				$raw_post = str_replace( "<#IMG_DIR#>", $this->ipsclass->skin['_imagedir'], $raw_post );		$raw_post = str_replace( "<#EMO_DIR#>", $this->ipsclass->skin['_emodir']  , $raw_post );				//-----------------------------------------		// Return plain text		//-----------------------------------------				@header( "Content-type: text/html; charset={$this->ipsclass->vars['gb_char_set']}" );		$this->print_nocache_headers();		print $raw_post;		exit();    }        /*-------------------------------------------------------------------------*/	// Post Edit Show	/*-------------------------------------------------------------------------*/          function post_edit_show( $error_msg = "" )    {    	//-----------------------------------------    	// INIT    	//-----------------------------------------    	    	$pid = intval( $_REQUEST['p'] );    	$fid = intval( $_REQUEST['f'] );    	$tid = intval( $_REQUEST['t'] );    	    	//-----------------------------------------    	// Check P|T|FID    	//-----------------------------------------    	    	if ( ! $pid OR ! $tid OR ! $fid )    	{    		@header( "Content-type: text/plain" );    		$this->print_nocache_headers();			print 'error';			exit();		}				//-----------------------------------------		// Get topic		//-----------------------------------------				$topic = $this->ipsclass->DB->build_and_exec_query( array( 'select' => '*', 'from' => "topics", 'where' => 'tid='.$tid ) );				//-----------------------------------------		// Got permission?		//-----------------------------------------				if ( ( $topic['state'] != 'open' ) and ( ! $this->ipsclass->member['g_is_supmod'] ) )		{			if ( $this->ipsclass->member['g_post_closed'] != 1 )			{				@header( "Content-type: text/plain" );				$this->print_nocache_headers();				print 'nopermission';				exit();			}		}				if ( $this->ipsclass->check_perms( $this->ipsclass->forums->forum_by_id[ $fid ]['reply_perms'] ) == FALSE )		{			@header( "Content-type: text/plain" );			$this->print_nocache_headers();			print 'nopermission';			exit();		}				if ( $this->ipsclass->forums->forum_by_id[ $fid ]['status'] == 0 )		{			@header( "Content-type: text/plain" );			$this->print_nocache_headers();			print 'nopermission';			exit();		}						//-----------------------------------------		// Get classes		//-----------------------------------------				if ( ! $this->post_init )		{			require_once( ROOT_PATH."sources/classes/post/class_post.php" );			require_once( ROOT_PATH."sources/classes/post/class_post_edit.php" );					$this->post           =  new post_functions();			$this->post->ipsclass =& $this->ipsclass;			$this->post->forum    =  $this->ipsclass->forums->forum_by_id[ $fid ];			$this->post->main_init();			$this->post_init      = 1;		}				//-----------------------------------------		// check		//-----------------------------------------				if ( ! $this->post->orig_post['post'] OR ! $topic['tid'] )		{			@header( "Content-type: text/plain" );			$this->print_nocache_headers();			print 'nopermission';			exit();		}				//-----------------------------------------		// Convert and return plain text		//-----------------------------------------		$raw_post = $this->post->parser->pre_edit_parse( $this->post->orig_post['post'] );				// Fix IE bug		$raw_post = str_replace( "&sect", "&amp;sect", $raw_post );				$html     = $this->ipsclass->compiled_templates['skin_post']->inline_edit_quick_box($raw_post, $pid, $error_msg);				$this->print_nocache_headers();		header( "Content-Type: text/html;charset={$this->ipsclass->vars['gb_char_set']}" );		echo $html;		exit();    }        /*-------------------------------------------------------------------------*/	// DST Auto correction	/*-------------------------------------------------------------------------*/          function dst_autocorrection()    {    	//-----------------------------------------    	// INIT    	//-----------------------------------------    	    	$xml       = intval( $_REQUEST['xml'] );    	$md5_check = substr( $this->ipsclass->parse_clean_value( rawurldecode( $_REQUEST['md5check'] ) ), 0, 32 );    	    	//-----------------------------------------    	// Check    	//-----------------------------------------    	    	if (  $md5_check != $this->ipsclass->return_md5_check() )    	{    		if ( $xml )    		{    			@header( "Content-type: text/plain" );    			$this->print_nocache_headers();				print 'error';				exit();			}			else			{				$this->ipsclass->boink_it( $this->ipsclass->base_url . 'act=usercp&CODE=04&dsterror=1' );			}    	}    	    	//-----------------------------------------    	// Already using DST?    	//-----------------------------------------    	    	if ( $this->ipsclass->member['dst_in_use'] == 1 )    	{    		$this->ipsclass->DB->do_update( 'members', array( 'dst_in_use' => 0 ), 'id='.$this->ipsclass->member['id'] );    	}    	else    	{    		$this->ipsclass->DB->do_update( 'members', array( 'dst_in_use' => 1 ), 'id='.$this->ipsclass->member['id'] );    	}    	    	if ( $xml )		{			@header( "Content-type: text/plain" );			$this->print_nocache_headers();			print 'success';			exit();		}		else		{			$this->ipsclass->boink_it( $this->ipsclass->base_url . 'act=idx' );		}    }        /*-------------------------------------------------------------------------*/	// Get new posts	/*-------------------------------------------------------------------------*/          function get_msg_preview()    {    	//-----------------------------------------    	// INIT    	//-----------------------------------------    	    	$limit     = intval( $_REQUEST['limit'] );    	    	//-----------------------------------------    	// Couldn't be easier....    	//-----------------------------------------    	    	$return = $this->ipsclass->get_new_pm_notification( $limit, TRUE );    	    	header("Content-type: text/plain;charset={$this->ipsclass->vars['gb_char_set']}");    	$this->print_nocache_headers();    	print $return;    	exit();    }        /*-------------------------------------------------------------------------*/	// Get new posts	/*-------------------------------------------------------------------------*/          function save_topic()    {    	//-----------------------------------------    	// INIT    	//-----------------------------------------    	    	$name      = $this->ipsclass->parse_clean_value( $this->convert_unicode($_REQUEST['name']) );    	$type      = $this->ipsclass->parse_clean_value( rawurldecode( $_REQUEST['type'] ) );    	$tid       = intval( $_REQUEST['tid'] );    	$md5_check = substr( $this->ipsclass->parse_clean_value( rawurldecode( $_REQUEST['md5check'] ) ), 0, 32 );    	$can_edit  = 0;    	$openclose = '';    	   		//$name = $this->convert_unicode( $name );   				if( strtolower($this->ipsclass->vars['gb_char_set']) != 'iso-8859-1' &&			strtolower($this->ipsclass->vars['gb_char_set']) != 'utf-8' )   		{	   		if ( array_key_exists( strtolower($this->ipsclass->vars['gb_char_set']), $this->decode_charsets ) )	   		{		   		$this->ipsclass->vars['gb_char_set'] = $this->decode_charsets[strtolower($this->ipsclass->vars['gb_char_set'])];		   		$name = html_entity_decode( $name, ENT_NOQUOTES, $this->ipsclass->vars['gb_char_set'] );	   		}   		}    	    	    	//-----------------------------------------    	// Checks...    	//-----------------------------------------    	    	if ( ! $tid OR ! $type )    	{     		$this->return_null('-');    		exit();    	}    	    	if (  $md5_check != $this->ipsclass->return_md5_check() )    	{    		$this->return_null('-');    		exit();    	}    	    	//-----------------------------------------    	// Load topic    	//-----------------------------------------    	    	$topic = $this->ipsclass->DB->build_and_exec_query( array( 'select' => '*', 'from' => 'topics', 'where' => 'tid='.$tid ) );    	    	if ( ! $topic['tid'] )    	{     		$this->return_null('-');    		exit();    	}    	    	//-----------------------------------------    	// Have permission?    	//-----------------------------------------    	    	if ( $this->ipsclass->member['g_is_supmod'] )    	{    		$can_edit = 1;    	}    	    	if ( $type == 'openclose' )    	{    		if ( $name == 'close' OR $name == 'closed' )    		{    			$openclose = 'closed';    			    			if ( $this->ipsclass->member['_moderator'][ $topic['forum_id'] ]['close_topic'] )				{					$can_edit = 1;				}    		}    		else    		{    			$openclose = 'open';    							if ( $this->ipsclass->member['_moderator'][ $topic['forum_id'] ]['open_topic'] )				{					$can_edit = 1;				}			}    	}    	else    	{			if ( $this->ipsclass->member['_moderator'][ $topic['forum_id'] ]['edit_topic'] )			{				$can_edit = 1;			}    	}    	    	if ( ! $can_edit )    	{    		$this->return_null('0');    		exit();    	}    	    	//-----------------------------------------    	// index.php?act=xmlout&do=save-topic&type=title&tid=60591&name=test&md5check=b6417fb0cbd1e24250db348193fdb7c1    	// Alright, save it!    	//-----------------------------------------    	    	if ( $type == 'desc' )    	{    		$this->ipsclass->DB->do_update( 'topics', array( 'description' => $name ), 'tid='.$tid );    					$this->ipsclass->DB->do_insert( 'moderator_logs', array (												  			'forum_id'    => $topic['forum_id'],												  			'topic_id'    => $tid,												  			'post_id'     => $pid,												  			'member_id'   => $this->ipsclass->member['id'],												  			'member_name' => $this->ipsclass->member['members_display_name'],												  			'ip_address'  => $this->ipsclass->input['IP_ADDRESS'],												 			'http_referer'=> $_SERVER['HTTP_REFERER'],												  			'ctime'       => time(),												  			'topic_title' => $topic['title'],												  			'action'      => $this->ipsclass->lang['ajax_topicdesc'],												  			'query_string'=> $_SERVER['QUERY_STRING'],											  )  );    		    	}    	else if ( $type == 'openclose' )    	{    		$this->ipsclass->DB->do_update( 'topics', array( 'state' => $openclose ), 'tid='.$tid );    					$this->ipsclass->DB->do_insert( 'moderator_logs', array (												  			'forum_id'    => $topic['forum_id'],												  			'topic_id'    => $tid,												  			'post_id'     => $pid,												  			'member_id'   => $this->ipsclass->member['id'],												  			'member_name' => $this->ipsclass->member['members_display_name'],												  			'ip_address'  => $this->ipsclass->input['IP_ADDRESS'],												 			'http_referer'=> $_SERVER['HTTP_REFERER'],												  			'ctime'       => time(),												  			'topic_title' => $topic['title'],												  			'action'      => $this->ipsclass->lang['ajax_topicstate'],												  			'query_string'=> $_SERVER['QUERY_STRING'],											  )  );    		    	}    	else    	{	    	if( trim($name) == '' OR !$name )	    	{		    	$this->return_string($topic['title']);		    	exit();	    	}	    	    		$this->ipsclass->DB->do_update( 'topics', array( 'title' => $name ), 'tid='.$tid );    					$this->ipsclass->DB->do_insert( 'moderator_logs', array (												  			'forum_id'    => $topic['forum_id'],												  			'topic_id'    => $tid,												  			'post_id'     => $pid,												  			'member_id'   => $this->ipsclass->member['id'],												  			'member_name' => $this->ipsclass->member['members_display_name'],												  			'ip_address'  => $this->ipsclass->input['IP_ADDRESS'],												 			'http_referer'=> $_SERVER['HTTP_REFERER'],												  			'ctime'       => time(),												  			'topic_title' => $name,												  			'action'      => sprintf($this->ipsclass->lang['ajax_topictitle'],$topic['title'],$name),												  			'query_string'=> $_SERVER['QUERY_STRING'],											  )  );    		    		    		if ( $topic['tid'] == $this->ipsclass->forums->forum_by_id[ $topic['forum_id'] ]['last_id'] )			{				$this->ipsclass->DB->do_update( 'forums', array( 'last_title' => $name ), 'id='.$topic['forum_id'] );				$this->ipsclass->update_forum_cache();			}						$this->return_string($name);		    exit();    	}   		    	$this->return_null('s');		exit();    	    }        /*-------------------------------------------------------------------------*/	// Get member names	/*-------------------------------------------------------------------------*/          function get_member_names()    {    	//-----------------------------------------    	// INIT

⌨️ 快捷键说明

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