Blog, Nucleus: 뉴클리어스 실시간 대화 플러그인

다음 글에 트랙백핑을 보냈습니다.
hof’옹께서 소개하신 “워드프레스 실시간 대화 플러그인 AJAX Shoutbox plugin”을 뉴클리어스 플러그인으로 변환해 보았습니다. 동작하는 모습은 우측 상단을 참고하세요.

테스트해 보시려면 “NP_ShoutBox.zip”을 다운로드하여 nucleus/plugins 디렉토리에 풀어 넣고 관리화면에서 플러그인을 등록한 다음, 스킨에 <%ShoutBox%>를 추가하면 됩니다.
다음은 NP_ShoutBox.php 의 전체 소스입니다.
jal_getData( $lastID );
		} else {
			// some weird conversion of the data inputed
			$jal_chat_name = str_replace( "\'", "'", $jal_chat_name );
			$jal_chat_name = str_replace( "'", "\'", $jal_chat_name );
			$jal_user_text = str_replace( "\'", "'", $jal_user_text );
			$jal_user_text = str_replace( "'", "\'", $jal_user_text );
			$jal_user_text = str_replace( "---", " - - ", $jal_user_text );
			$jal_chat_name = str_replace( "---", " - - ", $jal_chat_name );
			
			// the message is cut of after 500 letters
			$jal_user_text = shorten( $jal_user_text, 100, "..." );

			// to allow for linebreaks a space is inserted every 40 letters
			$jal_user_text = preg_replace( "/([^\s]{40})/",
				"$1 ", $jal_user_text);
			
			// the name is shortened to 30 letters
			$jal_chat_name = shorten( $jal_chat_name, 20, "..." );

			// only if a name and a message have been provides
			// the information is added to the db
			if ( $jal_chat_name != '' && $jal_user_text != ''
				&& $value == "yes" ) {
				//adds new data to the database
				$this->jal_addData( $jal_chat_name, $jal_user_text );
				//some database maintenance
				$this->jal_getID( 40 );
			}
		} // end of if-else
	} // end of function

	// skin vars
	function doSkinVar( $skinType ) {
		global $CONF, $member;

		$this->draw_form();
	}

	function draw_form() {
		global $member, $CONF;
?>



  • Loading...
realname != "" ) { echo "\n";/* If they are logged in, then print their nickname */ ?>




" . $lastID . " ORDER BY id ASC LIMIT 50" ); while ( $r = mysql_fetch_object( $res ) ) { $chat_user_name = $r->name; $chat_user_text = $r->text; $chat_user_id = $r->id; // --- is being used to separate the fields in the output echo $chat_user_id . " ---" . $chat_user_name . " ---" . $chat_user_text . " ---"; } } // end of jal_getData // adds new data to the database function jal_addData( $jal_chat_name, $jal_user_text ) { sql_query( "INSERT INTO " . sql_table( "plugin_shoutbox" ) . " ( time, name, text ) VALUES (NOW(),'" . $jal_chat_name . "','" . $jal_user_text . "')" ); } // end of jal_addData //returns the id of a message at a certain position function jal_getID( $position ) { $res = sql_query( "SELECT * FROM " . sql_table( "plugin_shoutbox" ) . " ORDER BY id DESC LIMIT " . $position . ",1" ); while ( $r = mysql_fetch_object( $res ) ) { $id = $r->id; } if ( $id ) { //deletes all message prior to a certain id $this->jal_deleteEntries( $id ); } } // end of jal_getID //deletes all message prior to a certain id function jal_deleteEntries( $id ) { sql_query( "DELETE FROM " . sql_table( "plugin_shoutbox" ) . " WHERE id < " . $id ); } // end of jal_deleteEntries } ?>
**추가**
ShoutBox 디렉토리 안에 들어 있는 fatAjax.php는 두 개의 자바스크립트를 출력하기 위한 스크립트입니다.
  • The Fade Anything Technique”: 페이드인 효과를 위한 자바스크립트로서 원본 소스를 그대로 사용합니다.
  • XHTML live Chat”: XHttpRequest를 사용하여 실제 채팅데이터의 입출력을 담당합니다. GetChaturl, SendChaturl의 경로와 insertNewContent() 함수를 약간 수정하였습니다.
***추가***
  • 시간도 출력되도록 수정. span태그의 title 속성 이용함.

인쇄 |

 

trackback pings

  1. 이 글에 걸린 트랙백이 없습니다.
트랙백을 보내려면 이 트랙백 URL을 복사하여 사용하세요. 당신의 블로그가 트랙백 기능을 지원하지 않는다면, 수동으로 트랙백 보내기를 이용해 보세요.


Powered by Nucleus Emacs, Bad Behavior.
Just Copyleft!