/**
  * 修改
  */
 public function edit()
 {
     $id = (int) $this->input->get('id');
     $data = $this->db->where('id', $id)->limit(1)->get($this->db->dbprefix('space_model'))->row_array();
     if (!$data) {
         $this->admin_msg(lang('019'));
     }
     if (IS_POST) {
         $data = $this->input->post('data', TRUE);
         $this->space_model_model->edit($id, $data);
         /* 更新相关缓存 */
         $this->space_model_model->cache();
         $this->load->model('menu_model');
         $this->menu_model->cache();
         $this->load->model('member_model');
         $this->member_model->cache();
         /* 更新相关缓存 */
         $this->system_log('修改会员空间模型【#' . $data['table'] . '】');
         // 记录日志
         $this->admin_msg(lang('000'), dr_url('member/model/index'), 1);
     }
     $data['setting'] = dr_string2array($data['setting']);
     $this->template->assign(array('data' => $data, 'result' => $result));
     $this->template->display('model_add.html');
 }
Example #2
0
 /**
  * 首页
  */
 public function index()
 {
     $uid = (int) $this->input->get('uid');
     if ($uid) {
         $this->_space($uid);
         // 带会员uid参数时进入会员空间界面
     } else {
         // 登录验证
         $url = MEMBER_URL . SELF . '?c=login&m=index&backurl=' . urlencode(dr_now_url());
         if (!$this->uid) {
             $this->member_msg(lang('m-039') . $this->member_model->logout(), $url);
         }
         /*
         $total = array();
         // 会员模块统计
         $module = $this->get_module(SITE_ID);
         if ($module) {
             $db = $this->site[SITE_ID];
             foreach ($module as $dir => $m) {
                 if (!$this->_module_post_catid($m)) {
                     continue;
                 }
                 $total['name'][] = '"'.$m['name'].'"';
                 $total['total'][] = $db->where('uid', $this->uid)->count_all_results(SITE_ID.'_'.$dir.'_index');
             }
             $total['name'] = @implode(',', $total['name']);
             $total['total'] = @implode(',', $total['total']);
         }
         */
         // 消息提醒
         $notice = array();
         $new_notice = $this->db->where('uid', $this->uid)->count_all_results('member_new_notice');
         if ($new_notice) {
             // 统计未读短消息
             if ($total = $this->db->where('uid', $this->uid)->where('isnew', 1)->count_all_results('pm_members')) {
                 $notice[] = array('name' => '短消息', 'url' => dr_member_url('pm/index'), 'total' => $total);
             }
             // 统计未读系统提醒
             if ($total = $this->db->where('uid', $this->uid)->where('type', 1)->where('isnew', 1)->count_all_results('member_notice_' . (int) $this->member['tableid'])) {
                 $notice[] = array('name' => '系统提醒', 'url' => dr_member_url('notice/index'), 'total' => $total);
             }
             // 统计未读会员提醒
             if ($total = $this->db->where('uid', $this->uid)->where('type', 2)->where('isnew', 1)->count_all_results('member_notice_' . (int) $this->member['tableid'])) {
                 $notice[] = array('name' => '会员互动', 'url' => dr_member_url('notice/member'), 'total' => $total);
             }
             // 统计未读模块提醒
             if ($total = $this->db->where('uid', $this->uid)->where('type', 3)->where('isnew', 1)->count_all_results('member_notice_' . (int) $this->member['tableid'])) {
                 $notice[] = array('name' => '模块提醒', 'url' => dr_member_url('notice/module'), 'total' => $total);
             }
             // 统计未读应用提醒
             if ($total = $this->db->where('uid', $this->uid)->where('type', 4)->where('isnew', 1)->count_all_results('member_notice_' . (int) $this->member['tableid'])) {
                 $notice[] = array('name' => '应用提醒', 'url' => dr_member_url('notice/app'), 'total' => $total);
             }
         }
         $this->template->assign(array('notice' => $notice, 'loginlog' => array_reverse(dr_string2array($this->member['loginlog'])), 'meta_name' => lang('m-012'), 'invite_url' => MEMBER_URL . 'index.php?c=register&uid=' . $this->uid . '&invite=' . $this->member['username'], 'new_notice' => $new_notice));
         $this->template->display(IS_AJAX ? 'main.html' : 'index.html');
     }
 }
Example #3
0
 /**
  * 数据
  *
  * @param	int	$id
  * @return	array
  */
 public function get($id)
 {
     $data = $this->db->where('id', (int) $id)->where('relatedid', $this->relatedid)->where('relatedname', $this->relatedname)->limit(1)->get('field')->row_array();
     if (!$data) {
         return NULL;
     }
     $data['setting'] = dr_string2array($data['setting']);
     return $data;
 }
Example #4
0
 /**
  * 搜索缓存数据
  *
  * @param	intval	$id
  * @param	intval	$page
  * @return	array
  */
 public function get($id, $page = 1)
 {
     $data = $this->link->where('id', $id)->limit(1)->get($this->tablename)->row_array();
     if (!$data) {
         return array();
     }
     $data['params'] = dr_string2array($data['params']);
     return $data;
 }
