<?php
/*
[UCenter] (C)2001-2009 Comsenz Inc.
This is NOT a freeware, use is subject to license terms
$Id: client.php 864 2008-12-11 05:06:20Z monkey $
*/
if(!defined('UC_API')) {
exit('Access denied');
}
error_reporting(0);
define('IN_UC', TRUE);
define('UC_CLIENT_VERSION', '1.5.0');
define('UC_CLIENT_RELEASE', '20081212');
define('UC_ROOT', substr(__FILE__, 0, -10)); //note 用户中心客户端的根目录 UC_CLIENTROOT
define('UC_DATADIR', UC_ROOT.'./data/'); //note 用户中心的数据缓存目录
define('UC_DATAURL', UC_API.'/data'); //note 用户中心的数据 URL
define('UC_API_FUNC', UC_CONNECT == 'mysql' ? 'uc_api_mysql' : 'uc_api_post');
$GLOBALS['uc_controls'] = array();
function uc_addslashes($string, $force = 0, $strip = FALSE) {
!defined('MAGIC_QUOTES_GPC') && define('MAGIC_QUOTES_GPC', get_magic_quotes_gpc());
if(!MAGIC_QUOTES_GPC || $force) {
if(is_array($string)) {
foreach($string as $key => $val) {
$string[$key] = uc_addslashes($val, $force, $strip);
}
} else {
$string = addslashes($strip ? stripslashes($string) : $string);
}
}
return $string;
}
if(!function_exists('daddslashes')) {
function daddslashes($string, $force = 0) {
return uc_addslashes($string, $force);
}
}
function uc_stripslashes($string) {
!defined('MAGIC_QUOTES_GPC') && define('MAGIC_QUOTES_GPC', get_magic_quotes_gpc());
if(MAGIC_QUOTES_GPC) {
return stripslashes($string);
} else {
return $string;
}
}
/**
* dfopen 方式取指定的模块和动作的数据
*
* @param string $module 请求的模块
* @param string $action 请求的动作
* @param array $arg 参数(会加密的方式传送)
* @return string
*/
function uc_api_post($module, $action, $arg = array()) {
$s = $sep = '';
foreach($arg as $k => $v) {
$k = urlencode($k);
if(is_array($v)) {
$s2 = $sep2 = '';
foreach($v as $k2 => $v2) {
$k2 = urlencode($k2);
$s2 .= "$sep2{$k}[$k2]=".urlencode(uc_stripslashes($v2));
$sep2 = '&';
}
$s .= $sep.$s2;
} else {
$s .= "$sep$k=".urlencode(uc_stripslashes($v));
}
$sep = '&';
}
$postdata = uc_api_requestdata($module, $action, $s);
return uc_fopen2(UC_API.'/index.php', 500000, $postdata, '', TRUE, UC_IP, 20);
}
/**
* 构造发送给用户中心的请求数据
*
* @param string $module 请求的模块
* @param string $action 请求的动作
* @param string $arg 参数(会加密的方式传送)
* @param string $extra 附加参数(传送时不加密)
* @return string
*/
function uc_api_requestdata($module, $action, $arg='', $extra='') {
$input = uc_api_input($arg);
$post = "m=$module&a=$action&inajax=2&release=".UC_CLIENT_RELEASE."&input=$input&appid=".UC_APPID.$extra;
return $post;
}
function uc_api_url($module, $action, $arg='', $extra='') {
$url = UC_API.'/index.php?'.uc_api_requestdata($module, $action, $arg, $extra);
return $url;
}
function uc_api_input($data) {
$s = urlencode(uc_authcode($data.'&agent='.md5($_SERVER['HTTP_USER_AGENT'])."&time=".time(), 'ENCODE', UC_KEY));
return $s;
}
/**
* MYSQL 方式取指定的模块和动作的数据
*
* @param string $model 请求的模块
* @param string $action 请求的动作
* @param string $args 参数(会加密的方式传送)
* @return mix
*/
function uc_api_mysql($model, $action, $args=array()) {
global $uc_controls;
if(empty($uc_controls[$model])) {
include_once UC_ROOT.'./lib/db.class.php';
include_once UC_ROOT.'./model/base.php';
include_once UC_ROOT."./control/$model.php";
eval("\$uc_controls['$model'] = new {$model}control();");
}
if($action{0} != '_') {
$args = uc_addslashes($args, 1, TRUE);
$action = 'on'.$action;
$uc_controls[$model]->input = $args;
return $uc_controls[$model]->$action($args);
} else {
return '';
}
}
function uc_serialize($arr, $htmlon = 0) {
include_once UC_ROOT.'./lib/xml.class.php';
return xml_serialize($arr, $htmlon);
}
function uc_unserialize($s) {
include_once UC_ROOT.'./lib/xml.class.php';
return xml_unserialize($s);
}
/**
* 字符串加密以及解密函数
*
* @param string $string 原文或者密文
* @param string $operation 操作(ENCODE | DECODE), 默认为 DECODE
* @param string $key 密钥
* @param int $expiry 密文有效期, 加密时候有效, 单位 秒,0 为永久有效
* @return string 处理后的 原文或者 经过 base64_encode 处理后的密文
*
* @example
*
* $a = authcode('abc', 'ENCODE', 'key');
* $b = authcode($a, 'DECODE', 'key'); // $b(abc)
*
* $a = authcode('abc', 'ENCODE', 'key', 3600);
* $b = authcode('abc', 'DECODE', 'key'); // 在一个小时内,$b(abc),否则 $b 为空
*/
function uc_authcode($string, $operation = 'DECODE', $key = '', $expiry = 0) {
$ckey_length = 4; //note 随机密钥长度 取值 0-32;
//note 加入随机密钥,可以令密文无任何规律,即便是原文和密钥完全相同,加密结果也会每次不同,增大破解难度。
//note 取值越大,密文变动规律越大,密文变化 = 16 的 $ckey_length 次方
//note 当此值为 0 时,则不产生随机密钥
$key = md5($key ? $key : UC_KEY);
$keya = md5(substr($key, 0, 16));
$keyb = md5(substr($key, 16, 16));
$keyc = $ckey_length ? ($operation == 'DECODE' ? substr($string, 0, $ckey_length): substr(md5(microtime()), -$ckey_length)) : '';
$cryptkey = $keya.md5($keya.$keyc);
$key_length = strlen($cryptkey);
$string = $operation == 'DECODE' ? base64_decode(substr($string, $ckey_length)) : sprintf('%010d', $expiry ? $expiry + time() : 0).substr(md5($string.$keyb), 0, 16).$string;
$string_length = strlen($string);
$result = '';
$box = range(0, 255);
$rndkey = array();
for($i = 0; $i <= 255; $i++) {
$rndkey[$i] = ord($cryptkey[$i % $key_length]);
}
for($j = $i = 0; $i < 256; $i++) {
$j = ($j + $box[$i] + $rndkey[$i]) % 256;
$tmp = $box[$i];
$box[$i] = $box[$j];
$box[$j] = $tmp;
}
for($a = $j = $i = 0; $i < $string_length; $i++) {
$a = ($a + 1) % 256;
$j = ($j + $box[$a]) % 256;
$tmp = $box[$a];
$box[$a] = $box[$j];
$box[$j] = $tmp;
$result .= chr(ord($string[$i]) ^ ($box[($box[$a] + $box[$j]) % 256]));
}
if($operation == 'DECODE') {
if((substr($result, 0, 10) == 0 || substr($result, 0, 10) - time() > 0) && substr($result, 10, 16) == substr(md5(substr($result, 26).$keyb), 0, 16)) {
return substr($result, 26);
} else {
return '';
}
} else {
return $keyc.str_replace('=', '', base64_encode($result));
}
}
/**
* 远程打开URL
* @param string $url 打开的url, 如 http://www.baidu.com/123.htm
* @param int $limit 取返回的数据的长度
* @param string $post 要发送的 POST 数据,如uid=1&password=1234
* @param string $cookie 要模拟的 COOKIE 数据,如uid=123&auth=a2323sd2323
* @param bool $bysocket TRUE/FALSE 是否通过SOCKET打开
* @param string $ip IP地址
* @param int $timeout 连接超时时间
* @param bool $block 是否为阻塞模式
* @return 取到的字符串
*/
function uc_fopen2($url, $limit = 0, $post = '', $cookie = '', $bysocket = FALSE, $ip = '', $timeout = 15, $block = TRUE) {
$__times__ = isset($_GET['__times__']) ? intval($_GET['__times__']) + 1 : 1;
if($__times__ > 2) {
return '';
}
$url .= (strpos($url, '?') === FALSE ? '?' : '&')."__times__=$__times__";
return uc_fopen($url, $limit, $post, $cookie, $bysocket, $ip, $timeout, $block);
}
function uc_fopen($url, $limit = 0, $post = '', $cookie = '', $bysocket = FALSE, $ip = '', $timeout = 15, $block = TRUE) {
$return = '';
$matches = parse_url($url);
!isset($matches['host']) && $matches['host'] = '';
!isset($matches['path']) && $matches['path'] = '';
!isset($matches['query']) && $matches['query'] = '';
!isset($matches['port']) && $matches['port'] = '';
$host = $matches['host'];
$path = $matches['path'] ? $matches['path'].($matches['query'] ? '?'.$matches['query'] : '') : '/';
$port = !empty($matches['port']) ? $matches['port'] : 80;
if($post) {
$out = "POST $path HTTP/1.0\r\n";
$out .= "Accept: */*\r\n";
//$out .= "Referer: $boardurl\r\n";
$out .= "Accept-Language: zh-cn\r\n
没有合适的资源?快使用搜索试试~ 我知道了~
其目的是提供最新最全的 UCenter 接口函数索引,方便开发基于 UCenter 的应用程序。
共120个文件
php:39个
htm:34个
gif:33个
4星 · 超过85%的资源 需积分: 14 39 下载量 26 浏览量
2009-11-21
11:12:08
上传
评论
收藏 257KB ZIP 举报
温馨提示
本手册针对的是有一定网页程序开发制作经验的读者。 其目的是提供最新最全的 UCenter 接口函数索引,方便开发基于 UCenter 的应用程序。 为了方便开发者手册中包含了样例程序。
资源推荐
资源详情
资源评论
收起资源包目录
其目的是提供最新最全的 UCenter 接口函数索引,方便开发基于 UCenter 的应用程序。 (120个子文件)
style.css 7KB
style.css 7KB
Thumbs.db 25KB
Thumbs.db 25KB
intro.gif 15KB
intro.gif 15KB
helplogo.gif 5KB
helplogo.gif 5KB
menubg.gif 1KB
menubg.gif 1KB
codeicon.gif 407B
codeicon.gif 407B
citeicon.gif 333B
citeicon.gif 333B
bg_repx.gif 314B
bg_repx.gif 314B
shrink.gif 313B
shrink.gif 313B
spread.gif 309B
spread.gif 309B
headbg.gif 170B
headbg.gif 170B
bg_repy.gif 167B
bg_repy.gif 167B
error.gif 158B
error.gif 158B
correct.gif 147B
correct.gif 147B
navbg.gif 104B
navbg.gif 104B
listicon.gif 82B
listicon.gif 82B
close.gif 76B
wrapbg.gif 53B
wrapbg.gif 53B
arrowr.gif 52B
arrowr.gif 52B
user.htm 22KB
user.htm 22KB
pm.htm 21KB
pm.htm 21KB
api.htm 20KB
api.htm 20KB
feed.htm 8KB
feed.htm 8KB
friend.htm 6KB
friend.htm 6KB
avatar.htm 5KB
avatar.htm 5KB
structure.htm 4KB
structure.htm 4KB
tag.htm 3KB
tag.htm 3KB
example.htm 3KB
example.htm 3KB
mail.htm 3KB
mail.htm 3KB
credit.htm 2KB
credit.htm 2KB
index.htm 2KB
index.htm 2KB
app.htm 2KB
app.htm 2KB
function.htm 2KB
function.htm 2KB
index.htm 1B
index.htm 1B
index.htm 1B
index.htm 1B
index.htm 0B
index.htm 0B
avatar.jpg 30KB
avatar.jpg 30KB
common.js 3KB
common.js 3KB
ucexample.js 3KB
header.js 402B
header.js 402B
footer.js 219B
footer.js 219B
client.php 30KB
pm.php 16KB
uc.php 10KB
user.php 9KB
pm.php 8KB
note.php 8KB
base.php 7KB
user.php 7KB
mail.php 6KB
uccode.class.php 5KB
sendmail.inc.php 5KB
db.class.php 4KB
misc.php 4KB
feed.php 4KB
pmlist.php 4KB
friend.php 3KB
db_mysql.class.php 3KB
xml.class.php 3KB
ucexample_2.php 3KB
register_db.php 2KB
共 120 条
- 1
- 2
资源评论
- wuqingxue2013-08-24挺好,整理的很详细
- ViRecall2013-10-19样例程序接口蛮全的,不错
- kongyuanyuanko2012-10-03样例程序接口蛮全的,不错
- jim12122014-03-08不错,挺齐全的。谢谢分享
- 小黄叫啥呢2013-02-24很好的,对于discuz论坛涞水很好的资料
这份情你不在乎
- 粉丝: 41
- 资源: 72
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功