head	1.2;
access;
symbols;
locks; strict;
comment	@# @;


1.2
date	2004.12.05.03.17.52;	author comfuture;	state Exp;
branches;
next	1.1;

1.1
date	2004.11.24.12.25.15;	author comfuture;	state Exp;
branches;
next	;


desc
@@


1.2
log
@3ȸ ڵ佺Ʈ ۾
@
text
@<?php
/* vim: set expandtab tabstop=4 shiftwidth=4 foldmethod=marker: */
/**
* 파일명: RPC/index.php
* 작성일: 2004-10-25
* 작성자: 거친마루
* 설  명: XML_RPC 서버 (뉴스전용)
*****************************************************************
* 
*/

require_once "XML/RPC/Server.php";
header('Content-type: text/xml');

$SERVER = new XML_RPC_Server(
	array(
		'server.list' => array('function'=>'server_list'),
		'news.summery' => array('function' => 'news_summery')
	),
	true
);

// {{{ Methods

function server_list($params) {
	return new XML_RPC_Response(
		XML_RPC_encode(array(
			'server1.simin.h-9.net', 'server2.simin.h-9.net', 'server3.simin.h-9.net'
		))
	);
}

function news_summery($params) {
	require_once "lib/class.DB.php";
	$DB = DB::Connection(getConnectionString());
	$DB->config['fetch_mode'] = MYSQL_ASSOC;

	$data = $DB->sqlFetchAll("
		SELECT
			idx, reg_date date, title, content
		FROM
			simin_news
		ORDER BY
			reg_date DESC
		LIMIT 3
	",MYSQL_ASSOC);
	@@array_walk($data,'cb_format_news');
	$response = new XML_RPC_Response(XML_RPC_encode($data));
	return $response;
}

/**
* string getConnectionString(void)
* 
* 설정파일에서 db connection을 만들어 리턴합니다.
* 
*/
function getConnectionString($dsn='default') {
	$conf = @@parse_ini_file('conf/database.conf.php',true);
	$str = $conf[$dsn]['dbms'].'://'.$conf[$dsn]['user'].':'.$conf[$dsn]['pass'].'@@'.$conf[$dsn]['host'].'/'.$conf[$dsn]['db'];
	return $str;
}

//==-- callbacks --==//
function cb_format_news(&$arr) {
	$arr['url'] = 'http://simin.h-9.net/?act=news.read&id='.$arr['idx'];
	$arr['content'] = preg_replace(
		array('/\s+/',chr(0xa0)),
		array(' ',''),
		strip_tags($arr['content'])
	);
	unset($arr['idx']);	// cleanup junk keys..
}

// }}}
?>
@


1.1
log
@ù Ʈ
@
text
@d36 1
d67 6
a72 3
	$arr['content'] = preg_replace('/\s+/',' ',strip_tags($arr['content']));
//	$arr['content'] = mb_substr($arr['content'],0,10);
	unset($arr['0'],$arr['1'],$arr['2'],$arr['3'],$arr['idx']);	// cleanup junk keys..
d74 1
@