Example #5
0
 /**
  * 数据显示
  *
  * @param	intval	$uid	uid
  * @param	intval	$page	页数
  * @return	array	
  */
 public function limit_page($uid, $page)
 {
     $members = $touidarr = $tousernamearr = array();
     $data = $this->db->query("SELECT * FROM " . $this->db->dbprefix('pm_members') . " m LEFT JOIN " . $this->db->dbprefix('pm_lists') . " t ON t.plid=m.plid WHERE m.uid={$uid} ORDER BY m.lastdateline DESC LIMIT " . $this->pagesize * ($page - 1) . ", " . $this->pagesize)->result_array();
     foreach ($data as $member) {
         if ($member['pmtype'] == 1) {
             $users = explode('_', $member['min_max']);
             $member['touid'] = $users[0] == $uid ? $users[1] : $users[0];
         } else {
             $member['touid'] = 0;
         }
         $touidarr[$member['touid']] = $member['touid'];
         $members[] = $member;
     }
     $this->db->query("DELETE FROM " . $this->db->dbprefix('newpm') . " WHERE uid={$uid}");
     $array = array();
     if ($members) {
         $today = SYS_TIME - SYS_TIME % 86400;
         foreach ($members as $key => $data) {
             $daterange = 5;
             $data['founddateline'] = $data['dateline'];
             $data['dateline'] = $data['lastdateline'];
             $data['pmid'] = $data['plid'];
             $lastmessage = dr_string2array($data['lastmessage']);
             if ($lastmessage['firstauthorid']) {
                 $data['firstauthorid'] = $lastmessage['firstauthorid'];
                 $data['firstauthor'] = $lastmessage['firstauthor'];
                 $data['firstsummary'] = $lastmessage['firstsummary'];
             }
             if ($lastmessage['lastauthorid']) {
                 $data['lastauthorid'] = $lastmessage['lastauthorid'];
                 $data['lastauthor'] = $lastmessage['lastauthor'];
                 $data['lastsummary'] = $lastmessage['lastsummary'];
             }
             $data['msgfromid'] = $lastmessage['lastauthorid'];
             $data['msgfrom'] = $lastmessage['lastauthor'];
             $data['message'] = $lastmessage['lastsummary'];
             $data['new'] = $data['isnew'];
             $data['msgtoid'] = $data['touid'];
             if ($data['lastdateline'] >= $today) {
                 $daterange = 1;
             } elseif ($data['lastdateline'] >= $today - 86400) {
                 $daterange = 2;
             } elseif ($data['lastdateline'] >= $today - 172800) {
                 $daterange = 3;
             } elseif ($data['lastdateline'] >= $today - 604800) {
                 $daterange = 4;
             }
             $data['daterange'] = $daterange;
             $data['tousername'] = get_member_value($data['touid']);
             unset($data['min_max']);
             $array[] = $data;
         }
     }
     return $array;
 }
 /**
  * 数据
  *
  * @param	int		$id
  * @return	array
  */
 public function get($id)
 {
     $_data = $this->db->limit(1)->where('id', (int) $id)->get('member_group')->row_array();
     if (!$_data) {
         return NULL;
     }
     $_data['allowfield'] = dr_string2array($_data['allowfield']);
     $_data['spacefield'] = dr_string2array($_data['spacefield']);
     return $_data;
 }
Example #7
0
 /**
  * 应用数据
  *
  * @param	string	$dir
  * @return	array
  */
 public function get($dir)
 {
     $data = $this->db->limit(1)->where('dirname', $dir)->get('application')->row_array();
     if (!$data) {
         return NULL;
     }
     $data['module'] = dr_string2array($data['module']);
     $data['setting'] = dr_string2array($data['setting']);
     return $data;
 }
Example #8
0
 /**
  * 查看值
  */
 public function show()
 {
     $id = (int) $this->input->get('id');
     $data = $this->db->where('id', $id)->limit(1)->get('cron_queue')->row_array();
     if (!$data) {
         exit(lang('019'));
     }
     echo '<pre style="width:500px;max-height:400px;overflow:auto;margin-bottom:10px;">';
     print_r(dr_string2array($data['value']));
     echo '</pre>';
 }
Example #9
0
 /**
  * 订单计算价格
  */
 public function price()
 {
     $data = dr_string2array($this->input->get('data'));
     $score = (int) $this->input->get('score');
     // 虚拟币抵消
     if ($data) {
         list($price, $total, $freight) = $this->order_model->get_price($data, $score);
     } else {
         $freight = $price = $total = 0;
     }
     echo $this->input->get('callback') . '(' . json_encode(array('price' => number_format($price, 2), 'total' => number_format($total, 2), 'freight' => number_format($freight, 2))) . ')';
 }
Example #10
0
 /**
  * 配置存/取
  *
  * @param	intval	$name	name值
  * @param	array	$data	修改数据
  * @return	array
  */
 private function config($name, $data = NULL)
 {
     $table = SITE_ID . '_' . APP_DIR . '_config';
     $config = $this->link->where('name', $name)->limit(1)->get($table)->row_array();
     $config = dr_string2array($config['value']);
     if ($data) {
         // 修改数据
         $config = $data;
         $this->link->replace($table, array('name' => $name, 'value' => dr_array2string($data)));
     }
     return $config;
 }
Example #11
0
 /**
  * 会员权限划分
  */
 public function permission()
 {
     $dir = trim(str_replace('.', '', $this->input->get('dir')), '/');
     $file = $this->path . $dir . '/rule.php';
     if (IS_POST) {
         file_put_contents($file, dr_array2string($this->input->post('data')));
         echo dr_json(1, lang('000'));
         exit;
     }
     $this->template->assign('data', is_file($file) ? dr_string2array(file_get_contents($file)) : array());
     $this->template->assign('space', $dir);
     $this->template->display('space_permission.html');
 }
