﻿<?php
/**
 *
 * spUcenter
 *
 * 搴风洓UCENTER绯荤粺锛坔ttp://www.comsenz.com/products/ucenter锛夌殑API鎺ュ彛绋嫔簭
 *
 * spUcenter 灏佽浜嗗搴风洓UCENTER绯荤粺API鎺ュ彛鎿崭綔锛屽彲涓哄簲鐢ㄧ▼搴忔彁渚涗互涓嫔姛鑳斤细
 *
 * 鎻愪緵鍚屾鐧诲綍銆侀€€鍑恒€佹敞鍐岀瓑鐩稿叧鎺ュ彛锛屽彲浠ュ疄鐜扮敤鎴蜂竴涓处鍙凤紝鍦ㄤ竴澶勭橱褰曪紝鍏ㄧ珯阃氲銆?
 * 鎻愪緵鐭秷鎭浉鍏虫帴鍙ｏ紝鍙互瀹炵幇鐢ㄦ埛鍦ㄤ笉鍚屽簲鐢ㄦ敹鍙戠煭娑堟伅銆?
 * 鎻愪緵 TAG 鐩稿叧鎺ュ彛锛屽彲浠ュ疄鐜伴€氲绷鍏抽敭璇嶅叧鑱斿悇搴旗敤镄勬暟鎹紝濡傚笘瀛愩€佸晢鍝并€佽棰戯紝浣挎暟鎹鍏冨寲銆?
 * 鎻愪緵 Feed 鐩稿叧鎺ュ彛锛屽彲浠ュ疄鐜拌褰旷敤鎴峰湪鍚勫簲鐢ㄧ殑琛屼负锛屽苟涓斿湪 UCenter Home 绛夊簲鐢ㄦ樉绀恒€?
 * 鎻愪緵濂藉弸鐩稿叧鎺ュ彛锛屽彲浠ュ疄鐜板悇搴旗敤濂藉弸浜掗€氥€?
 * 鎻愪緵绉垎绛栫暐鍏变韩锛屽彲浠ュ疄鐜板悇搴旗敤璁剧疆鐏垫椿镄勭Н鍒嗙瓥鐣ャ€?
 * 鎻愪緵璇嶈杩囨护鏁版嵁鍏变韩锛屽彲浠ュ疄鐜板悇搴旗敤鍏变韩 UCenter 镄勮瘝璇绷婊ゆ暟鎹€?
 * 鎻愪緵 MySQL 鍜?HTTP 涓ょ杩炴帴鐢ㄦ埛涓绩镄勬ā寮忥紝浣夸箣鑳藉皢 UCenter 鍜屽悇搴旗敤鑳界伒娲婚儴缃诧紝鍙互鏄崟鍙版湇锷″櫒锛屼篃鍙互鏄眬鍩熺綉銆佸箍鍩熺綉銆?
 * 阃氱煡澶辫触閲嶅彂链哄埗锛屼负鐢ㄦ埛涓绩涓庡悇搴旗敤浜ゆ崲鏁版嵁鎻愪緵镟村ソ镄勪缭闅溿€?
 * 缂揿瓨銆佹ā鏉裤€佹棩蹇楃瓑链哄埗锛屼缭闅灭郴缁熷湪绋冲畾锛屼紭鍖栫姸镐佷笅杩愯銆?
 *
 */
