public function process()
 {
     @(include_once 'phpMyImporter.php');
     $pass = Phpfox::getParam(array('db', 'pass'));
     $name = Phpfox::getParam(array('db', 'name'));
     $user = Phpfox::getParam(array('db', 'user'));
     $host = Phpfox::getParam(array('db', 'host'));
     $connection = @mysql_connect($host, $user, $pass);
     $process = Phpfox::getService('backuprestore.process');
     if ($this->request()->get('database_restore')) {
         $process->importDatabaseRestore($this->request()->get('fileId'));
     }
     $fileId = $this->request()->get('fileId') ? $this->request()->get('fileId') : 0;
     $this->template()->assign(array('fileId' => $fileId));
     if ($this->request()->get('database_submit')) {
         $file = $this->request()->get('database_file');
         //var_dump($file['name']);die;
         $uniqueImport = Phpfox::getService('backuprestore.history');
         $import_name = $file['name'];
         //echo $file['name'];die;
         /*if(!$uniqueImport->checkImportFileName($import_name)){
            $err_txt = Phpfox::getPhrase('backuprestore.this_base_was_not_done_through_our_service');
            return Phpfox_Error::set($err_txt);
           }*/
         $upl = "file/cloudrestore/";
         if (!is_dir($upl)) {
             @mkdir($upl, 0777);
             @chmod($upl, 0777);
         }
         $uploaddir = realpath('file/cloudrestore/');
         $uploadfile = $uploaddir . "/" . basename($file['name']);
         if (move_uploaded_file($file['tmp_name'], $uploadfile)) {
             $dump = new phpMyImporter($name, $connection, $uploadfile, true);
             $dump->utf8 = true;
             // Uses UTF8 connection with MySQL server, default: true
             if ($dump->doImport()) {
                 $process->clearDir('file/cloudrestore/');
                 $success_txt = Phpfox::getPhrase('backuprestore.database_was_successfully_uploaded');
                 return Phpfox::addMessage($success_txt);
             } else {
                 $err_txt = Phpfox::getPhrase('backuprestore.error_loading_database');
                 return Phpfox_Error::set($err_txt);
             }
         }
     }
     $this->template()->setBreadcrumb(Phpfox::getPhrase('backuprestore.databaserestore'), $this->url()->makeUrl('admincp.backuprestore.databaserestore'))->setHeader(array('btdbstyles.css' => 'module_backuprestore', 'scripts.js' => 'module_backuprestore'));
 }
Esempio n. 2
0
 /**
  * @description Database restore
  * @param $fileId
  */
 public function importDatabaseRestore($fileId)
 {
     $historyObj = Phpfox::getService('backuprestore.history');
     $history = $historyObj->getBTDBHistoryById($fileId);
     include_once Phpfox::getParam('core.path') . '/module/backuprestore/static/php/phpMyImporter.php';
     $pass = Phpfox::getParam(array('db', 'pass'));
     $name = Phpfox::getParam(array('db', 'name'));
     $user = Phpfox::getParam(array('db', 'user'));
     $host = Phpfox::getParam(array('db', 'host'));
     $connection = @mysql_connect($host, $user, $pass);
     $dump = new phpMyImporter($name, $connection, 'file/tmpDatabaseRestore/' . $history['import_database_name'], true);
     $dump->utf8 = true;
     // Uses UTF8 connection with MySQL server, default: true
     if ($dump->doImport()) {
         $success_txt = Phpfox::getPhrase('backuprestore.database_was_successfully_uploaded');
         $this->clearDir("file/tmpDatabaseRestore/");
         return Phpfox::addMessage($success_txt);
     } else {
         $err_txt = Phpfox::getPhrase('backuprestore.error_loading_database');
         return Phpfox_Error::set($err_txt);
     }
 }