Example #12
0
    /**
     * 字段相关属性参数
     *
     * @param	array	$value	值
     * @param	array	$field	字段集合
     * @return  string
     */
    public function option($option, $field = NULL)
    {
        $group = array();
        $option['value'] = isset($option['value']) ? $option['value'] : '';
        if ($field) {
            foreach ($field as $t) {
                if ($t['fieldtype'] == 'Group') {
                    $t['setting'] = dr_string2array($t['setting']);
                    if (preg_match_all('/\\{(.+)\\}/U', $t['setting']['option']['value'], $value)) {
                        foreach ($value[1] as $v) {
                            $group[] = $v;
                        }
                    }
                }
            }
            $_field = array();
            $_field[] = '<option value=""> -- </option>';
            foreach ($field as $t) {
                if ($t['fieldtype'] != 'Group' && !@in_array($t['fieldname'], $group)) {
                    $_field[] = '<option value="' . $t['fieldname'] . '">' . $t['name'] . '</option>';
                }
            }
            $_field = @implode('', @array_unique($_field));
        }
        return '
				<tr>
                    <th>' . lang('294') . ':</th>
                    <td>
                    <select name="xx" id="fxx">' . $_field . '</select><div class="onShow">' . lang('295') . '</div>
                    </td>
                </tr>
				<tr>
                    <th>' . lang('296') . ':</th>
                    <td>
                    <textarea name="data[setting][option][value]" id="fvalue" style="width:520px;height:120px;" class="text">' . $option['value'] . '</textarea>
					<br><font color="gray">' . lang('297') . '</font>
                    </td>
                </tr>
				<script type="text/javascript">
				$(function() {
					$("#fxx").change(function(){
						var value = $(this).val();
						var fvalue = $("#fvalue").val();
						var text = $("#fxx").find("option:selected").text();
						$("#fxx option[value=\'"+value+"\']").remove();
						$("#fvalue").val(fvalue+"  "+text+": {"+value+"}");
					});
				}); 
				</script>
				';
    }
Example #13
0
 /**
  * 所有数据
  *
  * @return	array
  */
 public function get_data()
 {
     $data = array();
     $_data = $this->link->order_by('displayorder ASC,id ASC')->get($this->tablename)->result_array();
     if (!$_data) {
         return $data;
     }
     foreach ($_data as $t) {
         $t['setting'] = dr_string2array($t['setting']);
         $t['permission'] = dr_string2array($t['permission']);
         $data[$t['id']] = $t;
     }
     return $data;
 }
Example #14
0
 /**
  * 用于商品订单
  */
 public function get_item_data($id)
 {
     if (!$id) {
         return NULL;
     }
     $data1 = $this->link->where('id', $id)->where('status', 9)->where('onsale', 1)->select('id,catid,tableid,title,thumb,price,uid,author,url,quantity,freight')->limit(1)->get($this->prefix)->row_array();
     if (!$data1) {
         return NULL;
     }
     $data2 = $this->link->where('id', $id)->select('discount,format')->limit(1)->get($this->prefix . '_data_' . $data1['tableid'])->row_array();
     $data1['format'] = dr_string2array($data2['format']);
     $data1['discount'] = dr_string2array($data2['discount']);
     return $data1;
 }
Example #15
0
 /**
  * 修改组
  */
 public function edit()
 {
     $id = (int) $this->input->get('id');
     $data = $this->db->where('id', $id)->limit(1)->get($this->db->dbprefix('admin_role'))->row_array();
     if (!$data) {
         exit(lang('019'));
     }
     if (IS_POST) {
         exit(dr_json(1, lang('014'), $this->auth_model->edit_role($data, $this->input->post('data', TRUE))));
     }
     $data['site'] = dr_string2array($data['site']);
     $this->template->assign('data', $data);
     $this->template->display('role_add.html');
 }
 /**
  * 构造函数
  */
 public function __construct()
 {
     parent::__construct();
     $cid = (int) $this->input->get('cid');
     $this->content = $this->content_model->get($cid);
     if (!$this->content) {
         $this->member_msg(lang('019'));
     }
     // 判断具有此栏目的管理权限
     $this->catrule = $this->module_rule[$this->content['catid']];
     $this->content['type'] = dr_string2array($this->content['type']);
     $this->template->assign(array('cid' => $cid, 'catrule' => $this->catrule, 'content' => $this->content));
     $this->load->library('Dfield', array(APP_DIR));
     $this->field = $this->get_cache('module-' . SITE_ID . '-' . APP_DIR, 'extend');
 }
Example #17
0
 /**
  * 修改
  */
 public function edit()
 {
     $id = (int) $this->input->get('id');
     $data = $this->db->where('id', $id)->limit(1)->get('urlrule')->row_array();
     if (!$data) {
         $this->admin_msg(lang('019'));
     }
     if (IS_POST) {
         $this->db->where('id', $id)->update('urlrule', array('name' => $this->input->post('name'), 'value' => dr_array2string($this->input->post('data'))));
         $this->cache(1);
         $this->admin_msg(lang('000'), dr_url('urlrule/index'), 1);
     }
     $data['value'] = dr_string2array($data['value']);
     $this->template->assign(array('data' => $data));
     $this->template->display('urlrule_add.html');
 }
