Autor Zpráva
Pavel Straka
Profil
Dobrý večer, rád bych požádal o radu. Přesunul jsem e-shop Zencart na jiný hosting (= přesun souborů + databáze) a nyní bych potřeboval nahradit přístupová data k databázi za nová. Nemá někdo zkušenost, v jakém souboru tyo údaje najdu, abych je mohl nahradit aktuálními? Když nyní jdu na adresu e-shopu zobrazí se jen bílá stránka, je to způsobeno tím nebo je problém někde jinde? Výpis chybových hlášek je zapnutý, proto tomu nerozumím.

Děkuji za pomoc.
Majkl578
Profil
Zkus hledat v souboru include/configure.php.
Pavel Straka
Profil
Ano, takovou radu jsem našel při hledání na internetu, ale mám tu jen složky:
application
lang
library
log
public
tmp

v index.php se vkládá soubor require_once 'application/Core.php';
a v Core pak require_once './application/plugins/DbConnectPlugin.php';

ale tam žádné přihl. údaje uvedeny nejsou.

Přikládám celý zdroj:
<?php

/**
 * Zend Framework
 *
 * LICENSE
 *
 * This source file is subject to the new BSD license that is bundled
 * with this package in the file LICENSE.txt.
 * It is also available through the world-wide-web at this URL:
 * http://framework.zend.com/license/new-bsd
 * If you did not receive a copy of the license and are unable to
 * obtain it through the world-wide-web, please send an email
 * to license@zend.com so we can send you a copy immediately.
 *
 * @category   Zend
 * @package    Zend_Auth
 * @copyright  Copyright (c) 2005-2007 Zend Technologies USA Inc. (http://www.zend.com)
 * @license    http://framework.zend.com/license/new-bsd     New BSD License
 * @version    $Id: Auth.php 3467 2007-02-15 22:40:55Z darby $
 */
class DbConnectPlugin extends Zend_Controller_Plugin_Abstract
{
      private $_dbSettings;
      private $_db;

      //public function __construct(array $dbSettings)
      public function __construct()
    {
            //$this->_dbSettings = $dbSettings;
            $this->_dbSettings = Core::getConfig()->database->toArray();
      }

      /**
       * Establish connection to database. If connection fails we go to @link ErrorController.
       *
       * @param  Zend_Controller_Request_Abstract $request
       * @return void
       */
      public function dispatchLoopStartup(Zend_Controller_Request_Abstract $request)
    {
            try {
/*
                $config = new Zend_Config(
              array(
                      'database' => array(
                          'adapter' => 'Pdo_PgSQL',
                          'params'  => array(
                              'host'     => 'localhost',
                              'dbname'   => 'controlpanel',
                              'username' => 'postgres',
                              'password' => 'heslo'
                          )
                      )
              )
            );

                  $this->_db = Zend_Db::factory($config->database);
*/
            if (intval($this->_dbSettings['uppercase']) === 1) {
                $options = array(
                                  //Zend_Db::CASE_FOLDING => Zend_Db::CASE_UPPER
                                  Zend_Db::CASE_FOLDING => Zend_Db::CASE_LOWER
                                );

                $this->_dbSettings['params']['options'] = $options;
            }

                  $this->_db = Zend_Db::factory($this->_dbSettings['adapter'], $this->_dbSettings['params']);

                  $this->_db->query('SET NAMES '.$this->_dbSettings['encoding']);
                  //$this->_db->query('SET CHARACTER SET '.$this->_dbSettings['encoding']);

                  if ($this->_dbSettings['profiler'] == true) {
                        $this->_db->getProfiler()->setEnabled(true);
                  }

            if (!empty($this->_dbSettings['prefix'])) {
                Zend_Registry::set('prefix', $this->_dbSettings['prefix']);

                //$this->setTablePrefix(trim($this->_dbSettings['prefix'], '_').'_');
            }

                  Zend_Db_Table_Abstract::setDefaultAdapter($this->_db);
                  //Zinn_Db_Table_Abstract::setDefaultAdapter($this->_db);

            $serverRoot = Zend_Registry::get('serverRoot');

            $frontendOptions = array('automatic_serialization' => true);
            //$backendOptions  = array('cache_dir' => 'cacheDir');
            $backendOptions  = array('cache_dir' => $serverRoot . 'tmp');
            $cache = Zend_Cache::factory('Core', 'File', $frontendOptions, $backendOptions); // Next, set the cache to be used with all table objects
            Zend_Db_Table_Abstract::setDefaultMetadataCache($cache);

                  Zend_Registry::set('db', $this->_db);

                  //$this->setTablePrefix('ds');
                  //$this->removeTablePrefix('ds');
            } catch(Exception $e) {
                  $frontController = Zend_Controller_Front::getInstance();

            if ($frontController->throwExceptions()) {
                throw $e;
            }

            $error = new ArrayObject(array(), ArrayObject::ARRAY_AS_PROPS);
            $exception = $e;
            $exceptionType = get_class($e);
            $error->exception = $exception;
            $error->type = Zend_Controller_Plugin_ErrorHandler::EXCEPTION_OTHER;

            $request->setParam('message', 'Došlo k chybě při spojení s databází');

            $error->request = clone $request;

                  $errorHandler = $frontController->getPlugin('Zend_Controller_Plugin_ErrorHandler');

                  $request->setParam('error_handler', $error)
                    ->setModuleName($errorHandler->getErrorHandlerModule())
                    ->setControllerName($errorHandler->getErrorHandlerController())
                    ->setActionName($errorHandler->getErrorHandlerAction())
                    ->setDispatched(false);
            }
      }

