示例#1
0
function restoreDBFromBackup()
{
    makeRed("Restore Database? WARNING: This will drop all tables and restore data to last backup!");
    echo "(Y/N): ";
    $data = FOPEN("php://stdin", "rb");
    $input = '';
    while (1 == 1) {
        $chunk = FREAD($data, 1);
        if ($chunk == "\n" || $chunk == "\r") {
            break;
        }
        $input .= $chunk;
    }
    FCLOSE($data);
    if (strtolower(@$input) == 'y') {
        echo "Getting Credentials from application.ini...\n";
        $application = new Zend_Application(APPLICATION_ENV, APPLICATION_PATH . '/configs/application.ini');
        $bootstrap = $application->getBootstrap();
        $options = $bootstrap->getOptions();
        $db = $options['resources']['db']['params'];
        echo "Database Restoring. Please be patient, this could take a while...";
        sleep(1);
        echo ".";
        sleep(1);
        echo ".";
        sleep(1);
        echo ".";
        echo "\n";
        exec("mysql -u " . $db['username'] . " -p" . $db['password'] . " " . $db['dbname'] . " < " . APPLICATION_PATH . "/../data/dbbackup.sql", $output);
        makeGreen("DONE!");
        echo "\n\n";
    } else {
        echo "Operation Cancelled.\n";
    }
}
示例#2
0
 public function doRequest($request)
 {
     // redirector should not exit
     $redirector = \Zend_Controller_Action_HelperBroker::getStaticHelper('redirector');
     $redirector->setExit(false);
     // json helper should not exit
     $json = \Zend_Controller_Action_HelperBroker::getStaticHelper('json');
     $json->suppressExit = true;
     $zendRequest = new \Zend_Controller_Request_HttpTestCase();
     $zendRequest->setMethod($request->getMethod());
     $zendRequest->setCookies($request->getCookies());
     $zendRequest->setParams($request->getParameters());
     $zendRequest->setRequestUri(str_replace('http://localhost', '', $request->getUri()));
     $zendRequest->setHeaders($request->getServer());
     $_FILES = $request->getFiles();
     $_SERVER = array_merge($_SERVER, $request->getServer());
     $zendResponse = new \Zend_Controller_Response_HttpTestCase();
     $this->front->setRequest($zendRequest)->setResponse($zendResponse);
     ob_start();
     $this->bootstrap->run();
     ob_end_clean();
     $this->zendRequest = $zendRequest;
     $response = new Response($zendResponse->getBody(), $zendResponse->getHttpResponseCode(), $zendResponse->getHeaders());
     return $response;
 }
示例#3
0
 protected function setUp()
 {
     parent::setUp();
     $application = new Zend_Application(APPLICATION_ENV, APPLICATION_PATH . '/configs/application.ini');
     $application->getBootstrap()->bootstrap();
     $this->_form = new Student_Form_CreateStudentProfile();
 }
示例#4
0
 /**
  * Prepares the environment before running ALL tests.
  */
 public static function setUpBeforeClass()
 {
     // Inicializa o ZF
     $inifile = getenv('TRAVIS') !== false ? 'application.travis.ini' : 'application.ini';
     $bootstrap = new Zend_Application('testing', TEST_ROOT . '/assets/application/configs/' . $inifile);
     $bootstrap->bootstrap();
 }
示例#5
0
 public function setUp()
 {
     $application = new Zend_Application('testing', APPLICATION_PATH . '/configs/application.ini');
     $bootstrap = $application->bootstrap()->getBootstrap();
     $this->em = $bootstrap->getResource('entityManager');
     parent::setUp();
 }
示例#6
0
 public function testBootstrap()
 {
     $application = new Zend_Application('tests', dirname(__FILE__) . '/application.ini');
     $rediska = $application->bootstrap()->getBootstrap()->getResource('rediska');
     $this->assertType('Rediska', $rediska);
     $this->assertEquals('Rediska_Test_', $rediska->getOption('namespace'));
 }