Example #18
0
 /**
  * 修改
  */
 public function edit()
 {
     $id = (int) $this->input->get('id');
     $data = $this->link->where('id', $id)->limit(1)->get($this->table)->row_array();
     if (!$data) {
         $this->admin_msg(lang('019'));
     }
     if (IS_POST) {
         $data = $this->input->post('data', TRUE);
         $this->link->where('id', $id)->update($this->table, array('name' => $data['name'], 'setting' => dr_array2string($data['setting']), 'permission' => dr_array2string($data['permission'])));
         $this->admin_msg(lang('000'), dr_url('mform/index', array('dir' => $this->dir)), 1);
     }
     $data['setting'] = dr_string2array($data['setting']);
     $data['permission'] = dr_string2array($data['permission']);
     $this->template->assign(array('data' => $data));
     $this->template->display('mform_add.html');
 }
Example #19
0
 /**
  * 修改
  */
 public function edit()
 {
     $id = (int) $this->input->get('id');
     $data = $this->db->where('id', $id)->limit(1)->get($this->form_model->prefix)->row_array();
     if (!$data) {
         $this->admin_msg(lang('019'));
     }
     if (IS_POST) {
         $data = $this->input->post('data', TRUE);
         $this->form_model->edit($id, $data);
         $this->form_model->cache();
         $this->admin_msg(lang('000'), dr_url('form/index'), 1);
     }
     $data['setting'] = dr_string2array($data['setting']);
     $this->template->assign(array('menu' => $this->get_menu(array(lang('245') => 'admin/form/index', lang('add') => 'admin/form/add', lang('001') => 'admin/form/cache')), 'data' => $data, 'result' => $result));
     $this->template->display('form_add.html');
 }
Example #20
0
    /**
     * 字段表单输入
     *
     * @param	string	$cname	字段别名
     * @param	string	$name	字段名称
     * @param	array	$cfg	字段配置
     * @param	string	$value	值
     * @return  string
     */
    public function input($cname, $name, $cfg, $value = NULL, $id = 0)
    {
        // 字段显示名称
        $text = (isset($cfg['validate']['required']) && $cfg['validate']['required'] == 1 ? '<font color="red">*</font>' : '') . '&nbsp;' . $cname . ':';
        // 表单附加参数
        $attr = isset($cfg['validate']['formattr']) && $cfg['validate']['formattr'] ? $cfg['validate']['formattr'] : '';
        // 字段提示信息
        $tips = isset($cfg['validate']['tips']) && $cfg['validate']['tips'] ? '<div class="onShow" id="dr_' . $name . '_tips">' . $cfg['validate']['tips'] . '</div>' : '<div class="onTime" id="dr_' . $name . '_tips"></div>';
        // 字段默认值
        $value = is_array($value) ? $value : dr_string2array($value);
        $str = '
		<select name="data[freight][type]">
		<option value="0" ' . (isset($value['type']) && $value['type'] == 0 ? 'selected' : '') . '> 按订单 </option>
		<option value="1" ' . (isset($value['type']) && $value['type'] == 1 ? 'selected' : '') . '> 按数量 </option>
		</select>&nbsp;&nbsp;
		费用:<input type="text" style="width:80px;" value="' . $value['price'] . '" name="data[freight][price]" class="input-text" />&nbsp;&nbsp;
		' . $tips;
        return $this->input_format($name, $text, $str);
    }
Example #21
0
 /**
  * ck播放器接口
  */
 public function ckplayer()
 {
     $at = $this->input->get('at');
     $form = $this->input->get('form');
     $data = array('text' => '', 'api_url' => SITE_URL . 'index.php?c=api&m=ckplayer', 'server_url' => SITE_URL . 'dayrui/ckplayer/');
     // 功能部分
     switch ($at) {
         case 'js':
             // 动态加载js
             //
             $text = $this->get_cache('poster-text-' . SITE_ID);
             if ($text) {
                 // 文字滚动广告
                 $this->load->model('poster_model');
                 $poster = $this->poster_model->poster($text);
                 if ($poster) {
                     $url = $this->poster_model->get_url($poster['id']);
                     $value = dr_string2array($poster['value']);
                     if ($value) {
                         $data['text'] = '{a href="' . $url . '" target="_blank"}{font color="' . $value['color'] . '" size="12"}' . ($value['text'] ? dr_clearhtml($value['text']) : '没有输入广告内容') . '{/font}{/a}';
                     }
                 }
             }
             $code = file_get_contents(FCPATH . 'dayrui/ckplayer/config/config.js');
             break;
         case 'share':
             // 分享
             header('Content-Type: text/xml');
             $code = file_get_contents(FCPATH . 'dayrui/ckplayer/config/share.xml');
             break;
     }
     // 兼容php5.5
     if (version_compare(PHP_VERSION, '5.5.0') >= 0) {
         $rep = new php5replace($data);
         $code = preg_replace_callback('#{([a-z_0-9]+)}#U', array($rep, 'php55_replace_data'), $code);
         unset($rep);
     } else {
         extract($data);
         $code = preg_replace('#{([a-z_0-9]+)}#Ue', "\$\\1", $code);
     }
     exit($code);
 }
