/** * 目录扫描 * * @param string $source_dir Path to source * @param int $directory_depth Depth of directories to traverse * (0 = fully recursive, 1 = current dir, etc) * @param bool $hidden Whether to show hidden files * @return array */ function dr_dir_map($source_dir, $directory_depth = 0, $hidden = FALSE) { if ($fp = @opendir($source_dir)) { $filedata = array(); $new_depth = $directory_depth - 1; $source_dir = rtrim($source_dir, DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR; while (FALSE !== ($file = readdir($fp))) { if ($file === '.' or $file === '..' or $hidden === FALSE && $file[0] === '.' or !@is_dir($source_dir . $file)) { continue; } if (($directory_depth < 1 or $new_depth > 0) && @is_dir($source_dir . $file)) { $filedata[$file] = dr_dir_map($source_dir . DIRECTORY_SEPARATOR . $file, $new_depth, $hidden); } else { $filedata[] = $file; } } closedir($fp); return $filedata; } return FALSE; }
/** * 修改 */ public function edit() { $id = (int) $this->input->get('id'); $data = $this->group_model->get($id); if (!$data) { $this->admin_msg(lang('019')); } $page = (int) $this->input->get('page'); $error = 0; if (IS_POST) { $post = $this->input->post('data', TRUE); $page = (int) $this->input->post('page'); if (!$data['name']) { $error = lang('m-033'); } else { $this->group_model->edit($id, $post); $this->clear_cache('member'); $this->admin_msg(lang('014'), dr_url('member/group/index'), 1); } } $group = $this->get_cache('member', 'group'); $overdue = array(); foreach ($group as $t) { if ($t['id'] > 2 && $t['price'] == 0) { $overdue[] = array('id' => $t['id'], 'name' => $t['name']); } } $this->template->assign(array('page' => $page, 'data' => $data, 'error' => $error, 'group' => $group, 'space' => array_diff(dr_dir_map(FCPATH . 'member/templates/', 1), array('admin', 'member')), 'theme' => array_diff(dr_dir_map(FCPATH . 'member/statics/', 1), array('avatar', 'js', 'OAuth', 'emotions')), 'overdue' => $overdue, 'mtemplate' => array_diff(dr_dir_map(FCPATH . 'member/templates/member/', 1), array('admin')))); $this->template->display('group_add.html'); }
/** * 商店 */ public function store() { $data = array(); $local = dr_dir_map(FCPATH . 'app/', 1); // 搜索本地应用 if ($local) { foreach ($local as $dir) { if (is_file(FCPATH . 'app/' . $dir . '/config/app.php')) { $config = (require FCPATH . 'app/' . $dir . '/config/app.php'); if ($config['key']) { $data[$config['key']] = $config['version']; } } } } $url = 'http://store.dayrui.com/index.php?c=category&id=1&action=application¶m=' . dr_base64_encode(dr_array2string(array('site' => SITE_URL, 'name' => SITE_NAME, 'data' => $data, 'admin' => SELF, 'version' => DR_VERSION_ID))); $this->template->assign(array('url' => $url)); $this->template->display('online.html'); }
/** * 模块商店 */ public function store() { $data = array(); $local = @array_diff(dr_dir_map(FCPATH, 1), array('app', 'cache', 'config', 'omweb', 'member', 'space', 'player')); // 搜索本地模块 if ($local) { foreach ($local as $dir) { if (is_file(FCPATH . $dir . '/config/module.php')) { $config = (require FCPATH . $dir . '/config/module.php'); if ($config['key']) { $data[$config['key']] = $config['version']; } } } } // // $url = 'http://store.omooo.com/index.php?c=category&id=3&action=module¶m='.dr_base64_encode(dr_array2string(array( // 'site' => SITE_URL, // 'name' => SITE_NAME, // 'data' => $data, // 'admin' => SELF, // 'version' => DR_VERSION_ID, // ))); // // $this->template->assign(array( // 'url' => $url, // )); $this->template->display('online.html'); }
/** * 后台首页 */ public function main() { // 首次安装系统-跳转到欢迎界面-并安装默认模块 if ($this->dcache->get('install')) { $this->admin_msg('首次安装系统,正在为您安装模块初始化数据', dr_url('home/init'), 2); exit; } $store = array(); // 搜索本地模块 $local = @array_diff(dr_dir_map(FCPATH, 1), array('app', 'cache', 'config', 'dayrui', 'member', 'space', 'player')); if ($local) { foreach ($local as $dir) { if (is_file(FCPATH . $dir . '/config/module.php')) { $config = (require FCPATH . $dir . '/config/module.php'); if ($config['key']) { if (isset($store[$config['key']])) { if (version_compare($config['version'], $store[$config['key']], '<')) { $store[$config['key']] = $config['version']; } } else { $store[$config['key']] = $config['version']; } } } } } // 搜索本地应用 $local = dr_dir_map(FCPATH . 'app/', 1); if ($local) { foreach ($local as $dir) { if (is_file(FCPATH . 'app/' . $dir . '/config/app.php')) { $config = (require FCPATH . 'app/' . $dir . '/config/app.php'); if ($config['key']) { $store[$config['key']] = $config['version']; } } } } // 判断管理员ip状况 $ip = ''; $login = $this->db->where('uid', $this->uid)->order_by('logintime desc')->limit(2)->get('admin_login')->result_array(); if ($login && count($login) == 2 && $login[0]['loginip'] != $login[1]['loginip']) { $this->load->library('dip'); $now = $this->dip->address($login[0]['loginip']); $last = $this->dip->address($login[1]['loginip']); if (@strpos($now, $last) === FALSE && @strpos($last, $now) === FALSE) { // Ip异常判断 $ip = dr_lang('html-022', $login[1]['loginip'], $last, dr_url('root/log', array('uid' => $this->uid))); } } // 统计模块数据 $total = array(); $module = $this->get_module(SITE_ID); if ($module) { // 查询模块的菜单 $top = array(); $menu = $this->db->where('pid=0')->where('hidden', 0)->order_by('displayorder ASC,id ASC')->get('admin_menu')->result_array(); if ($menu) { foreach ($menu as $t) { list($a, $dir) = @explode('-', $t['mark']); if ($dir && !$module[$dir]) { continue; } $top[$dir] = $t['id']; } } // 判断审核权限 if ($this->admin['adminid'] != 1) { $my = $this->_get_verify(); $my = $my[$this->admin['adminid']]; } foreach ($module as $dir => $mod) { // 判断模块表是否存在 if (!$this->site[SITE_ID]->query("SHOW TABLES LIKE '%" . $this->db->dbprefix(SITE_ID . '_' . $dir . '_verify') . "%'")->row_array()) { continue; } // $topid = intval($top[$dir]); $total[$dir] = array('name' => $mod['name'], 'today' => $this->_set_k_url($topid, dr_url($dir . '/home/index')), 'content' => $this->_set_k_url($topid, dr_url($dir . '/home/index')), 'content_verify' => $this->_set_k_url($topid, dr_url($dir . '/home/verify')), 'extend_verify' => 'javascript:;', 'add' => $this->_set_k_url($topid, dr_url($dir . '/home/add')), 'url' => $mod['url']); if ($this->admin['adminid'] == 1) { // 扩展审核数据 if (is_file(FCPATH . $dir . '/config/extend.main.table.php')) { $total[$dir]['extend_verify'] = $this->_set_k_url($topid, dr_url($dir . '/verify/index')); } } else { if (!$my) { continue; } if (is_file(FCPATH . $dir . '/config/extend.main.table.php')) { $total[$dir]['extend_verify'] = $this->_set_k_url($topid, dr_url($dir . '/verify/index')); } } } $total['member'] = array('name' => lang('364'), 'today' => $this->_set_k_url(3, dr_url('member/home/index')), 'content' => $this->_set_k_url(3, dr_url('member/home/index')), 'content_verify' => $this->_set_k_url(3, dr_url('member/home/index')), 'extend_verify' => 'javascript:;', 'add' => $this->_set_k_url(3, dr_url('member/home/index')), 'url' => $this->_set_k_url(3, dr_url('member/home/index'))); } $this->template->assign(array('ip' => $ip, 'sip' => $this->_get_server_ip(), 'store' => dr_base64_encode(dr_array2string($store)), 'mtotal' => $total, 'sqlversion' => $this->db->version())); $this->template->display('main.html'); }
/** * 应用缓存 */ public function cache() { $cache = array(); // 删除应用缓存 $this->dcache->delete('app'); // 搜索本地应用 $local = dr_dir_map(FCPATH . 'app/', 1); if ($local) { foreach ($local as $dir) { if (is_file(FCPATH . 'app/' . $dir . '/config/app.php') && $this->db->where('dirname', $dir)->where('disabled', 0)->count_all_results('application')) { // 保存缓存 $cache[] = $dir; } else { // 删除菜单 $this->db->where('mark', 'app-' . $dir)->delete('admin_menu'); $this->db->where('mark', 'app-' . $dir)->delete('member_menu'); } } } $this->dcache->set('app', $cache); return $cache; }
/** * 站点配置 */ public function config() { $id = isset($_GET['id']) ? max((int) $_GET['id'], 1) : SITE_ID; $data = $this->site_model->get_site_info($id); if (!$data) { $this->admin_msg(dr_lang('062', $id)); } $result = ''; if (IS_POST) { $cfg = $this->input->post('data'); $cfg['SITE_DOMAIN'] = $this->input->post('domain'); // 查询非当前站点绑定的域名 $as = array(); $all = $this->db->where('id<>', $id)->get('site')->result_array(); if ($all) { foreach ($all as $b) { $set = dr_string2array($b['setting']); $as[] = $b['domain']; if ($set['SITE_MOBILE']) { $as[] = $set['SITE_MOBILE']; } if ($set['SITE_DOMAINS']) { $_arr = @explode(',', $set['SITE_DOMAINS']); if ($_arr) { foreach ($_arr as $_a) { if ($_a) { $as[] = $_a; } } } } } } // 判断域名是否可用 if (in_array($cfg['SITE_DOMAIN'], $as)) { $result = dr_lang('249', $cfg['SITE_DOMAIN']); } else { $cfg['SITE_DOMAINS'] = str_replace(PHP_EOL, ',', $cfg['SITE_DOMAINS']); // 多域名验证 if ($cfg['SITE_DOMAINS']) { $arr = @explode(',', $cfg['SITE_DOMAINS']); if ($arr) { foreach ($arr as $a) { if (in_array($a, $as) || $a == $cfg['SITE_DOMAIN'] || $a == $cfg['SITE_MOBILE']) { $result = dr_lang('249', $a); break; } } } } if (!$result) { $cfg['SITE_NAVIGATOR'] = @implode(',', $this->input->post('navigator', TRUE)); $data = array('name' => $cfg['SITE_NAME'], 'domain' => $cfg['SITE_DOMAIN'], 'setting' => $cfg); $this->site_model->edit_site($id, $data); $domain = (require FCPATH . 'config/domain.php'); $domain[$cfg['SITE_DOMAIN']] = $id; if ($cfg['SITE_MOBILE']) { $domain[$cfg['SITE_MOBILE']] = $id; } $this->dconfig->file(FCPATH . 'config/site/' . $id . '.php')->note('站点配置文件')->space(32)->to_require_one($this->site_model->config, $cfg); $this->dconfig->file(FCPATH . 'config/domain.php')->note('站点域名文件')->space(32)->to_require_one($domain); $result = 1; } } $data = $cfg; $this->site_model->cache(); } $this->load->helper('directory'); $files = directory_map(FCPATH . 'dayrui/statics/watermark/', 1); $opacity = array(); foreach ($files as $t) { if (substr($t, -3) == 'ttf') { $font[] = $t; } else { $opacity[] = $t; } } $data['SITE_ATTACH_REMOTE'] = (int) $data['SITE_ATTACH_REMOTE']; $this->template->assign(array('id' => $id, 'ip' => $this->_get_server_ip(), 'data' => $data, 'page' => max((int) $this->input->post('page'), 0), 'lang' => dr_dir_map(FCPATH . 'dayrui/language/', 1), 'theme' => array_diff(dr_dir_map(FCPATH . 'dayrui/statics/', 1), array('css', 'images', 'watermark')), 'result' => $result, 'navigator' => @explode(',', $data['SITE_NAVIGATOR']), 'wm_opacity' => $opacity, 'remote_type' => array(0 => lang('close'), 1 => 'FTP', 2 => '百度云存储BCS', 3 => '阿里云存储OSS'), 'wm_font_path' => $font, 'template_path' => array_diff(dr_dir_map(FCPATH . 'dayrui/templates/', 1), array('api', 'admin')), 'wm_vrt_alignment' => array('top', 'middle', 'bottom'), 'wm_hor_alignment' => array('left', 'center', 'right'))); $this->template->display('site_config.html'); }
/** * 应用缓存 */ public function cache() { $cache = array(); // 删除应用缓存 $this->dcache->delete('app'); // 搜索本地应用 $local = dr_dir_map(FCPATH . 'app/', 1); if ($local) { $link = $this->dcache->get('link'); $role = $this->db->where('id>1')->get('admin_role')->result_array(); $role_cache = 0; foreach ($local as $dir) { $app = $this->db->where('dirname', $dir)->where('disabled', 0)->get('application')->row_array(); if (is_file(FCPATH . 'app/' . $dir . '/config/app.php') && $app) { // 保存缓存 $cache[] = $dir; $menu = $this->db->where('pid', 75)->where('mark', 'app-' . $dir)->get('admin_menu')->row_array(); if ($menu['hidden'] !== 0) { $this->db->where('id', $menu['id'])->update('admin_menu', array('hidden' => 0)); } //同步到角色组权限 if ($role && $menu) { foreach ($role as $t) { $cfg = dr_string2array($app['setting']); $auth = dr_string2array($t['system']); if ($cfg['admin'][$t['id']]) { if (!in_array($menu['uri'], $auth)) { $auth[] = $menu['uri']; $this->db->where('id', $t['id'])->update('admin_role', array('system' => dr_array2string($auth))); $role_cache = 1; } } else { if (in_array($menu['uri'], $auth)) { $temp = array_flip($auth); unset($temp[$menu['uri']]); $this->db->where('id', $t['id'])->update('admin_role', array('system' => dr_array2string(array_flip($temp)))); $role_cache = 1; } } } } if ($role_cache) { $this->load->model('auth_model'); $this->auth_model->role_cache(); } } else { // 删除菜单 $this->db->where('mark', 'app-' . $dir)->delete('admin_menu'); $this->db->where('mark', 'app-' . $dir)->delete('member_menu'); } } } $this->dcache->set('app', $cache); return $cache; }
/** * 空间模板 */ public function template() { $style = $this->input->get('style'); if ($style && $this->space['style'] != $style) { $rule = dr_string2array(@file_get_contents(FCPATH . 'member/templates/space/' . $style . '/rule.php')); if ($style == 'default' || isset($rule[$this->markrule]['use']) && $rule[$this->markrule]['use']) { // 判断是否购买过 $price = isset($rule[$this->markrule]['price']) ? intval($rule[$this->markrule]['price']) : 0; if ($price && $style != 'default' && !$this->db->where('type', 1)->where('uid', $this->uid)->where('mark', 'space-tpl-' . $style)->count_all_results('member_scorelog_' . $this->member['tableid'])) { // 未购买时,进行购买操作 if ($this->member['score'] - $price < 0) { $this->member_msg(dr_lang('m-215', $price, $this->member['score'])); } $this->member_model->update_score(1, $this->uid, -$price, 'space-tpl-' . $style, 'lang,m-216'); } $this->db->where('uid', (int) $this->uid)->update('space', array('style' => $style)); $this->member_msg(lang('m-319'), dr_member_url('space/template'), 1); } else { $this->member_msg(lang('m-320')); } } $my = $list = array(); $data = dr_dir_map(FCPATH . 'member/templates/space/', 1); if ($data) { foreach ($data as $dir) { $tpl = array('name' => $dir, 'price' => 0, 'preview' => MEMBER_URL . 'templates/space/' . $dir . '/preview.jpg'); $rule = dr_string2array(@file_get_contents(FCPATH . 'member/templates/space/' . $dir . '/rule.php')); if ($dir == 'default') { $list[$dir] = $tpl; } elseif ($rule && isset($rule[$this->markrule]['use']) && $rule[$this->markrule]['use']) { $tpl['price'] = intval($rule[$this->markrule]['price']); $list[$dir] = $tpl; } } $mytpl = $this->db->where('type', 1)->where('uid', $this->uid)->like('mark', 'space-tpl-')->get('member_scorelog_' . $this->member['tableid'])->result_array(); if ($mytpl) { foreach ($mytpl as $t) { list($a, $b, $dir) = explode('-', $t['mark']); if (isset($list[$dir]) && $list[$dir]['price']) { $my[$dir] = $list[$dir]; } } } } $this->template->assign(array('my' => $my, 'list' => $list, 'style' => $this->space['style'] ? $this->space['style'] : 'default')); $this->template->display('space_template.html'); }
/** * 空间模板 */ public function template() { $style = $this->input->get('style'); if ($style && $this->space['style'] != $style) { $rule = dr_string2array(@file_get_contents(FCPATH . 'member/templates/' . $style . '/rule.php')); if ($style == 'default' || isset($rule[$this->markrule])) { $this->db->where('uid', (int) $this->uid)->update($this->db->dbprefix('space'), array('style' => $style)); $this->member_msg(lang('m-319'), dr_member_url('space/template'), 1); } else { $this->member_msg(lang('m-320')); } } $list = array(); $data = array_diff(dr_dir_map(FCPATH . 'member/templates/', 1), array('admin', 'member')); if ($data) { foreach ($data as $dir) { $tpl = array('name' => $dir, 'preview' => MEMBER_URL . 'templates/' . $dir . '/preview.jpg'); $rule = dr_string2array(@file_get_contents(FCPATH . 'member/templates/' . $dir . '/rule.php')); if ($dir == 'default') { $list[] = $tpl; } elseif ($rule && isset($rule[$this->markrule])) { $list[] = $tpl; } } } $this->template->assign(array('list' => $list, 'style' => $this->space['style'] ? $this->space['style'] : 'default')); $this->template->display('space_template.html'); }