示例#7
0
文件: ZF1.php 项目: kansey/yii2albom
 public function doRequest($request)
 {
     // redirector should not exit
     $redirector = \Zend_Controller_Action_HelperBroker::getStaticHelper('redirector');
     $redirector->setExit(false);
     // json helper should not exit
     $json = \Zend_Controller_Action_HelperBroker::getStaticHelper('json');
     $json->suppressExit = true;
     $zendRequest = new \Zend_Controller_Request_HttpTestCase();
     $zendRequest->setMethod($request->getMethod());
     $zendRequest->setCookies($request->getCookies());
     $zendRequest->setParams($request->getParameters());
     // Sf2's BrowserKit does not distinguish between GET, POST, PUT etc.,
     // so we set all parameters in ZF's request here to not break apps
     // relying on $request->getPost()
     $zendRequest->setPost($request->getParameters());
     $zendRequest->setRawBody($request->getContent());
     $zendRequest->setRequestUri(str_replace('http://localhost', '', $request->getUri()));
     $zendRequest->setHeaders($this->extractHeaders($request));
     $_FILES = $this->remapFiles($request->getFiles());
     $_SERVER = array_merge($_SERVER, $request->getServer());
     $zendResponse = new \Zend_Controller_Response_HttpTestCase();
     $this->front->setRequest($zendRequest)->setResponse($zendResponse);
     ob_start();
     try {
         $this->bootstrap->run();
     } catch (\Exception $e) {
         ob_end_clean();
         throw $e;
     }
     ob_end_clean();
     $this->zendRequest = $zendRequest;
     $response = new Response($zendResponse->getBody(), $zendResponse->getHttpResponseCode(), $this->formatResponseHeaders($zendResponse));
     return $response;
 }
示例#8
0
 public function testBootstrap()
 {
     $application = new Zend_Application('tests', REDISKA_TESTS_PATH . '/Test/Zend/Application/application.ini');
     $rediska = $application->bootstrap()->getBootstrap()->getResource('rediska');
     $this->assertType('Rediska', $rediska);
     $this->assertEquals('Rediska_Test_', $rediska->getOption('namespace'));
 }
示例#9
0
文件: index.php 项目: josmel/HosPot
 /**
  * 
  * @return Zend_Application
  */
 public static function getApplication()
 {
     $application = new Zend_Application(APPLICATION_ENV);
     $applicationini = new Zend_Config_Ini(APPLICATION_PATH . "/configs/application.ini", APPLICATION_ENV);
     $options = $applicationini->toArray();
     foreach (self::$_ini as $value) {
         $iniFile = APPLICATION_PATH . self::$_pathConfig . $value;
         if (is_readable($iniFile)) {
             $config = new Zend_Config_Ini($iniFile);
             $options = $application->mergeOptions($options, $config->toArray());
         } else {
             throw new Zend_Exception('error en la configuracion de los .ini');
         }
     }
     //        foreach (self::$_ini as $value) {
     //            $iniFile = APPLICATION_PATH . self::$_pathConfig . $value;
     //
     //            if (is_readable($iniFile)) {
     //                $config = new Zend_Config_Ini($iniFile);
     //                $options = $application->mergeOptions($options,
     //                    $config->toArray());
     //            } else {
     //            throw new Zend_Exception('error en la configuracion de los .ini');
     //            }
     //        }
     Zend_Registry::set('config', $options);
     $a = $application->setOptions($options);
     return $application;
 }
示例#10
0
 public function init()
 {
     // Define some CLI options
     $getopt = new Zend_Console_Getopt(array('withdata|w' => 'Load database with sample data', 'env|e-s' => 'Application environment for which to create database (defaults to development)', 'help|h' => 'Help -- usage message'));
     try {
         $getopt->parse();
     } catch (Zend_Console_Getopt_Exception $e) {
         // Bad options passed: report usage
         echo $e->getUsageMessage();
         return false;
     }
     // Initialize Zend_Application
     $application = new Zend_Application(APPLICATION_ENV, APPLICATION_PATH . '/configs/application.ini');
     // Initialize and retrieve DB resource
     $bootstrap = $application->getBootstrap();
     $bootstrap->bootstrap('db');
     $dbAdapter = $bootstrap->getResource('db');
     // let the user know whats going on (we are actually creating a
     // database here)
     if ('testing' != APPLICATION_ENV) {
         echo 'Writing Database Guestbook in (control-c to cancel): ' . PHP_EOL;
         for ($x = 5; $x > 0; $x--) {
             echo $x . "\r";
             sleep(1);
         }
     }
     vd(1);
 }
