function search_files($base)
{
    global $search, $exclude, $replace;
    $file_list = get_dir_list($base);
    $ret = array();
    foreach ($file_list as $p => $af) {
        foreach ($af as $f) {
            // 过滤掉不是 php 的文件
            foreach ($search['file'] as $pat) {
                if (!preg_match($pat, $f)) {
                    continue 2;
                }
            }
            $path = "{$p}/{$f}";
            $cont = file_get_contents($path);
            foreach ($search['key'] as $sk) {
                $pat_sk = "/{$sk} (.*)/i";
                if (preg_match_all($pat_sk, $cont, $match_all)) {
                    $match_all = array_unique($match_all[1]);
                    foreach ($match_all as $ma) {
                        foreach ($exclude['key'] as $ek) {
                            if (!preg_match($ek, $ma)) {
                                foreach ($replace as $s => $r) {
                                    $ma = preg_replace($s, $r, $ma);
                                }
                                $ret[$path][] = trim($ma);
                            }
                        }
                    }
                }
            }
        }
    }
    return $ret;
}
 public function index()
 {
     $aLangs = get_dir_list(PH7_ROOT_INSTALL . 'langs/');
     $aLangsList = (include PH7_ROOT_INSTALL . 'inc/lang_list.inc.php');
     $sLangSelect = '';
     foreach ($aLangs as $sLang) {
         $sSel = empty($_REQUEST['l']) ? $sLang == $this->sCurrentLang ? '" selected="selected' : '' : $sLang == $_REQUEST['l'] ? '" selected="selected' : '';
         $sLangSelect .= '<option value="?l=' . $sLang . $sSel . '">' . $aLangsList[$sLang] . '</option>';
     }
     $this->oView->assign('lang_select', $sLangSelect);
     $this->oView->assign('sept_number', 1);
     $this->oView->display('index.tpl');
 }
Esempio n. 3
0
/**
 * @return string The links of the ​​available languages.
 */
function get_langs_html()
{
    $aLangs = get_dir_list(DATA_PATH);
    $aLangsList = (include ROOT_PATH . 'inc/conf.lang.php');
    $sHtml = '<div id="lang">';
    foreach ($aLangs as $sLang) {
        if ($sLang === LANG) {
            continue;
        }
        $sHtml .= '<a href="' . RELATIVE . substr($sLang, 0, 2) . '" data-load="ajax"><img src="' . STATIC_URL . 'img/flags/' . $sLang . '.gif" alt="' . $aLangsList[$sLang] . '" title="' . $aLangsList[$sLang] . '" /></a>&nbsp;';
    }
    $sHtml .= '</div>';
    return $sHtml;
}
Esempio n. 4
0
/**
 * Returns select lists with all the subdirectories along the current directory path
 *
 * @param string $dir
 * @return string
 */
