$Date: 2006-01-11 22:47:48 +0000 (Wed, 11 Jan 2006) $ | > $Revision: 122 $ | > $Author: bfarber $ +--------------------------------------------------------------------------- | | > XML OUT Functions for XmlHttpRequest functions | > Module written by Matt Mecham | > Date started: Friday 18th March 2005 | | > Module Version Number: 1.1.0 +-------------------------------------------------------------------------- */ if ( ! defined( 'IN_IPB' ) ) { print "

Некорректный адрес

Вы не имеете доступа к этому файлу напрямую. Если вы недавно обновляли форум, вы должны обновить все соответствующие файлы."; exit(); } class xmlout { # Classes var $ipsclass; var $search; var $xml_output; var $xml_header; var $post_init = 0; /** * Post object * * @var object */ var $post; var $decode_charsets = array( 'iso-8859-1' => 'ISO-8859-1', 'iso8859-1' => 'ISO-8859-1', 'iso-8859-15' => 'ISO-8859-15', 'iso8859-15' => 'ISO-8859-15', 'utf-8' => 'UTF-8', 'cp866' => 'cp866', 'ibm866' => 'cp866', 'cp1251' => 'windows-1251', 'windows-1251' => 'windows-1251', 'win-1251' => 'windows-1251', 'cp1252' => 'windows-1252', 'windows-1252' => 'windows-1252', 'koi8-r' => 'KOI8-R', 'koi8-ru' => 'KOI8-R', 'koi8r' => 'KOI8-R', 'big5' => 'BIG5', 'gb2312' => 'GB2312', 'big5-hkscs' => 'BIG5-HKSCS', 'shift_jis' => 'Shift_JIS', 'sjis' => 'Shift_JIS', 'euc-jp' => 'EUC-JP', 'eucjp' => 'EUC-JP' ); /*-------------------------------------------------------------------------*/ // Constructor /*-------------------------------------------------------------------------*/ function xmlout() { $this->xml_header = "ipsclass->vars['gb_char_set']}\"?".'>'; } /*-------------------------------------------------------------------------*/ // Auto run /*-------------------------------------------------------------------------*/ function auto_run() { //----------------------------------------- // INIT //----------------------------------------- if ( $this->ipsclass->input['j_do'] ) { $this->ipsclass->input['do'] = $this->ipsclass->input['j_do']; } //----------------------------------------- // What shall we do? //----------------------------------------- switch( $this->ipsclass->input['do'] ) { case 'get-new-posts': $this->get_new_posts(); break; case 'get-new-msgs': $this->get_new_messages(); break; case 'mark-forum': $this->mark_forum_as_read(); break; case 'get-member-names': $this->get_member_names(); break; case 'get-msg-preview': $this->get_msg_preview(); break; case 'save-topic': $this->save_topic(); break; case 'dst-autocorrection': $this->dst_autocorrection(); break; case 'check-display-name': $this->check_display_name('members_display_name'); break; case 'check-user-name': $this->check_display_name('name'); break; case 'check-email-address': $this->check_email_address(); break; case 'post-edit-show': $this->post_edit_show(); break; case 'post-edit-save': $this->post_edit_save(); break; } } /*-------------------------------------------------------------------------*/ // Check email address /*-------------------------------------------------------------------------*/ function check_email_address() { //----------------------------------------- // INIT //----------------------------------------- $email = $this->ipsclass->parse_clean_value( rawurldecode( $_REQUEST['email'] ) ); //----------------------------------------- // Try query... //----------------------------------------- $this->ipsclass->DB->build_query( array( 'select' => "email,id", 'from' => 'members', 'where' => "LOWER(email)='{$email}'", 'limit' => array( 0,1 ) ) ); $this->ipsclass->DB->exec_query(); //----------------------------------------- // Got any results? //----------------------------------------- if ( ! $this->ipsclass->DB->get_num_rows() ) { //----------------------------------------- // Load ban filters //----------------------------------------- $this->ipsclass->DB->simple_construct( array( 'select' => '*', 'from' => 'banfilters' ) ); $this->ipsclass->DB->simple_exec(); while( $r = $this->ipsclass->DB->fetch_row() ) { $banfilters[ $r['ban_type'] ][] = $r['ban_content']; } //----------------------------------------- // Are they banned [EMAIL]? //----------------------------------------- if ( is_array( $banfilters['email'] ) and count( $banfilters['email'] ) ) { foreach ( $banfilters['email'] as $memail ) { $memail = str_replace( "\*", '.*' , preg_quote($memail, "/") ); if ( preg_match( "/$memail/", $email ) ) { $this->return_string('banned'); break; } } } $this->return_string('notfound'); } else { $this->return_string('found'); } } /*-------------------------------------------------------------------------*/ // Check display name /*-------------------------------------------------------------------------*/ function check_display_name( $field='members_display_name' ) { //----------------------------------------- // INIT //----------------------------------------- $name = strtolower( $this->ipsclass->parse_clean_value( trim( rawurldecode( $_REQUEST['name'] ) ) ) ); $id = intval( $_REQUEST['id'] ); # Set member ID $id = $this->ipsclass->member['id'] ? $this->ipsclass->member['id'] : $id; //----------------------------------------- // Remove 'sneaky' spaces //----------------------------------------- if ( $this->ipsclass->vars['strip_space_chr'] ) { // Use hexdec to convert between '0xAD' and chr $name = str_replace( chr(160), ' ', $name ); $name = str_replace( chr(173), ' ', $name ); $name = trim($name); } //----------------------------------------- // Not allowed to select another's log in name //----------------------------------------- if ( $field == 'members_display_name' AND $this->ipsclass->vars['auth_dnames_nologinname'] ) { $check_name = $this->ipsclass->DB->build_and_exec_query( array( 'select' => "{$field}, id", 'from' => 'members', 'where' => "LOWER(name)='{$name}'", 'limit' => array( 0,1 ) ) ); if ( $this->ipsclass->DB->get_num_rows() ) { if ( $id AND $check_name['id'] == $id ) { $this->return_string('notfound'); break; } else { $this->return_string('found'); break; } } } //----------------------------------------- // Not allowed to select another's name //----------------------------------------- $check_name = $this->ipsclass->DB->build_and_exec_query( array( 'select' => "{$field}, id", 'from' => 'members', 'where' => "LOWER({$field})='{$name}'", 'limit' => array( 0,1 ) ) ); if ( $this->ipsclass->DB->get_num_rows() ) { if ( $id AND $check_name['id'] == $id ) { $this->return_string('notfound'); break; } else { $this->return_string('found'); break; } } //----------------------------------------- // Didn't get a result from the DB //----------------------------------------- else { //----------------------------------------- // Load ban filters //----------------------------------------- $this->ipsclass->DB->simple_construct( array( 'select' => '*', 'from' => 'banfilters' ) ); $this->ipsclass->DB->simple_exec(); while( $r = $this->ipsclass->DB->fetch_row() ) { $banfilters[ $r['ban_type'] ][] = $r['ban_content']; } //----------------------------------------- // Are they banned [NAMES]? //----------------------------------------- if ( is_array( $banfilters['name'] ) and count( $banfilters['name'] ) ) { foreach ( $banfilters['name'] as $n ) { if ( $n == "" ) { continue; } $n = preg_replace( "/\*/", '.*' , preg_quote($n, "/") ); if ( preg_match( "/$n/i", $name ) ) { $this->return_string('found'); break; } } } $this->return_string('notfound'); } } /*-------------------------------------------------------------------------*/ // Post Edit Save /*-------------------------------------------------------------------------*/ function post_edit_save() { //print utf8_encode($_POST['Post']);exit; //----------------------------------------- // INIT //----------------------------------------- $pid = intval( $_REQUEST['p'] ); $fid = intval( $_REQUEST['f'] ); $tid = intval( $_REQUEST['t'] ); $md5_check = substr( $this->ipsclass->parse_clean_value( rawurldecode( $_REQUEST['md5check'] ) ), 0, 32 ); $attach_pids = array(); $_POST['Post'] = $this->convert_unicode( $_POST['Post'] ); 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'])]; $_POST['Post'] = html_entity_decode( $_POST['Post'], ENT_NOQUOTES, $this->ipsclass->vars['gb_char_set'] ); } } //----------------------------------------- // Set things right //----------------------------------------- $_POST['std_used'] = 1; $this->ipsclass->input['Post'] = $this->ipsclass->parse_clean_value( $_POST['Post'] ); //----------------------------------------- // Check MD5 //----------------------------------------- if ( $md5_check != $this->ipsclass->return_md5_check() ) { @header( "Content-type: text/plain" ); $this->print_nocache_headers(); print 'error'; exit(); } //----------------------------------------- // Check P|T|FID //----------------------------------------- if ( ! $pid OR ! $tid OR ! $fid ) { @header( "Content-type: text/plain" ); $this->print_nocache_headers(); print 'error'; 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; } //----------------------------------------- // Make sure smilies are parsed //----------------------------------------- $this->ipsclass->input['enableemo'] = $this->post->orig_post['use_emo'] ? 'yes' : ''; $this->ipsclass->input['enablesig'] = $this->post->orig_post['use_sig'] ? 'yes' : ''; $this->ipsclass->input['post_htmlstatus'] = $this->post->orig_post['post_htmlstate']; $this->ipsclass->input['add_edit'] = $this->post->orig_post['append_edit']; $this->ipsclass->input['iconid'] = $this->post->orig_post['icon_id']; $this->ipsclass->input['add_edit'] = ( $this->post->orig_post['append_edit'] OR !$this->ipsclass->member['g_append_edit'] ) ? 1 : 0; //----------------------------------------- // check //----------------------------------------- if ( ! $this->post->orig_post['post'] ) { @header( "Content-type: text/plain" ); $this->print_nocache_headers(); print 'error'; exit(); } //----------------------------------------- // PARSE //----------------------------------------- # 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 .= "

