Exemplo n.º 1
0
function findfiles($path, $func)
{
    foreach (glob($path . '/*') as $fn) {
        if (is_dir($fn)) {
            findfiles($fn, $func);
        } else {
            $ext = array_pop(explode('.', $fn));
            if ($ext != 'php') {
                continue;
            }
            $func($fn);
        }
    }
}
Exemplo n.º 2
0
function findFiles($dir, $prefix)
{
    if (!file_exists($dir)) {
        return [];
    }
    $answer = [];
    foreach (scandir($dir, SCANDIR_SORT_DESCENDING) as $file) {
        if (invalidFile($file)) {
            continue;
        }
        $fullPath = "{$prefix}/{$file}";
        if (is_dir($fullPath)) {
            $answer += findfiles($fullPath, $fullPath);
        } else {
            $answer[] = $fullPath;
        }
    }
    return $answer;
}
Exemplo n.º 3
0
                $parastr .= "&startfrom=" . $startrow;
                foreach (array('filename', 'sizelimit', 'volume', 'tableid', 'sqlcompat', 'sqlcharset', 'usehex', 'tablestr') as $k) {
                    $parastr .= "&{$k}=" . ${$k};
                }
                amessage('backuping', "?entry=database&action=dbexport{$parastr}", count($tables), $tableid, $volume);
            }
        }
        adminlog(lang('dbbackup'));
        amessage('dbbackupfinish', '?entry=database&action=dbexport');
    }
} elseif ($action == 'dbimport') {
    if (!submitcheck('bdbimport') && !submitcheck('bbddelete')) {
        url_nav(lang('dboperate'), $urlsarr, 'dbimport');
        $expfiles = array();
        if (is_dir(M_ROOT . './dynamic/' . $backupdir)) {
            $expfiles = findfiles(M_ROOT . './dynamic/' . $backupdir, 'sql');
        }
        $itemstr = '';
        foreach ($expfiles as $k => $expfile) {
            $infos = array();
            $fp = fopen(M_ROOT . './dynamic/' . $backupdir . '/' . $expfile, 'rb');
            $identify = explode(',', base64_decode(preg_replace("/^# DatafileID:\\s*(\\w+).*/s", "\\1", fgets($fp, 256))));
            fclose($fp);
            $infos['filename'] = $expfile;
            $infos['createdate'] = date("{$dateformat} {$timeformat}", @filemtime(M_ROOT . './dynamic/' . $backupdir . '/' . $expfile));
            $infos['filesize'] = ceil(@filesize(M_ROOT . './dynamic/' . $backupdir . '/' . $expfile) / 1024);
            $infos['cmsname'] = empty($identify[1]) ? '' : $identify[1];
            $infos['version'] = empty($identify[2]) ? '' : $identify[2];
            $infos['volume'] = empty($identify[3]) ? '' : $identify[3];
            $infos['download'] = "<a href=\"?entry=database&action=download&filename={$infos['filename']}\">" . lang('download') . "</a>";
            $infos['import'] = $infos['volume'] == '1' && $infos['cmsname'] == '08CMS' ? "<a href=\"?entry=database&action=dbimport&bdbimport=1&filename={$infos['filename']}\">" . lang('import') . "</a>" : "-";
Exemplo n.º 4
0
        amessage('tplmodfin', axaction(6, $forward));
    }
} elseif ($action == 'mtplcopy' && $tplname) {
    $mtpl = $mtpls[$tplname];
    if (!submitcheck('bmtplcopy')) {
        !is_file($true_tpldir . '/' . $tplname) && amessage('poisotemfino');
        tabheader(lang('copnormapagetemp'), 'mtplcopy', "?entry=mtpls&action=mtplcopy{$param_suffix}&tplname={$tplname}");
        trbasic(lang('templatecname'), 'mtpladd[cname]');
        trbasic(lang('templateclass'), 'mtpladd[tpclass]', makeoption($tpclasses, $mtpl['tpclass']), 'select');
        trbasic(lang('soctemfi'), '', $tplname, '');
        trbasic(lang('tempfilsav'), 'mtpladd[tplname]');
        tabfooter('bmtplcopy');
        a_guide('mtplcopy');
    } else {
        (!$mtpladd['cname'] || !$mtpladd['tplname']) && amessage('datamissing', M_REFERER);
        $mtplsnew = findfiles($true_tpldir);
        in_array($mtpladd['tplname'], $mtplsnew) && amessage('poitemficnarep', M_REFERER);
        !copy($true_tpldir . '/' . $tplname, $true_tpldir . '/' . $mtpladd['tplname']) && amessage('temcopfai', M_REFERER);
        $mtpls[$mtpladd['tplname']] = array('cname' => stripslashes($mtpladd['cname']), 'tpclass' => $mtpladd['tpclass']);
        cache2file($mtpls, 'mtpls', 'mtpls', $sid);
        adminlog(lang('copynormaltemplate'));
        amessage('temcopfin', axaction(6, "?entry=mtpls&action=mtplsedit{$param_suffix}"));
    }
} elseif ($action == 'mtagcode') {
    if (empty($createrange)) {
        amessage('poitagsou');
    }
    if (preg_match("/\\{(u|c|p)\\\$(.+?)(\\s|\\})/is", $createrange, $matches)) {
        $ttype = $matches[1] . 'tag';
        $tname = $matches[2];
        $url = "?entry=mtags&action=mtagsdetail&ttype={$ttype}{$param_suffix}&tname={$tname}";
Exemplo n.º 5
0
(!defined('M_COM') || !defined('M_ADMIN')) && exit('No Permission');
include_once M_ROOT . "./include/database.fun.php";
load_cache('channels,fchannels');
aheader();
if ($action == 'tplpack') {
    if (!submitcheck('btplpack') && !submitcheck('bdelpack')) {
        $sqlcompatarr = array('0' => lang('default'), 'MYSQL40' => 'MySQL 3.23/4.0.x', 'MYSQL41' => 'MySQL 4.1.x/5.x');
        tabheader(lang('expsyscondat'), 'tplpack', '?entry=package&action=tplpack');
        trbasic(lang('dbfilename'), 'filename', date('ymd') . '_' . random(6));
        trbasic(lang('sqlcompat'), 'sqlcompat', makeoption($sqlcompatarr), 'select');
        trbasic(lang('usehex'), 'usehex', '0', 'radio');
        tabfooter('btplpack');
        $expfiles = array();
        if (is_dir(M_ROOT . './dynamic/export')) {
            $expfiles = findfiles(M_ROOT . './dynamic/export', 'sql');
        }
        $itemstr = '';
        foreach ($expfiles as $k => $expfile) {
            $infos = array();
            $fp = fopen(M_ROOT . './dynamic/export/' . $expfile, 'rb');
            $idsarr = explode(',', base64_decode(preg_replace("/^# DatafileID:\\s*(\\w+).*/s", "\\1", fgets($fp, 256))));
            fclose($fp);
            $infos['filename'] = $expfile;
            $infos['createdate'] = date("{$dateformat} {$timeformat}", $idsarr[0]);
            $infos['cmsname'] = $idsarr[1] . '&nbsp;v' . $idsarr[2];
            $infos['version'] = $idsarr[4] . $idsarr[3];
            $infos['filesize'] = ceil(@filesize(M_ROOT . './dynamic/export/' . $expfile) / 1024);
            $infos['download'] = "<a href=\"?entry=package&action=download&filename={$infos['filename']}\">" . 'download' . "</a>";
            $itemstr .= "<tr class=\"txt\"><td class=\"txtC\"><input class=\"checkbox\" type=\"checkbox\" name=\"selectid[{$infos['filename']}]\" value=\"{$infos['filename']}\">\n" . "<td class=\"txtL\"><a href=\"" . $cms_abs . "dynamic/export/{$infos['filename']}\">{$infos['filename']}</a></td>\n" . "<td class=\"txtC\">{$infos['cmsname']}</td>\n" . "<td class=\"txtC\">{$infos['version']}</td>\n" . "<td class=\"txtC\">{$infos['filesize']}</td>\n" . "<td class=\"txtC\">{$infos['createdate']}</td>\n" . "<td class=\"txtC\">{$infos['download']}</td></tr>\n";
        }
Exemplo n.º 6
0
     $convs[] = $droot . 'dynamic/mguides/' . $v;
 }
 //安装文件
 $convs[] = $droot . 'install/08cms.sql';
 $convs[] = $droot . 'install/langs/blangs.cac.php';
 $convs[] = $droot . 'install/langs/ilangs.cac.php';
 //模板文件
 $tplkeys = array(array('template/default/', 'htm'), array('template/default/', 'html'), array('template/default/js/', 'js'), array('template/default/css/', 'css'), array('template/default/function/', 'php'), array('template/default/cache/', 'php'));
 foreach ($tplkeys as $v) {
     $tplarr = findfiles($droot . $v[0], $v[1]);
     foreach ($tplarr as $u) {
         $convs[] = $droot . $v[0] . $u;
     }
 }
 //后台或会员中心用的js文件
 $jsarr = findfiles($droot . 'include/js/', 'js');
 foreach ($jsarr as $v) {
     $convs[] = $droot . 'include/js/' . $v;
 }
 //处理...
 foreach ($convs as $v) {
     if ($lan == 'tcutf8') {
         convert_file('gbk', 'big5', $v);
         convert_file('big5', 'utf-8', $v);
     } else {
         convert_file('gbk', $icharset, $v);
     }
 }
 //**************清除多余或开发用的文件及设置/////////////////////////////////////////////////////////////
 foreach (array('index.htm', 'index.html', 'google.xml', 'baidu.xml', 'sitemap.xml', 'init.php') as $k) {
     @unlink($droot . $k);