function get_dir_selects($dir)
{
    $dirs = explode("/", str_replace("\\", '/', $dir));
    $subdirs = get_dir_list();
    if (sizeof($subdirs) > 0) {
        $subdirs = array_merge(array('ext_disabled' => '-'), $subdirs);
    }
    if (empty($dirs[0])) {
        array_shift($dirs);
    }
    $dirsCopy = $dirs;
    $implode = '';
    $selectedDir = @$dirs[0];
    foreach ($subdirs as $index => $val) {
        if ($GLOBALS['use_mb']) {
            if (mb_detect_encoding($val) == 'ASCII') {
                $subdirs[$index] = utf8_encode($val);
            } else {
                $subdirs[$index] = $val;
            }
        } else {
            $subdirs[$index] = utf8_encode($val);
        }
    }
    $dir_links = ext_selectList('dirselect1', $selectedDir, $subdirs, 1, '', 'onchange="theDir=this.options[this.selectedIndex].value;if(theDir!=\'ext_disabled\' ) chDir(theDir);"');
    $i = 2;
    foreach ($dirs as $directory) {
        if ($directory != "") {
            $implode .= $directory;
            $next = next($dirsCopy);
            $subdirs = get_dir_list($implode);
            foreach ($subdirs as $index => $val) {
                unset($subdirs[$index]);
                if ($GLOBALS['use_mb']) {
                    if (mb_detect_encoding($index) == 'ASCII') {
                        if (mb_detect_encoding($val) == 'ASCII') {
                            $subdirs[utf8_encode($index)] = utf8_encode($val);
                        } else {
                            $subdirs[utf8_encode($index)] = $val;
                        }
                    } else {
                        if (mb_detect_encoding($val) == 'ASCII') {
                            $subdirs[$index] = utf8_encode($val);
                        } else {
                            $subdirs[$index] = $val;
                        }
                    }
                } else {
                    $subdirs[utf8_encode($index)] = utf8_encode($val);
                }
            }
            if ($next !== false) {
                $selectedDir .= '/' . $next;
            } else {
                if (sizeof($subdirs) > 0) {
                    $subdirs = array_merge(array('ext_disabled' => '-'), $subdirs);
                }
            }
            $dir_links .= ' / ' . ext_selectList('dirselect' . $i++, $selectedDir, $subdirs, 1, '', 'onchange="theDir=this.options[this.selectedIndex].value;if(theDir!=\'ext_disabled\' ) chDir(theDir);"');
            $implode .= '/';
        }
    }
    //echo '<pre>'.htmlspecialchars($dir_links).'</pre>';exit;
    return $dir_links;
}
Esempio n. 5
0
     }
     while (($e = readdir($d)) !== false) {
         if ($e == '.' || $e == '..') {
             continue;
         }
         if (!@is_dir($e)) {
             continue;
         }
         $inc[$e] = $e;
         flush();
     }
     closedir($d);
     chdir("..");
     return $inc;
 }
 $cat = get_dir_list();
 //нажата кнопка
 if (isset($_REQUEST['doupload'])) {
     if (is_sid()) {
         //если имеем дело с человеком, вкл. библиотеку
         $d = strval($_REQUEST['dir']);
         if (!isset($cat[$d]) || $d == '') {
             $d = '';
         } else {
             $d = $cat[$d];
         }
         require_once TE_DIR . '/lib/upload.php';
         $uns = upload_file($max_size = 10145728, $dir = $d, $cerber = false);
         //вернет сообщение об успешности загрузки
     } else {
         $uns = my_lang('feedback_t3');
Esempio n. 6
0
function get_dir_selects($dir)
{
    $dirs = explode("/", $dir);
    $subdirs = get_dir_list();
    if (empty($dirs[0])) {
        array_shift($dirs);
    }
    $dirsCopy = $dirs;
    $implode = '';
    $selectedDir = @$dirs[0];
    $dir_links = jx_selectList('dirselect1', $selectedDir, $subdirs, 1, '', 'onchange="theDir=this.options[this.selectedIndex].value;if(theDir!=\'jx_disabled\' ) chDir(theDir);"');
    $i = 2;
    foreach ($dirs as $directory) {
        if ($directory != "") {
            $implode .= $directory;
            $next = next($dirsCopy);
            $subdirs = get_dir_list($implode);
            if ($next !== false) {
                $selectedDir .= '/' . $next;
            } else {
                if (sizeof($subdirs) > 0) {
                    $subdirs = array_merge(array('jx_disabled' => '-'), $subdirs);
                }
            }
            $dir_links .= ' / ' . jx_selectList('dirselect' . $i++, $selectedDir, $subdirs, 1, '', 'onchange="theDir=this.options[this.selectedIndex].value;if(theDir!=\'jx_disabled\' ) chDir(theDir);"');
            $implode .= '/';
        }
    }
    return $dir_links;
}
Esempio n. 7
0
/**
 * 取系统前台的主题列表
 * @return [type] [description]
 */
function get_theme_list()
{
    $rearr = [];
    $path = APP_PATH . 'Home/View/';
    $list = get_dir_list($path);
    foreach ($list as $key => $value) {
        $filepath = $path . $value . '/tpl.ini';
        if (file_exists($filepath)) {
            $con = file_get_contents($filepath);
            $con = json_decode($con, true);
            $rearr[$value] = $con['name'];
        } else {
            $rearr[$value] = $value;
        }
    }
    return $rearr;
}
 /**
  * 新添加插件
  */
 public function newadd()
 {
     if (IS_POST) {
         $title = I('post.title');
         $name = I('post.name');
         $author = I('post.author');
         $descr = I('post.descr');
         if (empty($title) || empty($name) || empty($author) || empty($descr)) {
             $this->error('插件信息不能为空!');
         }
         //查找是不是存在相同标识的插件
         $dirlist = get_dir_list(ADDONS_PATH);
         $dirlist = str_replace('Plugin', '', $dirlist);
         $addoninfo = array();
         if (in_array($name, $dirlist)) {
             $temarr = run_plugin_method($name, 'getConfig');
             $this->error("插件标识符已经存在!,插件名字:{$temarr['name']}");
         }
         $p_content = file_get_contents('./Data/tpldata/plugin/TestPlugin.class.php');
         $p_config = file_get_contents('./Data/tpldata/plugin/View/config.html');
         $p_con = file_get_contents('./Data/tpldata/plugin/View/content.html');
         $p_content = str_replace('Test', $name, $p_content);
         $p_content = str_replace(array('[PLUGIN_TITLE]', '[PLUGIN_AUTHOR]', '[PLUGIN_DESCR]'), array($title, $author, $descr), $p_content);
         /*			$p_content = str_replace('[PLUGIN_NAME]', $author, $p_content);
         $p_content = str_replace('[PLUGIN_DESCR]', $descr, $p_content);*/
         $p_config = str_replace('Test', $name, $p_config);
         $p_con = str_replace('Test', $name, $p_con);
         create_folder("./Plugins/{$name}/View");
         file_put_contents("./Plugins/{$name}/{$name}Plugin.class.php", $p_content);
         file_put_contents("./Plugins/{$name}/View/content.html", $p_con);
         file_put_contents("./Plugins/{$name}/View/config.html", $p_config);
         $this->success(L('_ADD_SUCCESS_'));
     } else {
         //$field            = get_model_attr('plugin');
         $field = array(array('field' => 'title', 'name' => 'title', 'type' => 'string', 'title' => '插件名字', 'note' => '名称', 'extra' => null, 'value' => '测试', 'is_show' => 3), array('field' => 'name', 'name' => 'name', 'type' => 'string', 'title' => '插件标识符', 'note' => '只能用英文名(单词第一个字母大写)', 'extra' => null, 'is_show' => 3), array('field' => 'author', 'name' => 'author', 'type' => 'string', 'title' => '插件作者', 'note' => '', 'extra' => null, 'is_show' => 3), array('field' => 'descr', 'name' => 'descr', 'type' => 'string', 'title' => '插件描述', 'note' => '', 'extra' => null, 'is_show' => 3));
         $this->meta_title = '添加新插件';
         $this->assign('fieldarr', $field);
         $this->assign('data', null);
         $this->display();
     }
 }