Beispiel #1
0
 public function installAction()
 {
     // database configuration host/unix socket
     $dbConfig = ['username' => $this->getParam("mysql_username"), 'password' => $this->getParam("mysql_password"), 'dbname' => $this->getParam("mysql_database")];
     $hostSocketValue = $this->getParam("mysql_host_socket");
     if (file_exists($hostSocketValue)) {
         $dbConfig["unix_socket"] = $hostSocketValue;
     } else {
         $dbConfig["host"] = $hostSocketValue;
         $dbConfig["port"] = $this->getParam("mysql_port");
     }
     // try to establish a mysql connection
     try {
         $db = \Zend_Db::factory($this->getParam("mysql_adapter"), $dbConfig);
         $db->getConnection();
         // check utf-8 encoding
         $result = $db->fetchRow('SHOW VARIABLES LIKE "character\\_set\\_database"');
         if ($result['Value'] != "utf8") {
             $errors[] = "Database charset is not utf-8";
         }
     } catch (\Exception $e) {
         $errors[] = "Couldn't establish connection to mysql: " . $e->getMessage();
     }
     // check username & password
     if (strlen($this->getParam("admin_password")) < 4 || strlen($this->getParam("admin_username")) < 4) {
         $errors[] = "Username and password should have at least 4 characters";
     }
     if (empty($errors)) {
         $setup = new Tool\Setup();
         // check if /website folder already exists, if not, look for /website_demo & /website_example
         // /website_install is just for testing in dev environment
         if (!is_dir(PIMCORE_WEBSITE_PATH)) {
             foreach (["website_install", "website_demo", "website_example"] as $websiteDir) {
                 $dir = PIMCORE_DOCUMENT_ROOT . "/" . $websiteDir;
                 if (is_dir($dir)) {
                     rename($dir, PIMCORE_WEBSITE_PATH);
                     break;
                 }
             }
         }
         $setup->config(array("database" => array("adapter" => $this->getParam("mysql_adapter"), "params" => $dbConfig)));
         // look for a template dump
         // eg. for use with demo installer
         $dbDataFile = PIMCORE_WEBSITE_PATH . "/dump/data.sql";
         $contentConfig = array("username" => $this->getParam("admin_username"), "password" => $this->getParam("admin_password"));
         if (!file_exists($dbDataFile)) {
             $setup->database();
             \Pimcore::initConfiguration();
             $setup->contents($contentConfig);
         } else {
             $setup->database();
             $setup->insertDump($dbDataFile);
             \Pimcore::initConfiguration();
             $setup->createOrUpdateUser($contentConfig);
         }
         $this->_helper->json(array("success" => true));
     } else {
         echo implode("<br />", $errors);
         die;
     }
 }
Beispiel #2
0
 /**
  * resets the registry
  * @static
  * @return void
  */
 public static function resetRegistry()
 {
     $conf = Zend_Registry::get('pimcore_config_test');
     Zend_Registry::_unsetInstance();
     Zend_Registry::set('pimcore_config_test', $conf);
     Pimcore::initConfiguration();
     Pimcore::initPlugins();
 }
<?php 
/**
 * This source file is subject to the new BSD license that is
 * available through the world-wide-web at this URL:
 * http://www.pimcore.org/license
 *
 * @copyright  Copyright (c) 2013 Weblizards GbR (http://www.weblizards.de)
 * @author     Thomas Keil <*****@*****.**>
 * @license    http://www.pimcore.org/license     New BSD License
 */