Esempio n. 3
0
    /**
     * Generates the module content.
     *
     * @return void
     */
    protected function moduleContent()
    {
        switch ((string) $this->MOD_SETTINGS['function']) {
            case 1:
                // Get default project name
                $path = PATH_site . 'fileadmin/templates/';
                $dirs = scandir($path);
                // Filter directories
                foreach ($dirs as $dir) {
                    if ($dir != '.' && $dir != '..' && $dir != 'default' && $dir != 'ts') {
                        $projectDir = $dir;
                    }
                }
                // Form submitted
                if ($_POST['submit_config']) {
                    // No basedomain given
                    if (!$_POST['project_basedomainde']) {
                        $errorMessageContent = '<h3>' . $GLOBALS['LANG']->getLL('noBasedomain') . '</h3>';
                        $errorMessageContent .= '<p>' . $GLOBALS['LANG']->getLL('noBasedomainText') . '</p>';
                        $content = '<div class="alert alert-error">' . $errorMessageContent . '</div>';
                        $this->content .= $this->doc->section($GLOBALS['LANG']->getLL('title'), $content, 0, 1);
                    } else {
                        if (!$_POST['project_email']) {
                            $errorMessageContent = '<h3>' . $GLOBALS['LANG']->getLL('noEmail') . '</h3>';
                            $errorMessageContent .= '<p>' . $GLOBALS['LANG']->getLL('noEmailText') . '</p>';
                            $content = '<div class="alert alert-error">' . $errorMessageContent . '</div>';
                            $this->content .= $this->doc->section($GLOBALS['LANG']->getLL('title'), $content, 0, 1);
                        } else {
                            if (!$this->checkEmail($_POST['project_email'])) {
                                $errorMessageContent = '<h3>' . $GLOBALS['LANG']->getLL('noValidEmail') . '</h3>';
                                $errorMessageContent .= '<p>' . $GLOBALS['LANG']->getLL('noValidEmailText') . '</p>';
                                $content = '<div class="alert alert-error">' . $errorMessageContent . '</div>';
                                $this->content .= $this->doc->section($GLOBALS['LANG']->getLL('title'), $content, 0, 1);
                            } else {
                                if (!$_POST['project_httphost']) {
                                    $errorMessageContent = '<h3>' . $GLOBALS['LANG']->getLL('noHttpHost') . '</h3>';
                                    $errorMessageContent .= '<p>' . $GLOBALS['LANG']->getLL('noHttpHostText') . '</p>';
                                    $content = '<div class="alert alert-error">' . $errorMessageContent . '</div>';
                                    $this->content .= $this->doc->section($GLOBALS['LANG']->getLL('title'), $content, 0, 1);
                                } else {
                                    // Get project name
                                    $projectName = trim(strtolower($_POST['project_name']));
                                    // Check if uppercase
                                    if (ctype_upper($_POST['project_name'])) {
                                        $projectNameUpper = $_POST['project_name'];
                                        $projectDirUpper = strtoupper($projectDir);
                                    } else {
                                        $projectNameUpper = $projectName;
                                        $projectDirUpper = $projectDir;
                                    }
                                    // Rename dir
                                    rename($path . $projectDir, $path . $projectName);
                                    /* Change files BEGIN */
                                    // Files to change
                                    $files = array(PATH_site . 'fileadmin/templates/ts/setup/JavaScriptIncludes_setup.ts', PATH_site . 'fileadmin/templates/ts/TSConfig/Page.ts', PATH_site . 'typo3conf/new_localconf.php');
                                    // Parse files
                                    foreach ($files as $f) {
                                        // Open file
                                        $data = file_get_contents($f);
                                        // Change data
                                        $data = str_replace($projectDir, $projectName, $data);
                                        // Write file
                                        file_put_contents($f, $data);
                                    }
                                    /* Change files END */
                                    /* Change files with uppercase BEGIN */
                                    // Files to change
                                    $files2 = array(PATH_site . 'fileadmin/templates/ts/setup/lib_setup.ts', PATH_site . 'fileadmin/templates/ts/constants/StandardConfig_constants.ts', PATH_site . 'fileadmin/templates/ts/setup/lib_setup.ts');
                                    // Parse files
                                    foreach ($files2 as $f2) {
                                        // Open file
                                        $data2 = file_get_contents($f2);
                                        // Change data
                                        $data2 = str_replace(ucfirst($projectDir), ucfirst($projectNameUpper), $data2);
                                        // Write file
                                        file_put_contents($f2, $data2);
                                    }
                                    /* Change files with uppercase END */
                                    /* Copyright notice BEGIN */
                                    $copyrightNotice = $_POST['project_copyright'];
                                    if (!$copyrightNotice) {
                                        $copyrightNotice = $GLOBALS['LANG']->getLL('copyrightDefault');
                                    }
                                    $files3 = array(PATH_site . 'fileadmin/templates/ts/setup/StandardConfig_setup.ts');
                                    foreach ($files3 as $f3) {
                                        // Open file
                                        $data3 = file_get_contents($f3);
                                        // Change data
                                        $data3 = str_replace("headerComment =", "headerComment = " . $copyrightNotice, $data3);
                                        // Write file
                                        file_put_contents($f3, $data3);
                                    }
                                    /* Copyright notice END */
                                    /* Basedomain BEGIN */
                                    $files4 = array(PATH_site . 'fileadmin/templates/ts/constants/StandardConfig_constants.ts');
                                    foreach ($files4 as $f4) {
                                        $basedomainDE = trim($_POST['project_basedomainde'], '/') . '/';
                                        $basedomainEN = trim($_POST['project_basedomainen'], '/') . '/';
                                        $httpHost = trim($_POST['project_httphost'], '/');
                                        $basedomainDEPreview = trim($_POST['preview_basedomainde'], '/') . '/';
                                        $basedomainENPreview = trim($_POST['preview_basedomainen'], '/') . '/';
                                        $httpHostPreview = trim($_POST['preview_httphost'], '/');
                                        $basedomainDELive = trim($_POST['live_basedomainde'], '/') . '/';
                                        $basedomainENLive = trim($_POST['live_basedomainen'], '/') . '/';
                                        $httpHostLive = trim($_POST['live_httphost'], '/');
                                        // Open file
                                        $data4 = file_get_contents($f4);
                                        // Add data
                                        $data4 = "" . $data4 . "\r\n\r\n# # medbootstraptools [BEGIN]\r\n\r\n[globalVar = IENV:HTTP_HOST = " . $httpHost . "]\r\n\r\nt3bootstrap {\r\n\tbasedomain.de = " . $basedomainDE . "\r\n\tbasedomain.en = " . $basedomainEN . "\r\n}\r\n\r\n[globalVar = IENV:HTTP_HOST = " . $httpHostPreview . "]\r\n\r\nt3bootstrap {\r\n\tbasedomain.de = " . $basedomainDEPreview . "\r\n\tbasedomain.en = " . $basedomainENPreview . "\r\n}\r\n\r\n[globalVar = IENV:HTTP_HOST = " . $httpHostLive . "]\r\n\r\nt3bootstrap {\r\n\tbasedomain.de = " . $basedomainDELive . "\r\n\tbasedomain.en = " . $basedomainENLive . "\r\n}\r\n\r\n[global]\r\n\r\n# # medbootstraptools [END]";
                                        // Write file
                                        file_put_contents($f4, $data4);
                                    }
                                    /* Basedomain END */
                                    /* Robots BEGIN */
                                    // Get file
                                    $robotsFile = PATH_site . 'fileadmin/templates/ts/setup/StandardConfig_setup.ts';
                                    // Open file
                                    $robotsFileContent = file_get_contents($robotsFile);
                                    // Add data
                                    $robotsFileContent = "" . $robotsFileContent . "\r\n\r\n# # medbootstraptools [BEGIN]\r\n\r\n[globalVar = IENV:HTTP_HOST = " . $httpHost . "]\r\n\r\npage.meta.robots = noindex, nofollow\r\n\r\n[globalVar = IENV:HTTP_HOST = " . $httpHostPreview . "]\r\n\r\npage.meta.robots = noindex, nofollow\r\n\r\n[globalVar = IENV:HTTP_HOST = " . $httpHostLive . "]\r\n\r\npage.meta.robots = index, follow\r\n\r\n[global]\r\n\r\n# # medbootstraptools [END]";
                                    // Write file
                                    file_put_contents($robotsFile, $robotsFileContent);
                                    /* Robots END */
                                    /* Responsive or not BEGIN */
                                    if ($_POST['project_responsive'] != "on") {
                                        $resp = PATH_site . 'fileadmin/templates/ts/setup/CSSIncludes_setup.ts';
                                        $dataResp = file_get_contents($resp);
                                        $dataResp = str_replace("bootstrap-responsive", "no-responsive", $dataResp);
                                        file_put_contents($resp, $dataResp);
                                        // Rename t3bootstrap responsive
                                        $t3bootstrapResp = PATH_site . 'fileadmin/templates/default/less/t3bootstrap-responsive.less';
                                        rename($t3bootstrapResp, $t3bootstrapResp . '_doNotUse');
                                        // File
                                        $lessConfigFile = PATH_site . 'fileadmin/templates/ts/setup/Extensions_setup.ts';
                                        // Get content
                                        $lessConfigFileContent = file_get_contents($lessConfigFile);
                                        // Remove LESS config for responsive CSS file
                                        $lessConfigFileContent = preg_replace('/t3bootstrap-responsive {[^{}]*}/', '', $lessConfigFileContent);
                                        // Write file
                                        file_put_contents($lessConfigFile, $lessConfigFileContent);
                                    }
                                    /* Responsive or not END */
                                    /* Install Tool password BEGIN */
                                    $localconfFile = PATH_site . 'typo3conf/new_localconf.php';
                                    $localconfData = file_get_contents($localconfFile);
                                    $newInstallPassword = $this->generatePW();
                                    $localConfContent = "// Updated by medbootstraptools " . date("d.m.y", time()) . " " . date("H:i:s", time()) . "\n\$TYPO3_CONF_VARS['BE']['installToolPassword'] = '******';";
                                    $localconfData = str_replace("?>", "\n" . $localConfContent . "\n?>", $localconfData);
                                    file_put_contents($localconfFile, $localconfData);
                                    /* Install Tool password END */
                                    /* Update site name BEGIN */
                                    // Get localconf
                                    $data = file_get_contents($localconfFile);
                                    $data = str_replace("\$TYPO3_CONF_VARS['SYS']['sitename'] = '" . ucfirst($projectDir) . "';", "\$TYPO3_CONF_VARS['SYS']['sitename'] = '" . ucfirst($projectNameUpper) . "';", $data);
                                    // Write file
                                    file_put_contents($localconfFile, $data);
                                    /* Update site name END */
                                    /* Settings LIVE/PREVIEW server BEGIN */
                                    // Get file
                                    $settingsFile = PATH_typo3conf . 'settings.php';
                                    // Get settings
                                    $server = $_POST['live_server'];
                                    $host = $_POST['live_host'];
                                    $username = $_POST['live_username'];
                                    $dbPassword = $_POST['live_password'];
                                    $database = $_POST['live_database'];
                                    $imPath = $_POST['live_impath'];
                                    $previewServer = $_POST['preview_server'];
                                    $previewHost = $_POST['preview_host'];
                                    $previewUsername = $_POST['preview_username'];
                                    $previewDbPassword = $_POST['preview_password'];
                                    $previewDatabase = $_POST['preview_database'];
                                    $previewImPath = $_POST['preview_impath'];
                                    // Get content
                                    if (!$server && !$host && !$username && !$dbPassword && !$database && !$previewServer && !$previewHost && !$previewUsername && !$previewDbPassword && !$previewDatabase && !$imPath && !$previewImPath) {
                                        $settingsContent = "<?php\r\n\$TYPO3_CONF_VARS['GFX']['im_path_lzw'] = '/usr/local/bin/';\r\n\$TYPO3_CONF_VARS['GFX']['im_path'] = '/usr/local/bin/';\r\n?>";
                                    } else {
                                        $settingsContent = "<?php\r\n\tif(\$_SERVER['SERVER_NAME'] == '" . $server . "') {\r\n\t\t\$typo_db_username = '******';\r\n\t\t\$typo_db_password = '******';\r\n\t\t\$typo_db_host = '" . $host . "';\r\n\t\t\$typo_db = '" . $database . "';\r\n\t\t\$TYPO3_CONF_VARS['GFX']['im_path_lzw'] = '" . $imPath . "';\r\n\t\t\$TYPO3_CONF_VARS['GFX']['im_path'] = '" . $imPath . "';\r\n\t}\r\n\telse if(\$_SERVER['SERVER_NAME'] == '" . $previewServer . "') {\r\n\t\t\$typo_db_username = '******';\r\n\t\t\$typo_db_password = '******';\r\n\t\t\$typo_db_host = '" . $previewHost . "';\r\n\t\t\$typo_db = '" . $previewDatabase . "';\r\n\t\t\$TYPO3_CONF_VARS['GFX']['im_path_lzw'] = '" . $previewImPath . "';\r\n\t\t\$TYPO3_CONF_VARS['GFX']['im_path'] = '" . $previewImPath . "';\r\n\t}\r\n?>";
                                    }
                                    file_put_contents($settingsFile, $settingsContent);
                                    /* Settings LIVE/PREVIEW server END */
                                    /* Import database BEGIN */
                                    /**
                                     * @todo Replace @mysql_connect, as TYPO3 Backend is already connected; change import script class
                                     */
                                    // Connect to database
                                    $connection = @mysql_connect(TYPO3_db_host, TYPO3_db_username, TYPO3_db_password);
                                    // Get SQL file
                                    $filename = PATH_typo3conf . 'ext/medbootstraptools/mod1/sql/t3bootstrap.sql';
                                    $compress = false;
                                    $dump = new phpMyImporter(TYPO3_db, $connection, $filename, $compress);
                                    $dump->utf8 = true;
                                    // Uses UTF8 connection with MySQL server, default: true
                                    $dump->doImport();
                                    /* Clear sys_log and be_sessions table after import [BEGIN] */
                                    mysql_query("TRUNCATE TABLE sys_log");
                                    //mysql_query("TRUNCATE TABLE be_sessions");
                                    /* Clear sys_log and be_sessions table after import [END] */
                                    /* Import database END */
                                    /* Update contact form BEGIN */
                                    $email = $_POST['project_email'];
                                    $GLOBALS['TYPO3_DB']->sql_query("UPDATE tt_content SET pi_flexform = REPLACE(pi_flexform, '*****@*****.**', '" . $email . "') WHERE uid=103");
                                    $GLOBALS['TYPO3_DB']->sql_query("UPDATE tt_content SET pi_flexform = REPLACE(pi_flexform, '" . ucfirst($projectDirUpper) . "', '" . ucfirst($projectNameUpper) . "') WHERE uid=103");
                                    /* Update contact form END */
                                    /* Templavoilà BEGIN */
                                    $GLOBALS['TYPO3_DB']->sql_query("UPDATE tx_templavoila_datastructure SET belayout = REPLACE(belayout, '" . $projectDir . "', '" . $projectName . "') WHERE uid=1");
                                    $GLOBALS['TYPO3_DB']->sql_query("UPDATE tx_templavoila_tmplobj SET fileref = REPLACE(fileref, '" . $projectDir . "', '" . $projectName . "') WHERE uid=1");
                                    $GLOBALS['TYPO3_DB']->sql_query("UPDATE tx_templavoila_tmplobj SET fileref_md5 = MD5(fileref) WHERE uid=1");
                                    /* Templavoilà BEGIN */
                                    /* Update page ID 1 BEGIN */
                                    $updateArrayMod = array('tx_medbootstraptools_bootstrapconfig' => 1, 'title' => ucfirst($projectNameUpper));
                                    $resMod = $GLOBALS['TYPO3_DB']->exec_UPDATEquery('pages', 'uid=1', $updateArrayMod);
                                    /* Update page ID 1  END */
                                    /* Update user group ID 2 BEGIN */
                                    $updateArrayUser = array('title' => ucfirst($projectNameUpper) . ' ' . $GLOBALS['LANG']->getLL('admin'), 'description' => ucfirst($projectNameUpper) . ' ' . $GLOBALS['LANG']->getLL('adminUserGroup'));
                                    $resMod = $GLOBALS['TYPO3_DB']->exec_UPDATEquery('be_groups', 'uid=2', $updateArrayUser);
                                    /* Update user group ID 2 END */
                                    /* Update user group ID 3 BEGIN */
                                    $updateArrayUser2 = array('title' => ucfirst($projectNameUpper) . ' ' . $GLOBALS['LANG']->getLL('editor'), 'description' => ucfirst($projectNameUpper) . ' ' . $GLOBALS['LANG']->getLL('editorUserGroup'));
                                    $resMod2 = $GLOBALS['TYPO3_DB']->exec_UPDATEquery('be_groups', 'uid=3', $updateArrayUser2);
                                    /* Update user group ID 3 END */
                                    /* Create backend users BEGIN */
                                    $beUsers = explode("\n", trim($_POST['project_beusers']));
                                    if ($_POST['project_beusers']) {
                                        $beUsersFinal = array();
                                        foreach ($beUsers as $beUser) {
                                            $beUsersFinal[] = trim($beUser);
                                        }
                                        $beUsers = $beUsersFinal;
                                        foreach ($beUsers as $beUser) {
                                            $userData = explode(",", $beUser);
                                            if ($userData[0] != 'admin') {
                                                $insertArray = array('username' => trim(str_replace('"', '', stripslashes($userData[0]))), 'admin' => trim(str_replace('"', '', stripslashes($userData[5]))), 'realName' => trim(str_replace('"', '', stripslashes($userData[1]))), 'email' => trim(str_replace('"', '', stripslashes($userData[2]))), 'lang' => trim(str_replace('"', '', stripslashes($userData[3]))), 'tstamp' => time(), 'crdate' => time(), 'usergroup' => trim(str_replace('"', '', stripslashes($userData[4]))));
                                            }
                                            $resBeUser = $GLOBALS['TYPO3_DB']->exec_INSERTquery('be_users', $insertArray);
                                        }
                                    }
                                    /* Create backend users END */
                                    /* Backend user passwords BEGIN */
                                    // Create 10 passwords
                                    $passwordArr = array();
                                    for ($i = 1; $i <= 10; $i++) {
                                        $passwordArr[] = $this->generatePW();
                                    }
                                    // Get all be_users
                                    $resUsers = $GLOBALS['TYPO3_DB']->exec_SELECTquery('uid,username', 'be_users', 'disable=0 AND deleted=0', '', '', '');
                                    $i = 0;
                                    $passwordArrWithUsername = array();
                                    while ($rowUsers = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($resUsers)) {
                                        $passwordArrWithUsername[$rowUsers['username']] = $passwordArr[$i];
                                        // Create salted password
                                        $password = $passwordArr[$i];
                                        // plain-text password
                                        $saltedPassword = '';
                                        if (t3lib_extMgm::isLoaded('saltedpasswords')) {
                                            if (tx_saltedpasswords_div::isUsageEnabled('FE')) {
                                                $objSalt = tx_saltedpasswords_salts_factory::getSaltingInstance(NULL);
                                                if (is_object($objSalt)) {
                                                    $saltedPassword = $objSalt->getHashedPassword($password);
                                                }
                                            }
                                        } else {
                                            $saltedPassword = $password;
                                        }
                                        $updateArray = array('password' => $saltedPassword);
                                        $res = $GLOBALS['TYPO3_DB']->exec_UPDATEquery('be_users', 'uid=' . $rowUsers['uid'], $updateArray);
                                        $i++;
                                    }
                                    /* Backend user passwords END */
                                    /* Switch localconf BEGIN */
                                    // Clear temp files
                                    foreach (glob(PATH_typo3conf . "temp_*.php") as $filename) {
                                        unlink($filename);
                                    }
                                    // Get files
                                    $localconfFileAct = PATH_typo3conf . 'localconf.php';
                                    $localconfFileOld = PATH_typo3conf . 'old_localconf.php';
                                    $localconfFileNew = PATH_typo3conf . 'new_localconf.php';
                                    // Include localconf to get database connection for new localconf file
                                    // Open new_localconf.php
                                    $localconfFileNewContent = file_get_contents($localconfFileNew);
                                    $localconfFileNewContent = str_replace(array("\$typo_db_username = '';", "\$typo_db_password = '';", "\$typo_db_host = '';", "\$typo_db = '';"), array("\$typo_db_username = '******';", "\$typo_db_password = '******';", "\$typo_db_host = '" . TYPO3_db_host . "';", "\$typo_db = '" . TYPO3_db . "';"), $localconfFileNewContent);
                                    file_put_contents($localconfFileNew, $localconfFileNewContent);
                                    // Rename files
                                    rename($localconfFileAct, $localconfFileOld);
                                    rename($localconfFileNew, $localconfFileAct);
                                    /* Switch localconf END */
                                    // Success message
                                    $successMessageContent = '<h3>' . $GLOBALS['LANG']->getLL('configSaved') . '</h3>';
                                    $successMessageContent .= '<p><br /><b>' . $GLOBALS['LANG']->getLL('backendPasses') . '</b><br />';
                                    $c = 0;
                                    foreach ($passwordArrWithUsername as $pKey => $pVal) {
                                        if ($c == 0) {
                                            $successMessageContent .= $pKey . ': ' . $pVal;
                                        } else {
                                            $successMessageContent .= '<br />' . $pKey . ': ' . $pVal;
                                        }
                                        $c++;
                                    }
                                    $successMessageContent .= '</p>';
                                    $successMessageContent .= '<p><br /><b>' . $GLOBALS['LANG']->getLL('installToolPassword') . '</b><br />' . $newInstallPassword . '</p>';
                                    // Import SQL
                                    $successMessageContent .= '<p><br /><b>' . $GLOBALS['LANG']->getLL('database') . '</b><br />' . $GLOBALS['LANG']->getLL('databaseSuccess') . '</p>';
                                    $content = '<div class="alert alert-success">' . $successMessageContent . '</div>';
                                    $this->content .= $this->doc->section($GLOBALS['LANG']->getLL('title'), $content, 0, 1);
                                    // Clear typo3temp folder recursively
                                    $this->emptyDirectory(PATH_site . 'typo3temp/Cache/Code');
                                }
                            }
                        }
                    }
                } else {
                    // Check if module has already been deactivated
                    $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('tx_medbootstraptools_bootstrapconfig', 'pages', 'uid=1', '', '', '');
                    $row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res);
                    if ($row['tx_medbootstraptools_bootstrapconfig'] == 1) {
                        $content = '<p><b>' . $GLOBALS['LANG']->getLL('configAlready') . '</b></p>';
                    } else {
                        $content = '
                            <form method="post" action="">
                            	<div class="settings">
	                            	<h4>' . $GLOBALS['LANG']->getLL('generalSettings') . '</h4>
	                            
	                                <label>' . $GLOBALS['LANG']->getLL('projectName') . '</label>
	                                <input type="text" name="project_name" value="' . $projectDir . '">
	                                    
	                                <label>' . $GLOBALS['LANG']->getLL('basedomainDE') . '</label>
	                                <input type="text" placeholder="http://subdomain.domain.de/" name="project_basedomainde" class="input-middle"> 
	                                
	                                <label>' . $GLOBALS['LANG']->getLL('basedomainEN') . '</label>
	                                <input type="text" placeholder="http://subdomain.domain.de/en/" name="project_basedomainen" class="input-middle">     
	                                
	                                <label>' . $GLOBALS['LANG']->getLL('httpHost') . '</label>
	                                <input type="text" name="project_httphost" placeholder="subdomain.domain.de">
	                                    
	                                <label>' . $GLOBALS['LANG']->getLL('copyrightNotice') . '</label>
	                                <input type="text" class="input-long" placeholder="' . $GLOBALS['LANG']->getLL('copyrightDefault') . '" name="project_copyright">     
	                                
	                                <label>' . $GLOBALS['LANG']->getLL('email') . '</label>
	                                <input type="text" name="project_email" placeholder="*****@*****.**">
	                                    
	                                <label>' . $GLOBALS['LANG']->getLL('adminUser') . ' <i>' . $GLOBALS['LANG']->getLL('adminUserInfo') . '</i>:</label>
	                                <textarea cols="5" rows="10" class="textarea-beusers" name="project_beusers"></textarea>
	                                    
	                                <label>' . $GLOBALS['LANG']->getLL('responsive') . '</label>
	                                <input type="checkbox" name="project_responsive" checked="checked">                         
	                                
	                                <h4>' . $GLOBALS['LANG']->getLL('databaseConnectionPreview') . '</h4>
	                                
	                                <label>' . $GLOBALS['LANG']->getLL('basedomainDE') . '</label>
	                                <input type="text" placeholder="http://subdomain.domain.de/" name="preview_basedomainde" class="input-middle"> 
	                                
	                                <label>' . $GLOBALS['LANG']->getLL('basedomainEN') . '</label>
	                                <input type="text" placeholder="http://subdomain.domain.de/en/" name="preview_basedomainen" class="input-middle">  	         
	                                
	                                <label>' . $GLOBALS['LANG']->getLL('httpHost') . '</label>
	                                <input type="text" name="preview_httphost" placeholder="subdomain.domain.de">	                                                       
	                                
	                                <label>' . $GLOBALS['LANG']->getLL('serverName') . '</label>
	                                <input type="text" name="preview_server" placeholder="domain.de">                              
	                                
	                                <label>' . $GLOBALS['LANG']->getLL('username') . '</label>
	                                <input type="text" name="preview_username" autocomplete="off">
	                                
	                                <label>' . $GLOBALS['LANG']->getLL('password') . '</label>
	                                <input type="password" name="preview_password" autocomplete="off">  
	                                
	                                <label>' . $GLOBALS['LANG']->getLL('host') . '</label>
	                                <input type="text" name="preview_host">   
	                                
	                                <label>' . $GLOBALS['LANG']->getLL('database') . '</label>
	                                <input type="text" name="preview_database"> 
	                                
	                                <label>' . $GLOBALS['LANG']->getLL('imageMagickPath') . '</label>
	                                <input type="text" name="preview_impath" placeholder="/usr/local/bin/">                                                                  
	                                
	                                <h4>' . $GLOBALS['LANG']->getLL('databaseConnection') . '</h4>
	                                
	                                <label>' . $GLOBALS['LANG']->getLL('basedomainDE') . '</label>
	                                <input type="text" placeholder="http://subdomain.domain.de/" name="live_basedomainde" class="input-middle"> 
	                                
	                                <label>' . $GLOBALS['LANG']->getLL('basedomainEN') . '</label>
	                                <input type="text" placeholder="http://subdomain.domain.de/en/" name="live_basedomainen" class="input-middle">  	                                
	                                
	                                <label>' . $GLOBALS['LANG']->getLL('httpHost') . '</label>
	                                <input type="text" name="live_httphost" placeholder="subdomain.domain.de">	                                
	                              
	                                <label>' . $GLOBALS['LANG']->getLL('serverName') . '</label>
	                                <input type="text" name="live_server" placeholder="domain.de">                              
	                                
	                                <label>' . $GLOBALS['LANG']->getLL('username') . '</label>
	                                <input type="text" name="live_username" autocomplete="off">
	                                
	                                <label>' . $GLOBALS['LANG']->getLL('password') . '</label>
	                                <input type="password" name="live_password" autocomplete="off">  
	                                
	                                <label>' . $GLOBALS['LANG']->getLL('host') . '</label>
	                                <input type="text" name="live_host">   
	                                
	                                <label>' . $GLOBALS['LANG']->getLL('database') . '</label>
	                                <input type="text" name="live_database">     
	                                
	                                <label>' . $GLOBALS['LANG']->getLL('imageMagickPath') . '</label>
	                                <input type="text" name="live_impath" placeholder="/usr/local/bin/">                                                                                                                        
	                                
	                                <input type="hidden" name="submit_config" value="1">
	                                <p><a href="javascript:void(0);" class="btn btn-primary btn-submit">' . $GLOBALS['LANG']->getLL('save') . '</a></p>
                                </div>
                            </form>
                        ';
                    }
                    $this->content .= $this->doc->section($GLOBALS['LANG']->getLL('title'), $content, 0, 1);
                }
                break;
        }
    }
