| | |
| | | |
| | | class page_action extends tform_actions { |
| | | |
| | | // Returna a "3/2/1" path hash from a numeric id '123' |
| | | //* Returna a "3/2/1" path hash from a numeric id '123' |
| | | function id_hash($id,$levels) { |
| | | $hash = "" . $id % 10 ; |
| | | $id /= 10 ; |
| | |
| | | if(!$app->tform->checkResellerLimit('limit_web_domain',"type = 'vhost'")) { |
| | | $app->error('Reseller: '.$app->tform->wordbook["limit_web_domain_txt"]); |
| | | } |
| | | |
| | | // Get the limits of the client |
| | | $client_group_id = $_SESSION["s"]["user"]["default_group"]; |
| | | $client = $app->db->queryOneRecord("SELECT client.default_webserver FROM sys_group, client WHERE sys_group.client_id = client.client_id and sys_group.groupid = $client_group_id"); |
| | | $app->tpl->setVar("server_id_value", $client['default_webserver']); |
| | | } |
| | | |
| | | parent::onShowNew(); |
| | |
| | | $app->tpl->setVar("ipv6_address",$ip_select); |
| | | unset($tmp); |
| | | unset($ips); |
| | | |
| | | //PHP Version Selection (FastCGI) |
| | | $sql = "SELECT * FROM server_php WHERE php_fastcgi_binary != '' AND php_fastcgi_ini_dir != '' AND server_id = ".$client['default_webserver']." AND (client_id = 0 OR client_id=".$_SESSION['s']['user']['client_id'].")"; |
| | | $php_records = $app->db->queryAllRecords($sql); |
| | | $php_select = "<option value=''>Default</option>"; |
| | | if(is_array($php_records) && !empty($php_records)) { |
| | | foreach( $php_records as $php_record) { |
| | | $php_version = $php_record['name'].':'.$php_record['php_fastcgi_binary'].':'.$php_record['php_fastcgi_ini_dir']; |
| | | $selected = ($php_version == $this->dataRecord["fastcgi_php_version"])?'SELECTED':''; |
| | | $php_select .= "<option value='$php_version' $selected>".$php_record['name']."</option>\r\n"; |
| | | } |
| | | } |
| | | $app->tpl->setVar("fastcgi_php_version",$php_select); |
| | | unset($php_records); |
| | | |
| | | //* Reseller: If the logged in user is not admin and has sub clients (is a reseller) |
| | | } elseif ($_SESSION["s"]["user"]["typ"] != 'admin' && $app->auth->has_clients($_SESSION['s']['user']['userid'])) { |
| | |
| | | $records = $app->db->queryAllRecords($sql); |
| | | $tmp = $app->db->queryOneRecord("SELECT groupid FROM sys_group WHERE client_id = ".$client['client_id']); |
| | | $client_select = '<option value="'.$tmp['groupid'].'">'.$client['contact_name'].'</option>'; |
| | | $tmp_data_record = $app->tform->getDataRecord($this->id); |
| | | //$tmp_data_record = $app->tform->getDataRecord($this->id); |
| | | if(is_array($records)) { |
| | | foreach( $records as $rec) { |
| | | $selected = @($rec["groupid"] == $tmp_data_record["sys_groupid"])?'SELECTED':''; |
| | | $selected = @(is_array($this->dataRecord) && ($rec["groupid"] == $this->dataRecord['client_group_id'] || $rec["groupid"] == $this->dataRecord['sys_groupid']))?'SELECTED':''; |
| | | $client_select .= "<option value='$rec[groupid]' $selected>$rec[name]</option>\r\n"; |
| | | } |
| | | } |
| | |
| | | $app->tpl->setVar("ipv6_address",$ip_select); |
| | | unset($tmp); |
| | | unset($ips); |
| | | |
| | | //PHP Version Selection (FastCGI) |
| | | $sql = "SELECT * FROM server_php WHERE php_fastcgi_binary != '' AND php_fastcgi_ini_dir != '' AND server_id = ".$client['default_webserver']." AND (client_id = 0 OR client_id=".$_SESSION['s']['user']['client_id'].")"; |
| | | $php_records = $app->db->queryAllRecords($sql); |
| | | $php_select = "<option value=''>Default</option>"; |
| | | if(is_array($php_records) && !empty($php_records)) { |
| | | foreach( $php_records as $php_record) { |
| | | $php_version = $php_record['name'].':'.$php_record['php_fastcgi_binary'].':'.$php_record['php_fastcgi_ini_dir']; |
| | | $selected = ($php_version == $this->dataRecord["fastcgi_php_version"])?'SELECTED':''; |
| | | $php_select .= "<option value='$php_version' $selected>".$php_record['name']."</option>\r\n"; |
| | | } |
| | | } |
| | | $app->tpl->setVar("fastcgi_php_version",$php_select); |
| | | unset($php_records); |
| | | |
| | | //* Admin: If the logged in user is admin |
| | | } else { |
| | |
| | | $app->tpl->setVar("ipv6_address",$ip_select); |
| | | unset($tmp); |
| | | unset($ips); |
| | | |
| | | //PHP Version Selection (FastCGI) |
| | | $sql = "SELECT * FROM server_php WHERE php_fastcgi_binary != '' AND php_fastcgi_ini_dir != '' AND server_id = $server_id"; |
| | | $php_records = $app->db->queryAllRecords($sql); |
| | | $php_select = "<option value=''>Default</option>"; |
| | | if(is_array($php_records) && !empty($php_records)) { |
| | | foreach( $php_records as $php_record) { |
| | | $php_version = $php_record['name'].':'.$php_record['php_fastcgi_binary'].':'.$php_record['php_fastcgi_ini_dir']; |
| | | $selected = ($php_version == $this->dataRecord["fastcgi_php_version"])?'SELECTED':''; |
| | | $php_select .= "<option value='$php_version' $selected>".$php_record['name']."</option>\r\n"; |
| | | } |
| | | } |
| | | $app->tpl->setVar("fastcgi_php_version",$php_select); |
| | | unset($php_records); |
| | | |
| | | // Fill the client select field |
| | | $sql = "SELECT groupid, name FROM sys_group WHERE client_id > 0 ORDER BY name"; |
| | | $clients = $app->db->queryAllRecords($sql); |
| | | $client_select = "<option value='0'></option>"; |
| | | $tmp_data_record = $app->tform->getDataRecord($this->id); |
| | | //$tmp_data_record = $app->tform->getDataRecord($this->id); |
| | | if(is_array($clients)) { |
| | | foreach( $clients as $client) { |
| | | $selected = @($client["groupid"] == $tmp_data_record["sys_groupid"])?'SELECTED':''; |
| | | //$selected = @($client["groupid"] == $tmp_data_record["sys_groupid"])?'SELECTED':''; |
| | | $selected = @(is_array($this->dataRecord) && ($client["groupid"] == $this->dataRecord['client_group_id'] || $client["groupid"] == $this->dataRecord['sys_groupid']))?'SELECTED':''; |
| | | $client_select .= "<option value='$client[groupid]' $selected>$client[name]</option>\r\n"; |
| | | } |
| | | } |
| | |
| | | function onAfterUpdate() { |
| | | global $app, $conf; |
| | | |
| | | // make sure that the record belongs to the clinet group and not the admin group when a admin inserts it |
| | | // make sure that the record belongs to the client group and not the admin group when a admin inserts it |
| | | // also make sure that the user can not delete domain created by a admin |
| | | if($_SESSION["s"]["user"]["typ"] == 'admin' && isset($this->dataRecord["client_group_id"])) { |
| | | $client_group_id = intval($this->dataRecord["client_group_id"]); |
| | |
| | | } |
| | | unset($records); |
| | | unset($rec); |
| | | |
| | | //* Update all databases |
| | | $records = $app->db->queryAllRecords("SELECT database_id FROM web_database WHERE parent_domain_id = ".$this->id); |
| | | foreach($records as $rec) { |
| | | $app->db->datalogUpdate('web_database', "sys_userid = '".$web_rec['sys_userid']."', sys_groupid = '".$web_rec['sys_groupid']."'", 'database_id', $rec['database_id']); |
| | | } |
| | | unset($records); |
| | | unset($rec); |
| | | |
| | | } |
| | | |
| | |
| | | $sql = "UPDATE web_domain SET php_open_basedir = '$php_open_basedir' WHERE domain_id = ".$this->id; |
| | | $app->db->query($sql); |
| | | } |
| | | |
| | | //* Change database backup options when web backup options have been changed |
| | | if(isset($this->dataRecord['backup_interval']) && ($this->dataRecord['backup_interval'] != $this->oldDataRecord['backup_interval'] || $this->dataRecord['backup_copies'] != $this->oldDataRecord['backup_copies'])) { |
| | | //* Update all databases |
| | | $backup_interval = $this->dataRecord['backup_interval']; |
| | | $backup_copies = $this->dataRecord['backup_copies']; |
| | | $records = $app->db->queryAllRecords("SELECT database_id FROM web_database WHERE parent_domain_id = ".$this->id); |
| | | foreach($records as $rec) { |
| | | $app->db->datalogUpdate('web_database', "backup_interval = '$backup_interval', backup_copies = '$backup_copies'", 'database_id', $rec['database_id']); |
| | | } |
| | | unset($records); |
| | | unset($rec); |
| | | unset($backup_copies); |
| | | unset($backup_interval); |
| | | } |
| | | |
| | | } |
| | | |