public function saveImg() { Trace::output($this->traceID, "saveImg"); //---------------------------------------------------------- //init var //---------------------------------------------------------- $chk = array("bool" => 1); //---------------------------------------------------------- $img = str_replace('data:image/png;base64,', '', $this->img); $img = str_replace(' ', '+', $img); $data = base64_decode($img); $date = new DateTime(); //---------------------------------------------------------- if (is_null($imgName) || $encrypt) { $imgName = alphaID($date->getTimestamp()) . ".png"; } //---------------------------------------------------------- if (file_exists($this->dir)) { FileFolder::file_put_contents($this->dir . $imgName, $data); $chk["result"] = $this->fullURL . $imgName; } else { $chk['bool'] = false; $chk['message'] = $this->fullURL . " does no exist!!"; } //---------------------------------------------------------- return $chk; }
public static function callScript($script = null, $args = array()) { if (is_null($script)) { throw new Exception("script is null"); } //--------------------------------------------- $script = $_ENV["phantomjs_scripts"] . '/' . $script; //--------------------------------------------- $arr = FileFolder::fileExistInFolder($script, ["init.werm.js"], true); //--------------------------------------------- $content = ""; foreach ($arr as $value) { $content .= Import::replaceEnv($value); //krumo($content); } //--------------------------------------------- $content .= FileFolder::file_get_contents($script); //print_r($arr); //--------------------------------------------- FileFolder::file_put_contents($script = Import::newPath_CFG($script) . ".js", $content); //--------------------------------------------- $cmd = $_ENV["phantomjs"] . ' ' . $script; //--------------------------------------------- if (sizeof($args) > 0) { $cmd .= " " . implode(" ", $args); } //--------------------------------------------- $cmd .= ' > /dev/null 2>/dev/null &'; //--------------------------------------------- exec($cmd, $outputAndErrors, $return_value); //--------------------------------------------- return $outputAndErrors; }
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); }
public static function brand_CFG($file) { //if (is_null(Compiler::$api)) Compiler::init(); $txt = file_get_contents($file); if (!Compiler::$disabled || isset($_COOKIE['compile_curl'])) { preg_match('/(<!--{(\\S+)}-->)<script(?:src|)(.*?)<\\/script>/s', $txt, $matches); if (sizeof($matches) == 0) { //----------------------------------- $txt = Compiler::brand("script", $txt, $file); $txt = Compiler::brand("style", $txt, $file); //----------------------------------- //print_r($file); //$file = FileFolder::getPathFromFile($file).FileFolder::getFileName($file).".".FileFolder::getFileExt($file); $file = str_replace(array(Import::$uber_src_path, Import::getImportPath()), GlobalMas::$filesPath_absolute . Compiler::$importTmpPath, $file); FileFolder::file_put_contents($file, $txt); } } return $file; }
public function codiad_CFG($hash) { $dir_relative = GlobalMas::$filesPath_relative . $hash . "/"; $dir = GlobalMas::$filesPath_absolute . $hash . "/"; //----------------------------------------------------- if (!file_exists($dir . "codiad")) { Archive::extract(GlobalMas::$filesPath_absolute . "/codiad.zip", $dir); //----------------------------------------------------- $config_contents = FileFolder::file_get_contents($dir . "codiad/config.php"); $config_contents = str_replace("{BASE_PATH}", $dir . "codiad", $config_contents); $config_contents = str_replace("{BASE_URL}", GenFun::get_full_url($dir . "codiad"), $config_contents); FileFolder::file_put_contents($dir . "codiad/config.php", $config_contents); //--------------------------------------------------------- exec("ln -s " . $dir . "compile " . $dir . "codiad/workspace/compile" . " 2>&1", $output); exec("ln -s " . $dir . " " . $dir . "codiad/workspace/root" . " 2>&1", $output); //--------------------------------------------------------- if (strpos(join($output), "Errno::") !== false) { krumo($output); die; } } }
public function compile($output = NULL) { if (!is_null($output)) { $this->output_updated = $output; } $value = NULL; foreach ($this->tags as $key => $value) { $link = NULL; //------------------------------------------------- $value->compile(); //------------------------------------------------- if ($this->compileType == "seperate") { if (!is_null($value->save_path)) { $link = Html::getExtLink($value->save_path_relative); } } else { if ($this->compileType == "single") { /*if (is_null($this->mergedCode)) $this->mergedCode = ""; //krumo($value->save_path_relative); $this->mergedCode .= $value->content_updated.PHP_EOL; krumo($this->mergedCode);*/ } } //------------------------------------------------- if (!is_null($value->link_compile_file) && is_null($value->link_compile_file->content)) { $link = Html::getExtLink($value->link_compile_file->filePath); } //------------------------------------------------- if (!is_null($link)) { $this->extLinks .= $link . PHP_EOL; //$this->output_updated = str_replace("</head>",$link.PHP_EOL.'</head>', $this->output_updated); } //krumo($this->output_updated); } //------------------------------------------------- if ($this->compileType == "single" && !is_null($value)) { //krumo($value); $this->import_save_path_relative = "import." . $value->saveas_ext; $this->import_save_path = $this->compilePath . $this->import_save_path_relative; FileFolder::file_put_contents($this->import_save_path, $this->mergedCode); $link = Compiler::insertExtLink($this->import_save_path_relative); //krumo($this->output_updated); $this->extLinks .= $link . PHP_EOL; //$this->output_updated = str_replace("</head>",$link.PHP_EOL.'</head>', $this->output_updated); } else { if ($this->compileType == "inject") { $this->output_updated = str_replace("<head>", "<head>" . PHP_EOL . $this->mergedCode . PHP_EOL, $this->output_updated); } } }
public function getFiles($css, $srcPath) { $srcName = FileFolder::getFileName($srcPath); $newFolder = FileFolder::getPathFromFile($this->fileCss) . $srcName . "/"; //--------------------------------------------------------- $origSrcFolder = FileFolder::getPathFromFile($srcPath); //--------------------------------------------------------- preg_match_all('/(url\\(\\"|url\\(\'|url\\(|src=\')(.*?)(\\)|\'|\\")/s', $css, $files); //--------------------------------------------------------- foreach ($files[2] as $file_key => $origFilePath) { $fileAbPath = NULL; $newAbPath = NULL; $origFilePath = Compile::getBetweenQuot($origFilePath); //----------------------------------------------------- if (strpos($origFilePath, "../") !== false) { $goBack = explode("../", $origFilePath); $goBackAmt = sizeof($goBack); $srcFolderArr = explode("/", $origSrcFolder); $fileLocationArr = array_slice($srcFolderArr, 0, -$goBackAmt); $srcFolder = implode($fileLocationArr, "/") . "/"; $filePath = end($goBack); } else { $srcFolder = $origSrcFolder; $filePath = $origFilePath; if (strpos($filePath, "http://") !== false) { $fileAbPath = $filePath; $filePath = FileFolder::getFileName($filePath, false); $newFilePath = $newFolder . $filePath; } } //----------------------------------------------------- $filePath = FileFolder::getFileName($filePath, false, true); //----------------------------------------------------- if (is_null($fileAbPath)) { $fileAbPath = $srcFolder . $filePath; } if (is_null($newAbPath)) { $newAbPath = $newFolder . $filePath; } //----------------------------------------------------- $newFilePath = $srcName . "/" . $filePath; //----------------------------------------------------- if (file_exists(Import::uber_src_path() . $fileAbPath)) { $fileAbPath = Import::uber_src_path() . $fileAbPath; } //----------------------------------------------------- if ($fileContent = file_get_contents($fileAbPath)) { if (!file_get_contents($newAbPath)) { $css = str_replace($origFilePath, $newFilePath, $css); FileFolder::file_put_contents($newAbPath, $fileContent); FileFolder::file_put_contents(Compile::$unminifiedPath . $this->cleanURL($fileAbPath), $fileContent); } } } return $css; }
public function compile() { if ($this->compileType == "seperate") { if (!is_null($this->content)) { if (!is_null($this->save_path)) { //$file = $this->save_path; //$file = str_replace(array(Import::uber_src_path(), Import::getImportPath()), "", $file); //----------------------------------------------------- /*$path = (is_null($this->save_dir)) ? FileFolder::getFileName($file,true,true): $this->compilePath.$this->save_dir.FileFolder::getFileName($file,true); $file = $path.".".$this->saveas_ext; $this->save_path = $file;*/ //----------------------------------------------------- FileFolder::file_put_contents($this->save_path, $this->content_updated); } } } if (!is_null($this->images)) { $this->images->compile(); } }
public function compile() { if ($this->exist && !is_null($this->content) && is_null($this->base64_content)) { $this->successfully_saved = FileFolder::file_put_contents($this->save_path, $this->content); } }
public function copy_CFG() { //krumo($this->copy); foreach ($this->copy as $key => $value) { if (!file_exists($key)) { $key = $value; $value = NULL; } if (!$this->raw) { $txt = Compiler::markUp_CHK(file_get_contents($key)); } $path = isset($value['saveas']) ? str_replace(basename($key), $value['saveas'], Compiler::cleanURL($key, $this->compilePath)) : Compiler::cleanURL($key, $this->compilePath); FileFolder::file_put_contents($path, $txt); //copy($value, Compiler::cleanURL($value, $this->compilePath)); } }
public function chk() { //------------------------------------------- //init var //------------------------------------------- $bool = true; $delete = false; $file = $this->file_absolute; //------------------------------------------- foreach (Import::$filesLoaded as &$value) { if ($file == $value) { $bool = false; } } if ($bool) { $bool = Import::fileExist($file, $this->notExistException); //--------------------------------------- if (!$bool) { return $bool; } //--------------------------------------- array_push(Import::$filesLoaded, $file); //--------------------------------------- if ($this->ext == "js") { echo Html::getExJs($file) . PHP_EOL; return $bool; } else { if ($this->ext == "css") { echo Html::getExCss($file) . PHP_EOL; return $bool; } else { if ($this->ext == "scss") { $file = GenFun::get_full_url(self::compileSass($file)); echo Html::getExCss($file) . PHP_EOL; return $bool; } else { if ($this->importFunction == "include") { require_once "Compiler.php"; $modified = "HHH" . filectime($file) . "HHH"; $newPath = $this->newPath_CFG($file) . "_" . $modified . ".php"; // krumo(Import::$latestFiles); /*if (isset(Import::$latestFiles[$file]) && FileFolder::file_exists($newPath) && Import::$latestFiles[$file] == filectime($newPath)){ //print_r("kdhsf"); unset(Import::$latestFiles[$file]); }*/ //----------------------------------- //krumo(Import::$latestFiles); if (!FileFolder::file_exists($newPath)) { $content = file_get_contents($file); //----------------------------------- $prop = array("output" => $content, "onRemoveMatch" => array("Import", "onRemoveMatch"), "src_path" => $file, "matchProp" => array("ignoreIfExistInMatch" => array("<link"))); //--------------------------------------------- $css = new Compile_CSS($prop); $content = $css->output_updated; //$newPath = self::newPath_CFG($file); //--------------------------------------------- //krumo($file); /*$newScss = $newPath.".scss"; $content = self::replaceEnv(Import::$uber_src_path."GlobalSass.scss"); FileFolder::file_put_contents($newScss, $content.$css->mergedCode_noTag); $newCss = $newPath.".css"; //$output = shell_exec("/usr/local/bin/sass --scss -t uncompressed --sourcemap=none ".$newScss." ".$newCss); exec("/usr/local/bin/sass --scss --sourcemap=none ".$newScss." ".$newCss." 2>&1", $output);*/ /*if (strpos(join($output), "Errno::") !== false) { krumo($output); die(); };*/ FileFolder::file_put_contents($newPath, $content); $this->file_absolute_tmp = $file = $newPath; $this->compile_css = $css; $file = Compiler::brand_CFG($file); } else { $file = $newPath; $file = Compiler::brand_CFG($file); } //--------------------------------------------- /*if (sizeof($code->tmpl->matches) > 0) { echo '<!--{'.$file.'}-->'.$code->tmpl->mergedCode; }*/ //--------------------------------------------- /*$txt = Compiler::brand("script", $orig_txt, $file); $txt = Compiler::brand("style", $txt, $file); //----------------------------------- if ($txt != $orig_txt) { $delete = true; //------------------------------- $file = FileFolder::getPathFromFile($file).FileFolder::getFileName($file).".".FileFolder::getFileExt($file); $file = str_replace(array(Import::$uber_src_path, Import::getImportPath()), Compiler::$unminifiedPath_raw, $file); FileFolder::file_put_contents($file, $txt); }*/ //----------------------------------- //if($delete) FileFolder::delete($file); } } } } if ($bool && !is_null($this->importFunction) && !$this->externalLink) { eval($this->importFunction . " '" . $file . "';"); } } //------------------------------------------- return $bool; }
public function getAllContent($arr, $type, $minify) { $txt = ""; $import = ""; foreach ($arr as $value) { $content = $this->getFileContent($type, $value, $minify); //--------------------------------------------------------- if ($this->isPropSet($this->code[$type], "type", "seperate")) { $file = $value['file']; $file = str_replace(array(Import::uber_src_path(), Import::getImportPath()), "", $file); //----------------------------------------------------- $path = $this->isPropSet($this->code[$type], "path", NULL) ? FileFolder::getFileName($file, true, true) : $this->code[$type]['path'] . FileFolder::getFileName($file, true); $file = $path . ($type == "tmpl" ? "_tmpl.html" : ".{$type}"); if (!is_null($value['file']) && is_null($value['ex']) && $this->isPropSet($this->code[$type], "type", "seperate")) { //$import .= $this->getExtLink($file).PHP_EOL; /*krumo($this->code[$type]); krumo($file); krumo($type); krumo($value);*/ //krumo($value); //krumo($file); FileFolder::file_put_contents($this->path . $file, $content); } } /*else if (!is_null($value['ex']) && $this->isPropSet($this->code[$type], "forceDownload", NULL)) { $txt .= $this->getExtLink($value['file']).PHP_EOL; //$this->import .= $value['ex']; }*/ $txt .= $content; } if ($this->code[$type]["createImportFile"]) { $import_path = NULL; //----------------------------------------------------- if (is_array($this->code[$type]["createImportFile"]) && isset($this->code[$type]["createImportFile"])) { if (isset($this->code[$type]["createImportFile"]["path"])) { $import_path = $this->code[$type]["createImportFile"]["path"]; } } //----------------------------------------------------- $import_path = $this->path . (is_null($import_path) ? $this->compiler->compile_id . "_" . $type . "_import.php" : $import_path); FileFolder::file_put_contents($import_path, $import); } /*else { $this->import .= $import; }*/ return $txt; }