Changeset 2570


Ignore:
Timestamp:
01/31/10 23:00:43 (2 years ago)
Author:
tomdooley
Message:

Temporary commit of backup-restore

Location:
branches/backup-restore
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • branches/backup-restore/includes/BackupPackage_ispCP.php

    r2562 r2570  
    22/** 
    33 * ispCP ω (OMEGA) complete domain backup/restore tool 
    4  * ispCP backup class 
     4 * ispCP backup controller 
    55 * 
    66 * @copyright   2010 Thomas Wacker 
  • branches/backup-restore/includes/RestorePackage_ispCP.php

    r2562 r2570  
    11<?php 
    22/** 
    3  * ispCP ω (OMEGA) complete domain restore handler 
    4  * 
     3 * ispCP ω (OMEGA) complete domain backup/restore tool 
     4 * Restore controller 
    55 * 
    66 * @copyright   2010 Thomas Wacker 
     
    1919 */ 
    2020 
    21 class RestorePackage_ispCP 
     21class RestorePackage_ispCP extends BaseController 
    2222{ 
    23         // TODO: RestorePackage_ispCP 
     23        /** 
     24         * Instance of ispCP Database 
     25         */ 
     26        public $db = null; 
     27        /** 
     28         * domain name (string) 
     29         */ 
     30        protected $domain_name; 
     31        /** 
     32         * password for archive 
     33         */ 
     34        protected $password; 
     35        /** 
     36         * IP address or false for default IP address 
     37         */ 
     38        protected $ip; 
     39        /** 
     40         * ID of server_ips 
     41         */ 
     42        protected $ip_id = -1; 
     43        /** 
     44         * linux user id 
     45         */ 
     46        protected $domain_user_id = 0; 
     47 
     48        public function __construct($domain_name, $password, $specific_ip) 
     49        { 
     50                $this->password = $password; 
     51                $this->domain_name = $domain_name; 
     52                $this->db = Database::getInstance(); 
     53                $this->ip = $specific_ip; 
     54        } 
     55 
     56        private function setDomainPermissions() 
     57        { 
     58                // TODO: setDomainPermissions (chown) 
     59        } 
     60 
     61        /** 
     62         * Get ID of first server IP 
     63         * @return integer ID of IP 
     64         */ 
     65        private function getDefaultIP() 
     66        { 
     67                $result = -1; 
     68 
     69                $sql = "SELECT `ip_id` FROM `server_ips` ORDER BY `ip_id` LIMIT 0, 1"; 
     70                $query = $this->db->Prepare($sql); 
     71                $rs = $this->db->Execute($query); 
     72                if ($rs && !$rs->EOF) { 
     73                        $result = $rs->fields['ip_id']; 
     74                } else { 
     75                        $this->addErrorMessage('No IPs found!?'); 
     76                } 
     77 
     78                return $result; 
     79        } 
     80 
     81        /** 
     82         * Get ID of specific IP 
     83         * @param string $ip IP address 
     84         * @return integer ID of IP 
     85         */ 
     86        private function getSpecificIP($ip) 
     87        { 
     88                $result = -1; 
     89 
     90                $sql = "SELECT `ip_id` FROM `server_ips` WHERE `ip_number`=:ip LIMIT 0, 1"; 
     91                $query = $this->db->Prepare($sql); 
     92                $rs = $this->db->Execute($query, array('ip'=>$ip)); 
     93                if ($rs && !$rs->EOF) { 
     94                        $result = $rs->fields['ip_id']; 
     95                } else { 
     96                        $this->addErrorMessage('IP not found!?'); 
     97                } 
     98 
     99                return $result; 
     100        } 
     101 
     102        public function runRestore() 
     103        { 
     104                $result = false; 
     105 
     106                // IP detection 
     107                if ($this->ip === false) { 
     108                        $this->ip_id = $this->getDefaultIP(); 
     109                } else { 
     110                        $this->ip_id = $this->getSpecificIP($this->ip); 
     111                } 
     112 
     113                if ($this->ip_id != -1) { 
     114                        // TODO: got IP ID, go on... 
     115                } 
     116 
     117                return $result; 
     118        } 
    24119} 
  • branches/backup-restore/restore.php

    r2562 r2570  
    3030} 
    3131 
    32 $verbose = false; 
     32$verbose = $specific_ip = false; 
    3333for ($i = 1; $i < $argc-2; $i++) { 
    3434        if ($argv[$i] == '-v') { 
     
    4747 
    4848$exitcode = 0; 
    49 $handler = new RestorePackage_ispCP($domain_name, $password); 
     49$handler = new RestorePackage_ispCP($domain_name, $password, $specific_ip); 
    5050$handler->verbose = $verbose; 
    5151if ($handler->runRestore() == false) { 
Note: See TracChangeset for help on using the changeset viewer.