Exemplo n.º 1
0
function newObj($class)
{
    global $SYS, $MEMORY_CACHE;
    $bm = getmicrotime();
    if (class_exists("Ente_{$class}")) {
        debug("Clase ya cargada", "cyan");
        return eval("return new Ente_{$class}({$class});");
    }
    if (isset($MEMORY_CACHE["{$class}"])) {
        debug("Usando clase base ya cargada", "cyan");
        return new Ente($class);
    }
    if (file_exists($SYS["DOCROOT"] . $SYS["DATADEFPATH"] . $class . ".php") && !class_exists("Ente_{$class}")) {
        debug("Analizando clase extendida en " . $SYS["DOCROOT"] . $SYS["DATADEFPATH"] . $class . ".php", "yellow");
        $handle = fopen($SYS["DOCROOT"] . $SYS["DATADEFPATH"] . $class . ".php", "r");
        $len = filesize($SYS["DOCROOT"] . $SYS["DATADEFPATH"] . $class . ".php");
        $buffer = fread($handle, $len);
        fclose($handle);
        $buffer = str_replace("<?php", "", $buffer);
        $buffer = str_replace("?>", "", $buffer);
        debug("initing time  Ente_{$class} " . (getmicrotime() - $bm) . " s.", "yellow");
        return eval("\n\t\tclass Ente_{$class} extends Ente {\n\t\t" . $buffer . "\t\n\t\t}\n\t\treturn new Ente_{$class}({$class});\n\t\t");
    } else {
        if (e_file_exists("local/Class/{$class}.php") && !class_exists("Ente_{$class}")) {
            debug("Analizando clase extendida en local/Class/{$class}.php", "yellow");
            $handle = c_fopen("local/Class/{$class}.php", "rt", True);
            $len = c_filesize("local/Class/{$class}.php");
            $buffer = fread($handle, $len);
            fclose($handle);
            $buffer = str_replace("<?php", "", $buffer);
            $buffer = str_replace("?>", "", $buffer);
            debug("initing time Ente_{$class} " . (getmicrotime() - $bm) . " s.", "yellow");
            return eval("\n\t\tclass Ente_{$class} extends Ente {\n\t\t" . $buffer . "\t\n\t\t}\n\t\treturn new Ente_{$class}({$class});\n\t\t");
        } else {
            if (class_exists("Ente_{$class}")) {
                debug("Clase ya cargada Ente_{$class}", "cyan");
                return eval("return new Ente_{$class}({$class});");
            } else {
                debug("Cargando clase base {$class}", "cyan");
                return eval("\n\t\t\t\tclass Ente_{$class} extends Ente {}\n\t\t\t\treturn new Ente_{$class}({$class});\n\t\t\t");
                return new Ente($class);
            }
        }
    }
}
Exemplo n.º 2
0
 function Ente($name)
 {
     global $SYS, $TrazaStatus, $MEMORY_CACHE;
     $this->properties_desc = array();
     $this->properties = array();
     $this->properties_type = array();
     $this->ROOT = $SYS["ROOT"];
     $cache_time = false;
     $source_time = false;
     /* Soporte para precompilados */
     if (!isset($MEMORY_CACHE["{$name}"])) {
         if (file_exists(session_save_path() . "/coreg2_cache/{$SYS["ASCACHEDIR"]}/" . $name . ".cached_core_object_properties_" . $SYS["PROJECT"])) {
             $cache_time = filemtime(session_save_path() . "/coreg2_cache/{$SYS["ASCACHEDIR"]}/" . $name . ".cached_core_object_properties_" . $SYS["PROJECT"]);
         } else {
             $cache_time = false;
         }
         if (file_exists($SYS["DOCROOT"] . $SYS["DATADEFPATH"] . $name . ".def")) {
             $source_time = filemtime($SYS["DOCROOT"] . $SYS["DATADEFPATH"] . $name . ".def");
         } else {
             if (e_file_exists("local/Class/{$name}.def")) {
                 $source_time = filemtime(e_file_exists("local/Class/{$name}.def"));
             } else {
                 $source_time = false;
             }
         }
         if ($cache_time !== False && $cache_time > $source_time) {
             debug("Cargando definicion compilada de '{$name}'", "yellow");
             $fd = c_fopen(session_save_path() . "/coreg2_cache/{$SYS["ASCACHEDIR"]}/" . $name . ".cached_core_object_properties_" . $SYS["PROJECT"], "r");
             $buffer = "";
             while (!feof($fd)) {
                 $buffer .= fgets($fd, 4096);
             }
             fclose($fd);
             $prop = unserialize($buffer);
             unset($buffer);
         } else {
             /* Establece las propiedades desde un fichero XML */
             if (file_exists($SYS["DOCROOT"] . $SYS["DATADEFPATH"] . $name . ".def")) {
                 debug("Fichero definicion " . $SYS["DOCROOT"] . $SYS["DATADEFPATH"] . $name . ".def existe");
                 $file = $SYS["DOCROOT"] . $SYS["DATADEFPATH"] . $name . ".def";
             } else {
                 if (e_file_exists("local/Class/{$name}.def")) {
                     debug($SYS["BASE"] . "/local/Class/{$name}.def existe");
                     $file = e_file_exists("local/Class/{$name}.def");
                 } else {
                     die(debug($SYS["BASE"] . "/local/Class/{$name}.def no  existe"));
                 }
             }
             debug("Cargando definicion de '{$name}'", "yellow");
             $prop = load_prop($file);
             debug("Compilando dinamicamente '{$name}'", "magenta");
             $fd = c_fopen(session_save_path() . "/coreg2_cache/{$SYS["ASCACHEDIR"]}/" . $name . ".cached_core_object_properties_" . $SYS["PROJECT"], "w");
             fwrite($fd, serialize($prop), strlen(serialize($prop)));
             fclose($fd);
         }
         $MEMORY_CACHE["{$name}"] = serialize($prop);
     } else {
         $prop = unserialize($MEMORY_CACHE["{$name}"]);
     }
     $this->properties = $prop["p"];
     $this->properties_desc = $prop["pd"];
     $this->properties_type = $prop["pt"];
     $this->_normalize();
     $this->name = $name;
 }