".sprintf($this->ipsclass->lang['edited_by'], $this->post->post['edit_name'], $e_time).""; } 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", $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 //----------------------------------------- $name = $this->ipsclass->parse_clean_value( rawurldecode( $_REQUEST['name'] ) ); $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'] ); } } //-------------------------------------------- // Load extra db cache file //-------------------------------------------- $this->ipsclass->DB->load_cache_file( ROOT_PATH.'sources/sql/'.SQL_DRIVER.'_extra_queries.php', 'sql_extra_queries' ); //----------------------------------------- // Check length //----------------------------------------- if ( strlen( $name ) < 3 ) { $this->return_null(); } //----------------------------------------- // Try query... //----------------------------------------- $this->ipsclass->DB->cache_add_query( 'member_display_name_lookup', array( 'name' => $name, 'field' => 'members_display_name' ), 'sql_extra_queries' ); $this->ipsclass->DB->cache_exec_query(); //----------------------------------------- // Got any results? //----------------------------------------- if ( ! $this->ipsclass->DB->get_num_rows() ) { $this->return_null(); } $names = array(); $ids = array(); while( $r = $this->ipsclass->DB->fetch_row() ) { $names[] = '"'.$r['members_display_name'].'"'; $ids[] = intval($r['id']); } print "returnSearch( '".str_replace( "'", "", $name )."', new Array(".implode( ",", $names )."), new Array(".implode( ",", $ids ).") );"; } /*-------------------------------------------------------------------------*/ // Get new posts /*-------------------------------------------------------------------------*/ function get_new_messages( $return=0 ) { //----------------------------------------- // INIT //----------------------------------------- $count = intval( $_REQUEST['count'] ); $count = $count ? $count : 5; $this->ipsclass->load_template( 'skin_msg' ); $this->ipsclass->load_language( 'lang_msg' ); //----------------------------------------- // Check... //----------------------------------------- if ( ! $this->ipsclass->member['id'] ) { return $this->error_handler(); } //----------------------------------------- // Get message list //----------------------------------------- $this->ipsclass->DB->cache_add_query( 'msg_get_folder_list', array( 'mid' => $this->ipsclass->member['id'], 'vid' => 'in', 'sort' => 'mt_date DESC', 'limita' => 0, 'limitb' => $count ) ); $this->ipsclass->DB->simple_exec(); if ( ! $this->ipsclass->DB->get_num_rows() ) { //$this->error_handler("No messages"); } //----------------------------------------- // Start output //----------------------------------------- while( $r = $this->ipsclass->DB->fetch_row() ) { //----------------------------------------- // We only want 10 rows, but the 11th will // tell us if there are more to come //----------------------------------------- $r['date'] = $this->ipsclass->get_date( $r['mt_date'] , 'TINY', 0, 1 ); $r['icon'] = $r['mt_read'] == 1 ? "" : ""; $r['_mini'] = $this->ipsclass->txt_truncate( $r['mt_title'] , 30 ); $html .= $this->ipsclass->compiled_templates['skin_msg']->xmlout_msgs_row( $r ); } //----------------------------------------- // Check count... //----------------------------------------- if ( ! $return ) { @header( "Content-type: text/plain;charset={$this->ipsclass->vars['gb_char_set']}" ); $this->print_nocache_headers(); print $this->ipsclass->compiled_templates['skin_msg']->xmlout_msgs_wrapper( $html ); exit(); } else { return $this->ipsclass->compiled_templates['skin_msg']->xmlout_msgs_wrapper( $html ); } } /*-------------------------------------------------------------------------*/ // Get new posts /*-------------------------------------------------------------------------*/ function mark_forum_as_read() { //----------------------------------------- // INIT //----------------------------------------- $forum_id = intval( $_REQUEST['fid'] ); $sf = intval( $_REQUEST['sf'] ); //----------------------------------------- // Check... //----------------------------------------- if ( ! $this->ipsclass->member['id'] ) { return $this->error_handler(); } if ( ! $forum_id ) { return $this->error_handler(); } //----------------------------------------- // OK - do the magic!! //----------------------------------------- if ( $sf ) { $children = $this->ipsclass->forums->forums_get_children( $forum_id ); if ( is_array( $children ) and count($children) ) { foreach( $children as $id ) { $this->ipsclass->member['members_forum_markers'][ $id ] = time(); } } } $this->ipsclass->member['members_forum_markers'][ $forum_id ] = time(); $this->ipsclass->DB->do_update( 'members', array( 'members_forum_markers' => addslashes(serialize( $this->ipsclass->member['members_forum_markers'] ) ) ), 'id='.intval($this->ipsclass->member['id']) ); $this->xml_output = $this->xml_header . "\r\n1"; print $this->xml_output; exit(); } /*-------------------------------------------------------------------------*/ // Get new posts /*-------------------------------------------------------------------------*/ function get_new_posts( $return=0 ) { //----------------------------------------- // INIT //----------------------------------------- $count = 0; $st = intval( $_REQUEST['st'] ); $next = 0; $previous = 0; $html = ''; $this->ipsclass->load_template( 'skin_search' ); $this->ipsclass->load_language( 'lang_search' ); //----------------------------------------- // Check... //----------------------------------------- if ( ! $this->ipsclass->member['id'] ) { return $this->error_handler(); } //----------------------------------------- // Get search lib //----------------------------------------- require_once( ROOT_PATH.'sources/action_public/search.php' ); $this->search = new search(); $this->search->ipsclass =& $this->ipsclass; //----------------------------------------- // Do we have any forums to search in? //----------------------------------------- $this->ipsclass->input['forums'] = 'all'; $this->ipsclass->input['CODE'] = 'getnew'; $forums = $this->search->get_searchable_forums(); if ( $forums == "" ) { return $this->error_handler(); } //----------------------------------------- // Work out the "last time" //----------------------------------------- $last_time = $this->ipsclass->member['last_visit']; if ( $this->ipsclass->member['members_markers']['board'] > $last_time ) { $last_time = $this->ipsclass->member['members_markers']['board']; } //----------------------------------------- // Get query //----------------------------------------- $this->ipsclass->DB->simple_construct( array( 'select' => 't.*, t.title as topic_title', 'from' => 'topics t', 'where' => "t.forum_id IN($forums) AND t.last_post > {$last_time} AND t.approved=1 AND t.pinned IN (0,1)", 'order' => "t.last_post DESC", 'limit' => array( $st, 11 ) ) ); $this->ipsclass->DB->simple_exec(); while( $r = $this->ipsclass->DB->fetch_row() ) { //----------------------------------------- // We only want 10 rows, but the 11th will // tell us if there are more to come //----------------------------------------- $count++; if ( $count == 11 ) { break; } $mini_title = $this->ipsclass->txt_truncate( $r['title'] , 30 ); $mini_name = $this->ipsclass->txt_truncate( $r['last_poster_name'] , 25 ); $date = $this->ipsclass->get_date( $r['last_post'], 'TINY', 0, 1 ); $html .= $this->ipsclass->compiled_templates['skin_search']->xmlout_gnp_row($r['tid'], $mini_title, $r['title'], $date ); } //----------------------------------------- // Check count... //----------------------------------------- if ( $count ) { if ( $count > 10 ) { $next = $st + 10; } if ( $st ) { $previous = $st - 10; } } else { $html = "
{$this->ipsclass->lang['xml_nopost']}
"; } if ( ! $return ) { @header( "Content-type: text/plain;charset={$this->ipsclass->vars['gb_char_set']}" ); $this->print_nocache_headers(); print $this->ipsclass->compiled_templates['skin_search']->xmlout_gnp_wrapper( $html, $previous, $next, $st ); exit(); } else { return $this->ipsclass->compiled_templates['skin_search']->xmlout_gnp_wrapper( $html, $previous, $next, $st ); } } /*-------------------------------------------------------------------------*/ // make string XML safe /*-------------------------------------------------------------------------*/ function _make_safe_for_xml( $t ) { return str_replace( '&#39;', ''', htmlspecialchars( $t ) ); } /*-------------------------------------------------------------------------*/ // Error handler /*-------------------------------------------------------------------------*/ function error_handler() { @header( "Content-type: text/xml" ); $this->print_nocache_headers(); $this->xml_output = $this->xml_header."\r\n\r\n"; $this->xml_output .= "Для доступа к этой функции вы обязаны авторизоваться\r\n"; $this->xml_output .= ""; print $this->xml_output; exit(); } /*-------------------------------------------------------------------------*/ // Return NOTHING :o /*-------------------------------------------------------------------------*/ function return_null($val=0) { @header( "Content-type: text/xml" ); $this->print_nocache_headers(); print $this->xml_header."\r\n{$val}"; exit(); } /*-------------------------------------------------------------------------*/ // Return string /*-------------------------------------------------------------------------*/ function return_string($string) { @header( "Content-type: text/plain" ); $this->print_nocache_headers(); print $string; exit(); } /*-------------------------------------------------------------------------*/ // Print no cache headers /*-------------------------------------------------------------------------*/ function print_nocache_headers() { header("HTTP/1.0 200 OK"); header("HTTP/1.1 200 OK"); header("Cache-Control: no-cache, must-revalidate, max-age=0"); header("Expires: 0"); header("Pragma: no-cache"); } /*-------------------------------------------------------------------------*/ // Convert decimal character references to UTF-8 /*-------------------------------------------------------------------------*/ function dec_char_ref_to_utf8($int=0) { $return = ''; if ( $int < 0 ) { return chr(0); } else if ( $int <= 0x007f ) { $return .= chr($int); } else if ( $int <= 0x07ff ) { $return .= chr(0xc0 | ($int >> 6)); $return .= chr(0x80 | ($int & 0x003f)); } else if ( $int <= 0xffff ) { $return .= chr(0xe0 | ($int >> 12)); $return .= chr(0x80 | (($int >> 6) & 0x003f)); $return .= chr(0x80 | ($int & 0x003f)); } else if ( $int <= 0x10ffff ) { $return .= chr(0xf0 | ($int >> 18)); $return .= chr(0x80 | (($int >> 12) & 0x3f)); $return .= chr(0x80 | (($int >> 6) & 0x3f)); $return .= chr(0x80 | ($int & 0x3f)); } else { return chr(0); } return $return; } /*-------------------------------------------------------------------------*/ // Convert Ajax unicode /*-------------------------------------------------------------------------*/ function convert_unicode($t) { if ( strtolower($this->ipsclass->vars['gb_char_set']) == 'utf-8' ) { return preg_replace( '#%u([0-9A-F]{1,4})#ie', "\$this->dec_char_ref_to_utf8(hexdec('\\1'))", utf8_encode($t) ); } else { return preg_replace( '#%u([0-9A-F]{1,4})#ie', "'&#' . hexdec('\\1') . ';'", $t ); } } } ?>