コード例 #1
0
ファイル: install.php プロジェクト: zhang19960118/html11
    }
    tpl_install_db($error);
}
if ($action == 'finish') {
    setcookie('action', '', -10);
    $dbfile = IA_ROOT . '/data/db.php';
    @unlink($dbfile);
    define('IN_SYS', true);
    require IA_ROOT . '/framework/bootstrap.inc.php';
    require IA_ROOT . '/web/common/bootstrap.sys.inc.php';
    $_W['uid'] = $_W['isfounder'] = 1;
    load()->web('common');
    load()->web('template');
    load()->model('setting');
    load()->model('cache');
    cache_build_frame_menu();
    cache_build_setting();
    cache_build_users_struct();
    cache_build_module_subscribe_type();
    tpl_install_finish();
}
function local_writeable($dir)
{
    $writeable = 0;
    if (!is_dir($dir)) {
        @mkdir($dir, 0777);
    }
    if (is_dir($dir)) {
        if ($fp = fopen("{$dir}/test.txt", 'w')) {
            fclose($fp);
            unlink("{$dir}/test.txt");
コード例 #2
0
ファイル: common.func.php プロジェクト: weikit/wechat-addon
function buildframes($frame = array('platform'))
{
    global $_W, $_GPC;
    if ($_W['role'] == 'clerk') {
        return false;
    }
    $GLOBALS['top_nav'] = pdo_fetchall('SELECT name, title, append_title FROM ' . tablename('core_menu') . ' WHERE pid = 0 AND is_display = 1 ORDER BY displayorder DESC');
    $ms = cache_load('system_frame');
    if (empty($ms)) {
        cache_build_frame_menu();
        $ms = cache_load('system_frame');
    }
    load()->model('module');
    $frames = array();
    $modules = uni_modules(false);
    $modules_temp = array_keys($modules);
    $status = uni_user_permission_exist();
    if (is_error($status)) {
        $modules_temp = pdo_fetchall('SELECT type FROM ' . tablename('users_permission') . ' WHERE uniacid = :uniacid AND uid = :uid AND type != :type', array(':uniacid' => $_W['uniacid'], ':uid' => $_W['uid'], ':type' => 'system'), 'type');
        if (!empty($modules_temp)) {
            $modules_temp = array_keys($modules_temp);
        } else {
            $modules = array();
        }
    }
    if (!empty($modules)) {
        $sysmods = system_modules();
        foreach ($modules as $m) {
            if (in_array($m['name'], $sysmods)) {
                $_W['setting']['permurls']['modules'][] = $m['name'];
                continue;
            }
            if (in_array($m['name'], $modules_temp)) {
                if ($m['enabled']) {
                    $frames[$m['type']][] = $m;
                }
                $_W['setting']['permurls']['modules'][] = $m['name'];
            }
        }
    }
    if (is_error($status)) {
        $system = array();
        $system = uni_user_permission('system');
        if (!empty($system) || !empty($modules_temp)) {
            foreach ($ms as $name => $section) {
                $hassection = false;
                foreach ($section as $i => $menus) {
                    $hasitems = false;
                    if (empty($menus['items'])) {
                        continue;
                    }
                    foreach ($menus['items'] as $j => $menu) {
                        if (!in_array($menu['permission_name'], $system)) {
                            unset($ms[$name][$i]['items'][$j]);
                        } else {
                            $hasitems = true;
                            $hassection = true;
                        }
                    }
                    if (!$hasitems) {
                        unset($ms[$name][$i]);
                    }
                }
                if (!$hassection) {
                    unset($ms[$name]);
                } else {
                    $_W['setting']['permurls']['sections'][] = $name;
                }
            }
        }
    }
    $types = module_types();
    if (!empty($frames)) {
        foreach ($frames as $type => $fs) {
            $items = array();
            if (!empty($fs)) {
                foreach ($fs as $m) {
                    $items[] = array('title' => $m['title'], 'url' => url('home/welcome/ext', array('m' => $m['name'])));
                }
            }
            $ms['ext'][] = array('title' => $types[$type]['title'], 'items' => $items);
        }
        if (is_error($status)) {
            $_W['setting']['permurls']['sections'][] = 'ext';
        }
    }
    $GLOBALS['ext_type'] = 0;
    $m = trim($_GPC['m']);
    $eid = intval($_GPC['eid']);
    if (FRAME == 'ext' && (!empty($m) || !empty($eid)) && $GLOBALS['ext_type'] != 2) {
        if (empty($_COOKIE['ext_type'])) {
            setcookie('ext_type', 1, TIMESTAMP + 8640000, "/");
            $_COOKIE['ext_type'] = 1;
        }
        $GLOBALS['ext_type'] = $_COOKIE['ext_type'];
        if (empty($m)) {
            $m = pdo_fetchcolumn('SELECT module FROM ' . tablename('modules_bindings') . ' WHERE eid = :eid', array(':eid' => $eid));
        }
        $module = module_fetch($m);
        $entries = module_entries($m);
        if (is_error($status)) {
            $permission = uni_user_permission($m);
            if ($permission[0] != 'all') {
                if (!in_array($m . '_rule', $permission)) {
                    unset($module['isrulefields']);
                }
                if (!in_array($m . '_settings', $permission)) {
                    unset($module['settings']);
                }
                if (!in_array($m . '_home', $permission)) {
                    unset($entries['home']);
                }
                if (!in_array($m . '_profile', $permission)) {
                    unset($entries['profile']);
                }
                if (!in_array($m . '_shortcut', $permission)) {
                    unset($entries['shortcut']);
                }
                if (!empty($entries['cover'])) {
                    foreach ($entries['cover'] as $k => $row) {
                        if (!in_array($m . '_cover_' . $row['do'], $permission)) {
                            unset($entries['cover'][$k]);
                        }
                    }
                }
                if (!empty($entries['menu'])) {
                    foreach ($entries['menu'] as $k => $row) {
                        if (!in_array($m . '_menu_' . $row['do'], $permission)) {
                            unset($entries['menu'][$k]);
                        }
                    }
                }
            }
        }
        $entries_filter = array_elements(array('cover', 'menu', 'mine'), $entries);
        $navs = array(array('title' => "模块列表", 'items' => array(array('title' => "<i class='fa fa-reply-all'></i> &nbsp;&nbsp;返回模块列表", 'url' => url('home/welcome/ext', array('a' => 0))), array('title' => "<i class='fa fa-reply-all'></i> &nbsp;&nbsp;返回{$module['title']}", 'url' => url('home/welcome/ext', array('m' => $m, 't' => 1))))));
        if ($module['isrulefields'] || $module['settings']) {
            $navs['rule'] = array('title' => "回复规则");
            if ($module['isrulefields']) {
                $navs['rule']['items'][] = array('title' => "<i class='fa fa-comments'></i> &nbsp;&nbsp;回复规则列表", 'url' => url('platform/reply', array('m' => $m)));
            }
            if ($module['settings']) {
                $navs['rule']['items'][] = array('title' => "<i class='fa fa-cog'></i> &nbsp;&nbsp;参数设置", 'url' => url('profile/module/setting', array('m' => $m)));
            }
        }
        if ($entries['home'] || $entries['profile'] || $entries['shortcut']) {
            $navs['nav'] = array('title' => "导航菜单");
            if ($entries['home']) {
                $navs['nav']['items'][] = array('title' => "<i class='fa fa-home'></i> &nbsp;&nbsp;微站首页导航", 'url' => url('site/nav/home', array('m' => $m)));
            }
            if ($entries['profile']) {
                $navs['nav']['items'][] = array('title' => "<i class='fa fa-user'></i> &nbsp;&nbsp;个人中心导航", 'url' => url('site/nav/profile', array('m' => $m)));
            }
            if ($entries['shortcut']) {
                $navs['nav']['items'][] = array('title' => "<i class='fa fa-plane'></i> &nbsp;&nbsp;快捷菜单", 'url' => url('site/nav/shortcut', array('m' => $m)));
            }
        }
        $menus = array('menu' => "业务菜单", 'cover' => "封面入口", 'mine' => "自定义菜单");
        foreach ($entries_filter as $key => $row) {
            if (empty($row)) {
                continue;
            }
            if (!isset($navs[$key])) {
                $navs[$key] = array('title' => $menus[$key]);
            }
            foreach ($row as $li) {
                $navs[$key]['items'][] = array('title' => "<i class='{$li["icon"]}'></i> &nbsp;&nbsp;{$li['title']}", 'url' => $li['url']);
            }
        }
    }
    if ($GLOBALS['ext_type'] == 1) {
        $ms['ext'] = $navs;
    } elseif ($GLOBALS['ext_type'] == 3) {
        $ms['ext'] = array_merge($navs, $ms['ext']);
    }
    return $ms;
}