ini_set('memory_limit', '2048M');
set_time_limit(-1);
date_default_timezone_set("Europe/Berlin");
include_once dirname(__FILE__) . "/../../../pimcore/config/startup.php";
Pimcore::initAutoloader();
Pimcore::initConfiguration();
Pimcore::initLogger();
Pimcore::initPlugins();
$opts = new Zend_Console_Getopt(array('language|l=s' => "language", 'document|d=s' => "document"));
try {
    $opts->parse();
} catch (Exception $e) {
    Logger::critical($e->getMessage());
    die("Error: " . $e->getMessage());
}
$sphinx_config = SphinxSearch_Config::getInstance();
$documents = $sphinx_config->getDocumentsAsArray();
if (!array_key_exists($opts->document, $documents)) {
    SphinxSearch_Logger::err("Unknown document: " . $opts->document . "\n");
    print "Unknown document: " . $opts->document . "\n";
    print "Possible documents are:\n";
 public function installAction()
 {
     // try to establish a mysql connection
     try {
         $db = Zend_Db::factory($this->_getParam("mysql_adapter"), array('host' => $this->_getParam("mysql_host"), 'username' => $this->_getParam("mysql_username"), 'password' => $this->_getParam("mysql_password"), 'dbname' => $this->_getParam("mysql_database"), "port" => $this->_getParam("mysql_port")));
         $db->getConnection();
         // check utf-8 encoding
         $result = $db->fetchRow('SHOW VARIABLES LIKE "character\\_set\\_database"');
         if ($result['Value'] != "utf8") {
             $errors[] = "Database charset is not utf-8";
         }
     } catch (Exception $e) {
         $errors[] = "Couldn't establish connection to mysql: " . $e->getMessage();
     }
     // check username & password
     if (strlen($this->_getParam("admin_password")) < 4 || strlen($this->_getParam("admin_username")) < 4) {
         $errors[] = "Username and password should have at least 4 characters";
     }
     if (empty($errors)) {
         // write configuration file
         $settings = array("general" => array("timezone" => "Europe/Berlin", "language" => "en", "validLanguages" => "en", "debug" => "1", "loginscreenimageservice" => "1", "loglevel" => array("debug" => "1", "info" => "1", "notice" => "1", "warning" => "1", "error" => "1", "critical" => "1", "alert" => "1", "emergency" => "1")), "database" => array("adapter" => $this->_getParam("mysql_adapter"), "params" => array("host" => $this->_getParam("mysql_host"), "username" => $this->_getParam("mysql_username"), "password" => $this->_getParam("mysql_password"), "dbname" => $this->_getParam("mysql_database"), "port" => $this->_getParam("mysql_port"))), "documents" => array("versions" => array("steps" => "10"), "default_controller" => "default", "default_action" => "default", "error_pages" => array("default" => "/"), "createredirectwhenmoved" => "", "allowtrailingslash" => "no", "allowcapitals" => "no"), "objects" => array("versions" => array("steps" => "10")), "assets" => array("versions" => array("steps" => "10")), "services" => array(), "cache" => array("excludeCookie" => "pimcore_admin_sid"), "httpclient" => array("adapter" => "Zend_Http_Client_Adapter_Socket"));
         $config = new Zend_Config($settings, true);
         $writer = new Zend_Config_Writer_Xml(array("config" => $config, "filename" => PIMCORE_CONFIGURATION_SYSTEM));
         $writer->write();
         // insert db dump
         $db = Pimcore_Resource::get();
         $mysqlInstallScript = file_get_contents(PIMCORE_PATH . "/modules/install/mysql/install.sql");
         // remove comments in SQL script
         $mysqlInstallScript = preg_replace("/\\s*(?!<\")\\/\\*[^\\*]+\\*\\/(?!\")\\s*/", "", $mysqlInstallScript);
         // get every command as single part
         $mysqlInstallScripts = explode(";", $mysqlInstallScript);
         // execute every script with a separate call, otherwise this will end in a PDO_Exception "unbufferd queries, ..." seems to be a PDO bug after some googling
         foreach ($mysqlInstallScripts as $m) {
             $sql = trim($m);
             if (strlen($sql) > 0) {
                 $sql .= ";";
                 $db->query($m);
             }
         }
         // get a new database connection
         $db = Pimcore_Resource::reset();
         // insert data into database
         $db->insert("assets", array("id" => 1, "parentId" => 0, "type" => "folder", "filename" => "", "path" => "/", "creationDate" => time(), "modificationDate" => time(), "userOwner" => 1, "userModification" => 1));
         $db->insert("documents", array("id" => 1, "parentId" => 0, "type" => "page", "key" => "", "path" => "/", "index" => 999999, "published" => 1, "creationDate" => time(), "modificationDate" => time(), "userOwner" => 1, "userModification" => 1));
         $db->insert("documents_page", array("id" => 1, "controller" => "", "action" => "", "template" => "", "title" => "", "description" => "", "keywords" => ""));
         $db->insert("objects", array("o_id" => 1, "o_parentId" => 0, "o_type" => "folder", "o_key" => "", "o_path" => "/", "o_index" => 999999, "o_published" => 1, "o_creationDate" => time(), "o_modificationDate" => time(), "o_userOwner" => 1, "o_userModification" => 1));
         $db->insert("users", array("parentId" => 0, "name" => "system", "admin" => 1, "active" => 1));
         $db->update("users", array("id" => 0), $db->quoteInto("name = ?", "system"));
         $userPermissions = array(array("key" => "assets"), array("key" => "classes"), array("key" => "clear_cache"), array("key" => "clear_temp_files"), array("key" => "document_types"), array("key" => "documents"), array("key" => "objects"), array("key" => "plugins"), array("key" => "predefined_properties"), array("key" => "routes"), array("key" => "seemode"), array("key" => "system_settings"), array("key" => "thumbnails"), array("key" => "translations"), array("key" => "redirects"), array("key" => "glossary"), array("key" => "reports"));
         foreach ($userPermissions as $up) {
             $db->insert("users_permission_definitions", $up);
         }
         Pimcore::initConfiguration();
         $user = User::create(array("parentId" => 0, "username" => $this->_getParam("admin_username"), "password" => Pimcore_Tool_Authentication::getPasswordHash($this->_getParam("admin_username"), $this->_getParam("admin_password")), "active" => true));
         $user->setAdmin(true);
         $user->save();
         $this->_helper->json(array("success" => true));
     } else {
         echo implode("<br />", $errors);
         die;
     }
 }