| | |
| | | $this->dataRecord = $params; |
| | | $app->sites_database_plugin->processDatabaseInsert($this); |
| | | |
| | | return $this->insertQueryExecute($sql, $params); |
| | | $retval = $this->insertQueryExecute($sql, $params); |
| | | |
| | | // set correct values for backup_interval and backup_copies |
| | | if(isset($params['backup_interval']) || isset($params['backup_copies'])){ |
| | | $sql_set = array(); |
| | | if(isset($params['backup_interval'])) $sql_set[] = "backup_interval = '".$app->db->quote($params['backup_interval'])."'"; |
| | | if(isset($params['backup_copies'])) $sql_set[] = "backup_copies = ".$app->functions->intval($params['backup_copies']); |
| | | //$app->db->query("UPDATE web_database SET ".implode(', ', $sql_set)." WHERE database_id = ".$retval); |
| | | $this->updateQueryExecute("UPDATE web_database SET ".implode(', ', $sql_set)." WHERE database_id = ".$retval, $retval, $params); |
| | | } |
| | | |
| | | return $retval; |
| | | } |
| | | |
| | | return false; |
| | |
| | | $this->id = $primary_id; |
| | | $this->dataRecord = $params; |
| | | $app->sites_database_plugin->processDatabaseUpdate($this); |
| | | return $this->updateQueryExecute($sql, $primary_id, $params); |
| | | $retval = $this->updateQueryExecute($sql, $primary_id, $params); |
| | | |
| | | // set correct values for backup_interval and backup_copies |
| | | if(isset($params['backup_interval']) || isset($params['backup_copies'])){ |
| | | $sql_set = array(); |
| | | if(isset($params['backup_interval'])) $sql_set[] = "backup_interval = '".$app->db->quote($params['backup_interval'])."'"; |
| | | if(isset($params['backup_copies'])) $sql_set[] = "backup_copies = ".$app->functions->intval($params['backup_copies']); |
| | | //$app->db->query("UPDATE web_database SET ".implode(', ', $sql_set)." WHERE database_id = ".$primary_id); |
| | | $this->updateQueryExecute("UPDATE web_database SET ".implode(', ', $sql_set)." WHERE database_id = ".$primary_id, $primary_id, $params); |
| | | } |
| | | |
| | | return $retval; |
| | | } |
| | | |
| | | return false; |
| | |
| | | return false; |
| | | } |
| | | $affected_rows = $this->deleteQuery('../sites/form/web_domain.tform.php', $primary_id); |
| | | return $affected_rows; |
| | | } |
| | | |
| | | // ---------------------------------------------------------------------------------------------------------- |
| | | |
| | | //* Get record details |
| | | public function sites_web_vhost_aliasdomain_get($session_id, $primary_id) |
| | | { |
| | | global $app; |
| | | |
| | | if(!$this->checkPerm($session_id, 'sites_web_aliasdomain_get')) { |
| | | throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.'); |
| | | return false; |
| | | } |
| | | $app->uses('remoting_lib'); |
| | | $app->remoting_lib->loadFormDef('../sites/form/web_vhost_aliasdomain.tform.php'); |
| | | return $app->remoting_lib->getDataRecord($primary_id); |
| | | } |
| | | |
| | | //* Add a record |
| | | public function sites_web_vhost_aliasdomain_add($session_id, $client_id, $params) |
| | | { |
| | | global $app; |
| | | if(!$this->checkPerm($session_id, 'sites_web_aliasdomain_add')) { |
| | | throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.'); |
| | | return false; |
| | | } |
| | | |
| | | //* Set a few params to "not empty" values which get overwritten by the sites_web_domain_plugin |
| | | if($params['document_root'] == '') $params['document_root'] = '-'; |
| | | if($params['system_user'] == '') $params['system_user'] = '-'; |
| | | if($params['system_group'] == '') $params['system_group'] = '-'; |
| | | |
| | | //* Set a few defaults for nginx servers |
| | | if($params['pm_max_children'] == '') $params['pm_max_children'] = 1; |
| | | if($params['pm_start_servers'] == '') $params['pm_start_servers'] = 1; |
| | | if($params['pm_min_spare_servers'] == '') $params['pm_min_spare_servers'] = 1; |
| | | if($params['pm_max_spare_servers'] == '') $params['pm_max_spare_servers'] = 1; |
| | | |
| | | $domain_id = $this->insertQuery('../sites/form/web_vhost_aliasdomain.tform.php', $client_id, $params, 'sites:web_vhost_aliasdomain:on_after_insert'); |
| | | return $domain_id; |
| | | } |
| | | |
| | | //* Update a record |
| | | public function sites_web_vhost_aliasdomain_update($session_id, $client_id, $primary_id, $params) |
| | | { |
| | | if(!$this->checkPerm($session_id, 'sites_web_aliasdomain_update')) { |
| | | throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.'); |
| | | return false; |
| | | } |
| | | |
| | | //* Set a few defaults for nginx servers |
| | | if($params['pm_max_children'] == '') $params['pm_max_children'] = 1; |
| | | if($params['pm_start_servers'] == '') $params['pm_start_servers'] = 1; |
| | | if($params['pm_min_spare_servers'] == '') $params['pm_min_spare_servers'] = 1; |
| | | if($params['pm_max_spare_servers'] == '') $params['pm_max_spare_servers'] = 1; |
| | | |
| | | $affected_rows = $this->updateQuery('../sites/form/web_vhost_aliasdomain.tform.php', $client_id, $primary_id, $params, 'sites:web_vhost_aliasdomain:on_after_insert'); |
| | | return $affected_rows; |
| | | } |
| | | |
| | | //* Delete a record |
| | | public function sites_web_vhost_aliasdomain_delete($session_id, $primary_id) |
| | | { |
| | | if(!$this->checkPerm($session_id, 'sites_web_aliasdomain_delete')) { |
| | | throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.'); |
| | | return false; |
| | | } |
| | | $affected_rows = $this->deleteQuery('../sites/form/web_vhost_aliasdomain.tform.php', $primary_id); |
| | | return $affected_rows; |
| | | } |
| | | |
| | |
| | | $all = $app->db->queryAllRecords($sql); |
| | | return $all; |
| | | } |
| | | |
| | | |
| | | //** backup functions ----------------------------------------------------------------------------------- |
| | | public function sites_web_domain_backup_list($session_id, $site_id = null) |
| | | { |
| | | global $app; |
| | | |
| | | if(!$this->checkPerm($session_id, 'sites_web_domain_backup')) { |
| | | $this->server->fault('permission_denied', 'You do not have the permissions to access this function.'); |
| | | return false; |
| | | } |
| | | |
| | | $result = $app->db->queryAllRecords("SELECT * FROM web_backup".(($site_id != null)?' WHERE parent_domain_id = ?':''), $app->functions->intval($site_id)); |
| | | return $result; |
| | | } |
| | | |
| | | //* Backup download and restoration by Abdi Joseph |
| | | public function sites_web_domain_backup($session_id, $primary_id, $action_type) |
| | | { |
| | | global $app; |
| | | |
| | | if(!$this->checkPerm($session_id, 'sites_web_domain_backup')) { |
| | | $this->server->fault('permission_denied', 'You do not have the permissions to access this function.'); |
| | | return false; |
| | | } |
| | | |
| | | //*Set variables |
| | | $backup_record = $app->db->queryOneRecord("SELECT * FROM `web_backup` WHERE `backup_id`= ?", $primary_id); |
| | | $server_id = $backup_record['server_id']; |
| | | |
| | | //*Set default action state |
| | | $action_state = "pending"; |
| | | $tstamp = time(); |
| | | |
| | | //* Basic validation of variables |
| | | if ($server_id <= 0) { |
| | | $this->server->fault('invalid_backup_id', "Invalid or non existant backup_id $primary_id"); |
| | | return false; |
| | | } |
| | | |
| | | if ($action_type != 'backup_download' and $action_type != 'backup_restore') { |
| | | $this->server->fault('invalid_action', "Invalid action_type $action_type"); |
| | | return false; |
| | | } |
| | | |
| | | //* Validate instance |
| | | $instance_record = $app->db->queryOneRecord("SELECT * FROM `sys_remoteaction` WHERE `action_param`= ? and `action_type`= ? and `action_state`= ?", $primary_id, $action_type, 'pending'); |
| | | if ($instance_record['action_id'] >= 1) { |
| | | $this->server->fault('duplicate_action', "There is already a pending $action_type action"); |
| | | return false; |
| | | } |
| | | |
| | | //* Save the record |
| | | if ($app->db->query("INSERT INTO `sys_remoteaction` SET `server_id` = ?, `tstamp` = ?, `action_type` = ?, `action_param` = ?, `action_state` = ?", $server_id, $tstamp, $action_type, $primary_id, $action_state)) { |
| | | return true; |
| | | } else { |
| | | return false; |
| | | } |
| | | } |
| | | |
| | | //** quota functions ----------------------------------------------------------------------------------- |
| | | public function quota_get_by_user($session_id, $client_id) |
| | | { |
| | | global $app; |
| | | $app->uses('quota_lib'); |
| | | |
| | | if(!$this->checkPerm($session_id, 'quota_get_by_user')) { |
| | | $this->server->fault('permission_denied', 'You do not have the permissions to access this function.'); |
| | | return false; |
| | | } |
| | | |
| | | return $app->quota_lib->get_quota_data($client_id, false); |
| | | } |
| | | |
| | | |
| | | } |
| | | |
| | | ?> |