add_hook($hook, $tmp); $GLOBALS['__lazy'][$hook][] = $tmp; // throw new \core\error("\System klasė neregistruota!", EX_CODE); } function fbt($select){ global $core; if ("$select" == "") $tmp = $select; elseif (is_array($data=$select) || ($data = $core->db->query($select)) ){ $tmp = array_keys($data); // fb($tmp, "DEBUG fbt $select", FirePHP::WARN); if (($tmp = array_shift($tmp))!==NULL){ if (is_array($data[$tmp])) $tmp = array_keys($data[$tmp]); array_unshift($data, $tmp); } } $tmp = func_get_args(); array_shift($tmp); array_unshift($tmp, $data); return call_user_func_array("fb", $tmp); } function fb_ex(\Exception $e, $msg, $type=\FirePHP::ERROR){ global $BASE; if (! FB::getEnabled()) return false; $debug = new \core\debug_group($msg); fb(dechex($e->getCode()), $e->getMessage(), $type); fb(str_replace(BASE, "", $e->getFile()), "Failas", $type); fb($e->getLine(), "Eilutė", $type); if ($e instanceof \core\error) fb($e->getStack(), "Variables", $type); fb(explode("\n",str_replace(" $BASE", " ", $e->getTraceAsString())), "Trace", $type); return true; } function get_base(){ return $GLOBALS['sys']?:\system::get_instance(); } function redirect($url, $code=302){ fb($info, "REDIRECT"); @header("Status: $code",true); @header("Location: $url",true); $info=urlencode($url); ?>

Browser REDIRECT BUG!

Please go here:

define("EX_SESSION", 0x8005E55); /// @brief Klaida atgaivinant objektus, išvalom define("EX_ANOMALY", 0x8666666); /// @brief nesitikėta duomenų anomalija define("EX_OBSOLETE", 0xDEADBF); /// @brief nebenaudoti ! define("EX_TIMEOUT", 0x8888888); /// @brief užklauso laikas baigėsi define("EX_B2B", 0xBBDEAD); /// @brief B2B klaida define("EX_USER_ERROR", 0x1000000); /// @brief Vartotojas sukėlė klaidą define("EX_NEED_REPORT", 0x80000000); /// @brief Būtinas informavimas define("EX_CONDITION", 0x1000C0D); global $php_err_codes; $php_err_codes=array( 1 => "E_ERROR", 2 => "E_WARNING", 4 => "E_PARSE", 8 => "E_NOTICE", 16 => "E_CORE_ERROR", 32 => "E_CORE_WARNING", 64 => "E_COMPILE_ERROR", 128 => "E_COMPILE_WARNING", 256 => "E_USER_ERROR", 512 => "E_USER_WARNING", 1024=> "E_USER_NOTICE", 2047=> "E_ALL", 2048=> "E_STRICT", ); $ex_cb=array(); error_reporting(E_ALL & ~(E_NOTICE|E_DEPRECATED)); function er_hnd($errno, $errstr, $errfile=NULL, $errline=NULL, array $errcontext=NULL){ if (~error_reporting() & $errno){ fb($errcontext, "PHP Error[$errno @ ".str_replace(BASE,"",$errfile).":$errline] $errstr", \FirePHP::WARN); return NULL; } global $last_php_error; $last_php_error = $errcontext; throw new ErrorException($errstr, $errno, 0, $errfile, $errline); /* $last_php_error=array( "code"=> $errno, "message"=>$errstr, "file"=> $errfile, "line"=> $errline, "context"=> $errcontext, ); // $skip= E_STRICT | E_NOTICE; // if ( $errno & ~$skip ) throw new Exception("Perimta PHP aptikta klaida", EX_PHP); */ return NULL; } if (!function_exists("fb")) include_once "FirePHPCore/fb.php"; function ex_hnd($e){ global $last_php_error,$php_err_codes,$ex_cb,$BASE; restore_error_handler(); $msg=array( 'code' => $e->getCode(), 'codetxt' => NULL, 'message' => $e->getMessage(), 'file' => $e->getFile(), 'line' => $e->getLine(), 'trace' => $e->getTraceAsString(), 'context' => NULL, ); fb($e, "Exception", \FirePHP::ERROR); if($e instanceof ErrorException) $msg{'context'} = $last_php_error; $err="Klaida klasifikuojant klaidą"; $skip=array( "GLOBALS", "DSN", "report_dsn", "PASSWORD", "db", "auth", "_REQUEST", "_ENV", "_SERVER", "_SESSION", "cfg", "last_php_error", "ex_cb", "php_err_codes", "CONTENT", "CONTENT_OK", "CONTENT_DEF", "host_info", "BASE", "URLBASE", ); switch($err_code=($e->getCode() & ~EX_NEED_REPORT)){ case EX_GNRL: $err="Aptikta bendra sistemos klaida";break; case EX_CODE: $err="Aptiktas struktūrinis sistemos pažeidimas";break; case EX_KTU : $err="Aptiktas duomenų iš KTU bazės neatitikimas";break; case EX_CRACK: $err="Aptiktas bandymas laužtis į sistemą";break; case EX_FIX: $err="Atliekami šios dalies remonto darbai";break; case EX_BLOK: $err="Aptiktas šios programos dalies blokavimas";break; case EX_CONDITION: $err="Aptiktas apibrėžtų sąlygų pažeidimas";break; case EX_PHP: $err="Aptikta PHP klaida"; if (! $e instanceof ErrorException && is_array($last_php_error)){ $msg=$last_php_error; $msg{'codetxt'} = $php_err_codes[ $msg{'code'} ]; $msg{'trace'}= $e->getTraceAsString(); }elseif(! $e instanceof ErrorException) $msg="\$last_php_error nėra išsaugotos jokios informacijos apie perimtą klaidą!"; break; case EX_PERM: $err="Jums nepakanaka teisių naudotis šia programos dalimi";break; case EX_VERSION: $err="Aptiktas struktūrinis duomenų bazės nesuderinamumas";break; case EX_TIMEOUT: $err="Sistema perilgai neatsako";break; case EX_SESSION: $err="Sistemos sesijinis darbas sugadintas!"; session_destroy(); break; case EX_USER_ERROR: $err="Aptikta vartotojo veiksmų sukelta klaida";break; case EX_B2B: $err="Aptikta nežinoma duomenų mainų klaida\n" ."NEUŽDARYKITE šio lango ir BŪTINAI praneškite prižiūrinčiam personalui";break; default: $err="Aptikta neklasifikuota klaida ".dechex($err_code)."H";break; } $msg{'file'}=str_replace(BASE,"",$msg{'file'}); $msg{'trace'}=str_replace(BASE,"",$msg{'trace'}); set_time_limit(60); if (! headers_sent() && class_exists("FB", false)) FB::setEnabled(true); fb($ex_cb, "CBs"); fb(var_export(is_callable($ex_cb{$err_code}),true), "CB?"); fb(dechex($err_code), "KODAS $err_code"); if (is_array($ex_cb) && is_callable($ex_cb{$err_code}) && call_user_func($ex_cb{$err_code},$msg,$e)) exit($err_code); else fb($ex_cb{$err_code}, "CB šiam kodui neaprašytas"); $last_php_error = NULL; $js=true; while(@ob_end_clean()); if (headers_sent()) echo <<< EOS "/>"/> EOS; else{ $js=false; header("HTTP/1.1 409 Database information conflict"); header("Content-Type: text/html; charset=utf-8",true); header("Cache-control: private, no-cache, no-store, must-revalidate, maxage=0, s-maxage=0"); header("Pragma: nocache"); ob_start(); } ?> Nenumatytas atvejis...

DĖMESIO