Example #22
0
 /**
  * 构造函数
  */
 public function __construct()
 {
     parent::__construct();
     $cid = (int) $this->input->get('cid');
     $catid = (int) $this->input->get('catid');
     $this->content = $this->content_model->get($cid);
     if (!$this->content) {
         $this->admin_msg(lang('019'));
     }
     // 判断管理组是否具有此栏目的管理权限
     $this->catrule = $this->get_cache('module-' . SITE_ID . '-' . APP_DIR, 'category', $this->content['catid'], 'setting', 'admin', $this->admin['adminid']);
     if ($this->admin['adminid'] > 1 && !$this->catrule['show']) {
         $this->admin_msg(lang('257'));
     } else {
         $this->catrule['show'] = $this->catrule['add'] = $this->catrule['edit'] = $this->catrule['del'] = 1;
     }
     $this->load->library('Dfield', array(APP_DIR));
     $this->content['type'] = dr_string2array($this->content['type']);
     $this->sysfield = array('inputtime' => array('name' => lang('104'), 'ismain' => 1, 'fieldtype' => 'Date', 'fieldname' => 'inputtime', 'setting' => array('option' => array('width' => 140), 'validate' => array('formattr' => ''))));
     $field = $this->get_cache('module-' . SITE_ID . '-' . APP_DIR, 'extend');
     $this->field = $field ? array_merge($field, $this->sysfield) : $this->sysfield;
     $this->template->assign(array('cid' => $cid, 'menu' => $this->get_menu(array(lang('mod-29') => APP_DIR . '/admin/extend/index/cid/' . $cid . ($catid ? '/catid/' . $catid : ''), '<font color=red><b>' . lang('mod-37') . '</b></font>' => APP_DIR . '/admin/extend/add/cid/' . $cid . '/catid/' . $catid, lang('mod-36') => APP_DIR . '/admin/home/index/catid/' . $catid)), 'catid' => $catid, 'catrule' => $this->catrule, 'content' => $this->content));
 }
 /**
  * 字段表单输入
  *
  * @param	string	$cname	字段别名
  * @param	string	$name	字段名称
  * @param	array	$cfg	字段配置
  * @param	string	$value	值
  * @return  string
  */
 public function input($cname, $name, $cfg, $value = NULL)
 {
     // 字段显示名称
     $text = (isset($cfg['validate']['required']) && $cfg['validate']['required'] == 1 ? '<font color="red">*</font>' : '') . '&nbsp;' . $cname . ':';
     // 表单附加参数
     $attr = isset($cfg['validate']['formattr']) && $cfg['validate']['formattr'] ? $cfg['validate']['formattr'] : '';
     // 字段提示信息
     $tips = isset($cfg['validate']['tips']) && $cfg['validate']['tips'] ? '<div class="onShow" id="dr_' . $name . '_tips">' . $cfg['validate']['tips'] . '</div>' : '<div class="onTime" id="dr_' . $name . '_tips"></div>';
     // 字段默认值
     if ($value) {
         $value = dr_string2array($value);
     } elseif ($cfg['option']['value']) {
         $value = $this->get_default_value($cfg['option']['value']);
         $value = is_array($value) ? $value : @explode('|', $value);
     } else {
         $value = NULL;
     }
     // 当字段必填时,加入html5验证标签
     if (isset($cfg['validate']['required']) && $cfg['validate']['required'] == 1) {
         $attr .= ' required="required"';
     }
     // 表单选项
     $options = isset($cfg['option']['options']) && $cfg['option']['options'] ? $cfg['option']['options'] : '';
     $str = '';
     if ($options) {
         $options = explode(PHP_EOL, $options);
         foreach ($options as $t) {
             $n = $v = $selected = '';
             list($n, $v) = explode('|', $t);
             $v = is_null($v) ? trim($n) : trim($v);
             $selected = is_array($value) && in_array($v, $value) ? ' checked' : '';
             $str .= '&nbsp;<input type="checkbox" name="data[' . $name . '][]" value="' . $v . '" ' . $selected . ' ' . $attr . ' />&nbsp;' . $n . '&nbsp;&nbsp;';
         }
     }
     $str .= $tips;
     return $this->input_format($name, $text, $str);
 }
Example #24
0
 /**
  * 字段表单输入
  *
  * @param	string	$cname	字段别名
  * @param	string	$name	字段名称
  * @param	array	$cfg	字段配置
  * @param	array	$data	值
  * @return  string
  */
 public function input($cname, $name, $cfg, $value = NULL, $id = 0)
 {
     // 编辑不出现
     if ($id) {
         return;
     }
     // 字段显示名称
     $text = (isset($cfg['validate']['required']) && $cfg['validate']['required'] == 1 ? '<font color="red">*</font>' : '') . '&nbsp;' . $cname . ':';
     // 字段提示信息
     $tips = isset($cfg['validate']['tips']) && $cfg['validate']['tips'] ? '<div class="onShow" id="dr_' . $name . '_tips">' . $cfg['validate']['tips'] . '</div>' : '';
     // 显示框宽度设置
     $width = isset($cfg['option']['width']) && $cfg['option']['width'] ? $cfg['option']['width'] : '80%';
     // 默认值
     $value = IS_POST ? $_POST['data']['syn'] : dr_string2array($value);
     // 查询当前模块是否在其他站点中出现
     $site = $this->ci->get_cache('module');
     unset($site[SITE_ID]);
     //
     $str = '<input type="radio" name="data[' . $name . '][use]" onclick="$(\'#dr_div_syn\').hide()" value="0" ' . (!$value['use'] ? 'checked' : '') . ' />&nbsp;关闭&nbsp;&nbsp;&nbsp;&nbsp;';
     $str .= '<input type="radio" name="data[' . $name . '][use]" onclick="$(\'#dr_div_syn\').show()" value="1" ' . ($value['use'] ? 'checked' : '') . ' />&nbsp;开启';
     $str .= '<div class="dr_format_wrap" id="dr_div_syn" style="margin-top:5px;' . ($value['use'] ? '' : 'display:none') . ';width:' . $width . '">';
     $str .= '<table width="100%">';
     // 查询当前模块是否在其他站点中出现
     if ($site) {
         foreach ($site as $sid => $dirs) {
             if (in_array(APP_DIR, $dirs)) {
                 $str .= '<tr>';
                 $str .= '	<td width=150 align=right>' . dr_strcut($this->ci->SITE[$sid]['SITE_NAME'], 15) . ':</td>';
                 $str .= '	<td>' . $this->ci->select_category($this->ci->get_cache('module-' . $sid . '-' . APP_DIR, 'category'), $value[$sid], ' name=\'data[' . $name . '][' . $sid . ']\'', ' -- ', 1, 1) . '</td>';
                 $str .= '</tr>';
             }
         }
     }
     $str .= '</table>';
     $str .= '</div>';
     return $this->input_format($name, $text, $str . $tips);
 }
 /**
  * 会员权限划分
  */
 public function permission()
 {
     $dir = trim(str_replace('.', '', $this->input->get('dir')), '/');
     $file = $this->path . $dir . '/rule.php';
     if (IS_POST) {
         file_put_contents($file, dr_array2string($this->input->post('data')));
         $this->system_log('会员空间模板的权限划分');
         // 记录日志
         echo dr_json(1, lang('000'));
         exit;
     }
     $data = is_file($file) ? dr_string2array(file_get_contents($file)) : array();
     if ($data && !isset($data[1]['price'])) {
         $temp = array();
         foreach ($data as $i => $t) {
             $temp[$i]['use'] = 0;
             $temp[$i]['price'] = $t;
         }
         $data = $temp;
     }
     $this->template->assign('data', $data);
     $this->template->assign('space', $dir);
     $this->template->display('space_permission.html');
 }
