Changeset 2570
- Timestamp:
- 01/31/10 23:00:43 (2 years ago)
- Location:
- branches/backup-restore
- Files:
-
- 3 edited
-
includes/BackupPackage_ispCP.php (modified) (1 diff)
-
includes/RestorePackage_ispCP.php (modified) (2 diffs)
-
restore.php (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/backup-restore/includes/BackupPackage_ispCP.php
r2562 r2570 2 2 /** 3 3 * ispCP ω (OMEGA) complete domain backup/restore tool 4 * ispCP backup c lass4 * ispCP backup controller 5 5 * 6 6 * @copyright 2010 Thomas Wacker -
branches/backup-restore/includes/RestorePackage_ispCP.php
r2562 r2570 1 1 <?php 2 2 /** 3 * ispCP ω (OMEGA) complete domain restore handler4 * 3 * ispCP ω (OMEGA) complete domain backup/restore tool 4 * Restore controller 5 5 * 6 6 * @copyright 2010 Thomas Wacker … … 19 19 */ 20 20 21 class RestorePackage_ispCP 21 class RestorePackage_ispCP extends BaseController 22 22 { 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 } 24 119 } -
branches/backup-restore/restore.php
r2562 r2570 30 30 } 31 31 32 $verbose = false;32 $verbose = $specific_ip = false; 33 33 for ($i = 1; $i < $argc-2; $i++) { 34 34 if ($argv[$i] == '-v') { … … 47 47 48 48 $exitcode = 0; 49 $handler = new RestorePackage_ispCP($domain_name, $password );49 $handler = new RestorePackage_ispCP($domain_name, $password, $specific_ip); 50 50 $handler->verbose = $verbose; 51 51 if ($handler->runRestore() == false) {
Note: See TracChangeset
for help on using the changeset viewer.