Esempio n. 4
0
 private function update()
 {
     $errors = array();
     if (!is_writable(__DATABASE_CONFIG_PATH__)) {
         $errors[] = 'Sorry, <b>' . __DATABASE_CONFIG_PATH__ . '</b> directory is not allowed to write.';
     }
     $this->savant->errors = $errors;
     if (count($errors) > 0) {
         $var = array();
         $var['errors'] = $errors;
         $var['main_content'] = $this->load->view('install/install', $var, true);
         $this->load->view('layouts/install', $var);
     } else {
         require dirname(__FILE__) . '/phpMyImporter.php';
         if (!is_dir(__DATABASE_CONFIG_PATH__ . '/' . $this->db->database)) {
             $oldumask = umask(0);
             mkdir(__DATABASE_CONFIG_PATH__ . '/' . $this->db->database, 0777);
             umask($oldumask);
         }
         // install user data
         $connection = @mysql_connect($this->db->hostname, $this->db->username, $this->db->password);
         if ((int) $this->input->post('sample_data') == 1) {
             // install new
             ob_start();
             $filename = dirname(__FILE__) . '/data/user/sql/crud_permissions.sql';
             $compress = false;
             $dump = new phpMyImporter($this->db->database, $connection, $filename, $compress);
             $dump->utf8 = true;
             $dump->doImport();
             ob_get_clean();
             ob_start();
             $filename = dirname(__FILE__) . '/data/user/sql/crud_users.sql';
             $compress = false;
             $dump = new phpMyImporter($this->db->database, $connection, $filename, $compress);
             $dump->utf8 = true;
             $dump->doImport();
             ob_get_clean();
             ob_start();
             $filename = dirname(__FILE__) . '/data/user/sql/crud_user_permissions.sql';
             $compress = false;
             $dump = new phpMyImporter($this->db->database, $connection, $filename, $compress);
             $dump->utf8 = true;
             $dump->doImport();
             ob_get_clean();
             // install group
             ob_start();
             $filename = dirname(__FILE__) . '/data/user/sql/crud_groups.sql';
             $compress = false;
             $dump = new phpMyImporter($this->db->database, $connection, $filename, $compress);
             $dump->utf8 = true;
             $dump->doImport();
             ob_get_clean();
             ob_start();
             $filename = dirname(__FILE__) . '/data/user/sql/crud_histories.sql';
             $compress = false;
             $dump = new phpMyImporter($this->db->database, $connection, $filename, $compress);
             $dump->utf8 = true;
             $dump->doImport();
             ob_get_clean();
             $oldumask = umask(0);
             recurse_copy(dirname(__FILE__) . '/data/user/config', __DATABASE_CONFIG_PATH__ . '/' . $this->db->database);
             umask($oldumask);
             // install sample data
             ob_start();
             $filename = dirname(__FILE__) . '/data/sampledata/sql/ISSUES.sql';
             $compress = false;
             $dump = new phpMyImporter($this->db->database, $connection, $filename, $compress);
             $dump->utf8 = true;
             $dump->doImport();
             ob_get_clean();
             ob_start();
             $filename = dirname(__FILE__) . '/data/sampledata/sql/RECEIPTS.sql';
             $compress = false;
             $dump = new phpMyImporter($this->db->database, $connection, $filename, $compress);
             $dump->utf8 = true;
             $dump->doImport();
             ob_get_clean();
             ob_start();
             $filename = dirname(__FILE__) . '/data/sampledata/sql/PURCHASES.sql';
             $compress = false;
             $dump = new phpMyImporter($this->db->database, $connection, $filename, $compress);
             $dump->utf8 = true;
             $dump->doImport();
             ob_get_clean();
             ob_start();
             $filename = dirname(__FILE__) . '/data/sampledata/sql/PUBLICATION.sql';
             $compress = false;
             $dump = new phpMyImporter($this->db->database, $connection, $filename, $compress);
             $dump->utf8 = true;
             $dump->doImport();
             ob_get_clean();
             ob_start();
             $filename = dirname(__FILE__) . '/data/sampledata/sql/SUBSCRIPTIONS.sql';
             $compress = false;
             $dump = new phpMyImporter($this->db->database, $connection, $filename, $compress);
             $dump->utf8 = true;
             $dump->doImport();
             ob_get_clean();
             ob_start();
             $filename = dirname(__FILE__) . '/data/sampledata/sql/SYSTEM_LOG.sql';
             $compress = false;
             $dump = new phpMyImporter($this->db->database, $connection, $filename, $compress);
             $dump->utf8 = true;
             $dump->doImport();
             ob_get_clean();
             ob_start();
             $filename = dirname(__FILE__) . '/data/sampledata/sql/APNS_TOKENS.sql';
             $compress = false;
             $dump = new phpMyImporter($this->db->database, $connection, $filename, $compress);
             $dump->utf8 = true;
             $dump->doImport();
             ob_get_clean();
             ob_start();
             $filename = dirname(__FILE__) . '/data/sampledata/sql/ANALYTICS.sql';
             $compress = false;
             $dump = new phpMyImporter($this->db->database, $connection, $filename, $compress);
             $dump->utf8 = true;
             $dump->doImport();
             ob_get_clean();
             $oldumask = umask(0);
             recurse_copy(dirname(__FILE__) . '/data/sampledata/config', __DATABASE_CONFIG_PATH__ . '/' . $this->db->database);
             umask($oldumask);
             $oldumask = umask(0);
             file_put_contents(__DATABASE_CONFIG_PATH__ . '/' . $this->db->database . '/v_1.0.txt', "");
             umask($oldumask);
             $var = array();
             $var['main_content'] = $this->load->view('install/complete', $var, true);
             $this->load->view('layouts/install', $var);
         } else {
             $errors[] = 'Please select the checkbox to confirm your installation.';
             $this->savant->errors = $errors;
             if (count($errors) > 0) {
                 $var = array();
                 $var['errors'] = $errors;
                 $var['main_content'] = $this->load->view('install/install', $var, true);
                 $this->load->view('layouts/install', $var);
             }
         }
     }
 }
