Example #1
0
 public function script_CFG()
 {
     //---------------------------------------------------------
     //init var
     //---------------------------------------------------------
     preg_match_all('/<script(.*?)<\\/script>/s', $this->content, $matches);
     //---------------------------------------------------------
     FileFolder::delete($this->fileJs);
     //---------------------------------------------------------
     foreach ($matches[0] as $key => $match) {
         $num++;
         $txt = NULL;
         if (strpos($match, "<script src=") !== false || strpos($match, "text/javascript") !== false && strpos($match, "<script") !== false && strpos($match, "src=") !== false) {
             preg_match_all('/src=("| ")(.*?)"/s', $match, $links);
             if (sizeof($links[0]) > 0) {
                 $file = $links[2][0];
                 //---------------------------------------------
                 $result = $this->url_CFG($file);
                 //---------------------------------------------
                 $txt = $result["txt"];
                 $file = $result["file"];
                 //---------------------------------------------
                 $this->project = str_replace($match, '<script type="text/javascript" src="' . $file . '"></script>', $this->project);
                 //---------------------------------------------
             }
         } else {
             if (strpos($match, '"text/x-jQuery-tmpl">') !== false || strpos($match, "'text/x-jQuery-tmpl'>") !== false) {
                 FileFolder::file_put_contents($this->fileTmpl, $match, FILE_APPEND);
                 $this->content = str_replace($match, '', $this->content);
                 $this->project = str_replace($match, PHP_EOL, $this->project);
             } else {
                 preg_match_all('/<script(.*?)(type="text\\/javascript"|type="text\\/javascript" )>/s', $match, $style);
                 //krumo($style);
                 //$match = str_replace($style[0], "", $match);
                 $txt = str_replace(array("<script>", '<script type="text/javascript">', '<script type="text/javascript" >', "</script>"), "", $match);
                 //$txt = preg_replace('/(?:(?:\/\*(?:[^*]|(?:\*+[^*\/]))*\*+\/)|(?:(?<!\:|\\\|\')\/\/.*))/', '', $txt);
                 //$txt = $style[1];
                 $txt = str_replace($style[0], '', $txt);
                 //-----------------------------------------------------
                 preg_match_all('/var(.*?)=/s', $txt, $fileName);
                 $fileName = StringUtil::removeWhiteSpace($fileName[1][0]);
                 $file = "client/werm/" . $fileName . ".js";
                 $this->project = str_replace($match, '<script type="text/javascript" src="' . $file . '"></script>' . PHP_EOL, $this->project);
                 //-----------------------------------------------------
                 $txtNoComments = StringUtil::removeAllComments($txt);
                 //-----------------------------------------------------
                 preg_match_all('/"([^\'"]*\\.(php)[\'"]?)"/', $txtNoComments, $php);
                 if (sizeof($php[0]) > 0) {
                     foreach ($php[1] as $file) {
                         preg_match_all('/{(.*?)}/', $file, $constant);
                         if (sizeof($constant[0]) > 0) {
                             $file = GenFun::constCHK($file);
                             require_once Import::$uber_src_path . $file;
                         } else {
                             $file = strpos($file, "http://") === false ? Import::$uber_src_path . $file : GenFun::get_local_url($file);
                             if (file_exists($file)) {
                                 $file = str_replace(Import::$uber_src_path, "", $file);
                                 FileFolder::file_put_contents(Compile::$unminifiedPath . $file, file_get_contents($file));
                                 FileFolder::file_put_contents(Compile::$minifiedPath . $file, file_get_contents($file));
                             }
                         }
                     }
                 }
             }
         }
         if (!is_null($txt)) {
             //$txt = Minifier::minify($txt);
             FileFolder::file_put_contents($this->fileJs, $txt, FILE_APPEND);
             $this->content = str_replace($match, '', $this->content);
         }
     }
     //---------------------------------------------------------
     return $this->content;
 }
Example #2
0
 public function refresh()
 {
     if (isset($_GET['refresh']) && $_GET['refresh'] == "1") {
         FileFolder::delete($this->compilePath);
     }
 }
Example #3
0
 public function deleteFile($id, $hardDelete = false)
 {
     Trace::output(self::$traceID, "insertFile", func_get_args());
     //----------------------------------------------------------
     //init var
     //----------------------------------------------------------
     $chk = array("bool" => true, 'result' => array(), "func" => "deleteFile");
     $date = date("Y-m-d H:i:s");
     //----------------------------------------------------------
     if ($hardDelete) {
         $file = GetTable::go("files", array("id" => $id));
         $path = $file['result'][0]['hash'];
         $path = GlobalMas::$filesPath_absolute . $path;
         if (!FileFolder::delete($path)) {
             $chk['bool'] = false;
             $chk['message'] = "file was not deleted";
         }
     }
     if (!$chk['bool']) {
         return $chk;
     } else {
         $chk = Update::go("files", array("deleted" => $date), array('id' => $id));
     }
     //----------------------------------------------------------
     return $chk;
 }
Example #4
0
 public function complete()
 {
     if ($this->getIncluded) {
         FileFolder::dupIncluded(Import::$uber_src_path . "server/", $this->compilePath . "/server/");
         FileFolder::dupIncluded(Import::getImportPath(), $this->compilePath . "/", NULL, true);
     }
     FileFolder::delete(Compiler::$tmpPath);
     //FileFolder::dupIncluded("", $this->compilePath."/", NULL,true);
 }