Example #26
0
 /**
  * 更新角色缓存
  *
  * @return	void
  */
 public function role_cache()
 {
     $data = $this->get_admin_role_all();
     if (!$data) {
         return NULL;
     }
     $this->dcache->delete('role');
     $this->ci->clear_cache('role');
     $cahce = array();
     foreach ($data as $t) {
         $t['site'] = dr_string2array($t['site']);
         $t['system'] = dr_string2array($t['system']);
         $t['module'] = dr_string2array($t['module']);
         $t['application'] = dr_string2array($t['application']);
         $cache[$t['id']] = $t;
     }
     $this->dcache->set('role', $cache);
     return $cache;
 }
 /**
  * 模块缓存
  *
  * @param	string	$dirname	模块名称
  * @param	intval	$update		是否更新数量
  * @return	NULL
  */
 public function cache($dirname, $update = 1)
 {
     if (!is_dir(FCPATH . $dirname . '/')) {
         return NULL;
     }
     $data = $this->db->where('disabled', 0)->where('dirname', $dirname)->order_by('displayorder ASC,id ASC')->get('module')->row_array();
     if (!$data) {
         return NULL;
     }
     $config = (require FCPATH . $dirname . '/config/module.php');
     // 配置信息
     $site_domain = (require FCPATH . 'config/domain.php');
     // 加载站点域名配置文件
     $data['site'] = dr_string2array($data['site']);
     $data['setting'] = dr_string2array($data['setting']);
     // 模块表单数据
     $form = array();
     $temp = $this->db->where('disabled', 0)->order_by('id ASC')->get('module_form')->result_array();
     if ($temp) {
         foreach ($temp as $t) {
             $t['field'] = array();
             // 模块表单的自定义字段
             $field = $this->db->where('disabled', 0)->where('relatedid', $t['id'])->where('relatedname', 'mform-' . $data['dirname'])->order_by('displayorder ASC, id ASC')->get('field')->result_array();
             if ($field) {
                 foreach ($field as $f) {
                     $t['field'][$f['fieldname']] = $this->get_field_value($f);
                 }
             }
             $t['setting'] = dr_string2array($t['setting']);
             $t['permission'] = dr_string2array($t['permission']);
             $form[$t['module']][$t['table']] = $t;
         }
     }
     // 按站点生成缓存
     foreach ($this->SITE as $siteid => $t) {
         $cache = $data;
         $this->cache->delete('module-' . $siteid . '-' . $dirname);
         $this->ci->clear_cache('module-' . $siteid . '-' . $dirname);
         if (isset($data['site'][$siteid]['use']) && $data['site'][$siteid]['use']) {
             // 模块域名
             $domain = $data['site'][$siteid]['domain'];
             if ($domain) {
                 $site_domain[$domain] = $siteid;
             }
             // 将站点保存至域名配置文件
             $cache['url'] = $domain ? 'http://' . $domain . '/' : $this->SITE[$siteid]['SITE_URL'] . $dirname . '/';
             // 模块的URL地址
             $cache['html'] = $data['site'][$siteid]['html'];
             $cache['theme'] = $data['site'][$siteid]['theme'];
             $cache['domain'] = $data['site'][$siteid]['domain'];
             $cache['template'] = $data['site'][$siteid]['template'];
             // 非主站开启静态生成时,创建新的入口文件
             if ($cache['html'] && $siteid > 1) {
                 $path = FCPATH . $cache['dirname'] . '/html/' . $siteid;
                 if (!file_exists($path)) {
                     dr_mkdirs($path, TRUE);
                 }
                 copy(FCPATH . $cache['dirname'] . '/html.php', $path . '/index.php');
             }
             // 系统模块格式
             if (!isset($config['mydb']) || !$config['mydb']) {
                 // 模块的自定义字段
                 $field = $this->db->where('disabled', 0)->where('relatedid', $data['id'])->where('relatedname', 'module')->order_by('displayorder ASC, id ASC')->get('field')->result_array();
                 if ($field) {
                     foreach ($field as $f) {
                         $cache['field'][$f['fieldname']] = $this->get_field_value($f);
                     }
                 } else {
                     $cache['field'] = array();
                 }
                 // 模块扩展的自定义字段
                 if ($data['extend']) {
                     $field = $this->db->where('disabled', 0)->where('relatedid', $data['id'])->where('relatedname', 'extend')->order_by('displayorder ASC, id ASC')->get('field')->result_array();
                     $cache['extend'] = array();
                     if ($field) {
                         foreach ($field as $f) {
                             $cache['extend'][$f['fieldname']] = $this->get_field_value($f);
                         }
                     }
                 } else {
                     $cache['extend'] = 0;
                 }
                 // 模块表单归类
                 $cache['form'] = isset($form[$dirname]) ? $form[$dirname] : array();
                 // 模块表创建统计字段
                 if ($cache['form']) {
                     foreach ($cache['form'] as $fm) {
                         $this->system_model->create_form_total_field($siteid, $dirname, $fm['table'], 1);
                     }
                 }
                 // 模块的栏目分类
                 $category = $this->site[$siteid]->order_by('displayorder ASC, id ASC')->get($siteid . '_' . $dirname . '_category')->result_array();
                 if ($category) {
                     $CAT = $CAT_DIR = $level = array();
                     foreach ($category as $c) {
                         if ($update == 1) {
                             if (!$c['child']) {
                                 $c['total'] = $this->site[$siteid]->where('status', 9)->where('catid', $c['id'])->count_all_results($siteid . '_' . $dirname . '_index');
                             } else {
                                 $c['total'] = 0;
                             }
                         } else {
                             $c['total'] = $this->ci->get_cache('module-' . SITE_ID . '-' . APP_DIR, 'category', $c['id'], 'total');
                         }
                         $pid = explode(',', $c['pids']);
                         $level[] = substr_count($c['pids'], ',');
                         $c['topid'] = isset($pid[1]) ? $pid[1] : $c['id'];
                         $c['catids'] = explode(',', $c['childids']);
                         $c['setting'] = dr_string2array($c['setting']);
                         $c['permission'] = $c['child'] ? '' : dr_string2array($c['permission']);
                         $c['url'] = isset($c['setting']['linkurl']) && $c['setting']['linkurl'] ? $c['setting']['linkurl'] : dr_category_url($cache, $c);
                         // 删除过期的部分
                         unset($c['setting']['urlmode']);
                         unset($c['setting']['url']);
                         $CAT[$c['id']] = $c;
                         $CAT_DIR[$c['dirname']] = $c['id'];
                     }
                     // 更新父栏目数量
                     if ($update == 1) {
                         foreach ($category as $c) {
                             if ($c['child']) {
                                 $arr = explode(',', $c['childids']);
                                 $CAT[$c['id']]['total'] = 0;
                                 foreach ($arr as $i) {
                                     $CAT[$c['id']]['total'] += $CAT[$i]['total'];
                                 }
                             }
                         }
                     }
                     // 栏目自定义字段,把父级栏目的字段合并至当前栏目
                     $field = $this->db->where('disabled', 0)->where('relatedname', $dirname . '-' . $siteid)->order_by('displayorder ASC, id ASC')->get('field')->result_array();
                     if ($field) {
                         foreach ($field as $f) {
                             if (isset($CAT[$f['relatedid']]['childids']) && $CAT[$f['relatedid']]['childids']) {
                                 // 将该字段同时归类至其子栏目
                                 $child = explode(',', $CAT[$f['relatedid']]['childids']);
                                 foreach ($child as $catid) {
                                     if ($CAT[$catid]) {
                                         $CAT[$catid]['field'][$f['fieldname']] = $this->get_field_value($f);
                                     }
                                 }
                             }
                         }
                     }
                     $cache['category'] = $CAT;
                     $cache['category_dir'] = $CAT_DIR;
                     $cache['category_field'] = $field ? 1 : 0;
                     $cache['category_level'] = $level ? max($level) : 0;
                 } else {
                     $cache['category'] = array();
                     $cache['category_dir'] = array();
                     $cache['category_field'] = $cache['category_level'] = 0;
                 }
                 $cache['is_system'] = 1;
             } else {
                 $cache['is_system'] = 0;
             }
             // 模块名称
             $name = $this->db->select('name')->where('pid', 0)->where('mark', 'module-' . $dirname)->limit(1)->get('admin_menu')->row_array();
             $cache['name'] = $name['name'] ? $name['name'] : $config['name'];
             $this->dcache->set('module-' . $siteid . '-' . $dirname, $cache);
         }
     }
     $this->load->library('dconfig');
     $this->dconfig->file(FCPATH . 'config/domain.php')->note('站点域名文件')->space(32)->to_require_one($site_domain);
 }
