code
stringlengths 1
2.01M
| repo_name
stringlengths 3
62
| path
stringlengths 1
267
| language
stringclasses 231
values | license
stringclasses 13
values | size
int64 1
2.01M
|
|---|---|---|---|---|---|
<?php
defined('IN_ADMIN') or exit('No permission resources.');
include $this->admin_tpl('header', 'admin');
?>
<div class="pad-10">
<form method="post" action="?m=announce&c=admin_announce&a=add" name="myform" id="myform">
<table class="table_form" width="100%" cellspacing="0">
<tbody>
<tr>
<th width="80"><strong><?php echo L('announce_title')?></strong></th>
<td><input name="announce[title]" id="title" class="input-text" type="text" size="50" ></td>
</tr>
<tr>
<th><strong><?php echo L('startdate')?>:</strong></th>
<td><?php echo form::date('announce[starttime]', date('Y-m-d H:i:s'), 1)?></td>
</tr>
<tr>
<th><strong><?php echo L('enddate')?>:</strong></th>
<td><?php echo form::date('announce[endtime]', $an_info['endtime'], 1);?></td>
</tr>
<tr>
<th><strong><?php echo L('announce_content')?></strong></th>
<td><textarea name="announce[content]" id="content"></textarea><?php echo form::editor('content');?></td>
</tr>
<tr>
<th><strong><?php echo L('available_style')?>:</strong></th>
<td>
<?php echo form::select($template_list, $info['default_style'], 'name="announce[style]" id="style" onchange="load_file_list(this.value)"', L('please_select'))?>
</td>
</tr>
<tr>
<th><strong><?php echo L('template_select')?>:</strong></th>
<td id="show_template"><script type="text/javascript">$.getJSON('?m=admin&c=category&a=public_tpl_file_list&style=<?php echo $info['default_style']?>&module=announce&templates=show&name=announce&pc_hash='+pc_hash, function(data){$('#show_template').html(data.show_template);});</script></td>
</tr>
<tr>
<th><strong><?php echo L('announce_status')?></strong></th>
<td><input name="announce[passed]" type="radio" value="1" checked> <?php echo L('pass')?> <input name="announce[passed]" type="radio" value="0"> <?php echo L('unpass')?></td>
</tr>
</tbody>
</table>
<input type="submit" name="dosubmit" id="dosubmit" value=" <?php echo L('ok')?> " class="dialog"> <input type="reset" class="dialog" value=" <?php echo L('clear')?> ">
</form>
</div>
</body>
</html>
<script type="text/javascript">
function load_file_list(id) {
if (id=='') return false;
$.getJSON('?m=admin&c=category&a=public_tpl_file_list&style='+id+'&module=announce&templates=show&name=announce&pc_hash='+pc_hash, function(data){$('#show_template').html(data.show_template);});
}
$(document).ready(function(){
$.formValidator.initConfig({formid:"myform",autotip:true,onerror:function(msg,obj){window.top.art.dialog({content:msg,lock:true,width:'220',height:'70'}, function(){this.close();$(obj).focus();})}});
$('#title').formValidator({onshow:"<?php echo L('input_announce_title')?>",onfocus:"<?php echo L('title_min_3_chars')?>",oncorrect:"<?php echo L('right')?>"}).inputValidator({min:1,onerror:"<?php echo L('title_cannot_empty')?>"}).ajaxValidator({type:"get",url:"",data:"m=announce&c=admin_announce&a=public_check_title",datatype:"html",cached:false,async:'true',success : function(data) {
if( data == "1" )
{
return true;
}
else
{
return false;
}
},
error: function(){alert("<?php echo L('server_no_data')?>");},
onerror : "<?php echo L('announce_exist')?>",
onwait : "<?php echo L('checking')?>"
});
$('#starttime').formValidator({onshow:"<?php echo L('select_stardate')?>",onfocus:"<?php echo L('select_stardate')?>",oncorrect:"<?php echo L('right_all')?>"});
$('#endtime').formValidator({onshow:"<?php echo L('select_downdate')?>",onfocus:"<?php echo L('select_downdate')?>",oncorrect:"<?php echo L('right_all')?>"});
$("#content").formValidator({autotip:true,onshow:"",onfocus:"<?php echo L('announcements_cannot_be_empty')?>"}).functionValidator({
fun:function(val,elem){
//获取编辑器中的内容
var oEditor = CKEDITOR.instances.content;
var data = oEditor.getData();
if(data==''){
return "<?php echo L('announcements_cannot_be_empty')?>"
} else {
return true;
}
}
});
$('#style').formValidator({onshow:"<?php echo L('select_style')?>",onfocus:"<?php echo L('select_style')?>",oncorrect:"<?php echo L('right_all')?>"}).inputValidator({min:1,onerror:"<?php echo L('select_style')?>"});
});
</script>
|
108wo
|
phpcms/modules/announce/templates/announce_add.tpl.php
|
PHP
|
asf20
| 4,298
|
<?php
defined('IN_ADMIN') or exit('No permission resources.');
include $this->admin_tpl('header', 'admin');
?>
<div class="pad-10">
<form method="post" action="?m=announce&c=admin_announce&a=edit&aid=<?php echo $_GET['aid']?>" name="myform" id="myform">
<table class="table_form" width="100%">
<tbody>
<tr>
<th width="80"><?php echo L('announce_title')?></th>
<td><input name="announce[title]" id="title" value="<?php echo htmlspecialchars($an_info['title'])?>" class="input-text" type="text" size="50" ></td>
</tr>
<tr>
<th><?php echo L('startdate')?>:</th>
<td><?php echo form::date('announce[starttime]', $an_info['starttime'], 1)?></td>
</tr>
<tr>
<th><?php echo L('enddate')?>:</th>
<td><?php $an_info['endtime'] = $an_info['endtime']=='0000-00-00' ? '' : $an_info['endtime']; echo form::date('announce[endtime]', $an_info['endtime'], 1);?></td>
</tr>
<tr>
<th><?php echo L('announce_content')?></th>
<td >
<textarea name="announce[content]" id="content"><?php echo $an_info['content']?></textarea>
<?php echo form::editor('content','basic');?>
</td>
</tr>
<tr>
<th><strong><?php echo L('available_style')?>:</strong></th>
<td><?php echo form::select($template_list, $an_info['style'], 'name="announce[style]" id="style" onchange="load_file_list(this.value)"', L('please_select'))?></td>
</tr>
<tr>
<th><?php echo L('template_select')?>:</th>
<td id="show_template"><?php if ($an_info['style']) echo '<script type="text/javascript">$.getJSON(\'?m=admin&c=category&a=public_tpl_file_list&style='.$an_info['style'].'&id='.$an_info['show_template'].'&module=announce&templates=show&name=announce&pc_hash=\'+pc_hash, function(data){$(\'#show_template\').html(data.show_template);});</script>'?></td>
</tr>
<tr>
<th><?php echo L('announce_status')?></th>
<td><input name="announce[passed]" type="radio" value="1" <?php if($an_info['passed']==1) {?>checked<?php }?>></input> <?php echo L('pass')?> <input name="announce[passed]" type="radio" value="0" <?php if($an_info['passed']==0) {?>checked<?php }?>> <?php echo L('unpass')?></td>
</tr>
</tbody>
</table>
<input type="submit" name="dosubmit" id="dosubmit" value=" <?php echo L('ok')?> " class="dialog"> <input type="reset" class="dialog" value=" <?php echo L('clear')?> ">
</form>
</div>
</body>
</html>
<script type="text/javascript">
function load_file_list(id) {
$.getJSON('?m=admin&c=category&a=public_tpl_file_list&style='+id+'&module=announce&templates=show&name=announce&pc_hash='+pc_hash, function(data){$('#show_template').html(data.show_template);});
}
$(document).ready(function(){
$.formValidator.initConfig({formid:"myform",autotip:true,onerror:function(msg,obj){window.top.art.dialog({content:msg,lock:true,width:'220',height:'70'}, function(){this.close();$(obj).focus();})}});
$('#title').formValidator({onshow:"<?php echo L('input_announce_title')?>",onfocus:"<?php echo L('title_min_3_chars')?>",oncorrect:"<?php echo L('right')?>"}).inputValidator({min:1,onerror:"<?php echo L('title_cannot_empty')?>"}).ajaxValidator({type:"get",url:"",data:"m=announce&c=admin_announce&a=public_check_title&aid=<?php echo $_GET['aid']?>",datatype:"html",cached:false,async:'true',success : function(data) {
if( data == "1" )
{
return true;
}
else
{
return false;
}
},
error: function(){alert("<?php echo L('server_no_data')?>");},
onerror : "<?php echo L('announce_exist')?>",
onwait : "<?php echo L('checking')?>"
}).defaultPassed();
$('#starttime').formValidator({onshow:"<?php echo L('select_stardate')?>",onfocus:"<?php echo L('select_stardate')?>",oncorrect:"<?php echo L('right_all')?>"}).defaultPassed();
$('#endtime').formValidator({onshow:"<?php echo L('select_downdate')?>",onfocus:"<?php echo L('select_downdate')?>",oncorrect:"<?php echo L('right_all')?>"}).defaultPassed();
$("#content").formValidator({autotip:true,onshow:"",onfocus:"<?php echo L('announcements_cannot_be_empty')?>"}).functionValidator({
fun:function(val,elem){
//获取编辑器中的内容
var oEditor = CKEDITOR.instances.content;
var data = oEditor.getData();
if(data==''){
return "<?php echo L('announcements_cannot_be_empty')?>"
} else {
return true;
}
}
}).defaultPassed();
$('#style').formValidator({onshow:"<?php echo L('select_style')?>",onfocus:"<?php echo L('select_style')?>",oncorrect:"<?php echo L('right_all')?>"}).inputValidator({min:1,onerror:"<?php echo L('select_style')?>"}).defaultPassed();
});
</script>
|
108wo
|
phpcms/modules/announce/templates/announce_edit.tpl.php
|
PHP
|
asf20
| 4,644
|
<?php
defined('IN_PHPCMS') or exit('No permission resources.');
class index {
function __construct() {
$this->db = pc_base::load_model('announce_model');
}
public function init() {
}
/**
* 展示公告
*/
public function show() {
if(!isset($_GET['aid'])) {
showmessage(L('illegal_operation'));
}
$_GET['aid'] = intval($_GET['aid']);
$where = '';
$where .= "`aid`='".$_GET['aid']."'";
$where .= " AND `passed`='1' AND (`endtime` > '".date('Y-m-d')."' or `endtime`='0000-00-00')";
$r = $this->db->get_one($where);
if($r['aid']) {
$this->db->update(array('hits'=>'+=1'), array('aid'=>$r['aid']));
$template = $r['show_template'] ? $r['show_template'] : 'show';
extract($r);
$SEO = seo(get_siteid(), '', $title);
include template('announce', $template, $r['style']);
} else {
showmessage(L('no_exists'));
}
}
}
?>
|
108wo
|
phpcms/modules/announce/index.php
|
PHP
|
asf20
| 906
|
<?php
/**
*
* 公告类
*
*/
defined('IN_PHPCMS') or exit('No permission resources.');
class announce_tag {
private $db;
public function __construct() {
$this->db = pc_base::load_model('announce_model');
}
/**
* 公告列表方法
* @param array $data 传递过来的参数
* @param return array 数据库中取出的数据数组
*/
public function lists($data) {
$where = '1';
$siteid = $data['siteid'] ? intval($data['siteid']) : get_siteid();
if ($siteid) $where .= " AND `siteid`='".$siteid."'";
$where .= ' AND `passed`=\'1\' AND (`endtime` > \''.date('Y-m-d').'\' or `endtime`=\'0000-00-00\')';
return $this->db->select($where, '*', $data['limit'], 'aid DESC');
}
public function count() {
}
/**
* pc标签初始方法
*/
public function pc_tag() {
//获取站点
$sites = pc_base::load_app_class('sites','admin');
$sitelist = $sites->pc_tag_list();
$result = getcache('special', 'commons');
if(is_array($result)) {
$specials = array(L('please_select', '', 'announce'));
foreach($result as $r) {
if($r['siteid']!=get_siteid()) continue;
$specials[$r['id']] = $r['title'];
}
}
return array(
'action'=>array('lists'=>L('lists', '', 'announce')),
'lists'=>array(
'siteid'=>array('name'=>L('sitename', '', 'announce'),'htmltype'=>'input_select', 'defaultvalue'=>get_siteid(), 'data'=>$sitelist),
),
);
}
}
?>
|
108wo
|
phpcms/modules/announce/classes/announce_tag.class.php
|
PHP
|
asf20
| 1,466
|
<?php
defined('IN_PHPCMS') or exit('Access Denied');
defined('INSTALL') or exit('Access Denied');
return array('announce');
?>
|
108wo
|
phpcms/modules/announce/install/model.php
|
PHP
|
asf20
| 133
|
{template 'content', 'header'}
<!--main-->
<div class="main">
<div class="col-left">
<div class="crumbs"><a href="">首页</a><span> > </span><a href="">公告</a></div>
<div id="Article">
<h1>{$title}<br />
<span></span></h1>
<div class="content">
{$content}
</div>
</div>
</div>
<div class="col-auto">
<div class="box pd_b0">
{pc:comment action="bang" cache="3600"}
<ul class="itemli">
{loop $data $r}
<li><a href="{$r[url]}" target="_blank">{str_cut($r[title], 26)}</a></li>
{/loop}
</ul>
{/pc}
</div>
</div>
</div>
{template 'content', 'footer'}
|
108wo
|
phpcms/modules/announce/install/templates/show.html
|
HTML
|
asf20
| 699
|
<?php
defined('IN_PHPCMS') or exit('Access Denied');
defined('INSTALL') or exit('Access Denied');
$parentid = $menu_db->insert(array('name'=>'announce', 'parentid'=>29, 'm'=>'announce', 'c'=>'admin_announce', 'a'=>'init', 'data'=>'s=1', 'listorder'=>0, 'display'=>'1'), true);
$menu_db->insert(array('name'=>'announce_add', 'parentid'=>$parentid, 'm'=>'announce', 'c'=>'admin_announce', 'a'=>'add', 'data'=>'', 'listorder'=>0, 'display'=>'0'));
$menu_db->insert(array('name'=>'edit_announce', 'parentid'=>$parentid, 'm'=>'announce', 'c'=>'admin_announce', 'a'=>'edit', 'data'=>'s=1', 'listorder'=>0, 'display'=>'0'));
$menu_db->insert(array('name'=>'check_announce', 'parentid'=>$parentid, 'm'=>'announce', 'c'=>'admin_announce', 'a'=>'init', 'data'=>'s=2', 'listorder'=>0, 'display'=>'1'));
$menu_db->insert(array('name'=>'overdue', 'parentid'=>$parentid, 'm'=>'announce', 'c'=>'admin_announce', 'a'=>'init', 'data'=>'s=3', 'listorder'=>0, 'display'=>'1'));
$menu_db->insert(array('name'=>'del_announce', 'parentid'=>$parentid, 'm'=>'announce', 'c'=>'admin_announce', 'a'=>'delete', 'data'=>'', 'listorder'=>0, 'display'=>'0'));
$language = array('announce'=>'公告', 'announce_add'=>'添加公告', 'edit_announce'=>'编辑公告', 'check_announce'=>'审核公告', 'overdue'=>'过期公告', 'del_announce'=>'删除公告');
?>
|
108wo
|
phpcms/modules/announce/install/extention.inc.php
|
PHP
|
asf20
| 1,345
|
<?php
defined('IN_PHPCMS') or exit('Access Denied');
defined('INSTALL') or exit('Access Denied');
$module = 'announce';
$modulename = '公告';
$introduce = '独立模块';
$author = 'phpcms Team';
$authorsite = 'http://www.phpcms.cn';
$authoremail = '';
?>
|
108wo
|
phpcms/modules/announce/install/config.inc.php
|
PHP
|
asf20
| 269
|
<?php
/*Language Format:
Add a new file(.lang.php) with your module name at /phpcms/languages/
translation save at the array:$LANG
*/
$LANG['announce'] = '公告';
$LANG['announce_manage'] = '公告管理';
$LANG['announce_list'] = '公告列表';
$LANG['announce_add'] = '添加公告';
$LANG['announce_title'] = '公告标题:';
$LANG['title_cannot_empty'] = '公告标题不能为空';
$LANG['announcements_cannot_be_empty'] = '公告内容不能为空';
$LANG['announcement_successful_added'] = '公告添加成功';
$LANG['announced_a'] = '公告修改成功';
$LANG['announce_passed'] = '公告批量通过完成!';
$LANG['announce_deleted'] = '公告批量删除完成!';
$LANG['startdate'] = '起始日期';
$LANG['enddate'] = '截止日期';
$LANG['announce_content'] = '公告内容:';
$LANG['announce_status'] = '公告状态:';
$LANG['edit_announce'] = '编辑公告';
$LANG['inputer'] = '录入者';
$LANG['check_annonuce'] = '审核公告';
$LANG['preview'] = '前台预览';
$LANG['index'] = '前台';
$LANG['cancel_all_selected'] = '取消批准选定的公告';
$LANG['pass_all_selected'] = '通过选定的公告';
$LANG['remove_all_selected'] = '删除选定的公告';
$LANG['overdue_announce'] = '过期公告';
$LANG['no_pass_announce'] = '未审核公告';
$LANG['no_exists'] = '此公告不存在或已删除!';
$LANG['affirm_delete'] = '您确定要删除吗?';
$LANG['input_announce_title'] = '请输入公告标题!';
$LANG['title_min_3_chars'] = '公告标题至少3个汉字以上';
$LANG['right'] = '输入正确!';
$LANG['server_no_data'] = '服务器没有返回数据,可能服务器忙,请重试';
$LANG['announce_exist'] = '该公告已存在';
$LANG['checking'] = '正进行合法性校验...';
$LANG['select_stardate'] = '请选择开始时间!';
$LANG['right_all'] = '正确!';
$LANG['select_downdate'] = '请选择下线时间!';
$LANG['select_style'] = '请选择风格!';
$LANG['available_style'] = '可用风格';
$LANG['lists'] = '列表';
$LANG['sitename'] = '站点';
?>
|
108wo
|
phpcms/modules/announce/install/languages/zh-cn/announce.lang.php
|
PHP
|
asf20
| 2,230
|
<?php
defined('IN_ADMIN') or exit('No permission resources.');
include $this->admin_tpl('header', 'admin');
?>
<div class="pad-lr-10">
<div class="explain-col">
<?php echo L('attachment_address_replace_msg')?>
</div>
<form action="index.php?m=attachment&c=address&a=update" method="post" onsubmit="return confirm('<?php echo L('form_submit_confirm');?>')">
<table width="100%" class="table_form">
<tr>
<th width="100"><?php echo L('old_attachment_address')?>:</th>
<td class="y-bg"><input type="text" class="input-text" name="old_attachment_path" id="old_attachment_path" size="40" value="" /> <?php echo L('old_attachment_address_msg')?></td>
</tr>
<tr>
<th><?php echo L('new_attachment_address')?>:</th>
<td class="y-bg"><input type="text" class="input-text" name="new_attachment_path" id="new_attachment_path" size="40" value="<?php echo pc_base::load_config('system', 'upload_url')?>" /></td>
</tr>
<tr>
<th></th>
<td class="y-bg"><input type="submit" value="<?php echo L('submit')?>" class="button"></td>
</tr>
</table>
</form>
</div>
</body>
</html>
<script type="text/javascript">
<!--
//-->
</script>
|
108wo
|
phpcms/modules/attachment/templates/address.tpl.php
|
PHP
|
asf20
| 1,183
|
<?php
defined('IN_ADMIN') or exit('No permission resources.');
include $this->admin_tpl('header', 'admin');
?>
<style type="text/css">
.attachment-list{ width:480px}
.attachment-list .cu{dispaly:block;float:right; background:url(statics/images/admin_img/cross.png) no-repeat 0px 100%;width:20px; height:16px; overflow:hidden;}
.attachment-list li{ width:120px; padding:0 20px 10px; float:left}
</style>
<div class="pad-10">
<ul class="attachment-list">
<?php foreach($thumbs as $thumb) {
?>
<li>
<img src="<?php echo $thumb['thumb_url']?>" alt="<?php echo $thumb['width']?> X <?php echo $thumb['height']?>" width="120" />
<span class="cu" title="<?php echo L('delete')?>" onclick="thumb_delete('<?php echo urlencode($thumb['thumb_filepath'])?>',this)"></span>
<?php echo $thumb['width']?> X <?php echo $thumb['height']?>
</li>
<?php } ?>
</ul>
</div>
<script type="text/javascript">
<!--
function thumb_delete(filepath,obj){
window.top.art.dialog({content:'<?php echo L('del_confirm')?>', fixed:true, style:'confirm', id:'att_delete'},
function(){
$.get('?m=attachment&c=manage&a=pullic_delthumbs&filepath='+filepath+'&pc_hash=<?php echo $_SESSION[pc_hash]?>',function(data){
if(data == 1) $(obj).parent().fadeOut("slow");
})
},
function(){});
};
//-->
</script>
</html>
|
108wo
|
phpcms/modules/attachment/templates/attachment_thumb.tpl.php
|
PHP
|
asf20
| 1,383
|
<?php
defined('IN_ADMIN') or exit('No permission resources.');
$show_header = $show_validator = $show_scroll = 1;
include $this->admin_tpl('header', 'admin');
?>
<link href="<?php echo JS_PATH?>swfupload/swfupload.css" rel="stylesheet" type="text/css" />
<form name="myform" action="" method="get" >
<input type="hidden" value="attachment" name="m">
<input type="hidden" value="attachments" name="c">
<input type="hidden" value="album_load" name="a">
<input type="hidden" value="<?php echo $file_upload_limit?>" name="info[file_upload_limit]">
<div class="lh26" style="padding:10px 0 0">
<label><?php echo L('name')?></label>
<input type="text" value="" class="input-text" name="info[filename]">
<label><?php echo L('date')?></label>
<?php echo form::date('info[uploadtime]')?>
<input type="submit" value="<?php echo L('search')?>" class="button" name="dosubmit">
</div>
</form>
<div class="bk20 hr"></div>
<ul class="attachment-list" id="fsUploadProgress">
<?php foreach($infos as $r) {?>
<li>
<div class="img-wrap">
<a href="javascript:;" onclick="javascript:album_cancel(this,'<?php echo $r['aid']?>','<?php echo $this->upload_url.$r['filepath']?>')"><div class="icon"></div><img src="<?php echo $r['src']?>" width="<?php echo $r['width']?>" path="<?php echo $this->upload_url.$r['filepath']?>" title="<?php echo $r['filename']?>"/></a>
</div>
</li>
<?php } ?>
</ul>
<div id="pages" class="text-c"> <?php echo $pages?></div>
<script type="text/javascript">
$(document).ready(function(){
set_status_empty();
});
function set_status_empty(){
parent.window.$('#att-status').html('');
parent.window.$('#att-name').html('');
}
function album_cancel(obj,id,source){
var src = $(obj).children("img").attr("path");
var filename = $(obj).children("img").attr("title");
if($(obj).hasClass('on')){
$(obj).removeClass("on");
var imgstr = parent.window.$("#att-status").html();
var length = $("a[class='on']").children("img").length;
var strs = filenames = '';
$.get('index.php?m=attachment&c=attachments&a=swfupload_json_del&aid='+id+'&src='+source);
for(var i=0;i<length;i++){
strs += '|'+$("a[class='on']").children("img").eq(i).attr('path');
filenames += '|'+$("a[class='on']").children("img").eq(i).attr('title');
}
parent.window.$('#att-status').html(strs);
parent.window.$('#att-name').html(filenames);
} else {
var num = parent.window.$('#att-status').html().split('|').length;
var file_upload_limit = '<?php echo $file_upload_limit?>';
if(num > file_upload_limit) {alert('不能选择超过'+file_upload_limit+'个附件'); return false;}
$(obj).addClass("on");
$.get('index.php?m=attachment&c=attachments&a=swfupload_json&aid='+id+'&src='+source);
parent.window.$('#att-status').append('|'+src);
parent.window.$('#att-name').append('|'+filename);
}
}
</script>
|
108wo
|
phpcms/modules/attachment/templates/album_list.tpl.php
|
PHP
|
asf20
| 2,882
|
<?php
defined('IN_ADMIN') or exit('No permission resources.');
$show_header = $show_scroll = 1;
include $this->admin_tpl('header','admin');
?>
<link href="<?php echo JS_PATH?>swfupload/swfupload.css" rel="stylesheet" type="text/css" />
<script language="JavaScript" src="<?php echo JS_PATH?>jquery.imgpreview.js"></script>
<script type="text/javascript">
$(document).ready(function(){
var obj=$("#imgPreview a[rel]");
if(obj.length>0) {
$('#imgPreview a[rel]').imgPreview({
srcAttr: 'rel',
imgCSS: { width: 200 }
});
}
});
</script>
<div class="pad-lr-10">
<div class="table-list">
<table width="100%" cellspacing="0" id="imgPreview">
<tr>
<td align="left"><?php echo L("local_dir")?>:<?php echo $local?></td>
</tr>
<?php if ($dir !='' && $dir != '.'):?>
<tr>
<td align="left"><a href="<?php echo '?m=attachment&c=attachments&a=album_dir&dir='.stripslashes(dirname($dir))?>"><img src="<?php echo IMG_PATH?>folder-closed.gif" /><?php echo L("parent_directory")?></td></a>
</tr>
<?php endif;?>
<?php
if(is_array($list)):
foreach($list as $v):
$filename = basename($v);
?>
<tr>
<?php if (is_dir($v)) {
echo '<td align="left"><img src="'.IMG_PATH.'folder-closed.gif" /> <a href="?m=attachment&c=attachments&a=album_dir&dir='.(isset($_GET['dir']) && !empty($_GET['dir']) ? stripslashes($_GET['dir']).'/' : '').$filename.'"><b>'.$filename.'</b></a></td>';
} else {
echo '<td align="left" onclick="javascript:album_cancel(this)"><img src="'.file_icon($filename,'gif').'" /> <a href="javascript:;" rel="'.$url.$filename.'" title="'.$filename.'">'.$filename.'</a></td>';
}?>
</tr>
<?php
endforeach;
endif;
?>
</table>
</div>
</div>
</body>
<script type="text/javascript">
$(document).ready(function(){
set_status_empty();
});
function set_status_empty(){
parent.window.$('#att-status').html('');
parent.window.$('#att-name').html('');
}
function album_cancel(obj){
var src = $(obj).children("a").attr("rel");
var filename = $(obj).children("a").attr("title");
if($(obj).hasClass('on')){
$(obj).removeClass("on");
var imgstr = parent.window.$("#att-status").html();
var length = $("a[class='on']").children("a").length;
var strs = filenames = '';
for(var i=0;i<length;i++){
strs += '|'+$("a[class='on']").children("a").eq(i).attr('rel');
filenames += '|'+$("a[class='on']").children("a").eq(i).attr('title');
}
parent.window.$('#att-status').html(strs);
parent.window.$('#att-name').html(filenames);
} else {
var num = parent.window.$('#att-status').html().split('|').length;
var file_upload_limit = '<?php echo $file_upload_limit?>';
$(obj).addClass("on");
parent.window.$('#att-status').append('|'+src);
parent.window.$('#att-name').append('|'+filename);
}
}
</script>
</html>
|
108wo
|
phpcms/modules/attachment/templates/album_dir.tpl.php
|
PHP
|
asf20
| 2,824
|
<?php
defined('IN_ADMIN') or exit('No permission resources.');
include $this->admin_tpl('header', 'admin');
?>
<script type="text/javascript" src="<?php echo JS_PATH?>jquery.sgallery.js"></script>
<div class="pad-lr-10">
<form name="searchform" action="" method="get" >
<input type="hidden" value="attachment" name="m">
<input type="hidden" value="manage" name="c">
<input type="hidden" value="init" name="a">
<table width="100%" cellspacing="0" class="search-form">
<tbody>
<tr>
<td><div class="explain-col"><?php echo L('name')?> <input type="text" value="<?php echo $filename?>" class="input-text" name="info[filename]"> <?php echo L('uploadtime')?> <?php echo form::date('info[start_uploadtime]',$start_uploadtime)?><?php echo L('to')?> <?php echo form::date('info[end_uploadtime]',$end_uploadtime)?> <?php echo L('filetype')?> <input type="text" value="<?php echo $fileext?>" class="input-text" name="info[fileext]"> <input type="submit" value="<?php echo L('search')?>" class="button" name="dosubmit"> <a href="?m=attachment&c=manage&a=dir&menuid=<?php echo $_GET['menuid']?>"><?php echo L('dir_schema')?></a>
</div>
</td>
</tr>
</tbody>
</table>
</form>
<div class="table-list">
<form name="myform" action="?m=admin&c=role&a=listorder" method="post" id="myform">
<table width="100%" cellspacing="0">
<thead>
<tr>
<th width="10%"><?php echo L('delete')?></th>
<th width="5%">ID</th>
<th width="8%" ><?php echo L('moudle')?>
<div class="tab-use">
<div style="position:relative">
<div class="arrows cu" onmouseover="hoverUse('module-div');" onmouseout="hoverUse();" onmouseover="this.style.display='block'"></div>
<ul id="module-div" class="tab-web-panel" onmouseover="this.style.display='block'" onmouseout="hoverUse('module-div');" style="height:150px; width:100px; text-align:left; overflow-y:scroll;">
<?php foreach ($modules as $module) {
if(in_array($module['module'], array('pay','digg','search','scan','attachment','block','dbsource','template','release','cnzz','comment','mood'))) continue;
echo '<li><a href='.url_par('dosubmit=1&module='.$module['module']).'>'.$module['name'].'</a></li>';
}?>
</ul>
</div>
</div>
</th>
<th width="8%" ><?php echo L('catname')?></th>
<th width="20%"><?php echo L('filename')?>
<div class="tab-use">
<div style="position:relative">
<div class="arrows cu" onmouseover="hoverUse('use-div');" onmouseout="hoverUse();" onmouseover="this.style.display='block'"></div>
<ul id="use-div" class="tab-web-panel" onmouseover="this.style.display='block'" onmouseout="hoverUse('use-div');">
<li><a href="<?php echo url_par('dosubmit=1&status=0')?>"><?php echo L('not_used')?></a></li>
<li><a href="<?php echo url_par('dosubmit=1&status=1')?>"><?php echo L('used')?></a></li>
</ul>
</div>
</div></th>
<th width="10%" ><?php echo L('filesize')?></th>
<th width="20%" ><?php echo L('uploadtime')?></th>
<th width="15%" ><?php echo L('operations_manage')?></th>
</tr>
</thead>
<tbody>
<?php
if(is_array($infos)){
foreach($infos as $info){
$thumb = glob(dirname($this->upload_path.$info['filepath']).'/thumb_*'.basename($info['filepath']));
?>
<tr>
<td width="10%" align="center"><input type="checkbox" name="aid[]" value="<?php echo $info['aid']?>" id="att_<?php echo $info['aid']?>" /></td>
<td width="5%" align="center"><?php echo $info['aid']?></td>
<td width="8%" align="center"><?php echo $modules[$info['module']]['name']?></td>
<td width="8%" align="center"><?php echo $category[$info['catid']]['catname']?></td>
<td width="20%"><img src="<?php echo file_icon($info['filename'],'gif')?>" /> <?php echo $info['filename']?> <?php echo $thumb ? '<img title="'.L('att_thumb_manage').'" src="statics/images/admin_img/havthumb.png" onclick="showthumb('.$info['aid'].', \''.new_addslashes($info['filename']).'\')"/>':''?> <?php echo $info['status'] ? '<img src="statics/images/admin_img/link.png"':''?></td>
<td width="10%" align="center"><?php echo $this->attachment->size($info['filesize'])?></td>
<td width="12%" align="center"><?php echo date('Y-m-d H:i:s',$info['uploadtime'])?></td>
<td align="center"><a href="javascript:preview(<?php echo $info['aid']?>, '<?php echo $info['filename']?>','<?php echo $this->upload_url.$info['filepath']?>')"><?php echo L('preview')?></a> | <a href="javascript:;" onclick="att_delete(this,'<?php echo $info['aid']?>')"><?php echo L('delete')?></a></td>
</tr>
<?php
}
}
?>
</tbody>
</table>
<div class="btn"><a href="#" onClick="javascript:$('input[type=checkbox]').attr('checked', true)"><?php echo L('selected_all')?></a>/<a href="#" onClick="javascript:$('input[type=checkbox]').attr('checked', false)"><?php echo L('cancel')?></a> <input type="submit" class="button" name="dosubmit" value="<?php echo L('delete')?>" onClick="document.myform.action='?m=attachment&c=manage&a=public_delete_all';return confirm('<?php echo L('del_confirm')?>')"/></div>
<div id="pages"> <?php echo $pages?></div>
</form>
</div>
</div>
</body>
</html>
<script type="text/javascript">
<!--
window.top.$('#display_center_id').css('display','none');
function preview(id, name,filepath) {
if(IsImg(filepath)) {
window.top.art.dialog({title:'<?php echo L('preview')?>',fixed:true, content:'<img src="'+filepath+'" onload="$(this).LoadImage(true, 500, 500,\'<?php echo IMG_PATH?>s_nopic.gif\');"/>'});
} else {
window.top.art.dialog({title:'<?php echo L('preview')?>',fixed:true, content:'<a href="'+filepath+'" target="_blank"/><img src="<?php echo IMG_PATH?>admin_img/down.gif"><?php echo L('click_open')?></a>'});
}
}
function att_delete(obj,aid){
window.top.art.dialog({content:'<?php echo L('del_confirm')?>', fixed:true, style:'confirm', id:'att_delete'},
function(){
$.get('?m=attachment&c=manage&a=delete&aid='+aid+'&pc_hash=<?php echo $_SESSION['pc_hash']?>',function(data){
if(data == 1) $(obj).parent().parent().fadeOut("slow");
})
},
function(){});
};
function showthumb(id, name) {
window.top.art.dialog({title:'<?php echo L('att_thumb_manage')?>--'+name, id:'edit', iframe:'?m=attachment&c=manage&a=pullic_showthumbs&aid='+id ,width:'500px',height:'400px'});
}
function hoverUse(target){
if($("#"+target).css("display") == "none"){
$("#"+target).show();
}else{
$("#"+target).hide();
}
}
function IsImg(url){
var sTemp;
var b=false;
var opt="jpg|gif|png|bmp|jpeg";
var s=opt.toUpperCase().split("|");
for (var i=0;i<s.length ;i++ ){
sTemp=url.substr(url.length-s[i].length-1);
sTemp=sTemp.toUpperCase();
s[i]="."+s[i];
if (s[i]==sTemp){
b=true;
break;
}
}
return b;
}
//-->
</script>
|
108wo
|
phpcms/modules/attachment/templates/attachment_list.tpl.php
|
PHP
|
asf20
| 7,047
|
<?php $show_header = $show_validator = $show_scroll = 1; include $this->admin_tpl('header', 'admin');?>
<link href="<?php echo JS_PATH?>swfupload/swfupload.css" rel="stylesheet" type="text/css" />
<script language="JavaScript" type="text/javascript" src="<?php echo JS_PATH?>swfupload/swfupload.js"></script>
<script language="JavaScript" type="text/javascript" src="<?php echo JS_PATH?>swfupload/fileprogress.js"></script>
<script language="JavaScript" type="text/javascript" src="<?php echo JS_PATH?>swfupload/handlers.js"></script>
<script type="text/javascript">
<?php echo initupload($_GET['module'],$_GET['catid'],$args,$this->userid,$this->groupid,$this->isadmin)?>
</script>
<div class="pad-10">
<div class="col-tab">
<ul class="tabBut cu-li">
<li id="tab_swf_1" <?php echo $tab_status?> onclick="SwapTab('swf','on','',5,1);"><?php echo L('upload_attachment')?></li>
<li id="tab_swf_2" onclick="SwapTab('swf','on','',5,2);"><?php echo L('net_file')?></li>
<?php if($allowupload && $this->admin_username && $_SESSION['userid']) {?>
<li id="tab_swf_3" onclick="SwapTab('swf','on','',5,3);set_iframe('album_list','index.php?m=attachment&c=attachments&a=album_load&args=<?php echo $args?>');"><?php echo L('gallery')?></li>
<li id="tab_swf_4" onclick="SwapTab('swf','on','',5,4);set_iframe('album_dir','index.php?m=attachment&c=attachments&a=album_dir&args=<?php echo $args?>');"><?php echo L('directory_browse')?></li>
<?php }?>
<?php if($att_not_used!='') {?>
<li id="tab_swf_5" class="on icon" onclick="SwapTab('swf','on','',5,5);"><?php echo L('att_not_used')?></li>
<?php }?>
</ul>
<div id="div_swf_1" class="content pad-10 <?php echo $div_status?>">
<div>
<div class="addnew" id="addnew">
<span id="buttonPlaceHolder"></span>
</div>
<input type="button" id="btupload" value="<?php echo L('start_upload')?>" onClick="swfu.startUpload();" />
<div id="nameTip" class="onShow"><?php echo L('upload_up_to')?><font color="red"> <?php echo $file_upload_limit?></font> <?php echo L('attachments')?>,<?php echo L('largest')?> <font color="red"><?php echo $file_size_limit?></font></div>
<div class="bk3"></div>
<div class="lh24"><?php echo L('supported')?> <font style="font-family: Arial, Helvetica, sans-serif"><?php echo str_replace(array('*.',';'),array('','、'),$file_types)?></font> <?php echo L('formats')?></div><input type="checkbox" id="watermark_enable" value="1" <?php if(isset($watermark_enable) &&$watermark_enable == 1) echo 'checked'?> onclick="change_params()"> <?php echo L('watermark_enable')?>
</div>
<div class="bk10"></div>
<fieldset class="blue pad-10" id="swfupload">
<legend><?php echo L('lists')?></legend>
<ul class="attachment-list" id="fsUploadProgress">
</ul>
</fieldset>
</div>
<div id="div_swf_2" class="contentList pad-10 hidden">
<div class="bk10"></div>
<?php echo L('enter_address')?><div class="bk3"></div><input type="text" name="info[filename]" class="input-text" value="" style="width:350px;" onblur="addonlinefile(this)">
<div class="bk10"></div>
</div>
<?php if($allowupload && $this->admin_username && $_SESSION['userid']) {?>
<div id="div_swf_3" class="contentList pad-10 hidden">
<ul class="attachment-list">
<iframe name="album-list" src="#" frameborder="false" scrolling="no" style="overflow-x:hidden;border:none" width="100%" height="345" allowtransparency="true" id="album_list"></iframe>
</ul>
</div>
<div id="div_swf_4" class="contentList pad-10 hidden">
<ul class="attachment-list">
<iframe name="album-dir" src="#" frameborder="false" scrolling="auto" style="overflow-x:hidden;border:none" width="100%" height="330" allowtransparency="true" id="album_dir"></iframe>
</ul>
</div>
<?php }?>
<?php if($att_not_used!='') {?>
<div id="div_swf_5" class="contentList pad-10">
<div class="explain-col"><?php echo L('att_not_used_desc')?></div>
<ul class="attachment-list" id="album">
<?php if(is_array($att) && !empty($att)){ foreach ($att as $_v) {?>
<li>
<div class="img-wrap">
<a onclick="javascript:album_cancel(this,<?php echo $_v['aid']?>,'<?php echo $_v['src']?>')" href="javascript:;" class="off" title="<?php echo $_v['filename']?>"><div class="icon"></div><img width="<?php echo $_v['width']?>" path="<?php echo $_v['src']?>" src="<?php echo $_v['fileimg']?>" title="<?php echo $_v['filename']?>"></a>
</div>
</li>
<?php }}?>
</ul>
</div>
<?php }?>
<div id="att-status" class="hidden"></div>
<div id="att-status-del" class="hidden"></div>
<div id="att-name" class="hidden"></div>
<!-- swf -->
</div>
</body>
<script type="text/javascript">
if ($.browser.mozilla) {
window.onload=function(){
if (location.href.indexOf("?rand=")<0) {
location.href=location.href+"?rand="+Math.random();
}
}
}
function imgWrap(obj){
$(obj).hasClass('on') ? $(obj).removeClass("on") : $(obj).addClass("on");
}
function SwapTab(name,cls_show,cls_hide,cnt,cur) {
for(i=1;i<=cnt;i++){
if(i==cur){
$('#div_'+name+'_'+i).show();
$('#tab_'+name+'_'+i).addClass(cls_show);
$('#tab_'+name+'_'+i).removeClass(cls_hide);
}else{
$('#div_'+name+'_'+i).hide();
$('#tab_'+name+'_'+i).removeClass(cls_show);
$('#tab_'+name+'_'+i).addClass(cls_hide);
}
}
}
function addonlinefile(obj) {
var strs = $(obj).val() ? '|'+ $(obj).val() :'';
$('#att-status').html(strs);
}
function change_params(){
if($('#watermark_enable').attr('checked')) {
swfu.addPostParam('watermark_enable', '1');
} else {
swfu.removePostParam('watermark_enable');
}
}
function set_iframe(id,src){
$("#"+id).attr("src",src);
}
function album_cancel(obj,id,source){
var src = $(obj).children("img").attr("path");
var filename = $(obj).attr('title');
if($(obj).hasClass('on')){
$(obj).removeClass("on");
var imgstr = $("#att-status").html();
var length = $("a[class='on']").children("img").length;
var strs = filenames = '';
$.get('index.php?m=attachment&c=attachments&a=swfupload_json_del&aid='+id+'&src='+source+'&filename='+filename);
for(var i=0;i<length;i++){
strs += '|'+$("a[class='on']").children("img").eq(i).attr('path');
filenames += '|'+$("a[class='on']").children("img").eq(i).attr('title');
}
$('#att-status').html(strs);
$('#att-status').html(filenames);
} else {
var num = $('#att-status').html().split('|').length;
var file_upload_limit = '<?php echo $file_upload_limit?>';
if(num > file_upload_limit) {alert('<?php echo L('attachment_tip1')?>'+file_upload_limit+'<?php echo L('attachment_tip2')?>'); return false;}
$(obj).addClass("on");
$.get('index.php?m=attachment&c=attachments&a=swfupload_json&aid='+id+'&src='+source+'&filename='+filename);
$('#att-status').append('|'+src);
$('#att-name').append('|'+filename);
}
}
</script>
</html>
|
108wo
|
phpcms/modules/attachment/templates/swfupload.tpl.php
|
PHP
|
asf20
| 7,350
|
<?php
defined('IN_ADMIN') or exit('No permission resources.');
include $this->admin_tpl('header','admin');
?>
<script language="JavaScript" src="<?php echo JS_PATH?>jquery.imgpreview.js"></script>
<script type="text/javascript">
$(document).ready(function(){
var obj=$("#imgPreview a[rel]");
if(obj.length>0) {
$('#imgPreview a[rel]').imgPreview({
srcAttr: 'rel',
imgCSS: { width: 200 }
});
}
});
</script>
<div class="bk15"></div>
<div class="pad-lr-10">
<table width="100%" cellspacing="0" class="search-form">
<tbody>
<tr>
<td><div class="explain-col">
<a href="?m=attachment&c=manage"><?php echo L('database_schema')?></a>
</div>
</td>
</tr>
</tbody>
</table>
<div class="table-list">
<table width="100%" cellspacing="0" id="imgPreview">
<tr>
<td align="left"><?php echo L("local_dir")?>:<?php echo $local?></td><td></td>
</tr>
<?php if ($dir !='' && $dir != '.'):?>
<tr>
<td align="left"><a href="<?php echo '?m=attachment&c=manage&a=dir&dir='.stripslashes(dirname($dir))?>"><img src="<?php echo IMG_PATH?>folder-closed.gif" /><?php echo L("parent_directory")?></a></td><td></td>
</tr>
<?php endif;?>
<?php
if(is_array($list)) {
foreach($list as $v) {
$filename = basename($v)
?>
<tr>
<?php if (is_dir($v)) {
echo '<td align="left"><img src="'.IMG_PATH.'folder-closed.gif" /> <a href="?m=attachment&c=manage&a=dir&dir='.(isset($_GET['dir']) && !empty($_GET['dir']) ? stripslashes($_GET['dir']).'/' : '').$filename.'"><b>'.$filename.'</b></a></td><td width="10%"></td>';
} else {
echo '<td align="left" ><img src="'.file_icon($filename,'gif').'" /><a rel="'.$local.'/'.$filename.'">'.$filename.'</a></td><td width="10%"><a href="javascript:;" onclick="preview(\''.$local.'/'.$filename.'\')">'.L('preview').'</a> | <a href="javascript:;" onclick="att_delete(this,\''.urlencode($filename).'\',\''.urlencode($local).'\')">'.L('delete').'</a> </td>';
}?>
</tr>
<?php
}
}
?>
</table>
</div>
</div>
</body>
<script type="text/javascript">
function preview(filepath) {
if(IsImg(filepath)) {
window.top.art.dialog({title:'<?php echo L('preview')?>',fixed:true, content:'<img src="'+filepath+'" />',time:8});
} else {
window.top.art.dialog({title:'<?php echo L('preview')?>',fixed:true, content:'<a href="'+filepath+'" target="_blank"/><img src="<?php echo IMG_PATH?>admin_img/down.gif"><?php echo L('click_open')?></a>'});
}
}
function att_delete(obj,filename,localdir){
window.top.art.dialog({content:'<?php echo L('del_confirm')?>', fixed:true, style:'confirm', id:'att_delete'},
function(){
$.get('?m=attachment&c=manage&a=pulic_dirmode_del&filename='+filename+'&dir='+localdir,function(data){
if(data) $(obj).parent().parent().fadeOut("slow");
})
},
function(){});
};
function IsImg(url){
var sTemp;
var b=false;
var opt="jpg|gif|png|bmp|jpeg";
var s=opt.toUpperCase().split("|");
for (var i=0;i<s.length ;i++ ){
sTemp=url.substr(url.length-s[i].length-1);
sTemp=sTemp.toUpperCase();
s[i]="."+s[i];
if (s[i]==sTemp){
b=true;
break;
}
}
return b;
}
</script>
</html>
|
108wo
|
phpcms/modules/attachment/templates/attachment_dir.tpl.php
|
PHP
|
asf20
| 3,206
|
<?php $show_header = $show_validator = $show_scroll = 1; include $this->admin_tpl('header', 'admin');?>
<link href="<?php echo JS_PATH?>swfupload/swfupload.css" rel="stylesheet" type="text/css" />
<script language="JavaScript" type="text/javascript" src="<?php echo JS_PATH?>swfupload/swfupload.js"></script>
<script language="JavaScript" type="text/javascript" src="<?php echo JS_PATH?>swfupload/fileprogress.js"></script>
<script language="JavaScript" type="text/javascript" src="<?php echo JS_PATH?>swfupload/handlers.js"></script>
<script type="text/javascript">
var swfu = '';
$(document).ready(function(){
swfu = new SWFUpload({
flash_url:"<?php echo JS_PATH; ?>swfupload/swfupload.swf?"+Math.random(),
upload_url:"<?php echo APP_PATH; ?>index.php?m=attachment&c=attachments&a=batchUpload&dosubmit=1&pc_hash=<?php echo $this->pc_hash; ?>",
file_post_name : "Filedata",
post_params:{"SWFUPLOADSESSID":"<?php echo SYS_TIME; ?>","module":"content","catid":"<?php echo $category['catid'];?>","userid":"<?php echo $this->userid;?>","username":"<?php echo $this->admin_username; ?>","siteid":"<?php echo $siteid;?>","dosubmit":"1","thumb_width":"0","thumb_height":"0","watermark_enable":"0","filetype_post":"jpg|jpeg|gif|png|bmp","swf_auth_key":"<?php echo md5(pc_base::load_config('system','auth_key').SYS_TIME);?>","isadmin":"<?php echo $this->isadmin;?>","groupid":"<?php echo $this->groupid;?>","bids":""},
file_size_limit:"2048",
file_types:"*.jpg;*.jpeg;*.gif;*.png;*.bmp",
file_types_description:"All Files",
file_upload_limit:"100",
custom_settings : {progressTarget : "fsUploadProgress",cancelButtonId : "btnCancel"},
button_image_url: "",
button_width: 75,
button_height: 28,
button_placeholder_id: "buttonPlaceHolder",
button_text_style: "",
button_text_top_padding: 3,
button_text_left_padding: 12,
button_window_mode: SWFUpload.WINDOW_MODE.TRANSPARENT,
button_cursor: SWFUpload.CURSOR.HAND,
file_dialog_start_handler : fileDialogStart,
file_queued_handler : fileQueued,
file_queue_error_handler:fileQueueError,
file_dialog_complete_handler:fileDialogComplete,
upload_progress_handler:uploadProgress,
upload_error_handler:uploadError,
upload_success_handler:uploadSuccess,
upload_complete_handler:uploadComplete,
debug: true
});
})
</script>
<div class="pad-10">
<div class="col-tab">
<ul class="tabBut cu-li">
<li id="tab_swf_1"><?php echo $category['catname']; ?> 批量上传</li>
</ul>
<div id="div_swf_1" class="content pad-10">
<div>
<div class="addnew" id="addnew">
<span id="buttonPlaceHolder"></span>
</div>
<input type="button" id="btupload" value="开始上传" onClick="uploadSubmit();" />
<div id="nameTip" class="onShow">最多上传<font color="red"> 100</font> 个附件,单文件最大 <font color="red">2 MB</font></div>
<div class="bk3"></div>
<div class="lh24">支持 <font style="font-family: Arial, Helvetica, sans-serif">jpg、jpeg、gif、png、bmp</font> 格式。</div><input type="checkbox" id="watermark_enable" value="1" onclick="change_params()"> 是否添加水印
<?php if ($brand_1) {?>
<br />品牌选择<select name="brand_1" id="brand_1">
<?php foreach($brand_1 AS $b1) {
echo "<option value='".$b1['id']."'>".$b1['name']."</option>";
}?>
</select><select name="brand_2" id="brand_2" <?php echo ($brand_1[0]['child'] ? "":"style='display:none;'")?>>
<?php foreach($brand_1[0]['child'] AS $b2) {
echo "<option value='".$b2['id']."'>".$b2['name']."</option>";
}?>
</select>
<?php } else{ ?>
<br /><span class="red"> 此栏目暂时没有品牌信息</span>
<?php }?>
</div>
<div class="bk10"></div>
<fieldset class="blue pad-10" id="swfupload">
<legend>列表</legend>
<ul class="attachment-list" id="fsUploadProgress">
</ul>
</fieldset>
</div>
<div id="att-status" class="hidden"></div>
<div id="att-status-del" class="hidden"></div>
<div id="att-name" class="hidden"></div>
<!-- swf -->
</div>
</body>
<script type="text/javascript"><!--
var brands = <?php echo $brands_json; ?>;
$(function(){
if(brands){
$("#brand_1").change(function(){
var bid_1 = this.value;
var html="";
for(i in brands) {
if(brands[i].id == bid_1) {
for(j in brands[i].child) {
html += "<option value='"+brands[i].child[j].id+"'>"+brands[i].child[j].name+"</option>";
}
if(html=="") {
$("#brand_2").html(html).hide();
}else {
$("#brand_2").show().html(html);
}
}
}
});
}
});
function uploadSubmit()
{
if($("#brand_1").size() > 0) {
if($("#brand_2").val()) {
swfu.addPostParam('bids', $("#brand_1").val()+','+$("#brand_2").val());
}else {
swfu.addPostParam('bids', $("#brand_1").val());
}
}
swfu.startUpload();
}
</script>
<script type="text/javascript">
function imgWrap(obj){
$(obj).hasClass('on') ? $(obj).removeClass("on") : $(obj).addClass("on");
}
function SwapTab(name,cls_show,cls_hide,cnt,cur) {
for(i=1;i<=cnt;i++){
if(i==cur){
$('#div_'+name+'_'+i).show();
$('#tab_'+name+'_'+i).addClass(cls_show);
$('#tab_'+name+'_'+i).removeClass(cls_hide);
}else{
$('#div_'+name+'_'+i).hide();
$('#tab_'+name+'_'+i).removeClass(cls_show);
$('#tab_'+name+'_'+i).addClass(cls_hide);
}
}
}
function addonlinefile(obj) {
var strs = $(obj).val() ? '|'+ $(obj).val() :'';
$('#att-status').html(strs);
}
function change_params(){
if($('#watermark_enable').attr('checked')) {
swfu.addPostParam('watermark_enable', '1');
} else {
swfu.removePostParam('watermark_enable');
}
}
function set_iframe(id,src){
$("#"+id).attr("src",src);
}
function album_cancel(obj,id,source){
var src = $(obj).children("img").attr("path");
var filename = $(obj).attr('title');
if($(obj).hasClass('on')){
$(obj).removeClass("on");
var imgstr = $("#att-status").html();
var length = $("a[class='on']").children("img").length;
var strs = filenames = '';
$.get('index.php?m=attachment&c=attachments&a=swfupload_json_del&aid='+id+'&src='+source+'&filename='+filename);
for(var i=0;i<length;i++){
strs += '|'+$("a[class='on']").children("img").eq(i).attr('path');
filenames += '|'+$("a[class='on']").children("img").eq(i).attr('title');
}
$('#att-status').html(strs);
$('#att-status').html(filenames);
} else {
var num = $('#att-status').html().split('|').length;
var file_upload_limit = '<?php echo $file_upload_limit?>';
if(num > file_upload_limit) {alert('<?php echo L('attachment_tip1')?>'+file_upload_limit+'<?php echo L('attachment_tip2')?>'); return false;}
$(obj).addClass("on");
$.get('index.php?m=attachment&c=attachments&a=swfupload_json&aid='+id+'&src='+source+'&filename='+filename);
$('#att-status').append('|'+src);
$('#att-name').append('|'+filename);
}
}
</script>
</html>
|
108wo
|
phpcms/modules/attachment/templates/product_batchupload.tpl.php
|
PHP
|
asf20
| 7,116
|
<?php
defined('IN_PHPCMS') or exit('No permission resources.');
pc_base::load_app_class('admin','admin',0);
class address extends admin {
public function __construct() {
parent::__construct();
}
public function init() {
include $this->admin_tpl('address');
}
public function update() {
set_time_limit(120);
$old_attachment_path = isset($_POST['old_attachment_path']) && trim($_POST['old_attachment_path']) ? trim($_POST['old_attachment_path']) : showmessage(L('old_attachment_address_empty'));
$new_attachment_path = isset($_POST['new_attachment_path']) && trim($_POST['new_attachment_path']) ? trim($_POST['new_attachment_path']) : showmessage(L('new_attachment_address_empty'));
//获取数据表列表
$db = pc_base::load_model('site_model');
$r = $db->query("show tables");
$r = $db->fetch_array($db_list);
foreach ($r as $k=>$v) {
$v = array_pop($v);
if (strpos($v, $db->db_tablepre)===false) continue;
$table_name = str_replace($db->db_tablepre, '', $v);
//获取每个表的数据表结构
if (!$modle_table_db = pc_base::load_model($table_name.'_model')) {
$modle_table_db = $db;
}
$s = $modle_table_db->get_fields($table_name);
if ($s) {
$sql = '';
foreach ($s as $key=>$val) {
//对数据表进行过滤,只有CHAR、TEXT或mediumtext类型的字段才可以保存下附件的地址。
if (preg_match('/(char|text|mediumtext)+/i', $val)) {
$sql .= !empty($sql) ? ", `$key`=replace(`$key`, '$old_attachment_path', '$new_attachment_path')" : "`$key`=replace(`$key`, '$old_attachment_path', '$new_attachment_path')";
}
}
if (!empty($sql)) $modle_table_db->query("UPDATE ".$db->db_tablepre.$table_name." SET $sql");
}
}
showmessage(L('operation_success'));
}
}
|
108wo
|
phpcms/modules/attachment/address.php
|
PHP
|
asf20
| 1,824
|
<?php
defined('IN_PHPCMS') or exit('No permission resources.');
pc_base::load_app_class('admin','admin',0);
class attachments extends admin {
private $att_db;
function __construct() {
pc_base::load_app_func('global');
$this->upload_url = pc_base::load_config('system','upload_url');
$this->upload_path = pc_base::load_config('system','upload_path');
$this->imgext = array('jpg','gif','png','bmp','jpeg');
$this->userid = param::get_cookie('userid') ? param::get_cookie('userid') : param::get_cookie('_userid');
$this->isadmin = param::get_cookie('userid') ? 1 : 0;
$this->groupid = param::get_cookie('_groupid') ? param::get_cookie('_groupid') : 8;
$this->admin_username = param::get_cookie('admin_username');
}
/**
* 常规上传
*/
public function upload() {
$grouplist = getcache('grouplist','member');
if($this->isadmin==0 && !$grouplist[$this->groupid]['allowattachment']) return false;
pc_base::load_sys_class('attachment','',0);
$module = trim($_GET['module']);
$catid = intval($_GET['catid']);
$siteid = $this->get_siteid();
$site_setting = get_site_setting($siteid);
$site_allowext = $site_setting['upload_allowext'];
$attachment = new attachment($module,$catid,$siteid);
$attachment->set_userid($this->userid);
$a = $attachment->upload('upload',$site_allowext);
if($a){
$filepath = $attachment->uploadedfiles[0]['filepath'];
$fn = $attachment->uploadedfiles[0]['fn'];
$this->upload_json($a[0],$filepath,$attachment->uploadedfiles[0]['filename']);
$attachment->mkhtml($fn,$this->upload_url.$filepath,'');
}
}
/**
* swfupload上传附件
*/
public function swfupload(){
$grouplist = getcache('grouplist','member');
if(isset($_POST['dosubmit'])){
if( $_POST['swf_auth_key'] != md5(pc_base::load_config('system','auth_key').$_POST['SWFUPLOADSESSID']) || ($_POST['isadmin']==0 && !$grouplist[$_POST['groupid']]['allowattachment'])) exit();
pc_base::load_sys_class('attachment','',0);
$attachment = new attachment($_POST['module'],$_POST['catid'],$_POST['siteid']);
$attachment->set_userid($_POST['userid']);
$aids = $attachment->upload('Filedata',$_POST['filetype_post'],'','',array($_POST['thumb_width'],$_POST['thumb_height']),$_POST['watermark_enable']);
if($aids[0]) {
$filename= (strtolower(CHARSET) != 'utf-8') ? iconv('gbk', 'utf-8', $attachment->uploadedfiles[0]['filename']) : $attachment->uploadedfiles[0]['filename'];
if($attachment->uploadedfiles[0]['isimage']) {
echo $aids[0].','.$this->upload_url.$attachment->uploadedfiles[0]['filepath'].','.$attachment->uploadedfiles[0]['isimage'].','.$filename;
} else {
$fileext = $attachment->uploadedfiles[0]['fileext'];
if($fileext == 'zip' || $fileext == 'rar') $fileext = 'rar';
elseif($fileext == 'doc' || $fileext == 'docx') $fileext = 'doc';
elseif($fileext == 'xls' || $fileext == 'xlsx') $fileext = 'xls';
elseif($fileext == 'ppt' || $fileext == 'pptx') $fileext = 'ppt';
elseif ($fileext == 'flv' || $fileext == 'swf' || $fileext == 'rm' || $fileext == 'rmvb') $fileext = 'flv';
else $fileext = 'do';
echo $aids[0].','.$this->upload_url.$attachment->uploadedfiles[0]['filepath'].','.$fileext.','.$filename;
}
exit;
} else {
echo '0,'.$attachment->error();
exit;
}
} else {
if($this->isadmin==0 && !$grouplist[$this->groupid]['allowattachment']) showmessage(L('att_no_permission'));
$args = $_GET['args'];
$authkey = $_GET['authkey'];
if(upload_key($args)!=$authkey) showmessage(L('attachment_parameter_error'));
extract(getswfinit($_GET['args']));
$siteid = $this->get_siteid();
$site_setting = get_site_setting($siteid);
$file_size_limit = sizecount($site_setting['upload_maxsize']*1024);
$att_not_used = param::get_cookie('att_json');
if(empty($att_not_used) || !isset($att_not_used)) $tab_status = ' class="on"';
if(!empty($att_not_used)) $div_status = ' hidden';
//获取临时未处理文件列表
$att = $this->att_not_used();
include $this->admin_tpl('swfupload');
}
}
public function crop_upload() {
if (isset($GLOBALS["HTTP_RAW_POST_DATA"])) {
$pic = $GLOBALS["HTTP_RAW_POST_DATA"];
if (isset($_GET['width']) && !empty($_GET['width'])) {
$width = intval($_GET['width']);
}
if (isset($_GET['height']) && !empty($_GET['height'])) {
$height = intval($_GET['height']);
}
if (isset($_GET['file']) && !empty($_GET['file'])) {
if(is_image($_GET['file'])== false ) exit();
if (strpos($_GET['file'], pc_base::load_config('system', 'upload_url'))!==false) {
$file = $_GET['file'];
$basename = basename($file);
$filepath = str_replace(APP_PATH, '', dirname($file)).'/';
if (strpos($basename, 'thumb_')!==false) {
$file_arr = explode('_', $basename);
$basename = array_pop($file_arr);
}
$new_file = 'thumb_'.$width.'_'.$height.'_'.$basename;
} else {
pc_base::load_sys_class('attachment','',0);
$module = trim($_GET['module']);
$catid = intval($_GET['catid']);
$siteid = $this->get_siteid();
$attachment = new attachment($module, $catid, $siteid);
$uploadedfile['filename'] = basename($_GET['file']);
$uploadedfile['fileext'] = fileext($_GET['file']);
if (in_array($uploadedfile['fileext'], array('jpg', 'gif', 'jpeg', 'png', 'bmp'))) {
$uploadedfile['isimage'] = 1;
}
$file_path = pc_base::load_config('system', 'upload_path').date('Y/md/');
pc_base::load_sys_func('dir');
dir_create($file_path);
$new_file = date('Ymdhis').rand(100, 999).'.'.$uploadedfile['fileext'];
$uploadedfile['filepath'] = date('Y/md/').$new_file;
$aid = $attachment->add($uploadedfile);
$filepath = str_replace(APP_PATH, '', pc_base::load_config('system', 'upload_url')).date('Y/md/');
}
file_put_contents(PHPCMS_PATH.$filepath.$new_file, $pic);
} else {
return false;
}
echo APP_PATH.$filepath.$new_file;
exit;
}
}
/**
* 删除附件
*/
public function swfdelete() {
$attachment = pc_base::load_sys_class('attachment');
$att_del_arr = explode('|',$_GET['data']);
foreach($att_del_arr as $n=>$att){
if($att) $attachment->delete(array('aid'=>$att,'userid'=>$this->userid,'uploadip'=>ip()));
}
}
/**
* 加载图片库
*/
public function album_load() {
if(!$this->admin_username) return false;
$where = $uploadtime= '';
$this->att_db= pc_base::load_model('attachment_model');
if($_GET['args']) extract(getswfinit($_GET['args']));
if($_GET['dosubmit']){
extract($_GET['info']);
if($filename) $where = "AND `filename` LIKE '%$filename%' ";
if($uploadtime) {
$start_uploadtime = strtotime($uploadtime.' 00:00:00');
$stop_uploadtime = strtotime($uploadtime.' 23:59:59');
$where .= "AND `uploadtime` >= '$start_uploadtime' AND `uploadtime` <= '$stop_uploadtime'";
}
if($where) $where = substr($where, 3);
}
pc_base::load_sys_class('form');
$page = $_GET['page'] ? $_GET['page'] : '1';
$infos = $this->att_db->listinfo($where, $order = 'aid DESC', $page, $pagesize = 8,'',5);
foreach($infos as $n=>$v){
$ext = fileext($v['filepath']);
if(in_array($ext,$this->imgext)) {
$infos[$n]['src']=$this->upload_url.$v['filepath'];
$infos[$n]['width']='80';
} else {
$infos[$n]['src']=file_icon($v['filepath']);
$infos[$n]['width']='64';
}
}
$pages = $this->att_db->pages;
include $this->admin_tpl('album_list');
}
/**
* 目录浏览模式添加图片
*/
public function album_dir() {
if(!$this->admin_username) return false;
if($_GET['args']) extract(getswfinit($_GET['args']));
$dir = isset($_GET['dir']) && trim($_GET['dir']) ? str_replace(array('..\\', '../', './', '.\\'), '', trim($_GET['dir'])) : '';
$filepath = $this->upload_path.$dir;
$list = glob($filepath.'/'.'*');
if(!empty($list)) rsort($list);
$local = str_replace(array(PC_PATH, PHPCMS_PATH ,DIRECTORY_SEPARATOR.DIRECTORY_SEPARATOR), array('','',DIRECTORY_SEPARATOR), $filepath);
$url = ($dir == '.' || $dir=='') ? $this->upload_url : $this->upload_url.str_replace('.', '', $dir).'/';
$show_header = true;
include $this->admin_tpl('album_dir');
}
/**
* 设置upload上传的json格式cookie
*/
private function upload_json($aid,$src,$filename) {
$arr['aid'] = intval($aid);
$arr['src'] = trim($src);
$arr['filename'] = urlencode($filename);
$json_str = json_encode($arr);
$att_arr_exist = param::get_cookie('att_json');
$att_arr_exist_tmp = explode('||', $att_arr_exist);
if(is_array($att_arr_exist_tmp) && in_array($json_str, $att_arr_exist_tmp)) {
return true;
} else {
$json_str = $att_arr_exist ? $att_arr_exist.'||'.$json_str : $json_str;
param::set_cookie('att_json',$json_str);
return true;
}
}
/**
* 设置swfupload上传的json格式cookie
*/
public function swfupload_json() {
$arr['aid'] = intval($_GET['aid']);
$arr['src'] = trim($_GET['src']);
$arr['filename'] = urlencode($_GET['filename']);
$json_str = json_encode($arr);
$att_arr_exist = param::get_cookie('att_json');
$att_arr_exist_tmp = explode('||', $att_arr_exist);
if(is_array($att_arr_exist_tmp) && in_array($json_str, $att_arr_exist_tmp)) {
return true;
} else {
$json_str = $att_arr_exist ? $att_arr_exist.'||'.$json_str : $json_str;
param::set_cookie('att_json',$json_str);
return true;
}
}
/**
* 删除swfupload上传的json格式cookie
*/
public function swfupload_json_del() {
$arr['aid'] = intval($_GET['aid']);
$arr['src'] = trim($_GET['src']);
$arr['filename'] = urlencode($_GET['filename']);
$json_str = json_encode($arr);
$att_arr_exist = param::get_cookie('att_json');
$att_arr_exist = str_replace(array($json_str,'||||'), array('','||'), $att_arr_exist);
$att_arr_exist = preg_replace('/^\|\|||\|\|$/i', '', $att_arr_exist);
param::set_cookie('att_json',$att_arr_exist);
}
private function att_not_used() {
$this->att_db= pc_base::load_model('attachment_model');
//获取临时未处理文件列表
if($att_json = param::get_cookie('att_json')) {
if($att_json) $att_cookie_arr = explode('||', $att_json);
foreach ($att_cookie_arr as $_att_c) $att[] = json_decode($_att_c,true);
if(is_array($att) && !empty($att)) {
foreach ($att as $n=>$v) {
$ext = fileext($v['src']);
if(in_array($ext,$this->imgext)) {
$att[$n]['fileimg']=$v['src'];
$att[$n]['width']='80';
$att[$n]['filename']=urldecode($v['filename']);
} else {
$att[$n]['fileimg']=file_icon($v['src']);
$att[$n]['width']='64';
$att[$n]['filename']=urldecode($v['filename']);
}
$this->cookie_att .= '|'.$v['src'];
}
}
}
return $att;
}
}
?>
|
108wo
|
phpcms/modules/attachment/attachments.php
|
PHP
|
asf20
| 11,041
|
<?php
defined('IN_PHPCMS') or exit('No permission resources.');
pc_base::load_app_class('admin','admin',0);
class manage extends admin {
private $db;
function __construct() {
parent::__construct();
pc_base::load_app_func('global');
$this->upload_url = pc_base::load_config('system','upload_url');
$this->upload_path = pc_base::load_config('system','upload_path');
$this->imgext = array('jpg','gif','png','bmp','jpeg');
$this->db= pc_base::load_model('attachment_model');
$this->attachment = pc_base::load_sys_class('attachment');
$this->admin_username = param::get_cookie('admin_username');
$this->siteid = $this->get_siteid();
}
/**
* 附件列表
*/
public function init() {
$where = '';
if($_GET['dosubmit']){
if(is_array($_GET['info'])&&!empty($_GET['info']))extract($_GET['info']);
if($filename) $where = "AND `filename` LIKE '%$filename%' ";
if($start_uploadtime && $end_uploadtime) {
$start = strtotime($start_uploadtime);
$end = strtotime($end_uploadtime);
if($start > $end) showmessage(L('range_not_correct'),HTTP_REFERER);
$where .= "AND `uploadtime` >= '$start' AND `uploadtime` <= '$end' ";
}
if($fileext) $where .= "AND `fileext`='$fileext' ";
$status = trim($_GET['status']);
if($status!='' && ($status==1 ||$status==0)) $where .= "AND `status`='$status' ";
$module = trim($_GET['module']);
if(isset($module) && $module!='') $where .= "AND `module`='$module' ";
}
$where .="AND `siteid`='".$this->siteid."'";
if($where) $where = substr($where, 3);
pc_base::load_sys_class('form');
$category = getcache('category_content_'.$this->siteid,'commons');
$modules = getcache('modules','commons');
$page = $_GET['page'] ? $_GET['page'] : '1';
$infos = $this->db->listinfo($where, 'uploadtime DESC', $page, $pagesize = 20);
$pages = $this->db->pages;
include $this->admin_tpl('attachment_list');
}
/**
* 目录浏览模式添加图片
*/
public function dir() {
if(!$this->admin_username) return false;
$dir = isset($_GET['dir']) && trim($_GET['dir']) ? str_replace(array('..\\', '../', './', '.\\'), '', trim($_GET['dir'])) : '';
$filepath = $this->upload_path.$dir;
$list = glob($filepath.'/'.'*');
if(!empty($list)) rsort($list);
$local = str_replace(array(PC_PATH, PHPCMS_PATH ,DIRECTORY_SEPARATOR.DIRECTORY_SEPARATOR), array('','',DIRECTORY_SEPARATOR), $filepath);
//$show_header = true;
include $this->admin_tpl('attachment_dir');
}
public function pulic_dirmode_del() {
$filename = urldecode($_GET['filename']);
$dir = urldecode($_GET['dir']);
$file = PHPCMS_PATH.$dir.DIRECTORY_SEPARATOR.$filename;
$file = str_replace(array('/','\\'), DIRECTORY_SEPARATOR, $file);
if(@unlink($file)) {
echo '1';
} else {
echo '0';
}
}
/**
* 删除附件
*/
public function delete() {
$aid = $_GET['aid'];
$attachment_index = pc_base::load_model('attachment_index_model');
if($this->attachment->delete(array('aid'=>$aid))) {
$attachment_index->delete(array('aid'=>$aid));
exit('1');
} else {
exit('0');
}
}
/**
* 批量删除附件
*/
public function public_delete_all() {
$del_arr = array();
$del_arr = $_POST['aid'];
$attachment_index = pc_base::load_model('attachment_index_model');
if(is_array($del_arr)){
foreach($del_arr as $v){
$aid = intval($v);
$this->attachment->delete(array('aid'=>$aid));
$attachment_index->delete(array('aid'=>$aid));
}
showmessage(L('delete').L('success'), HTTP_REFERER);
}
}
public function pullic_showthumbs() {
$aid = intval($_GET['aid']);
$info = $this->db->get_one(array('aid'=>$aid));
if($info) {
$infos = glob(dirname($this->upload_path.$info['filepath']).'/thumb_*'.basename($info['filepath']));
foreach ($infos as $n=>$thumb) {
$thumbs[$n]['thumb_url'] = str_replace($this->upload_path, $this->upload_url, $thumb);
$thumbinfo = explode('_', basename($thumb));
$thumbs[$n]['thumb_filepath'] = $thumb;
$thumbs[$n]['width'] = $thumbinfo[1];
$thumbs[$n]['height'] = $thumbinfo[2];
}
}
$show_header = 1;
include $this->admin_tpl('attachment_thumb');
}
public function pullic_delthumbs() {
$filepath = urldecode($_GET['filepath']);
$reslut = @unlink($filepath);
if($reslut) exit('1');
exit('0');
}
}
?>
|
108wo
|
phpcms/modules/attachment/manage.php
|
PHP
|
asf20
| 4,463
|
<?php
/**
* 返回附件类型图标
* @param $file 附件名称
* @param $type png为大图标,gif为小图标
*/
function file_icon($file,$type = 'png') {
$ext_arr = array('doc','docx','ppt','xls','txt','pdf','mdb','jpg','gif','png','bmp','jpeg','rar','zip','swf','flv');
$ext = fileext($file);
if($type == 'png') {
if($ext == 'zip' || $ext == 'rar') $ext = 'rar';
elseif($ext == 'doc' || $ext == 'docx') $ext = 'doc';
elseif($ext == 'xls' || $ext == 'xlsx') $ext = 'xls';
elseif($ext == 'ppt' || $ext == 'pptx') $ext = 'ppt';
elseif ($ext == 'flv' || $ext == 'swf' || $ext == 'rm' || $ext == 'rmvb') $ext = 'flv';
else $ext = 'do';
}
if(in_array($ext,$ext_arr)) return 'statics/images/ext/'.$ext.'.'.$type;
else return 'statics/images/ext/blank.'.$type;
}
/**
* 附件目录列表,暂时没用
* @param $dirpath 目录路径
* @param $currentdir 当前目录
*/
function file_list($dirpath,$currentdir) {
$filepath = $dirpath.$currentdir;
$list['list'] = glob($filepath.DIRECTORY_SEPARATOR.'*');
if(!empty($list['list'])) rsort($list['list']);
$list['local'] = str_replace(array(PC_PATH, DIRECTORY_SEPARATOR.DIRECTORY_SEPARATOR), array('',DIRECTORY_SEPARATOR), $filepath);
return $list;
}
/**
* flash上传初始化
* 初始化swfupload上传中需要的参数
* @param $module 模块名称
* @param $catid 栏目id
* @param $args 传递参数
* @param $userid 用户id
* @param $groupid 用户组id
* @param $isadmin 是否为管理员模式
*/
function initupload($module, $catid,$args, $userid, $groupid = '8', $isadmin = '0'){
$grouplist = getcache('grouplist','member');
if($isadmin==0 && !$grouplist[$groupid]['allowattachment']) return false;
extract(getswfinit($args));
$siteid = get_siteid();
$site_setting = get_site_setting($siteid);
$file_size_limit = $site_setting['upload_maxsize'];
$sess_id = SYS_TIME;
$swf_auth_key = md5(pc_base::load_config('system','auth_key').$sess_id);
$init = 'var swfu = \'\';
$(document).ready(function(){
swfu = new SWFUpload({
flash_url:"'.JS_PATH.'swfupload/swfupload.swf?"+Math.random(),
upload_url:"'.APP_PATH.'index.php?m=attachment&c=attachments&a=swfupload&dosubmit=1",
file_post_name : "Filedata",
post_params:{"SWFUPLOADSESSID":"'.$sess_id.'","module":"'.$module.'","catid":"'.$_GET['catid'].'","userid":"'.$userid.'","siteid":"'.$siteid.'","dosubmit":"1","thumb_width":"'.$thumb_width.'","thumb_height":"'.$thumb_height.'","watermark_enable":"'.$watermark_enable.'","filetype_post":"'.$file_types_post.'","swf_auth_key":"'.$swf_auth_key.'","isadmin":"'.$isadmin.'","groupid":"'.$groupid.'"},
file_size_limit:"'.$file_size_limit.'",
file_types:"'.$file_types.'",
file_types_description:"All Files",
file_upload_limit:"'.$file_upload_limit.'",
custom_settings : {progressTarget : "fsUploadProgress",cancelButtonId : "btnCancel"},
button_image_url: "",
button_width: 75,
button_height: 28,
button_placeholder_id: "buttonPlaceHolder",
button_text_style: "",
button_text_top_padding: 3,
button_text_left_padding: 12,
button_window_mode: SWFUpload.WINDOW_MODE.TRANSPARENT,
button_cursor: SWFUpload.CURSOR.HAND,
file_dialog_start_handler : fileDialogStart,
file_queued_handler : fileQueued,
file_queue_error_handler:fileQueueError,
file_dialog_complete_handler:fileDialogComplete,
upload_progress_handler:uploadProgress,
upload_error_handler:uploadError,
upload_success_handler:uploadSuccess,
upload_complete_handler:uploadComplete
});
})';
return $init;
}
/**
* 获取站点配置信息
* @param $siteid 站点id
*/
function get_site_setting($siteid) {
$siteinfo = getcache('sitelist', 'commons');
return string2array($siteinfo[$siteid]['setting']);
}
/**
* 读取swfupload配置类型
* @param array $args flash上传配置信息
*/
function getswfinit($args) {
$siteid = get_siteid();
$site_setting = get_site_setting($siteid);
$site_allowext = $site_setting['upload_allowext'];
$args = explode(',',$args);
$arr['file_upload_limit'] = intval($args[0]) ? intval($args[0]) : '8';
$args['1'] = ($args[1]!='') ? $args[1] : $site_allowext;
$arr_allowext = explode('|', $args[1]);
foreach($arr_allowext as $k=>$v) {
$v = '*.'.$v;
$array[$k] = $v;
}
$upload_allowext = implode(';', $array);
$arr['file_types'] = $upload_allowext;
$arr['file_types_post'] = $args[1];
$arr['allowupload'] = intval($args[2]);
$arr['thumb_width'] = intval($args[3]);
$arr['thumb_height'] = intval($args[4]);
$arr['watermark_enable'] = ($args[5]=='') ? 1 : intval($args[5]);
return $arr;
}
/**
* 判断是否为图片
*/
function is_image($file) {
$ext_arr = array('jpg','gif','png','bmp','jpeg','tiff');
$ext = fileext($file);
return in_array($ext,$ext_arr) ? $ext_arr :false;
}
/**
* 判断是否为视频
*/
function is_video($file) {
$ext_arr = array('rm','mpg','avi','mpeg','wmv','flv','asf','rmvb');
$ext = fileext($file);
return in_array($ext,$ext_arr) ? $ext_arr :false;
}
?>
|
108wo
|
phpcms/modules/attachment/functions/global.func.php
|
PHP
|
asf20
| 5,242
|
<?php
defined('IN_PHPCMS') or exit('No permission resources.');
pc_base::load_app_class('admin','admin',0);
class MY_attachments extends admin {
private $att_db;
function __construct() {
pc_base::load_app_func('global');
$this->upload_url = pc_base::load_config('system','upload_url');
$this->upload_path = pc_base::load_config('system','upload_path');
$this->imgext = array('jpg','gif','png','bmp','jpeg');
$this->userid = param::get_cookie('userid') ? param::get_cookie('userid') : param::get_cookie('_userid');
$this->isadmin = param::get_cookie('userid') ? 1 : 0;
$this->groupid = param::get_cookie('_groupid') ? param::get_cookie('_groupid') : 8;
$this->admin_username = param::get_cookie('admin_username');
}
/**
* 常规上传
*/
public function upload() {
$grouplist = getcache('grouplist','member');
if($this->isadmin==0 && !$grouplist[$this->groupid]['allowattachment']) return false;
pc_base::load_sys_class('attachment','',0);
$module = trim($_GET['module']);
$catid = intval($_GET['catid']);
$siteid = $this->get_siteid();
$site_setting = get_site_setting($siteid);
$site_allowext = $site_setting['upload_allowext'];
$attachment = new attachment($module,$catid,$siteid);
$attachment->set_userid($this->userid);
$a = $attachment->upload('upload',$site_allowext);
if($a){
$filepath = $attachment->uploadedfiles[0]['filepath'];
$fn = $attachment->uploadedfiles[0]['fn'];
$this->upload_json($a[0],$filepath,$attachment->uploadedfiles[0]['filename']);
$attachment->mkhtml($fn,$this->upload_url.$filepath,'');
}
}
/**
* swfupload上传附件
*/
public function swfupload(){
$grouplist = getcache('grouplist','member');
if(isset($_POST['dosubmit'])){
if( $_POST['swf_auth_key'] != md5(pc_base::load_config('system','auth_key').$_POST['SWFUPLOADSESSID']) || ($_POST['isadmin']==0 && !$grouplist[$_POST['groupid']]['allowattachment'])) exit();
pc_base::load_sys_class('attachment','',0);
$attachment = new attachment($_POST['module'],$_POST['catid'],$_POST['siteid']);
$attachment->set_userid($_POST['userid']);
$aids = $attachment->upload('Filedata',$_POST['filetype_post'],'','',array($_POST['thumb_width'],$_POST['thumb_height']),$_POST['watermark_enable']);
if($aids[0]) {
$filename= (strtolower(CHARSET) != 'utf-8') ? iconv('gbk', 'utf-8', $attachment->uploadedfiles[0]['filename']) : $attachment->uploadedfiles[0]['filename'];
if($attachment->uploadedfiles[0]['isimage']) {
echo $aids[0].','.$this->upload_url.$attachment->uploadedfiles[0]['filepath'].','.$attachment->uploadedfiles[0]['isimage'].','.$filename;
} else {
$fileext = $attachment->uploadedfiles[0]['fileext'];
if($fileext == 'zip' || $fileext == 'rar') $fileext = 'rar';
elseif($fileext == 'doc' || $fileext == 'docx') $fileext = 'doc';
elseif($fileext == 'xls' || $fileext == 'xlsx') $fileext = 'xls';
elseif($fileext == 'ppt' || $fileext == 'pptx') $fileext = 'ppt';
elseif ($fileext == 'flv' || $fileext == 'swf' || $fileext == 'rm' || $fileext == 'rmvb') $fileext = 'flv';
else $fileext = 'do';
echo $aids[0].','.$this->upload_url.$attachment->uploadedfiles[0]['filepath'].','.$fileext.','.$filename;
}
exit;
} else {
echo '0,'.$attachment->error();
exit;
}
} else {
if($this->isadmin==0 && !$grouplist[$this->groupid]['allowattachment']) showmessage(L('att_no_permission'));
$args = $_GET['args'];
$authkey = $_GET['authkey'];
if(upload_key($args)!=$authkey) showmessage(L('attachment_parameter_error'));
extract(getswfinit($_GET['args']));
$siteid = $this->get_siteid();
$site_setting = get_site_setting($siteid);
$file_size_limit = sizecount($site_setting['upload_maxsize']*1024);
$att_not_used = param::get_cookie('att_json');
if(empty($att_not_used) || !isset($att_not_used)) $tab_status = ' class="on"';
if(!empty($att_not_used)) $div_status = ' hidden';
//获取临时未处理文件列表
$att = $this->att_not_used();
include $this->admin_tpl('swfupload');
}
}
public function crop_upload() {
if (isset($GLOBALS["HTTP_RAW_POST_DATA"])) {
$pic = $GLOBALS["HTTP_RAW_POST_DATA"];
if (isset($_GET['width']) && !empty($_GET['width'])) {
$width = intval($_GET['width']);
}
if (isset($_GET['height']) && !empty($_GET['height'])) {
$height = intval($_GET['height']);
}
if (isset($_GET['file']) && !empty($_GET['file'])) {
if(is_image($_GET['file'])== false ) exit();
if (strpos($_GET['file'], pc_base::load_config('system', 'upload_url'))!==false) {
$file = $_GET['file'];
$basename = basename($file);
$filepath = str_replace(APP_PATH, '', dirname($file)).'/';
if (strpos($basename, 'thumb_')!==false) {
$file_arr = explode('_', $basename);
$basename = array_pop($file_arr);
}
$new_file = 'thumb_'.$width.'_'.$height.'_'.$basename;
} else {
pc_base::load_sys_class('attachment','',0);
$module = trim($_GET['module']);
$catid = intval($_GET['catid']);
$siteid = $this->get_siteid();
$attachment = new attachment($module, $catid, $siteid);
$uploadedfile['filename'] = basename($_GET['file']);
$uploadedfile['fileext'] = fileext($_GET['file']);
if (in_array($uploadedfile['fileext'], array('jpg', 'gif', 'jpeg', 'png', 'bmp'))) {
$uploadedfile['isimage'] = 1;
}
$file_path = pc_base::load_config('system', 'upload_path').date('Y/md/');
pc_base::load_sys_func('dir');
dir_create($file_path);
$new_file = date('Ymdhis').rand(100, 999).'.'.$uploadedfile['fileext'];
$uploadedfile['filepath'] = date('Y/md/').$new_file;
$aid = $attachment->add($uploadedfile);
$filepath = str_replace(APP_PATH, '', pc_base::load_config('system', 'upload_url')).date('Y/md/');
}
file_put_contents(PHPCMS_PATH.$filepath.$new_file, $pic);
} else {
return false;
}
echo APP_PATH.$filepath.$new_file;
exit;
}
}
/**
* 删除附件
*/
public function swfdelete() {
$attachment = pc_base::load_sys_class('attachment');
$att_del_arr = explode('|',$_GET['data']);
foreach($att_del_arr as $n=>$att){
if($att) $attachment->delete(array('aid'=>$att,'userid'=>$this->userid,'uploadip'=>ip()));
}
}
/**
* 加载图片库
*/
public function album_load() {
if(!$this->admin_username) return false;
$where = $uploadtime= '';
$this->att_db= pc_base::load_model('attachment_model');
if($_GET['args']) extract(getswfinit($_GET['args']));
if($_GET['dosubmit']){
extract($_GET['info']);
if($filename) $where = "AND `filename` LIKE '%$filename%' ";
if($uploadtime) {
$start_uploadtime = strtotime($uploadtime.' 00:00:00');
$stop_uploadtime = strtotime($uploadtime.' 23:59:59');
$where .= "AND `uploadtime` >= '$start_uploadtime' AND `uploadtime` <= '$stop_uploadtime'";
}
if($where) $where = substr($where, 3);
}
pc_base::load_sys_class('form');
$page = $_GET['page'] ? $_GET['page'] : '1';
$infos = $this->att_db->listinfo($where, $order = 'aid DESC', $page, $pagesize = 8,'',5);
foreach($infos as $n=>$v){
$ext = fileext($v['filepath']);
if(in_array($ext,$this->imgext)) {
$infos[$n]['src']=$this->upload_url.$v['filepath'];
$infos[$n]['width']='80';
} else {
$infos[$n]['src']=file_icon($v['filepath']);
$infos[$n]['width']='64';
}
}
$pages = $this->att_db->pages;
include $this->admin_tpl('album_list');
}
/**
* 目录浏览模式添加图片
*/
public function album_dir() {
if(!$this->admin_username) return false;
if($_GET['args']) extract(getswfinit($_GET['args']));
$dir = isset($_GET['dir']) && trim($_GET['dir']) ? str_replace(array('..\\', '../', './', '.\\'), '', trim($_GET['dir'])) : '';
$filepath = $this->upload_path.$dir;
$list = glob($filepath.'/'.'*');
if(!empty($list)) rsort($list);
$local = str_replace(array(PC_PATH, PHPCMS_PATH ,DIRECTORY_SEPARATOR.DIRECTORY_SEPARATOR), array('','',DIRECTORY_SEPARATOR), $filepath);
$url = ($dir == '.' || $dir=='') ? $this->upload_url : $this->upload_url.str_replace('.', '', $dir).'/';
$show_header = true;
include $this->admin_tpl('album_dir');
}
/**
* 设置upload上传的json格式cookie
*/
private function upload_json($aid,$src,$filename) {
$arr['aid'] = intval($aid);
$arr['src'] = trim($src);
$arr['filename'] = urlencode($filename);
$json_str = json_encode($arr);
$att_arr_exist = param::get_cookie('att_json');
$att_arr_exist_tmp = explode('||', $att_arr_exist);
if(is_array($att_arr_exist_tmp) && in_array($json_str, $att_arr_exist_tmp)) {
return true;
} else {
$json_str = $att_arr_exist ? $att_arr_exist.'||'.$json_str : $json_str;
param::set_cookie('att_json',$json_str);
return true;
}
}
/**
* 设置swfupload上传的json格式cookie
*/
public function swfupload_json() {
$arr['aid'] = intval($_GET['aid']);
$arr['src'] = trim($_GET['src']);
$arr['filename'] = urlencode($_GET['filename']);
$json_str = json_encode($arr);
$att_arr_exist = param::get_cookie('att_json');
$att_arr_exist_tmp = explode('||', $att_arr_exist);
if(is_array($att_arr_exist_tmp) && in_array($json_str, $att_arr_exist_tmp)) {
return true;
} else {
$json_str = $att_arr_exist ? $att_arr_exist.'||'.$json_str : $json_str;
param::set_cookie('att_json',$json_str);
return true;
}
}
/**
* 删除swfupload上传的json格式cookie
*/
public function swfupload_json_del() {
$arr['aid'] = intval($_GET['aid']);
$arr['src'] = trim($_GET['src']);
$arr['filename'] = urlencode($_GET['filename']);
$json_str = json_encode($arr);
$att_arr_exist = param::get_cookie('att_json');
$att_arr_exist = str_replace(array($json_str,'||||'), array('','||'), $att_arr_exist);
$att_arr_exist = preg_replace('/^\|\|||\|\|$/i', '', $att_arr_exist);
param::set_cookie('att_json',$att_arr_exist);
}
private function att_not_used() {
$this->att_db= pc_base::load_model('attachment_model');
//获取临时未处理文件列表
if($att_json = param::get_cookie('att_json')) {
if($att_json) $att_cookie_arr = explode('||', $att_json);
foreach ($att_cookie_arr as $_att_c) $att[] = json_decode($_att_c,true);
if(is_array($att) && !empty($att)) {
foreach ($att as $n=>$v) {
$ext = fileext($v['src']);
if(in_array($ext,$this->imgext)) {
$att[$n]['fileimg']=$v['src'];
$att[$n]['width']='80';
$att[$n]['filename']=urldecode($v['filename']);
} else {
$att[$n]['fileimg']=file_icon($v['src']);
$att[$n]['width']='64';
$att[$n]['filename']=urldecode($v['filename']);
}
$this->cookie_att .= '|'.$v['src'];
}
}
}
return $att;
}
/**
* 产品 批量上传
* eddy
*/
public function batchUpload()
{
if (isset($_REQUEST['dosubmit'])) {
if( $_POST['swf_auth_key'] != md5(pc_base::load_config('system','auth_key').$_POST['SWFUPLOADSESSID']) || ($_POST['isadmin']==0 && !$grouplist[$_POST['groupid']]['allowattachment'])) exit();
pc_base::load_sys_class('attachment','',0);
$attachment = new attachment($_POST['module'],$_POST['catid'],$_POST['siteid']);
$attachment->set_userid($_POST['userid']);
$aids = $attachment->upload('Filedata',$_POST['filetype_post'],'','',array($_POST['thumb_width'],$_POST['thumb_height']),$_POST['watermark_enable']);
if($aids[0]) {
$filename= (strtolower(CHARSET) != 'utf-8') ? iconv('gbk', 'utf-8', $attachment->uploadedfiles[0]['filename']) : $filename ;
if($attachment->uploadedfiles[0]['isimage']) {
$arrtitle = explode('.', $_FILES['Filedata']['name']);
//内容数据
$_POST['status'] = 99;
$_POST['style_color'] = '';
$_POST['style_font_weight'] = '';
$_POST['pc_hash'] = $_SESSION['pc_hash'];
$_POST['info'] = array(
'monthordernum' => 0,
'inputtime' => date('Y-m-d H:i:s'),
'template' => '',
'catid' => $_POST['catid'],
'title' => $arrtitle[0],
'ordernum' => 0,
'viewnum' => 0,
'keywords' => '',
'goodnum' => 0,
'badnum' => 0,
'status' => 99,
'thumb' => $this->upload_url.$attachment->uploadedfiles[0]['filepath'],
'username' => $_POST['username'],
'bids' => array_pop(explode(',', $_POST['bids'])),
);
$content_model = pc_base::load_model('content_model');
$content_model->set_model(13); //只针对产品模型
$content_id = $content_model->add_content($_POST['info']);
//更改附件状态
$attachment_model = pc_base::load_model('attachment_model');
$attachment_model->update(array('status'=>1),array('aid'=>$aids[0]));
//插入附件关联内容表
$att_index_db = pc_base::load_model('attachment_index_model');
$att_index_db->insert(array('keyid'=>'c-'.$_POST['catid'].'-'.$content_id,'aid'=>$aids[0]));
echo $aids[0].','.$this->upload_url.$attachment->uploadedfiles[0]['filepath'].','.$attachment->uploadedfiles[0]['isimage'].','.$filename;
}
exit;
} else {
echo '0,'.$attachment->error();
exit;
}
}
pc_base::load_app_func('global');
$this->upload_url = pc_base::load_config('system','upload_url');
$this->upload_path = pc_base::load_config('system','upload_path');
$this->imgext = array('jpg','gif','png','bmp','jpeg');
$this->userid = param::get_cookie('userid') ? param::get_cookie('userid') : param::get_cookie('_userid');
$this->isadmin = param::get_cookie('userid') ? 1 : 0;
$this->groupid = param::get_cookie('_groupid') ? param::get_cookie('_groupid') : 8;
$this->admin_username = param::get_cookie('admin_username');
$this->pc_hash = $_GET['pc_hash'];
$args = "100,jpg|jpeg|gif|png|bmp,1,,,0";
$siteid = $this->get_siteid();
$this->categorys = getcache('category_content_'.$siteid,'commons');
$catid = $_GET['catid'] = intval($_GET['catid']);
$category = $this->categorys[$catid];
//品牌
$brand_db = pc_base::load_model('brand_model');
$brand_1 = $brand_db->select(array('catid'=>$_GET['catid'], 'parentid'=>0), 'id,name', '', 'name ASC');
if (is_array($brand_1)) {
foreach ($brand_1 as &$b){
$b['child'] = $brand_db->select(array('catid'=>$_GET['catid'], 'parentid'=>$b['id']), 'id,name', '', 'name ASC');
}
}
$brands_json = json_encode($brand_1);
$siteid = $_GET['siteid'];
include $this->admin_tpl('product_batchupload');
}
}
?>
|
108wo
|
phpcms/modules/attachment/MY_attachments.php
|
PHP
|
asf20
| 14,842
|
<?php
/**
* 管理员后台会员中心菜单管理类
*/
defined('IN_PHPCMS') or exit('No permission resources.');
pc_base::load_app_class('admin', 'admin', 0);
class member_menu extends admin {
function __construct() {
parent::__construct();
$this->db = pc_base::load_model('member_menu_model');
}
function manage() {
$tree = pc_base::load_sys_class('tree');
$tree->icon = array(' │ ',' ├─ ',' └─ ');
$tree->nbsp = ' ';
$userid = $_SESSION['userid'];
$admin_username = param::get_cookie('admin_username');
$result = $this->db->select('','*','','listorder ASC,id DESC');
foreach($result as $r) {
$r['cname'] = L($r['name'], '', 'member_menu');
$r['str_manage'] = '<a href="?m=member&c=member_menu&a=edit&id='.$r['id'].'&menuid='.$_GET['menuid'].'">'.L('edit').'</a> | <a href="javascript:confirmurl(\'?m=member&c=member_menu&a=delete&id='.$r['id'].'&menuid='.$_GET['menuid'].'\',\''.L('confirm',array('message'=>$r['cname'])).'\')">'.L('delete').'</a> ';
$array[] = $r;
}
$str = "<tr>
<td align='center'><input name='listorders[\$id]' type='text' size='3' value='\$listorder' class='input-text-c'></td>
<td align='center'>\$id</td>
<td >\$spacer\$cname</td>
<td align='center'>\$str_manage</td>
</tr>";
$tree->init($array);
$categorys = $tree->get_tree(0, $str);
include $this->admin_tpl('member_menu');
}
function add() {
if(isset($_POST['dosubmit'])) {
$this->db->insert($_POST['info']);
//开发过程中用于自动创建语言包
$file = PC_PATH.'languages'.DIRECTORY_SEPARATOR.'zh-cn'.DIRECTORY_SEPARATOR.'member_menu.lang.php';
if(file_exists($file)) {
$content = file_get_contents($file);
$content = substr($content,0,-2);
$key = $_POST['info']['name'];
$data = $content."\$LANG['$key'] = '$_POST[language]';\r\n?>";
file_put_contents($file,$data);
} else {
$key = $_POST['info']['name'];
$data = "<?php\r\n\$LANG['$key'] = '$_POST[language]';\r\n?>";
file_put_contents($file,$data);
}
//结束
showmessage(L('add_success'));
} else {
$show_validator = '';
$tree = pc_base::load_sys_class('tree');
$result = $this->db->select();
foreach($result as $r) {
$r['cname'] = L($r['name'], '', 'member_menu');
$r['selected'] = $r['id'] == $_GET['parentid'] ? 'selected' : '';
$array[] = $r;
}
$str = "<option value='\$id' \$selected>\$spacer \$cname</option>";
$tree->init($array);
$select_categorys = $tree->get_tree(0, $str);
include $this->admin_tpl('member_menu');
}
}
function delete() {
$_GET['id'] = intval($_GET['id']);
$this->db->delete(array('id'=>$_GET['id']));
showmessage(L('operation_success'));
}
function edit() {
if(isset($_POST['dosubmit'])) {
$id = intval($_POST['id']);
$this->db->update($_POST['info'],array('id'=>$id));
//修改语言文件
$file = PC_PATH.'languages'.DIRECTORY_SEPARATOR.'zh-cn'.DIRECTORY_SEPARATOR.'system_menu.lang.php';
require $file;
$key = $_POST['info']['name'];
if(!isset($LANG[$key])) {
$content = file_get_contents($file);
$content = substr($content,0,-2);
$data = $content."\$LANG['$key'] = '$_POST[language]';\r\n?>";
file_put_contents($file,$data);
} elseif(isset($LANG[$key]) && $LANG[$key]!=$_POST['language']) {
$content = file_get_contents($file);
$content = str_replace($LANG[$key],$_POST['language'],$content);
file_put_contents($file,$content);
}
//结束语言文件修改
showmessage(L('operation_success'));
} else {
$show_validator = '';
$tree = pc_base::load_sys_class('tree');
$id = intval($_GET['id']);
$r = $this->db->get_one(array('id'=>$id));
if($r) extract($r);
$result = $this->db->select();
foreach($result as $r) {
$r['cname'] = L($r['name'], '', 'member_menu');
$r['selected'] = $r['id'] == $parentid ? 'selected' : '';
$array[] = $r;
}
$str = "<option value='\$id' \$selected>\$spacer \$cname</option>";
$tree->init($array);
$select_categorys = $tree->get_tree(0, $str);
include $this->admin_tpl('member_menu');
}
}
/**
* 排序
*/
function listorder() {
if(isset($_POST['dosubmit'])) {
foreach($_POST['listorders'] as $id => $listorder) {
$this->db->update(array('listorder'=>$listorder),array('id'=>$id));
}
showmessage(L('operation_success'));
} else {
showmessage(L('operation_failure'));
}
}
}
?>
|
108wo
|
phpcms/modules/member/member_menu.php
|
PHP
|
asf20
| 4,640
|
<?php
/**
* 管理员后台会员模型操作类
*/
defined('IN_PHPCMS') or exit('No permission resources.');
pc_base::load_app_class('admin', 'admin', 0);
pc_base::load_sys_class('form', '', 0);
//模型原型存储路径
define('MODEL_PATH',PC_PATH.'modules'.DIRECTORY_SEPARATOR.'member'.DIRECTORY_SEPARATOR.'fields'.DIRECTORY_SEPARATOR);
//模型缓存路径
define('CACHE_MODEL_PATH',CACHE_PATH.'caches_model'.DIRECTORY_SEPARATOR.'caches_data'.DIRECTORY_SEPARATOR);
class member_model extends admin {
private $db;
function __construct() {
parent::__construct();
$this->db = pc_base::load_model('sitemodel_model');
}
/**
* 会员模型列表
*/
function manage() {
$page = isset($_GET['page']) ? intval($_GET['page']) : 1;
$member_model_list = $this->db->listinfo(array('type'=>2, 'siteid'=>$this->get_siteid()), 'sort', $page, 10);
$pages = $this->db->pages;
$big_menu = array('javascript:window.top.art.dialog({id:\'add\',iframe:\'?m=member&c=member_model&a=add\', title:\''.L('add_model').'\', width:\'700\', height:\'500\', lock:true}, function(){var d = window.top.art.dialog({id:\'add\'}).data.iframe;var form = d.document.getElementById(\'dosubmit\');form.click();return false;}, function(){window.top.art.dialog({id:\'add\'}).close()});void(0);', L('member_model_add'));
include $this->admin_tpl('member_model_list');
}
/**
* 添加会员模型
*/
function add() {
if(isset($_POST['dosubmit'])) {
$info = array();
$info['name'] = $_POST['info']['modelname'];
$info['tablename'] = 'member_'.$_POST['info']['tablename'];
$info['description'] = $_POST['info']['description'];
$info['type'] = 2;
$info['siteid'] = $this->get_siteid();
if(!empty($_FILES['model_import']['tmp_name'])) {
$model_import = @file_get_contents($_FILES['model_import']['tmp_name']);
if(!empty($model_import)) {
$model_import_data = string2array($model_import);
}
}
$is_exists = $this->db->table_exists($info['tablename']);
if($is_exists) showmessage(L('operation_failure'),'?m=member&c=member_model&a=manage', '', 'add');
$modelid = $this->db->insert($info, 1);
if($modelid) {
$model_sql = file_get_contents(MODEL_PATH.'model.sql');
$tablepre = $this->db->db_tablepre;
$tablename = $info['tablename'];
$model_sql = str_replace('$tablename', $tablepre.$tablename, $model_sql);
$this->db->sql_execute($model_sql);
if(!empty($model_import_data)) {
$this->sitemodel_field_db = pc_base::load_model('sitemodel_field_model');
$tablename = $tablepre.$tablename;
foreach($model_import_data as $v) {
//修改模型表字段
$field = $v['field'];
$minlength = $v['minlength'] ? $v['minlength'] : 0;
$maxlength = $v['maxlength'] ? $v['maxlength'] : 0;
$field_type = $v['formtype'];
require MODEL_PATH.$field_type.DIRECTORY_SEPARATOR.'config.inc.php';
if(isset($v['setting']['fieldtype'])) {
$field_type = $v['setting']['fieldtype'];
}
require MODEL_PATH.'add.sql.php';
$v['setting'] = array2string($v['setting']);
$v['modelid'] = $modelid;
unset($v['fieldid']);
$fieldid = $this->sitemodel_field_db->insert($v, 1);
}
}
//更新模型缓存
pc_base::load_app_class('member_cache','','');
member_cache::update_cache_model();
showmessage(L('operation_success'),'?m=member&c=member_model&a=manage', '', 'add');
} else {
showmessage(L('operation_failue'),'?m=member&c=member_model&a=manage', '', 'add');
}
} else {
$show_header = $show_scroll = true;
include $this->admin_tpl('member_model_add');
}
}
/**
* 修改会员模型
*/
function edit() {
if(isset($_POST['dosubmit'])) {
$modelid = isset($_POST['info']['modelid']) ? $_POST['info']['modelid'] :showmessage(L('operation_success'),'?m=member&c=member_model&a=manage', '', 'edit');
$info['name'] = $_POST['info']['modelname'];
$info['disabled'] = $_POST['info']['disabled'] ? 1 : 0;
$info['description'] = $_POST['info']['description'];
$this->db->update($info, array('modelid'=>$modelid));
//更新模型缓存
pc_base::load_app_class('member_cache','','');
member_cache::update_cache_model();
showmessage(L('operation_success'),'?m=member&c=member_model&a=manage', '', 'edit');
} else {
$show_header = $show_scroll = true;
$modelinfo = $this->db->get_one(array('modelid'=>$_GET['modelid']));
include $this->admin_tpl('member_model_edit');
}
}
/**
* 删除会员模型
*/
function delete() {
$modelidarr = isset($_POST['modelid']) ? $_POST['modelid'] : showmessage(L('illegal_parameters'), HTTP_REFERER);
$where = to_sqls($modelidarr, '', 'modelid');
$modelinfo = $this->db->select($where);
foreach($modelinfo as $v) {
$this->db->drop_table($v['tablename']);
}
if ($this->db->delete($where)) {
//删除模型字段
$this->sitemodel_field_db = pc_base::load_model('sitemodel_field_model');
$this->sitemodel_field_db->delete($where);
//修改用户模型组为普通会员
$this->member_db = pc_base::load_model('members_model');
$this->member_db->update(array('modelid'=>10), $where);
//更新模型缓存
pc_base::load_app_class('member_cache','','');
member_cache::update_cache_model();
showmessage(L('operation_success'), HTTP_REFERER);
} else {
showmessage(L('operation_failure'), HTTP_REFERER);
}
}
/**
* 导入会员模型
*/
function import(){
include $this->admin_tpl('member_model_import');
}
/**
* 导出会员模型
*/
function export() {
$modelid = isset($_GET['modelid']) ? $_GET['modelid'] : showmessage(L('illegal_parameters'), HTTP_REFERER);
$modelarr = getcache('member_model', 'commons');
$this->sitemodel_field_db = pc_base::load_model('sitemodel_field_model');
$modelinfo = $this->sitemodel_field_db->select(array('modelid'=>$modelid));
foreach($modelinfo as $k=>$v) {
$modelinfoarr[$k] = $v;
$modelinfoarr[$k]['setting'] = string2array($v['setting']);
}
$res = var_export($modelinfoarr, TRUE);
header('Content-Disposition: attachment; filename="'.$modelarr[$modelid]['tablename'].'.model"');
echo $res;exit;
}
/**
* 修改会员模型
*/
function move() {
if(isset($_POST['dosubmit'])) {
$from_modelid = isset($_POST['from_modelid']) ? $_POST['from_modelid'] : showmessage(L('illegal_parameters'), HTTP_REFERER);
$to_modelid = !empty($_POST['to_modelid']) && $_POST['to_modelid'] != $from_modelid ? $_POST['to_modelid'] : showmessage(L('illegal_parameters'), HTTP_REFERER);
//更新会员表modelid
$this->db->change_member_modelid($from_modelid, $to_modelid);
showmessage(L('member_move').L('operation_success'), HTTP_REFERER, '', 'move');
} else {
$show_header = $show_scroll = true;
$modelarr = $this->db->select(array('type'=>2));
foreach($modelarr as $v) {
$modellist[$v['modelid']] = $v['name'];
}
include $this->admin_tpl('member_model_move');
}
}
/**
* 排序会员模型
*/
function sort() {
if(isset($_POST['sort'])) {
foreach($_POST['sort'] as $k=>$v) {
$this->db->update(array('sort'=>$v), array('modelid'=>$k));
}
//更新模型缓存
pc_base::load_app_class('member_cache','','');
member_cache::update_cache_model();
showmessage(L('operation_success'), HTTP_REFERER);
} else {
showmessage(L('operation_failure'), HTTP_REFERER);
}
}
/**
* 检查模型名称
* @param string $username 模型名
* @return $status {0:模型名已经存在 ;1:成功}
*/
public function public_checkmodelname_ajax() {
$modelname = isset($_GET['modelname']) ? trim($_GET['modelname']) : exit('0');
if(CHARSET != 'utf-8') {
$modelname = iconv('utf-8', CHARSET, $modelname);
$modelname = addslashes($modelname);
}
$oldmodelname = $_GET['oldmodelname'];
if($modelname==$oldmodelname) exit('1');
$status = $this->db->get_one(array('name'=>$modelname));
if($status) {
exit('0');
} else {
exit('1');
}
}
/**
* 检查模型表是否存在
* @param string $username 模型名
* @return $status {0:模型表名已经存在 ;1:成功}
*/
public function public_checktablename_ajax() {
$tablename = isset($_GET['tablename']) ? trim($_GET['tablename']) : exit('0');
$status = $this->db->table_exists('member_'.$tablename);
if($status) {
exit('0');
} else {
exit('1');
}
}
}
?>
|
108wo
|
phpcms/modules/member/member_model.php
|
PHP
|
asf20
| 8,742
|
<?php
/**
* 管理员后台会员操作类
*/
defined('IN_PHPCMS') or exit('No permission resources.');
//模型缓存路径
define('CACHE_MODEL_PATH',CACHE_PATH.'caches_model'.DIRECTORY_SEPARATOR.'caches_data'.DIRECTORY_SEPARATOR);
pc_base::load_app_class('admin', 'admin', 0);
pc_base::load_sys_class('format', '', 0);
pc_base::load_sys_class('form', '', 0);
pc_base::load_app_func('util', 'content');
class member extends admin {
private $db, $verify_db;
function __construct() {
parent::__construct();
$this->db = pc_base::load_model('member_model');
$this->_init_phpsso();
}
/**
* defalut
*/
function init() {
$show_header = $show_scroll = true;
pc_base::load_sys_class('form', '', 0);
$this->verify_db = pc_base::load_model('member_verify_model');
//搜索框
$keyword = isset($_GET['keyword']) ? $_GET['keyword'] : '';
$type = isset($_GET['type']) ? $_GET['type'] : '';
$groupid = isset($_GET['groupid']) ? $_GET['groupid'] : '';
$start_time = isset($_GET['start_time']) ? $_GET['start_time'] : date('Y-m-d', SYS_TIME-date('t', SYS_TIME)*86400);
$end_time = isset($_GET['end_time']) ? $_GET['end_time'] : date('Y-m-d', SYS_TIME);
$grouplist = getcache('grouplist');
foreach($grouplist as $k=>$v) {
$grouplist[$k] = $v['name'];
}
$memberinfo['totalnum'] = $this->db->count();
$memberinfo['vipnum'] = $this->db->count(array('vip'=>1));
$memberinfo['verifynum'] = $this->verify_db->count(array('status'=>0));
$todaytime = strtotime(date('Y-m-d', SYS_TIME));
$memberinfo['today_member'] = $this->db->count("`regdate` > '$todaytime'");
include $this->admin_tpl('member_init');
}
/**
* 会员搜索
*/
function search() {
//搜索框
$keyword = isset($_GET['keyword']) ? $_GET['keyword'] : '';
$type = isset($_GET['type']) ? $_GET['type'] : '';
$groupid = isset($_GET['groupid']) ? $_GET['groupid'] : '';
$modelid = isset($_GET['modelid']) ? $_GET['modelid'] : '';
//站点信息
$sitelistarr = getcache('sitelist', 'commons');
$siteid = isset($_GET['siteid']) ? intval($_GET['siteid']) : '0';
foreach ($sitelistarr as $k=>$v) {
$sitelist[$k] = $v['name'];
}
$status = isset($_GET['status']) ? $_GET['status'] : '';
$amount_from = isset($_GET['amount_from']) ? $_GET['amount_from'] : '';
$amount_to = isset($_GET['amount_to']) ? $_GET['amount_to'] : '';
$point_from = isset($_GET['point_from']) ? $_GET['point_from'] : '';
$point_to = isset($_GET['point_to']) ? $_GET['point_to'] : '';
$start_time = isset($_GET['start_time']) ? $_GET['start_time'] : '';
$end_time = isset($_GET['end_time']) ? $_GET['end_time'] : date('Y-m-d', SYS_TIME);
$grouplist = getcache('grouplist');
foreach($grouplist as $k=>$v) {
$grouplist[$k] = $v['name'];
}
//会员所属模型
$modellistarr = getcache('member_model', 'commons');
foreach ($modellistarr as $k=>$v) {
$modellist[$k] = $v['name'];
}
if (isset($_GET['search'])) {
//默认选取一个月内的用户,防止用户量过大给数据造成灾难
$where_start_time = strtotime($start_time) ? strtotime($start_time) : 0;
$where_end_time = strtotime($end_time) + 86400;
//开始时间大于结束时间,置换变量
if($where_start_time > $where_end_time) {
$tmp = $where_start_time;
$where_start_time = $where_end_time;
$where_end_time = $tmp;
$tmptime = $start_time;
$start_time = $end_time;
$end_time = $tmptime;
unset($tmp, $tmptime);
}
$where = '';
//如果是超级管理员角色,显示所有用户,否则显示当前站点用户
if($_SESSION['roleid'] == 1) {
if(!empty($siteid)) {
$where .= "`siteid` = '$siteid' AND ";
}
} else {
$siteid = get_siteid();
$where .= "`siteid` = '$siteid' AND ";
}
if($status) {
$islock = $status == 1 ? 1 : 0;
$where .= "`islock` = '$islock' AND ";
}
if($groupid) {
$where .= "`groupid` = '$groupid' AND ";
}
if($modelid) {
$where .= "`modelid` = '$modelid' AND ";
}
$where .= "`regdate` BETWEEN '$where_start_time' AND '$where_end_time' AND ";
//资金范围
if($amount_from) {
if($amount_to) {
if($amount_from > $amount_to) {
$tmp = $amount_from;
$amount_from = $amount_to;
$amount_to = $tmp;
unset($tmp);
}
$where .= "`amount` BETWEEN '$amount_from' AND '$amount_to' AND ";
} else {
$where .= "`amount` > '$amount_from' AND ";
}
}
//点数范围
if($point_from) {
if($point_to) {
if($point_from > $point_to) {
$tmp = $amount_from;
$point_from = $point_to;
$point_to = $tmp;
unset($tmp);
}
$where .= "`point` BETWEEN '$point_from' AND '$point_to' AND ";
} else {
$where .= "`point` > '$point_from' AND ";
}
}
if($keyword) {
if ($type == '1') {
$where .= "`username` LIKE '%$keyword%'";
} elseif($type == '2') {
$where .= "`userid` = '$keyword'";
} elseif($type == '3') {
$where .= "`email` like '%$keyword%'";
} elseif($type == '4') {
$where .= "`regip` = '$keyword'";
} elseif($type == '5') {
$where .= "`nickname` LIKE '%$keyword%'";
} else {
$where .= "`username` like '%$keyword%'";
}
} else {
$where .= '1';
}
} else {
$where = '';
}
$page = isset($_GET['page']) ? intval($_GET['page']) : 1;
$memberlist = $this->db->listinfo($where, 'userid DESC', $page, 15);
$pages = $this->db->pages;
$big_menu = array('?m=member&c=member&a=manage&menuid=72', L('member_research'));
include $this->admin_tpl('member_list');
}
/**
* member list
*/
function manage() {
$sitelistarr = getcache('sitelist', 'commons');
foreach ($sitelistarr as $k=>$v) {
$sitelist[$k] = $v['name'];
}
$groupid = isset($_GET['groupid']) ? intval($_GET['groupid']) : '';
$page = isset($_GET['page']) ? intval($_GET['page']) : 1;
//如果是超级管理员角色,显示所有用户,否则显示当前站点用户
if($_SESSION['roleid'] == 1) {
$where = '';
} else {
$siteid = get_siteid();
$where .= "`siteid` = '$siteid'";
}
$memberlist_arr = $this->db->listinfo($where, 'userid DESC', $page, 15);
$pages = $this->db->pages;
//搜索框
$keyword = isset($_GET['keyword']) ? $_GET['keyword'] : '';
$type = isset($_GET['type']) ? $_GET['type'] : '';
$start_time = isset($_GET['start_time']) ? $_GET['start_time'] : '';
$end_time = isset($_GET['end_time']) ? $_GET['end_time'] : date('Y-m-d', SYS_TIME);
$grouplist = getcache('grouplist');
foreach($grouplist as $k=>$v) {
$grouplist[$k] = $v['name'];
}
//会员所属模型
$modellistarr = getcache('member_model', 'commons');
foreach ($modellistarr as $k=>$v) {
$modellist[$k] = $v['name'];
}
//查询会员头像
foreach($memberlist_arr as $k=>$v) {
$memberlist[$k] = $v;
$memberlist[$k]['avatar'] = get_memberavatar($v['phpssouid']);
}
$big_menu = array('javascript:window.top.art.dialog({id:\'add\',iframe:\'?m=member&c=member&a=add\', title:\''.L('member_add').'\', width:\'700\', height:\'500\', lock:true}, function(){var d = window.top.art.dialog({id:\'add\'}).data.iframe;var form = d.document.getElementById(\'dosubmit\');form.click();return false;}, function(){window.top.art.dialog({id:\'add\'}).close()});void(0);', L('member_add'));
include $this->admin_tpl('member_list');
}
/**
* add member
*/
function add() {
header("Cache-control: private");
if(isset($_POST['dosubmit'])) {
$info = array();
if(!$this->_checkname($_POST['info']['username'])){
showmessage(L('member_exist'));
}
$info = $this->_checkuserinfo($_POST['info']);
if(!$this->_checkpasswd($info['password'])){
showmessage(L('password_format_incorrect'));
}
$info['regip'] = ip();
$info['overduedate'] = strtotime($info['overduedate']);
$status = $this->client->ps_member_register($info['username'], $info['password'], $info['email'], $info['regip']);
if($status > 0) {
unset($info[pwdconfirm]);
$info['phpssouid'] = $status;
//取phpsso密码随机数
$memberinfo = $this->client->ps_get_member_info($status);
$memberinfo = unserialize($memberinfo);
$info['encrypt'] = $memberinfo['random'];
$info['password'] = password($info['password'], $info['encrypt']);
$info['regdate'] = $info['lastdate'] = SYS_TIME;
$this->db->insert($info);
if($this->db->insert_id()){
showmessage(L('operation_success'),'?m=member&c=member&a=add', '', 'add');
}
} elseif($status == -4) {
showmessage(L('username_deny'), HTTP_REFERER);
} elseif($status == -5) {
showmessage(L('email_deny'), HTTP_REFERER);
} else {
showmessage(L('operation_failure'), HTTP_REFERER);
}
} else {
$show_header = $show_scroll = true;
$siteid = get_siteid();
//会员组缓存
$group_cache = getcache('grouplist', 'member');
foreach($group_cache as $_key=>$_value) {
$grouplist[$_key] = $_value['name'];
}
//会员模型缓存
$member_model_cache = getcache('member_model', 'commons');
foreach($member_model_cache as $_key=>$_value) {
if($siteid == $_value['siteid']) {
$modellist[$_key] = $_value['name'];
}
}
include $this->admin_tpl('member_add');
}
}
/**
* edit member
*/
function edit() {
if(isset($_POST['dosubmit'])) {
$memberinfo = $info = array();
$basicinfo['userid'] = $_POST['info']['userid'];
$basicinfo['username'] = $_POST['info']['username'];
$basicinfo['nickname'] = $_POST['info']['nickname'];
$basicinfo['email'] = $_POST['info']['email'];
$basicinfo['point'] = $_POST['info']['point'];
$basicinfo['password'] = $_POST['info']['password'];
$basicinfo['groupid'] = $_POST['info']['groupid'];
$basicinfo['modelid'] = $_POST['info']['modelid'];
$basicinfo['vip'] = $_POST['info']['vip'];
$basicinfo['overduedate'] = strtotime($_POST['info']['overduedate']);
//会员基本信息
$info = $this->_checkuserinfo($basicinfo, 1);
//会员模型信息
$modelinfo = array_diff($_POST['info'], $info);
//过滤vip过期时间
unset($modelinfo['overduedate']);
unset($modelinfo['pwdconfirm']);
$userid = $info['userid'];
//如果是超级管理员角色,显示所有用户,否则显示当前站点用户
if($_SESSION['roleid'] == 1) {
$where = array('userid'=>$userid);
} else {
$siteid = get_siteid();
$where = array('userid'=>$userid, 'siteid'=>$siteid);
}
$userinfo = $this->db->get_one($where);
if(empty($userinfo)) {
showmessage(L('user_not_exist').L('or').L('no_permission'), HTTP_REFERER);
}
//删除用户头像
if(!empty($_POST['delavatar'])) {
$this->client->ps_deleteavatar($userinfo['phpssouid']);
}
$status = $this->client->ps_member_edit($info['username'], $info['email'], '', $info['password'], $userinfo['phpssouid'], $userinfo['encrypt']);
if($status >= 0) {
unset($info['userid']);
unset($info['username']);
//如果密码不为空,修改用户密码。
if(isset($info['password']) && !empty($info['password'])) {
$info['password'] = password($info['password'], $userinfo['encrypt']);
} else {
unset($info['password']);
}
$this->db->update($info, array('userid'=>$userid));
require_once CACHE_MODEL_PATH.'member_input.class.php';
require_once CACHE_MODEL_PATH.'member_update.class.php';
$member_input = new member_input($basicinfo['modelid']);
$modelinfo = $member_input->get($modelinfo);
//更新模型表,方法更新了$this->table
$this->db->set_model($info['modelid']);
$userinfo = $this->db->get_one(array('userid'=>$userid));
if($userinfo) {
$this->db->update($modelinfo, array('userid'=>$userid));
} else {
$modelinfo['userid'] = $userid;
$this->db->insert($modelinfo);
}
showmessage(L('operation_success'), '?m=member&c=member&a=manage', '', 'edit');
} else {
showmessage(L('operation_failure'), HTTP_REFERER);
}
} else {
$show_header = $show_scroll = true;
$siteid = get_siteid();
$userid = isset($_GET['userid']) ? $_GET['userid'] : showmessage(L('illegal_parameters'), HTTP_REFERER);
//会员组缓存
$group_cache = getcache('grouplist', 'member');
foreach($group_cache as $_key=>$_value) {
$grouplist[$_key] = $_value['name'];
}
//会员模型缓存
$member_model_cache = getcache('member_model', 'commons');
foreach($member_model_cache as $_key=>$_value) {
if($siteid == $_value['siteid']) {
$modellist[$_key] = $_value['name'];
}
}
//如果是超级管理员角色,显示所有用户,否则显示当前站点用户
if($_SESSION['roleid'] == 1) {
$where = array('userid'=>$userid);
} else {
$where = array('userid'=>$userid, 'siteid'=>$siteid);
}
$memberinfo = $this->db->get_one($where);
if(empty($memberinfo)) {
showmessage(L('user_not_exist').L('or').L('no_permission'), HTTP_REFERER);
}
$memberinfo['avatar'] = get_memberavatar($memberinfo['phpssouid'], '', 90);
$modelid = isset($_GET['modelid']) ? $_GET['modelid'] : $memberinfo['modelid'];
//获取会员模型表单
require CACHE_MODEL_PATH.'member_form.class.php';
$member_form = new member_form($modelid);
$form_overdudate = form::date('info[overduedate]', date('Y-m-d H:i:s',$memberinfo['overduedate']), 1);
$this->db->set_model($modelid);
$membermodelinfo = $this->db->get_one(array('userid'=>$userid));
$forminfos = $forminfos_arr = $member_form->get($membermodelinfo);
//万能字段过滤
foreach($forminfos as $field=>$info) {
if($info['isomnipotent']) {
unset($forminfos[$field]);
} else {
if($info['formtype']=='omnipotent') {
foreach($forminfos_arr as $_fm=>$_fm_value) {
if($_fm_value['isomnipotent']) {
$info['form'] = str_replace('{'.$_fm.'}',$_fm_value['form'], $info['form']);
}
}
$forminfos[$field]['form'] = $info['form'];
}
}
}
$show_dialog = 1;
include $this->admin_tpl('member_edit');
}
}
/**
* delete member
*/
function delete() {
$uidarr = isset($_POST['userid']) ? $_POST['userid'] : showmessage(L('illegal_parameters'), HTTP_REFERER);
$where = to_sqls($uidarr, '', 'userid');
$phpsso_userinfo = $this->db->listinfo($where);
$phpssouidarr = array();
if(is_array($phpsso_userinfo)) {
foreach($phpsso_userinfo as $v) {
if(!empty($v['phpssouid'])) {
$phpssouidarr[] = $v['phpssouid'];
}
}
}
//查询用户信息
$userinfo_arr = $this->db->select($where, "userid, modelid");
$userinfo = array();
if(is_array($userinfo_arr)) {
foreach($userinfo_arr as $v) {
$userinfo[$v['userid']] = $v['modelid'];
}
}
//delete phpsso member first
if(!empty($phpssouidarr)) {
$status = $this->client->ps_delete_member($phpssouidarr, 1);
if($status > 0) {
if ($this->db->delete($where)) {
//删除用户模型用户资料
foreach($uidarr as $v) {
if(!empty($userinfo[$v])) {
$this->db->set_model($userinfo[$v]);
$this->db->delete(array('userid'=>$v));
}
}
showmessage(L('operation_success'), HTTP_REFERER);
} else {
showmessage(L('operation_failure'), HTTP_REFERER);
}
} else {
showmessage(L('operation_failure'), HTTP_REFERER);
}
} else {
if ($this->db->delete($where)) {
showmessage(L('operation_success'), HTTP_REFERER);
} else {
showmessage(L('operation_failure'), HTTP_REFERER);
}
}
}
/**
* lock member
*/
function lock() {
if(isset($_POST['userid'])) {
$uidarr = isset($_POST['userid']) ? $_POST['userid'] : showmessage(L('illegal_parameters'), HTTP_REFERER);
$where = to_sqls($uidarr, '', 'userid');
$this->db->update(array('islock'=>1), $where);
showmessage(L('member_lock').L('operation_success'), HTTP_REFERER);
} else {
showmessage(L('operation_failure'), HTTP_REFERER);
}
}
/**
* unlock member
*/
function unlock() {
if(isset($_POST['userid'])) {
$uidarr = isset($_POST['userid']) ? $_POST['userid'] : showmessage(L('illegal_parameters'), HTTP_REFERER);
$where = to_sqls($uidarr, '', 'userid');
$this->db->update(array('islock'=>0), $where);
showmessage(L('member_unlock').L('operation_success'), HTTP_REFERER);
} else {
showmessage(L('operation_failure'), HTTP_REFERER);
}
}
/**
* move member
*/
function move() {
if(isset($_POST['dosubmit'])) {
$uidarr = isset($_POST['userid']) ? $_POST['userid'] : showmessage(L('illegal_parameters'), HTTP_REFERER);
$groupid = isset($_POST['groupid']) && !empty($_POST['groupid']) ? $_POST['groupid'] : showmessage(L('illegal_parameters'), HTTP_REFERER);
$where = to_sqls($uidarr, '', 'userid');
$this->db->update(array('groupid'=>$groupid), $where);
showmessage(L('member_move').L('operation_success'), HTTP_REFERER, '', 'move');
} else {
$show_header = $show_scroll = true;
$grouplist = getcache('grouplist');
foreach($grouplist as $k=>$v) {
$grouplist[$k] = $v['name'];
}
$ids = isset($_GET['ids']) ? explode(',', $_GET['ids']): showmessage(L('illegal_parameters'), HTTP_REFERER);
array_pop($ids);
if(!empty($ids)) {
$where = to_sqls($ids, '', 'userid');
$userarr = $this->db->listinfo($where);
} else {
showmessage(L('illegal_parameters'), HTTP_REFERER, '', 'move');
}
include $this->admin_tpl('member_move');
}
}
function memberinfo() {
$show_header = false;
$userid = !empty($_GET['userid']) ? intval($_GET['userid']) : '';
$username = !empty($_GET['username']) ? trim($_GET['username']) : '';
if(!empty($userid)) {
$memberinfo = $this->db->get_one(array('userid'=>$userid));
} elseif(!empty($username)) {
$memberinfo = $this->db->get_one(array('username'=>$username));
} else {
showmessage(L('illegal_parameters'), HTTP_REFERER);
}
if(empty($memberinfo)) {
showmessage(L('user').L('not_exists'), HTTP_REFERER);
}
$memberinfo['avatar'] = get_memberavatar($memberinfo['phpssouid'], '', 90);
$grouplist = getcache('grouplist');
//会员模型缓存
$modellist = getcache('member_model', 'commons');
$modelid = !empty($_GET['modelid']) ? intval($_GET['modelid']) : $memberinfo['modelid'];
//站群缓存
$sitelist =getcache('sitelist', 'commons');
$this->db->set_model($modelid);
$member_modelinfo = $this->db->get_one(array('userid'=>$userid));
//模型字段名称
$model_fieldinfo = getcache('model_field_'.$modelid, 'model');
//图片字段显示图片
foreach($model_fieldinfo as $k=>$v) {
if($v['formtype'] == 'image') {
$member_modelinfo[$k] = "<a href='.$member_modelinfo[$k].' target='_blank'><img src='.$member_modelinfo[$k].' height='40' widht='40' onerror=\"this.src='$phpsso_api_url/statics/images/member/nophoto.gif'\"></a>";
} elseif($v['formtype'] == 'images') {
$tmp = string2array($member_modelinfo[$k]);
$member_modelinfo[$k] = '';
if(is_array($tmp)) {
foreach ($tmp as $tv) {
$member_modelinfo[$k] .= " <a href='$tv[url]' target='_blank'><img src='$tv[url]' height='40' widht='40' onerror=\"this.src='$phpsso_api_url/statics/images/member/nophoto.gif'\"></a>";
}
unset($tmp);
}
} elseif($v['formtype'] == 'box') { //box字段,获取字段名称和值的数组
$tmp = explode("\n",$v['options']);
if(is_array($tmp)) {
foreach($tmp as $boxv) {
$box_tmp_arr = explode('|', trim($boxv));
if(is_array($box_tmp_arr) && isset($box_tmp_arr[1]) && isset($box_tmp_arr[0])) {
$box_tmp[$box_tmp_arr[1]] = $box_tmp_arr[0];
$tmp_key = intval($member_modelinfo[$k]);
}
}
}
if(isset($box_tmp[$tmp_key])) {
$member_modelinfo[$k] = $box_tmp[$tmp_key];
} else {
$member_modelinfo[$k] = $member_modelinfo_arr[$k];
}
unset($tmp, $tmp_key, $box_tmp, $box_tmp_arr);
} elseif($v['formtype'] == 'linkage') { //如果为联动菜单
$tmp = string2array($v['setting']);
$tmpid = $tmp['linageid'];
$linkagelist = getcache($tmpid, 'linkage');
$fullname = $this->_get_linkage_fullname($member_modelinfo[$k], $linkagelist);
$member_modelinfo[$v['name']] = substr($fullname, 0, -1);
unset($tmp, $tmpid, $linkagelist, $fullname);
} else {
$member_modelinfo[$k] = $member_modelinfo[$k];
}
}
$member_fieldinfo = array();
//交换数组key值
foreach($model_fieldinfo as $v) {
if(!empty($member_modelinfo) && array_key_exists($v['field'], $member_modelinfo)) {
$tmp = $member_modelinfo[$v['field']];
unset($member_modelinfo[$v['field']]);
$member_fieldinfo[$v['name']] = $tmp;
unset($tmp);
} else {
$member_fieldinfo[$v['name']] = '';
}
}
include $this->admin_tpl('member_moreinfo');
}
/*
* 通过linkageid获取名字路径
*/
private function _get_linkage_fullname($linkageid, $linkagelist) {
$fullname = '';
if($linkagelist['data'][$linkageid]['parentid'] != 0) {
$fullname = $this->_get_linkage_fullname($linkagelist['data'][$linkageid]['parentid'], $linkagelist);
}
//所在地区名称
$return = $fullname.$linkagelist['data'][$linkageid]['name'].'>';
return $return;
}
private function _checkuserinfo($data, $is_edit=0) {
if(!is_array($data)){
showmessage(L('need_more_param'));return false;
} elseif (!is_username($data['username']) && !$is_edit){
showmessage(L('username_format_incorrect'));return false;
} elseif (!isset($data['userid']) && $is_edit) {
showmessage(L('username_format_incorrect'));return false;
} elseif (empty($data['email']) || !is_email($data['email'])){
showmessage(L('email_format_incorrect'));return false;
}
return $data;
}
private function _checkpasswd($password){
if (!is_password($password)){
return false;
}
return true;
}
private function _checkname($username) {
$username = trim($username);
if ($this->db->get_one(array('username'=>$username))){
return false;
}
return true;
}
/**
* 初始化phpsso
* about phpsso, include client and client configure
* @return string phpsso_api_url phpsso地址
*/
private function _init_phpsso() {
pc_base::load_app_class('client', '', 0);
define('APPID', pc_base::load_config('system', 'phpsso_appid'));
$phpsso_api_url = pc_base::load_config('system', 'phpsso_api_url');
$phpsso_auth_key = pc_base::load_config('system', 'phpsso_auth_key');
$this->client = new client($phpsso_api_url, $phpsso_auth_key);
return $phpsso_api_url;
}
/**
* 检查用户名
* @param string $username 用户名
* @return $status {-4:用户名禁止注册;-1:用户名已经存在 ;1:成功}
*/
public function public_checkname_ajax() {
$username = isset($_GET['username']) && trim($_GET['username']) ? trim($_GET['username']) : exit(0);
if(CHARSET != 'utf-8') {
$username = iconv('utf-8', CHARSET, $username);
$username = addslashes($username);
}
$status = $this->client->ps_checkname($username);
if($status == -4 || $status == -1) {
exit('0');
} else {
exit('1');
}
}
/**
* 检查邮箱
* @param string $email
* @return $status {-1:email已经存在 ;-5:邮箱禁止注册;1:成功}
*/
public function public_checkemail_ajax() {
$email = isset($_GET['email']) && trim($_GET['email']) ? trim($_GET['email']) : exit(0);
$status = $this->client->ps_checkemail($email);
if($status == -5) { //禁止注册
exit('0');
} elseif($status == -1) { //用户名已存在,但是修改用户的时候需要判断邮箱是否是当前用户的
if(isset($_GET['phpssouid'])) { //修改用户传入phpssouid
$status = $this->client->ps_get_member_info($email, 3);
if($status) {
$status = unserialize($status); //接口返回序列化,进行判断
if (isset($status['uid']) && $status['uid'] == intval($_GET['phpssouid'])) {
exit('1');
} else {
exit('0');
}
} else {
exit('0');
}
} else {
exit('0');
}
} else {
exit('1');
}
}
}
?>
|
108wo
|
phpcms/modules/member/member.php
|
PHP
|
asf20
| 24,933
|
<?php defined('IN_ADMIN') or exit('No permission resources.');?>
<?php include $this->admin_tpl('header', 'admin');?>
<div class="pad_10">
<div class="common-form">
<form name="myform" action="?m=member&c=member_model&a=move" method="post" id="myform">
<input type="hidden" name="from_modelid" value="<?php echo $_GET['modelid']?>">
<fieldset>
<legend><?php echo L('move').L('model_member')?></legend>
<div class="bk10"></div>
<div class="explain-col">
<?php echo L('move_member_model_alert')?>
</div>
<div class="bk10"></div>
<table width="100%" class="table_form">
<tr>
<td width="120"><?php echo L('from_model_name')?></td>
<td>
<?php echo $modellist[$_GET['modelid']];?>
</td>
</tr>
<tr>
<td width="120"><?php echo L('to_model_name')?></td>
<td>
<?php echo form::select($modellist, 0, 'id="to_modelid" name="to_modelid"', L('please_select'))?>
</td>
</tr>
</table>
</fieldset>
<div class="bk15"></div>
<input name="dosubmit" id="dosubmit" type="submit" value="<?php echo L('submit')?>" class="dialog">
</form>
</div>
</div>
</body>
</html>
|
108wo
|
phpcms/modules/member/templates/member_model_move.tpl.php
|
PHP
|
asf20
| 1,134
|
<?php defined('IN_ADMIN') or exit('No permission resources.');?>
<?php include $this->admin_tpl('header', 'admin');?>
<form name="myform" action="?m=member&c=member_verify&a=delete" method="post" onsubmit="checkuid();return false;">
<div class="pad-lr-10">
<div class="table-list">
<table width="100%" cellspacing="0">
<thead>
<tr>
<th align="left" width="20"><input type="checkbox" value="" id="check_box" onclick="selectall('userid[]');"></th>
<th align="left"><?php echo L('username')?></th>
<th align="left"><?php echo L('email')?></th>
<th align="left"><?php echo L('regtime')?></th>
<th align="left"><?php echo L('model_name')?></th>
<th align="left"><?php echo L('verify_message')?></th>
<th align="left"><?php echo L('verify_status')?></th>
</tr>
</thead>
<tbody>
<?php
foreach($memberlist as $k=>$v) {
?>
<tr>
<td align="left"><input type="checkbox" value="<?php echo $v['userid']?>" name="userid[]"></td>
<td align="left"><?php echo $v['username']?></td>
<td align="left"><?php echo $v['email']?></td>
<td align="left" title="<?php echo $v['regip']?>"><?php echo format::date($v['regdate'], 1);?></td>
<td align="left"><a href="javascript:member_verify(<?php echo $v['userid']?>, '<?php echo $v['modelid']?>', '')"><?php echo $member_model[$v['modelid']]['name']?><img src="<?php echo IMG_PATH?>admin_img/detail.png"></a></td>
<td align="left"><?php echo $v['message']?></td>
<td align="left"><?php $verify_status = array('5'=>L('nerver_pass'), '4'=>L('reject'), '3'=>L('delete'), '2'=>L('ignore'), '0'=>L('need_verify'), '1'=>L('pass')); echo $verify_status[$v['status']]?></td>
</tr>
<?php
}
?>
</tbody>
</table>
<div class="btn">
<label for="check_box"><?php echo L('select_all')?>/<?php echo L('cancel')?></label>
<input type="submit" class="button" name="dosubmit" value="<?php echo L('verify_pass')?>" onclick="document.myform.action='?m=member&c=member_verify&a=pass'"/>
<input type="submit" class="button" name="dosubmit" value="<?php echo L('reject')?>" onclick="document.myform.action='?m=member&c=member_verify&a=reject'"/>
<input type="submit" class="button" name="dosubmit" value="<?php echo L('delete')?>" onclick="return confirm('<?php echo L('sure_delete')?>');"/>
<input type="submit" class="button" name="dosubmit" value="<?php echo L('ignore')?>" onclick="document.myform.action='?m=member&c=member_verify&a=ignore'"/>
<?php echo L('verify_message')?>:<input type="text" name="message"><input type="checkbox" value=1 name="sendemail" checked/><?php echo L('sendemail')?>
</div>
<div id="pages"><?php echo $pages?></div>
</div>
</div>
</form>
<script type="text/javascript">
<!--
function checkuid() {
var ids='';
$("input[name='userid[]']:checked").each(function(i, n){
ids += $(n).val() + ',';
});
if(ids=='') {
window.top.art.dialog({content:'<?php echo L('plsease_select').L('member')?>',lock:true,width:'200',height:'50',time:1.5},function(){});
return false;
} else {
myform.submit();
}
}
function member_verify(userid, modelid, name) {
window.top.art.dialog({id:'modelinfo'}).close();
window.top.art.dialog({title:'<?php echo L('member_verify')?>',id:'modelinfo',iframe:'?m=member&c=member_verify&a=modelinfo&userid='+userid+'&modelid='+modelid,width:'700',height:'500'}, function(){var d = window.top.art.dialog({id:'modelinfo'}).data.iframe;d.document.getElementById('dosubmit').click();return false;}, function(){window.top.art.dialog({id:'modelinfo'}).close()});
}
//-->
</script>
</body>
</html>
|
108wo
|
phpcms/modules/member/templates/member_verify.tpl.php
|
PHP
|
asf20
| 3,630
|
<?php
defined('IN_ADMIN') or exit('No permission resources.');
include $this->admin_tpl('header', 'admin');?>
<?php if(ROUTE_A=='manage') {?>
<form name="myform" action="?m=member&c=member_menu&a=listorder" method="post">
<div class="pad-lr-10">
<div class="table-list">
<table width="100%" cellspacing="0">
<thead>
<tr>
<th width="80"><?php echo L('listorder');?></th>
<th width="100">id</th>
<th><?php echo L('menu_name');?></th>
<th><?php echo L('operations_manage');?></th>
</tr>
</thead>
<tbody>
<?php echo $categorys;?>
</tbody>
</table>
<div class="btn"><input type="submit" class="button" name="dosubmit" value="<?php echo L('listorder')?>" /></div> </div>
</div>
</div>
</form>
</body>
</html>
<?php } elseif(ROUTE_A=='add') {?>
<script type="text/javascript">
<!--
$(function(){
$.formValidator.initConfig({formid:"myform",autotip:true,onerror:function(msg,obj){window.top.art.dialog({content:msg,lock:true,width:'200',height:'50'}, function(){this.close();$(obj).focus();})}});
$("#language").formValidator({onshow:"<?php echo L("input", '', 'admin').L('chinese_name')?>",onfocus:"<?php echo L("input").L('chinese_name')?>",oncorrect:"<?php echo L('input_right');?>"}).inputValidator({min:1,onerror:"<?php echo L("input").L('chinese_name')?>"});
$("#name").formValidator({onshow:"<?php echo L("input").L('menu_name')?>",onfocus:"<?php echo L("input").L('menu_name')?>",oncorrect:"<?php echo L('input_right');?>"}).inputValidator({min:1,onerror:"<?php echo L("input").L('menu_name')?>"});
$("#m").formValidator({onshow:"<?php echo L("input").L('module_name')?>",onfocus:"<?php echo L("input").L('module_name')?>",oncorrect:"<?php echo L('input_right');?>"}).inputValidator({min:1,onerror:"<?php echo L("input").L('module_name')?>"});
$("#c").formValidator({onshow:"<?php echo L("input").L('file_name')?>",onfocus:"<?php echo L("input").L('file_name')?>",oncorrect:"<?php echo L('input_right');?>"}).inputValidator({min:1,onerror:"<?php echo L("input").L('file_name')?>"});
$("#a").formValidator({tipid:'a_tip',onshow:"<?php echo L("input").L('action_name')?>",onfocus:"<?php echo L("input").L('action_name')?>",oncorrect:"<?php echo L('input_right');?>"}).inputValidator({min:1,onerror:"<?php echo L("input").L('action_name')?>"});
})
//-->
</script>
<div class="common-form">
<form name="myform" id="myform" action="?m=member&c=member_menu&a=add" method="post">
<table width="100%" class="table_form contentWrap">
<tr>
<th width="200"><?php echo L('menu_parentid')?>:</th>
<td><select name="info[parentid]" >
<option value="0"><?php echo L('no_parent_menu')?></option>
</select></td>
</tr>
<tr>
<th> <?php echo L('chinese_name')?>:</th>
<td><input type="text" name="language" id="language" class="input-text" ></td>
</tr>
<tr>
<th><?php echo L('menu_name')?>:</th>
<td><input type="text" name="info[name]" id="name" class="input-text" ></td>
</tr>
<?php if(!isset($_GET['isurl']) || (isset($_GET['isurl']) && $_GET['isurl']==0)) {?>
<tr>
<th><?php echo L('module_name')?>:</th>
<td><input type="text" name="info[m]" id="m" class="input-text" ></td>
</tr>
<tr>
<th><?php echo L('file_name')?>:</th>
<td><input type="text" name="info[c]" id="c" class="input-text" ></td>
</tr>
<tr>
<th><?php echo L('action_name')?>:</th>
<td><input type="text" name="info[a]" id="a" class="input-text" > <span id="a_tip"></span><?php echo L('ajax_tip')?></td>
</tr>
<tr>
<th><?php echo L('att_data')?>:</th>
<td><input type="text" name="info[data]" class="input-text" ></td>
</tr>
<?php }?>
<tr>
<th><?php echo L('menu_display')?>:</th>
<td><input type="radio" name="info[display]" value="1" checked> <?php echo L('yes')?><input type="radio" name="info[display]" value="0"> <?php echo L('no')?></td>
</tr>
<tr>
<th><?php echo L('isurl')?>:</th>
<td><input type="radio" name="info[isurl]" value="1" onclick="redirect('<?php echo get_url().'&isurl=1';?>')" <?php if(isset($_GET['isurl']) && $_GET['isurl']==1) echo 'checked';?>> <?php echo L('yes')?><input type="radio" name="info[isurl]" value="0" <?php if(!isset($_GET['isurl']) || (isset($_GET['isurl']) && $_GET['isurl']==0)) echo 'checked';?> onclick="redirect('<?php echo get_url().'&isurl=0';?>')"> <?php echo L('no')?></td>
</tr>
<?php if(isset($_GET['isurl']) && $_GET['isurl']==1) {?>
<tr>
<th><?php echo L('url')?>:</th>
<td><input type="text" name="info[url]" class="input-text" size=80></td>
</tr>
<?php }?>
</table>
<!--table_form_off-->
</div>
<div class="bk15"></div>
<div class="btn"><input type="submit" id="dosubmit" class="button" name="dosubmit" value="<?php echo L('submit')?>"/></div>
</div>
</form>
<?php } elseif(ROUTE_A=='edit') {?>
<script type="text/javascript">
<!--
$(function(){
$.formValidator.initConfig({formid:"myform",autotip:true,onerror:function(msg,obj){window.top.art.dialog({content:msg,lock:true,width:'200',height:'50'}, function(){this.close();$(obj).focus();})}});
$("#language").formValidator({onshow:"<?php echo L("input", '', 'admin').L('chinese_name')?>",onfocus:"<?php echo L("input").L('chinese_name')?>",oncorrect:"<?php echo L('input_right');?>"}).inputValidator({min:1,onerror:"<?php echo L("input").L('chinese_name')?>"});
$("#name").formValidator({onshow:"<?php echo L("input").L('menu_name')?>",onfocus:"<?php echo L("input").L('menu_name')?>",oncorrect:"<?php echo L('input_right');?>"}).inputValidator({min:1,onerror:"<?php echo L("input").L('menu_name')?>"});
$("#m").formValidator({onshow:"<?php echo L("input").L('module_name')?>",onfocus:"<?php echo L("input").L('module_name')?>",oncorrect:"<?php echo L('input_right');?>"}).inputValidator({min:1,onerror:"<?php echo L("input").L('module_name')?>"});
$("#c").formValidator({onshow:"<?php echo L("input").L('file_name')?>",onfocus:"<?php echo L("input").L('file_name')?>",oncorrect:"<?php echo L('input_right');?>"}).inputValidator({min:1,onerror:"<?php echo L("input").L('file_name')?>"});
$("#a").formValidator({tipid:'a_tip',onshow:"<?php echo L("input").L('action_name')?>",onfocus:"<?php echo L("input").L('action_name')?>",oncorrect:"<?php echo L('input_right');?>"}).inputValidator({min:1,onerror:"<?php echo L("input").L('action_name')?>"});
})
//-->
</script>
<div class="common-form">
<form name="myform" id="myform" action="?m=member&c=member_menu&a=edit" method="post">
<table width="100%" class="table_form contentWrap">
<tr>
<th width="200"><?php echo L('menu_parentid')?>:</th>
<td><select name="info[parentid]" style="width:200px;">
<option value="0"><?php echo L('no_parent_menu')?></option>
</select></td>
</tr>
<tr>
<th> <?php echo L('for_chinese_lan')?>:</th>
<td><input type="text" name="language" id="language" class="input-text" value="<?php echo L($name,'','',1)?>"></td>
</tr>
<tr>
<th><?php echo L('menu_name')?>:</th>
<td><input type="text" name="info[name]" id="name" class="input-text" value="<?php echo $name?>"></td>
</tr>
<?php if(empty($isurl)) {?>
<tr>
<th><?php echo L('module_name')?>:</th>
<td><input type="text" name="info[m]" id="m" class="input-text" value="<?php echo $m?>"></td>
</tr>
<tr>
<th><?php echo L('file_name')?>:</th>
<td><input type="text" name="info[c]" id="c" class="input-text" value="<?php echo $c?>"></td>
</tr>
<tr>
<th><?php echo L('action_name')?>:</th>
<td><input type="text" name="info[a]" id="a" class="input-text" value="<?php echo $a?>"> <span id="a_tip"></span><?php echo L('ajax_tip')?></td>
</tr>
<tr>
<th><?php echo L('att_data')?>:</th>
<td><input type="text" name="info[data]" class="input-text" value="<?php echo $data?>"></td>
</tr>
<?php }?>
<tr>
<th><?php echo L('menu_display')?>:</th>
<td><input type="radio" name="info[display]" value="1" <?php if($display) echo 'checked';?>> <?php echo L('yes')?><input type="radio" name="info[display]" value="0" <?php if(!$display) echo 'checked';?>> <?php echo L('no')?></td>
</tr>
<tr>
<th><?php echo L('isurl')?>:</th>
<td>
<?php if($isurl) {?>
<input type="radio" name="info[isurl]" value="1" checked> <?php echo L('yes')?>
<?php } else {?>
<input type="radio" name="info[isurl]" value="0" checked> <?php echo L('no')?>
<?php }?>
</td>
</tr>
<?php if((isset($_GET['isurl']) && $_GET['isurl']==1) || $isurl) {?>
<tr>
<th><?php echo L('url')?>:</th>
<td><input type="text" name="info[url]" class="input-text" size=80 value="<?php echo $url?>"></td>
</tr>
<?php }?>
</table>
<!--table_form_off-->
</div>
<div class="bk15"></div>
<input name="id" type="hidden" value="<?php echo $id?>">
<div class="btn"><input type="submit" id="dosubmit" class="button" name="dosubmit" value="<?php echo L('submit')?>"/></div>
</div>
</form>
<?php }?>
</body>
</html>
|
108wo
|
phpcms/modules/member/templates/member_menu.tpl.php
|
PHP
|
asf20
| 9,378
|
<?php defined('IN_ADMIN') or exit('No permission resources.');?>
<?php include $this->admin_tpl('header', 'admin');?>
<script language="javascript" type="text/javascript" src="<?php echo JS_PATH?>formvalidator.js" charset="UTF-8"></script>
<script language="javascript" type="text/javascript" src="<?php echo JS_PATH?>formvalidatorregex.js" charset="UTF-8"></script>
<script type="text/javascript">
<!--
$(function(){
$.formValidator.initConfig({autotip:true,formid:"myform",onerror:function(msg){}});
$("#modelname").formValidator({onshow:"<?php echo L('input').L('model_name')?>",onfocus:"<?php echo L('model_name').L('between_2_to_20')?>"}).inputValidator({min:2,max:20,onerror:"<?php echo L('model_name').L('between_2_to_20')?>"}).regexValidator({regexp:"ps_username",datatype:"enum",onerror:"<?php echo L('model_name').L('format_incorrect')?>"}).ajaxValidator({
type : "get",
url : "",
data :"m=member&c=member_model&a=public_checkmodelname_ajax",
datatype : "html",
async:'false',
success : function(data){
if( data == "1" ) {
return true;
} else {
return false;
}
},
buttons: $("#dosubmit"),
onerror : "<?php echo L('modelname_already_exist')?>",
onwait : "<?php echo L('connecting_please_wait')?>"
});
$("#tablename").formValidator({onshow:"<?php echo L('input').L('table_name')?>",onfocus:"<?php echo L('table_name').L('format_incorrect')?>",oncorrect:"<?php echo L('table_name').L('format_right')?>"}).inputValidator({min:2,max:8,onerror:"<?php echo L('table_name').L('between_2_to_8')?>"}).regexValidator({regexp:"letter_l",datatype:"enum",onerror:"<?php echo L('table_name').L('format_incorrect')?>"}).ajaxValidator({
type : "get",
url : "",
data :"m=member&c=member_model&a=public_checktablename_ajax",
datatype : "html",
async:'false',
success : function(data){
if( data == "1" ) {
return true;
} else {
return false;
}
},
buttons: $("#dosubmit"),
onerror : "<?php echo L('tablename_already_exist')?>",
onwait : "<?php echo L('connecting_please_wait')?>"
});
});
//-->
</script>
<div class="pad-10">
<div class="common-form">
<form name="myform" action="?m=member&c=member_model&a=add" method="post" id="myform" enctype="multipart/form-data">
<fieldset>
<legend><?php echo L('basic_configuration')?></legend>
<table width="100%" class="table_form">
<tr>
<td width="80"><?php echo L('model_name')?></td>
<td><input type="text" name="info[modelname]" class="input-text" id="modelname" size="30"></input></td>
</tr>
<tr>
<td><?php echo L('table_name')?></td>
<td>
<?php echo $this->db->db_tablepre?>member_<input type="text" name="info[tablename]" value="" class="input-text" id="tablename" size="16"></input>
</td>
</tr>
<tr>
<td><?php echo L('model_description')?></td>
<td>
<input type="text" name="info[description]" value="" class="input-text" id="description" size="80"></input>
</td>
</tr>
<tr>
<td><?php echo L('model_import')?></td>
<td>
<input type="file" name="model_import" value="" class="input-text" id="model_import"></input><?php echo L('create_new_model_can_empty')?>
</td>
</tr>
</table>
</fieldset>
<div class="bk15"></div>
<input name="dosubmit" type="submit" id="dosubmit" value="<?php echo L('submit')?>" class="dialog">
</form>
</div>
</div>
</body>
</html>
|
108wo
|
phpcms/modules/member/templates/member_model_add.tpl.php
|
PHP
|
asf20
| 3,497
|
<?php defined('IN_ADMIN') or exit('No permission resources.');?>
<?php include $this->admin_tpl('header','admin');?>
<script type="text/javascript">
<!--
$(function(){
$.formValidator.initConfig({autotip:true,formid:"myform"});
$("#field").formValidator({onshow:"<?php echo L('input').L('fieldname')?>",onfocus:"<?php echo L('fieldname').L('between_1_to_20')?>"}).regexValidator({regexp:"^[a-zA-Z]{1}([a-zA-Z0-9]|[_]){0,19}$",onerror:"<?php echo L('filedname_incorrect')?>"}).inputValidator({min:1,max:20,onerror:"<?php echo L('fieldname').L('between_1_to_20')?>"}).ajaxValidator({
type : "get",
url : "",
data : "m=member&c=member_modelfield&a=public_checkfield&modelid=<?php echo $modelid?>",
datatype : "html",
cached:false,
getdata:{issystem:'issystem'},
async:'false',
success : function(data){
if( data == "1" )
{
return true;
}
else
{
return false;
}
},
buttons: $("#dosubmit"),
onerror : "<?php echo L('fieldname').L('already_exist')?>",
onwait : "<?php echo L('connecting_please_wait')?>"
});
$("#formtype").formValidator({onshow:"<?php echo L('filedtype_need')?>",onfocus:"<?php echo L('filedtype_need')?>",oncorrect:"<?php echo L('input_correct')?>",defaultvalue:""}).inputValidator({min:1,onerror: "<?php echo L('filedtype_need')?>!"});
$("#name").formValidator({onshow:"<?php echo L('filed_nickname_need')?>",onfocus:"<?php echo L('filed_nickname_need')?>",oncorrect:"<?php echo L('input_correct')?>"}).inputValidator({min:1,onerror:"<?php echo L('filed_nickname_need')?>"});
})
//-->
</script>
<div class="pad_10">
<form name="myform" id="myform" action="?m=member&c=member_modelfield&a=add" method="post">
<div class="common-form">
<fieldset>
<legend><?php echo L('basic_configuration')?></legend>
<table width="100%" class="table_form contentWrap">
<tr>
<th><strong><?php echo L('filedtype')?></strong><br /></th>
<td>
<?php echo form::select($fields,'','name="info[formtype]" id="formtype" onchange="javascript:field_setting(this.value);"',L('filedtype_need'));?>
</td>
</tr>
<tr>
<th width="25%"><font color="red">*</font> <strong><?php echo L('filedname')?></strong><br />
<?php echo L('username_rule')?>
</th>
<td><input type="text" name="info[field]" id="field" size="20" class="input-text"></td>
</tr>
<tr>
<th><font color="red">*</font> <strong><?php echo L('filed_nickname')?></strong><br /><?php echo L('exaple_title')?></th>
<td><input type="text" name="info[name]" id="name" size="30" class="input-text"></td>
</tr>
<tr>
<th><strong><?php echo L('field_cue')?></strong><br /><?php echo L('nickname_alert')?></th>
<td><textarea name="info[tips]" rows="2" cols="20" id="tips" style="height:40px; width:80%"></textarea></td>
</tr>
<tr>
<th><strong><?php echo L('correlation_param')?></strong><br /><?php echo L('correlation_attribute')?></th>
<td><div id="setting"></div></td>
</tr>
<tr>
<th><strong><?php echo L('extra_attribute')?></strong><br /><?php echo L('add_javascript')?></th>
<td><input type="text" name="info[formattribute]" value="" size="50" class="input-text"></td>
</tr>
<tr>
<th><strong><?php echo L('form_css')?></strong><br /><?php echo L('user_form_css')?></th>
<td><input type="text" name="info[css]" value="" size="10" class="input-text"></td>
</tr>
<tr>
<th><strong><?php echo L('string_len_range')?></strong><br /><?php echo L('post_alert')?></th>
<td><?php echo L('min')?><input type="text" name="info[minlength]" id="field_minlength" value="0" size="5" class="input-text"> <?php echo L('max')?><input type="text" name="info[maxlength]" id="field_maxlength" value="" size="5" class="input-text"></td>
</tr>
<tr>
<th><strong><?php echo L('date_regular')?></strong><br /><?php echo L('validity_alert')?></th>
<td><input type="text" name="info[pattern]" id="pattern" value="" size="40" class="input-text">
<select name="pattern_select" onchange="javascript:$('#pattern').val(this.value)">
<option value=""><?php echo L('common_regular')?></option>
<option value="/^[0-9.-]+$/"><?php echo L('number')?></option>
<option value="/^[0-9-]+$/"><?php echo L('int')?></option>
<option value="/^[a-z]+$/i"><?php echo L('alphabet')?></option>
<option value="/^[0-9a-z]+$/i"><?php echo L('alphabet')?>+<?php echo L('number')?></option>
<option value="/^[\w\-\.]+@[\w\-\.]+(\.\w+)+$/">E-mail</option>
<option value="/^[0-9]{5,20}$/">QQ</option>
<option value="/^http:\/\//"><?php echo L('http')?></option>
<option value="/^(1)[0-9]{10}$/"><?php echo L('mp')?></option>
<option value="/^[0-9-]{6,13}$/"><?php echo L('tel')?></option>
<option value="/^[0-9]{6}$/"><?php echo L('postcode')?></option>
</select>
</td>
</tr>
<tr>
<th><strong><?php echo L('error_alert')?></strong><br /><?php echo L('form_error_alert')?></th>
<td><input type="text" name="info[errortips]" value="" size="50" class="input-text"></td>
</tr>
<tr>
<th><strong><?php echo L('unique')?></strong></th>
<td><input type="radio" name="info[isunique]" value="1" id="field_allow_isunique1"> <?php echo L('yes')?> <input type="radio" name="info[isunique]" value="0" id="field_allow_isunique0" checked> <?php echo L('no')?></td>
</tr>
<tr>
<th><strong><?php echo L('can_empty')?></strong></th>
<td><input type="radio" name="info[isbase]" value="1" checked> <?php echo L('yes')?> <input type="radio" name="info[isbase]" value="0"> <?php echo L('no')?> </td>
</tr>
<tr>
<th><strong><?php echo L('search_condition')?></strong></th>
<td><input type="radio" name="info[issearch]" value="1" id="field_allow_search1"> <?php echo L('yes')?> <input type="radio" name="info[issearch]" value="0" id="field_allow_search0" checked> <?php echo L('no')?></td>
</tr>
<tr>
<th><strong><?php echo L('isadd_condition')?></strong></th>
<td><input type="radio" name="info[isadd]" value="1" checked><?php echo L('yes')?><input type="radio" name="info[isadd]" value="0" ><?php echo L('no')?></td>
</tr>
<tr>
<th><strong><?php echo L('isomnipotent_condition')?></strong></th>
<td><input type="radio" name="info[isomnipotent]" value="1"><?php echo L('yes')?><input type="radio" name="info[isomnipotent]" value="0" checked><?php echo L('no')?></td>
</tr>
<tr>
<th><strong><?php echo L('deny_set_field_group')?></strong></th>
<td><?php echo form::checkbox($grouplist,$unsetgroupids,'name="unsetgroupids[]" id="unsetgroupids"',0,'100');?></td>
</tr>
<tr>
<th><strong><?php echo L('deny_set_field_role')?></strong></th>
<td><?php echo form::checkbox($roles,$unsetroleids,'name="unsetroleids[]" id="unsetroleids"',0,'100');?> </td>
</tr>
</table>
</fieldset>
<div class="bk15"></div>
<input name="info[modelid]" type="hidden" value="<?php echo $modelid?>">
<input name="dosubmit" id="dosubmit" type="submit" value="<?php echo L('submit')?>" class="dialog">
</form>
<div id="PC__contentHeight" style="display:none">90</div>
<script type="text/javascript">
<!--
function field_setting(fieldtype) {
$.getJSON("?m=member&c=member_modelfield&a=public_field_setting&fieldtype="+fieldtype, function(data){
if(data.field_basic_table=='1') {
$('#field_basic_table0').attr("disabled",false);
$('#field_basic_table1').attr("disabled",false);
} else {
$('#field_basic_table0').attr("checked",true);
$('#field_basic_table0').attr("disabled",true);
$('#field_basic_table1').attr("disabled",true);
}
if(data.field_allow_search=='1') {
$('#field_allow_search0').attr("disabled",false);
$('#field_allow_search1').attr("disabled",false);
} else {
$('#field_allow_search0').attr("checked",true);
$('#field_allow_search0').attr("disabled",true);
$('#field_allow_search1').attr("disabled",true);
}
if(data.field_allow_fulltext=='1') {
$('#field_allow_fulltext0').attr("disabled",false);
$('#field_allow_fulltext1').attr("disabled",false);
} else {
$('#field_allow_fulltext0').attr("checked",true);
$('#field_allow_fulltext0').attr("disabled",true);
$('#field_allow_fulltext1').attr("disabled",true);
}
if(data.field_allow_isunique=='1') {
$('#field_allow_isunique0').attr("disabled",false);
$('#field_allow_isunique1').attr("disabled",false);
} else {
$('#field_allow_isunique0').attr("checked",true);
$('#field_allow_isunique0').attr("disabled",true);
$('#field_allow_isunique1').attr("disabled",true);
}
$('#field_minlength').val(data.field_minlength);
$('#field_maxlength').val(data.field_maxlength);
$('#setting').html(data.setting);
});
}
//-->
</script>
</body>
</html>
|
108wo
|
phpcms/modules/member/templates/member_modelfield_add.tpl.php
|
PHP
|
asf20
| 8,936
|
<?php defined('IN_ADMIN') or exit('No permission resources.');?>
<?php include $this->admin_tpl('header', 'admin');?>
<div class="pad-lr-10">
<form name="searchform" action="" method="get" >
<input type="hidden" value="member" name="m">
<input type="hidden" value="member" name="c">
<input type="hidden" value="search" name="a">
<input type="hidden" value="879" name="menuid">
<table width="100%" cellspacing="0" class="search-form">
<tbody>
<tr>
<td>
<div class="explain-col">
<?php echo L('regtime')?>:
<?php echo form::date('start_time', $start_time)?>-
<?php echo form::date('end_time', $end_time)?>
<?php if($_SESSION['roleid'] == 1) {?>
<?php echo form::select($sitelist, $siteid, 'name="siteid"', L('all_site'));}?>
<select name="status">
<option value='0' <?php if(isset($_GET['status']) && $_GET['status']==0){?>selected<?php }?>><?php echo L('status')?></option>
<option value='1' <?php if(isset($_GET['status']) && $_GET['status']==1){?>selected<?php }?>><?php echo L('lock')?></option>
<option value='2' <?php if(isset($_GET['status']) && $_GET['status']==2){?>selected<?php }?>><?php echo L('normal')?></option>
</select>
<?php echo form::select($modellist, $modelid, 'name="modelid"', L('member_model'))?>
<?php echo form::select($grouplist, $groupid, 'name="groupid"', L('member_group'))?>
<select name="type">
<option value='1' <?php if(isset($_GET['type']) && $_GET['type']==1){?>selected<?php }?>><?php echo L('username')?></option>
<option value='2' <?php if(isset($_GET['type']) && $_GET['type']==2){?>selected<?php }?>><?php echo L('uid')?></option>
<option value='3' <?php if(isset($_GET['type']) && $_GET['type']==3){?>selected<?php }?>><?php echo L('email')?></option>
<option value='4' <?php if(isset($_GET['type']) && $_GET['type']==4){?>selected<?php }?>><?php echo L('regip')?></option>
<option value='5' <?php if(isset($_GET['type']) && $_GET['type']==5){?>selected<?php }?>><?php echo L('nickname')?></option>
</select>
<input name="keyword" type="text" value="<?php if(isset($_GET['keyword'])) {echo $_GET['keyword'];}?>" class="input-text" />
<input type="submit" name="search" class="button" value="<?php echo L('search')?>" />
</div>
</td>
</tr>
</tbody>
</table>
</form>
<form name="myform" action="?m=member&c=member&a=delete" method="post" onsubmit="checkuid();return false;">
<div class="table-list">
<table width="100%" cellspacing="0">
<thead>
<tr>
<th align="left" width="20"><input type="checkbox" value="" id="check_box" onclick="selectall('userid[]');"></th>
<th align="left"></th>
<th align="left"><?php echo L('uid')?></th>
<th align="left"><?php echo L('username')?></th>
<th align="left"><?php echo L('nickname')?></th>
<th align="left"><?php echo L('email')?></th>
<th align="left"><?php echo L('model_name')?></th>
<th align="left"><?php echo L('regip')?></th>
<th align="left"><?php echo L('lastlogintime')?></th>
<th align="left"><?php echo L('amount')?></th>
<th align="left"><?php echo L('point')?></th>
<th align="left"><?php echo L('operation')?></th>
</tr>
</thead>
<tbody>
<?php
foreach($memberlist as $k=>$v) {
?>
<tr>
<td align="left"><input type="checkbox" value="<?php echo $v['userid']?>" name="userid[]"></td>
<td align="left"><?php if($v['islock']) {?><img title="<?php echo L('lock')?>" src="<?php echo IMG_PATH?>icon/icon_padlock.gif"><?php }?></td>
<td align="left"><?php echo $v['userid']?></td>
<td align="left"><img src="<?php echo $v['avatar']?>" height=18 width=18 onerror="this.src='<?php echo IMG_PATH?>member/nophoto.gif'"><?php if($v['vip']) {?><img title="<?php echo L('vip')?>" src="<?php echo IMG_PATH?>icon/vip.gif"><?php }?><?php echo $v['username']?><a href="javascript:member_infomation(<?php echo $v['userid']?>, '<?php echo $v['modelid']?>', '')"><?php echo $member_model[$v['modelid']]['name']?><img src="<?php echo IMG_PATH?>admin_img/detail.png"></a></td>
<td align="left"><?php echo htmlspecialchars($v['nickname'])?></td>
<td align="left"><?php echo $v['email']?></td>
<td align="left"><?php echo $modellist[$v['modelid']]?></td>
<td align="left"><?php echo $v['regip']?></td>
<td align="left"><?php echo format::date($v['lastdate'], 1);?></td>
<td align="left"><?php echo $v['amount']?></td>
<td align="left"><?php echo $v['point']?></td>
<td align="left">
<a href="javascript:edit(<?php echo $v['userid']?>, '<?php echo $v['username']?>')">[<?php echo L('edit')?>]</a>
</td>
</tr>
<?php
}
?>
</tbody>
</table>
<div class="btn">
<label for="check_box"><?php echo L('select_all')?>/<?php echo L('cancel')?></label> <input type="submit" class="button" name="dosubmit" value="<?php echo L('delete')?>" onclick="return confirm('<?php echo L('sure_delete')?>')"/>
<input type="submit" class="button" name="dosubmit" onclick="document.myform.action='?m=member&c=member&a=lock'" value="<?php echo L('lock')?>"/>
<input type="submit" class="button" name="dosubmit" onclick="document.myform.action='?m=member&c=member&a=unlock'" value="<?php echo L('unlock')?>"/>
<input type="button" class="button" name="dosubmit" onclick="move();return false;" value="<?php echo L('move')?>"/>
</div>
<div id="pages"><?php echo $pages?></div>
</div>
</form>
</div>
<script type="text/javascript">
<!--
function edit(id, name) {
window.top.art.dialog({id:'edit'}).close();
window.top.art.dialog({title:'<?php echo L('edit').L('member')?>《'+name+'》',id:'edit',iframe:'?m=member&c=member&a=edit&userid='+id,width:'700',height:'500'}, function(){var d = window.top.art.dialog({id:'edit'}).data.iframe;d.document.getElementById('dosubmit').click();return false;}, function(){window.top.art.dialog({id:'edit'}).close()});
}
function move() {
var ids='';
$("input[name='userid[]']:checked").each(function(i, n){
ids += $(n).val() + ',';
});
if(ids=='') {
window.top.art.dialog({content:'<?php echo L('plsease_select').L('member')?>',lock:true,width:'200',height:'50',time:1.5},function(){});
return false;
}
window.top.art.dialog({id:'move'}).close();
window.top.art.dialog({title:'<?php echo L('move').L('member')?>',id:'move',iframe:'?m=member&c=member&a=move&ids='+ids,width:'700',height:'500'}, function(){var d = window.top.art.dialog({id:'move'}).data.iframe;d.$('#dosubmit').click();return false;}, function(){window.top.art.dialog({id:'move'}).close()});
}
function checkuid() {
var ids='';
$("input[name='userid[]']:checked").each(function(i, n){
ids += $(n).val() + ',';
});
if(ids=='') {
window.top.art.dialog({content:'<?php echo L('plsease_select').L('member')?>',lock:true,width:'200',height:'50',time:1.5},function(){});
return false;
} else {
myform.submit();
}
}
function member_infomation(userid, modelid, name) {
window.top.art.dialog({id:'modelinfo'}).close();
window.top.art.dialog({title:'<?php echo L('memberinfo')?>',id:'modelinfo',iframe:'?m=member&c=member&a=memberinfo&userid='+userid+'&modelid='+modelid,width:'700',height:'500'}, function(){var d = window.top.art.dialog({id:'modelinfo'}).data.iframe;d.document.getElementById('dosubmit').click();return false;}, function(){window.top.art.dialog({id:'modelinfo'}).close()});
}
//-->
</script>
</body>
</html>
|
108wo
|
phpcms/modules/member/templates/member_list.tpl.php
|
PHP
|
asf20
| 7,451
|
<?php defined('IN_ADMIN') or exit('No permission resources.');?>
<?php include $this->admin_tpl('header', 'admin');?>
<script language="javascript" type="text/javascript" src="<?php echo JS_PATH?>formvalidator.js" charset="UTF-8"></script>
<script language="javascript" type="text/javascript" src="<?php echo JS_PATH?>formvalidatorregex.js" charset="UTF-8"></script>
<script type="text/javascript">
<!--
$(function(){
$.formValidator.initConfig({autotip:true,formid:"myform",onerror:function(msg){}});
$("#name").formValidator({onshow:"<?php echo L('input').L('groupname')?>",onfocus:"<?php echo L('groupname').L('between_2_to_8')?>"}).inputValidator({min:2,max:15,onerror:"<?php echo L('groupname').L('between_2_to_8')?>"}).regexValidator({regexp:"ps_username",datatype:"enum",onerror:"<?php echo L('groupname').L('format_incorrect')?>"}).ajaxValidator({
type : "get",
url : "",
data :"m=member&c=member_group&a=public_checkname_ajax",
datatype : "html",
async:'false',
success : function(data){
if( data == "1" ) {
return true;
} else {
return false;
}
},
buttons: $("#dosubmit"),
onerror : "<?php echo L('groupname_already_exist')?>",
onwait : "<?php echo L('connecting_please_wait')?>"
}).defaultPassed();
$("#group_point").formValidator({tipid:"pointtip",onshow:"<?php echo L('input').L('point')?>",onfocus:"<?php echo L('point').L('between_1_to_8_num')?>"}).regexValidator({regexp:"^\\d{1,8}$",onerror:"<?php echo L('point').L('between_1_to_8_num')?>"});
$("#group_starnum").formValidator({tipid:"starnumtip",onshow:"<?php echo L('input').L('starnum')?>",onfocus:"<?php echo L('starnum').L('between_1_to_8_num')?>"}).regexValidator({regexp:"^\\d{1,8}$",onerror:"<?php echo L('starnum').L('between_1_to_8_num')?>"});
$("#maxmessagenum").formValidator({tipid:"maxmessagenumtip",onshow:"<?php echo L('input').L('maxmessagenum')?>",onfocus:"<?php echo L('maxmessagenum').L('between_1_to_8_num')?>"}).regexValidator({regexp:"^\\d{1,8}$",onerror:"<?php echo L('maxmessagenum').L('between_1_to_8_num')?>"});
$("#allowpostnum").formValidator({tipid:"allowpostnumip",onshow:"<?php echo L('input').L('allowpostnum')?>",onfocus:"<?php echo L('allowpostnum').L('between_1_to_8_num')?>"}).regexValidator({regexp:"^\\d{1,8}$",onerror:"<?php echo L('allowpostnum').L('between_1_to_8_num')?>"});
});
//-->
</script>
<div class="pad-10">
<div class="common-form">
<form name="myform" action="?m=member&c=member_group&a=edit" method="post" id="myform">
<input type="hidden" name="info[groupid]"value="<?php echo $groupinfo['groupid']?>">
<fieldset>
<legend><?php echo L('basic_configuration')?></legend>
<table width="100%" class="table_form">
<tr>
<td width="120"><?php echo L('member_group_name')?></td>
<td><?php if(in_array($groupid, array(1,7,8))) { echo $groupinfo['name'];} else {?><input type="text" name="info[name]" class="input-text" id="name" value="<?php echo $groupinfo['name']?>"><?php }?></td>
</tr>
<tr>
<td><?php echo L('member_group_creditrange')?></td>
<td>
<input type="text" name="info[point]" class="input-text" id="group_point" value="<?php echo $groupinfo['point']?>" size="6"></td>
</tr>
<tr>
<td><?php echo L('member_group_starnum')?></td>
<td><input type="text" name="info[starnum]" class="input-text" id="group_starnum" value="<?php echo $groupinfo['starnum']?>" size="6"></td>
</tr>
</table>
</fieldset>
<div class="bk15"></div>
<fieldset>
<legend><?php echo L('more_configuration')?></legend>
<table width="100%" class="table_form">
<tr>
<td><?php echo L('member_group_permission')?></td>
<td>
<span class="ik lf" style="width:120px;">
<input type="checkbox" name="info[allowpost]" <?php if($groupinfo['allowpost']){?>checked<?php }?> />
<?php echo L('member_group_publish')?>
</span>
<span class="ik lf" style="width:120px;">
<input type="checkbox" name="info[allowpostverify]" <?php if($groupinfo['allowpostverify']){?>checked<?php }?>>
<?php echo L('member_group_publish_verify')?>
</span>
<span class="ik lf" style="width:120px;">
<input type="checkbox" name="info[allowupgrade]" <?php if($groupinfo['allowupgrade']){?>checked<?php }?> />
<?php echo L('member_group_upgrade')?>
</span>
<span class="ik lf" style="width:120px;">
<input type="checkbox" name="info[allowsendmessage]" <?php if($groupinfo['allowsendmessage']){?>checked<?php }?>>
<?php echo L('member_group_sendmessage')?>
</span>
<span class="ik lf" style="width:120px;">
<input type="checkbox" name="info[allowattachment]" <?php if($groupinfo['allowattachment']){?>checked<?php }?>>
<?php echo L('allowattachment')?>
</span>
<span class="ik lf" style="width:120px;">
<input type="checkbox" name="info[allowsearch]" <?php if($groupinfo['allowsearch']){?>checked<?php }?>>
<?php echo L('allowsearch')?>
</span>
</td>
</tr>
<tr>
<td width="80"><?php echo L('member_group_upgradeprice')?></td>
<td>
<span class="ik lf" style="width:120px;">
<?php echo L('member_group_dayprice')?>:
<input type="text" name="info[price_d]" class="input-text" value="<?php echo $groupinfo['price_d']?>" size="6">
</span>
<span class="ik lf" style="width:120px;">
<?php echo L('member_group_monthprice')?>:
<input type="text" name="info[price_m]" class="input-text" value="<?php echo $groupinfo['price_m']?>" size="6">
</span>
<span class="ik lf" style="width:120px;">
<?php echo L('member_group_yearprice')?>:
<input type="text" name="info[price_y]" class="input-text" value="<?php echo $groupinfo['price_y']?>" size="6">
</span>
</td>
</tr>
<tr>
<td width="80"><?php echo L('member_group_maxmessagenum')?></td>
<td><input type="text" name="info[allowmessage]" class="input-text" id="maxmessagenum" value="<?php echo $groupinfo['allowmessage']?>" size="8"></td>
</tr>
<tr>
<td width="80"><?php echo L('member_group_username_color')?></td>
<td><input type="text" name="info[usernamecolor]" class="input-text" id="usernamecolor" size="8" value="<?php echo $groupinfo['usernamecolor']?>" ></td>
</tr>
<tr>
<td width="80"><?php echo L('allowpostnum')?></td>
<td><input type="text" name="info[allowpostnum]" class="input-text" id="allowpostnum" size="8" value="<?php echo $groupinfo['allowpostnum']?>"> <?php echo L('zero_nolimit')?></td>
</tr>
<tr>
<td width="80"><?php echo L('member_group_icon')?></td>
<td><input type="text" name="info[icon]" class="input-text" id="icon" value="<?php echo $groupinfo['icon']?>" size="40"></td>
</tr>
<tr>
<td width="80"><?php echo L('member_group_description')?></td>
<td><input type="text" name="info[description]" class="input-text" value="<?php echo $groupinfo['description']?>" size="60"></td>
</tr>
</table>
</fieldset>
<div class="bk15"></div>
<input name="dosubmit" type="submit" id="dosubmit" value="<?php echo L('submit')?>" class="dialog">
</form>
</div>
</div>
</body>
</html>
|
108wo
|
phpcms/modules/member/templates/member_group_edit.tpl.php
|
PHP
|
asf20
| 7,211
|
<?php defined('IN_ADMIN') or exit('No permission resources.');?>
<?php include $this->admin_tpl('header','admin');?>
<script type="text/javascript">
<!--
$(function(){
$.formValidator.initConfig({autotip:true,formid:"myform"});
$("#field").formValidator({onshow:"<?php echo L('input').L('fieldname')?>",onfocus:"<?php echo L('fieldname').L('between_1_to_20')?>"}).regexValidator({regexp:"^[a-zA-Z]{1}([a-zA-Z0-9]|[_]){0,19}$",onerror:"<?php echo L('filedname_incorrect')?>"}).inputValidator({min:1,max:20,onerror:"<?php echo L('fieldname').L('between_1_to_20')?>"}).ajaxValidator({
type : "get",
url : "",
data : "m=member&c=member_modelfield&a=public_checkfield&modelid=<?php echo $modelid?>&oldfield=<?php echo $field;?>",
datatype : "html",
cached:false,
async:'true',
success : function(data){
if( data == "1" )
{
return true;
}
else
{
return false;
}
},
buttons: $("#dosubmit"),
onerror : "<?php echo L('fieldname').L('already_exist')?>",
onwait : "<?php echo L('connecting_please_wait')?>"
}).defaultPassed();
$("#formtype").formValidator({onshow:"<?php echo L('filedtype_need')?>",onfocus:"<?php echo L('filedtype_need')?>",oncorrect:"<?php echo L('input_correct')?>",defaultvalue:""}).inputValidator({min:1,onerror: "<?php echo L('filedtype_need')?>"});
$("#name").formValidator({onshow:"<?php echo L('filed_nickname_need')?>",onfocus:"<?php echo L('filed_nickname_need')?>",oncorrect:"<?php echo L('input_correct')?>"}).inputValidator({min:1,onerror:"<?php echo L('filed_nickname_need')?>"});
})
//-->
</script>
<div class="pad-10">
<div class="common-form">
<form name="myform" id="myform" action="?m=member&c=member_modelfield&a=edit" method="post">
<input name="info[modelid]" type="hidden" value="<?php echo $modelid?>">
<input name="fieldid" type="hidden" value="<?php echo $fieldid?>">
<input name="oldfield" type="hidden" value="<?php echo $field?>">
<fieldset>
<legend><?php echo L('basic_configuration')?></legend>
<table width="100%" class="table_form contentWrap">
<tr>
<th><strong><?php echo L('filedtype')?></strong><br /></th>
<td>
<input type="hidden" name="info[formtype]" value="<?php echo $formtype;?>">
<?php echo form::select($fields,$formtype,'name="info[formtype]" id="formtype" onchange="javascript:field_setting(this.value);" disabled',L('filedtype_need'));?>
</td>
</tr>
<tr>
<th><strong><?php echo L('main_table_filed')?></strong></th>
<td>
<input type="hidden" name="issystem" id="issystem" value="<?php echo $issystem ? 1 : 0;?>">
<input type="radio" name="info[issystem]" id="field_basic_table1" value="1" <?php if($issystem) echo 'checked';?> disabled> <?php echo L('yes')?> <input type="radio" id="field_basic_table0" name="info[issystem]" value="0" <?php if(!$issystem) echo 'checked';?> disabled> <?php echo L('no')?></td>
</tr>
<tr>
<th width="25%"><font color="red">*</font> <strong><?php echo L('filedname')?></strong><br />
<?php echo L('username_rule')?>
</th>
<td><input type="text" name="info[field]" id="field" size="20" class="input-text" value="<?php echo $field?>"></td>
</tr>
<tr>
<th><font color="red">*</font> <strong><?php echo L('filed_nickname')?></strong><br /><?php echo L('exaple_title')?></th>
<td><input type="text" name="info[name]" id="name" size="30" class="input-text" value="<?php echo $name?>"></td>
</tr>
<tr>
<th><strong><?php echo L('field_cue')?></strong><br /><?php echo L('nickname_alert')?></th>
<td><textarea name="info[tips]" rows="2" cols="20" id="tips" style="height:40px; width:80%"><?php echo htmlspecialchars($tips)?></textarea></td>
</tr>
<tr>
<th><strong><?php echo L('correlation_param')?></strong><br /><?php echo L('correlation_attribute')?></th>
<td><?php echo $form_data;?></td>
</tr>
<tr>
<th><strong><?php echo L('extra_attribute')?></strong><br /><?php echo L('add_javascript')?></th>
<td><input type="text" name="info[formattribute]" size="50" class="input-text" value="<?php echo htmlspecialchars($formattribute);?>"></td>
</tr>
<tr>
<th><strong><?php echo L('form_css')?></strong><br /><?php echo L('user_form_css')?></th>
<td><input type="text" name="info[css]" size="10" class="input-text" value="<?php echo htmlspecialchars($css);?>"></td>
</tr>
<tr>
<th><strong><?php echo L('string_len_range')?></strong><br /><?php echo L('post_alert')?></th>
<td><?php echo L('min')?><input type="text" name="info[minlength]" id="field_minlength" value="<?php echo $minlength;?>" size="5" class="input-text"> <?php echo L('max')?><input type="text" name="info[maxlength]" id="field_maxlength" value="<?php echo $maxlength;?>" size="5" class="input-text"></td>
</tr>
<tr>
<th><strong><?php echo L('date_regular')?></strong><br /><?php echo L('validity_alert')?></th>
<td><input type="text" name="info[pattern]" id="pattern" value="<?php echo $pattern;?>" size="40" class="input-text">
<select name="pattern_select" onchange="javascript:$('#pattern').val(this.value)">
<option value=""><?php echo L('common_regular')?></option>
<option value="/^[0-9.-]+$/"><?php echo L('number')?></option>
<option value="/^[0-9-]+$/"><?php echo L('int')?></option>
<option value="/^[a-z]+$/i"><?php echo L('alphabet')?></option>
<option value="/^[0-9a-z]+$/i"><?php echo L('alphabet')?>+<?php echo L('number')?></option>
<option value="/^[\w\-\.]+@[\w\-\.]+(\.\w+)+$/">E-mail</option>
<option value="/^[0-9]{5,20}$/">QQ</option>
<option value="/^http:\/\//"><?php echo L('http')?></option>
<option value="/^(1)[0-9]{10}$/"><?php echo L('mp')?></option>
<option value="/^[0-9-]{6,13}$/"><?php echo L('tel')?></option>
<option value="/^[0-9]{6}$/"><?php echo L('postcode')?></option>
</select>
</td>
</tr>
<tr>
<th><strong><?php echo L('error_alert')?></strong><br /><?php echo L('form_error_alert')?></th>
<td><input type="text" name="info[errortips]" value="<?php echo $errortips;?>" size="50" class="input-text"></td>
</tr>
<tr>
<th><strong><?php echo L('unique')?></strong></th>
<td><input type="radio" name="info[isunique]" value="1" id="field_allow_isunique1" <?php if($isunique) echo 'checked';?>><?php echo L('yes')?><input type="radio" name="info[isunique]" value="0" id="field_allow_isunique0" <?php if(!$isunique) echo 'checked';?>><?php echo L('no')?></td>
</tr>
<tr>
<th><strong><?php echo L('can_empty')?></strong></th>
<td><input type="radio" name="info[isbase]" value="1" <?php if($isbase) echo 'checked';?>><?php echo L('yes')?><input type="radio" name="info[isbase]" value="0" <?php if(!$isbase) echo 'checked';?>><?php echo L('no')?> </td>
</tr>
<tr>
<th><strong><?php echo L('search_condition')?></strong></th>
<td><input type="radio" name="info[issearch]" value="1" id="field_allow_search1" <?php if($issearch) echo 'checked';?>><?php echo L('yes')?><input type="radio" name="info[issearch]" value="0" id="field_allow_search0" <?php if(!$issearch) echo 'checked';?>><?php echo L('no')?></td>
</tr>
<tr>
<th><strong><?php echo L('isadd_condition')?></strong></th>
<td><input type="radio" name="info[isadd]" value="1" <?php if($isadd) echo 'checked';?>><?php echo L('yes')?><input type="radio" name="info[isadd]" value="0" <?php if(!$isadd) echo 'checked';?>><?php echo L('no')?></td>
</tr>
<tr>
<th><strong><?php echo L('isomnipotent_condition')?></strong></th>
<td><input type="radio" name="info[isomnipotent]" value="1" <?php if($isomnipotent) echo 'checked';?>><?php echo L('yes')?><input type="radio" name="info[isomnipotent]" value="0" <?php if(!$isomnipotent) echo 'checked';?>><?php echo L('no')?></td>
</tr>
<tr>
<th><strong><?php echo L('deny_set_field_group')?></strong></th>
<td><?php echo form::checkbox($grouplist,$unsetgroupids,'name="unsetgroupids[]" id="unsetgroupids"',0,'100');?></td>
</tr>
<tr>
<th><strong><?php echo L('deny_set_field_role')?></strong></th>
<td><?php echo form::checkbox($roles,$unsetroleids,'name="unsetroleids[]" id="unsetroleids"',0,'100');?> </td>
</tr>
</table>
</fieldset>
<div class="bk15"></div>
<input name="dosubmit" type="submit" id="dosubmit" value="<?php echo L('submit')?>" class="dialog">
</form>
</div>
</div>
</body>
</html>
|
108wo
|
phpcms/modules/member/templates/member_modelfield_edit.tpl.php
|
PHP
|
asf20
| 8,518
|
<?php defined('IN_ADMIN') or exit('No permission resources.');?>
<?php include $this->admin_tpl('header', 'admin');?>
<script language="javascript" type="text/javascript" src="<?php echo JS_PATH?>formvalidator.js" charset="UTF-8"></script>
<script language="javascript" type="text/javascript" src="<?php echo JS_PATH?>formvalidatorregex.js" charset="UTF-8"></script>
<script type="text/javascript">
<!--
$(function(){
$.formValidator.initConfig({autotip:true,formid:"myform",onerror:function(msg){}});
$("#modelname").formValidator({onshow:"<?php echo L('input').L('model_name')?>",onfocus:"<?php echo L('model_name').L('between_2_to_20')?>"}).inputValidator({min:2,max:20,onerror:"<?php echo L('model_name').L('between_2_to_20')?>"}).regexValidator({regexp:"ps_username",datatype:"enum",onerror:"<?php echo L('model_name').L('format_incorrect')?>"}).ajaxValidator({
type : "get",
url : "",
data :"m=member&c=member_model&a=public_checkmodelname_ajax&oldmodelname=<?php echo $modelinfo['name']?>",
datatype : "html",
async:'false',
success : function(data){
if( data == "1" ) {
return true;
} else {
return false;
}
},
buttons: $("#dosubmit"),
onerror : "<?php echo L('modelname_already_exist')?>",
onwait : "<?php echo L('connecting_please_wait')?>"
}).defaultPassed();
});
//-->
</script>
<div class="pad-10">
<div class="common-form">
<form name="myform" action="?m=member&c=member_model&a=edit" method="post" id="myform">
<input type="hidden" name="info[modelid]" value="<?php echo $_GET['modelid']?>">
<fieldset>
<legend><?php echo L('basic_configuration')?></legend>
<table width="100%" class="table_form">
<tr>
<td width="80"><?php echo L('model_name')?></td>
<td><input type="text" name="info[modelname]" class="input-text" id="modelname" size="30" value="<?php echo $modelinfo['name']?>"></input></td>
</tr>
<tr>
<td><?php echo L('table_name')?></td>
<td>
<?php echo $this->db->db_tablepre.$modelinfo['tablename']?>
</td>
</tr>
<tr>
<td><?php echo L('model_description')?></td>
<td>
<input type="text" name="info[description]" value="<?php echo $modelinfo['description']?>" class="input-text" id="description" size="80"></input>
</td>
</tr>
<tr>
<td><?php echo L('deny_model')?></td>
<td>
<input type="checkbox" value="1" name="info[disabled]" <?php if($modelinfo['disabled']) {?>checked<?php }?>>
</td>
</tr>
</table>
</fieldset>
<div class="bk15"></div>
<input name="dosubmit" type="submit" id="dosubmit" value="<?php echo L('submit')?>" class="dialog">
</form>
</div>
</div>
</body>
</html>
|
108wo
|
phpcms/modules/member/templates/member_model_edit.tpl.php
|
PHP
|
asf20
| 2,717
|
<?php defined('IN_ADMIN') or exit('No permission resources.');?>
<?php include $this->admin_tpl('header', 'admin');?>
<div class="pad-lr-10">
<div class="table-list">
<div class="explain-col">
<?php echo L('move_member_model_index_alert')?>
</div>
<div class="bk10"></div>
<form name="myform" id="myform" action="?m=member&c=member_model&a=delete" method="post" onsubmit="check();return false;">
<table width="100%" cellspacing="0">
<thead>
<tr>
<th align="left" width="30px"><input type="checkbox" value="" id="check_box" onclick="selectall('modelid[]');"></th>
<th align="left">ID</th>
<th><?php echo L('sort')?></th>
<th align="left"><?php echo L('model_name')?></th>
<th align="left"><?php echo L('model_description')?></th>
<th align="left"><?php echo L('table_name')?></th>
<th align="center"><?php echo L('status')?></th>
<th><?php echo L('operation')?></th>
</tr>
</thead>
<tbody>
<?php
foreach($member_model_list as $k=>$v) {
?>
<tr>
<td align="left"><input type="checkbox" value="<?php echo $v['modelid']?>" name="modelid[]"></td>
<td align="left"><?php echo $v['modelid']?></td>
<td align="center"><input type="text" name="sort[<?php echo $v['modelid']?>]" class="input-text" size="1" value="<?php echo $v['sort']?>"></th>
<td align="left"><?php echo $v['name']?></td>
<td align="left"><?php echo $v['description']?></td>
<td align="left"><?php echo $this->db->db_tablepre.$v['tablename']?></td>
<td align="center"><?php echo $v['disabled'] ? L('icon_locked') : L('icon_unlock')?></td>
<td align="center">
<a onclick="_M(892);" href="?m=member&c=member_modelfield&a=manage&modelid=<?php echo $v['modelid']?>&menuid=892"><?php echo L('field').L('manage')?></a> | <a href="javascript:edit(<?php echo $v['modelid']?>, '<?php echo $v['name']?>')"><?php echo L('edit')?></a> | <a href="?m=member&c=member_model&a=export&modelid=<?php echo $v['modelid']?>"><?php echo L('export')?></a> | <a href="javascript:move(<?php echo $v['modelid']?>, '<?php echo $v['name']?>')"><?php echo L('move')?></a>
</td>
</tr>
<?php
}
?>
</tbody>
</table>
<div class="btn"><label for="check_box"><?php echo L('select_all')?>/<?php echo L('cancel')?></label> <input type="submit" class="button" name="dosubmit" value="<?php echo L('delete')?>" onclick="return confirm('<?php echo L('sure_delete')?>')"/>
<input type="submit" class="button" name="dosubmit" onclick="document.myform.action='?m=member&c=member_model&a=sort'" value="<?php echo L('sort')?>"/>
</div>
<div id="pages"><?php echo $pages?></div>
</div>
</div>
</form>
<div id="PC__contentHeight" style="display:none">160</div>
<script language="JavaScript">
<!--
function edit(id, name) {
window.top.art.dialog({id:'edit'}).close();
window.top.art.dialog({title:'<?php echo L('edit').L('member_model')?>《'+name+'》',id:'edit',iframe:'?m=member&c=member_model&a=edit&modelid='+id,width:'700',height:'500'}, function(){var d = window.top.art.dialog({id:'edit'}).data.iframe;d.document.getElementById('dosubmit').click();return false;}, function(){window.top.art.dialog({id:'edit'}).close()});
}
function move(id, name) {
window.top.art.dialog({id:'move'}).close();
window.top.art.dialog({title:'<?php echo L('move')?>《'+name+'》',id:'move',iframe:'?m=member&c=member_model&a=move&modelid='+id,width:'700',height:'500'}, function(){var d = window.top.art.dialog({id:'move'}).data.iframe;d.$('#dosubmit').click();return false;}, function(){window.top.art.dialog({id:'move'}).close()});
}
function check() {
if(myform.action == '?m=member&c=member_model&a=delete') {
var ids='';
$("input[name='modelid[]']:checked").each(function(i, n){
ids += $(n).val() + ',';
});
if(ids=='') {
window.top.art.dialog({content:'<?php echo L('plsease_select').L('member_model')?>',lock:true,width:'200',height:'50',time:1.5},function(){});
return false;
}
}
myform.submit();
}
//修改菜单地址栏
function _M(menuid) {
$.get("?m=admin&c=index&a=public_current_pos&menuid="+menuid, function(data){
parent.$("#current_pos").html(data);
});
}
//-->
</script>
</body>
</html>
|
108wo
|
phpcms/modules/member/templates/member_model_list.tpl.php
|
PHP
|
asf20
| 4,193
|
<?php defined('IN_ADMIN') or exit('No permission resources.');?>
<?php include $this->admin_tpl('header', 'admin');?>
<script language="javascript" type="text/javascript" src="<?php echo JS_PATH?>formvalidator.js" charset="UTF-8"></script>
<script language="javascript" type="text/javascript" src="<?php echo JS_PATH?>formvalidatorregex.js" charset="UTF-8"></script>
<script type="text/javascript">
<!--
$(function(){
$.formValidator.initConfig({autotip:true,formid:"myform",onerror:function(msg){}});
$("#modelname").formValidator({onshow:"<?php echo L('input').L('model_name')?>",onfocus:"<?php echo L('model_name').L('between_2_to_20')?>"}).inputValidator({min:2,max:20,onerror:"<?php echo L('model_name').L('between_2_to_20')?>"}).regexValidator({regexp:"ps_username",datatype:"enum",onerror:"<?php echo L('model_name').L('format_incorrect')?>"}).ajaxValidator({
type : "get",
url : "",
data :"m=member&c=member_model&a=public_checkmodelname_ajax",
datatype : "html",
async:'false',
success : function(data){
if( data == "1" ) {
return true;
} else {
return false;
}
},
buttons: $("#dosubmit"),
onerror : "<?php echo L('modelname_already_exist')?>",
onwait : "<?php echo L('connecting_please_wait')?>"
});
$("#tablename").formValidator({onshow:"<?php echo L('input').L('table_name')?>",onfocus:"<?php echo L('table_name').L('format_incorrect')?>",oncorrect:"<?php echo L('table_name').L('format_right')?>"}).inputValidator({min:2,max:8,onerror:"<?php echo L('table_name').L('between_2_to_8')?>"}).regexValidator({regexp:"letter_l",datatype:"enum",onerror:"<?php echo L('table_name').L('format_incorrect')?>"}).ajaxValidator({
type : "get",
url : "",
data :"m=member&c=member_model&a=public_checktablename_ajax",
datatype : "html",
async:'false',
success : function(data){
if( data == "1" ) {
return true;
} else {
return false;
}
},
buttons: $("#dosubmit"),
onerror : "<?php echo L('tablename_already_exist')?>",
onwait : "<?php echo L('connecting_please_wait')?>"
});
});
//-->
</script>
<div class="pad-10">
<div class="common-form">
<form name="myform" action="?m=member&c=member_model&a=add" method="post" id="myform">
<fieldset>
<legend><?php echo L('basic_configuration')?></legend>
<table width="100%" class="table_form">
<tr>
<td width="80"><?php echo L('model_name')?></td>
<td><input type="text" name="info[modelname]" class="input-text" id="modelname" size="30"></input></td>
</tr>
<tr>
<td><?php echo L('table_name')?></td>
<td>
<?php echo $this->db->db_tablepre?>member_<input type="text" name="info[tablename]" value="" class="input-text" id="tablename" size="16"></input>
</td>
</tr>
<tr>
<td><?php echo L('model_description')?></td>
<td>
<input type="text" name="info[description]" value="" class="input-text" id="description" size="80"></input>
</td>
</tr>
</table>
</fieldset>
<div class="bk15"></div>
<input name="dosubmit" type="submit" id="dosubmit" value="<?php echo L('submit')?>" class="dialog">
</form>
</div>
</div>
</body>
</html>
|
108wo
|
phpcms/modules/member/templates/member_model_import.tpl.php
|
PHP
|
asf20
| 3,245
|
<?php defined('IN_ADMIN') or exit('No permission resources.');?>
<?php include $this->admin_tpl('header', 'admin');?>
<script language="javascript" type="text/javascript" src="<?php echo JS_PATH?>formvalidator.js" charset="UTF-8"></script>
<script language="javascript" type="text/javascript" src="<?php echo JS_PATH?>formvalidatorregex.js" charset="UTF-8"></script>
<script type="text/javascript">
<!--
$(function(){
$.formValidator.initConfig({autotip:true,formid:"myform",onerror:function(msg){}});
$("#name").formValidator({onshow:"<?php echo L('input').L('groupname')?>",onfocus:"<?php echo L('groupname').L('between_2_to_8')?>"}).inputValidator({min:2,max:15,onerror:"<?php echo L('groupname').L('between_2_to_8')?>"}).regexValidator({regexp:"ps_username",datatype:"enum",onerror:"<?php echo L('groupname').L('format_incorrect')?>"}).ajaxValidator({
type : "get",
url : "",
data :"m=member&c=member_group&a=public_checkname_ajax",
datatype : "html",
async:'false',
success : function(data){
if( data == "1" ) {
return true;
} else {
return false;
}
},
buttons: $("#dosubmit"),
onerror : "<?php echo L('groupname_already_exist')?>",
onwait : "<?php echo L('connecting_please_wait')?>"
});
$("#group_point").formValidator({tipid:"pointtip",onshow:"<?php echo L('input').L('point')?>",onfocus:"<?php echo L('point').L('between_1_to_8_num')?>"}).regexValidator({regexp:"^\\d{1,8}$",onerror:"<?php echo L('point').L('between_1_to_8_num')?>"});
$("#group_starnum").formValidator({tipid:"starnumtip",onshow:"<?php echo L('input').L('starnum')?>",onfocus:"<?php echo L('starnum').L('between_1_to_8_num')?>"}).regexValidator({regexp:"^\\d{1,8}$",onerror:"<?php echo L('starnum').L('between_1_to_8_num')?>"});
$("#maxmessagenum").formValidator({tipid:"maxmessagenumtip",onshow:"<?php echo L('input').L('maxmessagenum')?>",onfocus:"<?php echo L('maxmessagenum').L('between_1_to_8_num')?>"}).regexValidator({regexp:"^\\d{1,8}$",onerror:"<?php echo L('maxmessagenum').L('between_1_to_8_num')?>"});
$("#allowpostnum").formValidator({tipid:"allowpostnumip",onshow:"<?php echo L('input').L('allowpostnum')?>",onfocus:"<?php echo L('allowpostnum').L('between_1_to_8_num')?>"}).regexValidator({regexp:"^\\d{1,8}$",onerror:"<?php echo L('allowpostnum').L('between_1_to_8_num')?>"});
});
//-->
</script>
<div class="pad-10">
<div class="common-form">
<form name="myform" action="?m=member&c=member_group&a=add" method="post" id="myform">
<fieldset>
<legend><?php echo L('basic_configuration')?></legend>
<table width="100%" class="table_form">
<tr>
<td width="120"><?php echo L('member_group_name')?></td>
<td><input type="text" name="info[name]" class="input-text" id="name"></td>
</tr>
<tr>
<td><?php echo L('member_group_creditrange')?></td>
<td>
<input type="text" name="info[point]" class="input-text" id="group_point" value="" size="6"></td>
</tr>
<tr>
<td><?php echo L('member_group_starnum')?></td>
<td><input type="text" name="info[starnum]" class="input-text" id="group_starnum" size="6"></td>
</tr>
</table>
</fieldset>
<div class="bk15"></div>
<fieldset>
<legend><?php echo L('more_configuration')?></legend>
<table width="100%" class="table_form">
<tr>
<td><?php echo L('member_group_permission')?></td>
<td>
<span class="ik lf" style="width:120px;">
<input type="checkbox" name="info[allowpost]">
<?php echo L('member_group_publish')?>
</span>
<span class="ik lf" style="width:120px;">
<input type="checkbox" name="info[allowpostverify]">
<?php echo L('member_group_publish_verify')?>
</span>
<span class="ik lf" style="width:120px;">
<input type="checkbox" name="info[allowupgrade]">
<?php echo L('member_group_upgrade')?>
</span>
<span class="ik lf" style="width:120px;">
<input type="checkbox" name="info[allowsendmessage]">
<?php echo L('member_group_sendmessage')?>
</span>
<span class="ik lf" style="width:120px;">
<input type="checkbox" name="info[allowattachment]">
<?php echo L('allowattachment')?>
</span>
<span class="ik lf" style="width:120px;">
<input type="checkbox" name="info[allowsearch]">
<?php echo L('allowsearch')?>
</span>
</td>
</tr>
<tr>
<td width="80"><?php echo L('member_group_upgradeprice')?></td>
<td>
<span class="ik lf" style="width:120px;">
<?php echo L('member_group_dayprice')?>:
<input type="text" name="info[price_d]" class="input-text" size="6">
</span>
<span class="ik lf" style="width:120px;">
<?php echo L('member_group_monthprice')?>:
<input type="text" name="info[price_m]" class="input-text" size="6">
</span>
<span class="ik lf" style="width:120px;">
<?php echo L('member_group_yearprice')?>:
<input type="text" name="info[price_y]" class="input-text" size="6">
</span>
</td>
</tr>
<tr>
<td width="80"><?php echo L('member_group_maxmessagenum')?></td>
<td><input type="text" name="info[allowmessage]" class="input-text" id="allowmessage" size="8"></td>
</tr>
<tr>
<td width="80"><?php echo L('allowpostnum')?></td>
<td><input type="text" name="info[allowpostnum]" class="input-text" id="allowpostnum" size="8"> <?php echo L('zero_nolimit')?></td>
</tr>
<tr>
<td width="80"><?php echo L('member_group_username_color')?></td>
<td><input type="text" name="info[usernamecolor]" class="input-text" id="usernamecolor" size="8" value="#000000"></td>
</tr>
<tr>
<td width="80"><?php echo L('member_group_icon')?></td>
<td><input type="text" name="info[icon]" class="input-text" id="icon" value="images/group/vip.jpg" size="40"></td>
</tr>
<tr>
<td width="80"><?php echo L('member_group_description')?></td>
<td><input type="text" name="info[description]" class="input-text" size="60"></td>
</tr>
</table>
</fieldset>
<div class="bk15"></div>
<input name="dosubmit" type="submit" id="dosubmit" value="<?php echo L('submit')?>" class="dialog">
</form>
</div>
</div>
</body>
</html>
|
108wo
|
phpcms/modules/member/templates/member_group_add.tpl.php
|
PHP
|
asf20
| 6,241
|
<?php defined('IN_ADMIN') or exit('No permission resources.');?>
<?php include $this->admin_tpl('header', 'admin');?>
<script language="javascript" type="text/javascript" src="<?php echo JS_PATH?>member_common.js"></script>
<script language="javascript" type="text/javascript" src="<?php echo JS_PATH?>formvalidator.js" charset="UTF-8"></script>
<script language="javascript" type="text/javascript" src="<?php echo JS_PATH?>formvalidatorregex.js" charset="UTF-8"></script>
<script type="text/javascript">
$(document).ready(function() {
$.formValidator.initConfig({autotip:true,formid:"myform",onerror:function(msg){}});
$("#password").formValidator({empty:true,onshow:"<?php echo L('not_change_the_password_please_leave_a_blank')?>",onfocus:"<?php echo L('password').L('between_6_to_20')?>"}).inputValidator({min:6,max:20,onerror:"<?php echo L('password').L('between_6_to_20')?>"});
$("#pwdconfirm").formValidator({empty:true,onshow:"<?php echo L('not_change_the_password_please_leave_a_blank')?>",onfocus:"<?php echo L('input').L('passwords_not_match')?>",oncorrect:"<?php echo L('passwords_match')?>"}).compareValidator({desid:"password",operateor:"=",onerror:"<?php echo L('input').L('passwords_not_match')?>"});
$("#point").formValidator({tipid:"pointtip",onshow:"<?php echo L('input').L('point').L('point_notice')?>",onfocus:"<?php echo L('point').L('between_1_to_8_num')?>"}).regexValidator({regexp:"^\\d{1,8}$",onerror:"<?php echo L('point').L('between_1_to_8_num')?>"});
//$("#email").formValidator({onshow:"<?php echo L('input').L('email')?>",onfocus:"<?php echo L('email').L('format_incorrect')?>",oncorrect:"<?php echo L('email').L('format_right')?>"}).regexValidator({regexp:"email",datatype:"enum",onerror:"<?php echo L('email').L('format_incorrect')?>"}).ajaxValidator({
// type : "get",
// url : "",
// data :"m=member&c=member&a=public_checkemail_ajax&phpssouid=<?php echo $memberinfo['phpssouid']?>",
// datatype : "html",
// async:'false',
// success : function(data){
// if( data == "1" ) {
// return true;
// } else {
// return false;
// }
// },
// buttons: $("#dosubmit"),
// onerror : "<?php echo L('email_already_exist')?>",
// onwait : "<?php echo L('connecting_please_wait')?>"
//}).defaultPassed();
$("#nickname").formValidator({onshow:"<?php echo L('input').L('nickname')?>",onfocus:"<?php echo L('nickname').L('between_2_to_20')?>"}).inputValidator({min:2,max:20,onerror:"<?php echo L('nickname').L('between_2_to_20')?>"}).regexValidator({regexp:"ps_username",datatype:"enum",onerror:"<?php echo L('nickname').L('format_incorrect')?>"}).ajaxValidator({
type : "get",
url : "",
data :"m=member&c=index&a=public_checknickname_ajax",
datatype : "html",
async:'false',
success : function(data){
if( data == "1" ) {
return true;
} else {
return false;
}
},
buttons: $("#dosubmit"),
onerror : "<?php echo L('username').L('already_exist')?>",
onwait : "<?php echo L('connecting_please_wait')?>"
}).defaultPassed();
});
</script>
<div class="pad-10">
<div class="common-form">
<form name="myform" action="?m=member&c=member&a=edit" method="post" id="myform">
<input type="hidden" name="info[userid]" value="<?php echo $memberinfo['userid']?>"></input>
<input type="hidden" name="info[username]" value="<?php echo $memberinfo['username']?>"></input>
<fieldset>
<legend><?php echo L('basic_configuration')?></legend>
<table width="100%" class="table_form">
<!-- eddy start --><!--<tr>
<td width="80"><?php echo L('username')?></td>
<td><?php echo $memberinfo['username']?><?php if($memberinfo['islock']) {?><img title="<?php echo L('lock')?>" src="<?php echo IMG_PATH?>icon/icon_padlock.gif"><?php }?><?php if($memberinfo['vip']) {?><img title="<?php echo L('lock')?>" src="<?php echo IMG_PATH?>icon/vip.gif"><?php }?></td>
</tr>
-->
<tr>
<td><?php echo L('email')?></td>
<td>
<input type="hidden" name="info[email]" id="email" value="<?php echo $memberinfo['email']?>" />
<?php echo $memberinfo['email']?><?php if($memberinfo['islock']) {?><img title="<?php echo L('lock')?>" src="<?php echo IMG_PATH?>icon/icon_padlock.gif"><?php }?><?php if($memberinfo['vip']) {?><img title="<?php echo L('lock')?>" src="<?php echo IMG_PATH?>icon/vip.gif"><?php }?>
<input type="hidden" name="info[username]" id="username" value=""></input>
</td>
</tr>
<!-- eddy end -->
<tr>
<td><?php echo L('avatar')?></td>
<td><img src="<?php echo $memberinfo['avatar']?>" onerror="this.src='<?php echo IMG_PATH?>member/nophoto.gif'" height=90 width=90><input type="checkbox" name="delavatar" id="delavatar" class="input-text" value="1" ><label for="delavatar"><?php echo L('delete').L('avatar')?></label></td>
</tr>
<tr>
<td><?php echo L('password')?></td>
<td><input type="password" name="info[password]" id="password" class="input-text"></input></td>
</tr>
<tr>
<td><?php echo L('cofirmpwd')?></td>
<td><input type="password" name="info[pwdconfirm]" id="pwdconfirm" class="input-text"></input></td>
</tr>
<tr>
<td><?php echo L('nickname')?></td>
<td><input type="text" name="info[nickname]" id="nickname" value="<?php echo $memberinfo['nickname']?>" class="input-text"></input></td>
</tr>
<tr>
<td><?php echo L('member_group')?></td>
<td>
<?php echo form::select($grouplist, $memberinfo['groupid'], 'name="info[groupid]"', '');?> <div class="onShow"><?php echo L('changegroup_notice')?></div>
</td>
</tr>
<tr>
<td><?php echo L('point')?></td>
<td>
<input type="text" name="info[point]" value="<?php echo $memberinfo['point']?>" class="input-text" id="point" size="10"></input>
</td>
</tr>
<tr>
<td><?php echo L('member_model')?></td>
<td>
<?php echo form::select($modellist, $modelid, 'name="info[modelid]" onchange="changemodel($(this).val())"', '');?>
</td>
</tr>
<tr>
<td><?php echo L('vip')?></td>
<td>
<?php echo L('isvip')?> <input type="checkbox" name="info[vip]" value=1 <?php if($memberinfo['vip']){?>checked<?php }?>/>
<?php echo L('overduedate')?> <?php echo $form_overdudate?>
</td>
</tr>
<!-- eddy 开发商上传权限 start -->
<tr>
<td>开通供应商上传权限</td>
<td>
<input type="radio" name="info[doupload]" value="1" <?php echo $memberinfo['doupload'] ? "checked" : ""; ?> />是 <input type="radio" name="info[doupload]" value="0" <?php echo $memberinfo['doupload'] ? "" : "checked"; ?> />否
</td>
</tr>
<!-- eddy 开发商上传权限 end -->
</table>
</fieldset>
<div class="bk15"></div>
<fieldset>
<legend><?php echo L('more_configuration')?></legend>
<table width="100%" class="table_form">
<?php foreach($forminfos as $k=>$v) {?>
<tr>
<td width="80"><?php echo $v['name']?></td>
<td><?php echo $v['form']?></td>
</tr>
<?php }?>
</table>
</fieldset>
<div class="bk15"></div>
<input name="dosubmit" id="dosubmit" type="submit" value="<?php echo L('submit')?>" class="dialog">
</form>
</div>
</div>
</body>
<script language="JavaScript">
<!--
function changemodel(modelid) {
redirect('?m=member&c=member&a=edit&userid=<?php echo $memberinfo[userid]?>&modelid='+modelid+'&pc_hash=<?php echo $_SESSION['pc_hash']?>');
}
//-->
</script>
</html>
|
108wo
|
phpcms/modules/member/templates/member_edit.tpl.php
|
PHP
|
asf20
| 7,459
|
<?php defined('IN_ADMIN') or exit('No permission resources.');?>
<?php include $this->admin_tpl('header', 'admin');?>
<div class="pad-10">
<div class="common-form">
<fieldset>
<legend><?php echo L('basic_configuration')?></legend>
<table width="100%" class="table_form contentWrap">
<tr>
<td width="120"><?php echo L('member_statistics')?></td>
<td>
<?php echo L('member_totalnum')?>:<?php echo $memberinfo['totalnum']?>
<?php echo L('member_todaynum')?>:<?php echo $memberinfo['today_member']?>
</td>
</tr>
<tr>
<td width="120"><?php echo L('member_verify_totalnum')?></td>
<td>
<?php echo $memberinfo['verifynum']?>
</td>
</tr>
<tr>
<td width="120"><?php echo L('member_vip_totalnum')?></td>
<td>
<?php echo $memberinfo['vipnum']?>
</td>
</tr>
</table>
</fieldset>
<div class="bk15"></div>
<form name="myform" action="" method="get">
<input type="hidden" name="m" value="member" />
<input type="hidden" name="c" value="member" />
<input type="hidden" name="a" value="search" />
<fieldset>
<legend><?php echo L('member_search')?></legend>
<div class="bk10"></div>
<form name="searchform" action="" method="get" >
<input type="hidden" value="member" name="m">
<input type="hidden" value="member" name="c">
<input type="hidden" value="search" name="a">
<input type="hidden" value="879" name="menuid">
<table width="100%" class="table_form contentWrap">
<tr>
<td width="120"><?php echo L('regtime')?></td>
<td>
<?php echo form::date('start_time', $start_time)?>-
<?php echo form::date('end_time', $end_time)?>
</td>
</tr>
<tr>
<td width="120"><?php echo L('member_group')?></td>
<td>
<?php echo form::select($grouplist, $_GET['groupid'], 'name="groupid"', L('nolimit'))?>
</td>
</tr>
<tr>
<td width="120"><?php echo L('status')?></td>
<td>
<select name="status">
<option value='0' <?php if(isset($_GET['status']) && $_GET['status']==0){?>selected<?php }?>><?php echo L('nolimit')?></option>
<option value='1' <?php if(isset($_GET['status']) && $_GET['status']==1){?>selected<?php }?>><?php echo L('lock')?></option>
<option value='2' <?php if(isset($_GET['status']) && $_GET['status']==2){?>selected<?php }?>><?php echo L('normal')?></option>
</select>
</td>
</tr>
<tr>
<td width="120"><?php echo L('type')?></td>
<td>
<select name="type">
<option value='1' <?php if(isset($_GET['type']) && $_GET['type']==1){?>selected<?php }?>><?php echo L('username')?></option>
<option value='2' <?php if(isset($_GET['type']) && $_GET['type']==2){?>selected<?php }?>><?php echo L('uid')?></option>
<option value='3' <?php if(isset($_GET['type']) && $_GET['type']==3){?>selected<?php }?>><?php echo L('email')?></option>
<option value='4' <?php if(isset($_GET['type']) && $_GET['type']==4){?>selected<?php }?>><?php echo L('regip')?></option>
</select>
<input name="keyword" type="text" value="<?php if(isset($_GET['keyword'])) {echo $_GET['keyword'];}?>" class="input-text" />
</td>
</tr>
<tr>
<td width="120"><?php echo L('amount')?></td>
<td>
<input name="amount_from" type="text" value="" class="input-text" size="4"/>-
<input name="amount_to" type="text" value="" class="input-text" size="4"/>
</td>
</tr>
<tr>
<td width="120"><?php echo L('point')?></td>
<td>
<input name="point_from" type="text" value="" class="input-text" size="4"/>-
<input name="point_to" type="text" value="" class="input-text" size="4"/>
</td>
</tr>
</table>
<div class="bk15"></div>
<input type="submit" name="search" class="button" value="<?php echo L('search')?>" />
</form>
</fieldset>
</form>
</div>
</div>
</body>
</html>
|
108wo
|
phpcms/modules/member/templates/member_init.tpl.php
|
PHP
|
asf20
| 3,829
|
<?php defined('IN_ADMIN') or exit('No permission resources.');?>
<?php include $this->admin_tpl('header', 'admin');?>
<form name="myform" id="myform" action="?m=member&c=member_group&a=delete" method="post" onsubmit="check();return false;">
<div class="pad-lr-10">
<div class="table-list">
<table width="100%" cellspacing="0">
<thead>
<tr>
<th align="left" width="30px"><input type="checkbox" value="" id="check_box" onclick="selectall('groupid[]');"></th>
<th align="left">ID</th>
<th><?php echo L('sort')?></th>
<th><?php echo L('groupname')?></th>
<th><?php echo L('issystem')?></th>
<th><?php echo L('membernum')?></th>
<th><?php echo L('starnum')?></th>
<th><?php echo L('pointrange')?></th>
<th><?php echo L('allowattachment')?></th>
<th><?php echo L('allowpost')?></th>
<th><?php echo L('member_group_publish_verify')?></th>
<th><?php echo L('allowsearch')?></th>
<th><?php echo L('allowupgrade')?></th>
<th><?php echo L('allowsendmessage')?></th>
<th><?php echo L('operation')?></th>
</tr>
</thead>
<tbody>
<?php
foreach($member_group_list as $k=>$v) {
?>
<tr>
<td align="left"><?php if(!$v['issystem']) {?><input type="checkbox" value="<?php echo $v['groupid']?>" name="groupid[]"><?php }?></td>
<td align="left"><?php echo $v['groupid']?></td>
<td align="center"><input type="text" name="sort[<?php echo $v['groupid']?>]" class="input-text" size="1" value="<?php echo $v['sort']?>"></th>
<td align="center" title="<?php echo $v['description']?>"><?php echo $v['name']?></td>
<td align="center"><?php echo $v['issystem'] ? L('icon_unlock') : L('icon_locked')?></td>
<td align="center"><?php echo $v['membernum']?></th>
<td align="center"><?php echo $v['starnum']?></td>
<td align="center"><?php echo $v['point']?></td>
<td align="center"><?php echo $v['allowattachment'] ? L('icon_unlock') : L('icon_locked')?></td>
<td align="center"><?php echo $v['allowpost'] ? L('icon_unlock') : L('icon_locked')?></td>
<td align="center"><?php echo $v['allowpostverify'] ? L('icon_unlock') : L('icon_locked')?></td>
<td align="center"><?php echo $v['allowsearch'] ? L('icon_unlock') : L('icon_locked')?></td>
<td align="center"><?php echo $v['allowupgrade'] ? L('icon_unlock') : L('icon_locked')?></td>
<td align="center"><?php echo $v['allowsendmessage'] ? L('icon_unlock') : L('icon_locked')?></td>
<td align="center"><a href="javascript:edit(<?php echo $v['groupid']?>, '<?php echo $v['name']?>')">[<?php echo L('edit')?>]</a></td>
</tr>
<?php
}
?>
</tbody>
</table>
<div class="btn"><label for="check_box"><?php echo L('select_all')?>/<?php echo L('cancel')?></label> <input type="submit" class="button" name="dosubmit" value="<?php echo L('delete')?>" onclick="return confirm('<?php echo L('sure_delete')?>')"/>
<input type="submit" class="button" name="dosubmit" onclick="document.myform.action='?m=member&c=member_group&a=sort'" value="<?php echo L('sort')?>"/>
</div>
<div id="pages"><?php echo $pages?></div>
</div>
</div>
</form>
<div id="PC__contentHeight" style="display:none">160</div>
<script language="JavaScript">
<!--
function edit(id, name) {
window.top.art.dialog({id:'edit'}).close();
window.top.art.dialog({title:'<?php echo L('edit').L('member_group')?>《'+name+'》',id:'edit',iframe:'?m=member&c=member_group&a=edit&groupid='+id,width:'700',height:'500'}, function(){var d = window.top.art.dialog({id:'edit'}).data.iframe;d.document.getElementById('dosubmit').click();return false;}, function(){window.top.art.dialog({id:'edit'}).close()});
}
function check() {
if(myform.action == '?m=member&c=member_group&a=delete') {
var ids='';
$("input[name='groupid[]']:checked").each(function(i, n){
ids += $(n).val() + ',';
});
if(ids=='') {
window.top.art.dialog({content:'<?php echo L('plsease_select').L('member_group')?>',lock:true,width:'200',height:'50',time:1.5},function(){});
return false;
}
}
myform.submit();
}
//-->
</script>
</body>
</html>
|
108wo
|
phpcms/modules/member/templates/member_group_list.tpl.php
|
PHP
|
asf20
| 4,073
|
<?php defined('IN_ADMIN') or exit('No permission resources.');?>
<?php include $this->admin_tpl('header', 'admin');?>
<script language="javascript" type="text/javascript" src="<?php echo JS_PATH?>formvalidator.js" charset="UTF-8"></script>
<script language="javascript" type="text/javascript" src="<?php echo JS_PATH?>formvalidatorregex.js" charset="UTF-8"></script>
<script type="text/javascript">
<!--
$(function(){
$.formValidator.initConfig({autotip:true,formid:"myform",onerror:function(msg){}});
$("#defualtpoint").formValidator({tipid:"pointtip",onshow:"<?php echo L('input').L('defualtpoint')?>",onfocus:"<?php echo L('defualtpoint').L('between_1_to_8_num')?>"}).regexValidator({regexp:"^\\d{1,8}$",onerror:"<?php echo L('defualtpoint').L('between_1_to_8_num')?>"});
$("#defualtamount").formValidator({tipid:"starnumtip",onshow:"<?php echo L('input').L('defualtamount')?>",onfocus:"<?php echo L('defualtamount').L('between_1_to_8_num')?>"}).regexValidator({regexp:"^\\d{1,8}$",onerror:"<?php echo L('defualtamount').L('between_1_to_8_num')?>"});
$("#rmb_point_rate").formValidator({tipid:"rmb_point_rateid",onshow:"<?php echo L('input').L('rmb_point_rate')?>",onfocus:"<?php echo L('rmb_point_rate').L('between_1_to_8_num')?>"}).regexValidator({regexp:"^\\d{1,8}$",onerror:"<?php echo L('rmb_point_rate').L('between_1_to_8_num')?>"});
});
//-->
</script>
<div class="pad-lr-10">
<div class="common-form">
<form name="myform" action="?m=member&c=member_setting&a=manage" method="post" id="myform">
<table width="100%" class="table_form">
<tr>
<td width="200"><?php echo L('allow_register')?></td>
<td>
<?php echo L('yes')?><input type="radio" name="info[allowregister]" class="input-radio" <?php if($member_setting['allowregister']) {?>checked<?php }?> value='1'>
<?php echo L('no')?><input type="radio" name="info[allowregister]" class="input-radio" <?php if(!$member_setting['allowregister']) {?>checked<?php }?> value='0'>
</td>
</tr>
<tr>
<td width="200"><?php echo L('register_model')?></td>
<td>
<?php echo L('yes')?><input type="radio" name="info[choosemodel]" class="input-radio"<?php if($member_setting['choosemodel']) {?>checked<?php }?> value='1'>
<?php echo L('no')?><input type="radio" name="info[choosemodel]" class="input-radio"<?php if(!$member_setting['choosemodel']) {?>checked<?php }?> value='0'>
</td>
</tr>
<tr>
<td width="200"><?php echo L('register_email_auth')?></td>
<td>
<?php echo L('yes')?><input type="radio" name="info[enablemailcheck]" class="input-radio"<?php if($member_setting['enablemailcheck']) {?>checked<?php }?> value='1' <?php if($mail_disabled) {?>disabled<?php }?>>
<?php echo L('no')?><input type="radio" name="info[enablemailcheck]" class="input-radio"<?php if(!$member_setting['enablemailcheck']) {?>checked<?php }?> value='0'> <font color=red><?php echo L('enablemailcheck_notice')?></red>
</td>
</tr>
<tr>
<td width="200"><?php echo L('register_verify')?></td>
<td>
<?php echo L('yes')?><input type="radio" name="info[registerverify]" class="input-radio"<?php if($member_setting['registerverify']) {?>checked<?php }?> value='1'>
<?php echo L('no')?><input type="radio" name="info[registerverify]" class="input-radio"<?php if(!$member_setting['registerverify']) {?>checked<?php }?> value='0'>
</td>
</tr>
<tr>
<td width="200"><?php echo L('show_app_point')?></td>
<td>
<?php echo L('yes')?><input type="radio" name="info[showapppoint]" class="input-radio"<?php if($member_setting['showapppoint']) {?>checked<?php }?> value='1'>
<?php echo L('no')?><input type="radio" name="info[showapppoint]" class="input-radio"<?php if(!$member_setting['showapppoint']) {?>checked<?php }?> value='0'>
</td>
</tr>
<tr>
<td width="200"><?php echo L('rmb_point_rate')?></td>
<td>
<input type="text" name="info[rmb_point_rate]" id="rmb_point_rate" class="input-text" size="4" value="<?php echo $member_setting['rmb_point_rate'];?>">
</td>
</tr>
<tr>
<td width="200"><?php echo L('defualtpoint')?></td>
<td>
<input type="text" name="info[defualtpoint]" id="defualtpoint" class="input-text" size="4" value="<?php echo $member_setting['defualtpoint'];?>">
</td>
</tr>
<tr>
<td width="200"><?php echo L('defualtamount')?></td>
<td>
<input type="text" name="info[defualtamount]" id="defualtamount" class="input-text" size="4" value="<?php echo $member_setting['defualtamount'];?>">
</td>
</tr>
<tr>
<td width="200"><?php echo L('show_register_protocol')?></td>
<td>
<?php echo L('yes')?><input type="radio" name="info[showregprotocol]" class="input-radio" <?php if($member_setting['showregprotocol']) {?>checked<?php }?> value='1'>
<?php echo L('no')?><input type="radio" name="info[showregprotocol]" class="input-radio" <?php if(!$member_setting['showregprotocol']) {?>checked<?php }?> value='0'>
</td>
</tr>
<tr>
<td width="200"><?php echo L('register_protocol')?></td>
<td>
<textarea name="info[regprotocol]" id="regprotocol" style="width:80%;height:120px;"><?php echo $member_setting['regprotocol']?></textarea>
</td>
</tr>
<tr>
<td width="200"><?php echo L('register_verify_message')?></td>
<td>
<textarea name="info[registerverifymessage]" id="registerverifymessage" style="width:80%;height:120px;"><?php echo $member_setting['registerverifymessage']?></textarea>
</td>
</tr>
<tr>
<td width="200"><?php echo L('forgetpasswordmessage')?></td>
<td>
<textarea name="info[forgetpassword]" id="forgetpassword" style="width:80%;height:120px;"><?php echo $member_setting['forgetpassword']?></textarea>
</td>
</tr>
</table>
<div class="bk15"></div>
<input name="dosubmit" type="submit" id="dosubmit" value="<?php echo L('submit')?>" class="button">
</form>
</div>
</div>
</body>
</html>
|
108wo
|
phpcms/modules/member/templates/member_setting.tpl.php
|
PHP
|
asf20
| 5,999
|
<?php defined('IN_ADMIN') or exit('No permission resources.');?>
<?php include $this->admin_tpl('header', 'admin');?>
<script language="javascript" type="text/javascript" src="<?php echo JS_PATH?>formvalidator.js" charset="UTF-8"></script>
<script language="javascript" type="text/javascript" src="<?php echo JS_PATH?>formvalidatorregex.js" charset="UTF-8"></script>
<script type="text/javascript">
$(document).ready(function() {
$.formValidator.initConfig({autotip:true,formid:"myform",onerror:function(msg){}});
$('#groupid').formValidator({onshow:"<?php echo L('please_select').L('member_group');?>",onfocus:"<?php echo L('please_select').L('member_group');?>",defaultvalue:"0"}).inputValidator({min:1,onerror:"<?php echo L('please_select').L('member_group');?>"});
});
</script>
<div class="pad_10">
<div class="common-form">
<form name="myform" action="?m=member&c=member&a=move" method="post" id="myform">
<fieldset>
<legend><?php echo L('basic_configuration')?></legend>
<table width="100%" class="table_form">
<tr>
<td width="80"><?php echo L('username')?></td>
<td>
<?php foreach($userarr as $v) {?>
<input type="checkbox" name="userid[]" value="<?php echo $v['userid']?>" checked />
<?php echo $v['username']?>
<?php }?>
</td>
</tr>
<tr>
<td><?php echo L('member_group')?></td>
<td>
<?php echo form::select($grouplist, $_GET['groupid'], 'id="groupid" name="groupid"', L('please_select'))?>
</td>
</tr>
</table>
</fieldset>
<div class="bk15"></div>
<input name="dosubmit" id="dosubmit" type="submit" value="<?php echo L('submit')?>" class="dialog">
</form>
</div>
</div>
</body>
</html>
|
108wo
|
phpcms/modules/member/templates/member_move.tpl.php
|
PHP
|
asf20
| 1,704
|
<?php defined('IN_ADMIN') or exit('No permission resources.');?>
<?php include $this->admin_tpl('header', 'admin');?>
<script language="javascript" type="text/javascript" src="<?php echo JS_PATH?>formvalidator.js" charset="UTF-8"></script>
<script language="javascript" type="text/javascript" src="<?php echo JS_PATH?>formvalidatorregex.js" charset="UTF-8"></script>
<script type="text/javascript">
<!--
$(function(){
$.formValidator.initConfig({autotip:true,formid:"myform",onerror:function(msg){}});
$("#password").formValidator({onshow:"<?php echo L('input').L('password')?>",onfocus:"<?php echo L('password').L('between_6_to_20')?>"}).inputValidator({min:6,max:20,onerror:"<?php echo L('password').L('between_6_to_20')?>"});
$("#pwdconfirm").formValidator({onshow:"<?php echo L('input').L('cofirmpwd')?>",onfocus:"<?php echo L('input').L('passwords_not_match')?>",oncorrect:"<?php echo L('passwords_match')?>"}).compareValidator({desid:"password",operateor:"=",onerror:"<?php echo L('input').L('passwords_not_match')?>"});
$("#point").formValidator({tipid:"pointtip",onshow:"<?php echo L('input').L('point').L('point_notice')?>",onfocus:"<?php echo L('point').L('between_1_to_8_num')?>"}).regexValidator({regexp:"^\\d{1,8}$",onerror:"<?php echo L('point').L('between_1_to_8_num')?>"});
$("#email").formValidator({onshow:"<?php echo L('input').L('email')?>",onfocus:"<?php echo L('email').L('format_incorrect')?>",oncorrect:"<?php echo L('email').L('format_right')?>"}).inputValidator({min:2,max:32,onerror:"<?php echo L('email').L('between_2_to_32')?>"}).regexValidator({regexp:"email",datatype:"enum",onerror:"<?php echo L('email').L('format_incorrect')?>"}).ajaxValidator({
type : "get",
url : "",
data :"m=member&c=member&a=public_checkemail_ajax",
datatype : "html",
async:'false',
success : function(data){
if( data == "1" ) {
$('#username').val($("#email").val()); //eddy
return true;
} else {
return false;
}
},
buttons: $("#dosubmit"),
onerror : "<?php echo L('deny_register').L('or').L('email_already_exist')?>",
onwait : "<?php echo L('connecting_please_wait')?>"
});
$("#nickname").formValidator({onshow:"<?php echo L('input').L('nickname')?>",onfocus:"<?php echo L('nickname').L('between_2_to_20')?>"}).inputValidator({min:2,max:20,onerror:"<?php echo L('nickname').L('between_2_to_20')?>"}).regexValidator({regexp:"ps_username",datatype:"enum",onerror:"<?php echo L('nickname').L('format_incorrect')?>"}).ajaxValidator({
type : "get",
url : "",
data :"m=member&c=index&a=public_checknickname_ajax",
datatype : "html",
async:'false',
success : function(data){
if( data == "1" ) {
return true;
} else {
return false;
}
},
buttons: $("#dosubmit"),
onerror : "<?php echo L('already_exist').L('already_exist')?>",
onwait : "<?php echo L('connecting_please_wait')?>"
}).defaultPassed();
});
//-->
</script>
<div class="pad-10">
<div class="common-form">
<form name="myform" action="?m=member&c=member&a=add" method="post" id="myform">
<fieldset>
<legend><?php echo L('basic_configuration')?></legend>
<table width="100%" class="table_form">
<!--<tr>
<td width="80"><?php echo L('username')?></td>
<td><input type="text" name="info[username]" class="input-text" id="username"></input></td>
</tr>
-->
<tr>
<td><?php echo L('email')?></td>
<td>
<input type="text" name="info[email]" value="" class="input-text" id="email" size="30"></input>
<input type="hidden" name="info[username]" id="username" value=""></input>
</td>
</tr>
<tr>
<td><?php echo L('password')?></td>
<td><input type="password" name="info[password]" class="input-text" id="password" value=""></input></td>
</tr>
<tr>
<td><?php echo L('cofirmpwd')?></td>
<td><input type="password" name="info[pwdconfirm]" class="input-text" id="pwdconfirm" value=""></input></td>
</tr>
<tr>
<td><?php echo L('nickname')?></td>
<td><input type="text" name="info[nickname]" id="nickname" value="" class="input-text"></input></td>
</tr>
<tr>
<td><?php echo L('member_group')?></td>
<td>
<?php echo form::select($grouplist, '2', 'name="info[groupid]"', '');?>
</td>
</tr>
<tr>
<td><?php echo L('point')?></td>
<td>
<input type="text" name="info[point]" value="" class="input-text" id="point" size="10"></input>
</td>
</tr>
<tr>
<td><?php echo L('member_model')?></td>
<td>
<?php echo form::select($modellist, '44', 'name="info[modelid]"', '');?>
</td>
</tr>
<tr>
<td><?php echo L('vip')?></td>
<td>
<?php echo L('isvip')?> <input type="checkbox" name="info[vip]" value=1 />
<?php echo L('overduedate')?> <?php echo form::date('info[overduedate]', '', 1)?>
</td>
</tr>
<!-- eddy 开发商上传权限 start -->
<tr>
<td>开通供应商上传权限</td>
<td>
<input type="radio" name="info[doupload]" value="1" />是 <input type="radio" name="info[doupload]" value="0" checked />否
</td>
</tr>
<!-- eddy 开发商上传权限 end -->
</table>
</fieldset>
<div class="bk15"></div>
<input name="dosubmit" type="submit" id="dosubmit" value="<?php echo L('submit')?>" class="dialog">
</form>
</div>
</div>
</body>
</html>
|
108wo
|
phpcms/modules/member/templates/member_add.tpl.php
|
PHP
|
asf20
| 5,433
|
<?php defined('IN_ADMIN') or exit('No permission resources.');?>
<?php include $this->admin_tpl('header', 'admin');?>
<div class="pad-lr-10">
<div class="table-list">
<table width="100%" cellspacing="0">
<thead>
<tr>
<th align="left" width="200px"><?php echo L('filedname')?></th>
<th align="left" ><?php echo L('value')?></th>
</tr>
</thead>
<tbody>
<?php
foreach($member_fieldinfo as $k=>$v) {
?>
<tr>
<td align="left" width="200px"><?php echo $k?></td>
<td align="left"><?php echo $v?></td>
</tr>
<?php
}
?>
</tbody>
</table>
<div class="btn">
<input type="button" class="dialog" name="dosubmit" id="dosubmit" value="<?php echo L('goback')?>" onclick="window.top.art.dialog({id:'modelinfo'}).close();"/>
</div>
</div>
</div>
</body>
</html>
|
108wo
|
phpcms/modules/member/templates/member_verify_modelinfo.tpl.php
|
PHP
|
asf20
| 845
|
<?php defined('IN_ADMIN') or exit('No permission resources.');?>
<?php include $this->admin_tpl('header', 'admin');?>
<div class="pad-lr-10">
<div class="table-list">
<div class="common-form">
<input type="hidden" name="info[userid]" value="<?php echo $memberinfo['userid']?>"></input>
<input type="hidden" name="info[username]" value="<?php echo $memberinfo['username']?>"></input>
<fieldset>
<legend><?php echo L('basic_configuration')?></legend>
<table width="100%" class="table_form">
<tr>
<td width="120"><?php echo L('username')?></td>
<td><?php echo $memberinfo['username']?><?php if($memberinfo['islock']) {?><img title="<?php echo L('lock')?>" src="<?php echo IMG_PATH?>icon/icon_padlock.gif"><?php }?><?php if($memberinfo['vip']) {?><img title="<?php echo L('vip')?>" src="<?php echo IMG_PATH?>icon/vip.gif"><?php }?></td>
</tr>
<tr>
<td><?php echo L('avatar')?></td>
<td><img src="<?php echo $memberinfo['avatar']?>" onerror="this.src='<?php echo IMG_PATH?>member/nophoto.gif'" height=90 width=90></td>
</tr>
<tr>
<td><?php echo L('nickname')?></td>
<td><?php echo $memberinfo['nickname']?></td>
</tr>
<tr>
<td><?php echo L('email')?></td>
<td>
<?php echo $memberinfo['email']?>
</td>
</tr>
<tr>
<td><?php echo L('member_group')?></td>
<td>
<?php echo $grouplist[$memberinfo['groupid']]['name'];?>
</td>
</tr>
<tr>
<td><?php echo L('member_model')?></td>
<td>
<?php echo $modellist[$modelid]['name'];?>
</td>
</tr>
<tr>
<td><?php echo L('in_site_name')?></td>
<td>
<?php echo $sitelist[$memberinfo['siteid']]['name'];?>
</td>
</tr>
<?php if($memberinfo['vip']) {?>
<tr>
<td><?php echo L('vip').L('overduedate')?></td>
<td>
<?php echo date('Y-m-d H:i:s',$memberinfo['overduedate']);?>
</td>
</tr>
<?php }?>
</table>
</fieldset>
<div class="bk15"></div>
<fieldset>
<legend><?php echo L('more_configuration')?></legend>
<table width="100%" class="table_form">
<?php foreach($member_fieldinfo as $k=>$v) {?>
<tr>
<td width="120"><?php echo $k?></td>
<td><?php echo $v?></td>
</tr>
<?php }?>
</table>
</fieldset>
</div>
<div class="bk15"></div>
<input type="button" class="dialog" name="dosubmit" id="dosubmit" onclick="window.top.art.dialog({id:'modelinfo'}).close();"/>
</div>
</div>
</body>
</html>
|
108wo
|
phpcms/modules/member/templates/member_moreinfo.tpl.php
|
PHP
|
asf20
| 2,430
|
<?php defined('IN_ADMIN') or exit('No permission resources.');?>
<?php include $this->admin_tpl('header', 'admin');?>
<div class="pad-lr-10">
<div class="table-list">
<div class="bk10"></div>
<form name="myform" id="myform" action="?m=member&c=member_modelfield&a=sort" method="post" onsubmit="check();return false;">
<table width="100%" cellspacing="0" >
<thead>
<tr>
<th width="70"><?php echo L('listorder')?></th>
<th width="90"><?php echo L('fieldname')?></th>
<th width="100"><?php echo L('cnames');?></th>
<th width="100"><?php echo L('type');?></th>
<th width="50"><?php echo L('must_input');?></th>
<th width="50"><?php echo L('search');?></th>
<th width="50"><?php echo L('listorder');?></th>
<th width="50"><?php echo L('disabled');?></th>
<th ><?php echo L('operations_manage');?></th>
</tr>
</thead>
<tbody class="td-line">
<?php
foreach($datas as $r) {
?>
<tr>
<td align='center' width='70'>
<input name='listorders[<?php echo $r['fieldid']?>]' type='text' size='3' value='<?php echo $r['listorder']?>' class='input-text-c'>
</td>
<td width='90'><?php echo $r['field']?></td>
<td width="100"><?php echo $r['name']?></td>
<td width="100" align='center'><?php echo $r['formtype']?></td>
<td width="50" align='center'>
<?php echo $r['isbase'] ? L('icon_unlock') : L('icon_locked')?></td>
<td width="50" align='center'>
<?php echo $r['issearch'] ? L('icon_unlock') : L('icon_locked')?></td>
<td width="50" align='center'>
<?php echo $r['isorder'] ? L('icon_unlock') : L('icon_locked')?></td>
<td width="50" align='center'>
<?php echo $r['disabled'] ? L('icon_unlock') : L('icon_locked')?></td>
<td align='center'>
<a href="javascript:edit(<?php echo $r['modelid']?>, <?php echo $r['fieldid']?>, '<?php echo $r['name']?>')"><?php echo L('modify')?></a> |
<?php if(!$r['disabled']) {?>
<a href="?m=member&c=member_modelfield&a=disable&disabled=1&fieldid=<?php echo $r['fieldid']?>&menuid=<?php echo $_GET['menuid']?>"><?php echo L('disable')?></a>
<?php } else {?>
<a href="?m=member&c=member_modelfield&a=disable&disabled=0&fieldid=<?php echo $r['fieldid']?>&menuid=<?php echo $_GET['menuid']?>"><?php echo L('enable')?></a>
<?php }?> |
<a href="javascript:confirmurl('?m=member&c=member_modelfield&a=delete&fieldid=<?php echo $r['fieldid']?>&menuid=<?php echo $_GET['menuid']?>','<?php echo L('sure_delete')?>')"><?php echo L('delete')?></a>
</td>
</tr>
<?php } ?>
</tbody>
</table>
<div class="btn"><input type="submit" class="button" name="dosubmit" value="<?php echo L('sort')?>"/>
</div>
<div id="pages"><?php if(isset($pages)){echo $pages;}?></div>
</div>
</div>
</form>
<div id="PC__contentHeight" style="display:none">160</div>
<script language="JavaScript">
<!--
function edit(modelid, fieldid, name) {
window.top.art.dialog({id:'edit'}).close();
window.top.art.dialog({title:'<?php echo L('edit').L('field')?>《'+name+'》',id:'edit',iframe:'?m=member&c=member_modelfield&a=edit&modelid='+modelid+'&fieldid='+fieldid,width:'700',height:'500'}, function(){var d = window.top.art.dialog({id:'edit'}).data.iframe;d.document.getElementById('dosubmit').click();return false;}, function(){window.top.art.dialog({id:'edit'}).close()});
}
function move(id, name) {
window.top.art.dialog({id:'move'}).close();
window.top.art.dialog({title:'<?php echo L('move')?>《'+name+'》',id:'move',iframe:'?m=member&c=member_model&a=move&modelid='+id,width:'700',height:'500'}, function(){var d = window.top.art.dialog({id:'move'}).data.iframe;d.document.getElementById('dosubmit').click();return false;}, function(){window.top.art.dialog({id:'move'}).close()});
}
function check() {
if(myform.action == '?m=member&c=member_model&a=delete') {
var ids='';
$("input[name='modelid[]']:checked").each(function(i, n){
ids += $(n).val() + ',';
});
if(ids=='') {
window.top.art.dialog({content:'<?php echo L('plsease_select').L('member_model')?>',lock:true,width:'200',height:'50',time:1.5},function(){});
return false;
}
}
myform.submit();
}
//-->
</script>
</body>
</html>
|
108wo
|
phpcms/modules/member/templates/member_modelfield_list.tpl.php
|
PHP
|
asf20
| 4,276
|
<?php
/**
* 会员前台管理中心、账号管理、收藏操作类
*/
defined('IN_PHPCMS') or exit('No permission resources.');
pc_base::load_app_class('foreground');
pc_base::load_sys_class('format', '', 0);
pc_base::load_sys_class('form', '', 0);
class MY_index extends foreground {
private $times_db;
function __construct() {
parent::__construct();
$this->http_user_agent = str_replace('7.0' ,'8.0',$_SERVER['HTTP_USER_AGENT']);
}
public function init() {
$memberinfo = $this->memberinfo;
//初始化phpsso
$phpsso_api_url = $this->_init_phpsso();
//获取头像数组
$avatar = $this->client->ps_getavatar($this->memberinfo['phpssouid']);
$grouplist = getcache('grouplist');
$memberinfo['groupname'] = $grouplist[$memberinfo[groupid]]['name'];
include template('member', 'index');
}
public function register() {
$this->_session_start();
//eddy 判断邀请码 start
if (!isset($_GET['uniqid'])) {
showmessage("本站只提供邀请码注册,请向已注册的会员索取邀请码!", APP_PATH.'index.php?m=member&c=index&a=login');
} else{
$member_model = pc_base::load_model('member_model');
if (!$member_model->count(array('uniqid'=>new_addslashes($_GET['uniqid'])))) {
showmessage("邀请码无效!", APP_PATH.'index.php?m=member&c=index&a=login');
}
}
//eddy end
//加载用户模块配置
$member_setting = getcache('member_setting');
if(!$member_setting['allowregister']) {
showmessage(L('deny_register'), 'index.php?m=member&c=index&a=login');
}
//获取用户siteid
$siteid = isset($_REQUEST['siteid']) && trim($_REQUEST['siteid']) ? intval($_REQUEST['siteid']) : 1;
//定义站点id常量
if (!defined('SITEID')) {
define('SITEID', $siteid);
}
header("Cache-control: private");
if(isset($_POST['dosubmit'])) {
//eddy 去掉验证码验证
//if (empty($_SESSION['connectid']) && $_SESSION['code'] != strtolower($_POST['code'])) {
// showmessage(L('code_error'));
//}
$userinfo = array();
$userinfo['encrypt'] = create_randomstr(6);
//eddy email转成email
//$userinfo['username'] = (isset($_POST['username']) && is_username($_POST['username'])) ? $_POST['username'] : exit('0');
$userinfo['username'] = (isset($_POST['email']) && is_email($_POST['email'])) ? $_POST['email'] : exit('0');
$userinfo['uniqid'] = uniqid(true); //eddy 唯一邀请码
//eddy end
$userinfo['nickname'] = (isset($_POST['nickname']) && is_username($_POST['nickname'])) ? $_POST['nickname'] : '';
$userinfo['email'] = (isset($_POST['email']) && is_email($_POST['email'])) ? $_POST['email'] : exit('0');
$userinfo['password'] = isset($_POST['password']) ? $_POST['password'] : exit('0');
$userinfo['email'] = (isset($_POST['email']) && is_email($_POST['email'])) ? $_POST['email'] : exit('0');
$userinfo['modelid'] = isset($_POST['modelid']) ? intval($_POST['modelid']) : 10;
$userinfo['regip'] = ip();
$userinfo['point'] = $member_setting['defualtpoint'] ? $member_setting['defualtpoint'] : 0;
$userinfo['amount'] = $member_setting['defualtamount'] ? $member_setting['defualtamount'] : 0;
$userinfo['regdate'] = $userinfo['lastdate'] = SYS_TIME;
$userinfo['siteid'] = $siteid;
$userinfo['connectid'] = isset($_SESSION['connectid']) ? $_SESSION['connectid'] : '';
$userinfo['from'] = isset($_SESSION['from']) ? $_SESSION['from'] : '';
unset($_SESSION['connectid'], $_SESSION['from']);
if($member_setting['enablemailcheck']) { //是否需要邮件验证
$userinfo['groupid'] = 7;
} elseif($member_setting['registerverify']) { //是否需要管理员审核
$userinfo['modelinfo'] = isset($_POST['info']) ? array2string($_POST['info']) : '';
$this->verify_db = pc_base::load_model('member_verify_model');
unset($userinfo['lastdate'],$userinfo['connectid'],$userinfo['from']);
$this->verify_db->insert($userinfo);
showmessage(L('operation_success'), 'index.php?m=member&c=index&a=register&t=3');
} else {
$userinfo['groupid'] = $this->_get_usergroup_bypoint($userinfo['point']);
}
if(pc_base::load_config('system', 'phpsso')) {
$this->_init_phpsso();
$status = $this->client->ps_member_register($userinfo['username'], $userinfo['password'], $userinfo['email'], $userinfo['regip'], $userinfo['encrypt']);
if($status > 0) {
$userinfo['phpssouid'] = $status;
//传入phpsso为明文密码,加密后存入phpcms_v9
$userinfo['password'] = password($userinfo['password'], $userinfo['encrypt']);
$userid = $this->db->insert($userinfo, 1);
if($member_setting['choosemodel']) { //如果开启选择模型
//通过模型获取会员信息
require_once CACHE_MODEL_PATH.'member_input.class.php';
require_once CACHE_MODEL_PATH.'member_update.class.php';
$member_input = new member_input($userinfo['modelid']);
$user_model_info = $member_input->get($_POST['info']);
$user_model_info['userid'] = $userid;
//插入会员模型数据
$this->db->set_model($userinfo['modelid']);
$this->db->insert($user_model_info);
}
if($userid > 0) {
//执行登陆操作
if(!$cookietime) $get_cookietime = param::get_cookie('cookietime');
$_cookietime = $cookietime ? intval($cookietime) : ($get_cookietime ? $get_cookietime : 0);
$cookietime = $_cookietime ? TIME + $_cookietime : 0;
if($userinfo['groupid'] == 7) {
param::set_cookie('_username', $userinfo['username'], $cookietime);
param::set_cookie('email', $userinfo['email'], $cookietime);
} else {
$phpcms_auth_key = md5(pc_base::load_config('system', 'auth_key').$this->http_user_agent);
$phpcms_auth = sys_auth($userid."\t".$userinfo['password'], 'ENCODE', $phpcms_auth_key);
param::set_cookie('auth', $phpcms_auth, $cookietime);
param::set_cookie('_userid', $userid, $cookietime);
param::set_cookie('_username', $userinfo['username'], $cookietime);
param::set_cookie('_nickname', $userinfo['nickname'], $cookietime);
param::set_cookie('_groupid', $userinfo['groupid'], $cookietime);
param::set_cookie('cookietime', $_cookietime, $cookietime);
}
}
//eddy 发送注册邮件 start
pc_base::load_sys_func('mail');
$date = date('Y-m-d', time());
$rmessage = <<<str
尊敬的{$userinfo['username']}:
您好!
您在108WO室内设计资源中心的用户名是:{$userinfo['username']} ,密码是:{$_POST['password']}
请妥善保管好您的帐号和密码,谢谢!
<a href="http://www.108wo.com/index.php?m=member&c=index&a=login">http://www.108wo.com/index.php?m=member&c=index&a=login</a> 点此链接登录系统。
本邮件由系统自动发送,请勿回复!
108WO室内设计资源中心
{$date}
str;
sendmail($userinfo['email'], '注册信息', nl2br($rmessage));
//eddy end
//如果需要邮箱认证
if($member_setting['enablemailcheck']) {
pc_base::load_sys_func('mail');
$phpcms_auth_key = md5(pc_base::load_config('system', 'auth_key').$this->http_user_agent);
$code = sys_auth($userid.'|'.md5($phpcms_auth_key), 'ENCODE', $phpcms_auth_key);
$url = APP_PATH."index.php?m=member&c=index&a=register&code=$code&verify=1";
$message = $member_setting['registerverifymessage'];
$message = str_replace(array('{click}','{url}'), array('<a href="'.$url.'">'.L('please_click').'</a>',$url), $message);
sendmail($userinfo['email'], L('reg_verify_email'), $message);
//eddy 转向首页
//showmessage(L('operation_success'), 'index.php?m=member&c=index&a=register&t=2');
showmessage(L('operation_success'), APP_PATH.'index.php');
//eddy end
} else {
//如果不需要邮箱认证、直接登录其他应用
$synloginstr = $this->client->ps_member_synlogin($userinfo['phpssouid']);
//eddy 转向首页
//showmessage(L('operation_success').$synloginstr, 'index.php?m=member&c=index&a=init');
showmessage(L('operation_success'), APP_PATH.'index.php');
//eddy end
}
}
} else {
showmessage(L('enable_register').L('enable_phpsso'), 'index.php?m=member&c=index&a=login');
}
showmessage(L('operation_failure'), HTTP_REFERER);
} else {
if(!pc_base::load_config('system', 'phpsso')) {
showmessage(L('enable_register').L('enable_phpsso'), 'index.php?m=member&c=index&a=login');
}
if(!empty($_GET['verify'])) {
$code = isset($_GET['code']) ? trim($_GET['code']) : showmessage(L('operation_failure'), 'index.php?m=member&c=index');
$phpcms_auth_key = md5(pc_base::load_config('system', 'auth_key').$this->http_user_agent);
$code_res = sys_auth($code, 'DECODE', $phpcms_auth_key);
$code_arr = explode('|', $code_res);
$userid = isset($code_arr[0]) ? $code_arr[0] : '';
$userid = is_numeric($userid) ? $userid : showmessage(L('operation_failure'), 'index.php?m=member&c=index');
$this->db->update(array('groupid'=>$this->_get_usergroup_bypoint()), array('userid'=>$userid));
showmessage(L('operation_success'), 'index.php?m=member&c=index');
} elseif(!empty($_GET['protocol'])) {
include template('member', 'protocol');
} else {
//过滤非当前站点会员模型
$modellist = getcache('member_model', 'commons');
foreach($modellist as $k=>$v) {
if($v['siteid']!=$siteid || $v['disabled']) {
unset($modellist[$k]);
}
}
if(empty($modellist)) {
showmessage(L('site_have_no_model').L('deny_register'), HTTP_REFERER);
}
//是否开启选择会员模型选项
if($member_setting['choosemodel']) {
$first_model = array_pop(array_reverse($modellist));
$modelid = isset($_GET['modelid']) ? intval($_GET['modelid']) : $first_model['modelid'];
if(array_key_exists($modelid, $modellist)) {
//获取会员模型表单
require CACHE_MODEL_PATH.'member_form.class.php';
$member_form = new member_form($modelid);
$this->db->set_model($modelid);
$forminfos = $forminfos_arr = $member_form->get();
//万能字段过滤
foreach($forminfos as $field=>$info) {
if($info['isomnipotent']) {
unset($forminfos[$field]);
} else {
if($info['formtype']=='omnipotent') {
foreach($forminfos_arr as $_fm=>$_fm_value) {
if($_fm_value['isomnipotent']) {
$info['form'] = str_replace('{'.$_fm.'}',$_fm_value['form'], $info['form']);
}
}
$forminfos[$field]['form'] = $info['form'];
}
}
}
$formValidator = $member_form->formValidator;
}
}
$description = $modellist[$modelid]['description'];
include template('member', 'register');
}
}
}
public function account_manage() {
$memberinfo = $this->memberinfo;
//初始化phpsso
$phpsso_api_url = $this->_init_phpsso();
//获取头像数组
$avatar = $this->client->ps_getavatar($this->memberinfo['phpssouid']);
$grouplist = getcache('grouplist');
$member_model = getcache('member_model', 'commons');
//获取用户模型数据
$this->db->set_model($this->memberinfo['modelid']);
$member_modelinfo_arr = $this->db->get_one(array('userid'=>$this->memberinfo['userid']));
$model_info = getcache('model_field_'.$this->memberinfo['modelid'], 'model');
foreach($model_info as $k=>$v) {
if($v['formtype'] == 'omnipotent') continue;
if($v['formtype'] == 'image') {
$member_modelinfo[$v['name']] = "<a href='$member_modelinfo_arr[$k]' target='_blank'><img src='$member_modelinfo_arr[$k]' height='40' widht='40' onerror=\"this.src='$phpsso_api_url/statics/images/member/nophoto.gif'\"></a>";
} elseif($v['formtype'] == 'datetime' && $v['fieldtype'] == 'int') { //如果为日期字段
$member_modelinfo[$v['name']] = format::date($member_modelinfo_arr[$k], $v['format'] == 'Y-m-d H:i:s' ? 1 : 0);
} elseif($v['formtype'] == 'images') {
$tmp = string2array($member_modelinfo_arr[$k]);
$member_modelinfo[$v['name']] = '';
if(is_array($tmp)) {
foreach ($tmp as $tv) {
$member_modelinfo[$v['name']] .= " <a href='$tv[url]' target='_blank'><img src='$tv[url]' height='40' widht='40' onerror=\"this.src='$phpsso_api_url/statics/images/member/nophoto.gif'\"></a>";
}
unset($tmp);
}
} elseif($v['formtype'] == 'box') { //box字段,获取字段名称和值的数组
$tmp = explode("\n",$v['options']);
if(is_array($tmp)) {
foreach($tmp as $boxv) {
$box_tmp_arr = explode('|', trim($boxv));
if(is_array($box_tmp_arr) && isset($box_tmp_arr[1]) && isset($box_tmp_arr[0])) {
$box_tmp[$box_tmp_arr[1]] = $box_tmp_arr[0];
$tmp_key = intval($member_modelinfo_arr[$k]);
}
}
}
if(isset($box_tmp[$tmp_key])) {
$member_modelinfo[$v['name']] = $box_tmp[$tmp_key];
} else {
$member_modelinfo[$v['name']] = $member_modelinfo_arr[$k];
}
unset($tmp, $tmp_key, $box_tmp, $box_tmp_arr);
} elseif($v['formtype'] == 'linkage') { //如果为联动菜单
$tmp = string2array($v['setting']);
$tmpid = $tmp['linkageid'];
$linkagelist = getcache($tmpid, 'linkage');
$fullname = $this->_get_linkage_fullname($member_modelinfo_arr[$k], $linkagelist);
$member_modelinfo[$v['name']] = substr($fullname, 0, -1);
unset($tmp, $tmpid, $linkagelist, $fullname);
} else {
$member_modelinfo[$v['name']] = $member_modelinfo_arr[$k];
}
}
include template('member', 'account_manage');
}
public function account_manage_avatar() {
$memberinfo = $this->memberinfo;
//初始化phpsso
$phpsso_api_url = $this->_init_phpsso();
$ps_auth_key = pc_base::load_config('system', 'phpsso_auth_key');
$auth_data = $this->client->auth_data(array('uid'=>$this->memberinfo['phpssouid'], 'ps_auth_key'=>$ps_auth_key), '', $ps_auth_key);
$upurl = base64_encode($phpsso_api_url.'/index.php?m=phpsso&c=index&a=uploadavatar&auth_data='.$auth_data);
//获取头像数组
$avatar = $this->client->ps_getavatar($this->memberinfo['phpssouid']);
$SEO['title'] = '修改头像 - 会员中心'; //eddy
include template('member', 'account_manage_avatar');
}
public function account_manage_security() {
$memberinfo = $this->memberinfo;
include template('member', 'account_manage_security');
}
public function account_manage_info() {
if(isset($_POST['dosubmit'])) {
//更新用户昵称
$nickname = isset($_POST['nickname']) && trim($_POST['nickname']) ? trim($_POST['nickname']) : '';
if($nickname) {
$this->db->update(array('nickname'=>$nickname), array('userid'=>$this->memberinfo['userid']));
if(!isset($cookietime)) {
$get_cookietime = param::get_cookie('cookietime');
}
$_cookietime = $cookietime ? intval($cookietime) : ($get_cookietime ? $get_cookietime : 0);
$cookietime = $_cookietime ? TIME + $_cookietime : 0;
param::set_cookie('_nickname', $nickname, $cookietime);
}
require_once CACHE_MODEL_PATH.'member_input.class.php';
require_once CACHE_MODEL_PATH.'member_update.class.php';
$member_input = new member_input($this->memberinfo['modelid']);
$modelinfo = $member_input->get($_POST['info']);
$this->db->set_model($this->memberinfo['modelid']);
$membermodelinfo = $this->db->get_one(array('userid'=>$this->memberinfo['userid']));
if(!empty($membermodelinfo)) {
$this->db->update($modelinfo, array('userid'=>$this->memberinfo['userid']));
} else {
$modelinfo['userid'] = $this->memberinfo['userid'];
$this->db->insert($modelinfo);
}
showmessage(L('operation_success'), HTTP_REFERER);
} else {
$memberinfo = $this->memberinfo;
//获取会员模型表单
require CACHE_MODEL_PATH.'member_form.class.php';
$member_form = new member_form($this->memberinfo['modelid']);
$this->db->set_model($this->memberinfo['modelid']);
$membermodelinfo = $this->db->get_one(array('userid'=>$this->memberinfo['userid']));
$forminfos = $forminfos_arr = $member_form->get($membermodelinfo);
//万能字段过滤
foreach($forminfos as $field=>$info) {
if($info['isomnipotent']) {
unset($forminfos[$field]);
} else {
if($info['formtype']=='omnipotent') {
foreach($forminfos_arr as $_fm=>$_fm_value) {
if($_fm_value['isomnipotent']) {
$info['form'] = str_replace('{'.$_fm.'}',$_fm_value['form'], $info['form']);
}
}
$forminfos[$field]['form'] = $info['form'];
}
}
}
$formValidator = $member_form->formValidator;
//会员模型 eddy
$model = pc_base::load_model('member_model_model');
$member_model = $model->select(array('type' => 2, 'disabled' => 0), 'modelid,name');
$SEO['title'] = '个人资料 - 会员中心';
// eddy end
include template('member', 'account_manage_info');
}
}
public function account_manage_password() {
if(isset($_POST['dosubmit'])) {
if(!is_password($_POST['info']['password'])) {
showmessage(L('password_format_incorrect'), HTTP_REFERER);
}
if($this->memberinfo['password'] != password($_POST['info']['password'], $this->memberinfo['encrypt'])) {
showmessage(L('old_password_incorrect'), HTTP_REFERER);
}
//修改会员邮箱
if($this->memberinfo['email'] != $_POST['info']['email'] && is_email($_POST['info']['email'])) {
$email = $_POST['info']['email'];
$updateinfo['email'] = $_POST['info']['email'];
} else {
$email = '';
}
$newpassword = password($_POST['info']['newpassword'], $this->memberinfo['encrypt']);
$updateinfo['password'] = $newpassword;
$this->db->update($updateinfo, array('userid'=>$this->memberinfo['userid']));
if(pc_base::load_config('system', 'phpsso')) {
//初始化phpsso
$this->_init_phpsso();
$res = $this->client->ps_member_edit('', $email, $_POST['info']['password'], $_POST['info']['newpassword'], $this->memberinfo['phpssouid'], $this->memberinfo['encrypt']);
}
showmessage(L('operation_success'), HTTP_REFERER);
} else {
$show_validator = true;
$memberinfo = $this->memberinfo;
$SEO['title'] = '修改密码 - 会员中心'; //eddy
include template('member', 'account_manage_password');
}
}
public function account_manage_upgrade() {
$memberinfo = $this->memberinfo;
$grouplist = getcache('grouplist');
if(empty($grouplist[$memberinfo['groupid']]['allowupgrade'])) {
showmessage(L('deny_upgrade'), HTTP_REFERER);
}
if(isset($_POST['upgrade_type']) && intval($_POST['upgrade_type']) < 0) {
showmessage(L('operation_failure'), HTTP_REFERER);
}
if(isset($_POST['upgrade_date']) && intval($_POST['upgrade_date']) < 0) {
showmessage(L('operation_failure'), HTTP_REFERER);
}
if(isset($_POST['dosubmit'])) {
$groupid = isset($_POST['groupid']) ? intval($_POST['groupid']) : showmessage(L('operation_failure'), HTTP_REFERER);
$upgrade_type = isset($_POST['upgrade_type']) ? intval($_POST['upgrade_type']) : showmessage(L('operation_failure'), HTTP_REFERER);
$upgrade_date = !empty($_POST['upgrade_date']) ? intval($_POST['upgrade_date']) : showmessage(L('operation_failure'), HTTP_REFERER);
//消费类型,包年、包月、包日,价格
$typearr = array($grouplist[$groupid]['price_y'], $grouplist[$groupid]['price_m'], $grouplist[$groupid]['price_d']);
//消费类型,包年、包月、包日,时间
$typedatearr = array('366', '31', '1');
//消费的价格
$cost = $typearr[$upgrade_type]*$upgrade_date;
//购买时间
$buydate = $typedatearr[$upgrade_type]*$upgrade_date*86400;
$overduedate = $memberinfo['overduedate'] > SYS_TIME ? ($memberinfo['overduedate']+$buydate) : (SYS_TIME+$buydate);
if($memberinfo['amount'] >= $cost) {
$this->db->update(array('groupid'=>$groupid, 'overduedate'=>$overduedate, 'vip'=>1), array('userid'=>$memberinfo['userid']));
//消费记录
pc_base::load_app_class('spend','pay',0);
spend::amount($cost, L('allowupgrade'), $memberinfo['userid'], $memberinfo['username']);
showmessage(L('operation_success'), 'index.php?m=member&c=index&a=init');
} else {
showmessage(L('operation_failure'), HTTP_REFERER);
}
} else {
$groupid = isset($_GET['groupid']) ? intval($_GET['groupid']) : '';
//初始化phpsso
$phpsso_api_url = $this->_init_phpsso();
//获取头像数组
$avatar = $this->client->ps_getavatar($this->memberinfo['phpssouid']);
$memberinfo['groupname'] = $grouplist[$memberinfo[groupid]]['name'];
$memberinfo['grouppoint'] = $grouplist[$memberinfo[groupid]]['point'];
unset($grouplist[$memberinfo['groupid']]);
include template('member', 'account_manage_upgrade');
}
}
public function login() {
$this->_session_start();
//获取用户siteid
$siteid = isset($_REQUEST['siteid']) && trim($_REQUEST['siteid']) ? intval($_REQUEST['siteid']) : 1;
//定义站点id常量
if (!defined('SITEID')) {
define('SITEID', $siteid);
}
if(isset($_POST['dosubmit'])) {
if(empty($_SESSION['connectid'])) {
//判断验证码
//下面注释掉,不需要验证码
//$code = isset($_POST['code']) && trim($_POST['code']) ? trim($_POST['code']) : showmessage(L('input_code'), HTTP_REFERER);
//if ($_SESSION['code'] != strtolower($code)) {
// showmessage(L('code_error'), HTTP_REFERER);
//}
}
$username = isset($_POST['username']) && trim($_POST['username']) ? trim($_POST['username']) : showmessage(L('username_empty'), HTTP_REFERER);
$password = isset($_POST['password']) && trim($_POST['password']) ? trim($_POST['password']) : showmessage(L('password_empty'), HTTP_REFERER);
$synloginstr = ''; //同步登陆js代码
if(pc_base::load_config('system', 'phpsso')) {
$this->_init_phpsso();
//eddy
//$status = $this->client->ps_member_login($username, $password);
$status = $this->client->ps_member_login($username, $password, 1);
$memberinfo = unserialize($status);
if(isset($memberinfo['uid'])) {
//查询帐号
$r = $this->db->get_one(array('phpssouid'=>$memberinfo['uid']));
if(!$r) {
//插入会员详细信息,会员不存在 插入会员
$info = array(
'phpssouid'=>$memberinfo['uid'],
'username'=>$memberinfo['username'],
'password'=>$memberinfo['password'],
'encrypt'=>$memberinfo['random'],
'email'=>$memberinfo['email'],
'regip'=>$memberinfo['regip'],
'regdate'=>$memberinfo['regdate'],
'lastip'=>$memberinfo['lastip'],
'lastdate'=>$memberinfo['lastdate'],
'groupid'=>$this->_get_usergroup_bypoint(), //会员默认组
'modelid'=>10, //普通会员
);
//如果是connect用户
if(!empty($_SESSION['connectid'])) {
$userinfo['connectid'] = $_SESSION['connectid'];
}
if(!empty($_SESSION['from'])) {
$userinfo['from'] = $_SESSION['from'];
}
unset($_SESSION['connectid'], $_SESSION['from']);
$this->db->insert($info);
unset($info);
$r = $this->db->get_one(array('phpssouid'=>$memberinfo['uid']));
}
$password = $r['password'];
$synloginstr = $this->client->ps_member_synlogin($r['phpssouid']);
} else {
if($status == -1) { //用户不存在
showmessage(L('user_not_exist'), 'index.php?m=member&c=index&a=login');
} elseif($status == -2) { //密码错误
showmessage(L('password_error'), 'index.php?m=member&c=index&a=login');
} else {
showmessage(L('login_failure'), 'index.php?m=member&c=index&a=login');
}
}
} else {
//密码错误剩余重试次数
$this->times_db = pc_base::load_model('times_model');
$rtime = $this->times_db->get_one(array('username'=>$username));
if($rtime['times'] > 4) {
$minute = 60 - floor((SYS_TIME - $rtime['logintime']) / 60);
showmessage(L('wait_1_hour', array('minute'=>$minute)));
}
//查询帐号
$r = $this->db->get_one(array('username'=>$username));
if(!$r) showmessage(L('user_not_exist'),'index.php?m=member&c=index&a=login');
//验证用户密码
$password = md5(md5(trim($password)).$r['encrypt']);
if($r['password'] != $password) {
$ip = ip();
if($rtime && $rtime['times'] < 5) {
$times = 5 - intval($rtime['times']);
$this->times_db->update(array('ip'=>$ip, 'times'=>'+=1'), array('username'=>$username));
} else {
$this->times_db->insert(array('username'=>$username, 'ip'=>$ip, 'logintime'=>SYS_TIME, 'times'=>1));
$times = 5;
}
showmessage(L('password_error', array('times'=>$times)), 'index.php?m=member&c=index&a=login', 3000);
}
$this->times_db->delete(array('username'=>$username));
}
//如果用户被锁定
if($r['islock']) {
showmessage(L('user_is_lock'));
}
$userid = $r['userid'];
$groupid = $r['groupid'];
$username = $r['username'];
$nickname = empty($r['nickname']) ? $username : $r['nickname'];
$updatearr = array('lastip'=>ip(), 'lastdate'=>SYS_TIME);
//vip过期,更新vip和会员组
if($r['overduedate'] < SYS_TIME) {
$updatearr['vip'] = 0;
}
//检查用户积分,更新新用户组,除去邮箱认证、禁止访问、游客组用户、vip用户
if($r['point'] >= 0 && !in_array($r['groupid'], array('1', '7', '8')) && empty($r[vip])) {
$check_groupid = $this->_get_usergroup_bypoint($r['point']);
if($check_groupid != $r['groupid']) {
$updatearr['groupid'] = $groupid = $check_groupid;
}
}
//如果是connect用户
if(!empty($_SESSION['connectid'])) {
$updatearr['connectid'] = $_SESSION['connectid'];
}
if(!empty($_SESSION['from'])) {
$updatearr['from'] = $_SESSION['from'];
}
unset($_SESSION['connectid'], $_SESSION['from']);
$this->db->update($updatearr, array('userid'=>$userid));
//eddy 记住登录状态 start
if (isset($_POST['cookietime']) && intval($_POST['cookietime']) > 0) {
$cookietime = intval($_POST['cookietime']);
}
//eddy 记住登录状态 end
if(!isset($cookietime)) {
$get_cookietime = param::get_cookie('cookietime');
}
$_cookietime = $cookietime ? intval($cookietime) : ($get_cookietime ? $get_cookietime : 0);
$cookietime = $_cookietime ? SYS_TIME + $_cookietime : 0;
$phpcms_auth_key = md5(pc_base::load_config('system', 'auth_key').$this->http_user_agent);
$phpcms_auth = sys_auth($userid."\t".$password, 'ENCODE', $phpcms_auth_key);
param::set_cookie('auth', $phpcms_auth, $cookietime);
param::set_cookie('_userid', $userid, $cookietime);
param::set_cookie('_username', $username, $cookietime);
param::set_cookie('_groupid', $groupid, $cookietime);
param::set_cookie('_nickname', $nickname, $cookietime);
param::set_cookie('cookietime', $_cookietime, $cookietime);
$forward = isset($_POST['forward']) && !empty($_POST['forward']) ? urldecode($_POST['forward']) : 'index.php?m=member&c=index';
showmessage(L('login_success').$synloginstr, $forward);
} else {
$setting = pc_base::load_config('system');
$forward = isset($_GET['forward']) && trim($_GET['forward']) ? urlencode($_GET['forward']) : '';
if(!empty($setting['connect_enable'])) {
$snda_res = $this->_snda_get_appid();
$appid = $snda_res['appid'];
$secretkey = $snda_res['secretkey'];
$sid = md5("appArea=0appId=".$appid."service=".urlencode(APP_PATH.'index.php?m=member&c=index&a=public_snda_login&forward='.$forward).$secretkey);
$sndaurl = "https://cas.sdo.com/cas/login?gateway=true&service=".urlencode(APP_PATH.'index.php?m=member&c=index&a=public_snda_login&forward='.$forward)."&appId=".$appid."&appArea=0&sid=".$sid;
}
$siteid = isset($_REQUEST['siteid']) && trim($_REQUEST['siteid']) ? intval($_REQUEST['siteid']) : 1;
$siteinfo = siteinfo($siteid);
include template('member', 'login');
}
}
/**
*
* 获取已申请的appid和secretkey,默认appid为200037400
*/
private function _snda_get_appid() {
$snda_res = pc_base::load_config('snda', 'snda_status');
if(strstr($snda_res, '|')) {
$snda_res_arr = explode('|', $snda_res);
$appid = isset($snda_res_arr[0]) ? $snda_res_arr[0] : '';
$secretkey = isset($snda_res_arr[1]) ? $snda_res_arr[1] : '';
} else {
$appid = 200037400;
$secretkey = '';
}
return array('appid'=>$appid, 'secretkey'=>$secretkey);
}
public function logout() {
$setting = pc_base::load_config('system');
//snda退出
if($setting['snda_enable'] && param::get_cookie('_from')=='snda') {
param::set_cookie('_from', '');
$forward = isset($_GET['forward']) && trim($_GET['forward']) ? urlencode($_GET['forward']) : '';
$logouturl = 'https://cas.sdo.com/cas/logout?url='.urlencode(APP_PATH.'index.php?m=member&c=index&a=logout&forward='.$forward);
header('Location: '.$logouturl);
} else {
$synlogoutstr = ''; //同步退出js代码
if(pc_base::load_config('system', 'phpsso')) {
$this->_init_phpsso();
$synlogoutstr = $this->client->ps_member_synlogout();
}
param::set_cookie('auth', '');
param::set_cookie('_userid', '');
param::set_cookie('_username', '');
param::set_cookie('_groupid', '');
param::set_cookie('_nickname', '');
param::set_cookie('cookietime', '');
$forward = isset($_GET['forward']) && trim($_GET['forward']) ? $_GET['forward'] : 'index.php?m=member&c=index&a=login';
showmessage(L('logout_success').$synlogoutstr, $forward);
}
}
/**
* 我的收藏
*
*/
public function favorite() {
$this->favorite_db = pc_base::load_model('favorite_model');
$memberinfo = $this->memberinfo;
if(isset($_GET['id']) && trim($_GET['id'])) {
$this->favorite_db->delete(array('userid'=>$memberinfo['userid'], 'id'=>intval($_GET['id'])));
showmessage(L('operation_success'), HTTP_REFERER);
} else {
$page = isset($_GET['page']) && trim($_GET['page']) ? intval($_GET['page']) : 1;
$favoritelist = $this->favorite_db->listinfo(array('userid'=>$memberinfo['userid']), 'id DESC', $page, 10);
$pages = $this->favorite_db->pages;
include template('member', 'favorite_list');
}
}
/**
* 我的好友
*/
public function friend() {
$memberinfo = $this->memberinfo;
$this->friend_db = pc_base::load_model('friend_model');
if(isset($_GET['friendid'])) {
$this->friend_db->delete(array('userid'=>$memberinfo['userid'], 'friendid'=>intval($_GET['friendid'])));
showmessage(L('operation_success'), HTTP_REFERER);
} else {
//初始化phpsso
$phpsso_api_url = $this->_init_phpsso();
//我的好友列表userid
$page = isset($_GET['page']) ? intval($_GET['page']) : 1;
$friendids = $this->friend_db->listinfo(array('userid'=>$memberinfo['userid']), '', $page, 10);
$pages = $this->friend_db->pages;
foreach($friendids as $k=>$v) {
$friendlist[$k]['friendid'] = $v['friendid'];
$friendlist[$k]['avatar'] = $this->client->ps_getavatar($v['phpssouid']);
$friendlist[$k]['is'] = $v['is'];
}
include template('member', 'friend_list');
}
}
/**
* 积分兑换
*/
public function change_credit() {
$memberinfo = $this->memberinfo;
//加载用户模块配置
$member_setting = getcache('member_setting');
$this->_init_phpsso();
$setting = $this->client->ps_getcreditlist();
$outcredit = unserialize($setting);
$setting = $this->client->ps_getapplist();
$applist = unserialize($setting);
if(isset($_POST['dosubmit'])) {
//本系统积分兑换数
$fromvalue = intval($_POST['fromvalue']);
//本系统积分类型
$from = $_POST['from'];
$toappid_to = explode('_', $_POST['to']);
//目标系统appid
$toappid = $toappid_to[0];
//目标系统积分类型
$to = $toappid_to[1];
if($from == 1) {
if($memberinfo['point'] < $fromvalue) {
showmessage(L('need_more_point'), HTTP_REFERER);
}
} elseif($from == 2) {
if($memberinfo['amount'] < $fromvalue) {
showmessage(L('need_more_amount'), HTTP_REFERER);
}
} else {
showmessage(L('credit_setting_error'), HTTP_REFERER);
}
$status = $this->client->ps_changecredit($memberinfo['phpssouid'], $from, $toappid, $to, $fromvalue);
if($status == 1) {
if($from == 1) {
$this->db->update(array('point'=>"-=$fromvalue"), array('userid'=>$memberinfo['userid']));
} elseif($from == 2) {
$this->db->update(array('amount'=>"-=$fromvalue"), array('userid'=>$memberinfo['userid']));
}
showmessage(L('operation_success'), HTTP_REFERER);
} else {
showmessage(L('operation_failure'), HTTP_REFERER);
}
} elseif(isset($_POST['buy'])) {
if(!is_numeric($_POST['money']) || $_POST['money'] < 0) {
showmessage(L('money_error'), HTTP_REFERER);
} else {
$money = intval($_POST['money']);
}
if($memberinfo['amount'] < $money) {
showmessage(L('short_of_money'), HTTP_REFERER);
}
//此处比率读取用户配置
$point = $money*$member_setting['rmb_point_rate'];
$this->db->update(array('point'=>"+=$point"), array('userid'=>$memberinfo['userid']));
//加入消费记录,同时扣除金钱
pc_base::load_app_class('spend','pay',0);
spend::amount($money, L('buy_point'), $memberinfo['userid'], $memberinfo['username']);
showmessage(L('operation_success'), HTTP_REFERER);
} else {
$credit_list = pc_base::load_config('credit');
include template('member', 'change_credit');
}
}
//mini登陆条
public function mini() {
$_username = param::get_cookie('_username');
$_userid = param::get_cookie('_userid');
$siteid = isset($_GET['siteid']) ? intval($_GET['siteid']) : '';
//定义站点id常量
if (!defined('SITEID')) {
define('SITEID', $siteid);
}
$snda_enable = pc_base::load_config('system', 'snda_enable');
include template('member', 'mini');
}
/**
* 初始化phpsso
* about phpsso, include client and client configure
* @return string phpsso_api_url phpsso地址
*/
private function _init_phpsso() {
pc_base::load_app_class('client', '', 0);
define('APPID', pc_base::load_config('system', 'phpsso_appid'));
$phpsso_api_url = pc_base::load_config('system', 'phpsso_api_url');
$phpsso_auth_key = pc_base::load_config('system', 'phpsso_auth_key');
$this->client = new client($phpsso_api_url, $phpsso_auth_key);
return $phpsso_api_url;
}
protected function _checkname($username) {
$username = trim($username);
if ($this->db->get_one(array('username'=>$username))){
return false;
}
return true;
}
private function _session_start() {
$session_storage = 'session_'.pc_base::load_config('system','session_storage');
pc_base::load_sys_class($session_storage);
}
/*
* 通过linkageid获取名字路径
*/
protected function _get_linkage_fullname($linkageid, $linkagelist) {
$fullname = '';
if($linkagelist['data'][$linkageid]['parentid'] != 0) {
$fullname = $this->_get_linkage_fullname($linkagelist['data'][$linkageid]['parentid'], $linkagelist);
}
//所在地区名称
$return = $fullname.$linkagelist['data'][$linkageid]['name'].'>';
return $return;
}
/**
*根据积分算出用户组
* @param $point int 积分数
*/
protected function _get_usergroup_bypoint($point=0) {
$groupid = 6;
if(empty($point)) {
$member_setting = getcache('member_setting');
$point = $member_setting['defualtpoint'] ? $member_setting['defualtpoint'] : 0;
}
$grouplist = getcache('grouplist');
foreach ($grouplist as $k=>$v) {
$grouppointlist[$k] = $v['point'];
}
arsort($grouppointlist);
//如果超出用户组积分设置则为积分最高的用户组
if($point > max($grouppointlist)) {
$groupid = key($grouppointlist);
} else {
foreach ($grouppointlist as $k=>$v) {
if($point >= $v) {
$groupid = $tmp_k;
break;
}
$tmp_k = $k;
}
}
return $groupid;
}
/**
* 检查用户名
* @param string $username 用户名
* @return $status {-4:用户名禁止注册;-1:用户名已经存在 ;1:成功}
*/
public function public_checkname_ajax() {
$username = isset($_GET['username']) && trim($_GET['username']) ? trim($_GET['username']) : exit(0);
if(CHARSET != 'utf-8') {
$username = iconv('utf-8', CHARSET, $username);
$username = addslashes($username);
}
//首先判断会员审核表
$this->verify_db = pc_base::load_model('member_verify_model');
if($this->verify_db->get_one(array('username'=>$username))) {
exit('0');
}
$this->_init_phpsso();
$status = $this->client->ps_checkname($username);
if($status == -4 || $status == -1) {
exit('0');
} else {
exit('1');
}
}
/**
* 检查用户昵称
* @param string $nickname 昵称
* @return $status {0:已存在;1:成功}
*/
public function public_checknickname_ajax() {
$nickname = isset($_GET['nickname']) && trim($_GET['nickname']) ? trim($_GET['nickname']) : exit('0');
if(CHARSET != 'utf-8') {
$nickname = iconv('utf-8', CHARSET, $nickname);
$nickname = addslashes($nickname);
}
//首先判断会员审核表
$this->verify_db = pc_base::load_model('member_verify_model');
if($this->verify_db->get_one(array('nickname'=>$nickname))) {
exit('0');
}
$res = $this->db->get_one(array('nickname'=>$nickname));
if($res) {
exit('0');
} else {
exit('1');
}
}
/**
* 检查邮箱
* @param string $email
* @return $status {-1:email已经存在 ;-5:邮箱禁止注册;1:成功}
*/
public function public_checkemail_ajax() {
$this->_init_phpsso();
$email = isset($_GET['email']) && trim($_GET['email']) ? trim($_GET['email']) : exit(0);
$status = $this->client->ps_checkemail($email);
if($status == -5) { //禁止注册
exit('0');
} elseif($status == -1) { //用户名已存在,但是修改用户的时候需要判断邮箱是否是当前用户的
if(isset($_GET['phpssouid'])) { //修改用户传入phpssouid
$status = $this->client->ps_get_member_info($email, 3);
if($status) {
$status = unserialize($status); //接口返回序列化,进行判断
if (isset($status['uid']) && $status['uid'] == intval($_GET['phpssouid'])) {
exit('1');
} else {
exit('0');
}
} else {
exit('0');
}
} else {
exit('0');
}
} else {
exit('1');
}
}
public function public_sina_login() {
define('WB_AKEY', pc_base::load_config('system', 'sina_akey'));
define('WB_SKEY', pc_base::load_config('system', 'sina_skey'));
pc_base::load_app_class('weibooauth', '' ,0);
$this->_session_start();
if(isset($_GET['callback']) && trim($_GET['callback'])) {
$o = new WeiboOAuth(WB_AKEY, WB_SKEY, $_SESSION['keys']['oauth_token'], $_SESSION['keys']['oauth_token_secret']);
$_SESSION['last_key'] = $o->getAccessToken($_REQUEST['oauth_verifier']);
$c = new WeiboClient(WB_AKEY, WB_SKEY, $_SESSION['last_key']['oauth_token'], $_SESSION['last_key']['oauth_token_secret']);
//获取用户信息
$me = $c->verify_credentials();
if(CHARSET != 'utf-8') {
$me['name'] = iconv('utf-8', CHARSET, $me['name']);
$me['location'] = iconv('utf-8', CHARSET, $me['location']);
$me['description'] = iconv('utf-8', CHARSET, $me['description']);
$me['screen_name'] = iconv('utf-8', CHARSET, $me['screen_name']);
}
if(!empty($me['id'])) {
//检查connect会员是否绑定,已绑定直接登录,未绑定提示注册/绑定页面
$where = array('connectid'=>$me['id'], 'from'=>'sina');
$r = $this->db->get_one($where);
//connect用户已经绑定本站用户
if(!empty($r)) {
//读取本站用户信息,执行登录操作
$password = $r['password'];
$this->_init_phpsso();
$synloginstr = $this->client->ps_member_synlogin($r['phpssouid']);
$userid = $r['userid'];
$groupid = $r['groupid'];
$username = $r['username'];
$nickname = empty($r['nickname']) ? $username : $r['nickname'];
$this->db->update(array('lastip'=>ip(), 'lastdate'=>SYS_TIME, 'nickname'=>$me['name']), array('userid'=>$userid));
if(!$cookietime) $get_cookietime = param::get_cookie('cookietime');
$_cookietime = $cookietime ? intval($cookietime) : ($get_cookietime ? $get_cookietime : 0);
$cookietime = $_cookietime ? TIME + $_cookietime : 0;
$phpcms_auth_key = md5(pc_base::load_config('system', 'auth_key').$this->http_user_agent);
$phpcms_auth = sys_auth($userid."\t".$password, 'ENCODE', $phpcms_auth_key);
param::set_cookie('auth', $phpcms_auth, $cookietime);
param::set_cookie('_userid', $userid, $cookietime);
param::set_cookie('_username', $username, $cookietime);
param::set_cookie('_groupid', $groupid, $cookietime);
param::set_cookie('cookietime', $_cookietime, $cookietime);
param::set_cookie('_nickname', $nickname, $cookietime);
$forward = isset($_GET['forward']) && !empty($_GET['forward']) ? $_GET['forward'] : 'index.php?m=member&c=index';
showmessage(L('login_success').$synloginstr, $forward);
} else {
//弹出绑定注册页面
$_SESSION['connectid'] = $me['id'];
$_SESSION['from'] = 'sina';
$connect_username = $me['name'];
include template('member', 'connect');
}
} else {
showmessage(L('login_failure'), 'index.php?m=member&c=index&a=login');
}
} else {
$o = new WeiboOAuth(WB_AKEY, WB_SKEY);
$keys = $o->getRequestToken();
$aurl = $o->getAuthorizeURL($keys['oauth_token'] ,false , APP_PATH.'index.php?m=member&c=index&a=public_sina_login&callback=1');
$_SESSION['keys'] = $keys;
include template('member', 'connect_sina');
}
}
/**
* 盛大通行证登陆
*/
public function public_snda_login() {
define('SNDA_AKEY', pc_base::load_config('system', 'snda_akey'));
define('SNDA_SKEY', pc_base::load_config('system', 'snda_skey'));
define('SNDA_CALLBACK', urlencode(APP_PATH.'index.php?m=member&c=index&a=public_snda_login&callback=1'));
pc_base::load_app_class('OauthSDK', '' ,0);
$this->_session_start();
if(isset($_GET['callback']) && trim($_GET['callback'])) {
$o = new OauthSDK(SNDA_AKEY, SNDA_SKEY, SNDA_CALLBACK);
$code = $_REQUEST['code'];
$accesstoken = $o->getAccessToken($code);
if(is_numeric($accesstoken['sdid'])) {
$userid = $accesstoken['sdid'];
} else {
showmessage(L('login_failure'), 'index.php?m=member&c=index&a=login');
}
if(!empty($userid)) {
//检查connect会员是否绑定,已绑定直接登录,未绑定提示注册/绑定页面
$where = array('connectid'=>$userid, 'from'=>'snda');
$r = $this->db->get_one($where);
//connect用户已经绑定本站用户
if(!empty($r)) {
//读取本站用户信息,执行登录操作
$password = $r['password'];
$this->_init_phpsso();
$synloginstr = $this->client->ps_member_synlogin($r['phpssouid']);
$userid = $r['userid'];
$groupid = $r['groupid'];
$username = $r['username'];
$nickname = empty($r['nickname']) ? $username : $r['nickname'];
$this->db->update(array('lastip'=>ip(), 'lastdate'=>SYS_TIME, 'nickname'=>$me['name']), array('userid'=>$userid));
if(!$cookietime) $get_cookietime = param::get_cookie('cookietime');
$_cookietime = $cookietime ? intval($cookietime) : ($get_cookietime ? $get_cookietime : 0);
$cookietime = $_cookietime ? TIME + $_cookietime : 0;
$phpcms_auth_key = md5(pc_base::load_config('system', 'auth_key').$this->http_user_agent);
$phpcms_auth = sys_auth($userid."\t".$password, 'ENCODE', $phpcms_auth_key);
param::set_cookie('auth', $phpcms_auth, $cookietime);
param::set_cookie('_userid', $userid, $cookietime);
param::set_cookie('_username', $username, $cookietime);
param::set_cookie('_groupid', $groupid, $cookietime);
param::set_cookie('cookietime', $_cookietime, $cookietime);
param::set_cookie('_nickname', $nickname, $cookietime);
param::set_cookie('_from', 'snda');
$forward = isset($_GET['forward']) && !empty($_GET['forward']) ? $_GET['forward'] : 'index.php?m=member&c=index';
showmessage(L('login_success').$synloginstr, $forward);
} else {
//弹出绑定注册页面
$_SESSION['connectid'] = $userid;
$_SESSION['from'] = 'snda';
$connect_username = $userid;
include template('member', 'connect');
}
}
} else {
$o = new OauthSDK(SNDA_AKEY, SNDA_SKEY, SNDA_CALLBACK);
$accesstoken = $o->getSystemToken();
$aurl = $o->getAuthorizeURL();
include template('member', 'connect_snda');
}
}
/**
* QQ登录
*/
public function public_qq_login() {
define('QQ_AKEY', pc_base::load_config('system', 'qq_akey'));
define('QQ_SKEY', pc_base::load_config('system', 'qq_skey'));
pc_base::load_app_class('qqoauth', '' ,0);
$this->_session_start();
if(isset($_GET['callback']) && trim($_GET['callback'])) {
$o = new WeiboOAuth(QQ_AKEY, QQ_SKEY, $_SESSION['keys']['oauth_token'], $_SESSION['keys']['oauth_token_secret']);
$_SESSION['last_key'] = $o->getAccessToken($_REQUEST['oauth_verifier']);
if(!empty($_SESSION['last_key']['name'])) {
//检查connect会员是否绑定,已绑定直接登录,未绑定提示注册/绑定页面
$where = array('connectid'=>$_SESSION['last_key']['name'], 'from'=>'qq');
$r = $this->db->get_one($where);
//connect用户已经绑定本站用户
if(!empty($r)) {
//读取本站用户信息,执行登录操作
$password = $r['password'];
$this->_init_phpsso();
$synloginstr = $this->client->ps_member_synlogin($r['phpssouid']);
$userid = $r['userid'];
$groupid = $r['groupid'];
$username = $r['username'];
$nickname = empty($r['nickname']) ? $username : $r['nickname'];
$this->db->update(array('lastip'=>ip(), 'lastdate'=>SYS_TIME, 'nickname'=>$me['name']), array('userid'=>$userid));
if(!$cookietime) $get_cookietime = param::get_cookie('cookietime');
$_cookietime = $cookietime ? intval($cookietime) : ($get_cookietime ? $get_cookietime : 0);
$cookietime = $_cookietime ? TIME + $_cookietime : 0;
$phpcms_auth_key = md5(pc_base::load_config('system', 'auth_key').$this->http_user_agent);
$phpcms_auth = sys_auth($userid."\t".$password, 'ENCODE', $phpcms_auth_key);
param::set_cookie('auth', $phpcms_auth, $cookietime);
param::set_cookie('_userid', $userid, $cookietime);
param::set_cookie('_username', $username, $cookietime);
param::set_cookie('_groupid', $groupid, $cookietime);
param::set_cookie('cookietime', $_cookietime, $cookietime);
param::set_cookie('_nickname', $nickname, $cookietime);
param::set_cookie('_from', 'snda');
$forward = isset($_GET['forward']) && !empty($_GET['forward']) ? $_GET['forward'] : 'index.php?m=member&c=index';
showmessage(L('login_success').$synloginstr, $forward);
} else {
//弹出绑定注册页面
$_SESSION['connectid'] = $_SESSION['last_key']['name'];
$_SESSION['from'] = 'qq';
$connect_username = $_SESSION['last_key']['name'];
include template('member', 'connect');
}
} else {
showmessage(L('login_failure'), 'index.php?m=member&c=index&a=login');
}
} else {
$oauth_callback = APP_PATH.'index.php?m=member&c=index&a=public_qq_login&callback=1';
$oauth_nonce = md5(SYS_TIME);
$oauth_signature_method = 'HMAC-SHA1';
$oauth_timestamp = SYS_TIME;
$oauth_version = '1.0';
$url = "https://open.t.qq.com/cgi-bin/request_token?oauth_callback=$oauth_callback&oauth_consumer_key=".QQ_AKEY."&oauth_nonce=$oauth_nonce&oauth_signature=".QQ_SKEY."&oauth_signature_method=HMAC-SHA1&oauth_timestamp=$oauth_timestamp&oauth_version=$oauth_version";
$o = new WeiboOAuth(QQ_AKEY, QQ_SKEY);
$keys = $o->getRequestToken(array('callback'=>$oauth_callback));
$_SESSION['keys'] = $keys;
$aurl = $o->getAuthorizeURL($keys['oauth_token'] ,false , $oauth_callback);
include template('member', 'connect_qq');
}
}
/**
* 找回密码
*/
public function public_forget_password () {
$email_config = getcache('common', 'commons');
if(empty($email_config['mail_user']) || empty($email_config['mail_password'])) {
showmessage(L('email_config_empty'), HTTP_REFERER);
}
$this->_session_start();
$member_setting = getcache('member_setting');
if(isset($_POST['dosubmit'])) {
if ($_SESSION['code'] != strtolower($_POST['code'])) {
showmessage(L('code_error'), HTTP_REFERER);
}
$memberinfo = $this->db->get_one(array('email'=>$_POST['email']));
if(!empty($memberinfo['email'])) {
$email = $memberinfo['email'];
} else {
showmessage(L('email_error'), HTTP_REFERER);
}
pc_base::load_sys_func('mail');
$phpcms_auth_key = md5(pc_base::load_config('system', 'auth_key').$this->http_user_agent);
$code = sys_auth($memberinfo['userid']."\t".SYS_TIME, 'ENCODE', $phpcms_auth_key);
$url = APP_PATH."index.php?m=member&c=index&a=public_forget_password&code=$code";
$message = $member_setting['forgetpassword'];
$message = str_replace(array('{click}','{url}'), array('<a href="'.$url.'">'.L('please_click').'</a>',$url), $message);
//获取站点名称
$sitelist = getcache('sitelist', 'commons');
if(isset($sitelist[$memberinfo['siteid']]['name'])) {
$sitename = $sitelist[$memberinfo['siteid']]['name'];
} else {
$sitename = 'PHPCMS_V9_MAIL';
}
sendmail($email, L('forgetpassword'), $message, '', '', $sitename);
showmessage(L('operation_success'), 'index.php?m=member&c=index&a=login');
} elseif($_GET['code']) {
$phpcms_auth_key = md5(pc_base::load_config('system', 'auth_key').$this->http_user_agent);
$hour = date('y-m-d h', SYS_TIME);
$code = sys_auth($_GET['code'], 'DECODE', $phpcms_auth_key);
$code = explode("\t", $code);
if(is_array($code) && is_numeric($code[0]) && date('y-m-d h', SYS_TIME) == date('y-m-d h', $code[1])) {
$memberinfo = $this->db->get_one(array('userid'=>$code[0]));
if(empty($memberinfo['phpssouid'])) {
showmessage(L('operation_failure'), 'index.php?m=member&c=index&a=login');
}
$password = random(8);
$updateinfo['password'] = password($password, $memberinfo['encrypt']);
$this->db->update($updateinfo, array('userid'=>$code[0]));
if(pc_base::load_config('system', 'phpsso')) {
//初始化phpsso
$this->_init_phpsso();
$this->client->ps_member_edit('', $email, '', $password, $memberinfo['phpssouid'], $memberinfo['encrypt']);
}
showmessage(L('operation_success').L('newpassword').':'.$password);
} else {
showmessage(L('operation_failure'), 'index.php?m=member&c=index&a=login');
}
} else {
$siteid = isset($_REQUEST['siteid']) && trim($_REQUEST['siteid']) ? intval($_REQUEST['siteid']) : 1;
$siteinfo = siteinfo($siteid);
include template('member', 'forget_password');
}
}
/**
*分享给好友
*eddy
*/
public function share()
{
$memberinfo = $this->memberinfo;
include template('member', 'share');
}
}
?>
|
108wo
|
phpcms/modules/member/MY_index.php
|
PHP
|
asf20
| 52,476
|
<?php
/**
* 会员前台管理中心、账号管理、收藏操作类
*/
defined('IN_PHPCMS') or exit('No permission resources.');
pc_base::load_app_class('foreground');
pc_base::load_sys_class('format', '', 0);
pc_base::load_sys_class('form', '', 0);
class index extends foreground {
private $times_db;
function __construct() {
parent::__construct();
$this->http_user_agent = str_replace('7.0' ,'8.0',$_SERVER['HTTP_USER_AGENT']);
}
public function init() {
$memberinfo = $this->memberinfo;
//初始化phpsso
$phpsso_api_url = $this->_init_phpsso();
//获取头像数组
$avatar = $this->client->ps_getavatar($this->memberinfo['phpssouid']);
$grouplist = getcache('grouplist');
$memberinfo['groupname'] = $grouplist[$memberinfo[groupid]]['name'];
include template('member', 'index');
}
public function register() {
$this->_session_start();
//加载用户模块配置
$member_setting = getcache('member_setting');
if(!$member_setting['allowregister']) {
showmessage(L('deny_register'), 'index.php?m=member&c=index&a=login');
}
//获取用户siteid
$siteid = isset($_REQUEST['siteid']) && trim($_REQUEST['siteid']) ? intval($_REQUEST['siteid']) : 1;
//定义站点id常量
if (!defined('SITEID')) {
define('SITEID', $siteid);
}
header("Cache-control: private");
if(isset($_POST['dosubmit'])) {
if (empty($_SESSION['connectid']) && $_SESSION['code'] != strtolower($_POST['code'])) {
showmessage(L('code_error'));
}
$userinfo = array();
$userinfo['encrypt'] = create_randomstr(6);
$userinfo['username'] = (isset($_POST['username']) && is_username($_POST['username'])) ? $_POST['username'] : exit('0');
$userinfo['nickname'] = (isset($_POST['nickname']) && is_username($_POST['nickname'])) ? $_POST['nickname'] : '';
$userinfo['email'] = (isset($_POST['email']) && is_email($_POST['email'])) ? $_POST['email'] : exit('0');
$userinfo['password'] = isset($_POST['password']) ? $_POST['password'] : exit('0');
$userinfo['email'] = (isset($_POST['email']) && is_email($_POST['email'])) ? $_POST['email'] : exit('0');
$userinfo['modelid'] = isset($_POST['modelid']) ? intval($_POST['modelid']) : 10;
$userinfo['regip'] = ip();
$userinfo['point'] = $member_setting['defualtpoint'] ? $member_setting['defualtpoint'] : 0;
$userinfo['amount'] = $member_setting['defualtamount'] ? $member_setting['defualtamount'] : 0;
$userinfo['regdate'] = $userinfo['lastdate'] = SYS_TIME;
$userinfo['siteid'] = $siteid;
$userinfo['connectid'] = isset($_SESSION['connectid']) ? $_SESSION['connectid'] : '';
$userinfo['from'] = isset($_SESSION['from']) ? $_SESSION['from'] : '';
unset($_SESSION['connectid'], $_SESSION['from']);
if($member_setting['enablemailcheck']) { //是否需要邮件验证
$userinfo['groupid'] = 7;
} elseif($member_setting['registerverify']) { //是否需要管理员审核
$userinfo['modelinfo'] = isset($_POST['info']) ? array2string($_POST['info']) : '';
$this->verify_db = pc_base::load_model('member_verify_model');
unset($userinfo['lastdate'],$userinfo['connectid'],$userinfo['from']);
$this->verify_db->insert($userinfo);
showmessage(L('operation_success'), 'index.php?m=member&c=index&a=register&t=3');
} else {
$userinfo['groupid'] = $this->_get_usergroup_bypoint($userinfo['point']);
}
if(pc_base::load_config('system', 'phpsso')) {
$this->_init_phpsso();
$status = $this->client->ps_member_register($userinfo['username'], $userinfo['password'], $userinfo['email'], $userinfo['regip'], $userinfo['encrypt']);
if($status > 0) {
$userinfo['phpssouid'] = $status;
//传入phpsso为明文密码,加密后存入phpcms_v9
$userinfo['password'] = password($userinfo['password'], $userinfo['encrypt']);
$userid = $this->db->insert($userinfo, 1);
if($member_setting['choosemodel']) { //如果开启选择模型
//通过模型获取会员信息
require_once CACHE_MODEL_PATH.'member_input.class.php';
require_once CACHE_MODEL_PATH.'member_update.class.php';
$member_input = new member_input($userinfo['modelid']);
$user_model_info = $member_input->get($_POST['info']);
$user_model_info['userid'] = $userid;
//插入会员模型数据
$this->db->set_model($userinfo['modelid']);
$this->db->insert($user_model_info);
}
if($userid > 0) {
//执行登陆操作
if(!$cookietime) $get_cookietime = param::get_cookie('cookietime');
$_cookietime = $cookietime ? intval($cookietime) : ($get_cookietime ? $get_cookietime : 0);
$cookietime = $_cookietime ? TIME + $_cookietime : 0;
if($userinfo['groupid'] == 7) {
param::set_cookie('_username', $userinfo['username'], $cookietime);
param::set_cookie('email', $userinfo['email'], $cookietime);
} else {
$phpcms_auth_key = md5(pc_base::load_config('system', 'auth_key').$this->http_user_agent);
$phpcms_auth = sys_auth($userid."\t".$userinfo['password'], 'ENCODE', $phpcms_auth_key);
param::set_cookie('auth', $phpcms_auth, $cookietime);
param::set_cookie('_userid', $userid, $cookietime);
param::set_cookie('_username', $userinfo['username'], $cookietime);
param::set_cookie('_nickname', $userinfo['nickname'], $cookietime);
param::set_cookie('_groupid', $userinfo['groupid'], $cookietime);
param::set_cookie('cookietime', $_cookietime, $cookietime);
}
}
//如果需要邮箱认证
if($member_setting['enablemailcheck']) {
pc_base::load_sys_func('mail');
$phpcms_auth_key = md5(pc_base::load_config('system', 'auth_key').$this->http_user_agent);
$code = sys_auth($userid.'|'.md5($phpcms_auth_key), 'ENCODE', $phpcms_auth_key);
$url = APP_PATH."index.php?m=member&c=index&a=register&code=$code&verify=1";
$message = $member_setting['registerverifymessage'];
$message = str_replace(array('{click}','{url}'), array('<a href="'.$url.'">'.L('please_click').'</a>',$url), $message);
sendmail($userinfo['email'], L('reg_verify_email'), $message);
showmessage(L('operation_success'), 'index.php?m=member&c=index&a=register&t=2');
} else {
//如果不需要邮箱认证、直接登录其他应用
$synloginstr = $this->client->ps_member_synlogin($userinfo['phpssouid']);
showmessage(L('operation_success').$synloginstr, 'index.php?m=member&c=index&a=init');
}
}
} else {
showmessage(L('enable_register').L('enable_phpsso'), 'index.php?m=member&c=index&a=login');
}
showmessage(L('operation_failure'), HTTP_REFERER);
} else {
if(!pc_base::load_config('system', 'phpsso')) {
showmessage(L('enable_register').L('enable_phpsso'), 'index.php?m=member&c=index&a=login');
}
if(!empty($_GET['verify'])) {
$code = isset($_GET['code']) ? trim($_GET['code']) : showmessage(L('operation_failure'), 'index.php?m=member&c=index');
$phpcms_auth_key = md5(pc_base::load_config('system', 'auth_key').$this->http_user_agent);
$code_res = sys_auth($code, 'DECODE', $phpcms_auth_key);
$code_arr = explode('|', $code_res);
$userid = isset($code_arr[0]) ? $code_arr[0] : '';
$userid = is_numeric($userid) ? $userid : showmessage(L('operation_failure'), 'index.php?m=member&c=index');
$this->db->update(array('groupid'=>$this->_get_usergroup_bypoint()), array('userid'=>$userid));
showmessage(L('operation_success'), 'index.php?m=member&c=index');
} elseif(!empty($_GET['protocol'])) {
include template('member', 'protocol');
} else {
//过滤非当前站点会员模型
$modellist = getcache('member_model', 'commons');
foreach($modellist as $k=>$v) {
if($v['siteid']!=$siteid || $v['disabled']) {
unset($modellist[$k]);
}
}
if(empty($modellist)) {
showmessage(L('site_have_no_model').L('deny_register'), HTTP_REFERER);
}
//是否开启选择会员模型选项
if($member_setting['choosemodel']) {
$first_model = array_pop(array_reverse($modellist));
$modelid = isset($_GET['modelid']) ? intval($_GET['modelid']) : $first_model['modelid'];
if(array_key_exists($modelid, $modellist)) {
//获取会员模型表单
require CACHE_MODEL_PATH.'member_form.class.php';
$member_form = new member_form($modelid);
$this->db->set_model($modelid);
$forminfos = $forminfos_arr = $member_form->get();
//万能字段过滤
foreach($forminfos as $field=>$info) {
if($info['isomnipotent']) {
unset($forminfos[$field]);
} else {
if($info['formtype']=='omnipotent') {
foreach($forminfos_arr as $_fm=>$_fm_value) {
if($_fm_value['isomnipotent']) {
$info['form'] = str_replace('{'.$_fm.'}',$_fm_value['form'], $info['form']);
}
}
$forminfos[$field]['form'] = $info['form'];
}
}
}
$formValidator = $member_form->formValidator;
}
}
$description = $modellist[$modelid]['description'];
include template('member', 'register');
}
}
}
public function account_manage() {
$memberinfo = $this->memberinfo;
//初始化phpsso
$phpsso_api_url = $this->_init_phpsso();
//获取头像数组
$avatar = $this->client->ps_getavatar($this->memberinfo['phpssouid']);
$grouplist = getcache('grouplist');
$member_model = getcache('member_model', 'commons');
//获取用户模型数据
$this->db->set_model($this->memberinfo['modelid']);
$member_modelinfo_arr = $this->db->get_one(array('userid'=>$this->memberinfo['userid']));
$model_info = getcache('model_field_'.$this->memberinfo['modelid'], 'model');
foreach($model_info as $k=>$v) {
if($v['formtype'] == 'omnipotent') continue;
if($v['formtype'] == 'image') {
$member_modelinfo[$v['name']] = "<a href='$member_modelinfo_arr[$k]' target='_blank'><img src='$member_modelinfo_arr[$k]' height='40' widht='40' onerror=\"this.src='$phpsso_api_url/statics/images/member/nophoto.gif'\"></a>";
} elseif($v['formtype'] == 'datetime' && $v['fieldtype'] == 'int') { //如果为日期字段
$member_modelinfo[$v['name']] = format::date($member_modelinfo_arr[$k], $v['format'] == 'Y-m-d H:i:s' ? 1 : 0);
} elseif($v['formtype'] == 'images') {
$tmp = string2array($member_modelinfo_arr[$k]);
$member_modelinfo[$v['name']] = '';
if(is_array($tmp)) {
foreach ($tmp as $tv) {
$member_modelinfo[$v['name']] .= " <a href='$tv[url]' target='_blank'><img src='$tv[url]' height='40' widht='40' onerror=\"this.src='$phpsso_api_url/statics/images/member/nophoto.gif'\"></a>";
}
unset($tmp);
}
} elseif($v['formtype'] == 'box') { //box字段,获取字段名称和值的数组
$tmp = explode("\n",$v['options']);
if(is_array($tmp)) {
foreach($tmp as $boxv) {
$box_tmp_arr = explode('|', trim($boxv));
if(is_array($box_tmp_arr) && isset($box_tmp_arr[1]) && isset($box_tmp_arr[0])) {
$box_tmp[$box_tmp_arr[1]] = $box_tmp_arr[0];
$tmp_key = intval($member_modelinfo_arr[$k]);
}
}
}
if(isset($box_tmp[$tmp_key])) {
$member_modelinfo[$v['name']] = $box_tmp[$tmp_key];
} else {
$member_modelinfo[$v['name']] = $member_modelinfo_arr[$k];
}
unset($tmp, $tmp_key, $box_tmp, $box_tmp_arr);
} elseif($v['formtype'] == 'linkage') { //如果为联动菜单
$tmp = string2array($v['setting']);
$tmpid = $tmp['linkageid'];
$linkagelist = getcache($tmpid, 'linkage');
$fullname = $this->_get_linkage_fullname($member_modelinfo_arr[$k], $linkagelist);
$member_modelinfo[$v['name']] = substr($fullname, 0, -1);
unset($tmp, $tmpid, $linkagelist, $fullname);
} else {
$member_modelinfo[$v['name']] = $member_modelinfo_arr[$k];
}
}
include template('member', 'account_manage');
}
public function account_manage_avatar() {
$memberinfo = $this->memberinfo;
//初始化phpsso
$phpsso_api_url = $this->_init_phpsso();
$ps_auth_key = pc_base::load_config('system', 'phpsso_auth_key');
$auth_data = $this->client->auth_data(array('uid'=>$this->memberinfo['phpssouid'], 'ps_auth_key'=>$ps_auth_key), '', $ps_auth_key);
$upurl = base64_encode($phpsso_api_url.'/index.php?m=phpsso&c=index&a=uploadavatar&auth_data='.$auth_data);
//获取头像数组
$avatar = $this->client->ps_getavatar($this->memberinfo['phpssouid']);
include template('member', 'account_manage_avatar');
}
public function account_manage_security() {
$memberinfo = $this->memberinfo;
include template('member', 'account_manage_security');
}
public function account_manage_info() {
if(isset($_POST['dosubmit'])) {
//更新用户昵称
$nickname = isset($_POST['nickname']) && trim($_POST['nickname']) ? trim($_POST['nickname']) : '';
if($nickname) {
$this->db->update(array('nickname'=>$nickname), array('userid'=>$this->memberinfo['userid']));
if(!isset($cookietime)) {
$get_cookietime = param::get_cookie('cookietime');
}
$_cookietime = $cookietime ? intval($cookietime) : ($get_cookietime ? $get_cookietime : 0);
$cookietime = $_cookietime ? TIME + $_cookietime : 0;
param::set_cookie('_nickname', $nickname, $cookietime);
}
require_once CACHE_MODEL_PATH.'member_input.class.php';
require_once CACHE_MODEL_PATH.'member_update.class.php';
$member_input = new member_input($this->memberinfo['modelid']);
$modelinfo = $member_input->get($_POST['info']);
$this->db->set_model($this->memberinfo['modelid']);
$membermodelinfo = $this->db->get_one(array('userid'=>$this->memberinfo['userid']));
if(!empty($membermodelinfo)) {
$this->db->update($modelinfo, array('userid'=>$this->memberinfo['userid']));
} else {
$modelinfo['userid'] = $this->memberinfo['userid'];
$this->db->insert($modelinfo);
}
showmessage(L('operation_success'), HTTP_REFERER);
} else {
$memberinfo = $this->memberinfo;
//获取会员模型表单
require CACHE_MODEL_PATH.'member_form.class.php';
$member_form = new member_form($this->memberinfo['modelid']);
$this->db->set_model($this->memberinfo['modelid']);
$membermodelinfo = $this->db->get_one(array('userid'=>$this->memberinfo['userid']));
$forminfos = $forminfos_arr = $member_form->get($membermodelinfo);
//万能字段过滤
foreach($forminfos as $field=>$info) {
if($info['isomnipotent']) {
unset($forminfos[$field]);
} else {
if($info['formtype']=='omnipotent') {
foreach($forminfos_arr as $_fm=>$_fm_value) {
if($_fm_value['isomnipotent']) {
$info['form'] = str_replace('{'.$_fm.'}',$_fm_value['form'], $info['form']);
}
}
$forminfos[$field]['form'] = $info['form'];
}
}
}
$formValidator = $member_form->formValidator;
include template('member', 'account_manage_info');
}
}
public function account_manage_password() {
if(isset($_POST['dosubmit'])) {
if(!is_password($_POST['info']['password'])) {
showmessage(L('password_format_incorrect'), HTTP_REFERER);
}
if($this->memberinfo['password'] != password($_POST['info']['password'], $this->memberinfo['encrypt'])) {
showmessage(L('old_password_incorrect'), HTTP_REFERER);
}
//修改会员邮箱
if($this->memberinfo['email'] != $_POST['info']['email'] && is_email($_POST['info']['email'])) {
$email = $_POST['info']['email'];
$updateinfo['email'] = $_POST['info']['email'];
} else {
$email = '';
}
$newpassword = password($_POST['info']['newpassword'], $this->memberinfo['encrypt']);
$updateinfo['password'] = $newpassword;
$this->db->update($updateinfo, array('userid'=>$this->memberinfo['userid']));
if(pc_base::load_config('system', 'phpsso')) {
//初始化phpsso
$this->_init_phpsso();
$res = $this->client->ps_member_edit('', $email, $_POST['info']['password'], $_POST['info']['newpassword'], $this->memberinfo['phpssouid'], $this->memberinfo['encrypt']);
}
showmessage(L('operation_success'), HTTP_REFERER);
} else {
$show_validator = true;
$memberinfo = $this->memberinfo;
include template('member', 'account_manage_password');
}
}
public function account_manage_upgrade() {
$memberinfo = $this->memberinfo;
$grouplist = getcache('grouplist');
if(empty($grouplist[$memberinfo['groupid']]['allowupgrade'])) {
showmessage(L('deny_upgrade'), HTTP_REFERER);
}
if(isset($_POST['upgrade_type']) && intval($_POST['upgrade_type']) < 0) {
showmessage(L('operation_failure'), HTTP_REFERER);
}
if(isset($_POST['upgrade_date']) && intval($_POST['upgrade_date']) < 0) {
showmessage(L('operation_failure'), HTTP_REFERER);
}
if(isset($_POST['dosubmit'])) {
$groupid = isset($_POST['groupid']) ? intval($_POST['groupid']) : showmessage(L('operation_failure'), HTTP_REFERER);
$upgrade_type = isset($_POST['upgrade_type']) ? intval($_POST['upgrade_type']) : showmessage(L('operation_failure'), HTTP_REFERER);
$upgrade_date = !empty($_POST['upgrade_date']) ? intval($_POST['upgrade_date']) : showmessage(L('operation_failure'), HTTP_REFERER);
//消费类型,包年、包月、包日,价格
$typearr = array($grouplist[$groupid]['price_y'], $grouplist[$groupid]['price_m'], $grouplist[$groupid]['price_d']);
//消费类型,包年、包月、包日,时间
$typedatearr = array('366', '31', '1');
//消费的价格
$cost = $typearr[$upgrade_type]*$upgrade_date;
//购买时间
$buydate = $typedatearr[$upgrade_type]*$upgrade_date*86400;
$overduedate = $memberinfo['overduedate'] > SYS_TIME ? ($memberinfo['overduedate']+$buydate) : (SYS_TIME+$buydate);
if($memberinfo['amount'] >= $cost) {
$this->db->update(array('groupid'=>$groupid, 'overduedate'=>$overduedate, 'vip'=>1), array('userid'=>$memberinfo['userid']));
//消费记录
pc_base::load_app_class('spend','pay',0);
spend::amount($cost, L('allowupgrade'), $memberinfo['userid'], $memberinfo['username']);
showmessage(L('operation_success'), 'index.php?m=member&c=index&a=init');
} else {
showmessage(L('operation_failure'), HTTP_REFERER);
}
} else {
$groupid = isset($_GET['groupid']) ? intval($_GET['groupid']) : '';
//初始化phpsso
$phpsso_api_url = $this->_init_phpsso();
//获取头像数组
$avatar = $this->client->ps_getavatar($this->memberinfo['phpssouid']);
$memberinfo['groupname'] = $grouplist[$memberinfo[groupid]]['name'];
$memberinfo['grouppoint'] = $grouplist[$memberinfo[groupid]]['point'];
unset($grouplist[$memberinfo['groupid']]);
include template('member', 'account_manage_upgrade');
}
}
public function login() {
$this->_session_start();
//获取用户siteid
$siteid = isset($_REQUEST['siteid']) && trim($_REQUEST['siteid']) ? intval($_REQUEST['siteid']) : 1;
//定义站点id常量
if (!defined('SITEID')) {
define('SITEID', $siteid);
}
if(isset($_POST['dosubmit'])) {
if(empty($_SESSION['connectid'])) {
//判断验证码
$code = isset($_POST['code']) && trim($_POST['code']) ? trim($_POST['code']) : showmessage(L('input_code'), HTTP_REFERER);
if ($_SESSION['code'] != strtolower($code)) {
showmessage(L('code_error'), HTTP_REFERER);
}
}
$username = isset($_POST['username']) && trim($_POST['username']) ? trim($_POST['username']) : showmessage(L('username_empty'), HTTP_REFERER);
$password = isset($_POST['password']) && trim($_POST['password']) ? trim($_POST['password']) : showmessage(L('password_empty'), HTTP_REFERER);
$synloginstr = ''; //同步登陆js代码
if(pc_base::load_config('system', 'phpsso')) {
$this->_init_phpsso();
$status = $this->client->ps_member_login($username, $password);
$memberinfo = unserialize($status);
if(isset($memberinfo['uid'])) {
//查询帐号
$r = $this->db->get_one(array('phpssouid'=>$memberinfo['uid']));
if(!$r) {
//插入会员详细信息,会员不存在 插入会员
$info = array(
'phpssouid'=>$memberinfo['uid'],
'username'=>$memberinfo['username'],
'password'=>$memberinfo['password'],
'encrypt'=>$memberinfo['random'],
'email'=>$memberinfo['email'],
'regip'=>$memberinfo['regip'],
'regdate'=>$memberinfo['regdate'],
'lastip'=>$memberinfo['lastip'],
'lastdate'=>$memberinfo['lastdate'],
'groupid'=>$this->_get_usergroup_bypoint(), //会员默认组
'modelid'=>10, //普通会员
);
//如果是connect用户
if(!empty($_SESSION['connectid'])) {
$userinfo['connectid'] = $_SESSION['connectid'];
}
if(!empty($_SESSION['from'])) {
$userinfo['from'] = $_SESSION['from'];
}
unset($_SESSION['connectid'], $_SESSION['from']);
$this->db->insert($info);
unset($info);
$r = $this->db->get_one(array('phpssouid'=>$memberinfo['uid']));
}
$password = $r['password'];
$synloginstr = $this->client->ps_member_synlogin($r['phpssouid']);
} else {
if($status == -1) { //用户不存在
showmessage(L('user_not_exist'), 'index.php?m=member&c=index&a=login');
} elseif($status == -2) { //密码错误
showmessage(L('password_error'), 'index.php?m=member&c=index&a=login');
} else {
showmessage(L('login_failure'), 'index.php?m=member&c=index&a=login');
}
}
} else {
//密码错误剩余重试次数
$this->times_db = pc_base::load_model('times_model');
$rtime = $this->times_db->get_one(array('username'=>$username));
if($rtime['times'] > 4) {
$minute = 60 - floor((SYS_TIME - $rtime['logintime']) / 60);
showmessage(L('wait_1_hour', array('minute'=>$minute)));
}
//查询帐号
$r = $this->db->get_one(array('username'=>$username));
if(!$r) showmessage(L('user_not_exist'),'index.php?m=member&c=index&a=login');
//验证用户密码
$password = md5(md5(trim($password)).$r['encrypt']);
if($r['password'] != $password) {
$ip = ip();
if($rtime && $rtime['times'] < 5) {
$times = 5 - intval($rtime['times']);
$this->times_db->update(array('ip'=>$ip, 'times'=>'+=1'), array('username'=>$username));
} else {
$this->times_db->insert(array('username'=>$username, 'ip'=>$ip, 'logintime'=>SYS_TIME, 'times'=>1));
$times = 5;
}
showmessage(L('password_error', array('times'=>$times)), 'index.php?m=member&c=index&a=login', 3000);
}
$this->times_db->delete(array('username'=>$username));
}
//如果用户被锁定
if($r['islock']) {
showmessage(L('user_is_lock'));
}
$userid = $r['userid'];
$groupid = $r['groupid'];
$username = $r['username'];
$nickname = empty($r['nickname']) ? $username : $r['nickname'];
$updatearr = array('lastip'=>ip(), 'lastdate'=>SYS_TIME);
//vip过期,更新vip和会员组
if($r['overduedate'] < SYS_TIME) {
$updatearr['vip'] = 0;
}
//检查用户积分,更新新用户组,除去邮箱认证、禁止访问、游客组用户、vip用户
if($r['point'] >= 0 && !in_array($r['groupid'], array('1', '7', '8')) && empty($r[vip])) {
$check_groupid = $this->_get_usergroup_bypoint($r['point']);
if($check_groupid != $r['groupid']) {
$updatearr['groupid'] = $groupid = $check_groupid;
}
}
//如果是connect用户
if(!empty($_SESSION['connectid'])) {
$updatearr['connectid'] = $_SESSION['connectid'];
}
if(!empty($_SESSION['from'])) {
$updatearr['from'] = $_SESSION['from'];
}
unset($_SESSION['connectid'], $_SESSION['from']);
$this->db->update($updatearr, array('userid'=>$userid));
if(!isset($cookietime)) {
$get_cookietime = param::get_cookie('cookietime');
}
$_cookietime = $cookietime ? intval($cookietime) : ($get_cookietime ? $get_cookietime : 0);
$cookietime = $_cookietime ? TIME + $_cookietime : 0;
$phpcms_auth_key = md5(pc_base::load_config('system', 'auth_key').$this->http_user_agent);
$phpcms_auth = sys_auth($userid."\t".$password, 'ENCODE', $phpcms_auth_key);
param::set_cookie('auth', $phpcms_auth, $cookietime);
param::set_cookie('_userid', $userid, $cookietime);
param::set_cookie('_username', $username, $cookietime);
param::set_cookie('_groupid', $groupid, $cookietime);
param::set_cookie('_nickname', $nickname, $cookietime);
param::set_cookie('cookietime', $_cookietime, $cookietime);
$forward = isset($_POST['forward']) && !empty($_POST['forward']) ? urldecode($_POST['forward']) : 'index.php?m=member&c=index';
showmessage(L('login_success').$synloginstr, $forward);
} else {
$setting = pc_base::load_config('system');
$forward = isset($_GET['forward']) && trim($_GET['forward']) ? urlencode($_GET['forward']) : '';
if(!empty($setting['connect_enable'])) {
$snda_res = $this->_snda_get_appid();
$appid = $snda_res['appid'];
$secretkey = $snda_res['secretkey'];
$sid = md5("appArea=0appId=".$appid."service=".urlencode(APP_PATH.'index.php?m=member&c=index&a=public_snda_login&forward='.$forward).$secretkey);
$sndaurl = "https://cas.sdo.com/cas/login?gateway=true&service=".urlencode(APP_PATH.'index.php?m=member&c=index&a=public_snda_login&forward='.$forward)."&appId=".$appid."&appArea=0&sid=".$sid;
}
$siteid = isset($_REQUEST['siteid']) && trim($_REQUEST['siteid']) ? intval($_REQUEST['siteid']) : 1;
$siteinfo = siteinfo($siteid);
include template('member', 'login');
}
}
/**
*
* 获取已申请的appid和secretkey,默认appid为200037400
*/
private function _snda_get_appid() {
$snda_res = pc_base::load_config('snda', 'snda_status');
if(strstr($snda_res, '|')) {
$snda_res_arr = explode('|', $snda_res);
$appid = isset($snda_res_arr[0]) ? $snda_res_arr[0] : '';
$secretkey = isset($snda_res_arr[1]) ? $snda_res_arr[1] : '';
} else {
$appid = 200037400;
$secretkey = '';
}
return array('appid'=>$appid, 'secretkey'=>$secretkey);
}
public function logout() {
$setting = pc_base::load_config('system');
//snda退出
if($setting['snda_enable'] && param::get_cookie('_from')=='snda') {
param::set_cookie('_from', '');
$forward = isset($_GET['forward']) && trim($_GET['forward']) ? urlencode($_GET['forward']) : '';
$logouturl = 'https://cas.sdo.com/cas/logout?url='.urlencode(APP_PATH.'index.php?m=member&c=index&a=logout&forward='.$forward);
header('Location: '.$logouturl);
} else {
$synlogoutstr = ''; //同步退出js代码
if(pc_base::load_config('system', 'phpsso')) {
$this->_init_phpsso();
$synlogoutstr = $this->client->ps_member_synlogout();
}
param::set_cookie('auth', '');
param::set_cookie('_userid', '');
param::set_cookie('_username', '');
param::set_cookie('_groupid', '');
param::set_cookie('_nickname', '');
param::set_cookie('cookietime', '');
$forward = isset($_GET['forward']) && trim($_GET['forward']) ? $_GET['forward'] : 'index.php?m=member&c=index&a=login';
showmessage(L('logout_success').$synlogoutstr, $forward);
}
}
/**
* 我的收藏
*
*/
public function favorite() {
$this->favorite_db = pc_base::load_model('favorite_model');
$memberinfo = $this->memberinfo;
if(isset($_GET['id']) && trim($_GET['id'])) {
$this->favorite_db->delete(array('userid'=>$memberinfo['userid'], 'id'=>intval($_GET['id'])));
showmessage(L('operation_success'), HTTP_REFERER);
} else {
$page = isset($_GET['page']) && trim($_GET['page']) ? intval($_GET['page']) : 1;
$favoritelist = $this->favorite_db->listinfo(array('userid'=>$memberinfo['userid']), 'id DESC', $page, 10);
$pages = $this->favorite_db->pages;
include template('member', 'favorite_list');
}
}
/**
* 我的好友
*/
public function friend() {
$memberinfo = $this->memberinfo;
$this->friend_db = pc_base::load_model('friend_model');
if(isset($_GET['friendid'])) {
$this->friend_db->delete(array('userid'=>$memberinfo['userid'], 'friendid'=>intval($_GET['friendid'])));
showmessage(L('operation_success'), HTTP_REFERER);
} else {
//初始化phpsso
$phpsso_api_url = $this->_init_phpsso();
//我的好友列表userid
$page = isset($_GET['page']) ? intval($_GET['page']) : 1;
$friendids = $this->friend_db->listinfo(array('userid'=>$memberinfo['userid']), '', $page, 10);
$pages = $this->friend_db->pages;
foreach($friendids as $k=>$v) {
$friendlist[$k]['friendid'] = $v['friendid'];
$friendlist[$k]['avatar'] = $this->client->ps_getavatar($v['phpssouid']);
$friendlist[$k]['is'] = $v['is'];
}
include template('member', 'friend_list');
}
}
/**
* 积分兑换
*/
public function change_credit() {
$memberinfo = $this->memberinfo;
//加载用户模块配置
$member_setting = getcache('member_setting');
$this->_init_phpsso();
$setting = $this->client->ps_getcreditlist();
$outcredit = unserialize($setting);
$setting = $this->client->ps_getapplist();
$applist = unserialize($setting);
if(isset($_POST['dosubmit'])) {
//本系统积分兑换数
$fromvalue = intval($_POST['fromvalue']);
//本系统积分类型
$from = $_POST['from'];
$toappid_to = explode('_', $_POST['to']);
//目标系统appid
$toappid = $toappid_to[0];
//目标系统积分类型
$to = $toappid_to[1];
if($from == 1) {
if($memberinfo['point'] < $fromvalue) {
showmessage(L('need_more_point'), HTTP_REFERER);
}
} elseif($from == 2) {
if($memberinfo['amount'] < $fromvalue) {
showmessage(L('need_more_amount'), HTTP_REFERER);
}
} else {
showmessage(L('credit_setting_error'), HTTP_REFERER);
}
$status = $this->client->ps_changecredit($memberinfo['phpssouid'], $from, $toappid, $to, $fromvalue);
if($status == 1) {
if($from == 1) {
$this->db->update(array('point'=>"-=$fromvalue"), array('userid'=>$memberinfo['userid']));
} elseif($from == 2) {
$this->db->update(array('amount'=>"-=$fromvalue"), array('userid'=>$memberinfo['userid']));
}
showmessage(L('operation_success'), HTTP_REFERER);
} else {
showmessage(L('operation_failure'), HTTP_REFERER);
}
} elseif(isset($_POST['buy'])) {
if(!is_numeric($_POST['money']) || $_POST['money'] < 0) {
showmessage(L('money_error'), HTTP_REFERER);
} else {
$money = intval($_POST['money']);
}
if($memberinfo['amount'] < $money) {
showmessage(L('short_of_money'), HTTP_REFERER);
}
//此处比率读取用户配置
$point = $money*$member_setting['rmb_point_rate'];
$this->db->update(array('point'=>"+=$point"), array('userid'=>$memberinfo['userid']));
//加入消费记录,同时扣除金钱
pc_base::load_app_class('spend','pay',0);
spend::amount($money, L('buy_point'), $memberinfo['userid'], $memberinfo['username']);
showmessage(L('operation_success'), HTTP_REFERER);
} else {
$credit_list = pc_base::load_config('credit');
include template('member', 'change_credit');
}
}
//mini登陆条
public function mini() {
$_username = param::get_cookie('_username');
$_userid = param::get_cookie('_userid');
$siteid = isset($_GET['siteid']) ? intval($_GET['siteid']) : '';
//定义站点id常量
if (!defined('SITEID')) {
define('SITEID', $siteid);
}
$snda_enable = pc_base::load_config('system', 'snda_enable');
include template('member', 'mini');
}
/**
* 初始化phpsso
* about phpsso, include client and client configure
* @return string phpsso_api_url phpsso地址
*/
private function _init_phpsso() {
pc_base::load_app_class('client', '', 0);
define('APPID', pc_base::load_config('system', 'phpsso_appid'));
$phpsso_api_url = pc_base::load_config('system', 'phpsso_api_url');
$phpsso_auth_key = pc_base::load_config('system', 'phpsso_auth_key');
$this->client = new client($phpsso_api_url, $phpsso_auth_key);
return $phpsso_api_url;
}
protected function _checkname($username) {
$username = trim($username);
if ($this->db->get_one(array('username'=>$username))){
return false;
}
return true;
}
private function _session_start() {
$session_storage = 'session_'.pc_base::load_config('system','session_storage');
pc_base::load_sys_class($session_storage);
}
/*
* 通过linkageid获取名字路径
*/
protected function _get_linkage_fullname($linkageid, $linkagelist) {
$fullname = '';
if($linkagelist['data'][$linkageid]['parentid'] != 0) {
$fullname = $this->_get_linkage_fullname($linkagelist['data'][$linkageid]['parentid'], $linkagelist);
}
//所在地区名称
$return = $fullname.$linkagelist['data'][$linkageid]['name'].'>';
return $return;
}
/**
*根据积分算出用户组
* @param $point int 积分数
*/
protected function _get_usergroup_bypoint($point=0) {
$groupid = 2;
if(empty($point)) {
$member_setting = getcache('member_setting');
$point = $member_setting['defualtpoint'] ? $member_setting['defualtpoint'] : 0;
}
$grouplist = getcache('grouplist');
foreach ($grouplist as $k=>$v) {
$grouppointlist[$k] = $v['point'];
}
arsort($grouppointlist);
//如果超出用户组积分设置则为积分最高的用户组
if($point > max($grouppointlist)) {
$groupid = key($grouppointlist);
} else {
foreach ($grouppointlist as $k=>$v) {
if($point >= $v) {
$groupid = $tmp_k;
break;
}
$tmp_k = $k;
}
}
return $groupid;
}
/**
* 检查用户名
* @param string $username 用户名
* @return $status {-4:用户名禁止注册;-1:用户名已经存在 ;1:成功}
*/
public function public_checkname_ajax() {
$username = isset($_GET['username']) && trim($_GET['username']) ? trim($_GET['username']) : exit(0);
if(CHARSET != 'utf-8') {
$username = iconv('utf-8', CHARSET, $username);
$username = addslashes($username);
}
//首先判断会员审核表
$this->verify_db = pc_base::load_model('member_verify_model');
if($this->verify_db->get_one(array('username'=>$username))) {
exit('0');
}
$this->_init_phpsso();
$status = $this->client->ps_checkname($username);
if($status == -4 || $status == -1) {
exit('0');
} else {
exit('1');
}
}
/**
* 检查用户昵称
* @param string $nickname 昵称
* @return $status {0:已存在;1:成功}
*/
public function public_checknickname_ajax() {
$nickname = isset($_GET['nickname']) && trim($_GET['nickname']) ? trim($_GET['nickname']) : exit('0');
if(CHARSET != 'utf-8') {
$nickname = iconv('utf-8', CHARSET, $nickname);
$nickname = addslashes($nickname);
}
//首先判断会员审核表
$this->verify_db = pc_base::load_model('member_verify_model');
if($this->verify_db->get_one(array('nickname'=>$nickname))) {
exit('0');
}
$res = $this->db->get_one(array('nickname'=>$nickname));
if($res) {
exit('0');
} else {
exit('1');
}
}
/**
* 检查邮箱
* @param string $email
* @return $status {-1:email已经存在 ;-5:邮箱禁止注册;1:成功}
*/
public function public_checkemail_ajax() {
$this->_init_phpsso();
$email = isset($_GET['email']) && trim($_GET['email']) ? trim($_GET['email']) : exit(0);
$status = $this->client->ps_checkemail($email);
if($status == -5) { //禁止注册
exit('0');
} elseif($status == -1) { //用户名已存在,但是修改用户的时候需要判断邮箱是否是当前用户的
if(isset($_GET['phpssouid'])) { //修改用户传入phpssouid
$status = $this->client->ps_get_member_info($email, 3);
if($status) {
$status = unserialize($status); //接口返回序列化,进行判断
if (isset($status['uid']) && $status['uid'] == intval($_GET['phpssouid'])) {
exit('1');
} else {
exit('0');
}
} else {
exit('0');
}
} else {
exit('0');
}
} else {
exit('1');
}
}
public function public_sina_login() {
define('WB_AKEY', pc_base::load_config('system', 'sina_akey'));
define('WB_SKEY', pc_base::load_config('system', 'sina_skey'));
pc_base::load_app_class('weibooauth', '' ,0);
$this->_session_start();
if(isset($_GET['callback']) && trim($_GET['callback'])) {
$o = new WeiboOAuth(WB_AKEY, WB_SKEY, $_SESSION['keys']['oauth_token'], $_SESSION['keys']['oauth_token_secret']);
$_SESSION['last_key'] = $o->getAccessToken($_REQUEST['oauth_verifier']);
$c = new WeiboClient(WB_AKEY, WB_SKEY, $_SESSION['last_key']['oauth_token'], $_SESSION['last_key']['oauth_token_secret']);
//获取用户信息
$me = $c->verify_credentials();
if(CHARSET != 'utf-8') {
$me['name'] = iconv('utf-8', CHARSET, $me['name']);
$me['location'] = iconv('utf-8', CHARSET, $me['location']);
$me['description'] = iconv('utf-8', CHARSET, $me['description']);
$me['screen_name'] = iconv('utf-8', CHARSET, $me['screen_name']);
}
if(!empty($me['id'])) {
//检查connect会员是否绑定,已绑定直接登录,未绑定提示注册/绑定页面
$where = array('connectid'=>$me['id'], 'from'=>'sina');
$r = $this->db->get_one($where);
//connect用户已经绑定本站用户
if(!empty($r)) {
//读取本站用户信息,执行登录操作
$password = $r['password'];
$this->_init_phpsso();
$synloginstr = $this->client->ps_member_synlogin($r['phpssouid']);
$userid = $r['userid'];
$groupid = $r['groupid'];
$username = $r['username'];
$nickname = empty($r['nickname']) ? $username : $r['nickname'];
$this->db->update(array('lastip'=>ip(), 'lastdate'=>SYS_TIME, 'nickname'=>$me['name']), array('userid'=>$userid));
if(!$cookietime) $get_cookietime = param::get_cookie('cookietime');
$_cookietime = $cookietime ? intval($cookietime) : ($get_cookietime ? $get_cookietime : 0);
$cookietime = $_cookietime ? TIME + $_cookietime : 0;
$phpcms_auth_key = md5(pc_base::load_config('system', 'auth_key').$this->http_user_agent);
$phpcms_auth = sys_auth($userid."\t".$password, 'ENCODE', $phpcms_auth_key);
param::set_cookie('auth', $phpcms_auth, $cookietime);
param::set_cookie('_userid', $userid, $cookietime);
param::set_cookie('_username', $username, $cookietime);
param::set_cookie('_groupid', $groupid, $cookietime);
param::set_cookie('cookietime', $_cookietime, $cookietime);
param::set_cookie('_nickname', $nickname, $cookietime);
$forward = isset($_GET['forward']) && !empty($_GET['forward']) ? $_GET['forward'] : 'index.php?m=member&c=index';
showmessage(L('login_success').$synloginstr, $forward);
} else {
//弹出绑定注册页面
$_SESSION['connectid'] = $me['id'];
$_SESSION['from'] = 'sina';
$connect_username = $me['name'];
include template('member', 'connect');
}
} else {
showmessage(L('login_failure'), 'index.php?m=member&c=index&a=login');
}
} else {
$o = new WeiboOAuth(WB_AKEY, WB_SKEY);
$keys = $o->getRequestToken();
$aurl = $o->getAuthorizeURL($keys['oauth_token'] ,false , APP_PATH.'index.php?m=member&c=index&a=public_sina_login&callback=1');
$_SESSION['keys'] = $keys;
include template('member', 'connect_sina');
}
}
/**
* 盛大通行证登陆
*/
public function public_snda_login() {
define('SNDA_AKEY', pc_base::load_config('system', 'snda_akey'));
define('SNDA_SKEY', pc_base::load_config('system', 'snda_skey'));
define('SNDA_CALLBACK', urlencode(APP_PATH.'index.php?m=member&c=index&a=public_snda_login&callback=1'));
pc_base::load_app_class('OauthSDK', '' ,0);
$this->_session_start();
if(isset($_GET['callback']) && trim($_GET['callback'])) {
$o = new OauthSDK(SNDA_AKEY, SNDA_SKEY, SNDA_CALLBACK);
$code = $_REQUEST['code'];
$accesstoken = $o->getAccessToken($code);
if(is_numeric($accesstoken['sdid'])) {
$userid = $accesstoken['sdid'];
} else {
showmessage(L('login_failure'), 'index.php?m=member&c=index&a=login');
}
if(!empty($userid)) {
//检查connect会员是否绑定,已绑定直接登录,未绑定提示注册/绑定页面
$where = array('connectid'=>$userid, 'from'=>'snda');
$r = $this->db->get_one($where);
//connect用户已经绑定本站用户
if(!empty($r)) {
//读取本站用户信息,执行登录操作
$password = $r['password'];
$this->_init_phpsso();
$synloginstr = $this->client->ps_member_synlogin($r['phpssouid']);
$userid = $r['userid'];
$groupid = $r['groupid'];
$username = $r['username'];
$nickname = empty($r['nickname']) ? $username : $r['nickname'];
$this->db->update(array('lastip'=>ip(), 'lastdate'=>SYS_TIME, 'nickname'=>$me['name']), array('userid'=>$userid));
if(!$cookietime) $get_cookietime = param::get_cookie('cookietime');
$_cookietime = $cookietime ? intval($cookietime) : ($get_cookietime ? $get_cookietime : 0);
$cookietime = $_cookietime ? TIME + $_cookietime : 0;
$phpcms_auth_key = md5(pc_base::load_config('system', 'auth_key').$this->http_user_agent);
$phpcms_auth = sys_auth($userid."\t".$password, 'ENCODE', $phpcms_auth_key);
param::set_cookie('auth', $phpcms_auth, $cookietime);
param::set_cookie('_userid', $userid, $cookietime);
param::set_cookie('_username', $username, $cookietime);
param::set_cookie('_groupid', $groupid, $cookietime);
param::set_cookie('cookietime', $_cookietime, $cookietime);
param::set_cookie('_nickname', $nickname, $cookietime);
param::set_cookie('_from', 'snda');
$forward = isset($_GET['forward']) && !empty($_GET['forward']) ? $_GET['forward'] : 'index.php?m=member&c=index';
showmessage(L('login_success').$synloginstr, $forward);
} else {
//弹出绑定注册页面
$_SESSION['connectid'] = $userid;
$_SESSION['from'] = 'snda';
$connect_username = $userid;
include template('member', 'connect');
}
}
} else {
$o = new OauthSDK(SNDA_AKEY, SNDA_SKEY, SNDA_CALLBACK);
$accesstoken = $o->getSystemToken();
$aurl = $o->getAuthorizeURL();
include template('member', 'connect_snda');
}
}
/**
* QQ登录
*/
public function public_qq_login() {
define('QQ_AKEY', pc_base::load_config('system', 'qq_akey'));
define('QQ_SKEY', pc_base::load_config('system', 'qq_skey'));
pc_base::load_app_class('qqoauth', '' ,0);
$this->_session_start();
if(isset($_GET['callback']) && trim($_GET['callback'])) {
$o = new WeiboOAuth(QQ_AKEY, QQ_SKEY, $_SESSION['keys']['oauth_token'], $_SESSION['keys']['oauth_token_secret']);
$_SESSION['last_key'] = $o->getAccessToken($_REQUEST['oauth_verifier']);
if(!empty($_SESSION['last_key']['name'])) {
//检查connect会员是否绑定,已绑定直接登录,未绑定提示注册/绑定页面
$where = array('connectid'=>$_SESSION['last_key']['name'], 'from'=>'qq');
$r = $this->db->get_one($where);
//connect用户已经绑定本站用户
if(!empty($r)) {
//读取本站用户信息,执行登录操作
$password = $r['password'];
$this->_init_phpsso();
$synloginstr = $this->client->ps_member_synlogin($r['phpssouid']);
$userid = $r['userid'];
$groupid = $r['groupid'];
$username = $r['username'];
$nickname = empty($r['nickname']) ? $username : $r['nickname'];
$this->db->update(array('lastip'=>ip(), 'lastdate'=>SYS_TIME, 'nickname'=>$me['name']), array('userid'=>$userid));
if(!$cookietime) $get_cookietime = param::get_cookie('cookietime');
$_cookietime = $cookietime ? intval($cookietime) : ($get_cookietime ? $get_cookietime : 0);
$cookietime = $_cookietime ? TIME + $_cookietime : 0;
$phpcms_auth_key = md5(pc_base::load_config('system', 'auth_key').$this->http_user_agent);
$phpcms_auth = sys_auth($userid."\t".$password, 'ENCODE', $phpcms_auth_key);
param::set_cookie('auth', $phpcms_auth, $cookietime);
param::set_cookie('_userid', $userid, $cookietime);
param::set_cookie('_username', $username, $cookietime);
param::set_cookie('_groupid', $groupid, $cookietime);
param::set_cookie('cookietime', $_cookietime, $cookietime);
param::set_cookie('_nickname', $nickname, $cookietime);
param::set_cookie('_from', 'snda');
$forward = isset($_GET['forward']) && !empty($_GET['forward']) ? $_GET['forward'] : 'index.php?m=member&c=index';
showmessage(L('login_success').$synloginstr, $forward);
} else {
//弹出绑定注册页面
$_SESSION['connectid'] = $_SESSION['last_key']['name'];
$_SESSION['from'] = 'qq';
$connect_username = $_SESSION['last_key']['name'];
include template('member', 'connect');
}
} else {
showmessage(L('login_failure'), 'index.php?m=member&c=index&a=login');
}
} else {
$oauth_callback = APP_PATH.'index.php?m=member&c=index&a=public_qq_login&callback=1';
$oauth_nonce = md5(SYS_TIME);
$oauth_signature_method = 'HMAC-SHA1';
$oauth_timestamp = SYS_TIME;
$oauth_version = '1.0';
$url = "https://open.t.qq.com/cgi-bin/request_token?oauth_callback=$oauth_callback&oauth_consumer_key=".QQ_AKEY."&oauth_nonce=$oauth_nonce&oauth_signature=".QQ_SKEY."&oauth_signature_method=HMAC-SHA1&oauth_timestamp=$oauth_timestamp&oauth_version=$oauth_version";
$o = new WeiboOAuth(QQ_AKEY, QQ_SKEY);
$keys = $o->getRequestToken(array('callback'=>$oauth_callback));
$_SESSION['keys'] = $keys;
$aurl = $o->getAuthorizeURL($keys['oauth_token'] ,false , $oauth_callback);
include template('member', 'connect_qq');
}
}
/**
* 找回密码
*/
public function public_forget_password () {
$email_config = getcache('common', 'commons');
if(empty($email_config['mail_user']) || empty($email_config['mail_password'])) {
showmessage(L('email_config_empty'), HTTP_REFERER);
}
$this->_session_start();
$member_setting = getcache('member_setting');
if(isset($_POST['dosubmit'])) {
if ($_SESSION['code'] != strtolower($_POST['code'])) {
showmessage(L('code_error'), HTTP_REFERER);
}
$memberinfo = $this->db->get_one(array('email'=>$_POST['email']));
if(!empty($memberinfo['email'])) {
$email = $memberinfo['email'];
} else {
showmessage(L('email_error'), HTTP_REFERER);
}
pc_base::load_sys_func('mail');
$phpcms_auth_key = md5(pc_base::load_config('system', 'auth_key').$this->http_user_agent);
$code = sys_auth($memberinfo['userid']."\t".SYS_TIME, 'ENCODE', $phpcms_auth_key);
$url = APP_PATH."index.php?m=member&c=index&a=public_forget_password&code=$code";
$message = $member_setting['forgetpassword'];
$message = str_replace(array('{click}','{url}'), array('<a href="'.$url.'">'.L('please_click').'</a>',$url), $message);
//获取站点名称
$sitelist = getcache('sitelist', 'commons');
if(isset($sitelist[$memberinfo['siteid']]['name'])) {
$sitename = $sitelist[$memberinfo['siteid']]['name'];
} else {
$sitename = 'PHPCMS_V9_MAIL';
}
sendmail($email, L('forgetpassword'), $message, '', '', $sitename);
showmessage(L('operation_success'), 'index.php?m=member&c=index&a=login');
} elseif($_GET['code']) {
$phpcms_auth_key = md5(pc_base::load_config('system', 'auth_key').$this->http_user_agent);
$hour = date('y-m-d h', SYS_TIME);
$code = sys_auth($_GET['code'], 'DECODE', $phpcms_auth_key);
$code = explode("\t", $code);
if(is_array($code) && is_numeric($code[0]) && date('y-m-d h', SYS_TIME) == date('y-m-d h', $code[1])) {
$memberinfo = $this->db->get_one(array('userid'=>$code[0]));
if(empty($memberinfo['phpssouid'])) {
showmessage(L('operation_failure'), 'index.php?m=member&c=index&a=login');
}
$password = random(8);
$updateinfo['password'] = password($password, $memberinfo['encrypt']);
$this->db->update($updateinfo, array('userid'=>$code[0]));
if(pc_base::load_config('system', 'phpsso')) {
//初始化phpsso
$this->_init_phpsso();
$this->client->ps_member_edit('', $email, '', $password, $memberinfo['phpssouid'], $memberinfo['encrypt']);
}
showmessage(L('operation_success').L('newpassword').':'.$password);
} else {
showmessage(L('operation_failure'), 'index.php?m=member&c=index&a=login');
}
} else {
$siteid = isset($_REQUEST['siteid']) && trim($_REQUEST['siteid']) ? intval($_REQUEST['siteid']) : 1;
$siteinfo = siteinfo($siteid);
include template('member', 'forget_password');
}
}
}
?>
|
108wo
|
phpcms/modules/member/index.php
|
PHP
|
asf20
| 49,934
|
<?php
/**
* member pc标签
*
* @copyright (C) 2005-2010 PHPCMS
* @license http://www.phpcms.cn/license/
* @lastmodify 2010-8-3
*/
defined('IN_PHPCMS') or exit('No permission resources.');
class member_tag {
private $db, $favorite_db;
public function __construct() {
$this->db = pc_base::load_model('member_model');
$this->favorite_db = pc_base::load_model('favorite_model');
}
/**
* 获取收藏列表
* @param array $data 数据信息{userid:用户id;limit:读取数;order:排序字段}
* @return array 收藏列表数组
*/
public function favoritelist($data) {
$userid = intval($data['userid']);
$limit = $data['limit'];
$order = $data['order'];
$favoritelist = $this->favorite_db->select(array('userid'=>$userid), "*", $limit, $order);
return $favoritelist;
}
/**
* 读取收藏文章数
* @param array $data 数据信息{userid:用户id;limit:读取数;order:排序字段}
* @return int 收藏数
*/
public function count($data) {
$userid = intval($data['userid']);
return $this->favorite_db->count(array('userid'=>$userid));
}
public function pc_tag() {
return array(
'action'=>array('favoritelist'=>L('favorite_list', '', 'member')),
'favoritelist'=>array(
'userid'=>array('name'=>L('uid'),'htmltype'=>'input'),
),
);
}
}
?>
|
108wo
|
phpcms/modules/member/classes/member_tag.class.php
|
PHP
|
asf20
| 1,370
|
<?php
/**
* 会员缓存操作
*
*/
class member_cache {
/**
* 更新模型缓存
*/
public static function update_cache_model() {
$sitemodel_db = pc_base::load_model('sitemodel_model');
$data = $sitemodel_db->select(array('type'=>2), "*", 1000, 'sort', '', 'modelid');
setcache('member_model', $data, 'commons');
if(!defined('MODEL_PATH')) {
//模型原型存储路径
define('MODEL_PATH',PC_PATH.'modules'.DIRECTORY_SEPARATOR.'member'.DIRECTORY_SEPARATOR.'fields'.DIRECTORY_SEPARATOR);
}
if(!defined('CACHE_MODEL_PATH')) {
//模型缓存路径
define('CACHE_MODEL_PATH',PHPCMS_PATH.'caches'.DIRECTORY_SEPARATOR.'caches_model'.DIRECTORY_SEPARATOR.'caches_data'.DIRECTORY_SEPARATOR);
}
require MODEL_PATH.'fields.inc.php';
//更新内容模型类:表单生成、入库、更新、输出
$classtypes = array('form','input','update','output');
foreach($classtypes as $classtype) {
$cache_data = file_get_contents(MODEL_PATH.'member_'.$classtype.'.class.php');
$cache_data = str_replace('}?>','',$cache_data);
foreach($fields as $field=>$fieldvalue) {
if(file_exists(MODEL_PATH.$field.DIRECTORY_SEPARATOR.$classtype.'.inc.php')) {
$cache_data .= file_get_contents(MODEL_PATH.$field.DIRECTORY_SEPARATOR.$classtype.'.inc.php');
}
}
$cache_data .= "\r\n } \r\n?>";
file_put_contents(CACHE_MODEL_PATH.'member_'.$classtype.'.class.php',$cache_data);
chmod(CACHE_MODEL_PATH.'member_'.$classtype.'.class.php',0777);
}
return true;
}
}
|
108wo
|
phpcms/modules/member/classes/member_cache.class.php
|
PHP
|
asf20
| 1,554
|
<?php
/**
* 会员接口
*
*/
class member_interface {
//数据库连接
private $db;
public function __construct() {
$this->db = pc_base::load_model('member_model');
}
/**
* 获取用户信息
* @param $username 用户名
* @param $type {1:用户id;2:用户名;3:email}
* @return $mix {-1:用户不存在;userinfo:用户信息}
*/
public function get_member_info($mix, $type=1) {
$mix = safe_replace($mix);
if($type==1) {
$userinfo = $this->db->get_one(array('userid'=>$mix));
} elseif($type==2) {
$userinfo = $this->db->get_one(array('username'=>$mix));
} elseif($type==3) {
if(!$this->_is_email($mix)) {
return -4;
}
$userinfo = $this->db->get_one(array('email'=>$mix));
}
if($userinfo) {
return $userinfo;
} else {
return -1;
}
}
/**
* 将文章加入收藏夹
* @param int $cid 文章id
* @param int $userid 会员id
* @param string $title 文章标题
* @param $mix {-1:加入失败;$id:加入成功,返回收藏id}
*/
public function add_favorite($cid, $userid, $title) {
$cid = intval($cid);
$userid = intval($userid);
$title = safe_replace($title);
$this->favorite_db = pc_base::load_model('favorite_model');
$id = $this->favorite_db->insert(array('title'=>$title,'userid'=>$userid, 'cid'=>$cid, 'adddate'=>SYS_TIME), 1);
if($id) {
return $id;
} else {
return -1;
}
}
/**
* 根据uid增加用户积分
* @param int $userid 用户id
* @param int $point 点数
* @return boolean
*/
public function add_point($userid, $point) {
$point = intval($point);
return $this->db->update(array('point'=>"+=$point"), array('userid'=>$userid));
}
}
|
108wo
|
phpcms/modules/member/classes/member_interface.class.php
|
PHP
|
asf20
| 1,733
|
<?php
/*
* 新浪微博APP 接口类
* Code based on:
* Abraham Williams (abraham@abrah.am) http://abrah.am
*/
/* Load OAuth lib. You can find it at http://oauth.net */
/**
* @ignore
*/
class OAuthException extends Exception {
// pass
}
/**
* @ignore
*/
class OAuthConsumer {
public $key;
public $secret;
function __construct($key, $secret) {
$this->key = $key;
$this->secret = $secret;
}
function __toString() {
return "OAuthConsumer[key=$this->key,secret=$this->secret]";
}
}
/**
* @ignore
*/
class OAuthToken {
// access tokens and request tokens
public $key;
public $secret;
/**
* key = the token
* secret = the token secret
*/
function __construct($key, $secret) {
$this->key = $key;
$this->secret = $secret;
}
/**
* generates the basic string serialization of a token that a server
* would respond to request_token and access_token calls with
*/
function to_string() {
return "oauth_token=" .
OAuthUtil::urlencode_rfc3986($this->key) .
"&oauth_token_secret=" .
OAuthUtil::urlencode_rfc3986($this->secret);
}
function __toString() {
return $this->to_string();
}
}
/**
* @ignore
*/
class OAuthSignatureMethod {
public function check_signature(&$request, $consumer, $token, $signature) {
$built = $this->build_signature($request, $consumer, $token);
return $built == $signature;
}
}
/**
* @ignore
*/
class OAuthSignatureMethod_HMAC_SHA1 extends OAuthSignatureMethod {
function get_name() {
return "HMAC-SHA1";
}
public function build_signature($request, $consumer, $token) {
$base_string = $request->get_signature_base_string();
//print_r( $base_string );
$request->base_string = $base_string;
$key_parts = array(
$consumer->secret,
($token) ? $token->secret : ""
);
//print_r( $key_parts );
$key_parts = OAuthUtil::urlencode_rfc3986($key_parts);
$key = implode('&', $key_parts);
return base64_encode(hash_hmac('sha1', $base_string, $key, true));
}
}
/**
* @ignore
*/
class OAuthSignatureMethod_PLAINTEXT extends OAuthSignatureMethod {
public function get_name() {
return "PLAINTEXT";
}
public function build_signature($request, $consumer, $token) {
$sig = array(
OAuthUtil::urlencode_rfc3986($consumer->secret)
);
if ($token) {
array_push($sig, OAuthUtil::urlencode_rfc3986($token->secret));
} else {
array_push($sig, '');
}
$raw = implode("&", $sig);
// for debug purposes
$request->base_string = $raw;
return OAuthUtil::urlencode_rfc3986($raw);
}
}
/**
* @ignore
*/
class OAuthSignatureMethod_RSA_SHA1 extends OAuthSignatureMethod {
public function get_name() {
return "RSA-SHA1";
}
protected function fetch_public_cert(&$request) {
// not implemented yet, ideas are:
// (1) do a lookup in a table of trusted certs keyed off of consumer
// (2) fetch via http using a url provided by the requester
// (3) some sort of specific discovery code based on request
//
// either way should return a string representation of the certificate
throw Exception("fetch_public_cert not implemented");
}
protected function fetch_private_cert(&$request) {
// not implemented yet, ideas are:
// (1) do a lookup in a table of trusted certs keyed off of consumer
//
// either way should return a string representation of the certificate
throw Exception("fetch_private_cert not implemented");
}
public function build_signature(&$request, $consumer, $token) {
$base_string = $request->get_signature_base_string();
$request->base_string = $base_string;
// Fetch the private key cert based on the request
$cert = $this->fetch_private_cert($request);
// Pull the private key ID from the certificate
$privatekeyid = openssl_get_privatekey($cert);
// Sign using the key
$ok = openssl_sign($base_string, $signature, $privatekeyid);
// Release the key resource
openssl_free_key($privatekeyid);
return base64_encode($signature);
}
public function check_signature(&$request, $consumer, $token, $signature) {
$decoded_sig = base64_decode($signature);
$base_string = $request->get_signature_base_string();
// Fetch the public key cert based on the request
$cert = $this->fetch_public_cert($request);
// Pull the public key ID from the certificate
$publickeyid = openssl_get_publickey($cert);
// Check the computed signature against the one passed in the query
$ok = openssl_verify($base_string, $decoded_sig, $publickeyid);
// Release the key resource
openssl_free_key($publickeyid);
return $ok == 1;
}
}
/**
* @ignore
*/
class OAuthRequest {
private $parameters;
private $http_method;
private $http_url;
// for debug purposes
public $base_string;
public static $version = '1.0a';
public static $POST_INPUT = 'php://input';
function __construct($http_method, $http_url, $parameters=NULL) {
@$parameters or $parameters = array();
$this->parameters = $parameters;
$this->http_method = $http_method;
$this->http_url = $http_url;
}
/**
* attempt to build up a request from what was passed to the server
*/
public static function from_request($http_method=NULL, $http_url=NULL, $parameters=NULL) {
$scheme = (!isset($_SERVER['HTTPS']) || $_SERVER['HTTPS'] != "on")
? 'http'
: 'https';
@$http_url or $http_url = $scheme .
'://' . $_SERVER['HTTP_HOST'] .
':' .
$_SERVER['SERVER_PORT'] .
$_SERVER['REQUEST_URI'];
@$http_method or $http_method = $_SERVER['REQUEST_METHOD'];
// We weren't handed any parameters, so let's find the ones relevant to
// this request.
// If you run XML-RPC or similar you should use this to provide your own
// parsed parameter-list
if (!$parameters) {
// Find request headers
$request_headers = OAuthUtil::get_headers();
// Parse the query-string to find GET parameters
$parameters = OAuthUtil::parse_parameters($_SERVER['QUERY_STRING']);
// It's a POST request of the proper content-type, so parse POST
// parameters and add those overriding any duplicates from GET
if ($http_method == "POST"
&& @strstr($request_headers["Content-Type"],
"application/x-www-form-urlencoded")
) {
$post_data = OAuthUtil::parse_parameters(
file_get_contents(self::$POST_INPUT)
);
$parameters = array_merge($parameters, $post_data);
}
// We have a Authorization-header with OAuth data. Parse the header
// and add those overriding any duplicates from GET or POST
if (@substr($request_headers['Authorization'], 0, 6) == "OAuth ") {
$header_parameters = OAuthUtil::split_header(
$request_headers['Authorization']
);
$parameters = array_merge($parameters, $header_parameters);
}
}
return new OAuthRequest($http_method, $http_url, $parameters);
}
/**
* pretty much a helper function to set up the request
*/
public static function from_consumer_and_token($consumer, $token, $http_method, $http_url, $parameters=NULL) {
@$parameters or $parameters = array();
$defaults = array("oauth_version" => OAuthRequest::$version,
"oauth_nonce" => OAuthRequest::generate_nonce(),
"oauth_timestamp" => OAuthRequest::generate_timestamp(),
"oauth_consumer_key" => $consumer->key);
if ($token)
$defaults['oauth_token'] = $token->key;
$parameters = array_merge($defaults, $parameters);
return new OAuthRequest($http_method, $http_url, $parameters);
}
public function set_parameter($name, $value, $allow_duplicates = true) {
if ($allow_duplicates && isset($this->parameters[$name])) {
// We have already added parameter(s) with this name, so add to the list
if (is_scalar($this->parameters[$name])) {
// This is the first duplicate, so transform scalar (string)
// into an array so we can add the duplicates
$this->parameters[$name] = array($this->parameters[$name]);
}
$this->parameters[$name][] = $value;
} else {
$this->parameters[$name] = $value;
}
}
public function get_parameter($name) {
return isset($this->parameters[$name]) ? $this->parameters[$name] : null;
}
public function get_parameters() {
return $this->parameters;
}
public function unset_parameter($name) {
unset($this->parameters[$name]);
}
/**
* The request parameters, sorted and concatenated into a normalized string.
* @return string
*/
public function get_signable_parameters() {
// Grab all parameters
$params = $this->parameters;
// remove pic
if (isset($params['pic'])) {
unset($params['pic']);
}
if (isset($params['image']))
{
unset($params['image']);
}
// Remove oauth_signature if present
// Ref: Spec: 9.1.1 ("The oauth_signature parameter MUST be excluded.")
if (isset($params['oauth_signature'])) {
unset($params['oauth_signature']);
}
return OAuthUtil::build_http_query($params);
}
/**
* Returns the base string of this request
*
* The base string defined as the method, the url
* and the parameters (normalized), each urlencoded
* and the concated with &.
*/
public function get_signature_base_string() {
$parts = array(
$this->get_normalized_http_method(),
$this->get_normalized_http_url(),
$this->get_signable_parameters()
);
//print_r( $parts );
$parts = OAuthUtil::urlencode_rfc3986($parts);
return implode('&', $parts);
}
/**
* just uppercases the http method
*/
public function get_normalized_http_method() {
return strtoupper($this->http_method);
}
/**
* parses the url and rebuilds it to be
* scheme://host/path
*/
public function get_normalized_http_url() {
$parts = parse_url($this->http_url);
$port = @$parts['port'];
$scheme = $parts['scheme'];
$host = $parts['host'];
$path = @$parts['path'];
$port or $port = ($scheme == 'https') ? '443' : '80';
if (($scheme == 'https' && $port != '443')
|| ($scheme == 'http' && $port != '80')) {
$host = "$host:$port";
}
return "$scheme://$host$path";
}
/**
* builds a url usable for a GET request
*/
public function to_url() {
$post_data = $this->to_postdata();
$out = $this->get_normalized_http_url();
if ($post_data) {
$out .= '?'.$post_data;
}
return $out;
}
/**
* builds the data one would send in a POST request
*/
public function to_postdata( $multi = false ) {
//echo "multi=" . $multi . '`';
if( $multi )
return OAuthUtil::build_http_query_multi($this->parameters);
else
return OAuthUtil::build_http_query($this->parameters);
}
/**
* builds the Authorization: header
*/
public function to_header() {
$out ='Authorization: OAuth realm=""';
$total = array();
foreach ($this->parameters as $k => $v) {
if (substr($k, 0, 5) != "oauth") continue;
if (is_array($v)) {
throw new OAuthException('Arrays not supported in headers');
}
$out .= ',' .
OAuthUtil::urlencode_rfc3986($k) .
'="' .
OAuthUtil::urlencode_rfc3986($v) .
'"';
}
return $out;
}
public function __toString() {
return $this->to_url();
}
public function sign_request($signature_method, $consumer, $token) {
$this->set_parameter(
"oauth_signature_method",
$signature_method->get_name(),
false
);
$signature = $this->build_signature($signature_method, $consumer, $token);
//echo "sign=" . $signature;
$this->set_parameter("oauth_signature", $signature, false);
}
public function build_signature($signature_method, $consumer, $token) {
$signature = $signature_method->build_signature($this, $consumer, $token);
return $signature;
}
/**
* util function: current timestamp
*/
private static function generate_timestamp() {
//return 1273566716;
//echo date("y-m-d H:i:s");
return time();
}
/**
* util function: current nonce
*/
private static function generate_nonce() {
//return '462d316f6f40c40a9e0eef1b009f37fa';
$mt = microtime();
$rand = mt_rand();
return md5($mt . $rand); // md5s look nicer than numbers
}
}
/**
* @ignore
*/
class OAuthServer {
protected $timestamp_threshold = 300; // in seconds, five minutes
protected $version = 1.0; // hi blaine
protected $signature_methods = array();
protected $data_store;
function __construct($data_store) {
$this->data_store = $data_store;
}
public function add_signature_method($signature_method) {
$this->signature_methods[$signature_method->get_name()] =
$signature_method;
}
// high level functions
/**
* process a request_token request
* returns the request token on success
*/
public function fetch_request_token(&$request) {
$this->get_version($request);
$consumer = $this->get_consumer($request);
// no token required for the initial token request
$token = NULL;
$this->check_signature($request, $consumer, $token);
$new_token = $this->data_store->new_request_token($consumer);
return $new_token;
}
/**
* process an access_token request
* returns the access token on success
*/
public function fetch_access_token(&$request) {
$this->get_version($request);
$consumer = $this->get_consumer($request);
// requires authorized request token
$token = $this->get_token($request, $consumer, "request");
$this->check_signature($request, $consumer, $token);
$new_token = $this->data_store->new_access_token($token, $consumer);
return $new_token;
}
/**
* verify an api call, checks all the parameters
*/
public function verify_request(&$request) {
$this->get_version($request);
$consumer = $this->get_consumer($request);
$token = $this->get_token($request, $consumer, "access");
$this->check_signature($request, $consumer, $token);
return array($consumer, $token);
}
// Internals from here
/**
* version 1
*/
private function get_version(&$request) {
$version = $request->get_parameter("oauth_version");
if (!$version) {
$version = 1.0;
}
if ($version && $version != $this->version) {
throw new OAuthException("OAuth version '$version' not supported");
}
return $version;
}
/**
* figure out the signature with some defaults
*/
private function get_signature_method(&$request) {
$signature_method =
@$request->get_parameter("oauth_signature_method");
if (!$signature_method) {
$signature_method = "PLAINTEXT";
}
if (!in_array($signature_method,
array_keys($this->signature_methods))) {
throw new OAuthException(
"Signature method '$signature_method' not supported " .
"try one of the following: " .
implode(", ", array_keys($this->signature_methods))
);
}
return $this->signature_methods[$signature_method];
}
/**
* try to find the consumer for the provided request's consumer key
*/
private function get_consumer(&$request) {
$consumer_key = @$request->get_parameter("oauth_consumer_key");
if (!$consumer_key) {
throw new OAuthException("Invalid consumer key");
}
$consumer = $this->data_store->lookup_consumer($consumer_key);
if (!$consumer) {
throw new OAuthException("Invalid consumer");
}
return $consumer;
}
/**
* try to find the token for the provided request's token key
*/
private function get_token(&$request, $consumer, $token_type="access") {
$token_field = @$request->get_parameter('oauth_token');
$token = $this->data_store->lookup_token(
$consumer, $token_type, $token_field
);
if (!$token) {
throw new OAuthException("Invalid $token_type token: $token_field");
}
return $token;
}
/**
* all-in-one function to check the signature on a request
* should guess the signature method appropriately
*/
private function check_signature(&$request, $consumer, $token) {
// this should probably be in a different method
$timestamp = @$request->get_parameter('oauth_timestamp');
$nonce = @$request->get_parameter('oauth_nonce');
$this->check_timestamp($timestamp);
$this->check_nonce($consumer, $token, $nonce, $timestamp);
$signature_method = $this->get_signature_method($request);
$signature = $request->get_parameter('oauth_signature');
$valid_sig = $signature_method->check_signature(
$request,
$consumer,
$token,
$signature
);
if (!$valid_sig) {
throw new OAuthException("Invalid signature");
}
}
/**
* check that the timestamp is new enough
*/
private function check_timestamp($timestamp) {
// verify that timestamp is recentish
$now = time();
if ($now - $timestamp > $this->timestamp_threshold) {
throw new OAuthException(
"Expired timestamp, yours $timestamp, ours $now"
);
}
}
/**
* check that the nonce is not repeated
*/
private function check_nonce($consumer, $token, $nonce, $timestamp) {
// verify that the nonce is uniqueish
$found = $this->data_store->lookup_nonce(
$consumer,
$token,
$nonce,
$timestamp
);
if ($found) {
throw new OAuthException("Nonce already used: $nonce");
}
}
}
/**
* @ignore
*/
class OAuthDataStore {
function lookup_consumer($consumer_key) {
// implement me
}
function lookup_token($consumer, $token_type, $token) {
// implement me
}
function lookup_nonce($consumer, $token, $nonce, $timestamp) {
// implement me
}
function new_request_token($consumer) {
// return a new token attached to this consumer
}
function new_access_token($token, $consumer) {
// return a new access token attached to this consumer
// for the user associated with this token if the request token
// is authorized
// should also invalidate the request token
}
}
/**
* @ignore
*/
class OAuthUtil {
public static $boundary = '';
public static function urlencode_rfc3986($input) {
if (is_array($input)) {
return array_map(array('OAuthUtil', 'urlencode_rfc3986'), $input);
} else if (is_scalar($input)) {
return str_replace(
'+',
' ',
str_replace('%7E', '~', rawurlencode($input))
);
} else {
return '';
}
}
// This decode function isn't taking into consideration the above
// modifications to the encoding process. However, this method doesn't
// seem to be used anywhere so leaving it as is.
public static function urldecode_rfc3986($string) {
return urldecode($string);
}
// Utility function for turning the Authorization: header into
// parameters, has to do some unescaping
// Can filter out any non-oauth parameters if needed (default behaviour)
public static function split_header($header, $only_allow_oauth_parameters = true) {
$pattern = '/(([-_a-z]*)=("([^"]*)"|([^,]*)),?)/';
$offset = 0;
$params = array();
while (preg_match($pattern, $header, $matches, PREG_OFFSET_CAPTURE, $offset) > 0) {
$match = $matches[0];
$header_name = $matches[2][0];
$header_content = (isset($matches[5])) ? $matches[5][0] : $matches[4][0];
if (preg_match('/^oauth_/', $header_name) || !$only_allow_oauth_parameters) {
$params[$header_name] = OAuthUtil::urldecode_rfc3986($header_content);
}
$offset = $match[1] + strlen($match[0]);
}
if (isset($params['realm'])) {
unset($params['realm']);
}
return $params;
}
// helper to try to sort out headers for people who aren't running apache
public static function get_headers() {
if (function_exists('apache_request_headers')) {
// we need this to get the actual Authorization: header
// because apache tends to tell us it doesn't exist
return apache_request_headers();
}
// otherwise we don't have apache and are just going to have to hope
// that $_SERVER actually contains what we need
$out = array();
foreach ($_SERVER as $key => $value) {
if (substr($key, 0, 5) == "HTTP_") {
// this is chaos, basically it is just there to capitalize the first
// letter of every word that is not an initial HTTP and strip HTTP
// code from przemek
$key = str_replace(
" ",
"-",
ucwords(strtolower(str_replace("_", " ", substr($key, 5))))
);
$out[$key] = $value;
}
}
return $out;
}
// This function takes a input like a=b&a=c&d=e and returns the parsed
// parameters like this
// array('a' => array('b','c'), 'd' => 'e')
public static function parse_parameters( $input ) {
if (!isset($input) || !$input) return array();
$pairs = explode('&', $input);
$parsed_parameters = array();
foreach ($pairs as $pair) {
$split = explode('=', $pair, 2);
$parameter = OAuthUtil::urldecode_rfc3986($split[0]);
$value = isset($split[1]) ? OAuthUtil::urldecode_rfc3986($split[1]) : '';
if (isset($parsed_parameters[$parameter])) {
// We have already recieved parameter(s) with this name, so add to the list
// of parameters with this name
if (is_scalar($parsed_parameters[$parameter])) {
// This is the first duplicate, so transform scalar (string) into an array
// so we can add the duplicates
$parsed_parameters[$parameter] = array($parsed_parameters[$parameter]);
}
$parsed_parameters[$parameter][] = $value;
} else {
$parsed_parameters[$parameter] = $value;
}
}
return $parsed_parameters;
}
public static function build_http_query_multi($params) {
if (!$params) return '';
//print_r( $params );
//return null;
// Urlencode both keys and values
$keys = array_keys($params);
$values = array_values($params);
//$keys = OAuthUtil::urlencode_rfc3986(array_keys($params));
//$values = OAuthUtil::urlencode_rfc3986(array_values($params));
$params = array_combine($keys, $values);
// Parameters are sorted by name, using lexicographical byte value ordering.
// Ref: Spec: 9.1.1 (1)
uksort($params, 'strcmp');
$pairs = array();
self::$boundary = $boundary = uniqid('------------------');
$MPboundary = '--'.$boundary;
$endMPboundary = $MPboundary. '--';
$multipartbody = '';
foreach ($params as $parameter => $value) {
//if( $parameter == 'pic' && $value{0} == '@' )
if( in_array($parameter,array("pic","image")) && $value{0} == '@' )
{
$url = ltrim( $value , '@' );
$content = file_get_contents( $url );
$filename = reset( explode( '?' , basename( $url ) ));
$mime = self::get_image_mime($url);
$multipartbody .= $MPboundary . "\r\n";
$multipartbody .= 'Content-Disposition: form-data; name="' . $parameter . '"; filename="' . $filename . '"'. "\r\n";
$multipartbody .= 'Content-Type: '. $mime . "\r\n\r\n";
$multipartbody .= $content. "\r\n";
}
else
{
$multipartbody .= $MPboundary . "\r\n";
$multipartbody .= 'content-disposition: form-data; name="'.$parameter."\"\r\n\r\n";
$multipartbody .= $value."\r\n";
}
}
$multipartbody .= $endMPboundary;
// For each parameter, the name is separated from the corresponding value by an '=' character (ASCII code 61)
// Each name-value pair is separated by an '&' character (ASCII code 38)
// echo $multipartbody;
return $multipartbody;
}
public static function build_http_query($params) {
if (!$params) return '';
// Urlencode both keys and values
$keys = OAuthUtil::urlencode_rfc3986(array_keys($params));
$values = OAuthUtil::urlencode_rfc3986(array_values($params));
$params = array_combine($keys, $values);
// Parameters are sorted by name, using lexicographical byte value ordering.
// Ref: Spec: 9.1.1 (1)
uksort($params, 'strcmp');
$pairs = array();
foreach ($params as $parameter => $value) {
if (is_array($value)) {
// If two or more parameters share the same name, they are sorted by their value
// Ref: Spec: 9.1.1 (1)
natsort($value);
foreach ($value as $duplicate_value) {
$pairs[] = $parameter . '=' . $duplicate_value;
}
} else {
$pairs[] = $parameter . '=' . $value;
}
}
// For each parameter, the name is separated from the corresponding value by an '=' character (ASCII code 61)
// Each name-value pair is separated by an '&' character (ASCII code 38)
return implode('&', $pairs);
}
public static function get_image_mime( $file )
{
$ext = strtolower(pathinfo( $file , PATHINFO_EXTENSION ));
switch( $ext )
{
case 'jpg':
case 'jpeg':
$mime = 'image/jpg';
break;
case 'png';
$mime = 'image/png';
break;
case 'gif';
default:
$mime = 'image/gif';
break;
}
return $mime;
}
}
/**
* 新浪微博操作类
*
* @package sae
* @author Easy Chen
* @version 1.0
*/
class WeiboClient
{
/**
* 构造函数
*
* @access public
* @param mixed $akey 微博开放平台应用APP KEY
* @param mixed $skey 微博开放平台应用APP SECRET
* @param mixed $accecss_token OAuth认证返回的token
* @param mixed $accecss_token_secret OAuth认证返回的token secret
* @return void
*/
function __construct( $akey , $skey , $accecss_token , $accecss_token_secret )
{
$this->oauth = new WeiboOAuth( $akey , $skey , $accecss_token , $accecss_token_secret );
}
/**
* 最新公共微博
*
* @access public
* @return array
*/
function public_timeline()
{
return $this->oauth->get('http://api.t.sina.com.cn/statuses/public_timeline.json');
}
/**
* 最新关注人微博
*
* @access public
* @return array
*/
function friends_timeline()
{
return $this->home_timeline();
}
/**
* 最新关注人微博
*
* @access public
* @return array
*/
function home_timeline()
{
return $this->oauth->get('http://api.t.sina.com.cn/statuses/home_timeline.json');
}
/**
* 最新 @用户的
*
* @access public
* @param int $page 返回结果的页序号。
* @param int $count 每次返回的最大记录数(即页面大小),不大于200,默认为20。
* @return array
*/
function mentions( $page = 1 , $count = 20 )
{
return $this->request_with_pager( 'http://api.t.sina.com.cn/statuses/mentions.json' , $page , $count );
}
/**
* 发表微博
*
* @access public
* @param mixed $text 要更新的微博信息。
* @return array
*/
function update( $text )
{
// http://api.t.sina.com.cn/statuses/update.json
$param = array();
$param['status'] = $text;
return $this->oauth->post( 'http://api.t.sina.com.cn/statuses/update.json' , $param );
}
/**
* 发表图片微博
*
* @access public
* @param string $text 要更新的微博信息。
* @param string $text 要发布的图片路径,支持url。[只支持png/jpg/gif三种格式,增加格式请修改get_image_mime方法]
* @return array
*/
function upload( $text , $pic_path )
{
// http://api.t.sina.com.cn/statuses/update.json
$param = array();
$param['status'] = $text;
$param['pic'] = '@'.$pic_path;
return $this->oauth->post( 'http://api.t.sina.com.cn/statuses/upload.json' , $param , true );
}
/**
* 获取单条微博
*
* @access public
* @param mixed $sid 要获取已发表的微博ID
* @return array
*/
function show_status( $sid )
{
return $this->oauth->get( 'http://api.t.sina.com.cn/statuses/show/' . $sid . '.json' );
}
/**
* 删除微博
*
* @access public
* @param mixed $sid 要删除的微博ID
* @return array
*/
function delete( $sid )
{
return $this->destroy( $sid );
}
/**
* 删除微博
*
* @access public
* @param mixed $sid 要删除的微博ID
* @return array
*/
function destroy( $sid )
{
return $this->oauth->post( 'http://api.t.sina.com.cn/statuses/destroy/' . $sid . '.json' );
}
/**
* 个人资料
*
* @access public
* @param mixed $uid_or_name 用户UID或微博昵称。
* @return array
*/
function show_user( $uid_or_name = null )
{
return $this->request_with_uid( 'http://api.t.sina.com.cn/users/show.json' , $uid_or_name );
}
/**
* 关注人列表
*
* @access public
* @param bool $cursor 单页只能包含100个关注列表,为了获取更多则cursor默认从-1开始,通过增加或减少cursor来获取更多的关注列表
* @param bool $count 每次返回的最大记录数(即页面大小),不大于200,默认返回20
* @param mixed $uid_or_name 要获取的 UID或微博昵称
* @return array
*/
function friends( $cursor = false , $count = false , $uid_or_name = null )
{
return $this->request_with_uid( 'http://api.t.sina.com.cn/statuses/friends.json' , $uid_or_name , false , $count , $cursor );
}
/**
* 粉丝列表
*
* @access public
* @param bool $cursor 单页只能包含100个粉丝列表,为了获取更多则cursor默认从-1开始,通过增加或减少cursor来获取更多的粉丝列表
* @param bool $count 每次返回的最大记录数(即页面大小),不大于200,默认返回20。
* @param mixed $uid_or_name 要获取的 UID或微博昵称
* @return array
*/
function followers( $cursor = false , $count = false , $uid_or_name = null )
{
return $this->request_with_uid( 'http://api.t.sina.com.cn/statuses/followers.json' , $uid_or_name , false , $count , $cursor );
}
/**
* 关注一个用户
*
* @access public
* @param mixed $uid_or_name 要关注的用户UID或微博昵称
* @return array
*/
function follow( $uid_or_name )
{
return $this->request_with_uid( 'http://api.t.sina.com.cn/friendships/create.json' , $uid_or_name , false , false , false , true );
}
/**
* 取消关注某用户
*
* @access public
* @param mixed $uid_or_name 要取消关注的用户UID或微博昵称
* @return array
*/
function unfollow( $uid_or_name )
{
return $this->request_with_uid( 'http://api.t.sina.com.cn/friendships/destroy.json' , $uid_or_name , false , false , false , true);
}
/**
* 返回两个用户关系的详细情况
*
* @access public
* @param mixed $uid_or_name 要判断的用户UID
* @return array
*/
function is_followed( $uid_or_name )
{
$param = array();
if( is_numeric( $uid_or_name ) ) $param['target_id'] = $uid_or_name;
else $param['target_screen_name'] = $uid_or_name;
return $this->oauth->get( 'http://api.t.sina.com.cn/friendships/show.json' , $param );
}
/**
* 用户发表微博列表
*
* @access public
* @param int $page 页码
* @param int $count 每次返回的最大记录数,最多返回200条,默认20。
* @param mixed $uid_or_name 指定用户UID或微博昵称
* @return array
*/
function user_timeline( $page = 1 , $count = 20 , $uid_or_name = null )
{
if( !is_numeric( $page ) )
return $this->request_with_uid( 'http://api.t.sina.com.cn/statuses/user_timeline.json' , $page );
else
return $this->request_with_uid( 'http://api.t.sina.com.cn/statuses/user_timeline.json' , $uid_or_name , $page , $count );
}
/**
* 获取私信列表
*
* @access public
* @param int $page 页码
* @param int $count 每次返回的最大记录数,最多返回200条,默认20。
* @return array
*/
function list_dm( $page = 1 , $count = 20 )
{
return $this->request_with_pager( 'http://api.t.sina.com.cn/direct_messages.json' , $page , $count );
}
/**
* 发送的私信列表
*
* @access public
* @param int $page 页码
* @param int $count 每次返回的最大记录数,最多返回200条,默认20。
* @return array
*/
function list_dm_sent( $page = 1 , $count = 20 )
{
return $this->request_with_pager( 'http://api.t.sina.com.cn/direct_messages/sent.json' , $page , $count );
}
/**
* 发送私信
*
* @access public
* @param mixed $uid_or_name UID或微博昵称
* @param mixed $text 要发生的消息内容,文本大小必须小于300个汉字。
* @return array
*/
function send_dm( $uid_or_name , $text )
{
$param = array();
$param['text'] = $text;
if( is_numeric( $uid_or_name ) ) $param['user_id'] = $uid_or_name;
else $param['screen_name'] = $uid_or_name;
return $this->oauth->post( 'http://api.t.sina.com.cn/direct_messages/new.json' , $param );
}
/**
* 删除一条私信
*
* @access public
* @param mixed $did 要删除的私信主键ID
* @return array
*/
function delete_dm( $did )
{
return $this->oauth->post( 'http://api.t.sina.com.cn/direct_messages/destroy/' . $did . '.json' );
}
/**
* 转发一条微博信息。
*
* @access public
* @param mixed $sid 转发的微博ID
* @param bool $text 添加的转发信息。
* @return array
*/
function repost( $sid , $text = false )
{
$param = array();
$param['id'] = $sid;
if( $text ) $param['status'] = $text;
return $this->oauth->post( 'http://api.t.sina.com.cn/statuses/repost.json' , $param );
}
/**
* 对一条微博信息进行评论
*
* @access public
* @param mixed $sid 要评论的微博id
* @param mixed $text 评论内容
* @param bool $cid 要评论的评论id
* @return array
*/
function send_comment( $sid , $text , $cid = false )
{
$param = array();
$param['id'] = $sid;
$param['comment'] = $text;
if( $cid ) $param['cid '] = $cid;
return $this->oauth->post( 'http://api.t.sina.com.cn/statuses/comment.json' , $param );
}
/**
* 发出的评论
*
* @access public
* @param int $page 页码
* @param int $count 每次返回的最大记录数,最多返回200条,默认20。
* @return array
*/
function comments_by_me( $page = 1 , $count = 20 )
{
return $this->request_with_pager( 'http://api.t.sina.com.cn/statuses/comments_by_me.json' , $page , $count );
}
/**
* 最新评论(按时间)
*
* @access public
* @param int $page 页码
* @param int $count 每次返回的最大记录数,最多返回200条,默认20。
* @return array
*/
function comments_timeline( $page = 1 , $count = 20 )
{
return $this->request_with_pager( 'http://api.t.sina.com.cn/statuses/comments_timeline.json' , $page , $count );
}
/**
* 单条评论列表(按微博)
*
* @access public
* @param mixed $sid 指定的微博ID
* @param int $page 页码
* @param int $count 每次返回的最大记录数,最多返回200条,默认20。
* @return array
*/
function get_comments_by_sid( $sid , $page = 1 , $count = 20 )
{
$param = array();
$param['id'] = $sid;
if( $page ) $param['page'] = $page;
if( $count ) $param['count'] = $count;
return $this->oauth->get('http://api.t.sina.com.cn/statuses/comments.json' , $param );
}
/**
* 批量统计微博的评论数,转发数,一次请求最多获取100个。
*
* @access public
* @param mixed $sids 微博ID号列表,用逗号隔开
* @return array
*/
function get_count_info_by_ids( $sids )
{
$param = array();
$param['ids'] = $sids;
return $this->oauth->get( 'http://api.t.sina.com.cn/statuses/counts.json' , $param );
}
/**
* 对一条微博评论信息进行回复。
*
* @access public
* @param mixed $sid 微博id
* @param mixed $text 评论内容。
* @param mixed $cid 评论id
* @return array
*/
function reply( $sid , $text , $cid )
{
$param = array();
$param['id'] = $sid;
$param['comment'] = $text;
$param['cid '] = $cid;
return $this->oauth->post( 'http://api.t.sina.com.cn/statuses/reply.json' , $param );
}
/**
* 返回用户的发布的最近20条收藏信息,和用户收藏页面返回内容是一致的。
*
* @access public
* @param bool $page 返回结果的页序号。
* @return array
*/
function get_favorites( $page = false )
{
$param = array();
if( $page ) $param['page'] = $page;
return $this->oauth->get( 'http://api.t.sina.com.cn/favorites.json' , $param );
}
/**
* 收藏一条微博信息
*
* @access public
* @param mixed $sid 收藏的微博id
* @return array
*/
function add_to_favorites( $sid )
{
$param = array();
$param['id'] = $sid;
return $this->oauth->post( 'http://api.t.sina.com.cn/favorites/create.json' , $param );
}
/**
* 删除微博收藏。
*
* @access public
* @param mixed $sid 要删除的收藏微博信息ID.
* @return array
*/
function remove_from_favorites( $sid )
{
return $this->oauth->post( 'http://api.t.sina.com.cn/favorites/destroy/' . $sid . '.json' );
}
function verify_credentials()
{
return $this->oauth->get( 'http://api.t.sina.com.cn/account/verify_credentials.json' );
}
function update_avatar( $pic_path )
{
$param = array();
$param['image'] = "@".$pic_path;
return $this->oauth->post( 'http://api.t.sina.com.cn/account/update_profile_image.json' , $param , true );
}
// =========================================
/**
* @ignore
*/
protected function request_with_pager( $url , $page = false , $count = false )
{
$param = array();
if( $page ) $param['page'] = $page;
if( $count ) $param['count'] = $count;
return $this->oauth->get($url , $param );
}
/**
* @ignore
*/
protected function request_with_uid( $url , $uid_or_name , $page = false , $count = false , $cursor = false , $post = false )
{
$param = array();
if( $page ) $param['page'] = $page;
if( $count ) $param['count'] = $count;
if( $cursor )$param['cursor'] = $cursor;
if( $post ) $method = 'post';
else $method = 'get';
if( is_numeric( $uid_or_name ) )
{
$param['user_id'] = $uid_or_name;
return $this->oauth->$method($url , $param );
}elseif( $uid_or_name !== null )
{
$param['screen_name'] = $uid_or_name;
return $this->oauth->$method($url , $param );
}
else
{
return $this->oauth->$method($url , $param );
}
}
}
/**
* 新浪微博 OAuth 认证类
*
* @package sae
* @author Easy Chen
* @version 1.0
*/
class WeiboOAuth {
/**
* Contains the last HTTP status code returned.
*
* @ignore
*/
public $http_code;
/**
* Contains the last API call.
*
* @ignore
*/
public $url;
/**
* Set up the API root URL.
*
* @ignore
*/
public $host = "http://api.t.sina.com.cn/";
/**
* Set timeout default.
*
* @ignore
*/
public $timeout = 30;
/**
* Set connect timeout.
*
* @ignore
*/
public $connecttimeout = 30;
/**
* Verify SSL Cert.
*
* @ignore
*/
public $ssl_verifypeer = FALSE;
/**
* Respons format.
*
* @ignore
*/
public $format = 'json';
/**
* Decode returned json data.
*
* @ignore
*/
public $decode_json = TRUE;
/**
* Contains the last HTTP headers returned.
*
* @ignore
*/
public $http_info;
/**
* Set the useragnet.
*
* @ignore
*/
public $useragent = 'Sae T OAuth v0.2.0-beta2';
/* Immediately retry the API call if the response was not successful. */
//public $retry = TRUE;
/**
* Set API URLS
*/
/**
* @ignore
*/
function accessTokenURL() { return 'http://api.t.sina.com.cn/oauth/access_token'; }
/**
* @ignore
*/
function authenticateURL() { return 'http://api.t.sina.com.cn/oauth/authenticate'; }
/**
* @ignore
*/
function authorizeURL() { return 'http://api.t.sina.com.cn/oauth/authorize'; }
/**
* @ignore
*/
function requestTokenURL() { return 'http://api.t.sina.com.cn/oauth/request_token'; }
/**
* Debug helpers
*/
/**
* @ignore
*/
function lastStatusCode() { return $this->http_status; }
/**
* @ignore
*/
function lastAPICall() { return $this->last_api_call; }
/**
* construct WeiboOAuth object
*/
function __construct($consumer_key, $consumer_secret, $oauth_token = NULL, $oauth_token_secret = NULL) {
$this->sha1_method = new OAuthSignatureMethod_HMAC_SHA1();
$this->consumer = new OAuthConsumer($consumer_key, $consumer_secret);
if (!empty($oauth_token) && !empty($oauth_token_secret)) {
$this->token = new OAuthConsumer($oauth_token, $oauth_token_secret);
} else {
$this->token = NULL;
}
}
/**
* Get a request_token from Weibo
*
* @return array a key/value array containing oauth_token and oauth_token_secret
*/
function getRequestToken($oauth_callback = NULL) {
$parameters = array();
if (!empty($oauth_callback)) {
$parameters['oauth_callback'] = $oauth_callback;
}
$request = $this->oAuthRequest($this->requestTokenURL(), 'GET', $parameters);
$token = OAuthUtil::parse_parameters($request);
$this->token = new OAuthConsumer($token['oauth_token'], $token['oauth_token_secret']);
return $token;
}
/**
* Get the authorize URL
*
* @return string
*/
function getAuthorizeURL($token, $sign_in_with_Weibo = TRUE , $url) {
if (is_array($token)) {
$token = $token['oauth_token'];
}
if (empty($sign_in_with_Weibo)) {
return $this->authorizeURL() . "?oauth_token={$token}&oauth_callback=" . urlencode($url);
} else {
return $this->authenticateURL() . "?oauth_token={$token}&oauth_callback=". urlencode($url);
}
}
/**
* Exchange the request token and secret for an access token and
* secret, to sign API calls.
*
* @return array array("oauth_token" => the access token,
* "oauth_token_secret" => the access secret)
*/
function getAccessToken($oauth_verifier = FALSE, $oauth_token = false) {
$parameters = array();
if (!empty($oauth_verifier)) {
$parameters['oauth_verifier'] = $oauth_verifier;
}
$request = $this->oAuthRequest($this->accessTokenURL(), 'GET', $parameters);
$token = OAuthUtil::parse_parameters($request);
$this->token = new OAuthConsumer($token['oauth_token'], $token['oauth_token_secret']);
return $token;
}
/**
* GET wrappwer for oAuthRequest.
*
* @return mixed
*/
function get($url, $parameters = array()) {
$response = $this->oAuthRequest($url, 'GET', $parameters);
if ($this->format === 'json' && $this->decode_json) {
return json_decode($response, true);
}
return $response;
}
/**
* POST wreapper for oAuthRequest.
*
* @return mixed
*/
function post($url, $parameters = array() , $multi = false) {
$response = $this->oAuthRequest($url, 'POST', $parameters , $multi );
if ($this->format === 'json' && $this->decode_json) {
return json_decode($response, true);
}
return $response;
}
/**
* DELTE wrapper for oAuthReqeust.
*
* @return mixed
*/
function delete($url, $parameters = array()) {
$response = $this->oAuthRequest($url, 'DELETE', $parameters);
if ($this->format === 'json' && $this->decode_json) {
return json_decode($response, true);
}
return $response;
}
/**
* Format and sign an OAuth / API request
*
* @return string
*/
function oAuthRequest($url, $method, $parameters , $multi = false) {
if (strrpos($url, 'http://') !== 0 && strrpos($url, 'http://') !== 0) {
$url = "{$this->host}{$url}.{$this->format}";
}
// echo $url ;
$request = OAuthRequest::from_consumer_and_token($this->consumer, $this->token, $method, $url, $parameters);
$request->sign_request($this->sha1_method, $this->consumer, $this->token);
switch ($method) {
case 'GET':
//echo $request->to_url();
return $this->http($request->to_url(), 'GET');
default:
return $this->http($request->get_normalized_http_url(), $method, $request->to_postdata($multi) , $multi );
}
}
/**
* Make an HTTP request
*
* @return string API results
*/
function http($url, $method, $postfields = NULL , $multi = false) {
$this->http_info = array();
$ci = curl_init();
/* Curl settings */
curl_setopt($ci, CURLOPT_USERAGENT, $this->useragent);
curl_setopt($ci, CURLOPT_CONNECTTIMEOUT, $this->connecttimeout);
curl_setopt($ci, CURLOPT_TIMEOUT, $this->timeout);
curl_setopt($ci, CURLOPT_RETURNTRANSFER, TRUE);
curl_setopt($ci, CURLOPT_SSL_VERIFYPEER, $this->ssl_verifypeer);
curl_setopt($ci, CURLOPT_HEADERFUNCTION, array($this, 'getHeader'));
curl_setopt($ci, CURLOPT_HEADER, FALSE);
switch ($method) {
case 'POST':
curl_setopt($ci, CURLOPT_POST, TRUE);
if (!empty($postfields)) {
curl_setopt($ci, CURLOPT_POSTFIELDS, $postfields);
//echo "=====post data======\r\n";
//echo $postfields;
}
break;
case 'DELETE':
curl_setopt($ci, CURLOPT_CUSTOMREQUEST, 'DELETE');
if (!empty($postfields)) {
$url = "{$url}?{$postfields}";
}
}
$header_array = array();
/*
$header_array["FetchUrl"] = $url;
$header_array['TimeStamp'] = date('Y-m-d H:i:s');
$header_array['AccessKey'] = SAE_ACCESSKEY;
$content="FetchUrl";
$content.=$header_array["FetchUrl"];
$content.="TimeStamp";
$content.=$header_array['TimeStamp'];
$content.="AccessKey";
$content.=$header_array['AccessKey'];
$header_array['Signature'] = base64_encode(hash_hmac('sha256',$content, SAE_SECRETKEY ,true));
*/
//curl_setopt($ci, CURLOPT_URL, SAE_FETCHURL_SERVICE_ADDRESS );
//print_r( $header_array );
$header_array2=array();
if( $multi )
$header_array2 = array("Content-Type: multipart/form-data; boundary=" . OAuthUtil::$boundary , "Expect: ");
foreach($header_array as $k => $v)
array_push($header_array2,$k.': '.$v);
curl_setopt($ci, CURLOPT_HTTPHEADER, $header_array2 );
curl_setopt($ci, CURLINFO_HEADER_OUT, TRUE );
//echo $url."<hr/>";
curl_setopt($ci, CURLOPT_URL, $url);
$response = curl_exec($ci);
$this->http_code = curl_getinfo($ci, CURLINFO_HTTP_CODE);
$this->http_info = array_merge($this->http_info, curl_getinfo($ci));
$this->url = $url;
//echo '=====info====='."\r\n";
//print_r( curl_getinfo($ci) );
//echo '=====$response====='."\r\n";
//print_r( $response );
curl_close ($ci);
return $response;
}
/**
* Get the header info to store.
*
* @return int
*/
function getHeader($ch, $header) {
$i = strpos($header, ':');
if (!empty($i)) {
$key = str_replace('-', '_', strtolower(substr($header, 0, $i)));
$value = trim(substr($header, $i + 2));
$this->http_header[$key] = $value;
}
return strlen($header);
}
}
|
108wo
|
phpcms/modules/member/classes/weibooauth.class.php
|
PHP
|
asf20
| 53,752
|
<?php
/*
* qq微博APP 接口类
* Code based on:
* Abraham Williams (abraham@abrah.am) http://abrah.am
*/
/* Load OAuth lib. You can find it at http://oauth.net */
/**
* @ignore
*/
class OAuthException extends Exception {
// pass
}
/**
* @ignore
*/
class OAuthConsumer {
public $key;
public $secret;
function __construct($key, $secret) {
$this->key = $key;
$this->secret = $secret;
}
function __toString() {
return "OAuthConsumer[key=$this->key,secret=$this->secret]";
}
}
/**
* @ignore
*/
class OAuthToken {
// access tokens and request tokens
public $key;
public $secret;
/**
* key = the token
* secret = the token secret
*/
function __construct($key, $secret) {
$this->key = $key;
$this->secret = $secret;
}
/**
* generates the basic string serialization of a token that a server
* would respond to request_token and access_token calls with
*/
function to_string() {
return "oauth_token=" .
OAuthUtil::urlencode_rfc3986($this->key) .
"&oauth_token_secret=" .
OAuthUtil::urlencode_rfc3986($this->secret);
}
function __toString() {
return $this->to_string();
}
}
/**
* @ignore
*/
class OAuthSignatureMethod {
public function check_signature(&$request, $consumer, $token, $signature) {
$built = $this->build_signature($request, $consumer, $token);
return $built == $signature;
}
}
/**
* @ignore
*/
class OAuthSignatureMethod_HMAC_SHA1 extends OAuthSignatureMethod {
function get_name() {
return "HMAC-SHA1";
}
public function build_signature($request, $consumer, $token) {
$base_string = $request->get_signature_base_string();
//print_r( $base_string );
$request->base_string = $base_string;
$key_parts = array(
$consumer->secret,
($token) ? $token->secret : ""
);
//print_r( $key_parts );
$key_parts = OAuthUtil::urlencode_rfc3986($key_parts);
$key = implode('&', $key_parts);
return base64_encode(hash_hmac('sha1', $base_string, $key, true));
}
}
/**
* @ignore
*/
class OAuthSignatureMethod_PLAINTEXT extends OAuthSignatureMethod {
public function get_name() {
return "PLAINTEXT";
}
public function build_signature($request, $consumer, $token) {
$sig = array(
OAuthUtil::urlencode_rfc3986($consumer->secret)
);
if ($token) {
array_push($sig, OAuthUtil::urlencode_rfc3986($token->secret));
} else {
array_push($sig, '');
}
$raw = implode("&", $sig);
// for debug purposes
$request->base_string = $raw;
return OAuthUtil::urlencode_rfc3986($raw);
}
}
/**
* @ignore
*/
class OAuthSignatureMethod_RSA_SHA1 extends OAuthSignatureMethod {
public function get_name() {
return "RSA-SHA1";
}
protected function fetch_public_cert(&$request) {
// not implemented yet, ideas are:
// (1) do a lookup in a table of trusted certs keyed off of consumer
// (2) fetch via http using a url provided by the requester
// (3) some sort of specific discovery code based on request
//
// either way should return a string representation of the certificate
throw Exception("fetch_public_cert not implemented");
}
protected function fetch_private_cert(&$request) {
// not implemented yet, ideas are:
// (1) do a lookup in a table of trusted certs keyed off of consumer
//
// either way should return a string representation of the certificate
throw Exception("fetch_private_cert not implemented");
}
public function build_signature(&$request, $consumer, $token) {
$base_string = $request->get_signature_base_string();
$request->base_string = $base_string;
// Fetch the private key cert based on the request
$cert = $this->fetch_private_cert($request);
// Pull the private key ID from the certificate
$privatekeyid = openssl_get_privatekey($cert);
// Sign using the key
$ok = openssl_sign($base_string, $signature, $privatekeyid);
// Release the key resource
openssl_free_key($privatekeyid);
return base64_encode($signature);
}
public function check_signature(&$request, $consumer, $token, $signature) {
$decoded_sig = base64_decode($signature);
$base_string = $request->get_signature_base_string();
// Fetch the public key cert based on the request
$cert = $this->fetch_public_cert($request);
// Pull the public key ID from the certificate
$publickeyid = openssl_get_publickey($cert);
// Check the computed signature against the one passed in the query
$ok = openssl_verify($base_string, $decoded_sig, $publickeyid);
// Release the key resource
openssl_free_key($publickeyid);
return $ok == 1;
}
}
/**
* @ignore
*/
class OAuthRequest {
private $parameters;
private $http_method;
private $http_url;
// for debug purposes
public $base_string;
public static $version = '1.0a';
public static $POST_INPUT = 'php://input';
function __construct($http_method, $http_url, $parameters=NULL) {
@$parameters or $parameters = array();
$this->parameters = $parameters;
$this->http_method = $http_method;
$this->http_url = $http_url;
}
/**
* attempt to build up a request from what was passed to the server
*/
public static function from_request($http_method=NULL, $http_url=NULL, $parameters=NULL) {
$scheme = (!isset($_SERVER['HTTPS']) || $_SERVER['HTTPS'] != "on")
? 'http'
: 'https';
@$http_url or $http_url = $scheme .
'://' . $_SERVER['HTTP_HOST'] .
':' .
$_SERVER['SERVER_PORT'] .
$_SERVER['REQUEST_URI'];
@$http_method or $http_method = $_SERVER['REQUEST_METHOD'];
// We weren't handed any parameters, so let's find the ones relevant to
// this request.
// If you run XML-RPC or similar you should use this to provide your own
// parsed parameter-list
if (!$parameters) {
// Find request headers
$request_headers = OAuthUtil::get_headers();
// Parse the query-string to find GET parameters
$parameters = OAuthUtil::parse_parameters($_SERVER['QUERY_STRING']);
// It's a POST request of the proper content-type, so parse POST
// parameters and add those overriding any duplicates from GET
if ($http_method == "POST"
&& @strstr($request_headers["Content-Type"],
"application/x-www-form-urlencoded")
) {
$post_data = OAuthUtil::parse_parameters(
file_get_contents(self::$POST_INPUT)
);
$parameters = array_merge($parameters, $post_data);
}
// We have a Authorization-header with OAuth data. Parse the header
// and add those overriding any duplicates from GET or POST
if (@substr($request_headers['Authorization'], 0, 6) == "OAuth ") {
$header_parameters = OAuthUtil::split_header(
$request_headers['Authorization']
);
$parameters = array_merge($parameters, $header_parameters);
}
}
return new OAuthRequest($http_method, $http_url, $parameters);
}
/**
* pretty much a helper function to set up the request
*/
public static function from_consumer_and_token($consumer, $token, $http_method, $http_url, $parameters=NULL) {
@$parameters or $parameters = array();
$defaults = array("oauth_version" => OAuthRequest::$version,
"oauth_nonce" => OAuthRequest::generate_nonce(),
"oauth_timestamp" => OAuthRequest::generate_timestamp(),
"oauth_consumer_key" => $consumer->key);
if ($token)
$defaults['oauth_token'] = $token->key;
$parameters = array_merge($defaults, $parameters);
return new OAuthRequest($http_method, $http_url, $parameters);
}
public function set_parameter($name, $value, $allow_duplicates = true) {
if ($allow_duplicates && isset($this->parameters[$name])) {
// We have already added parameter(s) with this name, so add to the list
if (is_scalar($this->parameters[$name])) {
// This is the first duplicate, so transform scalar (string)
// into an array so we can add the duplicates
$this->parameters[$name] = array($this->parameters[$name]);
}
$this->parameters[$name][] = $value;
} else {
$this->parameters[$name] = $value;
}
}
public function get_parameter($name) {
return isset($this->parameters[$name]) ? $this->parameters[$name] : null;
}
public function get_parameters() {
return $this->parameters;
}
public function unset_parameter($name) {
unset($this->parameters[$name]);
}
/**
* The request parameters, sorted and concatenated into a normalized string.
* @return string
*/
public function get_signable_parameters() {
// Grab all parameters
$params = $this->parameters;
// remove pic
if (isset($params['pic'])) {
unset($params['pic']);
}
if (isset($params['image']))
{
unset($params['image']);
}
// Remove oauth_signature if present
// Ref: Spec: 9.1.1 ("The oauth_signature parameter MUST be excluded.")
if (isset($params['oauth_signature'])) {
unset($params['oauth_signature']);
}
return OAuthUtil::build_http_query($params);
}
/**
* Returns the base string of this request
*
* The base string defined as the method, the url
* and the parameters (normalized), each urlencoded
* and the concated with &.
*/
public function get_signature_base_string() {
$parts = array(
$this->get_normalized_http_method(),
$this->get_normalized_http_url(),
$this->get_signable_parameters()
);
//print_r( $parts );
$parts = OAuthUtil::urlencode_rfc3986($parts);
return implode('&', $parts);
}
/**
* just uppercases the http method
*/
public function get_normalized_http_method() {
return strtoupper($this->http_method);
}
/**
* parses the url and rebuilds it to be
* scheme://host/path
*/
public function get_normalized_http_url() {
$parts = parse_url($this->http_url);
$port = @$parts['port'];
$scheme = $parts['scheme'];
$host = $parts['host'];
$path = @$parts['path'];
$port or $port = ($scheme == 'https') ? '443' : '80';
if (($scheme == 'https' && $port != '443')
|| ($scheme == 'http' && $port != '80')) {
$host = "$host:$port";
}
return "$scheme://$host$path";
}
/**
* builds a url usable for a GET request
*/
public function to_url() {
$post_data = $this->to_postdata();
$out = $this->get_normalized_http_url();
if ($post_data) {
$out .= '?'.$post_data;
}
return $out;
}
/**
* builds the data one would send in a POST request
*/
public function to_postdata( $multi = false ) {
//echo "multi=" . $multi . '`';
if( $multi )
return OAuthUtil::build_http_query_multi($this->parameters);
else
return OAuthUtil::build_http_query($this->parameters);
}
/**
* builds the Authorization: header
*/
public function to_header() {
$out ='Authorization: OAuth realm=""';
$total = array();
foreach ($this->parameters as $k => $v) {
if (substr($k, 0, 5) != "oauth") continue;
if (is_array($v)) {
throw new OAuthException('Arrays not supported in headers');
}
$out .= ',' .
OAuthUtil::urlencode_rfc3986($k) .
'="' .
OAuthUtil::urlencode_rfc3986($v) .
'"';
}
return $out;
}
public function __toString() {
return $this->to_url();
}
public function sign_request($signature_method, $consumer, $token) {
$this->set_parameter(
"oauth_signature_method",
$signature_method->get_name(),
false
);
$signature = $this->build_signature($signature_method, $consumer, $token);
//echo "sign=" . $signature;
$this->set_parameter("oauth_signature", $signature, false);
}
public function build_signature($signature_method, $consumer, $token) {
$signature = $signature_method->build_signature($this, $consumer, $token);
return $signature;
}
/**
* util function: current timestamp
*/
private static function generate_timestamp() {
//return 1273566716;
//echo date("y-m-d H:i:s");
return time();
}
/**
* util function: current nonce
*/
private static function generate_nonce() {
//return '462d316f6f40c40a9e0eef1b009f37fa';
$mt = microtime();
$rand = mt_rand();
return md5($mt . $rand); // md5s look nicer than numbers
}
}
/**
* @ignore
*/
class OAuthServer {
protected $timestamp_threshold = 300; // in seconds, five minutes
protected $version = 1.0; // hi blaine
protected $signature_methods = array();
protected $data_store;
function __construct($data_store) {
$this->data_store = $data_store;
}
public function add_signature_method($signature_method) {
$this->signature_methods[$signature_method->get_name()] =
$signature_method;
}
// high level functions
/**
* process a request_token request
* returns the request token on success
*/
public function fetch_request_token(&$request) {
$this->get_version($request);
$consumer = $this->get_consumer($request);
// no token required for the initial token request
$token = NULL;
$this->check_signature($request, $consumer, $token);
$new_token = $this->data_store->new_request_token($consumer);
return $new_token;
}
/**
* process an access_token request
* returns the access token on success
*/
public function fetch_access_token(&$request) {
$this->get_version($request);
$consumer = $this->get_consumer($request);
// requires authorized request token
$token = $this->get_token($request, $consumer, "request");
$this->check_signature($request, $consumer, $token);
$new_token = $this->data_store->new_access_token($token, $consumer);
return $new_token;
}
/**
* verify an api call, checks all the parameters
*/
public function verify_request(&$request) {
$this->get_version($request);
$consumer = $this->get_consumer($request);
$token = $this->get_token($request, $consumer, "access");
$this->check_signature($request, $consumer, $token);
return array($consumer, $token);
}
// Internals from here
/**
* version 1
*/
private function get_version(&$request) {
$version = $request->get_parameter("oauth_version");
if (!$version) {
$version = 1.0;
}
if ($version && $version != $this->version) {
throw new OAuthException("OAuth version '$version' not supported");
}
return $version;
}
/**
* figure out the signature with some defaults
*/
private function get_signature_method(&$request) {
$signature_method =
@$request->get_parameter("oauth_signature_method");
if (!$signature_method) {
$signature_method = "PLAINTEXT";
}
if (!in_array($signature_method,
array_keys($this->signature_methods))) {
throw new OAuthException(
"Signature method '$signature_method' not supported " .
"try one of the following: " .
implode(", ", array_keys($this->signature_methods))
);
}
return $this->signature_methods[$signature_method];
}
/**
* try to find the consumer for the provided request's consumer key
*/
private function get_consumer(&$request) {
$consumer_key = @$request->get_parameter("oauth_consumer_key");
if (!$consumer_key) {
throw new OAuthException("Invalid consumer key");
}
$consumer = $this->data_store->lookup_consumer($consumer_key);
if (!$consumer) {
throw new OAuthException("Invalid consumer");
}
return $consumer;
}
/**
* try to find the token for the provided request's token key
*/
private function get_token(&$request, $consumer, $token_type="access") {
$token_field = @$request->get_parameter('oauth_token');
$token = $this->data_store->lookup_token(
$consumer, $token_type, $token_field
);
if (!$token) {
throw new OAuthException("Invalid $token_type token: $token_field");
}
return $token;
}
/**
* all-in-one function to check the signature on a request
* should guess the signature method appropriately
*/
private function check_signature(&$request, $consumer, $token) {
// this should probably be in a different method
$timestamp = @$request->get_parameter('oauth_timestamp');
$nonce = @$request->get_parameter('oauth_nonce');
$this->check_timestamp($timestamp);
$this->check_nonce($consumer, $token, $nonce, $timestamp);
$signature_method = $this->get_signature_method($request);
$signature = $request->get_parameter('oauth_signature');
$valid_sig = $signature_method->check_signature(
$request,
$consumer,
$token,
$signature
);
if (!$valid_sig) {
throw new OAuthException("Invalid signature");
}
}
/**
* check that the timestamp is new enough
*/
private function check_timestamp($timestamp) {
// verify that timestamp is recentish
$now = time();
if ($now - $timestamp > $this->timestamp_threshold) {
throw new OAuthException(
"Expired timestamp, yours $timestamp, ours $now"
);
}
}
/**
* check that the nonce is not repeated
*/
private function check_nonce($consumer, $token, $nonce, $timestamp) {
// verify that the nonce is uniqueish
$found = $this->data_store->lookup_nonce(
$consumer,
$token,
$nonce,
$timestamp
);
if ($found) {
throw new OAuthException("Nonce already used: $nonce");
}
}
}
/**
* @ignore
*/
class OAuthDataStore {
function lookup_consumer($consumer_key) {
// implement me
}
function lookup_token($consumer, $token_type, $token) {
// implement me
}
function lookup_nonce($consumer, $token, $nonce, $timestamp) {
// implement me
}
function new_request_token($consumer) {
// return a new token attached to this consumer
}
function new_access_token($token, $consumer) {
// return a new access token attached to this consumer
// for the user associated with this token if the request token
// is authorized
// should also invalidate the request token
}
}
/**
* @ignore
*/
class OAuthUtil {
public static $boundary = '';
public static function urlencode_rfc3986($input) {
if (is_array($input)) {
return array_map(array('OAuthUtil', 'urlencode_rfc3986'), $input);
} else if (is_scalar($input)) {
return str_replace(
'+',
' ',
str_replace('%7E', '~', rawurlencode($input))
);
} else {
return '';
}
}
// This decode function isn't taking into consideration the above
// modifications to the encoding process. However, this method doesn't
// seem to be used anywhere so leaving it as is.
public static function urldecode_rfc3986($string) {
return urldecode($string);
}
// Utility function for turning the Authorization: header into
// parameters, has to do some unescaping
// Can filter out any non-oauth parameters if needed (default behaviour)
public static function split_header($header, $only_allow_oauth_parameters = true) {
$pattern = '/(([-_a-z]*)=("([^"]*)"|([^,]*)),?)/';
$offset = 0;
$params = array();
while (preg_match($pattern, $header, $matches, PREG_OFFSET_CAPTURE, $offset) > 0) {
$match = $matches[0];
$header_name = $matches[2][0];
$header_content = (isset($matches[5])) ? $matches[5][0] : $matches[4][0];
if (preg_match('/^oauth_/', $header_name) || !$only_allow_oauth_parameters) {
$params[$header_name] = OAuthUtil::urldecode_rfc3986($header_content);
}
$offset = $match[1] + strlen($match[0]);
}
if (isset($params['realm'])) {
unset($params['realm']);
}
return $params;
}
// helper to try to sort out headers for people who aren't running apache
public static function get_headers() {
if (function_exists('apache_request_headers')) {
// we need this to get the actual Authorization: header
// because apache tends to tell us it doesn't exist
return apache_request_headers();
}
// otherwise we don't have apache and are just going to have to hope
// that $_SERVER actually contains what we need
$out = array();
foreach ($_SERVER as $key => $value) {
if (substr($key, 0, 5) == "HTTP_") {
// this is chaos, basically it is just there to capitalize the first
// letter of every word that is not an initial HTTP and strip HTTP
// code from przemek
$key = str_replace(
" ",
"-",
ucwords(strtolower(str_replace("_", " ", substr($key, 5))))
);
$out[$key] = $value;
}
}
return $out;
}
// This function takes a input like a=b&a=c&d=e and returns the parsed
// parameters like this
// array('a' => array('b','c'), 'd' => 'e')
public static function parse_parameters( $input ) {
if (!isset($input) || !$input) return array();
$pairs = explode('&', $input);
$parsed_parameters = array();
foreach ($pairs as $pair) {
$split = explode('=', $pair, 2);
$parameter = OAuthUtil::urldecode_rfc3986($split[0]);
$value = isset($split[1]) ? OAuthUtil::urldecode_rfc3986($split[1]) : '';
if (isset($parsed_parameters[$parameter])) {
// We have already recieved parameter(s) with this name, so add to the list
// of parameters with this name
if (is_scalar($parsed_parameters[$parameter])) {
// This is the first duplicate, so transform scalar (string) into an array
// so we can add the duplicates
$parsed_parameters[$parameter] = array($parsed_parameters[$parameter]);
}
$parsed_parameters[$parameter][] = $value;
} else {
$parsed_parameters[$parameter] = $value;
}
}
return $parsed_parameters;
}
public static function build_http_query_multi($params) {
if (!$params) return '';
//print_r( $params );
//return null;
// Urlencode both keys and values
$keys = array_keys($params);
$values = array_values($params);
//$keys = OAuthUtil::urlencode_rfc3986(array_keys($params));
//$values = OAuthUtil::urlencode_rfc3986(array_values($params));
$params = array_combine($keys, $values);
// Parameters are sorted by name, using lexicographical byte value ordering.
// Ref: Spec: 9.1.1 (1)
uksort($params, 'strcmp');
$pairs = array();
self::$boundary = $boundary = uniqid('------------------');
$MPboundary = '--'.$boundary;
$endMPboundary = $MPboundary. '--';
$multipartbody = '';
foreach ($params as $parameter => $value) {
//if( $parameter == 'pic' && $value{0} == '@' )
if( in_array($parameter,array("pic","image")) && $value{0} == '@' )
{
$url = ltrim( $value , '@' );
$content = file_get_contents( $url );
$filename = reset( explode( '?' , basename( $url ) ));
$mime = self::get_image_mime($url);
$multipartbody .= $MPboundary . "\r\n";
$multipartbody .= 'Content-Disposition: form-data; name="' . $parameter . '"; filename="' . $filename . '"'. "\r\n";
$multipartbody .= 'Content-Type: '. $mime . "\r\n\r\n";
$multipartbody .= $content. "\r\n";
}
else
{
$multipartbody .= $MPboundary . "\r\n";
$multipartbody .= 'content-disposition: form-data; name="'.$parameter."\"\r\n\r\n";
$multipartbody .= $value."\r\n";
}
}
$multipartbody .= $endMPboundary;
// For each parameter, the name is separated from the corresponding value by an '=' character (ASCII code 61)
// Each name-value pair is separated by an '&' character (ASCII code 38)
// echo $multipartbody;
return $multipartbody;
}
public static function build_http_query($params) {
if (!$params) return '';
// Urlencode both keys and values
$keys = OAuthUtil::urlencode_rfc3986(array_keys($params));
$values = OAuthUtil::urlencode_rfc3986(array_values($params));
$params = array_combine($keys, $values);
// Parameters are sorted by name, using lexicographical byte value ordering.
// Ref: Spec: 9.1.1 (1)
uksort($params, 'strcmp');
$pairs = array();
foreach ($params as $parameter => $value) {
if (is_array($value)) {
// If two or more parameters share the same name, they are sorted by their value
// Ref: Spec: 9.1.1 (1)
natsort($value);
foreach ($value as $duplicate_value) {
$pairs[] = $parameter . '=' . $duplicate_value;
}
} else {
$pairs[] = $parameter . '=' . $value;
}
}
// For each parameter, the name is separated from the corresponding value by an '=' character (ASCII code 61)
// Each name-value pair is separated by an '&' character (ASCII code 38)
return implode('&', $pairs);
}
public static function get_image_mime( $file )
{
$ext = strtolower(pathinfo( $file , PATHINFO_EXTENSION ));
switch( $ext )
{
case 'jpg':
case 'jpeg':
$mime = 'image/jpg';
break;
case 'png';
$mime = 'image/png';
break;
case 'gif';
default:
$mime = 'image/gif';
break;
}
return $mime;
}
}
/**
* qq微博操作类
*
* @package sae
* @author Easy Chen
* @version 1.0
*/
class WeiboClient
{
/**
* 构造函数
*
* @access public
* @param mixed $akey 微博开放平台应用APP KEY
* @param mixed $skey 微博开放平台应用APP SECRET
* @param mixed $accecss_token OAuth认证返回的token
* @param mixed $accecss_token_secret OAuth认证返回的token secret
* @return void
*/
function __construct( $akey , $skey , $accecss_token , $accecss_token_secret )
{
$this->oauth = new WeiboOAuth( $akey , $skey , $accecss_token , $accecss_token_secret );
}
/**
* 最新公共微博
*
* @access public
* @return array
*/
function public_timeline()
{
return $this->oauth->get('http://open.t.qq.com/api/statuses/home_timeline');
}
/**
* 最新关注人微博
*
* @access public
* @return array
*/
function friends_timeline()
{
return $this->home_timeline();
}
/**
* 最新关注人微博
*
* @access public
* @return array
*/
function home_timeline()
{
return $this->oauth->get('http://open.t.qq.com/api/statuses/home_timeline.json');
}
/**
* 最新 @用户的
*
* @access public
* @param int $page 返回结果的页序号。
* @param int $count 每次返回的最大记录数(即页面大小),不大于200,默认为20。
* @return array
*/
function mentions( $page = 1 , $count = 20 )
{
return $this->request_with_pager( 'http://open.t.qq.com/api/statuses/mentions.json' , $page , $count );
}
/**
* 发表微博
*
* @access public
* @param mixed $text 要更新的微博信息。
* @return array
*/
function update( $text )
{
// http://open.t.qq.com/api/statuses/update.json
$param = array();
$param['status'] = $text;
return $this->oauth->post( 'http://open.t.qq.com/api/statuses/update.json' , $param );
}
/**
* 发表图片微博
*
* @access public
* @param string $text 要更新的微博信息。
* @param string $text 要发布的图片路径,支持url。[只支持png/jpg/gif三种格式,增加格式请修改get_image_mime方法]
* @return array
*/
function upload( $text , $pic_path )
{
// http://open.t.qq.com/api/statuses/update.json
$param = array();
$param['status'] = $text;
$param['pic'] = '@'.$pic_path;
return $this->oauth->post( 'http://open.t.qq.com/api/statuses/upload.json' , $param , true );
}
/**
* 获取单条微博
*
* @access public
* @param mixed $sid 要获取已发表的微博ID
* @return array
*/
function show_status( $sid )
{
return $this->oauth->get( 'http://open.t.qq.com/api/statuses/show/' . $sid . '.json' );
}
/**
* 删除微博
*
* @access public
* @param mixed $sid 要删除的微博ID
* @return array
*/
function delete( $sid )
{
return $this->destroy( $sid );
}
/**
* 删除微博
*
* @access public
* @param mixed $sid 要删除的微博ID
* @return array
*/
function destroy( $sid )
{
return $this->oauth->post( 'http://open.t.qq.com/api/statuses/destroy/' . $sid . '.json' );
}
/**
* 个人资料
*
* @access public
* @param mixed $uid_or_name 用户UID或微博昵称。
* @return array
*/
function show_user( $uid_or_name = null )
{
return $this->request_with_uid( 'http://open.t.qq.com/api/users/show.json' , $uid_or_name );
}
/**
* 关注人列表
*
* @access public
* @param bool $cursor 单页只能包含100个关注列表,为了获取更多则cursor默认从-1开始,通过增加或减少cursor来获取更多的关注列表
* @param bool $count 每次返回的最大记录数(即页面大小),不大于200,默认返回20
* @param mixed $uid_or_name 要获取的 UID或微博昵称
* @return array
*/
function friends( $cursor = false , $count = false , $uid_or_name = null )
{
return $this->request_with_uid( 'http://open.t.qq.com/api/statuses/friends.json' , $uid_or_name , false , $count , $cursor );
}
/**
* 粉丝列表
*
* @access public
* @param bool $cursor 单页只能包含100个粉丝列表,为了获取更多则cursor默认从-1开始,通过增加或减少cursor来获取更多的粉丝列表
* @param bool $count 每次返回的最大记录数(即页面大小),不大于200,默认返回20。
* @param mixed $uid_or_name 要获取的 UID或微博昵称
* @return array
*/
function followers( $cursor = false , $count = false , $uid_or_name = null )
{
return $this->request_with_uid( 'http://open.t.qq.com/api/statuses/followers.json' , $uid_or_name , false , $count , $cursor );
}
/**
* 关注一个用户
*
* @access public
* @param mixed $uid_or_name 要关注的用户UID或微博昵称
* @return array
*/
function follow( $uid_or_name )
{
return $this->request_with_uid( 'http://open.t.qq.com/api/friendships/create.json' , $uid_or_name , false , false , false , true );
}
/**
* 取消关注某用户
*
* @access public
* @param mixed $uid_or_name 要取消关注的用户UID或微博昵称
* @return array
*/
function unfollow( $uid_or_name )
{
return $this->request_with_uid( 'http://open.t.qq.com/api/friendships/destroy.json' , $uid_or_name , false , false , false , true);
}
/**
* 返回两个用户关系的详细情况
*
* @access public
* @param mixed $uid_or_name 要判断的用户UID
* @return array
*/
function is_followed( $uid_or_name )
{
$param = array();
if( is_numeric( $uid_or_name ) ) $param['target_id'] = $uid_or_name;
else $param['target_screen_name'] = $uid_or_name;
return $this->oauth->get( 'http://open.t.qq.com/api/friendships/show.json' , $param );
}
/**
* 用户发表微博列表
*
* @access public
* @param int $page 页码
* @param int $count 每次返回的最大记录数,最多返回200条,默认20。
* @param mixed $uid_or_name 指定用户UID或微博昵称
* @return array
*/
function user_timeline( $page = 1 , $count = 20 , $uid_or_name = null )
{
if( !is_numeric( $page ) )
return $this->request_with_uid( 'http://open.t.qq.com/api/statuses/user_timeline.json' , $page );
else
return $this->request_with_uid( 'http://open.t.qq.com/api/statuses/user_timeline.json' , $uid_or_name , $page , $count );
}
/**
* 获取私信列表
*
* @access public
* @param int $page 页码
* @param int $count 每次返回的最大记录数,最多返回200条,默认20。
* @return array
*/
function list_dm( $page = 1 , $count = 20 )
{
return $this->request_with_pager( 'http://open.t.qq.com/api/direct_messages.json' , $page , $count );
}
/**
* 发送的私信列表
*
* @access public
* @param int $page 页码
* @param int $count 每次返回的最大记录数,最多返回200条,默认20。
* @return array
*/
function list_dm_sent( $page = 1 , $count = 20 )
{
return $this->request_with_pager( 'http://open.t.qq.com/api/direct_messages/sent.json' , $page , $count );
}
/**
* 发送私信
*
* @access public
* @param mixed $uid_or_name UID或微博昵称
* @param mixed $text 要发生的消息内容,文本大小必须小于300个汉字。
* @return array
*/
function send_dm( $uid_or_name , $text )
{
$param = array();
$param['text'] = $text;
if( is_numeric( $uid_or_name ) ) $param['user_id'] = $uid_or_name;
else $param['screen_name'] = $uid_or_name;
return $this->oauth->post( 'http://open.t.qq.com/api/direct_messages/new.json' , $param );
}
/**
* 删除一条私信
*
* @access public
* @param mixed $did 要删除的私信主键ID
* @return array
*/
function delete_dm( $did )
{
return $this->oauth->post( 'http://open.t.qq.com/api/direct_messages/destroy/' . $did . '.json' );
}
/**
* 转发一条微博信息。
*
* @access public
* @param mixed $sid 转发的微博ID
* @param bool $text 添加的转发信息。
* @return array
*/
function repost( $sid , $text = false )
{
$param = array();
$param['id'] = $sid;
if( $text ) $param['status'] = $text;
return $this->oauth->post( 'http://open.t.qq.com/api/statuses/repost.json' , $param );
}
/**
* 对一条微博信息进行评论
*
* @access public
* @param mixed $sid 要评论的微博id
* @param mixed $text 评论内容
* @param bool $cid 要评论的评论id
* @return array
*/
function send_comment( $sid , $text , $cid = false )
{
$param = array();
$param['id'] = $sid;
$param['comment'] = $text;
if( $cid ) $param['cid '] = $cid;
return $this->oauth->post( 'http://open.t.qq.com/api/statuses/comment.json' , $param );
}
/**
* 发出的评论
*
* @access public
* @param int $page 页码
* @param int $count 每次返回的最大记录数,最多返回200条,默认20。
* @return array
*/
function comments_by_me( $page = 1 , $count = 20 )
{
return $this->request_with_pager( 'http://open.t.qq.com/api/statuses/comments_by_me.json' , $page , $count );
}
/**
* 最新评论(按时间)
*
* @access public
* @param int $page 页码
* @param int $count 每次返回的最大记录数,最多返回200条,默认20。
* @return array
*/
function comments_timeline( $page = 1 , $count = 20 )
{
return $this->request_with_pager( 'http://open.t.qq.com/api/statuses/comments_timeline.json' , $page , $count );
}
/**
* 单条评论列表(按微博)
*
* @access public
* @param mixed $sid 指定的微博ID
* @param int $page 页码
* @param int $count 每次返回的最大记录数,最多返回200条,默认20。
* @return array
*/
function get_comments_by_sid( $sid , $page = 1 , $count = 20 )
{
$param = array();
$param['id'] = $sid;
if( $page ) $param['page'] = $page;
if( $count ) $param['count'] = $count;
return $this->oauth->get('http://open.t.qq.com/api/statuses/comments.json' , $param );
}
/**
* 批量统计微博的评论数,转发数,一次请求最多获取100个。
*
* @access public
* @param mixed $sids 微博ID号列表,用逗号隔开
* @return array
*/
function get_count_info_by_ids( $sids )
{
$param = array();
$param['ids'] = $sids;
return $this->oauth->get( 'http://open.t.qq.com/api/statuses/counts.json' , $param );
}
/**
* 对一条微博评论信息进行回复。
*
* @access public
* @param mixed $sid 微博id
* @param mixed $text 评论内容。
* @param mixed $cid 评论id
* @return array
*/
function reply( $sid , $text , $cid )
{
$param = array();
$param['id'] = $sid;
$param['comment'] = $text;
$param['cid '] = $cid;
return $this->oauth->post( 'http://open.t.qq.com/api/statuses/reply.json' , $param );
}
/**
* 返回用户的发布的最近20条收藏信息,和用户收藏页面返回内容是一致的。
*
* @access public
* @param bool $page 返回结果的页序号。
* @return array
*/
function get_favorites( $page = false )
{
$param = array();
if( $page ) $param['page'] = $page;
return $this->oauth->get( 'http://open.t.qq.com/api/favorites.json' , $param );
}
/**
* 收藏一条微博信息
*
* @access public
* @param mixed $sid 收藏的微博id
* @return array
*/
function add_to_favorites( $sid )
{
$param = array();
$param['id'] = $sid;
return $this->oauth->post( 'http://open.t.qq.com/api/favorites/create.json' , $param );
}
/**
* 删除微博收藏。
*
* @access public
* @param mixed $sid 要删除的收藏微博信息ID.
* @return array
*/
function remove_from_favorites( $sid )
{
return $this->oauth->post( 'http://open.t.qq.com/api/favorites/destroy/' . $sid . '.json' );
}
function verify_credentials()
{
return $this->oauth->get( 'http://open.t.qq.com/api/user/info?format=json' );
}
function update_avatar( $pic_path )
{
$param = array();
$param['image'] = "@".$pic_path;
return $this->oauth->post( 'http://open.t.qq.com/api/account/update_profile_image.json' , $param , true );
}
// =========================================
/**
* @ignore
*/
protected function request_with_pager( $url , $page = false , $count = false )
{
$param = array();
if( $page ) $param['page'] = $page;
if( $count ) $param['count'] = $count;
return $this->oauth->get($url , $param );
}
/**
* @ignore
*/
protected function request_with_uid( $url , $uid_or_name , $page = false , $count = false , $cursor = false , $post = false )
{
$param = array();
if( $page ) $param['page'] = $page;
if( $count ) $param['count'] = $count;
if( $cursor )$param['cursor'] = $cursor;
if( $post ) $method = 'post';
else $method = 'get';
if( is_numeric( $uid_or_name ) )
{
$param['user_id'] = $uid_or_name;
return $this->oauth->$method($url , $param );
}elseif( $uid_or_name !== null )
{
$param['screen_name'] = $uid_or_name;
return $this->oauth->$method($url , $param );
}
else
{
return $this->oauth->$method($url , $param );
}
}
}
/**
* qq OAuth 认证类
*
* @package sae
* @author Easy Chen
* @version 1.0
*/
class WeiboOAuth {
/**
* Contains the last HTTP status code returned.
*
* @ignore
*/
public $http_code;
/**
* Contains the last API call.
*
* @ignore
*/
public $url;
/**
* Set up the API root URL.
*
* @ignore
*/
public $host = "http://open.t.qq.com/api/";
/**
* Set timeout default.
*
* @ignore
*/
public $timeout = 30;
/**
* Set connect timeout.
*
* @ignore
*/
public $connecttimeout = 30;
/**
* Verify SSL Cert.
*
* @ignore
*/
public $ssl_verifypeer = FALSE;
/**
* Respons format.
*
* @ignore
*/
public $format = 'json';
/**
* Decode returned json data.
*
* @ignore
*/
public $decode_json = TRUE;
/**
* Contains the last HTTP headers returned.
*
* @ignore
*/
public $http_info;
/**
* Set the useragnet.
*
* @ignore
*/
public $useragent = 'Sae T OAuth v0.2.0-beta2';
/* Immediately retry the API call if the response was not successful. */
//public $retry = TRUE;
/**
* Set API URLS
*/
/**
* @ignore
*/
function accessTokenURL() { return 'https://open.t.qq.com/cgi-bin/access_token'; }
/**
* @ignore
*/
function authenticateURL() { return 'https://open.t.qq.com/cgi-bin/authenticate'; }
/**
* @ignore
*/
function authorizeURL() { return 'https://open.t.qq.com/cgi-bin/authorize'; }
/**
* @ignore
*/
function requestTokenURL() { return 'https://open.t.qq.com/cgi-bin/request_token'; }
/**
* Debug helpers
*/
/**
* @ignore
*/
function lastStatusCode() { return $this->http_status; }
/**
* @ignore
*/
function lastAPICall() { return $this->last_api_call; }
/**
* construct WeiboOAuth object
*/
function __construct($consumer_key, $consumer_secret, $oauth_token = NULL, $oauth_token_secret = NULL) {
$this->sha1_method = new OAuthSignatureMethod_HMAC_SHA1();
$this->consumer = new OAuthConsumer($consumer_key, $consumer_secret);
if (!empty($oauth_token) && !empty($oauth_token_secret)) {
$this->token = new OAuthConsumer($oauth_token, $oauth_token_secret);
} else {
$this->token = NULL;
}
}
/**
* Get a request_token from Weibo
*
* @return array a key/value array containing oauth_token and oauth_token_secret
*/
function getRequestToken($oauth_callback = NULL) {
$parameters = array();
if (!empty($oauth_callback)) {
$parameters['oauth_callback'] = $oauth_callback;
}
$request = $this->oAuthRequest($this->requestTokenURL(), 'GET', $parameters);
$token = OAuthUtil::parse_parameters($request);
$this->token = new OAuthConsumer($token['oauth_token'], $token['oauth_token_secret']);
return $token;
}
/**
* Get the authorize URL
*
* @return string
*/
function getAuthorizeURL($token, $sign_in_with_Weibo = TRUE , $url) {
if (is_array($token)) {
$token = $token['oauth_token'];
}
if (empty($sign_in_with_Weibo)) {
return $this->authorizeURL() . "?oauth_token={$token}&oauth_callback=" . urlencode($url);
} else {
return $this->authenticateURL() . "?oauth_token={$token}&oauth_callback=". urlencode($url);
}
}
/**
* Exchange the request token and secret for an access token and
* secret, to sign API calls.
*
* @return array array("oauth_token" => the access token,
* "oauth_token_secret" => the access secret)
*/
function getAccessToken($oauth_verifier = FALSE, $oauth_token = false) {
$parameters = array();
if (!empty($oauth_verifier)) {
$parameters['oauth_verifier'] = $oauth_verifier;
}
$request = $this->oAuthRequest($this->accessTokenURL(), 'GET', $parameters);
$token = OAuthUtil::parse_parameters($request);
$this->token = new OAuthConsumer($token['oauth_token'], $token['oauth_token_secret']);
return $token;
}
/**
* GET wrappwer for oAuthRequest.
*
* @return mixed
*/
function get($url, $parameters = array()) {
$response = $this->oAuthRequest($url, 'GET', $parameters);
if ($this->format === 'json' && $this->decode_json) {
return json_decode($response, true);
}
return $response;
}
/**
* POST wreapper for oAuthRequest.
*
* @return mixed
*/
function post($url, $parameters = array() , $multi = false) {
$response = $this->oAuthRequest($url, 'POST', $parameters , $multi );
if ($this->format === 'json' && $this->decode_json) {
return json_decode($response, true);
}
return $response;
}
/**
* DELTE wrapper for oAuthReqeust.
*
* @return mixed
*/
function delete($url, $parameters = array()) {
$response = $this->oAuthRequest($url, 'DELETE', $parameters);
if ($this->format === 'json' && $this->decode_json) {
return json_decode($response, true);
}
return $response;
}
/**
* Format and sign an OAuth / API request
*
* @return string
*/
function oAuthRequest($url, $method, $parameters , $multi = false) {
if (strrpos($url, 'https://') !== 0) {
//$url = "{$this->host}{$url}format={$this->format}";
}
//echo $url ;
$request = OAuthRequest::from_consumer_and_token($this->consumer, $this->token, $method, $url, $parameters);
$request->sign_request($this->sha1_method, $this->consumer, $this->token);
switch ($method) {
case 'GET':
// echo $request->to_url();
return $this->http($request->to_url(), 'GET');
default:
return $this->http($request->get_normalized_http_url(), $method, $request->to_postdata($multi) , $multi );
}
}
/**
* Make an HTTP request
*
* @return string API results
*/
function http($url, $method, $postfields = NULL , $multi = false) {
$this->http_info = array();
$ci = curl_init();
/* Curl settings */
curl_setopt($ci, CURLOPT_USERAGENT, $this->useragent);
curl_setopt($ci, CURLOPT_CONNECTTIMEOUT, $this->connecttimeout);
curl_setopt($ci, CURLOPT_TIMEOUT, $this->timeout);
curl_setopt($ci, CURLOPT_RETURNTRANSFER, TRUE);
curl_setopt($ci, CURLOPT_SSL_VERIFYPEER, $this->ssl_verifypeer);
curl_setopt($ci, CURLOPT_HEADERFUNCTION, array($this, 'getHeader'));
curl_setopt($ci, CURLOPT_HEADER, FALSE);
switch ($method) {
case 'POST':
curl_setopt($ci, CURLOPT_POST, TRUE);
if (!empty($postfields)) {
curl_setopt($ci, CURLOPT_POSTFIELDS, $postfields);
//echo "=====post data======\r\n";
//echo $postfields;
}
break;
case 'DELETE':
curl_setopt($ci, CURLOPT_CUSTOMREQUEST, 'DELETE');
if (!empty($postfields)) {
$url = "{$url}?{$postfields}";
}
}
$header_array = array();
/*
$header_array["FetchUrl"] = $url;
$header_array['TimeStamp'] = date('Y-m-d H:i:s');
$header_array['AccessKey'] = SAE_ACCESSKEY;
$content="FetchUrl";
$content.=$header_array["FetchUrl"];
$content.="TimeStamp";
$content.=$header_array['TimeStamp'];
$content.="AccessKey";
$content.=$header_array['AccessKey'];
$header_array['Signature'] = base64_encode(hash_hmac('sha256',$content, SAE_SECRETKEY ,true));
*/
//curl_setopt($ci, CURLOPT_URL, SAE_FETCHURL_SERVICE_ADDRESS );
//print_r( $header_array );
$header_array2=array();
if( $multi )
$header_array2 = array("Content-Type: multipart/form-data; boundary=" . OAuthUtil::$boundary , "Expect: ");
foreach($header_array as $k => $v)
array_push($header_array2,$k.': '.$v);
curl_setopt($ci, CURLOPT_HTTPHEADER, $header_array2 );
curl_setopt($ci, CURLINFO_HEADER_OUT, TRUE );
//echo $url."<hr/>";
curl_setopt($ci, CURLOPT_URL, $url);
$response = curl_exec($ci);
$this->http_code = curl_getinfo($ci, CURLINFO_HTTP_CODE);
$this->http_info = array_merge($this->http_info, curl_getinfo($ci));
$this->url = $url;
//echo '=====info====='."\r\n";
//print_r( curl_getinfo($ci) );
//echo '=====$response====='."\r\n";
//print_r( $response );
curl_close ($ci);
return $response;
}
/**
* Get the header info to store.
*
* @return int
*/
function getHeader($ch, $header) {
$i = strpos($header, ':');
if (!empty($i)) {
$key = str_replace('-', '_', strtolower(substr($header, 0, $i)));
$value = trim(substr($header, $i + 2));
$this->http_header[$key] = $value;
}
return strlen($header);
}
}
|
108wo
|
phpcms/modules/member/classes/qqoauth.class.php
|
PHP
|
asf20
| 55,466
|
<?php
class foreground {
public $db, $memberinfo;
private $_member_modelinfo;
public function __construct() {
$this->db = pc_base::load_model('member_model');
//ajax验证信息不需要登录
if(substr(ROUTE_A, 0, 7) != 'public_') {
self::check_member();
}
}
/**
* 判断用户是否已经登陆
*/
final public function check_member() {
$phpcms_auth = param::get_cookie('auth');
if(ROUTE_M =='member' && ROUTE_C =='index' && in_array(ROUTE_A, array('login', 'register', 'mini'))) {
if ($phpcms_auth && ROUTE_A != 'mini') {
showmessage(L('login_success', '', 'member'), 'index.php?m=member&c=index');
} else {
return true;
}
} else {
//判断是否存在auth cookie
if ($phpcms_auth) {
$auth_key = md5(pc_base::load_config('system', 'auth_key').str_replace('7.0' ,'8.0',$_SERVER['HTTP_USER_AGENT']));
list($userid, $password) = explode("\t", sys_auth($phpcms_auth, 'DECODE', $auth_key));
//验证用户,获取用户信息
$this->memberinfo = $this->db->get_one(array('userid'=>$userid));
//获取用户模型信息
$this->db->set_model($this->memberinfo['modelid']);
$this->_member_modelinfo = $this->db->get_one(array('userid'=>$userid));
$this->_member_modelinfo = $this->_member_modelinfo ? $this->_member_modelinfo : array();
$this->db->set_model();
if(is_array($this->memberinfo)) {
$this->memberinfo = array_merge($this->memberinfo, $this->_member_modelinfo);
}
if($this->memberinfo && $this->memberinfo['password'] === $password) {
if (!defined('SITEID')) {
define('SITEID', $this->memberinfo['siteid']);
}
if($this->memberinfo['groupid'] == 1) {
param::set_cookie('auth', '');
param::set_cookie('_userid', '');
param::set_cookie('_username', '');
param::set_cookie('_groupid', '');
showmessage(L('userid_banned_by_administrator', '', 'member'), 'index.php?m=member&c=index&a=login');
} elseif($this->memberinfo['groupid'] == 7) {
param::set_cookie('auth', '');
param::set_cookie('_userid', '');
param::set_cookie('_groupid', '');
param::set_cookie('email', $this->memberinfo['email']);
showmessage(L('need_emial_authentication', '', 'member'), 'index.php?m=member&c=index&a=register&t=2');
}
} else {
param::set_cookie('auth', '');
param::set_cookie('_userid', '');
param::set_cookie('_username', '');
param::set_cookie('_groupid', '');
}
unset($userid, $password, $phpcms_auth, $auth_key);
} else {
$forward= isset($_GET['forward']) ? urlencode($_GET['forward']) : urlencode(get_url());
showmessage(L('please_login', '', 'member'), 'index.php?m=member&c=index&a=login&forward='.$forward);
}
}
}
}
|
108wo
|
phpcms/modules/member/classes/foreground.class.php
|
PHP
|
asf20
| 2,854
|
<?php
if (! function_exists('curl_init')) {
throw new Exception('Snda needs the CURL PHP extension.');
}
if (! function_exists('json_decode')) {
throw new Exception('Snda needs the JSON PHP extension.');
}
class OauthSDK
{
/**
* Contains the last HTTP status code returned.
*
* @ignore
*/
public $http_code;
/**
* Contains the last API call.
*
* @ignore
*/
public $url;
/**
* Set timeout default.
*
* @ignore
*/
public $timeout = 30;
/**
* Set connect timeout.
*
* @ignore
*/
public $connecttimeout = 30;
/**
* Verify SSL Cert.
*
* @ignore
*/
public $ssl_verifypeer = FALSE;
/**
* Respons format.
*
* @ignore
*/
public $format = 'json';
/**
* Decode returned json data.
*
* @ignore
*/
public $decode_json = TRUE;
/**
* Contains the last HTTP headers returned.
*
* @ignore
*/
public $http_info;
/**
* Set the useragnet.
*
* @ignore
*/
public $useragent = 'SNDA OAuth 2.0';
/* Immediately retry the API call if the response was not successful. */
//public $retry = TRUE;
/**
* The Application ID.
*/
protected $appId;
/**
* The Application API Secret.
*/
protected $appSecret;
/**
* app callback url
*/
protected $redirectURI;
protected $lastErrorCode;
protected $lastErrorMsg;
protected $systemParam = array(
'connectTimeout' => 5 ,
'timeout' => 3 ,
'gatewayUrl' => 'http://api.snda.com' ,
'authorizeURL' => 'http://oauth.snda.com/oauth/authorize' ,
'accessTokenURL' => 'http://oauth.snda.com/oauth/token' ,
'systemTokenURL' => 'http://oauth.snda.com/oauth/token' ,
'gatewayHost' => 'api.snda.com' ,
'gatewayPort' => 8888
);
protected $params = array();
private $oauth_debug = FALSE;
private $apiStartTime = 0;
private $apiStopTime = 0;
private $execTime = 0;
/**
* User Authorization url
*/
function authorizeURL ()
{
return $this->systemParam['authorizeURL'];
}
/**
* Get User Authorization url
*/
function accessTokenURL ()
{
return $this->systemParam['accessTokenURL'];
}
/**
* Get System Authorization url
*/
function systemTokenURL ()
{
return $this->systemParam['systemTokenURL'];
}
/**
* ApiPool GateWay Url
*/
function apiPoolURL ()
{
return $this->systemParam['gatewayUrl'];
}
function __construct ($apiKey, $appSecret, $redirectURI)
{
$this->appId = $apiKey;
$this->appSecret = $appSecret;
$this->redirectURI = $redirectURI;
}
function setOption ($key, $value)
{
$this->systemParam[$key] = $value;
}
/**
* Set the Application ID.
*
* @param String $appId the Application ID
*/
public function setAppId ($appId)
{
$this->appId = $appId;
}
/**
* Get the Application ID.
*
* @return String the Application ID
*/
public function getAppId ()
{
return $this->appId;
}
public function setRedirectURI ($redirectURI)
{
$this->redirectURI = $redirectURI;
}
public function getRedirectURI ()
{
return $this->redirectURI;
}
/**
* Set the API Secret.
*
* @param String $appId the API Secret
*/
public function setApiSecret ($apiSecret)
{
$this->apiSecret = $apiSecret;
}
/**
* Get the API Secret.
*
* @return String the API Secret
*/
public function getApiSecret ()
{
return $this->apiSecret;
}
//Get accesstoken
public function getAccessToken ($code)
{
$this->_clearError();
$clientID = $this->appId;
$redirectURI = $this->redirectURI;
$clientSecret = $this->appSecret;
$accessTokenURL = self::accessTokenURL();
$url = "{$accessTokenURL}?code={$code}&client_id={$clientID}&client_secret={$clientSecret}&redirect_uri={$redirectURI}";
$result = self::http($url);
$access_token = json_decode($result, TRUE);
if (empty($access_token) || isset($access_token['error'])) {
$this->_setOAuthError($access_token);
return FALSE;
} else {
return $access_token;
}
}
//Generate User Authorization url
public function getAuthorizeURL ()
{
$clientID = $this->appId;
$redirectURI = $this->redirectURI;
$authorizeURL = self::authorizeURL();
return "{$authorizeURL}?response_type=code&client_id={$clientID}&redirect_uri={$redirectURI}";
}
//Generate System Authorization token
public function getSystemToken ()
{
$this->_clearError();
$clientID = $this->appId;
$redirectURI = $this->redirectURI;
$clientSecret = $this->appSecret;
$accessTokenURL = self::accessTokenURL();
$url = "{$accessTokenURL}?grant_type=client_credentials&client_id={$clientID}&client_secret={$clientSecret}";
$result = self::http($url);
$access_token = json_decode($result, TRUE);
if (empty($access_token) || isset($access_token['error'])) {
$this->_setOAuthError($access_token);
return FALSE;
} else {
return $access_token;
}
}
public static function generate_nonce ()
{
$mt = microtime();
$rand = mt_rand();
return md5($mt . $rand); // md5s look nicer than numbers
}
/**
* request apipool
*/
public function request ($method = 'TCP')
{
static $tcpField = array(
'method' => 1 ,
'oauth_consumer_key' => 1 ,
'oauth_token' => 1 ,
'oauth_nonce' => 1 ,
'oauth_timestamp' => 1 ,
'oauth_version' => 1 ,
'oauth_signature_method' => 1 ,
'oauth_signature' => 1 ,
'call_id' => 1 ,
'version' => 1
);
$this->_clearError();
$param = $this->params;
$this->params = array();
$url = self::apiPoolURL();
$parameters['oauth_token'] = 'null';
$parameters['oauth_consumer_key'] = $this->appId;
$parameters['oauth_nonce'] = self::generate_nonce();
$parameters['oauth_timestamp'] = (string) time();
$parameters['oauth_version'] = '2.0';
$parameters['oauth_signature_method'] = 'HMAC-SHA1';
if ($method == 'TCP') {
$parameters['call_id'] = 0;
}
// data merging
foreach ($parameters as $key => $value) {
if (! isset($param[$key])) {
$param[$key] = $parameters[$key];
}
}
if ($method == 'TCP') {
$tcpParams = array();
foreach ($param as $key => $value) {
if (! isset($tcpField[$key])) {
$tcpParams[$key] = $value;
unset($param[$key]);
}
}
$param['params'] = $tcpParams;
}
if (! isset($param['oauth_signature'])) {
$param['oauth_signature'] = self::generateSig($param);
}
$result = '';
if ($this->oauth_debug) {
$this->apiStart();
}
switch ($method) {
case 'TCP':
$result = self::tcp($param);
break;
case 'GET':
$url = $url . '?' . http_build_query($param);
$result = self::http($url, $method);
break;
case 'POST':
$postdata = http_build_query($param);
$result = self::http($url, $method, $postdata);
break;
default:
return FALSE;
break;
}
if ($this->oauth_debug) {
$this->apiStop();
$this->apiSpent($this->appId, $param['method']);
}
$result = json_decode($result, TRUE);
if (empty($result)) {
$this->_setGWError();
return FALSE;
}
$response = array();
if ($method == 'TCP') {
$response = $result['response'];
} else {
$response = $result;
}
//check error
if (! isset($response['return_code']) || $response['return_code'] != 0) {
$this->_setGWError($response);
return FALSE;
}
return $response;
}
private function generateSig ($params, $secret = '')
{
if (empty($secret)) {
$secret = $this->appSecret;
}
$str = '';
ksort($params);
foreach ($params as $k => $v) {
if (! is_array($v)) {
$str .= "$k=$v";
} else {
ksort($v);
$str .= "$k=" . json_encode($v);
}
}
return bin2hex(hash_hmac('sha1', $str, $secret, TRUE));
}
public function setParam ($key, $value)
{
$this->params[$key] = $value;
}
public function tcp ($param)
{
$sock = socket_create(AF_INET, SOCK_STREAM, 0);
if (FALSE === $sock) {
return FALSE;
}
socket_set_option($sock, SOL_SOCKET, SO_RCVTIMEO, array(
'sec' => $this->systemParam['timeout'] ,
'usec' => 0
));
socket_set_option($sock, SOL_SOCKET, SO_SNDTIMEO, array(
'sec' => $this->systemParam['timeout'] ,
'usec' => 0
));
$result = socket_connect($sock, $this->systemParam['gatewayHost'], $this->systemParam['gatewayPort']);
if (FALSE === $result) {
socket_close($sock);
return FALSE;
}
$data = json_encode($param);
$len = dechex(strlen($data));
$data = sprintf('%06s%s', $len, $data);
$result = socket_write($sock, $data);
if (FALSE === $sock) {
socket_close($sock);
return FALSE;
}
$data = socket_read($sock, 6);
if (FALSE === $data) {
socket_close($sock);
return FALSE;
}
$len = hexdec($data);
$data = socket_read($sock, $len);
if (FALSE === $data) {
socket_close($sock);
return FALSE;
}
socket_close($sock);
return $data;
}
/**
* Make an HTTP request
*
* @return string API results
*/
public function http ($url, $method = 'GET', $postfields = FALSE)
{
$this->http_info = array();
$ci = curl_init();
/* Curl settings */
curl_setopt($ci, CURLOPT_USERAGENT, $this->useragent);
curl_setopt($ci, CURLOPT_CONNECTTIMEOUT, $this->systemParam['connectTimeout']);
curl_setopt($ci, CURLOPT_TIMEOUT, $this->systemParam['timeout']);
curl_setopt($ci, CURLOPT_RETURNTRANSFER, TRUE);
curl_setopt($ci, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_0);
curl_setopt($ci, CURLOPT_SSL_VERIFYPEER, $this->ssl_verifypeer);
curl_setopt($ci, CURLOPT_HEADERFUNCTION, array(
$this ,
'getHeader'
));
curl_setopt($ci, CURLOPT_HEADER, FALSE);
switch ($method) {
case 'POST':
curl_setopt($ci, CURLOPT_POST, TRUE);
if (! empty($postfields)) {
curl_setopt($ci, CURLOPT_POSTFIELDS, $postfields);
//echo "=====post data======\r\n";
//echo $postfields;
}
break;
case 'DELETE':
curl_setopt($ci, CURLOPT_CUSTOMREQUEST, 'DELETE');
if (! empty($postfields)) {
$url = "{$url}?{$postfields}";
}
break;
}
$header_array = array();
$header_array2 = array();
foreach ($header_array as $k => $v)
array_push($header_array2, $k . ': ' . $v);
curl_setopt($ci, CURLOPT_HTTPHEADER, $header_array2);
curl_setopt($ci, CURLINFO_HEADER_OUT, FALSE);
//echo $url."<hr/>";
curl_setopt($ci, CURLOPT_URL, $url);
$response = curl_exec($ci);
$this->http_code = curl_getinfo($ci, CURLINFO_HTTP_CODE);
$this->http_info = array_merge($this->http_info, curl_getinfo($ci));
$this->url = $url;
curl_close($ci);
return $response;
}
/**
* Get the header info to store.
*
* @return int
*/
public function getHeader ($ch, $header)
{
$i = strpos($header, ':');
if (! empty($i)) {
$key = str_replace('-', '_', strtolower(substr($header, 0, $i)));
$value = trim(substr($header, $i + 2));
$this->http_header[$key] = $value;
}
return strlen($header);
}
private function _setOAuthError ($err = null)
{
if (empty($err)) {
$this->lastErrorCode = 'unknow';
$this->lastErrorMsg = 'unkonw';
} else {
$this->lastErrorCode = @$err['error'];
$this->lastErrorMsg = @$err['error_description'];
}
}
private function _setGWError ($response = null)
{
if (empty($response)) {
$this->lastErrorCode = 'unknow';
$this->lastErrorMsg = 'unkonw';
} else {
$this->lastErrorCode = @$response['return_code'];
$this->lastErrorMsg = @$response['return_message'];
}
}
private function _clearError ()
{
$this->lastErrorCode = 0;
$this->lastErrorMsg = '';
}
public function getLastErrCode ()
{
return $this->lastErrorCode;
}
public function getLastErrMsg ()
{
return $this->lastErrorMsg;
}
public function getExecTime ()
{
return $this->execTime;
}
private function apiStart ()
{
$this->apiStartTime = microtime(TRUE);
}
private function apiStop ()
{
$this->apiStopTime = microtime(TRUE);
}
private function apiSpent ($appid, $api)
{
$url = 'http://log.ibw.sdo.com/apipool.jpg?';
$spent = round(($this->apiStopTime - $this->apiStartTime) * 1000, 1);
$this->execTime = $spent;
$params = array();
$params['appid'] = $appid;
$params['api'] = $api;
$params['time'] = $spent;
$url .= http_build_query($params);
@file_get_contents($url);
}
}
?>
|
108wo
|
phpcms/modules/member/classes/OauthSDK.class.php
|
PHP
|
asf20
| 15,350
|
<?php
class client {
private $ps_api_url, $ps_auth_key, $ps_vsersion;
/**
* 析构函数
* @param $ps_api_url 接口域名
* @param $ps_auth_key 加密密匙
*/
public function __construct($ps_api_url='127.0.0.1', $ps_auth_key='', $ps_vsersion='1') {
$this->ps_api_url = $ps_api_url;
$this->ps_auth_key = $ps_auth_key;
$this->ps_vsersion = $ps_vsersion;
}
/**
* 用户注册
* @param string $username 用户名
* @param string $password 密码
* @param string $email email
* @param string $regip 注册ip
* @param string $random 密码随机数
* @return int {-1:用户名已经存在 ;-2:email已存在;-3:email格式错误;-4:用户名禁止注册;-5:邮箱禁止注册;int(uid):成功}
*/
public function ps_member_register($username, $password, $email, $regip='', $random='') {
if(!$this->_is_email($email)) {
return -3;
}
return $this->_ps_send('register', array('username'=>$username, 'password'=>$password, 'email'=>$email, 'regip'=>$regip, 'random'=>$random));
}
/**
* 用户登陆
* @param string $username 用户名
* @param string $password 密码
* @param int $isemail email
* @return int {-2;密码错误;-1:用户名不存在;array(userinfo):用户信息}
*/
public function ps_member_login($username, $password, $isemail=0) {
if($isemail) {
if(!$this->_is_email($username)) {
return -3;
}
$return = $this->_ps_send('login', array('email'=>$username, 'password'=>$password));
} else {
$return = $this->_ps_send('login', array('username'=>$username, 'password'=>$password));
}
return $return;
}
/**
* 同步登陆
* @param string $uid
* @return string javascript用户同步登陆js
*/
public function ps_member_synlogin($uid) {
$uid = intval($uid);
return $this->_ps_send('synlogin', array('uid'=>$uid));
}
/**
* 同步退出
* @param string $uid
* @return string javascript用户同步退出js
*/
public function ps_member_synlogout() {
return $this->_ps_send('synlogout', array());
}
/**
* 编辑用户
* @param string $username 用户名
* @param string $email email
* @param string $password 旧密码
* @param string $newpassword 新密码
* @param int $uid phpsso用户uid
* @param string $random 密码随机数
* @return int {-1:用户不存在;-2:旧密码错误;-3:email已经存在 ;-4:email格式错误;1:成功;0:未作修改}
*/
public function ps_member_edit($username, $email, $password='', $newpassword='', $uid='', $random='') {
if($email && !$this->_is_email($email)) {
return -4;
}
return $this->_ps_send('edit', array('username'=>$username, 'password'=>$password, 'newpassword'=>$newpassword, 'email'=>$email, 'uid'=>$uid, 'random'=>$random));
}
/**
* 删除用户头像
* @param int $uid phpsso用户uid
* @return int {1:成功;0:失败}
*/
public function ps_deleteavatar($uid) {
return $this->_ps_send('deleteavatar', array('uid'=>$uid));
}
/**
* 获取用户信息
* @param $mix 用户id/用户名/email
* @param $type {1:用户id;2:用户名;3:email}
* @return $mix {-1:用户不存在;userinfo:用户信息}
*/
public function ps_get_member_info($mix, $type=1) {
if($type==1) {
$userinfo = $this->_ps_send('getuserinfo', array('uid'=>$mix));
} elseif($type==2) {
$userinfo = $this->_ps_send('getuserinfo', array('username'=>$mix));
} elseif($type==3) {
if(!$this->_is_email($mix)) {
return -4;
}
$userinfo = $this->_ps_send('getuserinfo', array('email'=>$mix));
}
if($userinfo) {
return $userinfo;
} else {
return -1;
}
}
/**
* 删除用户
* @param mix {1:用户id;2:用户名;3:email} 如果是用户id可以为数组
* @return int {-1:用户不存在;1:删除成功}
*/
public function ps_delete_member($mix, $type=1) {
if($type==1) {
$res = $this->_ps_send('delete', array('uid'=>$mix));
} elseif($type==2) {
$res = $this->_ps_send('delete', array('username'=>$mix));
} elseif($type==3) {
if(!$this->_is_email($mix)) {
return -4;
}
$res = $this->_ps_send('delete', array('email'=>$mix));
}
return $res;
}
/**
* 检查用户是否可以注册
* @param string $username
* @return int {-4:用户名禁止注册;-1:用户名已经存在 ;1:成功}
*/
public function ps_checkname($username) {
return $this->_ps_send('checkname', array('username'=>$username));
}
/**
* 检查邮箱是否可以注册
* @param string $email
* @return int {-1:email已经存在 ;-5:邮箱禁止注册;1:成功}
*/
public function ps_checkemail($email) {
return $this->_ps_send('checkemail', array('email'=>$email));
}
/**
* 获取应用列表信息
*/
public function ps_getapplist() {
return $this->_ps_send('getapplist', array());
}
/**
* 获取积分兑换比例列表
*/
public function ps_getcreditlist() {
return $this->_ps_send('getcredit', array());
}
/**
* 兑换积分
* 用于何其他应用之间积分兑换
* @param int $uid phpssouid
* @param int $from 本系统积分类型id
* @param int $toappid 目标系统应用appid
* @param int $to 目标系统积分类型id
* @param int $credit 本系统扣除积分数
* @return bool {1:成功;0:失败}
*/
public function ps_changecredit($uid, $from, $toappid, $to, $credit) {
return $this->_ps_send('changecredit', array('uid'=>$uid, 'from'=>$from, 'toappid'=>$toappid, 'to'=>$to, 'credit'=>$credit));
}
/**
* 根据phpsso uid获取头像url
* @param int $uid 用户id
* @return array 四个尺寸用户头像数组
*/
public function ps_getavatar($uid) {
$dir1 = ceil($uid / 10000);
$dir2 = ceil($uid % 10000 / 1000);
$url = $this->ps_api_url.'/uploadfile/avatar/'.$dir1.'/'.$dir2.'/'.$uid.'/';
$avatar = array('180'=>$url.'180x180.jpg', '90'=>$url.'90x90.jpg', '45'=>$url.'45x45.jpg', '30'=>$url.'30x30.jpg');
return $avatar;
}
/**
* 获取上传头像flash的html代码
* @param int $uid 用户id
*/
public function ps_getavatar_upload_html($uid) {
$auth_data = $this->auth_data(array('uid'=>$uid, 'ps_auth_key'=>$this->ps_auth_key), '', $this->ps_auth_key);
$upurl = base64_encode($this->ps_api_url.'/index.php?m=phpsso&c=index&a=uploadavatar&auth_data='.$auth_data);
$str = <<<EOF
<div id="phpsso_uploadavatar_flash"></div>
<script language="javascript" type="text/javascript" src="{$this->ps_api_url}/statics/js/swfobject.js"></script>
<script type="text/javascript">
var flashvars = {
'upurl':"{$upurl}&callback=return_avatar&"
};
var params = {
'align':'middle',
'play':'true',
'loop':'false',
'scale':'showall',
'wmode':'window',
'devicefont':'true',
'id':'Main',
'bgcolor':'#ffffff',
'name':'Main',
'allowscriptaccess':'always'
};
var attributes = {
};
swfobject.embedSWF("{$this->ps_api_url}/statics/images/main.swf", "phpsso_uploadavatar_flash", "490", "434", "9.0.0","{$this->ps_api_url}/statics/images/expressInstall.swf", flashvars, params, attributes);
function return_avatar(data) {
if(data == 1) {
window.location.reload();
} else {
alert('failure');
}
}
</script>
EOF;
return $str;
}
/**
* 字符串加密、解密函数
* @param string $txt 字符串
* @param string $operation ENCODE为加密,DECODE为解密,可选参数,默认为ENCODE,
* @param string $key 密钥:数字、字母、下划线
* @return string
*/
public function sys_auth($txt, $operation = 'ENCODE', $key = '') {
$key = $key ? $key : $this->ps_auth_key;
$txt = $operation == 'ENCODE' ? (string)$txt : base64_decode($txt);
$len = strlen($key);
$code = '';
for($i=0; $i<strlen($txt); $i++) {
$k = $i % $len;
$code .= $txt[$i] ^ $key[$k];
}
$code = $operation == 'DECODE' ? $code : base64_encode($code);
return $code;
}
/**
* 将数组转换为字符串
*
* @param array $data 数组
* @param bool $isformdata 如果为0,则不使用new_stripslashes处理,可选参数,默认为1
* @return string 返回字符串,如果,data为空,则返回空
*/
public function array2string($data, $isformdata = 1) {
if($data == '') return '';
if($isformdata) $data = new_stripslashes($data);
return var_export($data, TRUE);
}
public function auth_data($data) {
$s = $sep = '';
foreach($data as $k => $v) {
if(is_array($v)) {
$s2 = $sep2 = '';
foreach($v as $k2 => $v2) {
$s2 .= "$sep2{$k}[$k2]=".$this->_ps_stripslashes($v2);
$sep2 = '&';
}
$s .= $sep.$s2;
} else {
$s .= "$sep$k=".$this->_ps_stripslashes($v);
}
$sep = '&';
}
$auth_s = 'v='.$this->ps_vsersion.'&appid='.APPID.'&data='.urlencode($this->sys_auth($s));
return $auth_s;
}
/**
* 发送数据
* @param $action 操作
* @param $data 数据
*/
private function _ps_send($action, $data = null) {
return $this->_ps_post($this->ps_api_url."/index.php?m=phpsso&c=index&a=".$action, 500000, $this->auth_data($data));
}
/**
* post数据
* @param string $url post的url
* @param int $limit 返回的数据的长度
* @param string $post post数据,字符串形式username='dalarge'&password='123456'
* @param string $cookie 模拟 cookie,字符串形式username='dalarge'&password='123456'
* @param string $ip ip地址
* @param int $timeout 连接超时时间
* @param bool $block 是否为阻塞模式
* @return string 返回字符串
*/
private function _ps_post($url, $limit = 0, $post = '', $cookie = '', $ip = '', $timeout = 15, $block = true) {
$return = '';
$matches = parse_url($url);
$host = $matches['host'];
$path = $matches['path'] ? $matches['path'].($matches['query'] ? '?'.$matches['query'] : '') : '/';
$port = !empty($matches['port']) ? $matches['port'] : 80;
$siteurl = $this->_get_url();
if($post) {
$out = "POST $path HTTP/1.1\r\n";
$out .= "Accept: */*\r\n";
$out .= "Referer: ".$siteurl."\r\n";
$out .= "Accept-Language: zh-cn\r\n";
$out .= "Content-Type: application/x-www-form-urlencoded\r\n";
$out .= "User-Agent: $_SERVER[HTTP_USER_AGENT]\r\n";
$out .= "Host: $host\r\n" ;
$out .= 'Content-Length: '.strlen($post)."\r\n" ;
$out .= "Connection: Close\r\n" ;
$out .= "Cache-Control: no-cache\r\n" ;
$out .= "Cookie: $cookie\r\n\r\n" ;
$out .= $post ;
} else {
$out = "GET $path HTTP/1.1\r\n";
$out .= "Accept: */*\r\n";
$out .= "Referer: ".$siteurl."\r\n";
$out .= "Accept-Language: zh-cn\r\n";
$out .= "User-Agent: $_SERVER[HTTP_USER_AGENT]\r\n";
$out .= "Host: $host\r\n";
$out .= "Connection: Close\r\n";
$out .= "Cookie: $cookie\r\n\r\n";
}
$fp = @fsockopen(($ip ? $ip : $host), $port, $errno, $errstr, $timeout);
if(!$fp) return '';
stream_set_blocking($fp, $block);
stream_set_timeout($fp, $timeout);
@fwrite($fp, $out);
$status = stream_get_meta_data($fp);
if($status['timed_out']) return '';
while (!feof($fp)) {
if(($header = @fgets($fp)) && ($header == "\r\n" || $header == "\n")) break;
}
$stop = false;
while(!feof($fp) && !$stop) {
$data = fread($fp, ($limit == 0 || $limit > 8192 ? 8192 : $limit));
$return .= $data;
if($limit) {
$limit -= strlen($data);
$stop = $limit <= 0;
}
}
@fclose($fp);
//部分虚拟主机返回数值有误,暂不确定原因,过滤返回数据格式
$return_arr = explode("\n", $return);
if(isset($return_arr[1])) {
$return = trim($return_arr[1]);
}
unset($return_arr);
return $return;
}
/**
* 过滤字符串
* @param $string
*/
private function _ps_stripslashes($string) {
!defined('MAGIC_QUOTES_GPC') && define('MAGIC_QUOTES_GPC', get_magic_quotes_gpc());
if(MAGIC_QUOTES_GPC) {
return stripslashes($string);
} else {
return $string;
}
}
/**
* 获取当前页面完整URL地址
*/
private function _get_url() {
$sys_protocal = isset($_SERVER['SERVER_PORT']) && $_SERVER['SERVER_PORT'] == '443' ? 'https://' : 'http://';
$php_self = $_SERVER['PHP_SELF'] ? $this->_safe_replace($_SERVER['PHP_SELF']) : $this->_safe_replace($_SERVER['SCRIPT_NAME']);
$path_info = isset($_SERVER['PATH_INFO']) ? $this->_safe_replace($_SERVER['PATH_INFO']) : '';
$relate_url = isset($_SERVER['REQUEST_URI']) ? $this->_safe_replace($_SERVER['REQUEST_URI']) : $php_self.(isset($_SERVER['QUERY_STRING']) ? '?'.$this->_safe_replace($_SERVER['QUERY_STRING']) : $path_info);
return $sys_protocal.(isset($_SERVER['HTTP_HOST']) ? $_SERVER['HTTP_HOST'] : '').$relate_url;
}
/**
* 安全过滤函数
*
* @param $string
* @return string
*/
private function _safe_replace($string) {
$string = str_replace('%20','',$string);
$string = str_replace('%27','',$string);
$string = str_replace('%2527','',$string);
$string = str_replace('*','',$string);
$string = str_replace('"','"',$string);
$string = str_replace("'",'',$string);
$string = str_replace('"','',$string);
$string = str_replace(';','',$string);
$string = str_replace('<','<',$string);
$string = str_replace('>','>',$string);
$string = str_replace("{",'',$string);
$string = str_replace('}','',$string);
return $string;
}
/**
* 判断email格式是否正确
* @param $string email
*/
private function _is_email($email) {
return strlen($email) > 6 && preg_match("/^[\w\-\.]+@[\w\-\.]+(\.\w+)+$/", $email);
}
}
?>
|
108wo
|
phpcms/modules/member/classes/client.class.php
|
PHP
|
asf20
| 13,902
|
<?php
/**
* 管理员后台会员模块设置
*/
defined('IN_PHPCMS') or exit('No permission resources.');
pc_base::load_app_class('admin', 'admin', 0);
pc_base::load_sys_class('format', '', 0);
class member_setting extends admin {
private $db;
function __construct() {
parent::__construct();
$this->db = pc_base::load_model('module_model');
}
/**
* member list
*/
function manage() {
if(isset($_POST['dosubmit'])) {
$member_setting = array2string($_POST['info']);
$this->db->update(array('module'=>'member', 'setting'=>$member_setting), array('module'=>'member'));
setcache('member_setting', $_POST['info']);
showmessage(L('operation_success'), HTTP_REFERER);
} else {
$show_scroll = true;
$member_setting = $this->db->get_one(array('module'=>'member'), 'setting');
$member_setting = string2array($member_setting['setting']);
$email_config = getcache('common', 'commons');
if(empty($email_config['mail_user']) || empty($email_config['mail_password'])) {
$mail_disabled = 1;
}
include $this->admin_tpl('member_setting');
}
}
}
?>
|
108wo
|
phpcms/modules/member/member_setting.php
|
PHP
|
asf20
| 1,154
|
<?php
defined('IN_ADMIN') or exit('No permission resources.');
$defaultvalue = isset($_POST['setting']['defaultvalue']) ? $_POST['setting']['defaultvalue'] : '';
//正整数 UNSIGNED && SIGNED
$minnumber = isset($_POST['setting']['minnumber']) ? $_POST['setting']['minnumber'] : 1;
$decimaldigits = isset($_POST['setting']['decimaldigits']) ? $_POST['setting']['decimaldigits'] : '';
switch($field_type) {
case 'varchar':
if(!$maxlength) $maxlength = 255;
$maxlength = min($maxlength, 255);
$sql = "ALTER TABLE `$tablename` ADD `$field` VARCHAR( $maxlength ) NOT NULL DEFAULT '$defaultvalue'";
$this->db->query($sql);
break;
case 'tinyint':
if(!$maxlength) $maxlength = 3;
$minnumber = intval($minnumber);
$defaultvalue = intval($defaultvalue);
$this->db->query("ALTER TABLE `$tablename` ADD `$field` TINYINT( $maxlength ) ".($minnumber >= 0 ? 'UNSIGNED' : '')." NOT NULL DEFAULT '$defaultvalue'");
break;
case 'number':
$minnumber = intval($minnumber);
$defaultvalue = $decimaldigits == 0 ? intval($defaultvalue) : floatval($defaultvalue);
$sql = "ALTER TABLE `$tablename` ADD `$field` ".($decimaldigits == 0 ? 'INT' : 'FLOAT')." ".($minnumber >= 0 ? 'UNSIGNED' : '')." NOT NULL DEFAULT '$defaultvalue'";
$this->db->query($sql);
break;
case 'smallint':
$minnumber = intval($minnumber);
$this->db->query("ALTER TABLE `$tablename` ADD `$field` SMALLINT ".($minnumber >= 0 ? 'UNSIGNED' : '')." NOT NULL");
break;
case 'int':
$minnumber = intval($minnumber);
$defaultvalue = intval($defaultvalue);
$sql = "ALTER TABLE `$tablename` ADD `$field` INT ".($minnumber >= 0 ? 'UNSIGNED' : '')." NOT NULL DEFAULT '$defaultvalue'";
$this->db->query($sql);
break;
case 'mediumtext':
$this->db->query("ALTER TABLE `$tablename` ADD `$field` MEDIUMTEXT NOT NULL");
break;
case 'text':
$this->db->query("ALTER TABLE `$tablename` ADD `$field` TEXT NOT NULL");
break;
case 'date':
$this->db->query("ALTER TABLE `$tablename` ADD `$field` DATE NULL");
break;
case 'datetime':
$this->db->query("ALTER TABLE `$tablename` ADD `$field` DATETIME NULL");
break;
case 'timestamp':
$this->db->query("ALTER TABLE `$tablename` ADD `$field` TIMESTAMP NOT NULL");
break;
//特殊自定义字段
case 'pages':
$this->db->query("ALTER TABLE `$tablename` ADD `paginationtype` TINYINT( 1 ) NOT NULL DEFAULT '0'");
$this->db->query("ALTER TABLE `$tablename` ADD `maxcharperpage` MEDIUMINT( 6 ) NOT NULL DEFAULT '0'");
break;
case 'readpoint':
$defaultvalue = intval($defaultvalue);
$this->db->query("ALTER TABLE `$tablename` ADD `readpoint` smallint(5) unsigned NOT NULL default '$defaultvalue'");
$this->db->query("ALTER TABLE `$tablename` ADD `paytype` tinyint(1) unsigned NOT NULL default '0'");
break;
}
?>
|
108wo
|
phpcms/modules/member/fields/add.sql.php
|
PHP
|
asf20
| 2,838
|
<?php
$fields = array('text'=>'单行文本',
'textarea'=>'多行文本',
'editor'=>'编辑器',
'box'=>'选项',
'image'=>'图片',
'images'=>'多图片',
'number'=>'数字',
'datetime'=>'日期和时间',
'linkage'=>'联动菜单',
'omnipotent'=>'万能字段',
);
?>
|
108wo
|
phpcms/modules/member/fields/fields.inc.php
|
PHP
|
asf20
| 321
|
<?php
if(!$maxlength) $maxlength = 255;
$maxlength = min($maxlength, 255);
$fieldtype = $issystem ? 'CHAR' : 'VARCHAR';
$sql = "ALTER TABLE `$tablename` CHANGE `$field` `$field` $fieldtype( $maxlength ) NOT NULL DEFAULT '$defaultvalue'";
$db->query($sql);
?>
|
108wo
|
phpcms/modules/member/fields/omnipotent/field_edit.inc.php
|
PHP
|
asf20
| 265
|
function omnipotent($field, $value, $fieldinfo) {
extract($fieldinfo);
$formtext = str_replace('{FIELD_VALUE}',$value,$formtext);
$formtext = str_replace('{MODELID}',$this->modelid,$formtext);
$id = $this->id ? $this->id : 0;
$formtext = str_replace('{ID}',$id,$formtext);
$errortips = $this->fields[$field]['errortips'];
if($errortips && $this->fields[$field]['isbase']) $this->formValidator .= '$("#'.$field.'").formValidator({onshow:"'.$errortips.'",onfocus:"'.$errortips.'"}).inputValidator({min:1,onerror:"'.$errortips.'"});';
return $formtext;
}
|
108wo
|
phpcms/modules/member/fields/omnipotent/form.inc.php
|
PHP
|
asf20
| 581
|
<?php
$db->query("ALTER TABLE `$tablename` DROP `$field`");
?>
|
108wo
|
phpcms/modules/member/fields/omnipotent/field_delete.inc.php
|
PHP
|
asf20
| 65
|
<?php
defined('IN_ADMIN') or exit('No permission resources.');
$field_type = 'varchar'; //字段数据库类型
$field_basic_table = 0; //是否允许作为主表字段
$field_allow_index = 0; //是否允许建立索引
$field_minlength = 0; //字符长度默认最小值
$field_maxlength = ''; //字符长度默认最大值
$field_allow_search = 1; //作为搜索条件
$field_allow_fulltext = 0; //作为全站搜索信息
$field_allow_isunique = 0; //是否允许值唯一
?>
|
108wo
|
phpcms/modules/member/fields/omnipotent/config.inc.php
|
PHP
|
asf20
| 499
|
<table cellpadding="2" cellspacing="1" width="98%">
<tr>
<td width="100">表单</td>
<td><textarea name="setting[formtext]" rows="2" cols="20" id="options" style="height:100px;width:400px;"></textarea><BR>
例如:<input type='text' name='info[voteid]' id='voteid' value='{FIELD_VALUE}' style='50' ></td>
</tr>
<tr>
<td>字段类型</td>
<td>
<select name="setting[fieldtype]" onchange="javascript:fieldtype_setting(this.value);">
<option value="varchar">字符 VARCHAR</option>
<option value="tinyint">整数 TINYINT(3)</option>
<option value="smallint">整数 SMALLINT(5)</option>
<option value="mediumint">整数 MEDIUMINT(8)</option>
<option value="int">整数 INT(10)</option>
</select> <span id="minnumber" style="display:none"><input type="radio" name="setting[minnumber]" value="1" checked/> <font color='red'>正整数</font> <input type="radio" name="setting[minnumber]" value="-1" /> 整数</span>
</td>
</tr>
</table>
|
108wo
|
phpcms/modules/member/fields/omnipotent/field_add_form.inc.php
|
Hack
|
asf20
| 1,017
|
<?php defined('IN_PHPCMS') or exit('No permission resources.');?>
<table cellpadding="2" cellspacing="1" width="98%">
<tr>
<td width="100">表单</td>
<td><textarea name="setting[formtext]" rows="2" cols="20" id="options" style="height:100px;width:400px;"><?php echo $setting['formtext'];?></textarea><BR>
例如:<input type='text' name='info[voteid]' id='voteid' value='{FIELD_VALUE}' style='50' ></td>
</tr>
<tr>
<td>字段类型</td>
<td>
<select name="setting[fieldtype]" onchange="javascript:fieldtype_setting(this.value);">
<option value="varchar" <?php if($setting['fieldtype']=='varchar') echo 'selected';?>>字符 VARCHAR</option>
<option value="tinyint" <?php if($setting['fieldtype']=='tinyint') echo 'selected';?>>整数 TINYINT(3)</option>
<option value="smallint" <?php if($setting['fieldtype']=='smallint') echo 'selected';?>>整数 SMALLINT(5)</option>
<option value="mediumint" <?php if($setting['fieldtype']=='mediumint') echo 'selected';?>>整数 MEDIUMINT(8)</option>
<option value="int" <?php if($setting['fieldtype']=='int') echo 'selected';?>>整数 INT(10)</option>
</select> <span id="minnumber" style="display:none"><input type="radio" name="setting[minnumber]" value="1" <?php if($setting['minnumber']==1) echo 'checked';?>/> <font color='red'>正整数</font> <input type="radio" name="setting[minnumber]" value="-1" <?php if($setting['minnumber']==-1) echo 'checked';?>/> 整数</span>
</td>
</tr>
</table>
|
108wo
|
phpcms/modules/member/fields/omnipotent/field_edit_form.inc.php
|
PHP
|
asf20
| 1,525
|
function linkage($field, $value, $fieldinfo) {
$setting = string2array($fieldinfo['setting']);
$linkageid = $setting['linkageid'];
return menu_linkage($linkageid,$field,$value);
}
|
108wo
|
phpcms/modules/member/fields/linkage/form.inc.php
|
PHP
|
asf20
| 193
|
<?php
defined('IN_ADMIN') or exit('No permission resources.');
$field_type = 'number'; //字段数据库类型
$field_basic_table = 1; //是否允许作为主表字段
$field_allow_index = 1; //是否允许建立索引
$field_minlength = 0; //字符长度默认最小值
$field_maxlength = ''; //字符长度默认最大值
$field_allow_search = 1; //作为搜索条件
$field_allow_fulltext = 0; //作为全站搜索信息
$field_allow_isunique = 1; //是否允许值唯一
?>
|
108wo
|
phpcms/modules/member/fields/linkage/config.inc.php
|
PHP
|
asf20
| 498
|
<table cellpadding="2" cellspacing="1" width="98%">
<tr>
<td>菜单ID</td>
<td><input type="text" id="linkageid" name="setting[linkageid]" value="0" size="5" class="input-text">
<input type='button' value="在列表中选择" onclick="omnipotent('selectid','?m=admin&c=linkage&a=public_get_list','在列表中选择')" class="button">
请到导航 扩展 > 联动菜单 > 添加联动菜单</td>
</tr>
<tr>
<td>显示方式</td>
<td>
<input name="setting[showtype]" value="0" type="radio">
只显示名称
<input name="setting[showtype]" value="1" type="radio">
显示完整路径
<input name="setting[showtype]" value="2" type="radio">
返回菜单id
</td></tr>
<tr>
<td>路径分隔符</td>
<td><input type="text" name="setting[space]" value="" size="5" class="input-text"> 显示完整路径时生效</td>
</tr>
</table>
|
108wo
|
phpcms/modules/member/fields/linkage/field_add_form.inc.php
|
Hack
|
asf20
| 943
|
<?php defined('IN_PHPCMS') or exit('No permission resources.');?>
<table cellpadding="2" cellspacing="1" width="98%">
<tr>
<td>菜单ID</td>
<td><input type="text" id="linkageid" name="setting[linkageid]" value="<?php echo $setting['linkageid'];?>" size="5">
<input type='button' value="在列表中选择" onclick="omnipotent('selectid','?m=admin&c=linkage&a=public_get_list','在列表中选择')" class="button">
请到导航 扩展 > 联动菜单 > 添加联动菜单</td>
</tr>
<tr>
<td>显示方式</td>
<td>
<input name="setting[showtype]" value="0" type="radio" <?php if($setting['showtype']==0) echo 'checked';?>>
只显示名称
<input name="setting[showtype]" value="1" type="radio" <?php if($setting['showtype']==1) echo 'checked';?>>
显示完整路径
<input name="setting[showtype]" value="2" type="radio" <?php if($setting['showtype']==2) echo 'checked';?>>
返回联动菜单id
</td></tr>
<tr>
<td>路径分隔符</td>
<td><input type="text" name="setting[space]" value="<?php echo $setting['space'];?>" size="5" class="input-text"> 显示完整路径时生效</td>
</tr>
</table>
|
108wo
|
phpcms/modules/member/fields/linkage/field_edit_form.inc.php
|
PHP
|
asf20
| 1,218
|
function linkage($field, $value) {
$setting = string2array($this->fields[$field]['setting']);
$datas = getcache($setting['linkageid'],'linkage');
$infos = $datas['data'];
if($setting['showtype']==1) {
$result = $this->_get_parent($value, $setting['linkageid'], $setting['space']);
} elseif($setting['showtype']==2) {
$result = $value;
} else {
$result = $infos[$value]['name'];
}
return $result;
}
function _get_parent($linkageid, $keyid, $space = '>', $result = array(), $infos = array()) {
if($space=='' || !isset($space))$space = '>';
if(!$infos) {
$datas = getcache($keyid,'linkage');
$infos = $datas['data'];
}
if(array_key_exists($linkageid,$infos)) {
$result[]=$infos[$linkageid]['name'];
return $this->_get_parent($infos[$linkageid]['parentid'], $keyid, $space, $result, $infos);
} else {
if(count($result)>0) {
krsort($result);
$result = implode($space,$result);
return $result;
}
else {
return $result;
}
}
}
|
108wo
|
phpcms/modules/member/fields/linkage/output.inc.php
|
PHP
|
asf20
| 1,036
|
function images($field, $value, $fieldinfo) {
extract($fieldinfo);
$list_str = '';
if($value) {
$value = string2array(html_entity_decode($value,ENT_QUOTES));
if(is_array($value)) {
foreach($value as $_k=>$_v) {
$list_str .= "<li id='image{$_k}' style='padding:1px'><input type='text' name='{$field}_url[]' value='{$_v[url]}' style='width:310px;' ondblclick='image_priview(this.value);' class='input-text'> <input type='text' name='{$field}_alt[]' value='{$_v[alt]}' style='width:160px;' class='input-text'> <a href=\"javascript:remove_div('image{$_k}')\">".L('remove')."</a></li>";
}
}
} else {
//$list_str .= "<input type='hidden' name='{$field}_url[]' value='0'>";
$list_str .= "<center><div class='onShow' id='nameTip'>".L('max_upload_num')." <font color='red'>{$upload_number}</font> ".L('zhang')."</div></center>";
}
$string = '<input name="info['.$field.']" type="hidden" value="1">
<fieldset class="blue pad-10">
<legend>'.L('picutre_list').'</legend>';
$string .= $list_str;
$string .= '<ul id="'.$field.'" class="picList"></ul>
</fieldset>
<div class="bk10"></div>
';
if(!defined('IMAGES_INIT')) {
$str = '<script type="text/javascript" src="statics/js/swfupload/swf2ckeditor.js"></script>';
define('IMAGES_INIT', 1);
} else {
$str = '';
}
$authkey = upload_key("$upload_number,$upload_allowext,$isselectimage");
$string .= $str."<div class='picBut cu'><a herf='javascript:void(0);' onclick=\"javascript:flashupload('{$field}_images', '".L('attachment_upload')."','{$field}',change_images,'{$upload_number},{$upload_allowext},{$isselectimage}','member','','{$authkey}')\"/> ".L('select_picture')." </a></div>";
return $string;
}
|
108wo
|
phpcms/modules/member/fields/images/form.inc.php
|
Hack
|
asf20
| 1,750
|
function images($field, $value) {
return string2array($value);
}
|
108wo
|
phpcms/modules/member/fields/images/ouput.inc.php
|
PHP
|
asf20
| 72
|
<?php
defined('IN_ADMIN') or exit('No permission resources.');
$field_type = 'mediumtext'; //字段数据库类型
$field_basic_table = 0; //是否允许作为主表字段
$field_allow_index = 0; //是否允许建立索引
$field_minlength = 0; //字符长度默认最小值
$field_maxlength = ''; //字符长度默认最大值
$field_allow_search = 0; //作为搜索条件
$field_allow_fulltext = 0; //作为全站搜索信息
$field_allow_isunique = 0; //是否允许值唯一
?>
|
108wo
|
phpcms/modules/member/fields/images/config.inc.php
|
PHP
|
asf20
| 502
|
<table cellpadding="2" cellspacing="1" width="98%">
<tr>
<td>允许上传的图片类型</td>
<td><input type="text" name="setting[upload_allowext]" value="gif|jpg|jpeg|png|bmp" size="40" class="input-text"></td>
</tr>
<tr>
<td>是否从已上传中选择</td>
<td><input type="radio" name="setting[isselectimage]" value="1"> 是 <input type="radio" name="setting[isselectimage]" value="0" checked> 否</td>
</tr>
<tr>
<td>允许同时上传的个数</td>
<td><input type="text" name="setting[upload_number]" value="10" size=3></td>
</tr>
</table>
|
108wo
|
phpcms/modules/member/fields/images/field_add_form.inc.php
|
Hack
|
asf20
| 614
|
<?php defined('IN_PHPCMS') or exit('No permission resources.');?>
<table cellpadding="2" cellspacing="1" width="98%">
<tr>
<td>允许上传的图片类型</td>
<td><input type="text" name="setting[upload_allowext]" value="<?php echo $setting['upload_allowext'];?>" size="40" class="input-text"></td>
</tr>
<tr>
<td>是否从已上传中选择</td>
<td><input type="radio" name="setting[isselectimage]" value="1" <?php if($setting['isselectimage']) echo 'checked';?>> 是 <input type="radio" name="setting[isselectimage]" value="0" <?php if(!$setting['isselectimage']) echo 'checked';?>> 否</td>
</tr>
<tr>
<td>允许同时上传的个数</td>
<td><input type="text" name="setting[upload_number]" value="<?php echo $setting['upload_number'];?>" size=3></td>
</tr>
</table>
|
108wo
|
phpcms/modules/member/fields/images/field_edit_form.inc.php
|
PHP
|
asf20
| 840
|
function images($field, $value) {
return string2array($value);
}
|
108wo
|
phpcms/modules/member/fields/images/output.inc.php
|
PHP
|
asf20
| 72
|
function images($field, $value) {
//取得图片列表
$pictures = $_POST[$field.'_url'];
//取得图片说明
$pictures_alt = $_POST[$field.'_alt'];
$array = $temp = array();
if(!empty($pictures)) {
foreach($pictures as $key=>$pic) {
$temp['url'] = $pic;
$temp['alt'] = $pictures_alt[$key];
$array[$key] = $temp;
}
}
$array = array2string($array);
return $array;
}
|
108wo
|
phpcms/modules/member/fields/images/input.inc.php
|
PHP
|
asf20
| 420
|
<?php
if(!$maxlength) $maxlength = 255;
$maxlength = min($maxlength, 255);
$fieldtype = $issystem ? 'CHAR' : 'VARCHAR';
$sql = "ALTER TABLE `$tablename` CHANGE `$field` `$field` $fieldtype( $maxlength ) NOT NULL DEFAULT '$defaultvalue'";
$db->query($sql);
?>
|
108wo
|
phpcms/modules/member/fields/textarea/field_edit.inc.php
|
PHP
|
asf20
| 265
|
function textarea($field, $value, $fieldinfo) {
extract($fieldinfo);
$setting = string2array($setting);
extract($setting);
if(!$value) $value = $defaultvalue;
$allow_empty = 'empty:true,';
if($minlength || $pattern) $allow_empty = '';
if($errortips && $this->fields[$field]['isbase']) $this->formValidator .= '$("#'.$field.'").formValidator({'.$allow_empty.'onshow:"'.$errortips.'",onfocus:"'.$errortips.'"}).inputValidator({min:1,onerror:"'.$errortips.'"});';
$value = empty($value) ? $setting['defaultvalue'] : $value;
return "<textarea name='info[{$field}]' id='$field' style='width:{$width}%;height:{$height}px;' $formattribute $css>{$value}</textarea>";
}
|
108wo
|
phpcms/modules/member/fields/textarea/form.inc.php
|
PHP
|
asf20
| 692
|
<?php
$db->query("ALTER TABLE `$tablename` DROP `$field`");
?>
|
108wo
|
phpcms/modules/member/fields/textarea/field_delete.inc.php
|
PHP
|
asf20
| 65
|
function text($field, $value, $fieldinfo)
{
return form::text($field, $field, $value, 'text', 15);
}
|
108wo
|
phpcms/modules/member/fields/textarea/search_form.inc.php
|
PHP
|
asf20
| 110
|
<?php
defined('IN_ADMIN') or exit('No permission resources.');
$field_type = 'mediumtext'; //字段数据库类型
$field_basic_table = 0; //是否允许作为主表字段
$field_allow_index = 0; //是否允许建立索引
$field_minlength = 0; //字符长度默认最小值
$field_maxlength = ''; //字符长度默认最大值
$field_allow_search = 0; //作为搜索条件
$field_allow_fulltext = 1; //作为全站搜索信息
$field_allow_isunique = 0; //是否允许值唯一
?>
|
108wo
|
phpcms/modules/member/fields/textarea/config.inc.php
|
PHP
|
asf20
| 504
|
<table cellpadding="2" cellspacing="1" width="98%">
<tr>
<td width="100">文本域宽度</td>
<td><input type="text" name="setting[width]" value="100%" size="10" class="input-text" >%</td>
</tr>
<tr>
<td>文本域高度</td>
<td><input type="text" name="setting[height]" value="46" size="10" class="input-text"> px</td>
</tr>
<tr>
<td>默认值</td>
<td><textarea name="setting[defaultvalue]" rows="2" cols="20" id="defaultvalue" style="height:60px;width:250px;" ></textarea></td>
</tr>
<tr>
<td>是否允许Html</td>
<td><input type="radio" name="setting[enablehtml]" value="1"> 是 <input type="radio" name="setting[enablehtml]" value="0" checked> 否</td>
</tr>
</table>
|
108wo
|
phpcms/modules/member/fields/textarea/field_add_form.inc.php
|
Hack
|
asf20
| 762
|
function text($field, $value)
{
return $value === '' ? '' : " `$field` LIKE '%$value%' ";
}
|
108wo
|
phpcms/modules/member/fields/textarea/search.inc.php
|
PHP
|
asf20
| 101
|
<?php defined('IN_PHPCMS') or exit('No permission resources.');?>
<table cellpadding="2" cellspacing="1" width="98%">
<tr>
<td width="100">文本域宽度</td>
<td><input type="text" name="setting[width]" value="<?php echo $setting['width'];?>" size="10" class="input-text" > %</td>
</tr>
<tr>
<td>文本域高度</td>
<td><input type="text" name="setting[height]" value="<?php echo $setting['height'];?>" size="10" class="input-text"> px</td>
</tr>
<tr>
<td>默认值</td>
<td><textarea name="setting[defaultvalue]" rows="2" cols="20" id="defaultvalue" style="height:60px;width:250px;" ><?php echo $setting['defaultvalue'];?></textarea></td>
</tr>
<tr>
<td>是否允许Html</td>
<td><input type="radio" name="setting[enablehtml]" value="1" <?php if($setting['enablehtml']==1) {?>checked<?php }?>> 是 <input type="radio" name="setting[enablehtml]" value="0" <?php if($setting['enablehtml']==0) {?>checked<?php }?>> 否</td>
</tr>
</table>
|
108wo
|
phpcms/modules/member/fields/textarea/field_edit_form.inc.php
|
PHP
|
asf20
| 1,029
|
function textarea($field, $value) {
if(!$this->fields[$field]['enablehtml']) $value = strip_tags($value);
return $value;
}
|
108wo
|
phpcms/modules/member/fields/textarea/input.inc.php
|
PHP
|
asf20
| 133
|
<?php
class member_form {
var $modelid;
var $fields;
var $id;
var $formValidator;
function __construct($modelid) {
$this->modelid = $modelid;
$this->fields = getcache('model_field_'.$modelid,'model');
}
function get($data = array()) {
$_roleid = param::get_cookie('_roleid');
$_groupid = param::get_cookie('_groupid');
$this->data = $data;
if(isset($data['id'])) $this->id = $data['id'];
$info = array();
foreach($this->fields as $field=>$v) {
if(defined('IN_ADMIN')) {
if($v['disabled'] || $v['iscore'] || check_in($_roleid, $v['unsetroleids']) || check_in($_groupid, $v['unsetgroupids'])) continue;
} else {
if($v['disabled'] || $v['iscore'] || !$v['isadd'] || check_in($_roleid, $v['unsetroleids']) || check_in($_groupid, $v['unsetgroupids'])) continue;
}
$func = $v['formtype'];
$value = isset($data[$field]) ? htmlspecialchars($data[$field], ENT_QUOTES) : '';
if($func=='pages' && isset($data['maxcharperpage'])) {
$value = $data['paginationtype'].'|'.$data['maxcharperpage'];
}
if(!method_exists($this, $func)) continue;
$form = $this->$func($field, $value, $v);
if($form !== false) {
$star = $v['minlength'] || $v['pattern'] ? 1 : 0;
$info[$field] = array('name'=>$v['name'], 'tips'=>$v['tips'], 'form'=>$form, 'star'=>$star, 'isbase'=>$v['isbase'],'isomnipotent'=>$v['isomnipotent'],'formtype'=>$v['formtype']);
}
}
return $info;
}
}?>
|
108wo
|
phpcms/modules/member/fields/member_form.class.php
|
PHP
|
asf20
| 1,470
|
function number($field, $value, $fieldinfo) {
extract($fieldinfo);
if(!$value) $value = $defaultvalue;
$errortips = $this->fields[$field]['errortips'];
if($errortips && $this->fields[$field]['isbase']) $this->formValidator .= '$("#'.$field.'").formValidator({onshow:"'.$errortips.'",onfocus:"'.$errortips.'"}).inputValidator({min:'.$minnumber.',max:'.$maxnumber.',onerror:"'.$errortips.'"}).regexValidator({regexp:"num",datatype:"enum",onerror:"'.$errortips.'"});';
return "<input type='text' name='info[$field]' id='$field' value='$value' size='$size' class='input-text' {$formattribute} {$css}>";
}
|
108wo
|
phpcms/modules/member/fields/number/form.inc.php
|
PHP
|
asf20
| 620
|
<?php
defined('IN_ADMIN') or exit('No permission resources.');
$field_type = 'number'; //字段数据库类型
$field_basic_table = 1; //是否允许作为主表字段
$field_allow_index = 1; //是否允许建立索引
$field_minlength = 0; //字符长度默认最小值
$field_maxlength = ''; //字符长度默认最大值
$field_allow_search = 1; //作为搜索条件
$field_allow_fulltext = 0; //作为全站搜索信息
$field_allow_isunique = 1; //是否允许值唯一
?>
|
108wo
|
phpcms/modules/member/fields/number/config.inc.php
|
PHP
|
asf20
| 498
|
<table cellpadding="2" cellspacing="1" width="98%">
<tr>
<td width="100">取值范围</td>
<td><input type="text" name="setting[minnumber]" value="1" size="5" class="input-text"> - <input type="text" name="setting[maxnumber]" value="" size="5" class="input-text"></td>
</tr>
<tr>
<td>小数位数:</td>
<td>
<select name="setting[decimaldigits]">
<option value="-1">自动</option>
<option value="0" selected>0</option>
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
<option value="5">5</option>
</select>
</td>
</tr>
<tr>
<td>默认值</td>
<td><input type="text" name="setting[defaultvalue]" value="<?=$defaultvalue?>" size="40" class="input-text"></td>
</tr>
</table>
|
108wo
|
phpcms/modules/member/fields/number/field_add_form.inc.php
|
PHP
|
asf20
| 849
|
<?php defined('IN_PHPCMS') or exit('No permission resources.');?>
<table cellpadding="2" cellspacing="1" width="98%">
<tr>
<td width="100">取值范围</td>
<td><input type="text" name="setting[minnumber]" value="<?php echo $setting['minnumber'];?>" size="5" class="input-text"> - <input type="text" name="setting[maxnumber]" value="<?php echo $setting['maxnumber'];?>" size="5" class="input-text"></td>
</tr>
<tr>
<td>小数位数:</td>
<td>
<select name="setting[decimaldigits]">
<option value="-1" <?php if($setting['decimaldigits']==-1) echo 'selected';?>)>自动</option>
<option value="0" <?php if($setting['decimaldigits']==0) echo 'selected';?>>0</option>
<option value="1" <?php if($setting['decimaldigits']==1) echo 'selected';?>>1</option>
<option value="2" <?php if($setting['decimaldigits']==2) echo 'selected';?>>2</option>
<option value="3" <?php if($setting['decimaldigits']==3) echo 'selected';?>>3</option>
<option value="4" <?php if($setting['decimaldigits']==4) echo 'selected';?>>4</option>
<option value="5" <?php if($setting['decimaldigits']==5) echo 'selected';?>>5</option>
</select>
</td>
</tr>
<tr>
<td>输入框长度</td>
<td><input type="text" name="setting[size]" value="<?php echo $setting['size'];?>" size="3" class="input-text"> px</td>
</tr>
<tr>
<td>默认值</td>
<td><input type="text" name="setting[defaultvalue]" value="<?php echo $setting['defaultvalue'];?>" size="40" class="input-text"></td>
</tr>
</table>
|
108wo
|
phpcms/modules/member/fields/number/field_edit_form.inc.php
|
PHP
|
asf20
| 1,582
|
function editor($field, $value, $fieldinfo) {
//是否允许用户上传附件 ,后台管理员开启此功能
extract($fieldinfo);
extract(string2array($setting));
$allowupload = defined('IN_ADMIN') ? 1 : 0;
if(!$value) $value = $defaultvalue;
if($minlength || $pattern) $allow_empty = '';
if($errortips) $this->formValidator .= '$("#'.$field.'").formValidator({'.$allow_empty.'onshow:"",onfocus:"'.$errortips.'"}).inputValidator({min:1,onerror:"'.$errortips.'"});';
return "<div id='{$field}_tip'></div>".'<textarea name="info['.$field.']" id="'.$field.'" boxid="'.$field.'">'.$value.'</textarea>'.form::editor($field,$toolbar,'member','','',$allowupload,1,'',300);
}
|
108wo
|
phpcms/modules/member/fields/editor/form.inc.php
|
PHP
|
asf20
| 700
|
<?php
defined('IN_ADMIN') or exit('No permission resources.');
$field_type = 'mediumtext'; //字段数据库类型
$field_basic_table = 0; //是否允许作为主表字段
$field_allow_index = 0; //是否允许建立索引
$field_minlength = 0; //字符长度默认最小值
$field_maxlength = ''; //字符长度默认最大值
$field_allow_search = 0; //作为搜索条件
$field_allow_fulltext = 1; //作为全站搜索信息
$field_allow_isunique = 0; //是否允许值唯一
?>
|
108wo
|
phpcms/modules/member/fields/editor/config.inc.php
|
PHP
|
asf20
| 502
|
<table cellpadding="2" cellspacing="1" width="98%">
<tr>
<td width="100">编辑器样式:</td>
<td><input type="radio" name="setting[toolbar]" value="basic" checked> 简洁型 <input type="radio" name="setting[toolbar]" value="full"> 标准型 </td>
</tr>
<tr>
<td>默认值:</td>
<td><textarea name="setting[defaultvalue]" rows="2" cols="20" id="defaultvalue" style="height:100px;width:250px;"></textarea></td>
</tr>
<tr>
<td>是否启用关联链接:</td>
<td><input type="radio" name="setting[enablekeylink]" value="1"> 是 <input type="radio" name="setting[enablekeylink]" value="0" checked> 否 <input type="text" name="setting[replacenum]" value="1" size="4" class="input-text"> 替换次数 (留空则为替换全部)</td>
</tr>
<tr>
<td>关联链接方式:</td>
<td><input type="radio" name="setting[link_mode]" value="1" <?php if($setting['link_mode']==1) echo 'checked';?>> 关键字链接 <input type="radio" name="setting[link_mode]" value="0" <?php if($setting['link_mode']==0) echo 'checked';?>> 网址链接 </td>
</tr>
<tr>
<td>是否保存远程图片:</td>
<td><input type="radio" name="setting[enablesaveimage]" value="1"> 是 <input type="radio" name="setting[enablesaveimage]" value="0" checked> 否</td>
</tr>
</table>
|
108wo
|
phpcms/modules/member/fields/editor/field_add_form.inc.php
|
PHP
|
asf20
| 1,367
|
<?php defined('IN_PHPCMS') or exit('No permission resources.');?>
<table cellpadding="2" cellspacing="1" width="98%">
<tr>
<td width="100">编辑器样式:</td>
<td><input type="radio" name="setting[toolbar]" value="basic" <?php if($setting['toolbar']=='basic') echo 'checked';?>> <?php echo $setting['toolbar'];?>简洁型 <input type="radio" name="setting[toolbar]" value="full" <?php if($setting['toolbar']=='full') echo 'checked';?>> 标准型 </td>
</tr>
<tr>
<td>默认值:</td>
<td><textarea name="setting[defaultvalue]" rows="2" cols="20" id="defaultvalue" style="height:100px;width:250px;"><?php echo $setting['defaultvalue'];?></textarea></td>
</tr>
<tr>
<td>是否启用关联链接:</td>
<td><input type="radio" name="setting[enablekeylink]" value="1" <?php if($setting['enablekeylink']==1) echo 'checked';?>> 是 <input type="radio" name="setting[enablekeylink]" value="0" <?php if($setting['enablekeylink']==0) echo 'checked';?>> 否 <input type="text" name="setting[replacenum]" value="<?php echo $setting['replacenum'];?>" size="4" class="input-text"> 替换次数 (留空则为替换全部)</td>
</tr>
<tr>
<td>关联链接方式:</td>
<td><input type="radio" name="setting[link_mode]" value="1" <?php if($setting['link_mode']==1) echo 'checked';?>> 关键字链接 <input type="radio" name="setting[link_mode]" value="0" <?php if($setting['link_mode']==0) echo 'checked';?>> 网址链接 </td>
</tr>
<tr>
<td>是否保存远程图片:</td>
<td><input type="radio" name="setting[enablesaveimage]" value="1" <?php if($setting['enablesaveimage']==1) echo 'checked';?>> 是 <input type="radio" name="setting[enablesaveimage]" value="0" <?php if($setting['enablesaveimage']==0) echo 'checked';?>> 否</td>
</tr>
</table>
|
108wo
|
phpcms/modules/member/fields/editor/field_edit_form.inc.php
|
PHP
|
asf20
| 1,862
|
function editor($field, $value) {
$setting = string2array($this->fields[$field]['setting']);
if($setting['enablekeylink']) {
$data = $this->_keylinks($value, $setting['replacenum'],$setting['link_mode']);
}
return $data;
}
function _base64_encode($t,$str) {
return $t."\"".base64_encode($str)."\"";
}
function _base64_decode($t,$str) {
return $t."\"".base64_decode($str)."\"";
}
function _keylinks($txt, $replacenum = '',$link_mode = 1) {
$txt = addslashes($txt);
$search = "/(alt\s*=\s*|title\s*=\s*)[\"|\'](.+?)[\"|\']/ise";
$replace = "$this->_base64_encode('\\1','\\2')";
$replace1 = "$this->_base64_decode('\\1','\\2')";
$txt = preg_replace($search, $replace, $txt);
$keywords = $this->data['keywords'];
if($keywords) $keywords = strpos(',',$keywords) === false ? explode(' ',$keywords) : explode(',',$keywords);
if($link_mode && !empty($keywords)) {
foreach($keywords as $keyword) {
$linkdatas[] = $keyword;
}
} else {
//TODO
$linkdatas = array(
0 => array(0=>'网站',1=>'http://www.phpip.com'),
1 => array(0=>'百度',1=>'http://www.baidu.com'),
);
}
if($linkdatas) {
$word = $replacement = array();
foreach($linkdatas as $v) {
if($link_mode && $keywords) {
$word1[] = '/'.preg_quote($v, '/').'/';
$word2[] = $v;
$replacement[] = '<a href="javascript:;" onclick="show_ajax(this)" class="keylink">'.$v.'</a>';
} else {
$word1[] = '/'.preg_quote($v[0], '/').'/';
$word2[] = $v[0];
$replacement[] = '<a href="'.$v[1].'" target="_blank" class="keylink">'.$v[0].'</a>';
}
}
if($replacenum != '') {
$txt = preg_replace($word1, $replacement, $txt, $replacenum);
} else {
$txt = str_replace($word2, $replacement, $txt);
}
}
$txt = preg_replace($search, $replace1, $txt);
$txt = stripslashes($txt);
return $txt;
}
|
108wo
|
phpcms/modules/member/fields/editor/output.inc.php
|
PHP
|
asf20
| 1,924
|
function editor($field, $value) {
$setting = string2array($this->fields[$field]['setting']);
$enablesaveimage = $setting['enablesaveimage'];
$site_setting = string2array($this->site_config['setting']);
$watermark_enable = intval($site_setting['watermark_enable']);
$value = $this->attachment->download('content', $value,$watermark_enable);
return $value;
}
|
108wo
|
phpcms/modules/member/fields/editor/input.inc.php
|
PHP
|
asf20
| 379
|
<?php
class member_input {
var $modelid;
var $fields;
var $data;
function __construct($modelid) {
$this->db = pc_base::load_model('sitemodel_field_model');
$this->db_pre = $this->db->db_tablepre;
$this->modelid = $modelid;
$this->fields = getcache('model_field_'.$modelid,'model');
//初始化附件类
pc_base::load_sys_class('attachment','',0);
$this->siteid = param::get_cookie('siteid');
$this->attachment = new attachment('content','0',$this->siteid);
}
function get($data) {
$this->data = $data;
$model_cache = getcache('member_model', 'commons');
$this->db->table_name = $this->db_pre.$model_cache[$this->modelid]['tablename'];
$info = array();
$debar_filed = array('catid','title','style','thumb','status','islink','description');
if(!is_array($data)) {
foreach($data as $field=>$value) {
if($data['islink']==1 && !in_array($field,$debar_filed)) continue;
$name = $this->fields[$field]['name'];
$minlength = $this->fields[$field]['minlength'];
$maxlength = $this->fields[$field]['maxlength'];
$pattern = $this->fields[$field]['pattern'];
$errortips = $this->fields[$field]['errortips'];
if(empty($errortips)) $errortips = "$name 不符合要求!";
$length = empty($value) ? 0 : strlen($value);
if($minlength && $length < $minlength && !$isimport) showmessage("$name 不得少于 $minlength 个字符!");
if($maxlength && $length > $maxlength && !$isimport) {
showmessage("$name 不得超过 $maxlength 个字符!");
} else {
str_cut($value, $maxlength);
}
if($pattern && $length && !preg_match($pattern, $value) && !$isimport) showmessage($errortips);
if($this->fields[$field]['isunique'] && $this->db->get_one(array($field=>$value),$field) && ROUTE_A != 'edit') showmessage("$name 的值不得重复!");
$func = $this->fields[$field]['formtype'];
if(method_exists($this, $func)) $value = $this->$func($field, $value);
$info[$field] = $value;
}
}
return $info;
}
}?>
|
108wo
|
phpcms/modules/member/fields/member_input.class.php
|
PHP
|
asf20
| 2,081
|
function image($field, $value, $fieldinfo) {
$setting = string2array($fieldinfo['setting']);
extract($setting);
if(!defined('IMAGES_INIT')) {
$str = '<script type="text/javascript" src="statics/js/swfupload/swf2ckeditor.js"></script>';
define('IMAGES_INIT', 1);
}
$authkey = upload_key("1,$upload_allowext,$isselectimage,$images_width,$images_height");
if($show_type) {
$preview_img = $value ? $value : IMG_PATH.'icon/upload-pic.png';
return $str."<div class='upload-pic img-wrap'><input type='hidden' name='info[$field]' id='$field' value='$value'>
<a href='javascript:;' onclick=\"javascript:flashupload('{$field}_images', '".L('attachment_upload')."','{$field}',thumb_images,'1,$upload_allowext,$isselectimage,$images_width,$images_height','member','','{$authkey}')\">
<img src='$preview_img' id='{$field}_preview' width='135' height='113' style='cursor:hand' /></a></div>";
} else {
return $str."<input type='text' name='info[$field]' id='$field' value='$value' size='$size' class='input-text' /> <input type='button' class='button' onclick=\"javascript:flashupload('{$field}_images', '".L('attachment_upload')."','{$field}',submit_images,'1,{$upload_allowext},$isselectimage,$images_width,$images_height','member','','{$authkey}')\"/ value='".L('image_upload')."'>";
}
}
|
108wo
|
phpcms/modules/member/fields/image/form.inc.php
|
Hack
|
asf20
| 1,333
|
<?php
defined('IN_ADMIN') or exit('No permission resources.');
$field_type = 'varchar'; //字段数据库类型
$field_basic_table = 1; //是否允许作为主表字段
$field_allow_index = 0; //是否允许建立索引
$field_minlength = 0; //字符长度默认最小值
$field_maxlength = ''; //字符长度默认最大值
$field_allow_search = 0; //作为搜索条件
$field_allow_fulltext = 0; //作为全站搜索信息
$field_allow_isunique = 0; //是否允许值唯一
?>
|
108wo
|
phpcms/modules/member/fields/image/config.inc.php
|
PHP
|
asf20
| 499
|