示例#1
0
 public static function obj_CFG($class, $valueArr, $throwError = true)
 {
     //----------------------------------------------------------
     //init var
     //----------------------------------------------------------
     $chk = $traceID != NULL ? array("bool" => true, "func" => $traceID . ": setPublicProp") : array("bool" => true, "func" => ": setPublicProp");
     $bool = true;
     //----------------------------------------------------------
     if (is_null($valueArr)) {
         $chk['message'] = "valueArr is 'NULL";
         return $class;
     }
     //----------------------------------------------------------
     foreach ($valueArr as $i => $value) {
         if (gettype($class) == "object" and !property_exists($class, $i)) {
             $bool = false;
         } else {
             if (gettype($class) == "array" and empty($class[$i])) {
                 $bool = false;
             }
         }
         //--------------------------------------------------
         $class = SetPublicProp::findObj($class, $i);
         $i = $class['string'];
         $class = $class['class'];
         //--------------------------------------------------
         if (!$bool && $throwError) {
             $error = array_merge($chk, array("bool" => 0, "result" => $i . " is not a property"));
             $error['$valueArr'] = print_r($valueArr, true);
             print_r($error);
             trigger_error($i . " is not a property in '" . get_class($class) . "'", E_USER_ERROR);
         }
         //--------------------------------------------------
         if ($bool && gettype($class) == "object") {
             $valueArr[$i] = GenFun::constCHK($valueArr[$i]);
             $class->{$i} = $valueArr[$i];
         } else {
             if (gettype($class) == "array") {
                 $valueArr[$i] = GenFun::constCHK($valueArr[$i]);
                 $class[$i] = $valueArr[$i];
             }
         }
     }
     //----------------------------------------------------------
     if ($chk['bool']) {
         $chk = $class;
     }
     //----------------------------------------------------------
     return $chk;
 }
示例#2
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;
 }
示例#3
0
    Constants::$loggedIN = Account_v0::getUserSession($_COOKIE["user"]);
}
//-----------------------------------------------------------------------------
$_OBJ = isset($_GET["service"]) ? $_GET : $_POST;
//-----------------------------------------------------------------------------
indexExist($_OBJ, array('service', 'functionName'));
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
//imports
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
constExist("Constants", array("HOST", "PASS", "USER"));
//----------------------------------------------------------
require_once Import::$uber_src_path . "server/werm/utils/GenFun.php";
//----------------------------------------------------------
$classPath = GenFun::constCHK($_OBJ['service']);
//----------------------------------------------------------
$class = explode(".", $classPath);
//----------------------------------------------------------
if ($class[1] != "php") {
    die("service does not end with '.php'");
}
//----------------------------------------------------------
$class = explode("/", $class[sizeof($class) - 2]);
//----------------------------------------------------------
$class = end($class);
//----------------------------------------------------------
require_once Import::$uber_src_path . $classPath;
//----------------------------------------------------------
if (isset($_OBJ['staticClass'])) {
    if ($_OBJ['staticClass'] == "true") {