Example #28
0
 /**
  * 生成缓存
  * 
  * @return	void
  */
 public function cache($siteid = SITE_ID)
 {
     $siteid = $siteid ? $siteid : SITE_ID;
     $this->dcache->delete('form-' . $siteid);
     $form = $this->db->get($this->prefix)->result_array();
     if (!$form) {
         return NULL;
     }
     $cache = array();
     foreach ($form as $t) {
         $data = $this->db->where('disabled', 0)->where('relatedid', (int) $t['id'])->where('relatedname', 'form-' . $siteid)->order_by('displayorder ASC,id ASC')->get('field')->result_array();
         if ($data) {
             foreach ($data as $field) {
                 $field['setting'] = dr_string2array($field['setting']);
                 $t['field'][$field['fieldname']] = $field;
             }
         }
         $t['setting'] = dr_string2array($t['setting']);
         $cache[$t['id']] = $t;
     }
     $this->ci->clear_cache('form-' . $siteid);
     $this->dcache->set('form-' . $siteid, $cache);
     return $cache;
 }
Example #29
0
 /**
  * 字段表单输入
  *
  * @param	string	$cname	字段别名
  * @param	string	$name	字段名称
  * @param	array	$cfg	字段配置
  * @param	string	$value	值
  * @return  string
  */
 public function input($cname, $name, $cfg, $value = NULL, $id = 0)
 {
     // 字段显示名称
     $text = (isset($cfg['validate']['required']) && $cfg['validate']['required'] == 1 ? '<font color="red">*</font>' : '') . '&nbsp;' . $cname . ':';
     // 表单附加参数
     $attr = isset($cfg['validate']['formattr']) && $cfg['validate']['formattr'] ? $cfg['validate']['formattr'] : '';
     // 字段提示信息
     $tips = isset($cfg['validate']['tips']) && $cfg['validate']['tips'] ? '<div class="onShow" id="dr_' . $name . '_tips">' . $cfg['validate']['tips'] . '</div>' : '';
     // 字段默认值
     if ($value) {
         $value = dr_string2array($value);
     } elseif ($cfg['option']['value']) {
         $value = $this->get_default_value($cfg['option']['value']);
         $value = is_array($value) ? $value : @explode('|', $value);
     } else {
         $value = NULL;
     }
     $str = '';
     // 禁止修改
     if (!IS_ADMIN && $id && $value && isset($cfg['validate']['isedit']) && $cfg['validate']['isedit']) {
         $attr .= ' disabled';
     }
     // 表单选项
     $options = isset($cfg['option']['options']) && $cfg['option']['options'] ? $cfg['option']['options'] : '';
     if ($options) {
         $options = explode(PHP_EOL, str_replace(array(chr(13), chr(10)), PHP_EOL, $options));
         foreach ($options as $t) {
             if ($t) {
                 $n = $v = $selected = '';
                 list($n, $v) = explode('|', $t);
                 $v = is_null($v) ? trim($n) : trim($v);
                 $selected = is_array($value) && in_array($v, $value) ? ' checked' : '';
                 $str .= '&nbsp;<input type="checkbox" name="data[' . $name . '][]" value="' . $v . '" ' . $selected . ' ' . $attr . ' />&nbsp;<label>' . $n . '</label>&nbsp;&nbsp;&nbsp;';
             }
         }
     }
     $str .= $tips;
     return $this->input_format($name, $text, $str);
 }
