예제 #1
0
<?php

require_once dirname(__FILE__) . "/ProjectGlobal.php";
require_once Import::$uber_src_path . "/server/smarty/libs/Smarty.class.php";
//------------------------------------------------------------------------------------------------
function compile_CFG($prop)
{
    $smarty = new Smarty();
    $smarty->assign($prop);
    $string = $smarty->fetch(dirname(__FILE__) . '/compile.tpl');
    return $string;
}
//----------------------------------------
if (isset($_GET['compile']) && $_GET['compile'] == 1 && !isset($_COOKIE['compile_curl'])) {
    $compiler = new Compiler(ProjectGlobal::$compileObj);
    foreach ($compiler->compilers as $key => $compile) {
        $zipPath = rtrim(GenFun::get_full_url($compile->compilePath), "/") . ".zip";
        $prop = ["save_path" => $compile->save_path, "filesize" => number_format(FileFolder::getFileSize($zipPath)), "zipPath" => $zipPath, "fullPath" => GenFun::get_full_url($compile->compilePath), "width" => $_GET['width'], "height" => $_GET['height']];
        if ($key == 0) {
            $prop['style'] = true;
        }
        echo compile_CFG($prop);
    }
    //krumo($compiler);
}
//----------------------------------------
예제 #2
0
 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;
 }