Fatal Error Invalid controller specified (robots.txt)
EXCEPTION_NO_CONTROLLER : 0
{main}
open/home/wallst/ftp/diamondesign/library/Zend/Controller/Dispatcher/Standard.php
1     <?php
2    
/**
3     * Zend Framework
4     *
5     * LICENSE
6     *
7     * This source file is subject to the new BSD license that is bundled
8     * with this package in the file LICENSE.txt.
9     * It is also available through the world-wide-web at this URL:
10    * http://framework.zend.com/license/new-bsd
11    * If you did not receive a copy of the license and are unable to
12    * obtain it through the world-wide-web, please send an email
13    * to license@zend.com so we can send you a copy immediately.
14    *
15    * @category   Zend
16    * @package    Zend_Controller
17    * @subpackage Dispatcher
18    * @copyright  Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
19    * @license    http://framework.zend.com/license/new-bsd     New BSD License
20    */
21   
22   /** Zend_Loader */
23   
require_once 'Zend/Loader.php';
24   
25   
/** Zend_Controller_Dispatcher_Abstract */
26   
require_once 'Zend/Controller/Dispatcher/Abstract.php';
27   
28   
/**
29    * @category   Zend
30    * @package    Zend_Controller
31    * @subpackage Dispatcher
32    * @copyright  Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
33    * @license    http://framework.zend.com/license/new-bsd     New BSD License
34    */
35   
class Zend_Controller_Dispatcher_Standard extends Zend_Controller_Dispatcher_Abstract
36   
{
37       
/**
38        * Current dispatchable directory
39        * @var string
40        */
41       
protected $_curDirectory;
42   
43       
/**
44        * Current module (formatted)
45        * @var string
46        */
47       
protected $_curModule;
48   
49       
/**
50        * Controller directory(ies)
51        * @var array
52        */
53       
protected $_controllerDirectory = array();
54   
55       
/**
56        * Constructor: Set current module to default value
57        *
58        * @param  array $params
59        * @return void
60        */
61       
public function __construct(array $params = array())
62       {
63           
parent::__construct($params);
64           
$this->_curModule $this->getDefaultModule();
65       }
66   
67       
/**
68        * Add a single path to the controller directory stack
69        *
70        * @param string $path
71        * @param string $module
72        * @return Zend_Controller_Dispatcher_Standard
73        */
74       
public function addControllerDirectory($path$module null)
75       {
76           if (
null === $module) {
77               
$module $this->_defaultModule;
78           }
79   
80           
$module = (string) $module;
81           
$path   rtrim((string) $path'/\\');
82   
83           
$this->_controllerDirectory[$module] = $path;
84           return 
$this;
85       }
86   
87       
/**
88        * Set controller directory
89        *
90        * @param array|string $directory
91        * @return Zend_Controller_Dispatcher_Standard
92        */
93       
public function setControllerDirectory($directory$module null)
94       {
95           
$this->_controllerDirectory = array();
96   
97           if (
is_string($directory)) {
98               
$this->addControllerDirectory($directory$module);
99           } elseif (
is_array($directory)) {
100              foreach ((array) 
$directory as $module => $path) {
101                  
$this->addControllerDirectory($path$module);
102              }
103          } else {
104              require_once 
'Zend/Controller/Exception.php';
105              throw new 
Zend_Controller_Exception('Controller directory spec must be either a string or an array');
106          }
107  
108          return 
$this;
109      }
110  
111      
/**
112       * Return the currently set directories for Zend_Controller_Action class
113       * lookup
114       *
115       * If a module is specified, returns just that directory.
116       *
117       * @param  string $module Module name
118       * @return array|string Returns array of all directories by default, single
119       * module directory if module argument provided
120       */
121      
public function getControllerDirectory($module null)
122      {
123          if (
null === $module) {
124              return 
$this->_controllerDirectory;
125          }
126  
127          
$module = (string) $module;
128          if (
array_key_exists($module$this->_controllerDirectory)) {
129              return 
$this->_controllerDirectory[$module];
130          }
131  
132          return 
null;
133      }
134  
135      
/**
136       * Remove a controller directory by module name
137       * 
138       * @param  string $module 
139       * @return bool
140       */
141      
public function removeControllerDirectory($module)
142      {
143          
$module = (string) $module;
144          if (
array_key_exists($module$this->_controllerDirectory)) {
145              unset(
$this->_controllerDirectory[$module]);
146              return 
true;
147          }
148          return 
false;
149      }
150  
151      
/**
152       * Format the module name.
153       *
154       * @param string $unformatted
155       * @return string
156       */
157      
public function formatModuleName($unformatted)
158      {
159          if ((
$this->_defaultModule == $unformatted) && !$this->getParam('prefixDefaultModule')) {
160              return 
$unformatted;
161          }
162  
163          return 
ucfirst($this->_formatName($unformatted));
164      }
165  
166      
/**
167       * Format action class name
168       *
169       * @param string $moduleName Name of the current module
170       * @param string $className Name of the action class
171       * @return string Formatted class name
172       */
173      
public function formatClassName($moduleName$className)
174      {
175          return 
$this->formatModuleName($moduleName) . '_' $className;
176      }
177  
178      
/**
179       * Convert a class name to a filename
180       *
181       * @param string $class
182       * @return string
183       */
184      
public function classToFilename($class)
185      {
186          return 
str_replace('_'DIRECTORY_SEPARATOR$class) . '.php';
187      }
188  
189      
/**
190       * Returns TRUE if the Zend_Controller_Request_Abstract object can be
191       * dispatched to a controller.
192       *
193       * Use this method wisely. By default, the dispatcher will fall back to the
194       * default controller (either in the module specified or the global default)
195       * if a given controller does not exist. This method returning false does
196       * not necessarily indicate the dispatcher will not still dispatch the call.
197       *
198       * @param Zend_Controller_Request_Abstract $action
199       * @return boolean
200       */
201      
public function isDispatchable(Zend_Controller_Request_Abstract $request)
202      {
203          
$className $this->getControllerClass($request);
204          if (!
$className) {
205              return 
false;
206          }
207  
208          if (
class_exists($classNamefalse)) {
209              return 
true;
210          }
211  
212          
$fileSpec    $this->classToFilename($className);
213          
$dispatchDir $this->getDispatchDirectory();
214          
$test        $dispatchDir DIRECTORY_SEPARATOR $fileSpec;
215          return 
Zend_Loader::isReadable($test);
216      }
217  
218      
/**
219       * Dispatch to a controller/action
220       *
221       * By default, if a controller is not dispatchable, dispatch() will throw
222       * an exception. If you wish to use the default controller instead, set the
223       * param 'useDefaultControllerAlways' via {@link setParam()}.
224       *
225       * @param Zend_Controller_Request_Abstract $request
226       * @param Zend_Controller_Response_Abstract $response
227       * @return void
228       * @throws Zend_Controller_Dispatcher_Exception
229       */
230      
public function dispatch(Zend_Controller_Request_Abstract $requestZend_Controller_Response_Abstract $response)
231      {
232          
$this->setResponse($response);
233  
234          
/**
235           * Get controller class
236           */
237          
if (!$this->isDispatchable($request)) {
238              
$controller $request->getControllerName();
239              if (!
$this->getParam('useDefaultControllerAlways') && !empty($controller)) {
240                  require_once 
'Zend/Controller/Dispatcher/Exception.php';
241                  throw new 
Zend_Controller_Dispatcher_Exception('Invalid controller specified (' $request->getControllerName() . ')');
242              }
243  
244              
$className $this->getDefaultControllerClass($request);
245          } else {
246              
$className $this->getControllerClass($request);
247              if (!
$className) {
248                  
$className $this->getDefaultControllerClass($request);
249              }
250          }
251  
252          
/**
253           * Load the controller class file
254           */
255          
$className $this->loadClass($className);
256  
257          
/**
258           * Instantiate controller with request, response, and invocation
259           * arguments; throw exception if it's not an action controller
260           */
261          
$controller = new $className($request$this->getResponse(), $this->getParams());
262          if (!
$controller instanceof Zend_Controller_Action) {
263              require_once 
'Zend/Controller/Dispatcher/Exception.php';
264              throw new 
Zend_Controller_Dispatcher_Exception("Controller '$className' is not an instance of Zend_Controller_Action");
265          }
266  
267          
/**
268           * Retrieve the action name
269           */
270          
$action $this->getActionMethod($request);
271  
272          
/**
273           * Dispatch the method call
274           */
275          
$request->setDispatched(true);
276  
277          
// by default, buffer output
278          
$disableOb $this->getParam('disableOutputBuffering');
279          
$obLevel   ob_get_level();
280          if (empty(
$disableOb)) {
281              
ob_start();
282          }
283  
284          try {
285              
$controller->dispatch($action);
286          } catch (
Exception $e) {
287              
// Clean output buffer on error
288              
$curObLevel ob_get_level();
289              if (
$curObLevel $obLevel) {
290                  do {
291                      
ob_get_clean();
292                      
$curObLevel ob_get_level();
293                  } while (
$curObLevel $obLevel);
294              }
295  
296              throw 
$e;
297          }
298  
299          if (empty(
$disableOb)) {
300              
$content ob_get_clean();
301              
$response->appendBody($content);
302          }
303  
304          
// Destroy the page controller instance and reflection objects
305          
$controller null;
306      }
307  
308      
/**
309       * Load a controller class
310       *
311       * Attempts to load the controller class file from
312       * {@link getControllerDirectory()}.  If the controller belongs to a
313       * module, looks for the module prefix to the controller class.
314       *
315       * @param string $className
316       * @return string Class name loaded
317       * @throws Zend_Controller_Dispatcher_Exception if class not loaded
318       */
319      
public function loadClass($className)
320      {
321          
$finalClass  $className;
322          if ((
$this->_defaultModule != $this->_curModule
323              || 
$this->getParam('prefixDefaultModule')) 
324          {
325              
$finalClass $this->formatClassName($this->_curModule$className);
326          }
327          if (
class_exists($finalClassfalse)) {
328              return 
$finalClass;
329          }
330  
331          
$dispatchDir $this->getDispatchDirectory();
332          
$loadFile    $dispatchDir DIRECTORY_SEPARATOR $this->classToFilename($className);
333  
334          if (!include_once 
$loadFile) {
335              require_once 
'Zend/Controller/Dispatcher/Exception.php';
336              throw new 
Zend_Controller_Dispatcher_Exception('Cannot load controller class "' $className '" from file "' $loadFile "'");
337          }
338  
339          if (!
class_exists($finalClassfalse)) {
340              require_once 
'Zend/Controller/Dispatcher/Exception.php';
341              throw new 
Zend_Controller_Dispatcher_Exception('Invalid controller class ("' $finalClass '")');
342          }
343  
344          return 
$finalClass;
345      }
346  
347      
/**
348       * Get controller class name
349       *
350       * Try request first; if not found, try pulling from request parameter;
351       * if still not found, fallback to default
352       *
353       * @param Zend_Controller_Request_Abstract $request
354       * @return string|false Returns class name on success
355       */
356      
public function getControllerClass(Zend_Controller_Request_Abstract $request)
357      {
358          
$controllerName $request->getControllerName();
359          if (empty(
$controllerName)) {
360              if (!
$this->getParam('useDefaultControllerAlways')) {
361                  return 
false;
362              }
363              
$controllerName $this->getDefaultControllerName();
364              
$request->setControllerName($controllerName);
365          }
366  
367          
$className $this->formatControllerName($controllerName);
368  
369          
$controllerDirs      $this->getControllerDirectory();
370          
$module $request->getModuleName();
371          if (
$this->isValidModule($module)) {
372              
$this->_curModule    $module;
373              
$this->_curDirectory $controllerDirs[$module];
374          } elseif (
$this->isValidModule($this->_defaultModule)) {
375              
$request->setModuleName($this->_defaultModule);
376              
$this->_curModule    $this->_defaultModule;
377              
$this->_curDirectory $controllerDirs[$this->_defaultModule];
378          } else {
379              require_once 
'Zend/Controller/Exception.php';
380              throw new 
Zend_Controller_Exception('No default module defined for this application');
381          }
382  
383          return 
$className;
384      }
385  
386      
/**
387       * Determine if a given module is valid
388       *
389       * @param  string $module
390       * @return bool
391       */
392      
public function isValidModule($module)
393      {
394          if (!
is_string($module)) {
395              return 
false;
396          }
397  
398          
$module        strtolower($module);
399          
$controllerDir $this->getControllerDirectory();
400          foreach (
array_keys($controllerDir) as $moduleName) {
401              if (
$module == strtolower($moduleName)) {
402                  return 
true;
403              }
404          }
405  
406          return 
false;
407      }
408  
409      
/**
410       * Retrieve default controller class
411       *
412       * Determines whether the default controller to use lies within the
413       * requested module, or if the global default should be used.
414       *
415       * By default, will only use the module default unless that controller does
416       * not exist; if this is the case, it falls back to the default controller
417       * in the default module.
418       *
419       * @param Zend_Controller_Request_Abstract $request
420       * @return string
421       */
422      
public function getDefaultControllerClass(Zend_Controller_Request_Abstract $request)
423      {
424          
$controller $this->getDefaultControllerName();
425          
$default    $this->formatControllerName($controller);
426          
$request->setControllerName($controller)
427                  ->
setActionName(null);
428  
429          
$module              $request->getModuleName();
430          
$controllerDirs      $this->getControllerDirectory();
431          
$this->_curModule    $this->_defaultModule;
432          
$this->_curDirectory $controllerDirs[$this->_defaultModule];
433          if (
$this->isValidModule($module)) {
434              
$found false;
435              if (
class_exists($defaultfalse)) {
436                  
$found true;
437              } else {
438                  
$moduleDir $controllerDirs[$module];
439                  
$fileSpec  $moduleDir DIRECTORY_SEPARATOR $this->classToFilename($default);
440                  if (
Zend_Loader::isReadable($fileSpec)) {
441                      
$found true;
442                      
$this->_curDirectory $moduleDir;
443                  }
444              }
445              if (
$found) {
446                  
$request->setModuleName($module);
447                  
$this->_curModule    $this->formatModuleName($module);
448              }
449          } else {
450              
$request->setModuleName($this->_defaultModule);
451          }
452  
453          return 
$default;
454      }
455  
456      
/**
457       * Return the value of the currently selected dispatch directory (as set by
458       * {@link getController()})
459       *
460       * @return string
461       */
462      
public function getDispatchDirectory()
463      {
464          return 
$this->_curDirectory;
465      }
466  
467      
/**
468       * Determine the action name
469       *
470       * First attempt to retrieve from request; then from request params
471       * using action key; default to default action
472       *
473       * Returns formatted action name
474       *
475       * @param Zend_Controller_Request_Abstract $request
476       * @return string
477       */
478      
public function getActionMethod(Zend_Controller_Request_Abstract $request)
479      {
480          
$action $request->getActionName();
481          if (empty(
$action)) {
482              
$action $this->getDefaultAction();
483              
$request->setActionName($action);
484          }
485  
486          return 
$this->formatActionName($action);
487      }
488  }
489  
Stack trace
  1. open/home/wallst/ftp/diamondesign/library/Zend/Controller/Front.php
    Zend_Controller_Dispatcher_Standard->dispatch(Zend_Controller_Request_Http, Zend_Controller_Response_Http)
    1     <?php
    2    
    /**
    3     * Zend Framework
    4     *
    5     * LICENSE
    6     *
    7     * This source file is subject to the new BSD license that is bundled
    8     * with this package in the file LICENSE.txt.
    9     * It is also available through the world-wide-web at this URL:
    10    * http://framework.zend.com/license/new-bsd
    11    * If you did not receive a copy of the license and are unable to
    12    * obtain it through the world-wide-web, please send an email
    13    * to license@zend.com so we can send you a copy immediately.
    14    *
    15    * @category   Zend
    16    * @package    Zend_Controller
    17    * @copyright  Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
    18    * @license    http://framework.zend.com/license/new-bsd     New BSD License
    19    */
    20   
    21   
    22   /** Zend_Loader */
    23   
    require_once 'Zend/Loader.php';
    24   
    25   
    /** Zend_Controller_Action_HelperBroker */
    26   
    require_once 'Zend/Controller/Action/HelperBroker.php';
    27   
    28   
    /** Zend_Controller_Exception */
    29   
    require_once 'Zend/Controller/Exception.php';
    30   
    31   
    /** Zend_Controller_Plugin_Broker */
    32   
    require_once 'Zend/Controller/Plugin/Broker.php';
    33   
    34   
    /**
    35    * @category   Zend
    36    * @package    Zend_Controller
    37    * @copyright  Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
    38    * @license    http://framework.zend.com/license/new-bsd     New BSD License
    39    */
    40   
    class Zend_Controller_Front
    41   
    {
    42       
    /**
    43        * Base URL
    44        * @var string
    45        */
    46       
    protected $_baseUrl null;
    47   
    48       
    /**
    49        * Directory|ies where controllers are stored
    50        *
    51        * @var string|array
    52        */
    53       
    protected $_controllerDir null;
    54   
    55       
    /**
    56        * Instance of Zend_Controller_Dispatcher_Interface
    57        * @var Zend_Controller_Dispatcher_Interface
    58        */
    59       
    protected $_dispatcher null;
    60   
    61       
    /**
    62        * Singleton instance
    63        *
    64        * Marked only as protected to allow extension of the class. To extend,
    65        * simply override {@link getInstance()}.
    66        *
    67        * @var Zend_Controller_Front
    68        */
    69       
    protected static $_instance null;
    70   
    71       
    /**
    72        * Array of invocation parameters to use when instantiating action
    73        * controllers
    74        * @var array
    75        */
    76       
    protected $_invokeParams = array();
    77   
    78       
    /**
    79        * Subdirectory within a module containing controllers; defaults to 'controllers'
    80        * @var string
    81        */
    82       
    protected $_moduleControllerDirectoryName 'controllers';
    83   
    84       
    /**
    85        * Instance of Zend_Controller_Plugin_Broker
    86        * @var Zend_Controller_Plugin_Broker
    87        */
    88       
    protected $_plugins null;
    89   
    90       
    /**
    91        * Instance of Zend_Controller_Request_Abstract
    92        * @var Zend_Controller_Request_Abstract
    93        */
    94       
    protected $_request null;
    95   
    96       
    /**
    97        * Instance of Zend_Controller_Response_Abstract
    98        * @var Zend_Controller_Response_Abstract
    99        */
    100      
    protected $_response null;
    101  
    102      
    /**
    103       * Whether or not to return the response prior to rendering output while in
    104       * {@link dispatch()}; default is to send headers and render output.
    105       * @var boolean
    106       */
    107      
    protected $_returnResponse false;
    108  
    109      
    /**
    110       * Instance of Zend_Controller_Router_Interface
    111       * @var Zend_Controller_Router_Interface
    112       */
    113      
    protected $_router null;
    114  
    115      
    /**
    116       * Whether or not exceptions encountered in {@link dispatch()} should be
    117       * thrown or trapped in the response object
    118       * @var boolean
    119       */
    120      
    protected $_throwExceptions false;
    121  
    122      
    /**
    123       * Constructor
    124       *
    125       * Instantiate using {@link getInstance()}; front controller is a singleton
    126       * object.
    127       *
    128       * Instantiates the plugin broker.
    129       *
    130       * @return void
    131       */
    132      
    protected function __construct()
    133      {
    134          
    $this->_plugins = new Zend_Controller_Plugin_Broker();
    135      }
    136  
    137      
    /**
    138       * Enforce singleton; disallow cloning 
    139       * 
    140       * @return void
    141       */
    142      
    private function __clone()
    143      {
    144      }
    145  
    146      
    /**
    147       * Singleton instance
    148       *
    149       * @return Zend_Controller_Front
    150       */
    151      
    public static function getInstance()
    152      {
    153          if (
    null === self::$_instance) {
    154              
    self::$_instance = new self();
    155          }
    156  
    157          return 
    self::$_instance;
    158      }
    159  
    160      
    /**
    161       * Resets all object properties of the singleton instance
    162       *
    163       * Primarily used for testing; could be used to chain front controllers.
    164       *
    165       * Also resets action helper broker, clearing all registered helpers.
    166       *
    167       * @return void
    168       */
    169      
    public function resetInstance()
    170      {
    171          
    $reflection = new ReflectionObject($this);
    172          foreach (
    $reflection->getProperties() as $property) {
    173              
    $name $property->getName();
    174              switch (
    $name) {
    175                  case 
    '_instance':
    176                      break;
    177                  case 
    '_controllerDir':
    178                  case 
    '_invokeParams':
    179                      
    $this->{$name} = array();
    180                      break;
    181                  case 
    '_plugins':
    182                      
    $this->{$name} = new Zend_Controller_Plugin_Broker();
    183                      break;
    184                  case 
    '_throwExceptions':
    185                  case 
    '_returnResponse':
    186                      
    $this->{$name} = false;
    187                      break;
    188                  case 
    '_moduleControllerDirectoryName':
    189                      
    $this->{$name} = 'controllers';
    190                      break;
    191                  default:
    192                      
    $this->{$name} = null;
    193                      break;
    194              }
    195          }
    196          
    Zend_Controller_Action_HelperBroker::resetHelpers();
    197      }
    198  
    199      
    /**
    200       * Convenience feature, calls setControllerDirectory()->setRouter()->dispatch()
    201       *
    202       * In PHP 5.1.x, a call to a static method never populates $this -- so run()
    203       * may actually be called after setting up your front controller.
    204       *
    205       * @param string|array $controllerDirectory Path to Zend_Controller_Action
    206       * controller classes or array of such paths
    207       * @return void
    208       * @throws Zend_Controller_Exception if called from an object instance
    209       */
    210      
    public static function run($controllerDirectory)
    211      {
    212          
    self::getInstance()
    213              ->
    setControllerDirectory($controllerDirectory)
    214              ->
    dispatch();
    215      }
    216  
    217      
    /**
    218       * Add a controller directory to the controller directory stack
    219       *
    220       * If $args is presented and is a string, uses it for the array key mapping
    221       * to the directory specified.
    222       *
    223       * @param string $directory
    224       * @param string $module Optional argument; module with which to associate directory. If none provided, assumes 'default'
    225       * @return Zend_Controller_Front
    226       * @throws Zend_Controller_Exception if directory not found or readable
    227       */
    228      
    public function addControllerDirectory($directory$module null)
    229      {
    230          
    $this->getDispatcher()->addControllerDirectory($directory$module);
    231          return 
    $this;
    232      }
    233  
    234      
    /**
    235       * Set controller directory
    236       *
    237       * Stores controller directory(ies) in dispatcher. May be an array of
    238       * directories or a string containing a single directory.
    239       *
    240       * @param string|array $directory Path to Zend_Controller_Action controller
    241       * classes or array of such paths
    242       * @param  string $module Optional module name to use with string $directory
    243       * @return Zend_Controller_Front
    244       */
    245      
    public function setControllerDirectory($directory$module null)
    246      {
    247          
    $this->getDispatcher()->setControllerDirectory($directory$module);
    248          return 
    $this;
    249      }
    250  
    251      
    /**
    252       * Retrieve controller directory
    253       *
    254       * Retrieves:
    255       * - Array of all controller directories if no $name passed
    256       * - String path if $name passed and exists as a key in controller directory array
    257       * - null if $name passed but does not exist in controller directory keys
    258       *
    259       * @param  string $name Default null
    260       * @return array|string|null
    261       */
    262      
    public function getControllerDirectory($name null)
    263      {
    264          return 
    $this->getDispatcher()->getControllerDirectory($name);
    265      }
    266  
    267      
    /**
    268       * Remove a controller directory by module name 
    269       * 
    270       * @param  string $module 
    271       * @return bool
    272       */
    273      
    public function removeControllerDirectory($module)
    274      {
    275          return 
    $this->getDispatcher()->removeControllerDirectory($module);
    276      }
    277  
    278      
    /**
    279       * Specify a directory as containing modules
    280       *
    281       * Iterates through the directory, adding any subdirectories as modules;
    282       * the subdirectory within each module named after {@link $_moduleControllerDirectoryName}
    283       * will be used as the controller directory path.
    284       *
    285       * @param  string $path
    286       * @return Zend_Controller_Front
    287       */
    288      
    public function addModuleDirectory($path)
    289      {
    290          try{
    291              
    $dir = new DirectoryIterator($path);
    292          }catch(
    Exception $e){
    293              throw new 
    Zend_Controller_Exception("Directory $path not readable");
    294          }
    295          foreach (
    $dir as $file) {
    296              if (
    $file->isDot() || !$file->isDir()) {
    297                  continue;
    298              }
    299  
    300              
    $module    $file->getFilename();
    301  
    302              
    // Don't use SCCS directories as modules
    303              
    if (preg_match('/^[^a-z]/i'$module) || ('CVS' == $module)) {
    304                  continue;
    305              }
    306  
    307              
    $moduleDir $file->getPathname() . DIRECTORY_SEPARATOR $this->getModuleControllerDirectoryName();
    308              
    $this->addControllerDirectory($moduleDir$module);
    309          }
    310  
    311          return 
    $this;
    312      }
    313  
    314      
    /**
    315       * Return the path to a module directory (but not the controllers directory within)
    316       * 
    317       * @param  string $module 
    318       * @return string|null
    319       */
    320      
    public function getModuleDirectory($module null)
    321      {
    322          if (
    null === $module) {
    323              
    $request $this->getRequest();
    324              if (
    null !== $request) {
    325                  
    $module $this->getRequest()->getModuleName();
    326              }
    327              if (empty(
    $module)) {
    328                  
    $module $this->getDispatcher()->getDefaultModule();
    329              }
    330          }
    331  
    332          
    $controllerDir $this->getControllerDirectory($module);
    333  
    334          if ((
    null === $controllerDir) || !is_string($controllerDir)) {
    335              return 
    null;
    336          }
    337  
    338          return 
    dirname($controllerDir);
    339      }
    340  
    341      
    /**
    342       * Set the directory name within a module containing controllers
    343       *
    344       * @param  string $name
    345       * @return Zend_Controller_Front
    346       */
    347      
    public function setModuleControllerDirectoryName($name 'controllers')
    348      {
    349          
    $this->_moduleControllerDirectoryName = (string) $name;
    350  
    351          return 
    $this;
    352      }
    353  
    354      
    /**
    355       * Return the directory name within a module containing controllers
    356       *
    357       * @return string
    358       */
    359      
    public function getModuleControllerDirectoryName()
    360      {
    361          return 
    $this->_moduleControllerDirectoryName;
    362      }
    363  
    364      
    /**
    365       * Set the default controller (unformatted string)
    366       *
    367       * @param string $controller
    368       * @return Zend_Controller_Front
    369       */
    370      
    public function setDefaultControllerName($controller)
    371      {
    372          
    $dispatcher $this->getDispatcher();
    373          
    $dispatcher->setDefaultControllerName($controller);
    374          return 
    $this;
    375      }
    376  
    377      
    /**
    378       * Retrieve the default controller (unformatted string)
    379       *
    380       * @return string
    381       */
    382      
    public function getDefaultControllerName()
    383      {
    384          return 
    $this->getDispatcher()->getDefaultControllerName();
    385      }
    386  
    387      
    /**
    388       * Set the default action (unformatted string)
    389       *
    390       * @param string $action
    391       * @return Zend_Controller_Front
    392       */
    393      
    public function setDefaultAction($action)
    394      {
    395          
    $dispatcher $this->getDispatcher();
    396          
    $dispatcher->setDefaultAction($action);
    397          return 
    $this;
    398      }
    399  
    400      
    /**
    401       * Retrieve the default action (unformatted string)
    402       *
    403       * @return string
    404       */
    405      
    public function getDefaultAction()
    406      {
    407          return 
    $this->getDispatcher()->getDefaultAction();
    408      }
    409  
    410      
    /**
    411       * Set the default module name
    412       *
    413       * @param string $module
    414       * @return Zend_Controller_Front
    415       */
    416      
    public function setDefaultModule($module)
    417      {
    418          
    $dispatcher $this->getDispatcher();
    419          
    $dispatcher->setDefaultModule($module);
    420          return 
    $this;
    421      }
    422  
    423      
    /**
    424       * Retrieve the default module
    425       *
    426       * @return string
    427       */
    428      
    public function getDefaultModule()
    429      {
    430          return 
    $this->getDispatcher()->getDefaultModule();
    431      }
    432  
    433      
    /**
    434       * Set request class/object
    435       *
    436       * Set the request object.  The request holds the request environment.
    437       *
    438       * If a class name is provided, it will instantiate it
    439       *
    440       * @param string|Zend_Controller_Request_Abstract $request
    441       * @throws Zend_Controller_Exception if invalid request class
    442       * @return Zend_Controller_Front
    443       */
    444      
    public function setRequest($request)
    445      {
    446          if (
    is_string($request)) {
    447              
    Zend_Loader::loadClass($request);
    448              
    $request = new $request();
    449          }
    450          if (!
    $request instanceof Zend_Controller_Request_Abstract) {
    451              throw new 
    Zend_Controller_Exception('Invalid request class');
    452          }
    453  
    454          
    $this->_request $request;
    455  
    456          return 
    $this;
    457      }
    458  
    459      
    /**
    460       * Return the request object.
    461       *
    462       * @return null|Zend_Controller_Request_Abstract
    463       */
    464      
    public function getRequest()
    465      {
    466          return 
    $this->_request;
    467      }
    468  
    469      
    /**
    470       * Set router class/object
    471       *
    472       * Set the router object.  The router is responsible for mapping
    473       * the request to a controller and action.
    474       *
    475       * If a class name is provided, instantiates router with any parameters
    476       * registered via {@link setParam()} or {@link setParams()}.
    477       *
    478       * @param string|Zend_Controller_Router_Interface $router
    479       * @throws Zend_Controller_Exception if invalid router class
    480       * @return Zend_Controller_Front
    481       */
    482      
    public function setRouter($router)
    483      {
    484          if (
    is_string($router)) {
    485              
    Zend_Loader::loadClass($router);
    486              
    $router = new $router();
    487          }
    488  
    489          if (!
    $router instanceof Zend_Controller_Router_Interface) {
    490              throw new 
    Zend_Controller_Exception('Invalid router class');
    491          }
    492  
    493          
    $router->setFrontController($this);
    494          
    $this->_router $router;
    495  
    496          return 
    $this;
    497      }
    498  
    499      
    /**
    500       * Return the router object.
    501       *
    502       * Instantiates a Zend_Controller_Router_Rewrite object if no router currently set.
    503       *
    504       * @return Zend_Controller_Router_Interface
    505       */
    506      
    public function getRouter()
    507      {
    508          if (
    null == $this->_router) {
    509              require_once 
    'Zend/Controller/Router/Rewrite.php';
    510              
    $this->setRouter(new Zend_Controller_Router_Rewrite());
    511          }
    512  
    513          return 
    $this->_router;
    514      }
    515  
    516      
    /**
    517       * Set the base URL used for requests
    518       *
    519       * Use to set the base URL segment of the REQUEST_URI to use when
    520       * determining PATH_INFO, etc. Examples:
    521       * - /admin
    522       * - /myapp
    523       * - /subdir/index.php
    524       *
    525       * Note that the URL should not include the full URI. Do not use:
    526       * - http://example.com/admin
    527       * - http://example.com/myapp
    528       * - http://example.com/subdir/index.php
    529       *
    530       * If a null value is passed, this can be used as well for autodiscovery (default).
    531       *
    532       * @param string $base
    533       * @return Zend_Controller_Front
    534       * @throws Zend_Controller_Exception for non-string $base
    535       */
    536      
    public function setBaseUrl($base null)
    537      {
    538          if (!
    is_string($base) && (null !== $base)) {
    539              throw new 
    Zend_Controller_Exception('Rewrite base must be a string');
    540          }
    541  
    542          
    $this->_baseUrl $base;
    543  
    544          if ((
    null !== ($request $this->getRequest())) && (method_exists($request'setBaseUrl'))) {
    545              
    $request->setBaseUrl($base);
    546          }
    547  
    548          return 
    $this;
    549      }
    550  
    551      
    /**
    552       * Retrieve the currently set base URL
    553       *
    554       * @return string
    555       */
    556      
    public function getBaseUrl()
    557      {
    558          
    $request $this->getRequest();
    559          if ((
    null !== $request) && method_exists($request'getBaseUrl')) {
    560              return 
    $request->getBaseUrl();
    561          }
    562  
    563          return 
    $this->_baseUrl;
    564      }
    565  
    566      
    /**
    567       * Set the dispatcher object.  The dispatcher is responsible for
    568       * taking a Zend_Controller_Dispatcher_Token object, instantiating the controller, and
    569       * call the action method of the controller.
    570       *
    571       * @param Zend_Controller_Dispatcher_Interface $dispatcher
    572       * @return Zend_Controller_Front
    573       */
    574      
    public function setDispatcher(Zend_Controller_Dispatcher_Interface $dispatcher)
    575      {
    576          
    $this->_dispatcher $dispatcher;
    577          return 
    $this;
    578      }
    579  
    580      
    /**
    581       * Return the dispatcher object.
    582       *
    583       * @return Zend_Controller_Dispatcher_Interface
    584       */
    585      
    public function getDispatcher()
    586      {
    587          
    /**
    588           * Instantiate the default dispatcher if one was not set.
    589           */
    590          
    if (!$this->_dispatcher instanceof Zend_Controller_Dispatcher_Interface) {
    591              require_once 
    'Zend/Controller/Dispatcher/Standard.php';
    592              
    $this->_dispatcher = new Zend_Controller_Dispatcher_Standard();
    593          }
    594          return 
    $this->_dispatcher;
    595      }
    596  
    597      
    /**
    598       * Set response class/object
    599       *
    600       * Set the response object.  The response is a container for action
    601       * responses and headers. Usage is optional.
    602       *
    603       * If a class name is provided, instantiates a response object.
    604       *
    605       * @param string|Zend_Controller_Response_Abstract $response
    606       * @throws Zend_Controller_Exception if invalid response class
    607       * @return Zend_Controller_Front
    608       */
    609      
    public function setResponse($response)
    610      {
    611          if (
    is_string($response)) {
    612              
    Zend_Loader::loadClass($response);
    613              
    $response = new $response();
    614          }
    615          if (!
    $response instanceof Zend_Controller_Response_Abstract) {
    616              throw new 
    Zend_Controller_Exception('Invalid response class');
    617          }
    618  
    619          
    $this->_response $response;
    620  
    621          return 
    $this;
    622      }
    623  
    624      
    /**
    625       * Return the response object.
    626       *
    627       * @return null|Zend_Controller_Response_Abstract
    628       */
    629      
    public function getResponse()
    630      {
    631          return 
    $this->_response;
    632      }
    633  
    634      
    /**
    635       * Add or modify a parameter to use when instantiating an action controller
    636       *
    637       * @param string $name
    638       * @param mixed $value
    639       * @return Zend_Controller_Front
    640       */
    641      
    public function setParam($name$value)
    642      {
    643          
    $name = (string) $name;
    644          
    $this->_invokeParams[$name] = $value;
    645          return 
    $this;
    646      }
    647  
    648      
    /**
    649       * Set parameters to pass to action controller constructors
    650       *
    651       * @param array $params
    652       * @return Zend_Controller_Front
    653       */
    654      
    public function setParams(array $params)
    655      {
    656          
    $this->_invokeParams array_merge($this->_invokeParams$params);
    657          return 
    $this;
    658      }
    659  
    660      
    /**
    661       * Retrieve a single parameter from the controller parameter stack
    662       *
    663       * @param string $name
    664       * @return mixed
    665       */
    666      
    public function getParam($name)
    667      {
    668          if(isset(
    $this->_invokeParams[$name])) {
    669              return 
    $this->_invokeParams[$name];
    670          }
    671  
    672          return 
    null;
    673      }
    674  
    675      
    /**
    676       * Retrieve action controller instantiation parameters
    677       *
    678       * @return array
    679       */
    680      
    public function getParams()
    681      {
    682          return 
    $this->_invokeParams;
    683      }
    684  
    685      
    /**
    686       * Clear the controller parameter stack
    687       *
    688       * By default, clears all parameters. If a parameter name is given, clears
    689       * only that parameter; if an array of parameter names is provided, clears
    690       * each.
    691       *
    692       * @param null|string|array single key or array of keys for params to clear
    693       * @return Zend_Controller_Front
    694       */
    695      
    public function clearParams($name null)
    696      {
    697          if (
    null === $name) {
    698              
    $this->_invokeParams = array();
    699          } elseif (
    is_string($name) && isset($this->_invokeParams[$name])) {
    700              unset(
    $this->_invokeParams[$name]);
    701          } elseif (
    is_array($name)) {
    702              foreach (
    $name as $key) {
    703                  if (
    is_string($key) && isset($this->_invokeParams[$key])) {
    704                      unset(
    $this->_invokeParams[$key]);
    705                  }
    706              }
    707          }
    708  
    709          return 
    $this;
    710      }
    711  
    712      
    /**
    713       * Register a plugin.
    714       *
    715       * @param  Zend_Controller_Plugin_Abstract $plugin
    716       * @param  int $stackIndex Optional; stack index for plugin
    717       * @return Zend_Controller_Front
    718       */
    719      
    public function registerPlugin(Zend_Controller_Plugin_Abstract $plugin$stackIndex null)
    720      {
    721          
    $this->_plugins->registerPlugin($plugin$stackIndex);
    722          return 
    $this;
    723      }
    724  
    725      
    /**
    726       * Unregister a plugin.
    727       *
    728       * @param  string|Zend_Controller_Plugin_Abstract $plugin Plugin class or object to unregister
    729       * @return Zend_Controller_Front
    730       */
    731      
    public function unregisterPlugin($plugin)
    732      {
    733          
    $this->_plugins->unregisterPlugin($plugin);
    734          return 
    $this;
    735      }
    736  
    737      
    /**
    738       * Is a particular plugin registered?
    739       *
    740       * @param  string $class
    741       * @return bool
    742       */
    743      
    public function hasPlugin($class)
    744      {
    745          return 
    $this->_plugins->hasPlugin($class);
    746      }
    747  
    748      
    /**
    749       * Retrieve a plugin or plugins by class
    750       *
    751       * @param  string $class
    752       * @return false|Zend_Controller_Plugin_Abstract|array
    753       */
    754      
    public function getPlugin($class)
    755      {
    756          return 
    $this->_plugins->getPlugin($class);
    757      }
    758  
    759      
    /**
    760       * Retrieve all plugins
    761       *
    762       * @return array
    763       */
    764      
    public function getPlugins()
    765      {
    766          return 
    $this->_plugins->getPlugins();
    767      }
    768  
    769      
    /**
    770       * Set the throwExceptions flag and retrieve current status
    771       *
    772       * Set whether exceptions encounted in the dispatch loop should be thrown
    773       * or caught and trapped in the response object.
    774       *
    775       * Default behaviour is to trap them in the response object; call this
    776       * method to have them thrown.
    777       *
    778       * Passing no value will return the current value of the flag; passing a 
    779       * boolean true or false value will set the flag and return the current 
    780       * object instance.
    781       *
    782       * @param boolean $flag Defaults to null (return flag state)
    783       * @return boolean|Zend_Controller_Front Used as a setter, returns object; as a getter, returns boolean
    784       */
    785      
    public function throwExceptions($flag null)
    786      {
    787          if (
    $flag !== null) {
    788              
    $this->_throwExceptions = (bool) $flag;
    789              return 
    $this;
    790          }
    791  
    792          return 
    $this->_throwExceptions;
    793      }
    794  
    795      
    /**
    796       * Set whether {@link dispatch()} should return the response without first
    797       * rendering output. By default, output is rendered and dispatch() returns
    798       * nothing.
    799       *
    800       * @param boolean $flag
    801       * @return boolean|Zend_Controller_Front Used as a setter, returns object; as a getter, returns boolean
    802       */
    803      
    public function returnResponse($flag null)
    804      {
    805          if (
    true === $flag) {
    806              
    $this->_returnResponse true;
    807              return 
    $this;
    808          } elseif (
    false === $flag) {
    809              
    $this->_returnResponse false;
    810              return 
    $this;
    811          }
    812  
    813          return 
    $this->_returnResponse;
    814      }
    815  
    816      
    /**
    817       * Dispatch an HTTP request to a controller/action.
    818       *
    819       * @param Zend_Controller_Request_Abstract|null $request
    820       * @param Zend_Controller_Response_Abstract|null $response
    821       * @return void|Zend_Controller_Response_Abstract Returns response object if returnResponse() is true
    822       */
    823      
    public function dispatch(Zend_Controller_Request_Abstract $request nullZend_Controller_Response_Abstract $response null)
    824      {
    825          if (!
    $this->getParam('noErrorHandler') && !$this->_plugins->hasPlugin('Zend_Controller_Plugin_ErrorHandler')) {
    826              
    // Register with stack index of 100
    827              
    require_once 'Zend/Controller/Plugin/ErrorHandler.php';
    828              
    $this->_plugins->registerPlugin(new Zend_Controller_Plugin_ErrorHandler(), 100);
    829          }
    830  
    831          if (!
    $this->getParam('noViewRenderer') && !Zend_Controller_Action_HelperBroker::hasHelper('viewRenderer')) {
    832              require_once 
    'Zend/Controller/Action/Helper/ViewRenderer.php';
    833              
    Zend_Controller_Action_HelperBroker::getStack()->offsetSet(-80, new Zend_Controller_Action_Helper_ViewRenderer());
    834          }
    835  
    836          
    /**
    837           * Instantiate default request object (HTTP version) if none provided
    838           */
    839          
    if (null !== $request) {
    840              
    $this->setRequest($request);
    841          } elseif ((
    null === $request) && (null === ($request $this->getRequest()))) {
    842              require_once 
    'Zend/Controller/Request/Http.php';
    843              
    $request = new Zend_Controller_Request_Http();
    844              
    $this->setRequest($request);
    845          }
    846  
    847          
    /**
    848           * Set base URL of request object, if available
    849           */
    850          
    if (is_callable(array($this->_request'setBaseUrl'))) {
    851              if (
    null !== $this->_baseUrl) {
    852                  
    $this->_request->setBaseUrl($this->_baseUrl);
    853              }
    854          }
    855  
    856          
    /**
    857           * Instantiate default response object (HTTP version) if none provided
    858           */
    859          
    if (null !== $response) {
    860              
    $this->setResponse($response);
    861          } elseif ((
    null === $this->_response) && (null === ($this->_response $this->getResponse()))) {
    862              require_once 
    'Zend/Controller/Response/Http.php';
    863              
    $response = new Zend_Controller_Response_Http();
    864              
    $this->setResponse($response);
    865          }
    866  
    867          
    /**
    868           * Register request and response objects with plugin broker
    869           */
    870          
    $this->_plugins
    871               
    ->setRequest($this->_request)
    872               ->
    setResponse($this->_response);
    873  
    874          
    /**
    875           * Initialize router
    876           */
    877          
    $router $this->getRouter();
    878          
    $router->setParams($this->getParams());
    879  
    880          
    /**
    881           * Initialize dispatcher
    882           */
    883          
    $dispatcher $this->getDispatcher();
    884          
    $dispatcher->setParams($this->getParams())
    885                     ->
    setResponse($this->_response);
    886  
    887          
    // Begin dispatch
    888          
    try {
    889              
    /**
    890               * Route request to controller/action, if a router is provided
    891               */
    892  
    893              /**
    894              * Notify plugins of router startup
    895              */
    896              
    $this->_plugins->routeStartup($this->_request);
    897  
    898              
    $router->route($this->_request);
    899  
    900              
    /**
    901              * Notify plugins of router completion
    902              */
    903              
    $this->_plugins->routeShutdown($this->_request);
    904  
    905              
    /**
    906               * Notify plugins of dispatch loop startup
    907               */
    908              
    $this->_plugins->dispatchLoopStartup($this->_request);
    909  
    910              
    /**
    911               *  Attempt to dispatch the controller/action. If the $this->_request
    912               *  indicates that it needs to be dispatched, move to the next
    913               *  action in the request.
    914               */
    915              
    do {
    916                  
    $this->_request->setDispatched(true);
    917  
    918                  
    /**
    919                   * Notify plugins of dispatch startup
    920                   */
    921                  
    $this->_plugins->preDispatch($this->_request);
    922  
    923                  
    /**
    924                   * Skip requested action if preDispatch() has reset it
    925                   */
    926                  
    if (!$this->_request->isDispatched()) {
    927                      continue;
    928                  }
    929  
    930                  
    /**
    931                   * Dispatch request
    932                   */
    933                  
    try {
    934                      
    $dispatcher->dispatch($this->_request$this->_response);
    935                  } catch (
    Exception $e) {
    936                      if (
    $this->throwExceptions()) {
    937                          throw 
    $e;
    938                      }
    939                      
    $this->_response->setException($e);
    940                  }
    941  
    942                  
    /**
    943                   * Notify plugins of dispatch completion
    944                   */
    945                  
    $this->_plugins->postDispatch($this->_request);
    946              } while (!
    $this->_request->isDispatched());
    947          } catch (
    Exception $e) {
    948              if (
    $this->throwExceptions()) {
    949                  throw 
    $e;
    950              }
    951  
    952              
    $this->_response->setException($e);
    953          }
    954  
    955          
    /**
    956           * Notify plugins of dispatch loop completion
    957           */
    958          
    try {
    959              
    $this->_plugins->dispatchLoopShutdown();
    960          } catch (
    Exception $e) {
    961              if (
    $this->throwExceptions()) {
    962                  throw 
    $e;
    963              }
    964  
    965              
    $this->_response->setException($e);
    966          }
    967  
    968          if (
    $this->returnResponse()) {
    969              return 
    $this->_response;
    970          }
    971  
    972          
    $this->_response->sendResponse();
    973      }
    974  }
    975  
  2. open/home/wallst/ftp/diamondesign/index.php
    Zend_Controller_Front->dispatch()
    1     <?php
    2    
    3    
    function getmicrotime(){ list($usec$sec) = explode(" ",microtime()); return ((float)$usec + (float)$sec); } $time_start getmicrotime();
    4    
    5    
    error_reporting(E_ALL);
    6    
    date_default_timezone_set('Europe/Warsaw');
    7    
    8    
    ini_set'include_path''./library/' );
    9    
    ini_set('display_errors'1);
    10   
    11   
    set_include_path('.' PATH_SEPARATOR './library/Zend/'
    12   
    PATH_SEPARATOR './application/models/'
    13   
    PATH_SEPARATOR get_include_path());
    14   
    15   include 
    "Zend/Loader.php";
    16   
    Zend_Loader::registerAutoload();
    17   
    18   
    Zend_Session::start();
    19   
    20   
    /* load Smarty plugin */
    21   
    include "Fruwoc/View/Smarty.php";
    22   
    23   
    // load configuration
    24   
    $config = new Zend_Config_Ini('./application/config.ini.php''general');
    25   
    $registry Zend_Registry::getInstance();
    26   
    $registry->set('config'$config);
    27   
    28   
    $baza_start getmicrotime();
    29   
    // setup database
    30   
    $db Zend_Db::factory($config->db->adapter$config->db->config->toArray());
    31   
    Zend_Db_Table::setDefaultAdapter($db);
    32   
    Zend_Registry::set('db'$db);
    33   
    $db->getConnection();
    34   
    // $db->query('SET NAMES utf8');
    35   
    $baza_end getmicrotime();
    36   
    37   
    /* routers */
    38   
    39   
    $router = new Zend_Controller_Router_Rewrite();
    40   
    41   
    $router->addRoute('admin_action_id_status_var',     new Zend_Controller_Router_Route('admin/:controller/:action/:id/:status/:var', array('module' => 'admin')));
    42   
    $router->addRoute('orderr',     new Zend_Controller_Router_Route('admin/:controller/:action/:id/:status', array('module' => 'admin')));
    43   
    $router->addRoute('admin_action_id',     new Zend_Controller_Router_Route('admin/:controller/:action/:id', array('module' => 'admin')));
    44   
    $router->addRoute('admin_action',     new Zend_Controller_Router_Route('admin/:controller/:action', array('module' => 'admin')));
    45   
    $router->addRoute('admin_controller',     new Zend_Controller_Router_Route('admin/:controller', array('module' => 'admin')));
    46   
    $router->addRoute('admin',     new Zend_Controller_Router_Route('admin/', array('module' => 'admin')));
    47   
    48   
    /**** here ****/
    49   /*
    50   $route = new Zend_Controller_Router_Route_Regex(
    51           '([^-]*)-([^-]*)-([^-]*)-([^-]*)-([^-]*)\.html',
    52           array( 
    53                   'module' => 'default'
    54           ),
    55           array(
    56                   1 => 'controller',
    57                   2 => 'action',
    58                   3 => 'id',
    59                   4 => 'status',
    60                   5 => 'seo'
    61           ));
    62   $router->addRoute('default4', $route);
    63   
    64   $route = new Zend_Controller_Router_Route_Regex(
    65           '([^-]*)-([^-]*)-([^-]*)-([^-]*)\.html',
    66           array( 
    67                   'module' => 'default'
    68           ),
    69           array(
    70                   1 => 'controller',
    71                   2 => 'action',
    72                   3 => 'id',
    73                   4 => 'status'
    74           ));
    75   $router->addRoute('default4', $route);
    76   
    77   $route = new Zend_Controller_Router_Route_Regex(
    78           '([^-]*)-([^-]*)-([^-]*)\.html',
    79           array( 
    80                   'module' => 'default'
    81           ),
    82           array(
    83                   1 => 'controller',
    84                   2 => 'action',
    85                   3 => 'id',
    86           ));
    87   $router->addRoute('default3', $route);
    88   
    89   $route = new Zend_Controller_Router_Route_Regex(
    90           '([^-]*)-([^-]*)\.html',
    91           array( 
    92                   'module' => 'default'
    93           ),
    94           array(
    95                   1 => 'controller',
    96                   2 => 'action'
    97           ));
    98   $router->addRoute('default2', $route);
    99   
    100  
    101  $route = new Zend_Controller_Router_Route_Regex(
    102          '([^-]*)\.html',
    103          array( 
    104                  'module' => 'default',
    105                  'action' => 'index'
    106          ),
    107          array(
    108                  1 => 'controller'
    109          ));
    110  $router->addRoute('default', $route);
    111  
    112  */
    113  
    114  /*
    115  $router->addRoute('default',     new Zend_Controller_Router_Route(':action'), array('lang' => 'pl'));
    116  */
    117  //$router->removeDefaultRoutes();
    118  
    119  /* error handler */
    120  
    $errorHandler = new Zend_Controller_Plugin_ErrorHandler();
    121  
    $errorHandler->setErrorHandlerModule('default')
    122               ->
    setErrorHandlerController('error')
    123                ->
    setErrorHandlerAction('error');
    124  
    125  
    126  
    // setup controller
    127  
    $frontController Zend_Controller_Front::getInstance();
    128  
    $frontController->throwExceptions(false);
    129  
    $frontController->setParam('noViewRenderer'true); 
    130  
    131  
    $frontController->setRouter($router)
    132      ->
    setControllerDirectory(array(
    133      
    'default'=>'./application/default_controllers',
    134      
    'admin'=>'./application/admin_controllers'))
    135      
    //    ->addModuleDirectory('./application/modules');
    136      //    ->setModuleControllerDirectoryName('controllers')
    137      //    ->setBaseUrl( $url )
    138  
    ;
    139  
    140  
    141  
    // run!
    142  
    $frontController->dispatch();
    143  
    144  
    $time_end getmicrotime();
    145  
    146  
    $time_exec $time_end-$time_start;
    147  
    $time_baza $baza_end-$baza_start;
    148  
    //echo '<p style="clear: both; float: right;color: #9ae;">wygenerowano w: '.$time_exec.' s.<br />polaczenie z baza: '.$time_baza.' s.</p>';
    149  
    150  
    ?>