示例#11
0
 public static function bootstrap()
 {
     //
     // set the include_path
     set_include_path(implode(PATH_SEPARATOR, array('/usr/share/php/libzend-framework-php', realpath(APPLICATION_PATH . '/../glo-framework/library'), realpath(APPLICATION_PATH . '/../glo-generated'), realpath(APPLICATION_PATH . '/../library'), realpath(APPLICATION_PATH . '/../vendor'), get_include_path())));
     //
     // set up the autoloader
     require_once 'Zend/Loader/Autoloader.php';
     require_once 'Glo/Loader.php';
     $autoLoader = Zend_Loader_Autoloader::getInstance();
     $autoLoader->pushAutoloader(array('Glo_Loader', 'loadClass'));
     $autoLoader->setFallbackAutoloader(true);
     //
     // register the config
     $config = new Zend_Config_Ini(APPLICATION_PATH . '/configs/application.ini', Glo_Environment::get(), array('allowModifications' => TRUE));
     $registry = Zend_Registry::getInstance();
     $registry->set('config', $config);
     //
     // initialize the Zend Application
     require_once 'Zend/Application.php';
     $application = new Zend_Application(Glo_Environment::get(), APPLICATION_PATH . '/configs/application.ini');
     //
     // register the database configuration
     $bootstrap = $application->getBootstrap();
     $bootstrap->bootstrap('multidb');
     $resource = $bootstrap->getResource('multidb');
     Zend_Registry::set("conn_read", $resource->getDb('read'));
     Zend_Registry::set("conn_read_volatile", $resource->getDb('read_volatile'));
     Zend_Registry::set("conn_write", $resource->getDb('write'));
     return $application;
 }
示例#12
0
 public function setUp()
 {
     parent::setUp();
     $app = new Zend_Application(APPLICATION_ENV, APPLICATION_PATH . '/configs/application.ini');
     $app->getBootstrap()->bootstrap();
     $this->_form = new Student_Form_UpdateProfile();
 }
示例#13
0
 protected function setUp()
 {
     parent::setUp();
     $app = new Zend_Application(APPLICATION_ENV, APPLICATION_PATH . "/configs/application.ini");
     $app->bootstrap('translate');
     $this->translate = $app->getBootstrap()->getResource('translate');
     $this->translate->setLocale(new Zend_Locale('vi_VN'));
 }
示例#14
0
 public static function bootstrap($resource = null)
 {
     include_once 'Zend/Loader/Autoloader.php';
     $autoloader = Zend_Loader_Autoloader::getInstance();
     $autoloader->registerNamespace('Saffron_');
     $application = new Zend_Application(self::_getEnv(), self::_getConfig());
     return $application->getBootstrap()->bootstrap($resource);
 }
示例#15
0
 public function testNewInstance()
 {
     $application = new Zend_Application('tests', dirname(__FILE__) . '/application4.ini');
     $application->bootstrap()->getBootstrap()->getResource('session');
     $rediska = Zend_Session::getSaveHandler()->getRediska();
     $this->assertEquals('default', $rediska->getOption('name'));
     $this->assertEquals(array(), Rediska_Manager::getAll());
 }
示例#16
0
 /**
  * Overwrite standard setUp method, no database connection needed.  Will
  * create a file listing of class files instead.
  *
  * @return void
  */
 public function setUp()
 {
     require_once 'Zend/Application.php';
     set_include_path('../modules' . PATH_SEPARATOR . get_include_path());
     // Do test environment initializiation.
     $application = new Zend_Application(APPLICATION_ENV, array("config" => array(APPLICATION_PATH . '/application/configs/application.ini', APPLICATION_PATH . '/tests/config.ini')));
     $application->bootstrap();
 }
