示例#1
0
function unCssCompression($content)
{
    $content = regExp_Replace($content, '\\s*([\\{\\}\\:\\;\\,])\\s*', '$1');
    $content = regExp_Replace($content, ';\\s*;', ';');
    ////清除连续分号
    $content = regExp_Replace($content, '\\,[\\s\\.\\#\\d]*{', '{');
    $content = regExp_Replace($content, '([^\\s])\\{([^\\s])', '$1 {' . vbCrlf() . '' . vbTab() . '$2');
    $content = regExp_Replace($content, '([^\\s])\\}([^' . vbCrlf() . ']*)', '$1' . vbCrlf() . '}' . vbCrlf() . '$2');
    $content = regExp_Replace($content, '([^\\s]);([^\\s\\}])', '$1;' . vbCrlf() . '' . vbTab() . '$2');
    $unCssCompression = $content;
    return @$unCssCompression;
}
示例#2
0
function orAndSearch($addSql, $SeectField, $SearchValue)
{
    $splStr = '';
    $s = '';
    $c = '';
    $SearchValue = regExp_Replace($SearchValue, ' or ', ' Or ');
    $SearchValue = regExp_Replace($SearchValue, ' and ', ' And ');
    if (inStr($SearchValue, ' Or ') > 0) {
        $splStr = aspSplit($SearchValue, ' Or ');
        foreach ($splStr as $key => $s) {
            if ($s != '') {
                if ($c != '') {
                    $c = $c . ' Or ';
                }
                $c = $c . ' ' . $SeectField . ' Like \'%' . $s . '%\'';
            }
        }
    } else {
        if (inStr($SearchValue, ' And ') > 0) {
            $splStr = aspSplit($SearchValue, ' And ');
            foreach ($splStr as $key => $s) {
                if ($s != '') {
                    if ($c != '') {
                        $c = $c . ' And ';
                    }
                    $c = $c . ' ' . $SeectField . ' Like \'%' . $s . '%\'';
                }
            }
        } else {
            if ($SearchValue != '') {
                $splStr = aspSplit($SearchValue, ' And ');
                foreach ($splStr as $key => $s) {
                    if ($s != '') {
                        if ($c != '') {
                            $c = $c . ' And ';
                        }
                        $c = $c . ' ' . $SeectField . ' Like \'%' . $s . '%\'';
                    }
                }
            }
        }
    }
    if ($c != '') {
        if (inStr(lCase($addSql), ' where ') == 0) {
            $c = ' Where ' . $c;
        } else {
            $c = ' And ' . $c;
        }
        $addSql = $addSql . $c;
    }
    $orAndSearch = $addSql;
    return @$orAndSearch;
}
示例#3
0
function handleWebCssImg($RootPath, $content)
{
    $startStr = '';
    $endStr = '';
    $ImgList = '';
    $splStr = '';
    $c = '';
    $imgUrl = '';
    $NewImgUrl = '';
    $startStr = 'url\\(';
    $endStr = '\\)';
    $ImgList = GetArray($content, $startStr, $endStr, false, false);
    //Call RwEnd(ImgList)
    $splStr = aspSplit($ImgList, '$Array$');
    foreach ($splStr as $key => $imgUrl) {
        if ($imgUrl != '') {
            $NewImgUrl = handleHttpUrl($imgUrl);
            if (inStr($NewImgUrl, '/') > 0) {
                $NewImgUrl = mid($NewImgUrl, inStrRev($NewImgUrl, '/') + 1, -1);
            }
            $NewImgUrl = $RootPath . $NewImgUrl;
            $startStr = 'url(';
            $endStr = ')';
            if (inStr($content, $startStr) > 0 && inStr($content, $endStr) > 0) {
                //call echo(StartStr,"StartStr")
                $content = regExp_Replace($content, $startStr . $imgUrl . $endStr, $startStr . $NewImgUrl . $endStr);
            }
        }
    }
    $handleWebCssImg = $content;
    return @$handleWebCssImg;
}
示例#4
0
function copyHtmlToWeb()
{
    $webDir = '';
    $toWebDir = '';
    $toFilePath = '';
    $filePath = '';
    $fileName = '';
    $fileList = '';
    $splStr = '';
    $content = '';
    $s = '';
    $s1 = '';
    $c = '';
    $webImages = '';
    $webCss = '';
    $webJs = '';
    $splJs = '';
    $webFolderName = '';
    $jsFileList = '';
    $setFileCode = '';
    $nErrLevel = '';
    $jsFilePath = '';
    $url = '';
    $setFileCode = @$_REQUEST['setcode'];
    //设置文件保存编码
    handlePower('复制生成HTML页面');
    //管理权限处理
    writeSystemLog('', '复制生成HTML页面');
    //系统日志
    $webFolderName = $GLOBALS['cfg_webTemplate'];
    if (left($webFolderName, 1) == '/') {
        $webFolderName = mid($webFolderName, 2, -1);
    }
    if (right($webFolderName, 1) == '/') {
        $webFolderName = mid($webFolderName, 1, len($webFolderName) - 1);
    }
    if (inStr($webFolderName, '/') > 0) {
        $webFolderName = mid($webFolderName, inStr($webFolderName, '/') + 1, -1);
    }
    $webDir = '/htmladmin/' . $webFolderName . '/';
    $toWebDir = '/htmlw' . 'eb/viewweb/';
    CreateDirFolder($toWebDir);
    $toWebDir = $toWebDir . pinYin2($webFolderName) . '/';
    deleteFolder($toWebDir);
    //删除
    CreateFolder('/htmlweb/web');
    //创建文件夹 防止web文件夹不存在20160504
    deleteFolder($webDir);
    CreateDirFolder($webDir);
    $webImages = $webDir . 'Images/';
    $webCss = $webDir . 'Css/';
    $webJs = $webDir . 'Js/';
    copyFolder($GLOBALS['cfg_webImages'], $webImages);
    copyFolder($GLOBALS['cfg_webCss'], $webCss);
    CreateFolder($webJs);
    //创建Js文件夹
    //处理Js文件夹
    $splJs = aspSplit(getDirJsList($webJs), vbCrlf());
    foreach ($splJs as $key => $filePath) {
        if ($filePath != '') {
            $toFilePath = $webJs . getFileName($filePath);
            aspEcho('js', $filePath);
            moveFile($filePath, $toFilePath);
        }
    }
    //处理Css文件夹
    $splStr = aspSplit(getDirCssList($webCss), vbCrlf());
    foreach ($splStr as $key => $filePath) {
        if ($filePath != '') {
            $content = getFText($filePath);
            $content = replace($content, $GLOBALS['cfg_webImages'], '../images/');
            $content = deleteCssNote($content);
            $content = PHPTrim($content);
            //设置为utf-8编码 20160527
            if (lCase($setFileCode) == 'utf-8') {
                $content = replace($content, 'gb2312', 'utf-8');
            }
            WriteToFile($filePath, $content, $setFileCode);
            aspEcho('css', $GLOBALS['cfg_webImages']);
        }
    }
    //复制栏目HTML
    $GLOBALS['isMakeHtml'] = true;
    $rssObj = $GLOBALS['conn']->query('select * from ' . $GLOBALS['db_PREFIX'] . 'webcolumn where isonhtml=true');
    while ($rss = $GLOBALS['conn']->fetch_array($rssObj)) {
        $GLOBALS['glb_filePath'] = replace(getColumnUrl($rss['columnname'], 'name'), $GLOBALS['cfg_webSiteUrl'] . '/', '');
        if (right($GLOBALS['glb_filePath'], 1) == '/' || right($GLOBALS['glb_filePath'], 1) == '') {
            $GLOBALS['glb_filePath'] = $GLOBALS['glb_filePath'] . 'index.html';
        }
        if (right($GLOBALS['glb_filePath'], 5) == '.html') {
            if (right($GLOBALS['glb_filePath'], 11) == '/index.html') {
                $fileList = $fileList . $GLOBALS['glb_filePath'] . vbCrlf();
            } else {
                $fileList = $GLOBALS['glb_filePath'] . vbCrlf() . $fileList;
            }
            $fileName = replace($GLOBALS['glb_filePath'], '/', '_');
            $toFilePath = $webDir . $fileName;
            copyFile($GLOBALS['glb_filePath'], $toFilePath);
            aspEcho('导航', $GLOBALS['glb_filePath']);
        }
    }
    //复制文章HTML
    $rssObj = $GLOBALS['conn']->query('select * from ' . $GLOBALS['db_PREFIX'] . 'articledetail where isonhtml=true');
    while ($rss = $GLOBALS['conn']->fetch_array($rssObj)) {
        $GLOBALS['glb_url'] = getHandleRsUrl($rss['filename'], $rss['customaurl'], '/detail/detail' . $rss['id']);
        $GLOBALS['glb_filePath'] = replace($GLOBALS['glb_url'], $GLOBALS['cfg_webSiteUrl'] . '/', '');
        if (right($GLOBALS['glb_filePath'], 1) == '/' || right($GLOBALS['glb_filePath'], 1) == '') {
            $GLOBALS['glb_filePath'] = $GLOBALS['glb_filePath'] . 'index.html';
        }
        if (right($GLOBALS['glb_filePath'], 5) == '.html') {
            if (right($GLOBALS['glb_filePath'], 11) == '/index.html') {
                $fileList = $fileList . $GLOBALS['glb_filePath'] . vbCrlf();
            } else {
                $fileList = $GLOBALS['glb_filePath'] . vbCrlf() . $fileList;
            }
            $fileName = replace($GLOBALS['glb_filePath'], '/', '_');
            $toFilePath = $webDir . $fileName;
            copyFile($GLOBALS['glb_filePath'], $toFilePath);
            aspEcho('文章' . $rss['title'], $GLOBALS['glb_filePath']);
        }
    }
    //复制单面HTML
    $rssObj = $GLOBALS['conn']->query('select * from ' . $GLOBALS['db_PREFIX'] . 'onepage where isonhtml=true');
    while ($rss = $GLOBALS['conn']->fetch_array($rssObj)) {
        $GLOBALS['glb_url'] = getHandleRsUrl($rss['filename'], $rss['customaurl'], '/page/page' . $rss['id']);
        $GLOBALS['glb_filePath'] = replace($GLOBALS['glb_url'], $GLOBALS['cfg_webSiteUrl'] . '/', '');
        if (right($GLOBALS['glb_filePath'], 1) == '/' || right($GLOBALS['glb_filePath'], 1) == '') {
            $GLOBALS['glb_filePath'] = $GLOBALS['glb_filePath'] . 'index.html';
        }
        if (right($GLOBALS['glb_filePath'], 5) == '.html') {
            if (right($GLOBALS['glb_filePath'], 11) == '/index.html') {
                $fileList = $fileList . $GLOBALS['glb_filePath'] . vbCrlf();
            } else {
                $fileList = $GLOBALS['glb_filePath'] . vbCrlf() . $fileList;
            }
            $fileName = replace($GLOBALS['glb_filePath'], '/', '_');
            $toFilePath = $webDir . $fileName;
            copyFile($GLOBALS['glb_filePath'], $toFilePath);
            aspEcho('单页' . $rss['title'], $GLOBALS['glb_filePath']);
        }
    }
    //批量处理html文件列表
    //call echo(cfg_webSiteUrl,cfg_webTemplate)
    //call rwend(fileList)
    $sourceUrl = '';
    $replaceUrl = '';
    $splStr = aspSplit($fileList, vbCrlf());
    foreach ($splStr as $key => $filePath) {
        if ($filePath != '') {
            $filePath = $webDir . replace($filePath, '/', '_');
            aspEcho('filePath', $filePath);
            $content = getFText($filePath);
            foreach ($splStr as $key => $s) {
                $s1 = $s;
                if (right($s1, 11) == '/index.html') {
                    $s1 = left($s1, len($s1) - 11) . '/';
                }
                $sourceUrl = $GLOBALS['cfg_webSiteUrl'] . $s1;
                $replaceUrl = $GLOBALS['cfg_webSiteUrl'] . replace($s, '/', '_');
                //Call echo(sourceUrl, replaceUrl) 							'屏蔽  否则大量显示20160613
                $content = replace($content, $sourceUrl, $replaceUrl);
            }
            $content = replace($content, $GLOBALS['cfg_webSiteUrl'], '');
            //删除网址
            $content = replace($content, $GLOBALS['cfg_webTemplate'] . '/', '');
            //删除模板路径 记
            //content=nullLinkAddDefaultName(content)
            foreach ($splJs as $key => $s) {
                if ($s != '') {
                    $fileName = getFileName($s);
                    $content = replace($content, 'Images/' . $fileName, 'js/' . $fileName);
                }
            }
            if (inStr($content, '/Jquery/Jquery.Min.js') > 0) {
                $content = replace($content, '/Jquery/Jquery.Min.js', 'js/Jquery.Min.js');
                copyFile('/Jquery/Jquery.Min.js', $webJs . '/Jquery.Min.js');
            }
            $content = replace($content, '<a href="" ', '<a href="index.html" ');
            //让首页加index.html
            createFileGBK($filePath, $content);
        }
    }
    //把复制网站夹下的images/文件夹下的js移到js/文件夹下  20160315
    $htmlFileList = '';
    $splHtmlFile = '';
    $splJsFile = '';
    $htmlFilePath = '';
    $jsFileName = '';
    $jsFileList = getDirJsNameList($webImages);
    $htmlFileList = getDirHtmlList($webDir);
    $splHtmlFile = aspSplit($htmlFileList, vbCrlf());
    $splJsFile = aspSplit($jsFileList, vbCrlf());
    foreach ($splHtmlFile as $key => $htmlFilePath) {
        $content = getFText($htmlFilePath);
        foreach ($splJsFile as $key => $jsFileName) {
            $content = regExp_Replace($content, 'Images/' . $jsFileName, 'js/' . $jsFileName);
        }
        $nErrLevel = 0;
        $content = handleHtmlFormatting($content, false, $nErrLevel, '|删除空行|');
        //|删除空行|
        $content = handleCloseHtml($content, true, '');
        //闭合标签
        $nErrLevel = checkHtmlFormatting($content);
        if (checkHtmlFormatting($content) == false) {
            echoRed($htmlFilePath . '(格式化错误)', $nErrLevel);
            //注意
        }
        //设置为utf-8编码
        if (lCase($setFileCode) == 'utf-8') {
            $content = replace($content, '<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />', '<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />');
        }
        $content = PHPTrim($content);
        WriteToFile($htmlFilePath, $content, $setFileCode);
    }
    //images下js移动到js下
    foreach ($splJsFile as $key => $jsFileName) {
        $jsFilePath = $webImages . $jsFileName;
        $content = getFText($jsFilePath);
        $content = PHPTrim($content);
        WriteToFile($webJs . $jsFileName, $content, $setFileCode);
        DeleteFile($jsFilePath);
    }
    copyFolder($webDir, $toWebDir);
    //使htmlWeb文件夹用php压缩
    if (@$_REQUEST['isMakeZip'] == '1') {
        makeHtmlWebToZip($webDir);
    }
    //使网站用xml打包20160612
    if (@$_REQUEST['isMakeXml'] == '1') {
        makeHtmlWebToXmlZip('/htmladmin/', $webFolderName);
    }
    //浏览地址
    $url = 'http://10.10.10.57/' . $toWebDir;
    aspEcho('浏览', '<a href=\'' . $url . '\' target=\'_blank\'>' . $url . '</a>');
}