main.php

来自「视频监控网络部分的协议ddns,的模块的实现代码,请大家大胆指正.」· PHP 代码 · 共 762 行 · 第 1/3 页

PHP
762
字号
<?php//// +----------------------------------------------------------------------+// | PHP Version 4                                                        |// +----------------------------------------------------------------------+// | Copyright (c) 1997, 1998, 1999, 2000, 2001, 2002, 2003 The PHP Group |// +----------------------------------------------------------------------+// | This source file is subject to version 2.02 of the PHP license,      |// | that is bundled with this package in the file LICENSE, and is        |// | available at through the world-wide-web at                           |// | http://www.php.net/license/2_02.txt.                                 |// | If you did not receive a copy of the PHP license and are unable to   |// | obtain it through the world-wide-web, please send a note to          |// | license@php.net so we can mail you a copy immediately.               |// +----------------------------------------------------------------------+// | Authors: Wolfram Kriesing <wolfram@kriesing.de>                      |// +----------------------------------------------------------------------+//  $Id: Main.php,v 1.18 2003/12/01 21:54:39 cain Exp $//require_once 'PEAR.php';require_once 'HTML/Template/Xipe/Options.php';require_once 'HTML/Template/Xipe/Filter/Internal.php';require_once 'Log.php';/***   the intention is to use normal php in the template without the need to write*   <?php or <?= all the time*   but smarty, IT[X] and so on just dont give me enough power (i need referencing the reference of a variable and so on)*   and i want to have the entire power of php inside the template, without*   making the code look so ugly as it sometimes does, only because you want to write a varibale*   so this template engine will not do much, but fulfill my needs**   @package    HTML_Template_Xipe**/class HTML_Template_Xipe_Main extends HTML_Template_Xipe_Options{// FIXXME a problem we have here: is that if i use {include(a.php)} the varibales of this file overwrite the ones// set for the template where it is included, ... ***create a namespace for each file*** somehow, which is unique for every tempalte ... but how// without the need for the user to change its programming behaviour,// one solution would be copying everything from $GLOBALS into a unique varibale and replacing all variables in the// template using this unique variable, but this makes it a HUGE overhead, but would work// FIXXME2 by testing a site i realized, that a lot of php tags inside a tempalte slow slow down rendering// very much, somehoe it seems php is not too good in rendering html-pages with a lot of php tags inside// so we can write a filter, which can be applied that translates the entire template to use echo's only :-)// some work ha?// TODO// - enable a taglib/filter for sql statements inside the template, even though i will never use it :-)//   if we put that in a seperate file we can load it only on request, saves some php-compiling time// - add a taglib/filter for translate, smthg like: {%t $phpValue %}, to explicitly translate a string//   in case someone doesnt like to use the filter "applyTranslateFunction"// - add a filter for converting strings to html-entities, could work like "applyTranslateFunction" on//   mark up delimiters, or could be a taglib-tag too ... whatever//// MAY BE features// - url obfuscating (or whatever that is called), rewrite urls and decode them when retreiving a call to a specific page ... somehow//   i dont know if that belongs in a template engine, may be just write in the tutorial how to attach those products easily//   using a filter or whatever// -////    /**    *   for customizing the class    *    *   compileDir'    =>  'tmp',  // by default its always the same one as where the template lies in, this might not be desired    *   delimiter'     =>  array('{','}'),    *   templateDir'   =>  '',    *   autoBraces'    =>  true,   // see method 'autoBraces' for explaination    *   makePhpTags'   =>  true,   // set this to false if you dont want the delimiters to be translated to php tags automativally    *   forceCompile'  =>  false,  // only suggested for debugging    *   xmlConfigFile' =>  'config.xml', // name of the xml config file which might be found anywhere in the directory structure    *   locale'        =>  'en',   // default language    *   cache'         =>  array(                               'time'      => false// set this to the number of seconds for which the final (html-)file shall be cached                                                    // false means the file is not cached at all                                                    // if you set it to 0 it is cached forever                                ,'depends'  => 0    // what does it depend on if the cache file can be reused                                                    // i.e. could be $_REQUEST $_COOKIES                                ),    *   logLevel'      =>  1,      // 1 - only logs new compiles, 0 - logs nothing, 2 - logs everything even only deliveries    *   filterLevel'   =>  10,     // 0    is no filter, use this if u want to register each filter u need yourself                                    // 1-7  can still be defined :-)                                    // 8    comments stay in the code                                    // 9    as 10 only that the resulting HTML-code stays readable                                    // 10   use all default filters, uses the allPre/Postfilters methods of each filter class    *   enable-XMLConfig'=>false,    *   enable-Cache'  =>  false,  // if you only turn on the Cache XMLConfig will be turned on too, since it is needed    *   verbose'       =>  true,   // set this to true if the engine shall output errors on the screen                                    // in addition to returning a PEAR_Error                                    // this makes getting the engine running easier                                    // on a production system you should turn this off    *   logFileExtension'=>'log',  // the extension for the log file    *   cacheFileExtension'=>'html',// file extension for the cached file    *   compiledTemplateExtension'=>'php',// the extension the generated template shall have    *    *   The templateExtension is currently used in the Filter/TagLib, for determining if    *   an included file is a template file or a macro file. Templates are handled a bit    *   differently, they are included as often as the {%include%} tag occurs.    *   Macro-files are surrounded by an if() clause, to prevent multiple declarations    *   of macros (which are simply php-functions)    *   <br>    *       'templateExtension'=>   'tpl',<br>    *       'macroExtension'=>      'mcr'    *    *   @access private    *   @var    array   $options    the options for initializing the template class    */    var $options = array(                            'compileDir'    =>  'tmp',                            'delimiter'     =>  array('{','}'),                            'templateDir'   =>  '',                            'autoBraces'    =>  true,                            'makePhpTags'   =>  true,                            'forceCompile'  =>  false,                            'xmlConfigFile' =>  'config.xml',                            'locale'        =>  'en',                            'cache'         =>  array(                                                    'time'      => false                                                    ,'depends'  => 0                                                     ),                            'logLevel'      =>  1,                            'filterLevel'   =>  10,                            'enable-XMLConfig'=>false,                            'enable-Cache'  =>  false,                            'verbose'       =>  true,                            'logFileExtension'=>'log',                            'cacheFileExtension'=>'html',                            'compiledTemplateExtension'=>'php',                            'debug'         =>  0,                            'templateExtension'=>   'tpl',                            'macroExtension'=>      'mcr'                        );    /**    *   the current template file for this instance    */    var $_templateFile = '';    var $_compiledTemplate = '';    var $_didSetup = false;    var $_logFileName = '';    var $_compiledFilePrefix = '';    /**    *   @var    boolean     will be set to true if a recompile is needed,    *                       this is when any xml-config file that applies to the current template has changed    *                       or the template itself, or if the compiled template was removed, etc...    */    var $_needsRecompile = false;    /**    *   saves the preFilters which will be applied before compilation    *    *   @access private    *   @var    array   methods/functions that will be called as prefilter    */    var $_preFilters = array();    /**    *   saves the postFilters which will be applied after compilation    *    *   @access private    *   @var    array   methods/functions that will be called as postfilter    */    var $_postFilters = array();    /**    *   @var    float   the time compiling/delivering took    */    var $_compileTime = 0;                               /**    *   @var    boolean if the template was compiled    *   @see    compiled(), compile()    */    var $_compiled = false;    var $logObject = null;        /**    *   the constructor, pass the options to it as needed    *    *   @see        $options    *   @version    01/12/03    *   @access     public    *   @author     Wolfram Kriesing <wolfram@kriesing.de>    */    function HTML_Template_Xipe_Main( $options=array() )    {        foreach( $options as $key=>$aOption )            $this->setOption( $key , $aOption );        // replace (multiple) backslashes with forward slashes and replace multiple slashes with single slashes        // this way we can quitely sleep and use windows too :-) and only work with forward slashes        // all over the template engine        // the replacing of multiple slashes is doen because i realized that something like        // $DOCUMENT_ROOT.'/libs/' might come out to be '/document/root//libs' depending on the apache configuration        $this->setOption('compileDir' , preg_replace("/\\\+|\/+/" , DIRECTORY_SEPARATOR , $this->getOption('compileDir') ));        $this->setOption('templateDir' , preg_replace("/\\\+|\/+/" , DIRECTORY_SEPARATOR , $this->getOption('templateDir') ));    }    /**    *   this method sets up an instance of the engine    *   since the philosophie has changed to manage a single object-instance for    *   each page we need a method here so we dont need to setup all the internal    *   vars many times    *    *   @version    02/05/25    *   @access     public    *   @author     Wolfram Kriesing <wolfram@kriesing.de>    *   @param      string      the template filename for which this instance shall be setup    *   @return     boolean     if setup was necessary or not    */    function setup( $filename )    {        if( $this->_didSetup == true )            return false;        //        // setup all the internal vars, like compiledTemplate, etc.        //        $this->_templateFile = $filename;/*        $pathInfo = pathinfo($this->_templateFile);        if( in_array($pathInfo['extension'],array('sxw','sxc','sxi','sxd')) )        {        }*/        // build the filename-prefix that will be used for the compiled file        if( PEAR::isError( $ret = $this->_getCompiledFilePrefix() ) )        {            return $ret;        }        $this->_compiledFilePrefix = $ret;//print "this->_templateFile = $this->_templateFile<br>this->_compiledFilePrefix = $this->_compiledFilePrefix<br><br>";        $this->_compiledTemplate = $this->_compiledFilePrefix.$this->getOption('compiledTemplateExtension');//print ".........BEFORE SETUP METHOD..........<br>";//print_r($this);print "<br><br>";        //

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?