class spUcenter {
	/**
	 * UCENTER璁剧疆鍙傛暟
	 */
	protected $params = array(
		
		'UC_CLIENT_DIR' => "", // uc_client鏂囦欢澶圭殑鐩綍
		
		'UC_CONNECT' => NULL, 	// 杩炴帴 UCenter 镄勬柟寮? mysql/NULL, 榛樿涓虹┖镞朵负 fscoketopen()
									// mysql 鏄洿鎺ヨ繛鎺ョ殑鏁版嵁搴? 涓轰简鏁堢巼, 寤鸿閲囩敤 mysql
	
		//鏁版嵁搴撶浉鍏?(mysql 杩炴帴镞? 骞朵笖娌℃湁璁剧疆 UC_DBLINK 镞? 闇€瑕侀厤缃互涓嫔彉閲?
		'UC_DBHOST' => 'localhost',	// UCenter 鏁版嵁搴扑富链?
		'UC_DBUSER' => 'root',		// UCenter 鏁版嵁搴撶敤鎴峰悕
		'UC_DBPW'   => '',	// UCenter 鏁版嵁搴揿瘑镰?
		'UC_DBNAME' => 'ucenter',	// UCenter 鏁版嵁搴揿悕绉?
		'UC_DBCHARSET' => 'utf8',			// UCenter 鏁版嵁搴揿瓧绗﹂泦
		'UC_DBTABLEPRE' => 'ucenter.uc_',	// UCenter 鏁版嵁搴撹〃鍓岖紑锛屽姟蹇呮敞镒忥细链€濂藉湪琛ㄥ墠缂€鍓嶅姞涓婂簱鍚?
	
		//阃氢俊鐩稿叧
		'UC_KEY' => '123456789', 				// 涓?UCenter 镄勯€氢俊瀵嗛挜, 瑕佷笌 UCenter 淇濇寔涓€镊?
		'UC_API' => 'http://yourwebsite/uc_server', 	// UCenter 镄?URL 鍦板潃, 鍦ㄨ皟鐢ㄥご镀忔椂渚濊禆姝ゅ父閲?
		'UC_CHARSET' => 'utf8', 	// UCenter 镄勫瓧绗﹂泦
		'UC_IP'  => '',  // UCenter 镄?IP, 褰?UC_CONNECT 涓洪潪 mysql 鏂瑰纺镞? 骞朵笖褰揿墠搴旗敤链嶅姟鍣ㄨВ鏋?
		'UC_APPID' => 1 					// 褰揿墠搴旗敤镄?ID
	);

	/**
	 * 鏋勯€犲嚱鏁帮紝灏嗗鐞哢CENTER杞藉叆绛夋搷浣?
	 */
	public function __construct()
	{
		$params = ( false != spExt("spUcenter") ) ? array_merge($this->params, spExt("spUcenter")) : $this->params;
		$params['UC_CLIENT_DIR'] = ("" != $params['UC_CLIENT_DIR']) ? $params['UC_CLIENT_DIR'] : SP_PATH."/Extensions/uc_client";

		define('UC_CONNECT', $params['UC_CONNECT']);
		define('UC_DBHOST', $params['UC_DBHOST']);
		define('UC_DBUSER', $params['UC_DBUSER']);				
		define('UC_DBPW', $params['UC_DBPW']);					
		define('UC_DBNAME', $params['UC_DBNAME']);	
		define('UC_DBCHARSET', $params['UC_DBCHARSET']);
		define('UC_DBTABLEPRE', $params['UC_DBTABLEPRE']);		
		
		define('UC_KEY', $params['UC_KEY']);
		define('UC_API', $params['UC_API']);
		define('UC_CHARSET', $params['UC_CHARSET']);
		define('UC_IP', $params['UC_IP']);	
		define('UC_APPID', $params['UC_APPID']);
		
		import(rtrim($params['UC_CLIENT_DIR'], '/\\') . "/client.php");
	}

	/**
	 * 
	 * @param func    璋幂敤鍑芥暟鍚?
	 * @param args    鍙傛暟
	 */
	public function __call($func, $args)
	{
		if( 'uc_' == substr($func, 0, 3) &&  function_exists($func) ){
			return call_user_func_array ( $func, $args);
		}
		spError('镞犳硶镓惧埌璇ユ柟娉曪紝璇锋煡阒呮湰镓╁睍鍙奤CENTER镄勭浉鍏虫坠鍐?);
	}
}
?>