示例#17
0
 /**
  * Constructor
  *
  * Invoke setContainerFactory, set _coantainerFactory if factory is configurated
  * Ensure FrontController resource is registered
  *
  * @param  Zend_Application|Zend_Application_Bootstrap_Bootstrapper $application
  * @return void
  */
 public function __construct($application)
 {
     $this->setContainerFactory($application->getOptions());
     parent::__construct($application);
     if (!$this->hasPluginResource('FrontController')) {
         $this->registerPluginResource('FrontController');
     }
 }
示例#18
0
 public function testCleanWithNoIdsToClean()
 {
     $application = new Zend_Application('tests', dirname(__FILE__) . '/application5.ini');
     /* @var Zend_Cache_Manager $manager */
     $manager = $application->bootstrap()->getBootstrap()->getResource('cachemanager');
     $actual = $manager->getCache('test')->clean(Zend_Cache::CLEANING_MODE_ALL);
     $this->assertFalse($actual);
 }
    public function setUp()
    {
        include APPLICATION_PATH . '/../scripts/load.sqlite.php';

        $application = new Zend_Application(APPLICATION_ENV, APPLICATION_PATH . '/configs/application.ini');
        $this->bootstrap = array($application->getBootstrap(), 'bootstrap');
        return parent::setUp();
    }
    public function setUp()
    {
        include APPLICATION_PATH . '/../scripts/load.sqlite.php';
        $application = new Zend_Application(APPLICATION_ENV, APPLICATION_PATH . '/configs/application.ini');
        $bootstrap   = $application->getBootstrap();
        $bootstrap->bootstrap('autoload');
        $bootstrap->bootstrap('db');

        $this->guestbook = new Model_Guestbook();
    }
示例#21
0
 public function testNewInstance()
 {
     $application = new Zend_Application('tests', dirname(__FILE__) . '/application4.ini');
     $manager = $application->bootstrap()->getBootstrap()->getResource('cachemanager');
     $manager->getCache('test')->save('1', 'test');
     $rediska = new Rediska(array('redisVersion' => '2.0', 'addToManager' => false));
     $one = $rediska->get('test');
     $this->assertEquals('1', $one[0]);
     $this->assertEquals(array(), Rediska_Manager::getAll());
 }
示例#22
0
 public function qsBootstrap()
 {
     $this->application->bootstrap();
     $bootstrap = $this->application->getBootstrap();
     $frontController = $bootstrap->getResource('FrontController');
     $frontController->setParam('bootstrap', $bootstrap);
     $configApplication = $this->application->bootstrap('config');
     $requestConfig = $configApplication->getOption('request');
     $this->requestParameterName = $requestConfig['parameter'];
 }
示例#23
0
文件: AngelCommand.php 项目: ud223/yj
 public function __construct(\Zend_Application $application)
 {
     parent::__construct();
     $this->_application = $application;
     $this->_bootstrap = $application->getBootstrap();
     $this->_angel_bootstrap = $this->_bootstrap->getResource('modules')->offsetGet('angel');
     $this->_container = $this->_bootstrap->getResource('serviceContainer');
     $this->_documentManager = $this->_angel_bootstrap->getResource('mongoDocumentManager');
     $this->_logger = $this->_bootstrap->getResource('logger');
 }
示例#24
0
 public function testNewInstance()
 {
     $application = new Zend_Application('tests', dirname(__FILE__) . '/application4.ini');
     $log = $application->bootstrap()->getBootstrap()->getResource('log');
     $log->err('123');
     $log->info('123');
     $rediska = new Rediska(array('redisVersion' => '2.0', 'addToManager' => false));
     $count = $rediska->getListLength('log');
     $this->assertEquals(2, $count);
     $this->assertEquals(array(), Rediska_Manager::getAll());
 }