Example #30
0
 public function cache()
 {
     $data = $this->get_site_data();
     $oldfile = directory_map(FCPATH . 'config/site/');
     foreach ($oldfile as $file) {
         @unlink(FCPATH . 'config/site/' . $file);
     }
     $cache = $domain = array();
     $this->load->library('dconfig');
     $this->ci->dcache->delete('siteinfo');
     // 站点域名归类和写入配置文件
     foreach ($data as $id => $t) {
         // 站点域名归类
         if ($t['domain']) {
             $domain[$t['domain']] = $id;
         }
         // 移动端域名归类
         if ($t['setting']['SITE_MOBILE']) {
             $domain[$t['setting']['SITE_MOBILE']] = $id;
         }
         // 写入配置文件
         $this->dconfig->file(FCPATH . 'config/site/' . $id . '.php')->note('站点配置文件')->space(32)->to_require_one($this->config, $t['setting']);
         // 写入缓存文件
         $cache[$id] = $t['setting'];
     }
     $this->ci->dcache->set('siteinfo', $cache);
     // 查询所有可用模块
     $data = $this->db->where('disabled', 0)->select('site,dirname')->order_by('displayorder ASC')->get('module')->result_array();
     if ($data) {
         $module = array();
         foreach ($data as $t) {
             // 排除不存在的模块
             if (!is_dir(FCPATH . $t['dirname'])) {
                 continue;
             }
             // 排除自定义数据的模块
             $cfg = (require FCPATH . $t['dirname'] . '/config/module.php');
             if (isset($cfg['mydb']) && $cfg['mydb']) {
                 continue;
             }
             // 模块域名归类
             $site = dr_string2array($t['site']);
             foreach ($site as $sid => $s) {
                 if ($s['use']) {
                     if ($s['domain']) {
                         $domain[$s['domain']] = $sid;
                         // 更新模块域名
                     }
                     $module[$sid][] = $t['dirname'];
                     // 将模块归类至站点
                 }
             }
         }
         $this->ci->dcache->set('module', $module);
     } else {
         $this->ci->dcache->delete('module');
     }
     // 会员域名归类
     $data = $this->db->where('name', 'domain')->limit(1)->get('member_setting')->row_array();
     if ($data) {
         $data = dr_string2array($data['value']);
         foreach ($data as $sid => $url) {
             $domain[$url] = $sid;
         }
     }
     // 生成站点域名归属
     $this->dconfig->file(FCPATH . 'config/domain.php')->note('站点域名文件')->space(32)->to_require_one($domain);
 }