Praneškite apie žemiau pateiktą nenumatytą duomenų būseną prižiūrinčiam personalui

base = $base?:DIRECTORY_SEPARATOR; $this->strip_base = $strip?"/$strip":NULL; if (! class_exists("FirePHP")) require_once "FirePHPCore/fb.php"; fb($_SERVER,"\$_SERVER"); $this->script = $_SERVER['REQUEST_URI']; $this->mtime = []; $this->scripts = $this->css = $this->custom = $this->nocache = $this->offline = array(); fb($this, "SETUP"); if (substr($this->manifest_file = $this->script,0,1)== "/") $this->manifest_file = substr($this->manifest_file,1); if (substr($this->manifest_file,-1) == "/") $this->manifest_file = substr($this->manifest_file,0,strlen($this->manifest_file)-1); if (! $this->manifest_file) $this->manifest_file = "index"; fb($this, "P2"); $this->manifest_file = $_SERVER['DOCUMENT_ROOT'].$this->strip_base.$this->base.basename(str_replace("/","_", $this->manifest_file),".php").".appcache"; fb($this->manifest_file, "Manifest"); } function __destruct(){ if (!$this->file) return; flock($this->file,LOCK_UN); fclose($this->file); $this->file = NULL; } function setup_gzip(){ return NULL; } function lock(){ if (!$this->file && !($this->file = fopen($this->manifest_file, "c"))) return NULL; if (! flock($this->file, LOCK_EX)) return false; return true; } function expire($at,$maxage=3600, array $options=NULL){ if (! $options) $options = []; $options += [ 'maxage' => "maxage=$maxage", 's-maxage' => "s-maxage=".(4*$maxage), ]; header("Expires: ".gmdate('D, d M Y H:i:s T',$at)." GMT"); foreach($options as $k=>$v){ if ($v === NULL) unset($options[$k]); else if (! is_numeric($k)){ $v=explode("=",$k); $options[$v[0]]=$options[$k]; unset($options[$k]); } } if (! $options){ $options = [ 'private', 'must-revalidate', 'no-cache', ]; $options = array_combine($options,$options); } header("Cache-Control: ".join(", ",$options)); if (isset($options['no-cache'])) header("Pragma: no-cache"); } function etag($check_files, array $headers=[]){ $this->vary_headers += array_combine($headers,$headers); $tmp=0; foreach((array)$check_files as $f) if (($f=filemtime($f)) > $tmp) $tmp = $f; $hash = md5($_SERVER['REQUEST_URI'].$tmp); $not_modified = false; if (isset($_SERVER['HTTP_IF_MODIFIED_SINCE']) && strtotime($_SERVER['HTTP_IF_MODIFIED_SINCE']) >= $tmp) $not_modified = true; else if (isset($_SERVER['HTTP_IF_NONE_MATCH'])) foreach(explode(", ",stripslashes($_SERVER['HTTP_IF_NONE_MATCH'])) as $t){ if ($t != $hash) continue; $not_modified = true; break; } if ($not_modified){ header("Status: 304"); exit(); } header("ETAG: \"$hash\""); header("Last-Modified: ".gmdate('D, d M Y H:i:s T',$tmp)." GMT"); } function add_defaults(){ $this->scripts = array_merge(self::$scripts_def, $this->scripts); $this->css = array_merge(self::$css_def, $this->css); } function add($file, $modified_from=NULL){ return $this->_add('custom', $file, $modified_from); } function add_css($file, $modified_from=NULL){ return $this->_add('css', $file, $modified_from); } function add_js($file, $modified_from=NULL){ return $this->_add('js', $file, $modified_from); } function add_offline($file, $pattern=NULL){ $this->offline[$pattern?:$this->base] = $file; } function nocache($file){ $this->nocache[] = $file; } protected function _add($type, $file, $modified_from=NULL){ switch($type){ case 'js': $type = "scripts";break; case 'scripts': case 'css': case 'custom': case 'offline': break; default: throw new \OutOfBoundsException("Nežinomas tipas $type");break; } if (in_array($file, $this->$type)) return true; if ($modified_from){ $time = 0; settype($modified_from, "array"); $modified_from[] = __FILE__; foreach((array)$modified_from as $r){ if (substr($r,0,1)=='@'){ if (! file_exists($tmp = substr($r,1))) throw new \InvalidArgumentException("Nurodytas neegzistuojantis failas: $tmp"); $r = filemtime($tmp); }elseif(! is_numeric($r)) $r = date($r); if ($r>$time) $time = $r; } $this->mtime[$file] = $time; } return array_push($this->$type, $file); } function __toString(){ if (! $this->scripts && !$this->css && !$this->custom && !$this->offline) return ""; $tmp = str_replace($_SERVER['DOCUMENT_ROOT'].$this->strip_base, '', $this->manifest_file); return "manifest=\"$tmp\""; } function update(){ if (! file_exists($this->manifest_file) || !is_writeable($this->manifest_file) || !filesize($this->manifest_file)) return NULL; $x = filemtime($this->manifest_file); if ($this->mtime['_']) return false; foreach(array('css','scripts','custom') as $t){ foreach($this->$t as $r){ if (($tmp=$this->mtime[$r]) || ($tmp = $this->mtime['*'])) $r = $tmp; else if (strpos($r, "://") === false) { if (! file_exists($r=$_SERVER['DOCUMENT_ROOT'].$this->base.$r)) throw new \LogicException("Nurodytas failas neegzistuoja: $r"); $r = filemtime($r); } if ($r > $x) return true; } } fb("All manifest UP-TO-DATE",FirePHP::INFO); return false; } function getManifest(){ if (! $this->manifest_data){ if ($this->update()!==false) $this(); else $this->manifest_data = file_get_contents($this->manifest_file); } return $this->manifest_data; } function output(){ $this->getManifest(); header("Status: 200"); header("Content-Type: text/cache-manifest"); header("Content-Length: ".strlen($this->manifest_data)); exit($this->manifest_data); } function __invoke($mod_time=NULL){ fb($this->manifest_file, "MANIFEST_FILE"); // fb(stat($this->manifest_file), "STAT"); if ($this->update()!==false){ $manifest = array(); $manifest[] = "CACHE MANIFEST"; $manifest[] = "# Auto-created for $_SERVER[REQUEST_URI] @ ".($t=time()).": ".date(DATE_W3C, $t); $manifest[] = "CACHE:"; foreach(array('scripts','css','custom') as $t) foreach($this->$t as $r) if (! in_array($r, $this->nocache) && ! in_array('*', $this->nocache)) $manifest[] = (substr($r,0,1)=="/"?"":$this->base).$r; $manifest[] = NULL; if ($this->nocache){ $manifest[] = "NETWORK:"; foreach($this->nocache as $r) $manifest[] = (substr($r,0,1)=="/"?"":$this->base).$r; } $manifest[] = NULL; if ($this->offline){ $manifest[] = "FALLBACK:"; foreach($this->offline as $k=>$r) $manifest[] = "$k ".(substr($r,0,1)=="/"?"":$this->base).$r; } $manifest[] = NULL; $manifest = join("\n", $manifest); $this->manifest_data = $manifest; header("X-MANIFEST: ".strlen($manifest)); if ($this->file) fwrite($this->file, $manifest); else file_put_contents($this->manifest_file, $manifest, LOCK_EX); if (! $mod_time) $mod_time = filemtime($_SERVER['DOCUMENT_ROOT'].$_SERVER['SCRIPT_NAME']); touch($this->manifest_file, $mod_time, time()); } $out = array(); $out[] = "base."\" />"; foreach($this->css as $r) $out[] = ""; foreach($this->scripts as $r) $out[] = ""; return join("\n",$out); } }