示例#25
0
 public static function getOption($key)
 {
     $front = Zend_Controller_Front::getInstance();
     $boot = $front->getParam('bootstrap');
     if (empty($boot)) {
         $application = new Zend_Application(APPLICATION_ENV, CONFIG_PATH . '/' . APPLICATION_CONFIG_FILENAME);
         return $application->getOption($key);
     } else {
         return $front->getParam('bootstrap')->getOption($key);
     }
 }
示例#26
0
 public function testDefaultAndAnother()
 {
     $application = new Zend_Application('tests', dirname(__FILE__) . '/application4.ini');
     $application->bootstrap()->getBootstrap()->getResource('rediska');
     $default = Rediska_Manager::get('default');
     $this->assertEquals('defaultInstance', $default->getOption('namespace'));
     $another = Rediska_Manager::get('another');
     $this->assertEquals('anotherInstance', $another->getOption('namespace'));
     $this->assertEquals(2, count(Rediska_Manager::getAll()));
     $this->assertEquals($default, Zend_Registry::get('rediska'));
 }
示例#27
0
 public static function bootstrap()
 {
     // Define path to application directory
     defined('APPLICATION_PATH') || define('APPLICATION_PATH', realpath(dirname(__FILE__) . '/../application'));
     // Define application environment
     defined('APPLICATION_ENV') || define('APPLICATION_ENV', getenv('APPLICATION_ENV') ? getenv('APPLICATION_ENV') : 'testing');
     !defined('UPLOAD_PATH') ? define('UPLOAD_PATH', realpath(dirname(__FILE__) . '/../public/upload')) : null;
     defined('HTTP_PATH') || define('HTTP_PATH', realpath(dirname(__FILE__)) . '/../public');
     require_once 'Zend/Application.php';
     $application = new Zend_Application(APPLICATION_ENV, APPLICATION_PATH . '/configs/application.ini');
     $application->bootstrap();
 }
示例#28
0
 /**
  * Init Application
  */
 public static function appInit()
 {
     $config = APPLICATION_PATH . '/configs/application.yaml';
     $result = new Core_Config_Yaml($config, APPLICATION_ENV);
     $result = $result->toArray();
     // Create application, bootstrap, and run
     $application = new Zend_Application(APPLICATION_ENV, $result);
     //        $application->bootstrap();
     //        $application->bootstrap('Frontcontroller');
     $application->bootstrap();
     $acl = new Core_Controller_Plugin_Acl();
     $acl->getAcl();
     self::migrationUp();
 }
示例#29
0
 public static function bootstrap($resource = null)
 {
     include_once 'Zend/Loader/Autoloader.php';
     $autoloader = Zend_Loader_Autoloader::getInstance();
     $autoloader->registerNamespace('Vslice_');
     $autoloader->registerNamespace('ZFDebug');
     // $autoloader->registerNamespace('Bvb');
     $autoloader->registerNamespace('My');
     $autoloader->registerNamespace('F5');
     $autoloader->registerNamespace('Zendx');
     $options = array('jquery_path' => 'http://ajax.googleapis.com/ajax/libs/jquery/1.5.2/jquery.min.js', 'plugins' => array('Variables', 'Html', 'File' => array('base_path' => '/Library/WebServer/Documents/'), 'Memory', 'Time', 'Exception'));
     $debug = new ZFDebug_Controller_Plugin_Debug($options);
     $application = new Zend_Application(self::_getEnv(), self::_getConfig());
     return $application->getBootstrap()->bootstrap($resource);
 }
示例#30
-1
 /**
  * bootstrap application
  */
 public function appBootstrap()
 {
     $this->_application = new Zend_Application(APPLICATION_ENV, APPLICATION_PATH . '/configs/application.ini');
     $this->_application->bootstrap();
     /*
      * Fix for ZF-8193
      * http://framework.zend.com/issues/browse/ZF-8193
      * Zend_Controller_Action->getInvokeArg('bootstrap') doesn't work
      * under the unit testing environment.
      */
     $front = Zend_Controller_Front::getInstance();
     if ($front->getParam('bootstrap') === null) {
         $front->setParam('bootstrap', $this->_application->getBootstrap());
     }
 }