コード例 #1
0
ファイル: Mysql.php プロジェクト: dannypenrose/xtbackup
    public static function getConfigOptions($part = null)
    {
        // new options
        $opt = array(CfgPart::DEFAULTS => array('host' => 'localhost', 'port' => '3306', 'user' => 'root', 'password' => '', 'compressdata' => false, 'addtobasedir' => '', 'rotate' => array('days' => 0, 'weeks' => 0, 'months' => 0), 'filter-ext' => false, 'with-passwords' => false, 'server-location' => 'auto', 'no-data' => false), CfgPart::DESCRIPTIONS => array('host' => 'mysql server host name', 'port' => 'mysql server port number', 'user' => 'mysql user name', 'password' => 'mysql user password', 'dbname' => <<<TXT
Database to backup if string or array of databases to backup.
If array it may be string expressing name of db or array overriding default settings.
If it is string starting with / then the text is executed as SQL command and its results are used instead.

Override of following settings is possible: dbname (array key is used if not provided), addtobasedir, compressdata.
Consult examples in examples/mysql folder.',
TXT
, 'dbname.sql' => "SQL select which will replace dbname with multiple values (eg. SELECT schema_name as dbname, false as compressdata FROM `information_schema`.`schemata` WHERE schema_name not in ('mysql', 'information_schema'))", 'addtobasedir' => '', 'compressdata' => 'compress data files on the fly (true=PHP zlib method, gzip=external utility)', 'rotate.days' => 'for how many days should backups be kept', 'rotate.weeks' => 'for how many weeks should backups be kept', 'rotate.months' => 'for how many months should backups be kept', 'filter-ext' => "specify external filter application like 'php -f filter.php -- '", 'with-passwords' => 'if true hash of user passwords will be stored', 'server-location' => 'if server is able to access backup folder (auto=try to detect,local=server able to write to backup folder,remote=slower as local)', 'no-data' => 'if used data from tables will not be included in backup'), CfgPart::REQUIRED => array('dbname'));
        // add old options from Storage_Filesystem
        //Core_Engine::array_merge_configOptions(parent::getConfigOptions(), $opt);
        $optOld = parent::getConfigOptions();
        foreach ($opt as $k => &$o) {
            if (array_key_exists($k, $optOld)) {
                $o = Core_Engine::array_merge_recursive_distinct($optOld[$k], $o);
            }
        }
        foreach ($optOld as $k => $o) {
            if (!array_key_exists($k, $opt)) {
                $opt[$k] = $o;
            }
        }
        if (is_null($part)) {
            return $opt;
        } else {
            return array_key_exists($part, $opt) ? $opt[$part] : array();
        }
    }
コード例 #2
0
ファイル: Cli.php プロジェクト: dannypenrose/xtbackup
 /**
  * Constructor
  *
  * @param array $options configuration options
  */
 public function __construct($options)
 {
     // merge options with default options
     $options = Core_Engine::array_merge_recursive_distinct(static::getConfigOptions(CfgPart::DEFAULTS), $options);
     // remember configuration options
     $this->_options = $options;
     $this->_verbosity = Output_Stack::verbosityToConst($options['verbosity']);
     // make copy for faster access
     if (false === $this->_verbosity) {
         throw new Core_StopException("Value of option verbosity is '{$options['verbosity']}' which is not allowed.", "cliConstruct");
     }
     // make sure that all output is directly sent to console
     ob_implicit_flush();
 }
コード例 #3
0
ファイル: Engine.php プロジェクト: brucewu16899/xtbackup
 /**
  * Load INI file or lines into configuration array
  *
  * @param string|array $fileName INI file name or array of INI file line
  * @param bool $onlyReturn don't merge to $this->_optionsIni if true
  * @return array
  */
 public function loadIni($fileName, $onlyReturn = false)
 {
     if (false !== $this->_options) {
         // if init() already executed
         self::$out->stop("init() already executed, loadIni() is not allowed any more.");
         return array();
     }
     if (is_array($fileName)) {
         // we use parse_ini_string
         $params = @parse_ini_string(implode("\n", $fileName));
     } else {
         // load and parse INI file
         $params = @parse_ini_file($fileName);
     }
     if (false === $params) {
         $le = error_get_last();
         self::$out->stop($le['message']);
     }
     // process keys
     $options = array();
     foreach ($params as $key => $val) {
         $a = explode(".", $key);
         $param = array();
         $b =& $param;
         foreach ($a as $k) {
             $b[$k] = array();
             $b =& $b[$k];
         }
         $b = $val;
         $options = array_merge_recursive($options, $param);
     }
     if (!$onlyReturn) {
         // merge with existing options
         //$this->_optionsIni = array_merge_recursive($this->_optionsIni, $options);
         $this->_optionsIni = Core_Engine::array_merge_recursive_distinct($this->_optionsIni, $options);
     }
     return $options;
 }