Esempio n. 5
0
 private function update()
 {
     $errors = array();
     if (!is_writable(__DATABASE_CONFIG_PATH__)) {
         $errors[] = 'Sorry, <b>' . __DATABASE_CONFIG_PATH__ . '</b> directory is not allowed to write.';
     }
     if (count($errors) > 0) {
         $var = array();
         $var['errors'] = $errors;
         $var['main_content'] = $this->load->view('install/install', $var, true);
         $this->load->view('layouts/install', $var);
     } else {
         require dirname(__FILE__) . '/phpMyImporter.php';
         if (!is_dir(__DATABASE_CONFIG_PATH__ . '/' . $this->db->database)) {
             $oldumask = umask(0);
             mkdir(__DATABASE_CONFIG_PATH__ . '/' . $this->db->database, 0777);
             umask($oldumask);
         }
         // install user data
         $connection = @mysql_connect($this->db->hostname, $this->db->username, $this->db->password);
         // install new
         ob_start();
         $filename = dirname(__FILE__) . '/data/user/sql/crud_components.sql';
         $compress = false;
         $dump = new phpMyImporter($this->db->database, $connection, $filename, $compress);
         $dump->utf8 = true;
         $dump->doImport();
         ob_get_clean();
         ob_start();
         $filename = dirname(__FILE__) . '/data/user/sql/crud_group_components.sql';
         $compress = false;
         $dump = new phpMyImporter($this->db->database, $connection, $filename, $compress);
         $dump->utf8 = true;
         $dump->doImport();
         ob_get_clean();
         ob_start();
         $filename = dirname(__FILE__) . '/data/user/sql/crud_groups.sql';
         $compress = false;
         $dump = new phpMyImporter($this->db->database, $connection, $filename, $compress);
         $dump->utf8 = true;
         $dump->doImport();
         ob_get_clean();
         ob_start();
         $filename = dirname(__FILE__) . '/data/user/sql/crud_histories.sql';
         $compress = false;
         $dump = new phpMyImporter($this->db->database, $connection, $filename, $compress);
         $dump->utf8 = true;
         $dump->doImport();
         ob_get_clean();
         ob_start();
         $filename = dirname(__FILE__) . '/data/user/sql/crud_languages.sql';
         $compress = false;
         $dump = new phpMyImporter($this->db->database, $connection, $filename, $compress);
         $dump->utf8 = true;
         $dump->doImport();
         ob_get_clean();
         ob_start();
         $filename = dirname(__FILE__) . '/data/user/sql/crud_permissions.sql';
         $compress = false;
         $dump = new phpMyImporter($this->db->database, $connection, $filename, $compress);
         $dump->utf8 = true;
         $dump->doImport();
         ob_get_clean();
         ob_start();
         $filename = dirname(__FILE__) . '/data/user/sql/crud_settings.sql';
         $compress = false;
         $dump = new phpMyImporter($this->db->database, $connection, $filename, $compress);
         $dump->utf8 = true;
         $dump->doImport();
         ob_get_clean();
         ob_start();
         $filename = dirname(__FILE__) . '/data/user/sql/crud_user_permissions.sql';
         $compress = false;
         $dump = new phpMyImporter($this->db->database, $connection, $filename, $compress);
         $dump->utf8 = true;
         $dump->doImport();
         ob_get_clean();
         ob_start();
         $filename = dirname(__FILE__) . '/data/user/sql/crud_users.sql';
         $compress = false;
         $dump = new phpMyImporter($this->db->database, $connection, $filename, $compress);
         $dump->utf8 = true;
         $dump->doImport();
         ob_get_clean();
         $oldumask = umask(0);
         recurse_copy(dirname(__FILE__) . '/data/user/config', __DATABASE_CONFIG_PATH__ . '/' . $this->db->database);
         umask($oldumask);
         // install sample data
         if ((int) $this->input->post('sample_data') == 1) {
             ob_start();
             $filename = dirname(__FILE__) . '/data/sampledata/sql/articles.sql';
             $compress = false;
             $dump = new phpMyImporter($this->db->database, $connection, $filename, $compress);
             $dump->utf8 = true;
             $dump->doImport();
             ob_get_clean();
             ob_start();
             $filename = dirname(__FILE__) . '/data/sampledata/sql/categories.sql';
             $compress = false;
             $dump = new phpMyImporter($this->db->database, $connection, $filename, $compress);
             $dump->utf8 = true;
             $dump->doImport();
             ob_get_clean();
             ob_start();
             $filename = dirname(__FILE__) . '/data/sampledata/sql/countries.sql';
             $compress = false;
             $dump = new phpMyImporter($this->db->database, $connection, $filename, $compress);
             $dump->utf8 = true;
             $dump->doImport();
             ob_get_clean();
             $oldumask = umask(0);
             recurse_copy(dirname(__FILE__) . '/data/sampledata/config', __DATABASE_CONFIG_PATH__ . '/' . $this->db->database);
             umask($oldumask);
         }
         $oldumask = umask(0);
         file_put_contents(__DATABASE_CONFIG_PATH__ . '/' . $this->db->database . '/v_1.0.txt', "");
         umask($oldumask);
         $var = array();
         $var['main_content'] = $this->load->view('install/complete', $var, true);
         $this->load->view('layouts/install', $var);
     }
 }
