public function init($obj) { //---------------------------------------------------------- //init var //---------------------------------------------------------- $chk = array("bool" => true, 'result' => array(), "func" => "init"); //---------------------------------------------------------- if (!is_null($obj)) { if (isset($obj['zip'])) { $getFile = GetTable::go("files", array("id" => $obj['zip'])); //------------------------------------------------------ if (!$getFile['bool']) { return $getFile; } if (sizeof($getFile['result']) > 0) { //-------------------------------------------------- $projectName = $obj['project_name']; $hash = $getFile['result'][0]['hash']; $dir_relative = GlobalMas::$filesPath_relative . $hash . "/"; $dir = GlobalMas::$filesPath_absolute . $hash . "/"; $zip_path = $dir . $getFile['result'][0]['name']; $savePath = dirname($zip_path) . "/compile/" . $projectName . "/"; //----------------------------------------------------- Archive::extract($zip_path, $this->extractTo = dirname($zip_path) . "/" . FileFolder::getFileName($zip_path)); //----------------------------------------------------- //if (isset($obj['take_file_name']) && $obj['take_file_name'] == "true") $projectName = FileFolder::getFileName($zip_path); //----------------------------------------------------- $url = GenFun::get_full_url(dirname($zip_path) . "/" . rawurlencode(FileFolder::getFileName($zip_path)) . "/"); //----------------------------------------------------- $bool = $this->htmlExist_CHK($this->extractTo); } } else { if (isset($obj['url']) || is_string($obj)) { $url = isset($obj['url']) ? $obj['url'] : $obj; $bool = $this->htmlExist_CHK($url_local = GenFun::get_local_url($url)); //------------------------------------------------------ $output = CurlUtil::go(array("url" => $url)); $projectName = $this->getTitle($output); //------------------------------------------------------ if (is_null($projectName)) { $projectName = date("YmdHis"); $hash = alphaID(strtotime($projectName)); $projectName = "untitled_" . $projectName; } //------------------------------------------------------ $savePath_relative = $hash . "/" . "compile/" . $projectName . "/"; $savePath = GlobalMas::$filesPath_absolute . $savePath_relative; /*if (isset($obj['take_file_name']) && $obj['take_file_name'] == "true")*/ $useTitle = true; } else { $chk = array(); $chk['bool'] = false; $chk['error'] = true; $chk['message'] = $this->notifications_CFG(["message" => "Url could not be obtained!!!"]); die(json_encode($chk)); } } //--------------------------------------------------------- $compiler = $this->compile_CFG($url, $projectName, $savePath); //--------------------------------------------------------- if (!is_null($compiler->error)) { return $compiler->error; } //--------------------------------------------------------- //$chk['bool'] = true; // $chk['compiler'] = $compiler; $notifications = $compiler->compilerGlobal->notifications; //--------------------------------------------------------- /*if (sizeof($notifications) > 0) { $chk = $this->deleteFile($getFile['result'][0]['id'], true); $chk['message'] = $this->notifications_CFG($notifications); $chk['bool'] = false; $chk['error'] = true; return $chk; }*/ //--------------------------------------------------------- $new_zip_path = Archive::zipDir($compiler->compilePath); //--------------------------------------------------------- $prop = array(); $prop['hash'] = "{hash}"; $prop['url'] = $url; $prop['name'] = $projectName; $prop['dir'] = $savePath_relative; $prop["filesize"] = FileFolder::getFileSize($new_zip_path); if (isset($obj['zip'])) { $prop['files_id'] = $obj['zip']; } //--------------------------------------------------------- $chk = InsertINTO::go("compiles", $prop); //--------------------------------------------------------- $chk['download_link'] = GenFun::get_full_url(Import::$uber_src_path . "server/werm/services/Download.php") . "?url=" . GenFun::get_full_url($new_zip_path); $chk["filesize"] = $prop["filesize"]; $chk["url"] = $url; //--------------------------------------------------------- //$chk['project_location'] = GenFun::get_full_url($compiler->compilePath); } return $chk; }
function __construct($obj) { //----------------------------------------------------- SetPublicProp::go($this, $obj); //----------------------------------------------------- $this->compilePath = $this->compilerGlobal->compilePath . $this->save_path; $this->compilerGlobal->compileType = $this->compileType; //----------------------------------------------------- if ($this->insideCURL) { $this->complete(); } else { if (!$this->raw) { $prop = array("output" => $this->output, "minify" => $this->minify, "forceDownload" => $this->forceDownload, "compilerGlobal" => $this->compilerGlobal, "imagesProp" => $this->imagesProp, "compilePath" => $this->compilePath, "compileType" => $this->compileType); //--------------------------------------------- $this->css = new Compile_CSS(ArrayUtil::array_replace_recursive($prop, $this->cssProp)); $this->output_updated = $this->css->output_updated; //--------------------------------------------- $prop['output'] = $this->output_updated; $this->js = new Compile_JS(ArrayUtil::array_replace_recursive($prop, $this->jsProp)); $this->output_updated = $this->js->output_updated; //--------------------------------------------- $prop['output'] = $this->output_updated; $this->tmpl = new Compile_TMPL(ArrayUtil::array_replace_recursive($prop, $this->tmplProp)); $this->output_updated = $this->tmpl->output_updated; //----------------------------------------------------- $prop = array("src_content" => $this->output_updated, "forceDownload" => $this->forceDownload, "compilerGlobal" => $this->compilerGlobal, "compilePath" => $this->compilePath); $this->output_images = new Compile_Images($prop); $this->output_images->init($this->imagesProp); $this->output_updated = $this->output_images->src_content_updated; //--------------------------------------------- $this->css->output_updated = $this->output_updated; $this->css->compile(); $this->output_updated = $this->css->output_updated; //--------------------------------------------- $this->js->output_updated = $this->output_updated; $this->js->compile(); $this->output_updated = $this->js->output_updated; //--------------------------------------------- $this->tmpl->output_updated = $this->output_updated; $this->tmpl->compile(); $this->output_updated = $this->tmpl->output_updated; //--------------------------------------------- } $this->copy_CFG(); } //$this->compiler->getFiles($this->output, ""); //----------------------------------------------------- $this->output_updated = Compiler::markUp_CHK($this->output_updated); //----------------------------------------------------- //if ($this->compileType == "inject") $this->output_updated = str_replace("<head>","<head>".PHP_EOL.$this->mergedCode.PHP_EOL, $this->output_updated); //----------------------------------------------------- /*if ($this->compileType != "inject")*/ $this->output_updated = str_replace("<head>", "<head>" . PHP_EOL . $this->css->extLinks . PHP_EOL, $this->output_updated); //----------------------------------------------------- $this->output_updated = str_replace("<head>", "<head>" . PHP_EOL . $this->js->extLinks . PHP_EOL, $this->output_updated); //----------------------------------------------------- $this->clean_output(); //----------------------------------------------------- $this->output_updated = str_replace("<head>", '<head><meta charset="utf-8">', $this->output_updated); //----------------------------------------------------- if (is_array($this->outputContent)) { FileFolder::file_put_contents($this->compilePath . $this->outputContent['saveas'], $this->output_updated); } //----------------------------------------------------- $this->output_images->compile(); //----------------------------------------------------- Archive::zipDir($this->compilePath); }