public function file_CHK() { //----------------------------------------------------- $content = NULL; $getContent = true; //----------------------------------------------------- if (preg_match('/\\.(jpg|jpeg|png|gif)(?:[\\?\\#].*)?$/i', $this->filePath)) { $this->fileType = "image"; } //----------------------------------------------------- $filePath = explode("?", $this->filePath); $filePath = $filePath[0]; //----------------------------------------------------- if (strpos($filePath, "../") !== false) { $this->filePath_local = FileFolder::getParDirFromSrc($filePath, $this->url_local . $this->src_dir); //--------------------------------------------- if (FileFolder::file_exists($this->filePath_local)) { $this->exist = true; $this->content = $this->getContent($this->filePath_local); } //--------------------------------------------- $result = StringUtil::replaceOverlap($this->url_local, $this->filePath_local, "", "/"); //--------------------------------------------- if ($this->relativeToSrc && $this->exist) { $this->save_path = $this->compilePath . str_replace($this->url_local, "", $this->filePath_local); //----------------------------------------- if ($result['overlap'] != $this->url_local) { krumo($result); krumo($this->filePath_local . " cannot be saved outside of " . $this->compilePath . " ,'relativeToSrc' will be set to 'false'"); //----------------------------------------- $this->relativeToSrc = false; } } //--------------------------------------------- $filePath = str_replace($result["overlap"], "", $this->filePath_local); } else { if (strpos($filePath, "http://") !== false || strpos($filePath, "https://") !== false) { if (FileFolder::file_exists($filePath_local = GenFun::get_local_url($filePath))) { $this->filePath_local = $filePath_local; $this->content = $this->getContent($this->filePath_local); $this->filePath_local_relative = Compiler::cleanURL($this->filePath_local, ""); $filePath = !is_null($this->save_dir) ? basename($this->filePath_local_relative) : $this->filePath_local_relative; $this->exist = true; } else { if (CurlUtil::is_url_exist($this->filePath)) { $this->exist = true; if ($this->forceDownload) { $filePath = (!is_null($this->save_dir) ? "" : "global/forced/") . basename($filePath); $this->content = $this->getContent($this->filePath); $this->forced = true; } else { $this->link = Html::getExtLink($this->filePath); } } } } else { if (!is_null($this->src_save_dir) && $this->src_content_type == "css") { if (FileFolder::file_exists($this->filePath_local = (!is_null($this->src_dir) ? GenFun::get_local_url($this->src_dir) : $this->url_local) . $filePath)) { $this->exist = true; } $this->content = $this->getContent($this->filePath_local); if ($this->relativeToSrc) { $filePath = $this->src_save_dir . $filePath; } $this->save_path = $this->compilePath . $filePath; } else { if (FileFolder::file_exists($this->filePath_local = $this->url_local . $filePath)) { $this->content = $this->getContent($this->filePath_local); $filePath = $this->filePath; $this->exist = true; } } } } //------------------------------------------------- if (!$this->base64 || $this->fileType != "image") { if ($this->relativeToSrc && $this->src_content_type == "css") { $this->save_path_relative = $filePath; } else { if (!is_null($this->filePath_local)) { //--------------------------------------------- $this->save_path_relative = $this->get_savePath($filePath); $this->save_path = $this->compilePath . $this->save_path_relative; } else { //$this->save_path = $filePath; } } //------------------------------------------------- if ($this->relativeToSrc && !is_null($this->src_save_dir)) { $this->save_path_relative = StringUtil::pathRelativeToPath($this->save_path, $this->compilePath . $this->src_save_dir, "/", true); } } else { if ($this->fileType == "image") { $info = getimagesize($this->filePath_local); if ($info['mime'] == "image/png") { $this->base64_content = Image::compress_png($this->filePath_local, $this->quality, true); } else { if ($info['mime'] == "image/jpeg") { $this->base64_content = Image::compress_jpeg($this->filePath_local, $this->quality, true); } else { $this->base64_content = GenFun::fileToBase64($this->filePath_local, $info['mime']); } } } } //------------------------------------------------- if ($this->exist) { $this->src_content_updated = str_replace($this->filePath, !is_null($this->base64_content) ? $this->base64_content : $this->save_path_relative, $this->src_content); } else { $this->existCaseInsensitive = FileFolder::file_exists($this->filePath_local, false); array_push($this->compilerGlobal->notifications, array("existCaseInsensitive" => $this->existCaseInsensitive, "file" => $this->filePath)); } }
//----------------------------------------------------------------------------- indexExist($_REQUEST, array('service', 'functionName')); /////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////// //imports /////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////// preg_match("/{(.*?)}/", $_REQUEST['service'], $match); $classPath = sizeof($match) == 0 ? Import::services() . $_REQUEST['service'] : MarkUp::go($_REQUEST['service']); //---------------------------------------------------------- //if (!file_exists($classPath)) die($classPath." does not exist!!!!"); //---------------------------------------------------------- if (!isset($_REQUEST['service'])) { fail_CHK("service is not set!!"); } else { if (!FileFolder::file_exists($classPath)) { fail_CHK("service (" . $classPath . ") does not exist!!"); } } //---------------------------------------------------------- $class = explode(".", $classPath); //---------------------------------------------------------- if ($class[1] != "php") { fail_CHK("service does not end with '.php'"); } //---------------------------------------------------------- $class = explode("/", $class[sizeof($class) - 2]); //---------------------------------------------------------- $class = end($class); //---------------------------------------------------------- require_once $classPath;
public static function fileExistInFolder($dir, $lookFor, $recursive = false) { $dir = FileFolder::getPathFromFile($dir); $files = array(); $arr = explode("/", $dir); $file_wType = NULL; $path = ""; //$_POST['hey'] = array(); //$_POST['hey']['dir'] = $dir; foreach ($arr as $value) { if ($value != "") { $path .= "/" . $value; if (strpos($path, $_ENV["werm_root"]) !== false) { foreach ($lookFor as $lookFor_file) { if (FileFolder::file_exists($file = $path . "/" . $lookFor_file)) { array_push($files, $file); //break; } } } } } return $files; }
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; }