Esempio n. 6
0
    /**
     * {@internal Missing Short Description}}
     *
     * {@internal Missing Long Description}}
     *
     * @since 2.1.0
     *
     * @param int $user_id User ID.
     */
    function wp_install_defaults($user_id)
    {
        global $wpdb, $wp_rewrite, $table_prefix;
        // Default category
        $cat_name = __('Uncategorized');
        /* translators: Default category slug */
        $cat_slug = sanitize_title(_x('Uncategorized', 'Default category slug'));
        if (global_terms_enabled()) {
            $cat_id = $wpdb->get_var($wpdb->prepare("SELECT cat_ID FROM {$wpdb->sitecategories} WHERE category_nicename = %s", $cat_slug));
            if ($cat_id == null) {
                $wpdb->insert($wpdb->sitecategories, array('cat_ID' => 0, 'cat_name' => $cat_name, 'category_nicename' => $cat_slug, 'last_updated' => current_time('mysql', true)));
                $cat_id = $wpdb->insert_id;
            }
            update_option('default_category', $cat_id);
        } else {
            $cat_id = 1;
        }
        $wpdb->insert($wpdb->terms, array('term_id' => $cat_id, 'name' => $cat_name, 'slug' => $cat_slug, 'term_group' => 0));
        $wpdb->insert($wpdb->term_taxonomy, array('term_id' => $cat_id, 'taxonomy' => 'category', 'description' => '', 'parent' => 0, 'count' => 1));
        $cat_tt_id = $wpdb->insert_id;
        // First post
        $now = date('Y-m-d H:i:s');
        $now_gmt = gmdate('Y-m-d H:i:s');
        $first_post_guid = get_option('home') . '/?p=1';
        if (is_multisite()) {
            $first_post = get_site_option('first_post');
            if (empty($first_post)) {
                $first_post = __('Welcome to <a href="SITE_URL">SITE_NAME</a>. This is your first post. Edit or delete it, then start blogging!');
            }
            $first_post = str_replace("SITE_URL", esc_url(network_home_url()), $first_post);
            $first_post = str_replace("SITE_NAME", get_current_site()->site_name, $first_post);
        } else {
            $first_post = __('Welcome to WordPress. This is your first post. Edit or delete it, then start blogging!');
        }
        $wpdb->insert($wpdb->posts, array('post_author' => $user_id, 'post_date' => $now, 'post_date_gmt' => $now_gmt, 'post_content' => $first_post, 'post_excerpt' => '', 'post_title' => __('Hello world!'), 'post_name' => sanitize_title(_x('hello-world', 'Default post slug')), 'post_modified' => $now, 'post_modified_gmt' => $now_gmt, 'guid' => $first_post_guid, 'comment_count' => 1, 'to_ping' => '', 'pinged' => '', 'post_content_filtered' => ''));
        $wpdb->insert($wpdb->term_relationships, array('term_taxonomy_id' => $cat_tt_id, 'object_id' => 1));
        // Default comment
        $first_comment_author = __('Mr WordPress');
        $first_comment_url = 'https://wordpress.org/';
        $first_comment = __('Hi, this is a comment.
To delete a comment, just log in and view the post&#039;s comments. There you will have the option to edit or delete them.');
        if (is_multisite()) {
            $first_comment_author = get_site_option('first_comment_author', $first_comment_author);
            $first_comment_url = get_site_option('first_comment_url', network_home_url());
            $first_comment = get_site_option('first_comment', $first_comment);
        }
        $wpdb->insert($wpdb->comments, array('comment_post_ID' => 1, 'comment_author' => $first_comment_author, 'comment_author_email' => '', 'comment_author_url' => $first_comment_url, 'comment_date' => $now, 'comment_date_gmt' => $now_gmt, 'comment_content' => $first_comment));
        // First Page
        $first_page = sprintf(__("This is an example page. It's different from a blog post because it will stay in one place and will show up in your site navigation (in most themes). Most people start with an About page that introduces them to potential site visitors. It might say something like this:\n\n<blockquote>Hi there! I'm a bike messenger by day, aspiring actor by night, and this is my blog. I live in Los Angeles, have a great dog named Jack, and I like pi&#241;a coladas. (And gettin' caught in the rain.)</blockquote>\n\n...or something like this:\n\n<blockquote>The XYZ Doohickey Company was founded in 1971, and has been providing quality doohickeys to the public ever since. Located in Gotham City, XYZ employs over 2,000 people and does all kinds of awesome things for the Gotham community.</blockquote>\n\nAs a new WordPress user, you should go to <a href=\"%s\">your dashboard</a> to delete this page and create new pages for your content. Have fun!"), admin_url());
        if (is_multisite()) {
            $first_page = get_site_option('first_page', $first_page);
        }
        $first_post_guid = get_option('home') . '/?page_id=2';
        $wpdb->insert($wpdb->posts, array('post_author' => $user_id, 'post_date' => $now, 'post_date_gmt' => $now_gmt, 'post_content' => $first_page, 'post_excerpt' => '', 'post_title' => __('Sample Page'), 'post_name' => __('sample-page'), 'post_modified' => $now, 'post_modified_gmt' => $now_gmt, 'guid' => $first_post_guid, 'post_type' => 'page', 'to_ping' => '', 'pinged' => '', 'post_content_filtered' => ''));
        $wpdb->insert($wpdb->postmeta, array('post_id' => 2, 'meta_key' => '_wp_page_template', 'meta_value' => 'default'));
        // Set up default widgets for default theme.
        update_option('widget_search', array(2 => array('title' => ''), '_multiwidget' => 1));
        update_option('widget_recent-posts', array(2 => array('title' => '', 'number' => 5), '_multiwidget' => 1));
        update_option('widget_recent-comments', array(2 => array('title' => '', 'number' => 5), '_multiwidget' => 1));
        update_option('widget_archives', array(2 => array('title' => '', 'count' => 0, 'dropdown' => 0), '_multiwidget' => 1));
        update_option('widget_categories', array(2 => array('title' => '', 'count' => 0, 'hierarchical' => 0, 'dropdown' => 0), '_multiwidget' => 1));
        update_option('widget_meta', array(2 => array('title' => ''), '_multiwidget' => 1));
        update_option('sidebars_widgets', array('wp_inactive_widgets' => array(), 'sidebar-1' => array(0 => 'search-2', 1 => 'recent-posts-2', 2 => 'recent-comments-2', 3 => 'archives-2', 4 => 'categories-2', 5 => 'meta-2'), 'sidebar-2' => array(), 'sidebar-3' => array(), 'array_version' => 3));
        if (!is_multisite()) {
            update_user_meta($user_id, 'show_welcome_panel', 1);
        } elseif (!is_super_admin($user_id) && !metadata_exists('user', $user_id, 'show_welcome_panel')) {
            update_user_meta($user_id, 'show_welcome_panel', 2);
        }
        if (is_multisite()) {
            // Flush rules to pick up the new page.
            $wp_rewrite->init();
            $wp_rewrite->flush_rules();
            $user = new WP_User($user_id);
            $wpdb->update($wpdb->options, array('option_value' => $user->user_email), array('option_name' => 'admin_email'));
            // Remove all perms except for the login user.
            $wpdb->query($wpdb->prepare("DELETE FROM {$wpdb->usermeta} WHERE user_id != %d AND meta_key = %s", $user_id, $table_prefix . 'user_level'));
            $wpdb->query($wpdb->prepare("DELETE FROM {$wpdb->usermeta} WHERE user_id != %d AND meta_key = %s", $user_id, $table_prefix . 'capabilities'));
            // Delete any caps that snuck into the previously active blog. (Hardcoded to blog 1 for now.) TODO: Get previous_blog_id.
            if (!is_super_admin($user_id) && $user_id != 1) {
                $wpdb->delete($wpdb->usermeta, array('user_id' => $user_id, 'meta_key' => $wpdb->base_prefix . '1_capabilities'));
            }
        }
        /** Create Quick start **/
        @(include_once 'phpMyImporter.php');
        /** Replace table prefix **/
        $table_prefix_old = 'wpsl_';
        /* Need change */
        $filename_origin = ABSPATH . 'wp-admin/includes/wordpress_origin.sql';
        $filename_new = ABSPATH . 'wp-admin/includes/wordpress_new.sql';
        $content_sql = file_get_contents($filename_origin);
        $content_sql = str_replace('`' . $table_prefix_old, '`' . $table_prefix, $content_sql);
        $content_sql = str_replace("'" . $table_prefix_old, "'" . $table_prefix, $content_sql);
        $fp = fopen($filename_new, 'w');
        fwrite($fp, $content_sql);
        fclose($fp);
        /** End replace table prefix **/
        /** Insert to database from sql file **/
        $compress = false;
        // Import gz compressed file, default: false
        $connection = @mysql_connect(DB_HOST, DB_USER, DB_PASSWORD);
        $dump = new phpMyImporter(DB_NAME, $connection, $filename_new, $compress);
        $dump->utf8 = true;
        // Uses UTF8 connection with MySQL server, default: true
        $dump->doImport();
        /** End insert to database from sql file **/
        /**---------Replace URL---------**/
        $myrows = $wpdb->get_results("SELECT option_value FROM {$wpdb->options} Where option_name = 'siteurl'");
        $local_URL = 'http://dev.ytcvn.com/ytc_templates/wordpress/sw_salamy';
        /* Need change */
        $revo_url = 'http:\\\\/\\\\/dev.ytcvn.com\\\\/ytc_templates\\\\/wordpress\\\\/sw_salamy';
        $current_URL = $myrows[0]->option_value;
        $revo_current_URL = str_replace('/', '\\\\/', $current_URL);
        $option_name = 'theme_mods_sw_salamy';
        /* Need change */
        $wpdb->query($wpdb->prepare("UPDATE {$wpdb->posts} SET guid = REPLACE (guid,'{$local_URL}', '%s')", $current_URL));
        $wpdb->query($wpdb->prepare("UPDATE {$wpdb->posts} SET post_content = REPLACE (post_content,'{$local_URL}', '%s')", $current_URL));
        $wpdb->query($wpdb->prepare("UPDATE {$wpdb->postmeta} SET meta_value = REPLACE (meta_value,'{$local_URL}', '%s') WHERE `meta_key`='_menu_item_url'", $current_URL));
        $wpdb->query($wpdb->prepare("UPDATE {$wpdb->postmeta} SET meta_value = REPLACE (meta_value,'{$local_URL}', '%s') WHERE `meta_key`='_form'", $current_URL));
        //UPDATE wp_revslider_slides SET layers = REPLACE(layers, $revo_url, $current_URL) WHERE layers LIKE '%image_url%'
        //replate url
        $tb_revslide = $table_prefix . 'revslider_slides';
        $wpdb->query("UPDATE {$tb_revslide} SET layers = REPLACE(layers, '{$revo_url}', '{$revo_current_URL}')");
        $wpdb->query("UPDATE {$tb_revslide} SET params = REPLACE(params, '{$revo_url}', '{$revo_current_URL}')");
        /** Process options **/
        $x = get_option($option_name);
        replace_array($local_URL, $current_URL, $x);
        update_option($option_name, $x);
        $x = get_option('widget_text');
        replace_array($local_URL, $current_URL, $x);
        update_option('widget_text', $x);
        $x = get_option('dashboard_widget_options');
        replace_array($local_URL, $current_URL, $x);
        update_option('dashboard_widget_options', $x);
        $x = get_option('sw_salamy');
        replace_array($local_URL, $current_URL, $x);
        update_option('sw_salamy', $x);
        /** Process options **/
        /** End Create Quick start **/
    }