Пример #1
0
 public static function folderCopy($src, $dst, $rename = NULL)
 {
     $dir = opendir($src);
     //FileFolder::createFolderStructure($dst);
     //krumo($dst);
     while (false !== ($file = readdir($dir))) {
         if ($file != '.' && $file != '..') {
             if (is_dir($src . '/' . $file)) {
                 FileFolder::folderCopy($src . '/' . $file, $dst . '/' . $file);
             } else {
                 //krumo($src . '/' . $file."|||||".$dst . '/' . $file);
                 FileFolder::file_put_contents($dst . "/" . $file, file_get_contents($src . "/" . $file));
             }
         }
     }
     //krumo($dst);
     closedir($dir);
 }
Пример #2
0
 public function start()
 {
     if (is_null($this->folderName)) {
         if (isset($_GET['pageID'])) {
             $this->folderName = $_GET['pageID'];
         }
     }
     //---------------------------------------------------------
     $folderName = Compile::$minifiedPath;
     //---------------------------------------------------------
     $GET = array_merge($_GET, array());
     //---------------------------------------------------------
     unset($GET["pageID"]);
     //---------------------------------------------------------
     //$GET["compile"]=0;
     //$GET['print_cookie'] = 1;
     unset($GET['refresh']);
     $_COOKIE['compile_curl'] = 1;
     //---------------------------------------------------------
     $this->url .= "?" . http_build_query($GET);
     //---------------------------------------------------------
     if (is_null($folderName) && FileFolder::getFileName($this->url) != "") {
         $folderName = explode("/", $this->url);
         end($folderName);
         $folderName = prev($folderName);
     }
     //---------------------------------------------------------
     $this->fileCss = Compile::$minifiedPath . "global/css/" . $this->folderName . "/min.css";
     $this->fileJs = Compile::$minifiedPath . "global/js/" . $this->folderName . "/min.js";
     $this->fileTmpl = Compile::$minifiedPath . $this->folderName . "/min.php";
     //---------------------------------------------------------
     $this->fileCssAb = GenFun::get_full_url($this->fileCss);
     $this->fileJsAb = GenFun::get_full_url($this->fileJs);
     //---------------------------------------------------------
     FileFolder::createFolderStructure($this->fileCss);
     //---------------------------------------------------------
     FileFolder::folderCopy(Import::getImportPath(), Compile::$minifiedPath);
     FileFolder::folderCopy(Import::getImportPath(), Compile::$unminifiedPath);
     //---------------------------------------------------------
     $this->content = CurlUtil::go(array("url" => $this->url));
     //---------------------------------------------------------
     preg_match_all('/Fatal error(.*?)<br \\/>/s', $this->content, $errors);
     //---------------------------------------------------------
     if (sizeof($errors[0]) > 0) {
         krumo($errors[0]);
         die;
     }
     //---------------------------------------------------------
     $this->content = $this->css_CFG();
     $this->script_CFG();
     $this->content = str_replace("<head>", '<head><script type="text/javascript" src="' . $this->fileJsAb . '"></script>' . PHP_EOL, $this->content);
     $this->content = str_replace("<head>", '<head><link rel="stylesheet" type="text/css" href="' . $this->fileCssAb . '"/>' . PHP_EOL, $this->content);
     $this->content = str_replace("<head>", '<head>' . PHP_EOL . file_get_contents($this->fileTmpl), $this->content);
     //---------------------------------------------------------
     $this->project = str_replace("<head>", '<head>' . PHP_EOL . file_get_contents($this->fileTmpl), $this->project);
     //---------------------------------------------------------
     FileFolder::delete($this->fileTmpl);
     //---------------------------------------------------------
     $this->project = StringUtil::removeWhiteLines($this->project);
     //---------------------------------------------------------
     file_put_contents(Import::getImportPath() . "project/index.php", $this->project);
     //---------------------------------------------------------
     $this->content = StringUtil::removeWhiteLines($this->content);
     FileFolder::file_put_contents(Compile::$minifiedPath . "index.php", $this->content);
     //---------------------------------------------------------
     return $this->content;
 }