      /* Called before Zend_Controller_Front exits its dispatch loop.
     *
     * @return void
     */
      public function dispatchLoopShutdown()
    {
            if ($this->_dbSettings['profiler'] == true) {
                  $profiler = $this->_db->getProfiler();

                  $totalTime = $profiler->getTotalElapsedSecs();
                  $queryCount = $profiler->getTotalNumQueries();
                  $longestTime = 0;
                  $longestQuery = null;

            $out  = '<div style="width: 900px; text-align: left; background-color: #000000; color: #ffffff; border: 2px solid #ffffff; padding: 20px 20px; margin: 10px auto;">' . "\n";
            $out .= '<h3 style="padding-top: -20px; color: #ffffff; margin-bottom: 20px;">Database profiler (only for development purposes)</h3>' . "\n";
                  $out .= 'Executed ' . $queryCount . ' queries in ' . $totalTime . ' seconds<br /><br />' . "\n";

            if ($totalTime > 0 && $queryCount > 0) {
                      foreach ($profiler->getQueryProfiles() as $query) {
                            if ($query->getElapsedSecs() > $longestTime) {
                                  $longestTime = $query->getElapsedSecs();
                                  $longestQuery = $query->getQuery();
                            }
                      }

                      $out .= 'Average query length: ' . ($totalTime / $queryCount) . ' seconds<br /><br />' . "\n";
                      $out .= 'Queries per second: ' . ($queryCount / $totalTime) . '<br /><br />' . "\n";
                      $out .= 'Longest query length: ' . $longestTime . ' seconds<br /><br />' . "\n";
                      $out .= 'Longest query: ' . $longestQuery . '<br /><br />' . "\n";

                $out .= '<br /><br />' . "\n\n";

                      foreach ($profiler->getQueryProfiles() as $query) {
                    $out .= $query->getQuery() . '<br /><br />' . "\n\n";
                }
            }

            $out .= '</div>' . "\n";

                  $this->_response->appendBody($out);
            }

        if ($this->_dbSettings['logQueries'] == true) {
            $logger = Core::setLogger('queries');
                  $profiler = $this->_db->getProfiler();

            if (intval($profiler->getTotalNumQueries()) > 0) {
                      foreach ($profiler->getQueryProfiles() as $query) {
                    $logger->log($query->getQuery(), Zend_Log::DEBUG);
                }
            }
          }
      }

    public function setTablePrefix($prefix = '')
    {
        $tables = $this->_db->listTables();

        if (!empty($prefix)) {
            $prefix = trim($prefx, '_') . '_';

            foreach ($tables as $table) {
                $this->_db->query('RENAME TABLE `' . $table . '` TO `' . $prefix . $table . '`');
            }
        }

        Zend_Debug::dump('OK');
        exit();
/*
        $query = $this->_db->query('SHOW TABLES');
        $tables = $query->fetchAll();
  
        foreach($tables as $table)
        {
          $this->_db->query('RENAME TABLE `'.$table['Tables_in_portaly'].'` TO `ds_'.$table['Tables_in_portaly'].'`');
          $this->_db->query('RENAME TABLE `'.$table['Tables_in_portaly'].'` TO `'.str_replace("ds_", "", $table['Tables_in_portaly']).'`');
        }
  
        Zend_Debug::dump('OK');
        exit();
*/
    }

    public function removeTablePrefix($prefix = '')
    {
        $tables = $this->_db->listTables();

        $pattern = '';

        if (!empty($prefix)) {
            $prefix = trim($prefx, '_') . '_';
            $pattern = '/' . $prefix . '/';
        }

        if (!empty($pattern)) {
            foreach ($tables as $table) {
                $this->_db->query('RENAME TABLE `' . $table . '` TO `' . preg_replace($pattern, '', $table, 1) . '`');
            }
        }

        Zend_Debug::dump('OK');
        exit();
    }
}



Respektive jsou tam, ale v zakomentované části.
Pavel Straka
Profil
Omlouvám se, nejedná se o Zencart, ale o Zend Framework. Můj problém nyní: dohledal jsem na internetu, že nastavení přístupů do DB je v souboru application/configs/application.ini, žádnou sloužku configs tady ale nemám. Jak je to možné? Děkuji za rady.

Vaše odpověď

Mohlo by se hodit


Prosím používejte diakritiku a interpunkci.

Ochrana proti spamu. Napište prosím číslo dvě-sta čtyřicet-sedm: