daily pastebin goal
41%
SHARE
TWEET

Untitled

a guest Oct 3rd, 2017 392 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <?php
  2. class Bootstrap extends Zend_Application_Bootstrap_Bootstrap
  3. {
  4.     public static $frontController = null;
  5.     // application wide constant must be defined in index.php, not here
  6.     /*
  7.     const DEFAULT_THEME = 'default';
  8.     const UPLOAD_PATH = "application_data/uploads";
  9.     */
  10.    
  11.     protected function _initAutoload()
  12.     {
  13.         $autoloader = new Zend_Application_Module_Autoloader(array(
  14.                         'namespace' => 'Default',
  15.                         'basePath'  => dirname(__FILE__),
  16.         ));
  17.         return $autoloader;
  18.     }
  19.  
  20.     protected function _initWildFire()
  21.     {
  22.         $this->bootstrap("db");
  23.  
  24.         if(APPLICATION_ENV == 'development')
  25.         {
  26.             $db = Zend_Registry::get('db');
  27.             $profiler = new Zend_Db_Profiler_Firebug("All Db Queries");
  28.             $profiler->setEnabled("true");
  29.             $db->setProfiler($profiler);
  30.         }
  31.  
  32.         /*
  33.             Changed File Name to Current Date
  34.             @auther: Waheed Akhtar
  35.             @date: 17-05-2010
  36.         */
  37.         $filename=date('Ymd') . '.log';
  38.         $writer = (false ? new Zend_Log_Writer_Stream(APPLICATION_PATH . '/../data/log/logger/' . $filename) : new Zend_Log_Writer_Firebug()) ;
  39.         $logger = new Zend_Log($writer);
  40.         Zend_Registry::set('logger',$logger);
  41.  
  42.         /*
  43.             Changed File Name to Current Date
  44.             @auther: Waheed Akhtar
  45.             @date: 17-05-2010
  46.         */
  47.         $filename=date('Ymd') . '.log';
  48.         $pwriter = (true ? new Zend_Log_Writer_Stream(APPLICATION_PATH . '/../data/log/payment/' . $filename) : new Zend_Log_Writer_Firebug()) ;
  49.         $plogger = new Zend_Log($pwriter);
  50.         Zend_Registry::set('plogger', $plogger);
  51.     }
  52.     protected function _initDbTable()
  53.     {
  54.         $db = Zend_Registry::get("db");
  55.         Zend_Db_Table::setDefaultAdapter($db);
  56.     }
  57.     public static function _initDb()
  58.     {
  59.         /*
  60.             Changed File Name to Current Date
  61.             @auther: Waheed Akhtar
  62.             @date: 17-05-2010
  63.         */
  64.         $filename=date('Ymd') . '.log';
  65.         $ewriter = (true ? new Zend_Log_Writer_Stream(APPLICATION_PATH . '/../data/log/errors/' . $filename) : new Zend_Log_Writer_Firebug()) ;
  66.         $elogger = new Zend_Log($ewriter);
  67.         Zend_Registry::set('elogger', $elogger);
  68.         $config = new Zend_Config_Ini('application/configs/application.ini', APPLICATION_ENV);
  69.         Zend_Registry::set('config',$config);
  70.         $db = Zend_Db::factory($config->db->adapter, $config->db->toArray());
  71.         $db->setFetchMode(Zend_Db::FETCH_BOTH);
  72.         if($config->email->smtp!="")
  73.         {
  74.             $tr = new Zend_Mail_Transport_Smtp($config->email->smtp);
  75.             Zend_Mail::setDefaultTransport($tr);
  76.         }
  77.         try
  78.         {
  79.             $db->query("SET NAMES 'utf8'");
  80.             $db->insert("iplogs", array('ip'=>$_SERVER["REMOTE_ADDR"]));
  81.         } catch(Exception $e)
  82.         {
  83.             $elogger->log($e->getMessage(), Zend_Log::INFO);
  84.             if(APPLICATION_ENV != "development")
  85.             {
  86.                 $mail = new Zend_Mail();
  87.                 $mail->setBodyHtml(nl2br(date("d/m/Y H:i").": ".$e->getMessage()."\n\nStack Trace:\n".$e->getTraceAsString()));
  88.                 $mail->setFrom("no-reply@groupola.com", "groupola.com");
  89.                 $mail->addTo("arslan@markcotech.co.uk", "Arslan ALi");
  90.                 $mail->addTo("zeeshan@markcotech.co.uk", "M Zeeshan");
  91.                 $mail->addTo("faisal@markcotech.co.uk", "Faisal Sheikh");
  92.                 $mail->addTo("adnan@markcotech.co.uk", "Adnan Shaukat");
  93.                 $mail->addTo("qadeer@markcotech.co.uk", "Qadeer Ahmed");
  94.                 $mail->setSubject("Groupola.com mySQL Server problem - ".APPLICATION_ENV);
  95.                 $mail->send();
  96.             } else {
  97.                 echo $e->getMessage();
  98.                 echo "<br /><br />";
  99.                 echo $e->getTraceAsString();
  100.             }
  101.             exit;
  102.         }
  103.         Zend_Registry::set('db', $db);
  104.     }
  105.     public function _initFrontController()
  106.     {
  107.         $config = Zend_Registry::get("config");
  108.  
  109.         self::$frontController = Zend_Controller_Front::getInstance();
  110.         self::$frontController->throwExceptions($config->resources->frontController->throwExceptions);
  111.         self::$frontController->returnResponse(true);
  112.         self::$frontController->addModuleDirectory('application/modules');
  113.         self::$frontController->setDefaultModule('default');
  114.         self::$frontController->setModuleControllerDirectoryName('controllers');
  115.         self::$frontController->registerPlugin(new Default_Plugin_Layout());
  116.         self::$frontController->registerPlugin(new Default_Plugin_SecurePayment());
  117.  
  118.         $router = self::$frontController->getRouter();
  119.         $route = new Zend_Controller_Router_Route_Regex(
  120.                 '(\S+)/(\S+)/(\S+)/(\d+)-(\S+)',
  121.                 array(
  122.                 ),
  123.                 array(
  124.                         1 => 'module',
  125.                         2 => 'controller',
  126.                         3 => 'action',
  127.                         4 => 'id',
  128.                         5 => 'name'
  129.                 )
  130.         );
  131.         $defaultRoute = new Zend_Controller_Router_Route(':module/:controller/:action/:id/:page/*',array("module"=>"default","controller"=>"index","action"=>"index","id"=>0,"page"=>0));
  132.         //$frontRoute = new Zend_Controller_Router_Route('city/:city/:module/:controller/:action',array("module"=>"deal","controller"=>"show","action"=>"index","id"=>0,"page"=>0,"city"=>"london"));
  133.         $pagePerClickRoute = new Zend_Controller_Router_Route_Static(
  134.                 'register',
  135.                 array('module'=>'default','controller' => 'index', 'action' => 'register')
  136.         );
  137.  
  138.         $fbFan = new Zend_Controller_Router_Route_Static(
  139.                 'fbfan',
  140.                 array('module'=>'default','controller' => 'index', 'action' => 'fbfan')
  141.         );
  142.  
  143.         $competition = new Zend_Controller_Router_Route_Static(
  144.                 'competition',
  145.                 array('module'=>'default','controller' => 'index', 'action' => 'competition')
  146.         );
  147.  
  148.         $legacyRef = new Zend_Controller_Router_Route_Static(
  149.                 'index/ref',
  150.                 array('module'=>'default','controller' => 'index', 'action' => 'ref')
  151.         );
  152.  
  153.         $router->addRoute('default', $defaultRoute);
  154.         $router->addRoute('archive', $route);
  155.         $router->addRoute('PPC', $pagePerClickRoute);
  156.         $router->addRoute('competition', $competition);
  157.         $router->addRoute('legacyref', $legacyRef);
  158.         $router->addRoute('fbfan', $fbFan);
  159.  
  160.  
  161.         return self::$frontController;
  162.  
  163.         ## with order first in last out regex will be matched in last
  164.         ## $router->addRoute('bvc_route_regex',new Zend_Controller_Router_Route_Regex('(\S+)',array('controller'=>'front','action'=>'page')));
  165.         ## $router->addRoute('bvc_route',new Zend_Controller_Router_Route(':controller/:action/:id/:page',array('page'=>1,'id'=>0)));
  166.     }
  167.  
  168.     /**
  169.      * Comment by Qadeer for multiple design impliment.
  170.      */
  171. //    protected function _initView()
  172. //    {
  173. //        $view = new Zend_View;
  174. //        $view->doctype('XHTML1_TRANSITIONAL');
  175. //        $view->setEncoding('UTF-8');
  176. //
  177. //        //$currency=new Zend_Currency('en_GB');
  178. //        //$cur=$currency->getSymbol('GBP', 'en_GB');
  179. //
  180. //        $view->headTitle(APPLICATION_NAME . ' - '); //- app name in title bar, wherever this function is called in other pages, this title will be appended
  181. //        $viewRenderer = Zend_Controller_Action_HelperBroker::getStaticHelper(
  182. //                'ViewRenderer'
  183. //        );
  184. //
  185. //        $view->addHelperPath("application/helpers","My_View_Helper");
  186. //        $viewRenderer = new Zend_Controller_Action_Helper_ViewRenderer($view);
  187. //        Zend_Controller_Action_HelperBroker::addHelper($viewRenderer);
  188. //
  189. //        Zend_Layout::startMvc();
  190. //
  191. //        $viewRenderer->setView($view);
  192. //        return $view;
  193. //    }
  194.  
  195.     /**
  196.      * Add  By Qadeer for multiple design implement
  197.      *
  198.      */
  199.     protected function _getApplicationTheme()
  200.     {
  201.         return (!defined('APPLICATION_THEME')) ? self::DEFAULT_THEME : APPLICATION_THEME;
  202.     }
  203.     /**
  204.      * Add  By Qadeer for multiple design implement
  205.      * @return <type>
  206.      */
  207.     protected function _initSite() {
  208.  
  209.         //layout paths
  210.         $view = new Zend_View;
  211.         $view->doctype('XHTML1_TRANSITIONAL');
  212.         $view->setEncoding('UTF-8');
  213.  
  214.         $view->headTitle(APPLICATION_NAME . ' - '); //- app name in title bar, wherever this function is called in other pages, this title will be appended
  215.         $viewRenderer = Zend_Controller_Action_HelperBroker::getStaticHelper(
  216.                 'ViewRenderer'
  217.         );
  218.  
  219.         $view->addHelperPath("application/helpers","My_View_Helper");
  220.         $viewRenderer = new Zend_Controller_Action_Helper_ViewRenderer($view);
  221.         Zend_Controller_Action_HelperBroker::addHelper($viewRenderer);
  222.  
  223.         Zend_Layout::startMvc(array(
  224.                 'layout' => 'layout',
  225.                 'layoutPath' => array(
  226.                         APPLICATION_PATH.'/templates/' . APPLICATION_THEME . '/layouts/scripts'
  227.                 )
  228.         ));
  229.         $viewRenderer->setViewBasePathSpec(APPLICATION_PATH.'/templates/'. APPLICATION_THEME . '/views/:module');
  230.        $view->theme = APPLICATION_THEME;
  231.         $view->front = self::$frontController;
  232.         //$view->uploadPath = UPLOAD_PATH;
  233.         $view->addScriptPath(APPLICATION_PATH.'/layouts/partials');
  234.         $view->addScriptPath(APPLICATION_PATH.'/templates/'. APPLICATION_THEME . '/layouts/partials');//the default helpers
  235.         return $view;
  236.     }
  237.  
  238.     protected function _initConfiguration()
  239.     {
  240.         $app = $this->getApplication();
  241.         $config = $app->getOptions();
  242.  
  243.         if (APPLICATION_ENV == 'development')
  244.         {
  245.             error_reporting(E_ALL & E_STRICT);
  246.             error_reporting(E_ALL);
  247.             if (isset($config['phpsettings']))
  248.             {
  249.                 foreach ($config['phpsettings'] as $setting => $value)
  250.                 {
  251.                     ini_set($setting, $value);
  252.                 }
  253.             }
  254.         }
  255.     }
  256.  
  257.     public function run()
  258.     {
  259.         $loader = Zend_Loader_Autoloader::getInstance();
  260.         $loader->setFallbackAutoloader(true);
  261.        
  262.         $response = self::$frontController->dispatch();
  263.         $response->sendResponse();
  264.  
  265.     }
  266. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top