Пример #1
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;
 }
Пример #2
0
 public function start()
 {
     //---------------------------------------------------------
     $GET = array_merge($_GET, array());
     //---------------------------------------------------------
     unset($GET["pageID"]);
     //---------------------------------------------------------
     unset($GET['refresh']);
     //---------------------------------------------------------
     $_COOKIE['compile_curl'] = 1;
     //---------------------------------------------------------
     $this->url .= strpos($this->url, "?") === false ? "?" : "&";
     $this->url .= http_build_query($GET);
     //---------------------------------------------------------
     $this->output = CurlUtil::go(array("url" => $this->url));
     //---------------------------------------------------------
     $this->compile_id = Compiler::getCompile_id();
     //---------------------------------------------------------
     if ($this->useTitleAsId) {
         $this->title = $this->getTitle();
     }
     if (!is_null($this->title)) {
         $this->compile_id = $this->title;
     }
     //---------------------------------------------------------
     preg_match_all('/Fatal error(.*?)<br \\/>/s', $this->output, $errors);
     //---------------------------------------------------------
     if (sizeof($errors[0]) > 0) {
         print_r($errors[0]);
         die;
     }
     //---------------------------------------------------------
     foreach ($this->compile as $key => $value) {
         $value['compilerGlobal'] = $this->compilerGlobal;
         $value['output'] = $this->output;
         //$value['useTitleAsId'] = $this->useTitleAsId;
         $this->compilers[] = new Compile($value);
     }
     //---------------------------------------------------------
     return $this->output;
 }
Пример #3
0
 private function getTitle($url)
 {
     $output = CurlUtil::go(array("url" => $url));
     preg_match_all("/<title>(.*?)<\\/title>/s", $output, $matches, PREG_SET_ORDER);
     return sizeof($matches) == 0 ? NULL : $matches[0][1];
 }
Пример #4
0
 public static function getGeoIP()
 {
     return json_decode(CurlUtil::go(array("url" => "http://freegeoip.net/json/github.com/" . GenFun::getUserIP())), true);
 }