예제 #1
0
 /**
  * Create installation script.
  */
 public function showInstallScript()
 {
     $classes = array('Curry_Install', 'Curry_String', 'Curry_Util', 'Curry_Archive_FileInfo', 'Curry_Archive_Reader', 'Curry_Archive_Iterator', 'Curry_Archive');
     $contents = "<?php\n\n// CurryCMS v" . Curry_Core::VERSION . " Installation Script\n// Created on " . strftime('%Y-%m-%d %H:%M:%S') . "\n";
     $contents .= str_repeat('/', 60) . "\n\n";
     $contents .= "ini_set('error_reporting', E_ALL & ~E_NOTICE);\n";
     $contents .= "ini_set('display_errors', 1);\n";
     $contents .= "umask(0002);\n\n";
     $autoloader = Curry_Core::getAutoloader();
     foreach ($classes as $clazz) {
         $file = $autoloader->findFile($clazz);
         $contents .= "// {$clazz} ({$file})\n";
         $contents .= str_repeat('/', 60) . "\n\n";
         $contents .= preg_replace('/^<\\?php\\s+/', '', file_get_contents($file)) . "\n\n";
     }
     $contents .= "//////////////////////////////////////////////////////////\n\n";
     $contents .= 'Curry_Install::show(isset($_GET[\'step\']) ? $_GET[\'step\'] : \'\');';
     $contents = str_replace("{{INSTALL_CSS}}", file_get_contents(Curry_Core::$config->curry->basePath . '/shared/backend/common/css/install.css'), $contents);
     Curry_Application::returnData($contents, 'text/plain', 'install.php');
 }
예제 #2
0
 /**
  * Backup database.
  */
 public function showBackup()
 {
     $this->showMainMenu();
     $tables = array();
     $selectedTables = array();
     foreach (Curry_Propel::getModels() as $package => $classes) {
         $selectedTables = array_merge($selectedTables, array_values($classes));
         $tables[$package] = array();
         foreach ($classes as $table) {
             $tables[$package][$table] = $table;
         }
     }
     $form = new Curry_Form(array('action' => url('', array("module", "view", "page_id")), 'method' => 'post', 'elements' => array('tables' => array('multiselect', array('label' => 'Tables', 'multiOptions' => $tables, 'value' => $selectedTables, 'size' => 15)), 'name' => array('text', array('label' => 'Name', 'required' => true, 'value' => 'backup_%Y-%m-%d_%H-%M-%S.txt', 'description' => 'Name of the file, strftime() is used to format the string.')), 'type' => array('radio', array('label' => 'Where do you want to save?', 'multiOptions' => array('online' => 'Save online', 'local' => 'Save to local file'), 'value' => 'online')))));
     $form->addElement('submit', 'Go');
     if (isPost() && ($_POST['tables'] == '*' || $_POST['tables'] == array('*'))) {
         $_POST['tables'] = $selectedTables;
     }
     if (isPost() && $form->isValid($_POST)) {
         $values = $form->getValues();
         if ($values['type'] == 'local') {
             // dump to temp, stream to client
             $fp = fopen("php://temp", 'r+');
             Curry_Backend_DatabaseHelper::dumpDatabase($fp, $values['tables'], $this);
             rewind($fp);
             $name = Curry_String::getRewriteString(Curry_Core::$config->curry->name) . '-db.txt';
             Curry_Application::returnData($fp, 'application/octet-stream', $name);
         } else {
             if ($values['type'] == 'online') {
                 $filename = Curry_Backend_DatabaseHelper::createBackupName($values['name']);
                 $status = Curry_Backend_DatabaseHelper::dumpDatabase($filename, $values['tables'], $this);
                 $this->addMessage('Backup created ' . $filename, $status ? self::MSG_SUCCESS : self::MSG_ERROR);
             }
         }
     }
     $this->addMainContent($form);
 }