";
+ var $activeuser, $isloggedin, $globalfilter, $commandline = false, $erroroccured = false;
+ var $connected_mysql_servers = array();
+ var $ehcpdir = '';
+ var $tr = "
", $td = "
", $th = "
";
var $ehcpForceSplitString = "{EHCP_EAM_FORCE_SPLIT_STRING2015}";
var $ehcpInstallPath = "/var/www/new/ehcp/";
var $ehcpDownloadPath = "/var/www/new/ehcp/downloads";
- var $conf=array(
- # config section
- # yavas yavas conf sistemine gecmek lazim. aslinda kod icinde sabit bilgi kullanmamak lazim. string bile... ama nerdee...
- # this is like configuration of many system settings, tablenames etc. by this, changing something is easier, without need to change code..
- # apache and dns defs:
-
- 'adminname'=>'ehcpdeveloper',
- 'adminemail'=>'ehcpdeveloper@gmail.com',
- 'wwwbase'=>'/var/www',
- 'ehcpdir'=>'',
- 'vhosts'=>'/var/www/vhosts',
- 'namedbase'=>'/etc/bind',
+ var $conf = array(
+ # config section
+ # yavas yavas conf sistemine gecmek lazim. aslinda kod icinde sabit bilgi kullanmamak lazim. string bile... ama nerdee...
+ # this is like configuration of many system settings, tablenames etc. by this, changing something is easier, without need to change code..
+ # apache and dns defs:
+
+ 'adminname' => 'ehcpdeveloper',
+ 'adminemail' => 'ehcpdeveloper@gmail.com',
+ 'wwwbase' => '/var/www',
+ 'ehcpdir' => '',
+ 'vhosts' => '/var/www/vhosts',
+ 'namedbase' => '/etc/bind',
'dnsip' => '10.0.0.10',
- 'dnsemail' => 'your.email.here',
+ 'dnsemail' => 'your.email.here',
# mysql definitions
- 'mysqlrootuser'=>'root', # this is for db creation.
- 'mysqlrootpass'=>'12345',
+ 'mysqlrootuser' => 'root',
+ # this is for db creation.
+ 'mysqlrootpass' => '12345',
# ehcp db table definitions, this is to make code more db-independent...
- 'logintable'=>array(
- 'tablename'=>'panelusers',
- 'passwordfunction'=>'md5',
- 'usernamefield'=>'panelusername',
- 'passwordfield'=>'password'
+ 'logintable' => array(
+ 'tablename' => 'panelusers',
+ 'passwordfunction' => 'md5',
+ 'usernamefield' => 'panelusername',
+ 'passwordfield' => 'password'
),
- 'settingstable2'=>array(
- 'tablename'=>'settings',
- 'createtable'=>
-"CREATE TABLE IF NOT EXISTS `settings` (
+ 'settingstable2' => array(
+ 'tablename' => 'settings',
+ 'createtable' =>
+ "CREATE TABLE IF NOT EXISTS `settings` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`group` varchar(20) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT '',
`reseller` varchar(30) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT '',
@@ -114,21 +113,21 @@ class Application
`comment` varchar(100) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT '',
PRIMARY KEY (`id`),
UNIQUE KEY `group` (`group`,`reseller`,`panelusername`,`name`,`value`)
-) DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci COMMENT='ehcp db - Table for settings of ehcp'"
+) DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci COMMENT='ehcp db - Table for settings of ehcp'"
),
- 'vpstable'=>array(
- 'tablename'=>'vps',
- 'listfields'=>array('vpsname','ip','ip2','ram','description','reseller','panelusername','hostip','state','image_template'),
- 'linkimages'=>array('images/incele.jpg','images/poweron.gif','images/poweroff.gif','images/pause.gif','images/edit2.gif','images/delete1.jpg'),
- 'linkfiles'=>array('?op=vps&op2=select','?op=vps&op2=start','?op=vps&op2=shutoff','?op=vps&op2=pause','?op=vps&op2=edit','?op=vps&op2=delete'),
- 'linkfield'=>'vpsname',
- 'checkfields'=>array(
- 'addvpscmd'=>'text',
- 'ip2'=>'varchar(20)',
- 'cdimage'=>'varchar(100)'
+ 'vpstable' => array(
+ 'tablename' => 'vps',
+ 'listfields' => array('vpsname', 'ip', 'ip2', 'ram', 'description', 'reseller', 'panelusername', 'hostip', 'state', 'image_template'),
+ 'linkimages' => array('images/incele.jpg', 'images/poweron.gif', 'images/poweroff.gif', 'images/pause.gif', 'images/edit2.gif', 'images/delete1.jpg'),
+ 'linkfiles' => array('?op=vps&op2=select', '?op=vps&op2=start', '?op=vps&op2=shutoff', '?op=vps&op2=pause', '?op=vps&op2=edit', '?op=vps&op2=delete'),
+ 'linkfield' => 'vpsname',
+ 'checkfields' => array(
+ 'addvpscmd' => 'text',
+ 'ip2' => 'varchar(20)',
+ 'cdimage' => 'varchar(100)'
),
- 'createtable'=>
-"CREATE TABLE `vps` (
+ 'createtable' =>
+ "CREATE TABLE `vps` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`reseller` varchar(30) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL,
`panelusername` varchar(30) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL,
@@ -149,238 +148,246 @@ class Application
`addvpscmd` text CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL,
PRIMARY KEY (`id`)
) DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci COMMENT='ehcp db - list of vps and their properties'"
-
+
),
- 'domainstable'=>array(
- 'tablename'=>'domains',
- 'ownerfield'=>'panelusername',
- 'resellerfield'=>'reseller',
- 'domainfields'=>array('id','reseller','panelusername','domainname','status','comment'),
- 'listfields'=>array('id','reseller','panelusername','domainname','webserverips','status','diskquotaused','diskquota'),
- 'checkfields'=>array(
- 'serverip'=>'varchar(30)',
- 'dnsserverips'=>'varchar(200)',
- 'webserverips'=>'varchar(200)',
- 'mailserverips'=>'varchar(200)',
- 'mysqlserverips'=>'varchar(200)',
- 'host'=>'varchar(30)',
- 'apachetemplate'=>'text',
- 'apache2template'=>'text',
- 'nginxtemplate'=>'text',
- 'dnstemplate'=>'text',
- 'aliases'=>'text',
- 'diskquotaused'=>'int(4)',
- 'diskquota'=>'int(4)',
- 'diskquotaovernotified'=>'int(4)',
- 'diskquotaoversince'=>'date',
- 'graceperiod'=>'int(4) default 7',
- 'theorder'=>'int(11)',
- 'dnsmaster'=>'varchar(15) default NULL',
- 'redirect_to'=>'varchar(200) default NULL',
- 'ssl_cert'=>'text',
- 'ssl_cert_key'=>'text',
- 'ssl_cert_chain'=>'text',
+ 'domainstable' => array(
+ 'tablename' => 'domains',
+ 'ownerfield' => 'panelusername',
+ 'resellerfield' => 'reseller',
+ 'domainfields' => array('id', 'reseller', 'panelusername', 'domainname', 'status', 'comment'),
+ 'listfields' => array('id', 'reseller', 'panelusername', 'domainname', 'webserverips', 'status', 'diskquotaused', 'diskquota'),
+ 'checkfields' => array(
+ 'serverip' => 'varchar(30)',
+ 'dnsserverips' => 'varchar(200)',
+ 'webserverips' => 'varchar(200)',
+ 'mailserverips' => 'varchar(200)',
+ 'mysqlserverips' => 'varchar(200)',
+ 'host' => 'varchar(30)',
+ 'apachetemplate' => 'text',
+ 'apache2template' => 'text',
+ 'nginxtemplate' => 'text',
+ 'dnstemplate' => 'text',
+ 'aliases' => 'text',
+ 'diskquotaused' => 'int(4)',
+ 'diskquota' => 'int(4)',
+ 'diskquotaovernotified' => 'int(4)',
+ 'diskquotaoversince' => 'date',
+ 'graceperiod' => 'int(4) default 7',
+ 'theorder' => 'int(11)',
+ 'dnsmaster' => 'varchar(15) default NULL',
+ 'redirect_to' => 'varchar(200) default NULL',
+ 'ssl_cert' => 'text',
+ 'ssl_cert_key' => 'text',
+ 'ssl_cert_chain' => 'text',
'ssl_wild_card' => 'bit(1) default b\'0\'',
'ssl_use_letsenc' => 'bit(1) default b\'0\'',
'ssl_redirect_https' => 'bit(1) default b\'0\'',
'ssl_lets_enc_additional_hosts' => 'text'
)
),
- 'domainstable2'=>array(
- 'tablename'=>'domains',
- 'listfields'=>array('domainname')
+ 'domainstable2' => array(
+ 'tablename' => 'domains',
+ 'listfields' => array('domainname')
),
- 'subdomainstable'=>array(
- 'tablename'=>'subdomains',
- 'listfields'=>array('reseller','panelusername','subdomain','domainname','homedir','ftpusername','comment'),
- 'listlabels'=>array('Reseller', 'Username', 'Subdomain', 'Domain', 'Home Directory', 'FTP Username', 'Comment', 'Delete', 'Edit Template'),
- 'linkimages'=>array('images/delete1.jpg', 'images/editapachetemplate.png'),
- 'linkfiles'=>array('?op=delsubdomain','?op=editapachetemplatesubdomain'),
- 'linkfield'=>'id',
- 'checkfields'=>array(
- 'ftpusername'=>'varchar(30)',
- 'password'=>'varchar(20)',
- 'email'=>'varchar(50)',
- 'webserverips'=>'varchar(200)',
- 'apache2template'=>'text',
- 'nginxtemplate'=>'text'
+ 'subdomainstable' => array(
+ 'tablename' => 'subdomains',
+ 'listfields' => array('reseller', 'panelusername', 'subdomain', 'domainname', 'homedir', 'ftpusername', 'comment'),
+ 'listlabels' => array('Reseller', 'Username', 'Subdomain', 'Domain', 'Home Directory', 'FTP Username', 'Comment', 'Delete', 'Edit Template'),
+ 'linkimages' => array('images/delete1.jpg', 'images/editapachetemplate.png'),
+ 'linkfiles' => array('?op=delsubdomain', '?op=editapachetemplatesubdomain'),
+ 'linkfield' => 'id',
+ 'checkfields' => array(
+ 'ftpusername' => 'varchar(30)',
+ 'password' => 'varchar(20)',
+ 'email' => 'varchar(50)',
+ 'webserverips' => 'varchar(200)',
+ 'apache2template' => 'text',
+ 'nginxtemplate' => 'text'
)
- ),
+ ),
- 'globalwebservertemplatestable'=>array(
- 'tablename'=>'globalwebservertemplates',
- 'listfields'=>array('template_name','template_webserver_type','template_value'),
+ 'globalwebservertemplatestable' => array(
+ 'tablename' => 'globalwebservertemplates',
+ 'listfields' => array('template_name', 'template_webserver_type', 'template_value'),
// Password protected directories
- 'createtable'=>"CREATE TABLE IF NOT EXISTS `globalwebservertemplates` (
+ 'createtable' => "CREATE TABLE IF NOT EXISTS `globalwebservertemplates` (
template_name varchar(100) NOT NULL,
template_webserver_type varchar(100) NOT NULL,
template_ssl_type varchar(100) NOT NULL,
template_value text default NULL,
PRIMARY KEY (template_name, template_webserver_type, template_ssl_type)
) comment='Used for custom global webserver templates';"
- ),
+ ),
- 'paneluserstable'=> array(
- 'tablename'=>'panelusers',
- 'resellerfield'=>'reseller',
- 'usernamefield'=>'panelusername',
- 'passwordfield'=>'password',
- 'listlabels'=>array('ID','Reseller','Username','Max Domains','Max Emails','Quota','Max Panel Users','Max FTP Users','Max MySQL Databases','Full Name','Email','Theme Color','Theme Contrast','Master Reseller','Max Sub Domains', 'Edit User', 'Delete User'),
- 'listfields'=>array('id','reseller','panelusername','maxdomains','maxemails','quota','maxpanelusers','maxftpusers','maxdbs','name','email','theme_color','theme_contrast','master_reseller','maxsubdomains'),
- 'clickimages'=>array('images/edit.gif','images/delete1.jpg'),
- 'clickfiles'=>array('?op=editpaneluser','?op=deletepaneluser'),
- 'insertfields'=>array(array('panelusername', 'lefttext'=>'Panel Username:'),array('password','password','lefttext'=>'Password:'),array('maxdomains','default'=>5, 'lefttext'=>'Max Domains:'),array('maxsubdomains','default'=>15, 'lefttext'=>'Max Sub Domains:'),array('maxemails','default'=>20, 'lefttext'=>'Max Emails:'),array('quota','default'=>500, 'lefttext'=>'Quota in MB:'),array('master_reseller','checkbox','default'=>1,'disabled'=>'','lefttext'=>'Set as Master Reseller Account:','requires_admin'=>true),array('maxpanelusers','default'=>0, 'lefttext'=>'Max Panel Users:'),array('maxftpusers','default'=>5, 'lefttext'=>'Max FTP Users:'),array('maxdbs','default'=>10, 'lefttext'=>'Max Databases:'),array('name', 'lefttext'=>'Full Name:'),array('email', 'lefttext'=>'Email Address:')),
- 'insertfieldlabels'=>array('Panel Username','Password','Max Domains','Max Subdomains','Max Emails','Quota (MB)','Master Reseller Account','Max Panel Users','Max FTP Users','Max MySQL Databases','Name','Email'),
- 'mandatoryinsertfields'=>array('panelusername'), # zorunlu insert alanlari
- 'editfields'=>array('maxdomains','maxsubdomains','maxemails','quota','maxpanelusers','maxftpusers','maxdbs','name','email','master_reseller'), # edit edildigi zaman görünecek alanlar..
- 'editlabels'=>array('Max Domains','Max Subdomains','Max Emails','Quota (MB)','Max Panel Users','Max FTP Users','Max MySQL Databases','Full Name','Email','Master Reseller'), # edit edildigi zaman görünecek alanlar..
- 'checkbox_fields'=>array('master_reseller'),
- 'linkfield'=>'id',
- 'checkfields'=>array(
- 'comment'=>'varchar(100)',
- 'theme_color'=>'varchar(7)',
- 'theme_contrast'=>'varchar(10)',
- 'master_reseller'=>'tinyint(1) default 0',
- 'maxsubdomains'=>'int(11) default 10',
+ 'paneluserstable' => array(
+ 'tablename' => 'panelusers',
+ 'resellerfield' => 'reseller',
+ 'usernamefield' => 'panelusername',
+ 'passwordfield' => 'password',
+ 'listlabels' => array('ID', 'Reseller', 'Username', 'Max Domains', 'Max Emails', 'Quota', 'Max Panel Users', 'Max FTP Users', 'Max MySQL Databases', 'Full Name', 'Email', 'Theme Color', 'Theme Contrast', 'Master Reseller', 'Max Sub Domains', 'Edit User', 'Delete User'),
+ 'listfields' => array('id', 'reseller', 'panelusername', 'maxdomains', 'maxemails', 'quota', 'maxpanelusers', 'maxftpusers', 'maxdbs', 'name', 'email', 'theme_color', 'theme_contrast', 'master_reseller', 'maxsubdomains'),
+ 'clickimages' => array('images/edit.gif', 'images/delete1.jpg'),
+ 'clickfiles' => array('?op=editpaneluser', '?op=deletepaneluser'),
+ 'insertfields' => array(array('panelusername', 'lefttext' => 'Panel Username:'), array('password', 'password', 'lefttext' => 'Password:'), array('maxdomains', 'default' => 5, 'lefttext' => 'Max Domains:'), array('maxsubdomains', 'default' => 15, 'lefttext' => 'Max Sub Domains:'), array('maxemails', 'default' => 20, 'lefttext' => 'Max Emails:'), array('quota', 'default' => 500, 'lefttext' => 'Quota in MB:'), array('master_reseller', 'checkbox', 'default' => 1, 'disabled' => '', 'lefttext' => 'Set as Master Reseller Account:', 'requires_admin' => true), array('maxpanelusers', 'default' => 0, 'lefttext' => 'Max Panel Users:'), array('maxftpusers', 'default' => 5, 'lefttext' => 'Max FTP Users:'), array('maxdbs', 'default' => 10, 'lefttext' => 'Max Databases:'), array('name', 'lefttext' => 'Full Name:'), array('email', 'lefttext' => 'Email Address:')),
+ 'insertfieldlabels' => array('Panel Username', 'Password', 'Max Domains', 'Max Subdomains', 'Max Emails', 'Quota (MB)', 'Master Reseller Account', 'Max Panel Users', 'Max FTP Users', 'Max MySQL Databases', 'Name', 'Email'),
+ 'mandatoryinsertfields' => array('panelusername'),
+ # zorunlu insert alanlari
+ 'editfields' => array('maxdomains', 'maxsubdomains', 'maxemails', 'quota', 'maxpanelusers', 'maxftpusers', 'maxdbs', 'name', 'email', 'master_reseller'),
+ # edit edildigi zaman görünecek alanlar..
+ 'editlabels' => array('Max Domains', 'Max Subdomains', 'Max Emails', 'Quota (MB)', 'Max Panel Users', 'Max FTP Users', 'Max MySQL Databases', 'Full Name', 'Email', 'Master Reseller'),
+ # edit edildigi zaman görünecek alanlar..
+ 'checkbox_fields' => array('master_reseller'),
+ 'linkfield' => 'id',
+ 'checkfields' => array(
+ 'comment' => 'varchar(100)',
+ 'theme_color' => 'varchar(7)',
+ 'theme_contrast' => 'varchar(10)',
+ 'master_reseller' => 'tinyint(1) default 0',
+ 'maxsubdomains' => 'int(11) default 10',
),
- 'help'=>'description of this table... ehcp control panel users... '
+ 'help' => 'description of this table... ehcp control panel users... '
),
- 'customstable'=>array( # custom dns and http settings
- 'tablename'=>'customsettings',
- 'listfields'=>array('id','domainname','name','comment','value','value2','webservertype'),
- 'linkimages'=>array('images/delete1.jpg'),
- 'linkfiles'=>array('?op=deletecustom'),
- 'orderby'=>'id',
- 'linkfield'=>'id',
- 'checkfields'=>array(
- 'reseller'=>'varchar(30)',
- 'panelusername'=>'varchar(30)',
- 'domainname'=>'varchar(50)',
- 'webservertype'=>'varchar(30)',
- 'value2'=>'text'
+ 'customstable' => array(
+ # custom dns and http settings
+ 'tablename' => 'customsettings',
+ 'listfields' => array('id', 'domainname', 'name', 'comment', 'value', 'value2', 'webservertype'),
+ 'linkimages' => array('images/delete1.jpg'),
+ 'linkfiles' => array('?op=deletecustom'),
+ 'orderby' => 'id',
+ 'linkfield' => 'id',
+ 'checkfields' => array(
+ 'reseller' => 'varchar(30)',
+ 'panelusername' => 'varchar(30)',
+ 'domainname' => 'varchar(50)',
+ 'webservertype' => 'varchar(30)',
+ 'value2' => 'text'
)
),
- 'emailuserstable'=>array(
- 'tablename'=>'emailusers', # going to be array as above..
- 'listfields'=>array('email','quota','domainname'),
- 'linkimages'=>array('images/delete1.jpg','images/edit.gif'),
- 'linkfiles'=>array('?op=userop&action=emailuserdelete','?op=editemailuser'),
- 'linkfield'=>'id',
- 'ownerfield'=>'panelusername',
- 'resellerfield'=>'reseller',
+ 'emailuserstable' => array(
+ 'tablename' => 'emailusers',
+ # going to be array as above..
+ 'listfields' => array('email', 'quota', 'domainname'),
+ 'linkimages' => array('images/delete1.jpg', 'images/edit.gif'),
+ 'linkfiles' => array('?op=userop&action=emailuserdelete', '?op=editemailuser'),
+ 'linkfield' => 'id',
+ 'ownerfield' => 'panelusername',
+ 'resellerfield' => 'reseller',
# for use with email user logins
- 'passwordfunction'=>'encrypt',
- 'usernamefield'=>'email',
- 'passwordfield'=>'password',
+ 'passwordfunction' => 'encrypt',
+ 'usernamefield' => 'email',
+ 'passwordfield' => 'password',
- 'checkfields'=>array(
- 'reseller'=>'varchar(30)',
- 'panelusername'=>'varchar(30)',
- 'domainname'=>'varchar(50)',
- 'status'=>'varchar(10)',
- 'autoreplysubject'=>'varchar(100)',
- 'autoreplymessage'=>'text'
+ 'checkfields' => array(
+ 'reseller' => 'varchar(30)',
+ 'panelusername' => 'varchar(30)',
+ 'domainname' => 'varchar(50)',
+ 'status' => 'varchar(10)',
+ 'autoreplysubject' => 'varchar(100)',
+ 'autoreplymessage' => 'text'
)
),
- 'ftpuserstable'=>array(
- 'tablename'=>'ftpaccounts', # going to be array as above..
- 'ownerfield'=>'panelusername',
- 'resellerfield'=>'reseller',
- 'listfields'=>array('domainname','ftpusername','status','homedir','type'),
- 'checkfields'=>array(
- 'type'=>'varchar(10)',
- 'reseller'=>'varchar(30)',
- 'panelusername'=>'varchar(30)',
- 'domainname'=>'varchar(50)',
- 'homedir'=>'varchar(100)',
- 'datetime'=>'datetime'
+ 'ftpuserstable' => array(
+ 'tablename' => 'ftpaccounts',
+ # going to be array as above..
+ 'ownerfield' => 'panelusername',
+ 'resellerfield' => 'reseller',
+ 'listfields' => array('domainname', 'ftpusername', 'status', 'homedir', 'type'),
+ 'checkfields' => array(
+ 'type' => 'varchar(10)',
+ 'reseller' => 'varchar(30)',
+ 'panelusername' => 'varchar(30)',
+ 'domainname' => 'varchar(50)',
+ 'homedir' => 'varchar(100)',
+ 'datetime' => 'datetime'
)
),
- 'operations_table'=>array(
- 'tablename'=>'operations', # going to be array as above..
- 'listfields'=>array('id','user','ip','op','status','tarih','try','info','info2','info3','action'),
- 'checkfields'=>array(
- 'info'=>'text',
- 'info2'=>'text',
- 'info3'=>'text',
- 'user'=>'varchar(30)',
- 'ip'=>'varchar(30)'
+ 'operations_table' => array(
+ 'tablename' => 'operations',
+ # going to be array as above..
+ 'listfields' => array('id', 'user', 'ip', 'op', 'status', 'tarih', 'try', 'info', 'info2', 'info3', 'action'),
+ 'checkfields' => array(
+ 'info' => 'text',
+ 'info2' => 'text',
+ 'info3' => 'text',
+ 'user' => 'varchar(30)',
+ 'ip' => 'varchar(30)'
)
),
- 'backups_table'=>array(
- 'tablename'=>'backups',
- 'listfields'=>array('id','domainname','backupname','filename','date','size','status'),
- 'linkimages'=>array('images/delete1.gif'),
- 'linkfiles'=>array('?op=backups&op2=delete&filename='),
- 'linkfield'=>'filename',
- 'checkfields'=>array(
- 'status'=>'varchar(100)',
- 'domainname'=>'varchar(100)',
- 'filename'=>'varchar(200)'
+ 'backups_table' => array(
+ 'tablename' => 'backups',
+ 'listfields' => array('id', 'domainname', 'backupname', 'filename', 'date', 'size', 'status'),
+ 'linkimages' => array('images/delete1.gif'),
+ 'linkfiles' => array('?op=backups&op2=delete&filename='),
+ 'linkfield' => 'filename',
+ 'checkfields' => array(
+ 'status' => 'varchar(100)',
+ 'domainname' => 'varchar(100)',
+ 'filename' => 'varchar(200)'
)
),
- 'mysqldbstable'=>array(
- 'tablename'=>'mysqldb',
- 'listfields'=>array('domainname','dbname','host'),
- 'linkimages'=>array('images/delete1.jpg'),
- 'linkfiles'=>array('?op=domainop&action=deletedb'),
- 'linkfield'=>'id',
- 'checkfields'=>array(
- 'host'=>'varchar(30)',
- 'reseller'=>'varchar(30)',
- 'panelusername'=>'varchar(30)',
- 'domainname'=>'varchar(50)'
+ 'mysqldbstable' => array(
+ 'tablename' => 'mysqldb',
+ 'listfields' => array('domainname', 'dbname', 'host'),
+ 'linkimages' => array('images/delete1.jpg'),
+ 'linkfiles' => array('?op=domainop&action=deletedb'),
+ 'linkfield' => 'id',
+ 'checkfields' => array(
+ 'host' => 'varchar(30)',
+ 'reseller' => 'varchar(30)',
+ 'panelusername' => 'varchar(30)',
+ 'domainname' => 'varchar(50)'
)
),
- 'mysqldbuserstable'=>array(
- 'tablename'=>'mysqlusers',
- 'listfields'=>array('domainname','dbname','dbusername','host'),
- 'linkimages'=>array('images/edit.gif'),
- 'linkfiles'=>array('?op=dbedituser'),
- 'linkfield'=>'id',
- 'checkfields'=>array(
- 'host'=>'varchar(30)',
- 'reseller'=>'varchar(30)',
- 'panelusername'=>'varchar(30)',
- 'domainname'=>'varchar(50)',
- 'password'=>'varchar(32)',
- 'dbname'=>'varchar(64)'
+ 'mysqldbuserstable' => array(
+ 'tablename' => 'mysqlusers',
+ 'listfields' => array('domainname', 'dbname', 'dbusername', 'host'),
+ 'linkimages' => array('images/edit.gif'),
+ 'linkfiles' => array('?op=dbedituser'),
+ 'linkfield' => 'id',
+ 'checkfields' => array(
+ 'host' => 'varchar(30)',
+ 'reseller' => 'varchar(30)',
+ 'panelusername' => 'varchar(30)',
+ 'domainname' => 'varchar(50)',
+ 'password' => 'varchar(32)',
+ 'dbname' => 'varchar(64)'
)
),
- 'serverstable'=>array(
- 'tablename'=>'servers',
- 'listfields'=>array('servertype','ip','accessip','mandatory','location'),
- 'linkimages'=>array('images/edit.gif'),
- 'linkfiles'=>array('?op=editserver'),
- 'linkfield'=>'id',
- 'checkfields'=>array('accessip'=>'varchar(30)')
+ 'serverstable' => array(
+ 'tablename' => 'servers',
+ 'listfields' => array('servertype', 'ip', 'accessip', 'mandatory', 'location'),
+ 'linkimages' => array('images/edit.gif'),
+ 'linkfiles' => array('?op=editserver'),
+ 'linkfield' => 'id',
+ 'checkfields' => array('accessip' => 'varchar(30)')
),
- 'emailforwardingstable'=>array(
- 'tablename'=>'forwardings',
- 'listfields'=>array('panelusername','domainname','source','destination'),
- 'linkimages'=>array('images/delete1.jpg'),
- 'linkfiles'=>array('?op=delemailforwarding'),
- 'linkfield'=>'id',
- 'checkfields'=>array(
- 'reseller'=>'varchar(30)',
- 'panelusername'=>'varchar(30)',
- 'domainname'=>'varchar(50)'
+ 'emailforwardingstable' => array(
+ 'tablename' => 'forwardings',
+ 'listfields' => array('panelusername', 'domainname', 'source', 'destination'),
+ 'linkimages' => array('images/delete1.jpg'),
+ 'linkfiles' => array('?op=delemailforwarding'),
+ 'linkfield' => 'id',
+ 'checkfields' => array(
+ 'reseller' => 'varchar(30)',
+ 'panelusername' => 'varchar(30)',
+ 'domainname' => 'varchar(50)'
)
),
- 'transporttable'=>array( # for email autoreply
- 'tablename'=>'transport',
- 'createtable'=>
-"
+ 'transporttable' => array(
+ # for email autoreply
+ 'tablename' => 'transport',
+ 'createtable' =>
+ "
CREATE TABLE transport (
domainname varchar(128) NOT NULL default '',
transport varchar(128) NOT NULL default '',
@@ -388,40 +395,40 @@ CREATE TABLE transport (
) DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci
"
),
- 'settingstable'=>array(
- 'tablename'=>'misc',
- 'checkfields'=>array(
- 'name'=>'varchar(40)',
- 'panelusername'=>'varchar(30)'
+ 'settingstable' => array(
+ 'tablename' => 'misc',
+ 'checkfields' => array(
+ 'name' => 'varchar(40)',
+ 'panelusername' => 'varchar(30)'
)
),
- 'scriptstable'=>array(
- 'tablename'=>'scripts',
- 'checkfields'=>array(
- 'homepage'=>'varchar(50)',
- 'description'=>'text',
- 'customfileownerships'=>'text'
+ 'scriptstable' => array(
+ 'tablename' => 'scripts',
+ 'checkfields' => array(
+ 'homepage' => 'varchar(50)',
+ 'description' => 'text',
+ 'customfileownerships' => 'text'
)
),
- 'daemonopstable'=>'operations',
- 'hashtable'=>array(
- 'tablename'=>'hash',
- 'createtable'=>"
+ 'daemonopstable' => 'operations',
+ 'hashtable' => array(
+ 'tablename' => 'hash',
+ 'createtable' => "
CREATE TABLE IF NOT EXISTS `hash` (
`email` varchar(100) COLLATE utf8_general_ci NOT NULL DEFAULT 'NULL',
`hash` varchar(100) COLLATE utf8_general_ci DEFAULT NULL,
KEY `email_index` (`email`)
) DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci COMMENT='to store password remind hash'
"
-
+
),
-
+
// Start of new tables
-
+
// Remote backups table
- 'remote_backups_table'=>array(
- 'tablename'=>'remote_backups',
- 'createtable'=>"
+ 'remote_backups_table' => array(
+ 'tablename' => 'remote_backups',
+ 'createtable' => "
CREATE TABLE IF NOT EXISTS `remote_backups` (
`id` tinyint(4) NOT NULL auto_increment,
`name` varchar(50) default NULL,
@@ -436,16 +443,16 @@ CREATE TABLE IF NOT EXISTS `remote_backups` (
PRIMARY KEY (`id`)
) DEFAULT CHARSET=utf8 COMMENT='Used to schedule cronjobs for remote backups';
",
- 'checkfields'=>array(
- 'encryption_pass'=>'varchar(50)'
+ 'checkfields' => array(
+ 'encryption_pass' => 'varchar(50)'
)
-
+
),
-
+
// Cronjob table
- 'cronjobs_table'=>array(
- 'tablename'=>'cronjobs',
- 'createtable'=>"
+ 'cronjobs_table' => array(
+ 'tablename' => 'cronjobs',
+ 'createtable' => "
CREATE TABLE IF NOT EXISTS `cronjobs` (
`id` tinyint(4) NOT NULL auto_increment,
`script` varchar(100) default NULL,
@@ -454,13 +461,13 @@ CREATE TABLE IF NOT EXISTS `cronjobs` (
PRIMARY KEY (`id`)
) DEFAULT CHARSET=utf8 COMMENT='Used to run any cronjobs an admin may want to run';
"
-
+
),
-
+
// Password protected directories
- 'pwd_dirs_table'=>array(
- 'tablename'=>'pwd_dirs',
- 'createtable'=>"CREATE TABLE IF NOT EXISTS `pwd_dirs` (
+ 'pwd_dirs_table' => array(
+ 'tablename' => 'pwd_dirs',
+ 'createtable' => "CREATE TABLE IF NOT EXISTS `pwd_dirs` (
id int(11) NOT NULL auto_increment,
domainname varchar(100) default NULL,
domainpath varchar(300) default NULL,
@@ -470,11 +477,11 @@ CREATE TABLE IF NOT EXISTS `cronjobs` (
PRIMARY KEY (id)
) comment='Used for password protected directories';"
),
-
+
// Admin defined hosting plans
- 'hosting_plans_table'=>array(
- 'tablename'=>'hosting_plans',
- 'createtable'=>"CREATE TABLE IF NOT EXISTS `hosting_plans` (
+ 'hosting_plans_table' => array(
+ 'tablename' => 'hosting_plans',
+ 'createtable' => "CREATE TABLE IF NOT EXISTS `hosting_plans` (
id int(11) NOT NULL auto_increment,
name varchar(200) default NULL,
master_reseller tinyint(1) default 0,
@@ -488,692 +495,1162 @@ CREATE TABLE IF NOT EXISTS `cronjobs` (
panelusername varchar(30) NOT NULL default 'admin',
PRIMARY KEY (id)
) comment='Used for admin defined hosting plans';",
- 'checkfields'=>array(
- 'panelusername'=>"varchar(30) NOT NULL default 'admin'",
+ 'checkfields' => array(
+ 'panelusername' => "varchar(30) NOT NULL default 'admin'",
)
),
-
- 'logtable'=>array(
- 'tablename'=>'log',
- 'listfields'=>array('tarih','panelusername','notified','ip','log'),
- 'checkfields'=>array(
- 'panelusername'=>'varchar(50)',
- 'notified'=>'varchar(5)'
+
+ 'logtable' => array(
+ 'tablename' => 'log',
+ 'listfields' => array('tarih', 'panelusername', 'notified', 'ip', 'log'),
+ 'checkfields' => array(
+ 'panelusername' => 'varchar(50)',
+ 'notified' => 'varchar(5)'
)
)
-
+
);
-/*
-for almost every record:
-panelusername: who is the owner of that, who setupd that. cannot be empty.
-resellername: who is the reseller of that panelusername. cannot be empty.
-domainname: to which domain is that related. empty if not related to domainname
+ /*
+ for almost every record:
+ panelusername: who is the owner of that, who setupd that. cannot be empty.
+ resellername: who is the reseller of that panelusername. cannot be empty.
+ domainname: to which domain is that related. empty if not related to domainname
-*/
+ */
-/////////////////////
-// The constructor //
-/////////////////////
-function __construct() {
- global $skipUpdateWebstats,$debuglevel;
-
- // Get the right FTP username since Ubuntu 15 and up decided to use a different username...
- $wwwUser = $this->getWWWUser();
-
- // Get the BIND9 DNS user
- $bindUser = $this->getBindUser();
-
- // Get the service name for php-fpm
- $phpFPMName = $this->getPHPFPMName();
-
- // Set our global public class members to the value
- $this->wwwuser = $wwwUser;
- $this->ftpuser = $wwwUser;
-
- if($phpFPMName){
- $this->php_fpm_name = $phpFPMName;
- }
-
- // Set global bind user variable
- if($this->hasValueOrZero($bindUser)){
- $this->binduser = $bindUser;
+ /////////////////////
+ // The constructor //
+ /////////////////////
+ function __construct()
+ {
+ global $skipUpdateWebstats, $debuglevel;
+
+ // Get the right FTP username since Ubuntu 15 and up decided to use a different username...
+ $wwwUser = $this->getWWWUser();
+
+ // Get the BIND9 DNS user
+ $bindUser = $this->getBindUser();
+
+ // Get the service name for php-fpm
+ $phpFPMName = $this->getPHPFPMName();
+
+ // Set our global public class members to the value
+ $this->wwwuser = $wwwUser;
+ $this->ftpuser = $wwwUser;
+
+ if ($phpFPMName) {
+ $this->php_fpm_name = $phpFPMName;
+ }
+
+ // Set global bind user variable
+ if ($this->hasValueOrZero($bindUser)) {
+ $this->binduser = $bindUser;
+ }
+
+ // Load mysql settings from configuration
+ include('config.php');
+ $this->set_ehcp_dir(dirname(__FILE__));
+ $this->vhostsdir = $this->conf['vhosts'];
+
+ // Set variables
+ $this->dbhost = $dbhost;
+ $this->dbusername = $dbusername;
+ $this->dbpass = $dbpass;
+ $this->dbname = $dbname;
+ $this->conf['mysqlrootpass'] = $dbrootpass;
+ $this->defaultlanguage = $defaultlanguage;
+ $this->isDemo = $isdemo;
+ if (!(isset($this->isDemo)))
+ $this->isDemo = False;
+ $this->statusActivePassive = array("active" => "active", "passive" => "passive");
+
+ /* Remote Backup Select List Vars */
+ $this->remoteBackupMethod = array("ftp" => "FTP", "scp" => "SCP");
+ $this->remoteBackupTime = array("0" => "00:00", "6" => "06:00", "12" => "12:00", "18" => "18:00");
+ $this->remoteDayOfWeek = array("0" => "Sunday", "1" => "Monday", "2" => "Tuesday", "3" => "Wednesday", "4" => "Thursday", "5" => "Friday", "6" => "Saturday");
+
+ if (isset($this->debuglevel)) {
+ #....
+ }
+ $debuglevel = $this->debuglevel; # for outer functions using debuglevel
+
+ $this->clientip = getenv("REMOTE_ADDR");
+ if (!validateIpAddress($this->clientip)) {
+ $this->clientip = "";
+ }
+ $this->referer = getenv("HTTP_REFERER");
+
+ $this->wwwowner = $this->wwwuser . ':' . $this->wwwgroup;
+ $this->ftpowner = $this->ftpuser . ':' . $this->ftpgroup;
+
+ // Generate missing SSL files if needed.
+ $this->generateSslFiles();
}
- // Load mysql settings from configuration
- include('config.php');
- $this->set_ehcp_dir(dirname(__FILE__));
- $this->vhostsdir=$this->conf['vhosts'];
-
- // Set variables
- $this->dbhost=$dbhost;
- $this->dbusername=$dbusername;
- $this->dbpass=$dbpass;
- $this->dbname=$dbname;
- $this->conf['mysqlrootpass']=$dbrootpass;
- $this->defaultlanguage=$defaultlanguage;
- $this->isDemo=$isdemo;
- if(!(isset($this->isDemo))) $this->isDemo=False;
- $this->statusActivePassive=array("active"=>"active","passive"=>"passive");
-
- /* Remote Backup Select List Vars */
- $this->remoteBackupMethod=array("ftp"=>"FTP","scp"=>"SCP");
- $this->remoteBackupTime=array("0"=>"00:00","6"=>"06:00","12"=>"12:00","18"=>"18:00");
- $this->remoteDayOfWeek=array("0"=>"Sunday","1"=>"Monday", "2"=>"Tuesday","3"=>"Wednesday","4"=>"Thursday","5"=>"Friday","6"=>"Saturday");
-
- if(isset($this->debuglevel)){
- #....
- }
- $debuglevel=$this->debuglevel; # for outer functions using debuglevel
-
- $this->clientip = getenv ("REMOTE_ADDR");
- if(!validateIpAddress($this->clientip)){
- $this->clientip = "";
- }
- $this->referer = getenv("HTTP_REFERER");
-
- $this->wwwowner=$this->wwwuser.':'.$this->wwwgroup;
- $this->ftpowner=$this->ftpuser.':'.$this->ftpgroup;
-
- // Generate missing SSL files if needed.
- $this->generateSslFiles();
-}
-
-// -------------------- //
+ // -------------------- //
// All other functions //
// -------------------- //
-function run() {
- $this->debugecho("file:".__FILE__.", Line:".__LINE__.", Function:".__FUNCTION__,4,false);
- #$this->serverPlan=new serverPlan();
- # $this->output.=$this->debug();
- global $commandline;
- $this->commandline=$commandline;
- $this->initialize();
- # this is actual application runner, maps urls to functions..
- $this->runOp($this->op);
- $this->show();
-}
-
-function runOp($op){ # these are like url to function mappers... maps op variable to some functions in ehcp; This also can be seen as a controller in MVC model.
- global $id,$domainname,$op2,$_insert;
- $this->getVariable(array('id','domainname','op2','_insert'));
- $op=strtolower($op);
- $otheroperations=array('advancedsettings');
-
-
- switch ($op) {
-
- case 'failedlogins' : return $this->failedlogins();break;
-
- #ssl related:
- case 'adjust_ssl' : return $this->adjust_ssl();break;
- case 'pagerewrite' : return $this->pagerewrite();break;
-
- # other
- case 'activate' : return $this->activate();break;
- case 'settings' : return $this->settings();break;
- case 'adjust_system' : return $this->adjust_system();break;
- case 'redirect_domain' : return $this->redirect_domain();break;
- case 'information' : return $this->information($id);break;
-
- #multi-server operations:
- case 'multiserver_add_domain' : return $this->multiserver_add_domain();break;
-
- case 'new_sync_all' : return $this->new_sync_all();break;
- case 'sync_server_services' : return $this->sync_server_services();break;
- case 'new_sync_domains' : return $this->new_sync_domains();break;
- case 'new_sync_dns' : return $this->new_sync_dns();break;
- case 'multiserver_add_ftp_user_direct': return $this->gui_multiserver_add_ftp_user_direct();break;
-
- #single-server operations:
- case 'bulkaddemail' : return $this->bulkAddEmail();break;
- case 'whitelist' : return $this->whitelist();break;
- case 'fixmailconfiguration' : return $this->fixMailConfiguration();break;
- case 'dofixmailconfiguration' : return $this->addDaemonOp('fixmailconfiguration','','','','fix mail configuration');break;
- case 'dofixapacheconfigssl' : return $this->addDaemonOp('fixApacheConfigSsl','','','','fixApacheConfigSsl');break;
- case 'dofixapacheconfigsslonly' : return $this->addDaemonOp('fixApacheConfigSslOnly','','','','fixApacheConfigSslOnly');break;
- case 'dofixapacheconfignonssl' : return $this->addDaemonOp('fixApacheConfigNonSsl','','','','fixApacheConfigNonSsl');break;
- case 'dofixapacheconfignonssl2' : return $this->addDaemonOp('fixApacheConfigNonSsl2','','','','fixApacheConfigNonSsl2');break;
- case 'rebuild_webserver_configs': return $this->rebuild_webserver_configs();break;
- case 'configure_anon_ftp' : return $this->configure_anon_ftp();break;
-
- case 'updatediskquota' : return $this->updateDiskQuota();break;
- case 'doupdatediskquota' : $this->addDaemonOp('updatediskquota','',$domainname,'','update disk quota');return $this->displayHome();break;
-
- #editing of dns/apache templates for domains, on ehcp db
- case 'editdnstemplate' : return $this->editDnsTemplate();break;
- case 'editapachetemplate' : return $this->editApacheTemplate();break;
- case 'editapachetemplatesubdomain' : return $this->editApacheTemplateSubdomain();break;
- case 'editdomainaliases' : return $this->editDomainAliases();break;
-
- case 'changedomainserverip' : return $this->changedomainserverip();break;
- case 'warnings' : break; # this will be written just before show..
- case 'bulkadddomain' : return $this->bulkaddDomain();break ;
- case 'bulkdeletedomain' : return $this->bulkDeleteDomain();break ;
- case 'exportdomain' : return $this->exportDomain();break;
-
- case 'adddnsonlydomain' : return $this->addDnsOnlyDomain();break;
-
- // Slave DNS
- case 'addslavedns' : return $this->addSlaveDNS();break;
- case 'removeslavedns' : return $this->removeSlaveDNS();break;
-
- // Custom FTP
- case 'addcustomftp' : return $this->addCustomFTP();break;
- case 'removecustomftp' : return $this->removeCustomFTP();break;
- case 'resetallcustomtemplates' : return $this->resetAllCustomTemplates();break;
-
- // Global Website Apache / Nginx Templates
- case 'manageglobalwebtemplates' : return $this->manageGlobalWebTemplates();break;
- case 'getglobalwebtemplate' : return $this->getGlobalWebTemplate();break;
-
- // Is PolicyD installed:
- case 'ispolicydinstalled' : return $this->isPolicyDInstalled();break;
-
- // Get public server settings:
- case 'getpublicserversettings' : return $this->getPublicServerSettings();break;
-
- // Remote backups
- case 'addremotebackup':
- case 'editremotebackup':
- return $this->addRemoteBackup();break;
- case 'removeremotebackup' : return $this->removeRemoteBackup();break;
-
- // Password directories
- case 'addpasswordprotecteddir' : return $this->addPasswordProtectedDir();break;
- case 'rmpasswordprotecteddir' : return $this->rmPasswordProtectedDIR();break;
-
- // Admin defined hosting plans
- case 'addhostingplan' : return $this->addHostingPlan();break;
- case 'removehostingplan' : return $this->removeHostingPlan();break;
-
- // Theming stuff
- case 'updatethemecolor' : $this->updateThemeColor();break;
- case 'updatethemecontrast' : $this->updateThemeContrast();break;
- case 'getmydomainsobject' : $this->getMyDomainsAsObject();break;
-
- // Cronjobs
- case 'addcronjob' : return $this->addCronjob();break;
- case 'removecronjob' : return $this->removeCronjob();break;
-
- // Move domain to another account
- case 'transferdomain':
- case 'movedomaintoanotheraccount':
- return $this->moveDomainToAnotherAccount();break;
-
- case 'adddnsonlydomainwithpaneluser': return $this->addDnsOnlyDomainWithPaneluser();break;
-
- case 'getselfftpaccount' : return $this->getSelfFtpAccount();break;
- case 'adddomaintothispaneluser' : return $this->addDomainToThisPaneluser();break;
-
- case 'dodownloadallscripts' : return $this->doDownloadAllscripts();break;
- case 'choosedomaingonextop' : return $this->chooseDomainGoNextOp();break;
-
- case 'getmysqlserver' : return $this->getMysqlServer();break;
-
- case 'emailforwardingsself' : return $this->emailForwardingsSelf();break;
- case 'addemailforwardingself' : return $this->addEmailForwardingSelf();break;
-
- case 'cmseditpages' : return $this->cmsEditPages();break;
- case 'listservers' : return $this->listServers();break;
- case 'addserver' : return $this->addServer();break;
- case 'addiptothisserver' : return $this->add_ip_to_this_server();break;
- case 'setactiveserverip' : return $this->set_active_server_ip();break;
-
-
- case 'advancedsettings' : return $this->advancedsettings();break;
- case 'delemailforwarding' : return $this->delEmailForwarding();break;
- case 'addemailforwarding' : return $this->addEmailForwarding();break;
- case 'emailforwardings' : return $this->emailForwardings();break;
- case 'addscript' : return $this->addScript();break;
- case 'addnewscript' : return $this->addNewScript();break;
-
- case 'suggestnewscript' : return $this->suggestnewscript();break;
- case 'updateinstallscriptsql' : return $this->updateInstallScriptSQL();break;
- case 'listselectdomain' : return $this->listselectdomain();break;
- case 'selectdomain' : return $this->selectdomain($id);break;
- case 'deselectdomain' : return $this->deselectdomain();break;
- case 'otheroperations' : return $this->otheroperations();break;
-
-
- case 'loadconfig' : return $this->loadConfig();break;
- #case 'showconf' : return $this->showConfig();break;
- case 'changemypass' : return $this->changeMyPass();break;
-
- case 'dostopapache2' : $this->requireAdmin(); return $this->add_daemon_op(array('op'=>'service','info'=>'apache2','info2'=>'stop')); break;
- case 'dostartapache2' : $this->requireAdmin(); return $this->add_daemon_op(array('op'=>'service','info'=>'apache2','info2'=>'start')); break;
- case 'dorestartapache2' : $this->requireAdmin(); return $this->add_daemon_op(array('op'=>'service','info'=>'apache2','info2'=>'restart')); break;
-
- case 'dostopnginx' : $this->requireAdmin(); return $this->add_daemon_op(array('op'=>'service','info'=>'nginx','info2'=>'stop')); break;
- case 'dostartnginx' : $this->requireAdmin(); return $this->add_daemon_op(array('op'=>'service','info'=>'nginx','info2'=>'start')); break;
- case 'dorestartnginx' : $this->requireAdmin(); return $this->add_daemon_op(array('op'=>'service','info'=>'nginx','info2'=>'restart')); break;
-
- case 'dostopphp5fpm' : $this->requireAdmin(); return $this->add_daemon_op(array('op'=>'service','info'=>$this->php_fpm_name,'info2'=>'stop')); break;
- case 'dostartphp5fpm' : $this->requireAdmin(); return $this->add_daemon_op(array('op'=>'service','info'=>$this->php_fpm_name,'info2'=>'start')); break;
- case 'dorestartphp5fpm' : $this->requireAdmin(); return $this->add_daemon_op(array('op'=>'service','info'=>$this->php_fpm_name,'info2'=>'restart')); break;
-
- case 'dostopvsftpd' : $this->requireAdmin(); return $this->add_daemon_op(array('op'=>'service','info'=>'vsftpd','info2'=>'stop')); break;
- case 'dostartvsftpd' : $this->requireAdmin(); return $this->add_daemon_op(array('op'=>'service','info'=>'vsftpd','info2'=>'start')); break;
- case 'dorestartvsftpd' : $this->requireAdmin(); return $this->add_daemon_op(array('op'=>'service','info'=>'vsftpd','info2'=>'restart')); break;
-
- case 'dostopbind' : $this->requireAdmin(); return $this->add_daemon_op(array('op'=>'service','info'=>'bind9','info2'=>'stop')); break;
- case 'dostartbind' : $this->requireAdmin(); return $this->add_daemon_op(array('op'=>'service','info'=>'bind9','info2'=>'start')); break;
- case 'dorestartbind' : $this->requireAdmin(); return $this->add_daemon_op(array('op'=>'service','info'=>'bind9','info2'=>'restart')); break;
-
- case 'dostoppostfix' : $this->requireAdmin(); return $this->add_daemon_op(array('op'=>'service','info'=>'postfix','info2'=>'stop')); break;
- case 'dostartpostfix' : $this->requireAdmin(); return $this->add_daemon_op(array('op'=>'service','info'=>'postfix','info2'=>'start')); break;
- case 'dorestartpostfix' : $this->requireAdmin(); return $this->add_daemon_op(array('op'=>'service','info'=>'postfix','info2'=>'restart')); break;
-
-
- case 'donewsyncdomains' : $this->requireAdmin(); return $this->add_daemon_op(array('op'=>'new_sync_domains')); break;
- case 'donewsyncdns' : $this->requireAdmin(); return $this->add_daemon_op(array('op'=>'new_sync_dns')); break;
-
- case 'dosyncdomains' : $this->requireAdmin(); return $this->addDaemonOp('syncdomains','','','','sync domains');break;
- case 'dosyncdns' : $this->requireAdmin(); return $this->addDaemonOp('syncdns','','','','sync dns');break;
- case 'dosyncftp' : $this->requireAdmin(); return $this->addDaemonOp('syncftp','','','','sync ftp for nonstandard homes');break;
- case 'options' : return $this->options();
-
-
- case 'backups' : return $this->backups();break;
- case 'dobackup' : return $this->doBackup();break;
- case 'dorestore' : return $this->doRestore();break;
- case 'listbackups' : return $this->listBackups();break;
-
- # these sync functions are executed in daemon mode.
- case 'updatehostsfile' : return $this->updateHostsFile();break;
- case 'syncdomains' : return $this->syncDomains();break;
- case 'handlecouriersslcert' : return $this->handleCourierSSLCert();break;
- case 'handlevsftpdsslcert' : return $this->handleVSFTPDSSLCert();break;
- case 'handlepostfixsslcert' : return $this->handlePostfixSSLCert();break;
- case 'resynccourierssl' : return $this->resyncCourierSSL();break;
- case 'resyncvsftpdssl' : return $this->resyncVSFTPDSSL();break;
- case 'resyncpostfixssl' : return $this->resyncPostfixSSL();break;
- case 'syncftp' : return $this->syncFtp();break;
- case 'rebuild_crontab' : return $this->rebuildCrontab();break;
- case 'process_pwd_dirs' : return $this->handlePasswordProtectedDirs();break;
- case 'handle_reset_sites_enabled_default' : return $this->handleResetSitesEnabledDefault();break;
- case 'handle_reset_mainwebserverconf' : return $this->handleResetMainWebServerConf();break;
- case 'process_ssl_certs' : return $this->handleCustomSSLCertsForDomains();break;
- case 'syncdns' : return $this->syncDns();break;
- case 'syncall' : return $this->syncAll();break;
- case 'fixapacheconfigssl' : return $this->fixApacheConfigSsl();break;
- case 'fixapacheconfigsslonly' : return $this->fixApacheConfigSslOnly();break;
- case 'fixapacheconfignonssl' : return $this->fixApacheConfigNonSsl();break;
-
-
- #case 'syncallnew' : return $this->syncallnew();break;
- case 'listdomains' : return $this->listDomains();break; # ayni zamanda domain email userlarini da listeler.
- case 'subdomains' : return $this->subDomains(); break;
- case 'addsubdomain' : return $this->addSubDomain(); break;
- case 'addsubdomainwithftp' : return $this->addSubDomainWithFtp(); break;
- case 'addsubdirectorywithftp' :return $this->addSubDirectoryWithFtp(); break;
-
-
- case 'delsubdomain' : return $this->delSubDomain(); break;
-
-
- case 'editdomain' : return $this->editdomain();
- case 'listpassivedomains' : return $this->listDomains('',$this->passivefilt);break;
- case 'phpinfo' : return $this->phpinfo();break;
- case 'help' : return $this->help();break;
- case 'syncpostfix' : return $this->syncpostfix();break;
- case 'listemailusers' : return $this->listemailusers();break;
- case 'listallemailusers' : return $this->listallemailusers();break;
- case 'listpanelusers' : return $this->listpanelusers();break;
- case 'resellers' : return $this->resellers();break;
-
- case 'deletepaneluser' : return $this->deletepaneluser();break;
-
- case 'operations' : $this->requireAdmin();$this->listTable('operations','operations_table','');break;
-
- case 'listallftpusers' : return $this->listAllFtpUsers();break;
- case 'listftpusersrelatedtodomains': return $this->listAllFtpUsers("domainname<>''");break;
- case 'listftpuserswithoutdomain': return $this->listAllFtpUsers("domainname='' or domainname is null");break;
- case 'listftpusers' : return $this->listftpusers();break;
- case 'sifrehatirlat' : return $this->sifreHatirlat();break;
- case 'todolist' : return $this->todolist();break;
- case 'adddomain' : return $this->addDomain();break;
- case 'adddomaineasy' : return $this->addDomainEasy();break;
- case 'adddomaineasyip' : return $this->addDomainEasyip();break;
- case 'deletedomain' : return $this->deleteDomain();break;
- case 'addemailuser' : return $this->addEmailUser();break;
- case 'addftpuser' : return $this->addFtpUser();break;
- case 'addftptothispaneluser' : return $this->addFtpToThisPaneluser();break;# added in 7.6.2009
- case 'add_ftp_special' : return $this->add_ftp_special();break;
-
- case 'userop' : return $this->userop();break;
- case 'domainop' : return $this->domainop();break;
- case 'addmysqldb' : return $this->addMysqlDb(); break;
- case 'addmysqldbtouser' : return $this->addMysqlDbtoUser(); break;
- case 'addpaneluser' : return $this->addPanelUser();break;
- case 'addpaneluserwithpredefinedplan' : return $this->addPanelUserWithHostingPlan();break;
- case 'editpaneluser' : return $this->editPanelUser();break;
- case 'impersonatepaneluser' : return $this->impersonatePanelUser();break;
- case 'editftpuser' : return $this->editFtpUser();break;
-
- // Domain ordering settings which are no longer used
- // case 'domainsettings' : return $this->domainSettings();break;
-
- case 'logout' : return $this->logout();break;
- case 'daemon' : return $this->daemon();break;
- case 'test' : return $this->test(); break;
- case 'aboutcontactus' : return $this->aboutcontactus();break;
- case 'applyforaccount' : return $this->applyforaccount();break;
- case 'applyfordomainaccount' : return $this->applyfordomainaccount();break;
- case 'setconfigvalue2' : return $this->setConfigValue2($id);break;
- case 'customhttp' : return $this->customHttpSettings();break;
- case 'addcustomhttp' : return $this->addCustomHttp();break;
- case 'deletecustom' : return $this->deleteCustomSetting();break;
- case 'customdns' : return $this->customDnsSettings();break;
- case 'addcustomdns' : return $this->addCustomDns();break;
- case 'dbedituser' : return $this->dbEditUser();break;
- case 'dbadduser' : return $this->dbAddUser();break;
-
- case 'custompermissions' : return $this->custompermissions();break;
- case 'addcustompermission' : return $this->addcustompermission();break;
-
- case 'editemailuser' : # same as below
- case 'editemailuserself' : return $this->editEmailUser();break;
-
- case 'editemailuserautoreplyself':
- case 'editemailuserautoreply' : return $this->editEmailUserAutoreply();break;
-
- case 'editemailuserpasswordself':
- case 'editemailuserpassword' : return $this->editEmailUserPassword();break;
- case 'changetemplate' : return $this->changetemplate();break;
- case 'addredirect' : return $this->addRedirect();break;
- case 'adddomainsslcert' : return $this->addDomainSSLCert();break;
- case 'serverstatus' : return $this->serverStatus();break;
- case 'setlanguage' : $this->setLanguage($id);$this->displayHome();break;
- case 'setdefaultdomain' : $this->setDefaultDomain();$this->displayHome();break;
-
- case 'dologin' : # default anasayfa, same as below:
- case '' : $this->displayHome();break;
-
- # virtual machine (vps) opcodes:
- case 'vps_home' : return $this->call_func_in_module('Vps_Module','vps_home'); break;
- case 'vps' : return $this->call_func_in_module('Vps_Module','vps'); break;
- case 'vps_mountimage' : return $this->call_func_in_module('Vps_Module','vps_mountimage'); break;
- case 'vps_dismountimage' : return $this->call_func_in_module('Vps_Module','vps_dismountimage'); break;
- case 'add_vps' : return $this->call_func_in_module('Vps_Module','add_vps'); break;
-
-
- default : return $this->errorText("Internal EHCP Error - Undefined Operation: $op This feature may not be complete.");break;
-
- }# switch
- return True;
-
-}# func runop
-
-function getWWWUser(){
- return determineFTPUserFromCMD();
-}
-
-function getBindUser(){
- return determineBindUserFromCMD();
-}
-
-function getPHPFPMName(){
- return determinePHPFPMName();
-}
-
-function set_ehcp_dir($dirname){
- # extra variables will be removed later, only one should be used.
- $this->ehcpdir=$dirname;
- $this->mydir=$dirname;
- $this->conf['ehcpdir']=$dirname;
-}
-
-function setInitialMiscConfigOptionDefaultsPostInstall(){
- // Should only really be called once post EHCP installation
- // Don't call this function more than once or config values could be reset.
- $success = $this->setConfigValue('disableeditapachetemplate','Yes'); // Prevent apache2 template modifications by non-admin users...
- $success2 = $this->setConfigValue('disableeditdnstemplate','Yes'); // Prevent dns template modifications by non-admin users...
- $success3 = $this->setConfigValue('forcedeletesubdomainfiles','Yes'); // Delete files under subdomain home directory when subdomain is deleted by default
- $success4 = $this->setConfigValue('useglobalsslcert','Yes'); // Use invalid system default global https cert for SSL sites by default
- $success5 = $this->setConfigValue('enablewildcarddomain','Yes'); // Use wildcard domains and DNS
- $success6 = $this->setConfigValue('allowcustomsslnonadmin','Yes'); // Use wildcard domains and DNS
-
- return $success && $success2 && $success3 && $success4 && $success5 && $success6;
-}
-
-function initialize(){
- # burda herhangi class initialization yapilacak.. basta yapilacak isler..
- global $commandline,$ehcpversion;
- #if(!$commandline)$this->output.="".$this->appname."
";
- $this->myversion=$ehcpversion;
-
- if(isset($this->op) && !empty($this->op)){
- $this->op = removeInvalidChars($this->op, "lettersandnumbers");
+ function run()
+ {
+ $this->debugecho("file:" . __FILE__ . ", Line:" . __LINE__ . ", Function:" . __FUNCTION__, 4, false);
+ #$this->serverPlan=new serverPlan();
+ # $this->output.=$this->debug();
+ global $commandline;
+ $this->commandline = $commandline;
+ $this->initialize();
+ # this is actual application runner, maps urls to functions..
+ $this->runOp($this->op);
+ $this->show();
}
- $this->connectTodb();
- $this->debugecho("file:".__FILE__.", Line:".__LINE__.", Function:".__FUNCTION__,4,false);
- $this->syncConfigs();
+ function runOp($op)
+ { # these are like url to function mappers... maps op variable to some functions in ehcp; This also can be seen as a controller in MVC model.
+ global $id, $domainname, $op2, $_insert;
+ $this->getVariable(array('id', 'domainname', 'op2', '_insert'));
+ $op = strtolower($op);
+ $otheroperations = array('advancedsettings');
- $this->passivefilt="status<>'".$this->status_active."' or status is null";
- $this->activefilt="status='".$this->status_active."'";
- $this->loadLanguage(); # load default en to handle errors in loadconfig,
- $this->checkInstall();
- $this->loadConfig();
-
- if(!$this->isNoPassOp() and $this->requirePassword ) $this->securitycheck();
- $this->loadLanguage(); # load again to activate actual lang in config.
- if($this->isadmin()) {
- $this->globalfilter=''; # burasi, securitycheck den sonra olmali. isadmin yoksa calismaz.
- } else $this->globalfilter="(reseller='".$this->activeuser."' or panelusername='".$this->activeuser."')";
+ switch ($op) {
- if(!$this->isadmin()) {
- $userinfo=$this->query("select * from ".$this->conf['paneluserstable']['tablename']." where panelusername='$this->activeuser'", "dologin2");
- $this->userinfo=$userinfo[0];
- if($this->userinfo['maxpanelusers']>0) $this->isreseller=True;
- }
-
- $this->loadServerPlan();
-
- $HTTPMode = $this->EHCPIsUsingHTTPS() ? "https://" : "http://";
- $this->url = $HTTPMode . $this->conf['dnsip'] . $_SERVER['REQUEST_URI'];
-
- if($this->isloggedin) $this->output.=$this->check_failed_logins();
- if($commandline) $this->echoln("Finished initialize");
- #$this->check_mysql_connection();
-}
-
-function counter_reached($counter,$count){
- # can be used to count something...
- if(intval($this->miscconfig[$counter])>0) {
- $nextval=intval($this->miscconfig[$counter])-1;
- $this->setConfigValue($counter,$nextval);
- return False; # check sometime,
- }
- $this->setConfigValue($counter,$count);
- return True;
-}
-
-function check_ehcp_version(){
- global $ehcpversion;
- if($this->latest_version<>'') return; # check once
- if(!$this->counter_reached('versionwarningcounter',20)) return False; # check 20 login later again.
-
- $this->latest_version=trim(@file_get_contents("http://www.ehcpforce.tk/latest_version.txt"));
- if($this->latest_version<>'' and $this->latest_version<>$ehcpversion) {
- $str="Your EHCP Force Edition version ($ehcpversion) is different than the latest version ($this->latest_version). Either your EHCP Force Edition installation is old, or you are using a new beta/test version. Check here for updates!";
- $this->warnings.=$str;
- $this->infotoadminemail($str,"Version Warning for ".$this->dnsip,false);
- }
-}
-
-function loadServerPlan(){
- $this->singleserverip=$this->conf['dnsip']; # if there is only one server...
- #$this->output.=__FUNCTION__.":".$this->singleserverip." ";
- # more servers will be coded here...
-}
-
-function load_module($name){
- if(!defined($name.'_file_loaded')) {
- $this->echoln2(__FUNCTION__.": Sory, that module file not loaded yet. check code. (php autoload does not work with CLI)");
- return False;
- }
- if(gettype($this->$name)<>'object') $this->$name=new $name($this,$name); # initialize new module, only if not done before.
- return True;
-}
-
-function call_func_in_module($name,$func,$params=Null){
- if(!$this->load_module($name)) return False;
-
- if($params==Null) return $this->$name->$func(); # a function with no args
- else return $this->$name->$func($params); # a func with named arguments (named array), as used in many parts of this file
-}
-
-function check_module_tables(){
- # to be coded later.
-}
-
-function activate(){
- $alanlar=array('panelusername','code','newpass');
- foreach($alanlar as $al) global $$al;
- $degerler=$this->getVariable($alanlar);
-
- if($panelusername) {
- $info=$this->getPanelUserInfo('',$panelusername);
- $email=$info['email'];
- if($email=='') return;
- }
-
-
- if(!$panelusername){
- $this->output.=inputform5(array(
- array('panelusername', 'lefttext'=>'Panel Username:')
-
- ));
- } elseif($panelusername and !$code) {
- $hash=get_rand_id(10);
- $r=$this->executeQuery("insert into hash (email,hash)values('$email','$hash')");
- $msg="Dear EHCP Force User,
Your EHCP activation code is: $hash";
- $this->sendEmail($email, "EHCP Activation Code", $msg);
- $this->output.="An activation code was sent to your email address of $email. Please insert this code now: ".inputform5(array(
- array('panelusername', 'lefttext'=>'Panel Username:'),
- array('code', 'lefttext'=>'Code:'),
- array('newpass', 'lefttext'=>'New Password:')
- ));
- } elseif($panelusername and $code) {
- $filt3="email='$email' and hash='$hash'";
- $sayi=$this->recordcount("hash",$filt3);
- if($sayi==0) $this->errorTextExit("Invalid activation information received. Please verify the activation code that was sent to your email.");
-
- if($this->conf['logintable']['passwordfunction']==''){
- $set="'$newpass'";
- } else {
- $set=$this->conf['logintable']['passwordfunction']."('$newpass')";
- }
-
- $this->executeQuery("update panelusers set status='active',{$this->conf['logintable']['passwordfield']}=$set where status='passive' and panelusername='$panelusername'");
- }
-
-}
-
-function pagerewrite(){
- global $op2,$_insert;
- $domainname=$this->chooseDomain(__FUNCTION__,$domainname);
- $this->output.="This function is being tested with nginx only ";
-
- $alanlar=array('frompage','topage','redirecttype');
- foreach($alanlar as $al) global $$al;
- $degerler=$this->getVariable($alanlar);
-
- $table=$this->conf['customstable'];
-
-
- if($op2=='add') {
-
- if($_insert){
- switch($this->miscconfig['webservertype']) {
- case 'nginx':
- if($redirecttype=='exactmatch') $val="rewrite ^($frompage)\$ $topage break; \n";
- else $val="rewrite $frompage $topage break; \n";
+ case 'failedlogins':
+ return $this->failedlogins();
break;
-
- #case 'apache2:
- default: $this->errorTextExit("Your webserver does not support changing the EHCP GUI directory: ".$this->miscconfig['webservertype']);
- }
-
- #$q="insert into customsettings (panelusername,domainname,name,`value`,webservertype) values ('$this->activeuser','$domainname','pagerewrite','$val','".$this->miscconfig['webservertype']."')";
- #if($this->executeQuery($q)) $this->output.="Ekleme tamam - OK";
- $this->addCustomHttpDirect($domainname,$val,"pagerewrite");
-
- }else{
- $alanlar=array(array('frompage','righttext'=>''),array('topage'),array('redirecttype','radio','secenekler'=>array('exactmatch'=>'Exact Match Ex: frompage: /basvuru topage: /en/basvuru.html','partialmatch'=>'Partial Match, nginx style, examples')));
- $this->output.=inputform5($alanlar);
+
+ #ssl related:
+ case 'adjust_ssl':
+ return $this->adjust_ssl();
+ break;
+ case 'pagerewrite':
+ return $this->pagerewrite();
+ break;
+
+ # other
+ case 'activate':
+ return $this->activate();
+ break;
+ case 'settings':
+ return $this->settings();
+ break;
+ case 'adjust_system':
+ return $this->adjust_system();
+ break;
+ case 'redirect_domain':
+ return $this->redirect_domain();
+ break;
+ case 'information':
+ return $this->information($id);
+ break;
+
+ #multi-server operations:
+ case 'multiserver_add_domain':
+ return $this->multiserver_add_domain();
+ break;
+
+ case 'new_sync_all':
+ return $this->new_sync_all();
+ break;
+ case 'sync_server_services':
+ return $this->sync_server_services();
+ break;
+ case 'new_sync_domains':
+ return $this->new_sync_domains();
+ break;
+ case 'new_sync_dns':
+ return $this->new_sync_dns();
+ break;
+ case 'multiserver_add_ftp_user_direct':
+ return $this->gui_multiserver_add_ftp_user_direct();
+ break;
+
+ #single-server operations:
+ case 'bulkaddemail':
+ return $this->bulkAddEmail();
+ break;
+ case 'whitelist':
+ return $this->whitelist();
+ break;
+ case 'fixmailconfiguration':
+ return $this->fixMailConfiguration();
+ break;
+ case 'dofixmailconfiguration':
+ return $this->addDaemonOp('fixmailconfiguration', '', '', '', 'fix mail configuration');
+ break;
+ case 'dofixapacheconfigssl':
+ return $this->addDaemonOp('fixApacheConfigSsl', '', '', '', 'fixApacheConfigSsl');
+ break;
+ case 'dofixapacheconfigsslonly':
+ return $this->addDaemonOp('fixApacheConfigSslOnly', '', '', '', 'fixApacheConfigSslOnly');
+ break;
+ case 'dofixapacheconfignonssl':
+ return $this->addDaemonOp('fixApacheConfigNonSsl', '', '', '', 'fixApacheConfigNonSsl');
+ break;
+ case 'dofixapacheconfignonssl2':
+ return $this->addDaemonOp('fixApacheConfigNonSsl2', '', '', '', 'fixApacheConfigNonSsl2');
+ break;
+ case 'rebuild_webserver_configs':
+ return $this->rebuild_webserver_configs();
+ break;
+ case 'configure_anon_ftp':
+ return $this->configure_anon_ftp();
+ break;
+
+ case 'updatediskquota':
+ return $this->updateDiskQuota();
+ break;
+ case 'doupdatediskquota':
+ $this->addDaemonOp('updatediskquota', '', $domainname, '', 'update disk quota');
+ return $this->displayHome();
+ break;
+
+ #editing of dns/apache templates for domains, on ehcp db
+ case 'editdnstemplate':
+ return $this->editDnsTemplate();
+ break;
+ case 'editapachetemplate':
+ return $this->editApacheTemplate();
+ break;
+ case 'editapachetemplatesubdomain':
+ return $this->editApacheTemplateSubdomain();
+ break;
+ case 'editdomainaliases':
+ return $this->editDomainAliases();
+ break;
+
+ case 'changedomainserverip':
+ return $this->changedomainserverip();
+ break;
+ case 'warnings':
+ break; # this will be written just before show..
+ case 'bulkadddomain':
+ return $this->bulkaddDomain();
+ break;
+ case 'bulkdeletedomain':
+ return $this->bulkDeleteDomain();
+ break;
+ case 'exportdomain':
+ return $this->exportDomain();
+ break;
+
+ case 'adddnsonlydomain':
+ return $this->addDnsOnlyDomain();
+ break;
+
+ // Slave DNS
+ case 'addslavedns':
+ return $this->addSlaveDNS();
+ break;
+ case 'removeslavedns':
+ return $this->removeSlaveDNS();
+ break;
+
+ // Custom FTP
+ case 'addcustomftp':
+ return $this->addCustomFTP();
+ break;
+ case 'removecustomftp':
+ return $this->removeCustomFTP();
+ break;
+ case 'resetallcustomtemplates':
+ return $this->resetAllCustomTemplates();
+ break;
+
+ // Global Website Apache / Nginx Templates
+ case 'manageglobalwebtemplates':
+ return $this->manageGlobalWebTemplates();
+ break;
+ case 'getglobalwebtemplate':
+ return $this->getGlobalWebTemplate();
+ break;
+
+ // Is PolicyD installed:
+ case 'ispolicydinstalled':
+ return $this->isPolicyDInstalled();
+ break;
+
+ // Get public server settings:
+ case 'getpublicserversettings':
+ return $this->getPublicServerSettings();
+ break;
+
+ // Remote backups
+ case 'addremotebackup':
+ case 'editremotebackup':
+ return $this->addRemoteBackup();
+ break;
+ case 'removeremotebackup':
+ return $this->removeRemoteBackup();
+ break;
+
+ // Password directories
+ case 'addpasswordprotecteddir':
+ return $this->addPasswordProtectedDir();
+ break;
+ case 'rmpasswordprotecteddir':
+ return $this->rmPasswordProtectedDIR();
+ break;
+
+ // Admin defined hosting plans
+ case 'addhostingplan':
+ return $this->addHostingPlan();
+ break;
+ case 'removehostingplan':
+ return $this->removeHostingPlan();
+ break;
+
+ // Theming stuff
+ case 'updatethemecolor':
+ $this->updateThemeColor();
+ break;
+ case 'updatethemecontrast':
+ $this->updateThemeContrast();
+ break;
+ case 'getmydomainsobject':
+ $this->getMyDomainsAsObject();
+ break;
+
+ // Cronjobs
+ case 'addcronjob':
+ return $this->addCronjob();
+ break;
+ case 'removecronjob':
+ return $this->removeCronjob();
+ break;
+
+ // Move domain to another account
+ case 'transferdomain':
+ case 'movedomaintoanotheraccount':
+ return $this->moveDomainToAnotherAccount();
+ break;
+
+ case 'adddnsonlydomainwithpaneluser':
+ return $this->addDnsOnlyDomainWithPaneluser();
+ break;
+
+ case 'getselfftpaccount':
+ return $this->getSelfFtpAccount();
+ break;
+ case 'adddomaintothispaneluser':
+ return $this->addDomainToThisPaneluser();
+ break;
+
+ case 'dodownloadallscripts':
+ return $this->doDownloadAllscripts();
+ break;
+ case 'choosedomaingonextop':
+ return $this->chooseDomainGoNextOp();
+ break;
+
+ case 'getmysqlserver':
+ return $this->getMysqlServer();
+ break;
+
+ case 'emailforwardingsself':
+ return $this->emailForwardingsSelf();
+ break;
+ case 'addemailforwardingself':
+ return $this->addEmailForwardingSelf();
+ break;
+
+ case 'cmseditpages':
+ return $this->cmsEditPages();
+ break;
+ case 'listservers':
+ return $this->listServers();
+ break;
+ case 'addserver':
+ return $this->addServer();
+ break;
+ case 'addiptothisserver':
+ return $this->add_ip_to_this_server();
+ break;
+ case 'setactiveserverip':
+ return $this->set_active_server_ip();
+ break;
+
+
+ case 'advancedsettings':
+ return $this->advancedsettings();
+ break;
+ case 'delemailforwarding':
+ return $this->delEmailForwarding();
+ break;
+ case 'addemailforwarding':
+ return $this->addEmailForwarding();
+ break;
+ case 'emailforwardings':
+ return $this->emailForwardings();
+ break;
+ case 'addscript':
+ return $this->addScript();
+ break;
+ case 'addnewscript':
+ return $this->addNewScript();
+ break;
+
+ case 'suggestnewscript':
+ return $this->suggestnewscript();
+ break;
+ case 'updateinstallscriptsql':
+ return $this->updateInstallScriptSQL();
+ break;
+ case 'listselectdomain':
+ return $this->listselectdomain();
+ break;
+ case 'selectdomain':
+ return $this->selectdomain($id);
+ break;
+ case 'deselectdomain':
+ return $this->deselectdomain();
+ break;
+ case 'otheroperations':
+ return $this->otheroperations();
+ break;
+
+
+ case 'loadconfig':
+ return $this->loadConfig();
+ break;
+ #case 'showconf' : return $this->showConfig();break;
+ case 'changemypass':
+ return $this->changeMyPass();
+ break;
+
+ case 'dostopapache2':
+ $this->requireAdmin();
+ return $this->add_daemon_op(array('op' => 'service', 'info' => 'apache2', 'info2' => 'stop'));
+ break;
+ case 'dostartapache2':
+ $this->requireAdmin();
+ return $this->add_daemon_op(array('op' => 'service', 'info' => 'apache2', 'info2' => 'start'));
+ break;
+ case 'dorestartapache2':
+ $this->requireAdmin();
+ return $this->add_daemon_op(array('op' => 'service', 'info' => 'apache2', 'info2' => 'restart'));
+ break;
+
+ case 'dostopnginx':
+ $this->requireAdmin();
+ return $this->add_daemon_op(array('op' => 'service', 'info' => 'nginx', 'info2' => 'stop'));
+ break;
+ case 'dostartnginx':
+ $this->requireAdmin();
+ return $this->add_daemon_op(array('op' => 'service', 'info' => 'nginx', 'info2' => 'start'));
+ break;
+ case 'dorestartnginx':
+ $this->requireAdmin();
+ return $this->add_daemon_op(array('op' => 'service', 'info' => 'nginx', 'info2' => 'restart'));
+ break;
+
+ case 'dostopphp5fpm':
+ $this->requireAdmin();
+ return $this->add_daemon_op(array('op' => 'service', 'info' => $this->php_fpm_name, 'info2' => 'stop'));
+ break;
+ case 'dostartphp5fpm':
+ $this->requireAdmin();
+ return $this->add_daemon_op(array('op' => 'service', 'info' => $this->php_fpm_name, 'info2' => 'start'));
+ break;
+ case 'dorestartphp5fpm':
+ $this->requireAdmin();
+ return $this->add_daemon_op(array('op' => 'service', 'info' => $this->php_fpm_name, 'info2' => 'restart'));
+ break;
+
+ case 'dostopvsftpd':
+ $this->requireAdmin();
+ return $this->add_daemon_op(array('op' => 'service', 'info' => 'vsftpd', 'info2' => 'stop'));
+ break;
+ case 'dostartvsftpd':
+ $this->requireAdmin();
+ return $this->add_daemon_op(array('op' => 'service', 'info' => 'vsftpd', 'info2' => 'start'));
+ break;
+ case 'dorestartvsftpd':
+ $this->requireAdmin();
+ return $this->add_daemon_op(array('op' => 'service', 'info' => 'vsftpd', 'info2' => 'restart'));
+ break;
+
+ case 'dostopbind':
+ $this->requireAdmin();
+ return $this->add_daemon_op(array('op' => 'service', 'info' => 'bind9', 'info2' => 'stop'));
+ break;
+ case 'dostartbind':
+ $this->requireAdmin();
+ return $this->add_daemon_op(array('op' => 'service', 'info' => 'bind9', 'info2' => 'start'));
+ break;
+ case 'dorestartbind':
+ $this->requireAdmin();
+ return $this->add_daemon_op(array('op' => 'service', 'info' => 'bind9', 'info2' => 'restart'));
+ break;
+
+ case 'dostoppostfix':
+ $this->requireAdmin();
+ return $this->add_daemon_op(array('op' => 'service', 'info' => 'postfix', 'info2' => 'stop'));
+ break;
+ case 'dostartpostfix':
+ $this->requireAdmin();
+ return $this->add_daemon_op(array('op' => 'service', 'info' => 'postfix', 'info2' => 'start'));
+ break;
+ case 'dorestartpostfix':
+ $this->requireAdmin();
+ return $this->add_daemon_op(array('op' => 'service', 'info' => 'postfix', 'info2' => 'restart'));
+ break;
+
+
+ case 'donewsyncdomains':
+ $this->requireAdmin();
+ return $this->add_daemon_op(array('op' => 'new_sync_domains'));
+ break;
+ case 'donewsyncdns':
+ $this->requireAdmin();
+ return $this->add_daemon_op(array('op' => 'new_sync_dns'));
+ break;
+
+ case 'dosyncdomains':
+ $this->requireAdmin();
+ return $this->addDaemonOp('syncdomains', '', '', '', 'sync domains');
+ break;
+ case 'dosyncdns':
+ $this->requireAdmin();
+ return $this->addDaemonOp('syncdns', '', '', '', 'sync dns');
+ break;
+ case 'dosyncftp':
+ $this->requireAdmin();
+ return $this->addDaemonOp('syncftp', '', '', '', 'sync ftp for nonstandard homes');
+ break;
+ case 'options':
+ return $this->options();
+
+
+ case 'backups':
+ return $this->backups();
+ break;
+ case 'dobackup':
+ return $this->doBackup();
+ break;
+ case 'dorestore':
+ return $this->doRestore();
+ break;
+ case 'listbackups':
+ return $this->listBackups();
+ break;
+
+ # these sync functions are executed in daemon mode.
+ case 'updatehostsfile':
+ return $this->updateHostsFile();
+ break;
+ case 'syncdomains':
+ return $this->syncDomains();
+ break;
+ case 'handlecouriersslcert':
+ return $this->handleCourierSSLCert();
+ break;
+ case 'handlevsftpdsslcert':
+ return $this->handleVSFTPDSSLCert();
+ break;
+ case 'handlepostfixsslcert':
+ return $this->handlePostfixSSLCert();
+ break;
+ case 'resynccourierssl':
+ return $this->resyncCourierSSL();
+ break;
+ case 'resyncvsftpdssl':
+ return $this->resyncVSFTPDSSL();
+ break;
+ case 'resyncpostfixssl':
+ return $this->resyncPostfixSSL();
+ break;
+ case 'syncftp':
+ return $this->syncFtp();
+ break;
+ case 'rebuild_crontab':
+ return $this->rebuildCrontab();
+ break;
+ case 'process_pwd_dirs':
+ return $this->handlePasswordProtectedDirs();
+ break;
+ case 'handle_reset_sites_enabled_default':
+ return $this->handleResetSitesEnabledDefault();
+ break;
+ case 'handle_reset_mainwebserverconf':
+ return $this->handleResetMainWebServerConf();
+ break;
+ case 'process_ssl_certs':
+ return $this->handleCustomSSLCertsForDomains();
+ break;
+ case 'syncdns':
+ return $this->syncDns();
+ break;
+ case 'syncall':
+ return $this->syncAll();
+ break;
+ case 'fixapacheconfigssl':
+ return $this->fixApacheConfigSsl();
+ break;
+ case 'fixapacheconfigsslonly':
+ return $this->fixApacheConfigSslOnly();
+ break;
+ case 'fixapacheconfignonssl':
+ return $this->fixApacheConfigNonSsl();
+ break;
+
+
+ #case 'syncallnew' : return $this->syncallnew();break;
+ case 'listdomains':
+ return $this->listDomains();
+ break; # ayni zamanda domain email userlarini da listeler.
+ case 'subdomains':
+ return $this->subDomains();
+ break;
+ case 'addsubdomain':
+ return $this->addSubDomain();
+ break;
+ case 'addsubdomainwithftp':
+ return $this->addSubDomainWithFtp();
+ break;
+ case 'addsubdirectorywithftp':
+ return $this->addSubDirectoryWithFtp();
+ break;
+
+
+ case 'delsubdomain':
+ return $this->delSubDomain();
+ break;
+
+
+ case 'editdomain':
+ return $this->editdomain();
+ case 'listpassivedomains':
+ return $this->listDomains('', $this->passivefilt);
+ break;
+ case 'phpinfo':
+ return $this->phpinfo();
+ break;
+ case 'help':
+ return $this->help();
+ break;
+ case 'syncpostfix':
+ return $this->syncpostfix();
+ break;
+ case 'listemailusers':
+ return $this->listemailusers();
+ break;
+ case 'listallemailusers':
+ return $this->listallemailusers();
+ break;
+ case 'listpanelusers':
+ return $this->listpanelusers();
+ break;
+ case 'resellers':
+ return $this->resellers();
+ break;
+
+ case 'deletepaneluser':
+ return $this->deletepaneluser();
+ break;
+
+ case 'operations':
+ $this->requireAdmin();
+ $this->listTable('operations', 'operations_table', '');
+ break;
+
+ case 'listallftpusers':
+ return $this->listAllFtpUsers();
+ break;
+ case 'listftpusersrelatedtodomains':
+ return $this->listAllFtpUsers("domainname<>''");
+ break;
+ case 'listftpuserswithoutdomain':
+ return $this->listAllFtpUsers("domainname='' or domainname is null");
+ break;
+ case 'listftpusers':
+ return $this->listftpusers();
+ break;
+ case 'sifrehatirlat':
+ return $this->sifreHatirlat();
+ break;
+ case 'todolist':
+ return $this->todolist();
+ break;
+ case 'adddomain':
+ return $this->addDomain();
+ break;
+ case 'adddomaineasy':
+ return $this->addDomainEasy();
+ break;
+ case 'adddomaineasyip':
+ return $this->addDomainEasyip();
+ break;
+ case 'deletedomain':
+ return $this->deleteDomain();
+ break;
+ case 'addemailuser':
+ return $this->addEmailUser();
+ break;
+ case 'addftpuser':
+ return $this->addFtpUser();
+ break;
+ case 'addftptothispaneluser':
+ return $this->addFtpToThisPaneluser();
+ break; # added in 7.6.2009
+ case 'add_ftp_special':
+ return $this->add_ftp_special();
+ break;
+
+ case 'userop':
+ return $this->userop();
+ break;
+ case 'domainop':
+ return $this->domainop();
+ break;
+ case 'addmysqldb':
+ return $this->addMysqlDb();
+ break;
+ case 'addmysqldbtouser':
+ return $this->addMysqlDbtoUser();
+ break;
+ case 'addpaneluser':
+ return $this->addPanelUser();
+ break;
+ case 'addpaneluserwithpredefinedplan':
+ return $this->addPanelUserWithHostingPlan();
+ break;
+ case 'editpaneluser':
+ return $this->editPanelUser();
+ break;
+ case 'impersonatepaneluser':
+ return $this->impersonatePanelUser();
+ break;
+ case 'editftpuser':
+ return $this->editFtpUser();
+ break;
+
+ // Domain ordering settings which are no longer used
+ // case 'domainsettings' : return $this->domainSettings();break;
+
+ case 'logout':
+ return $this->logout();
+ break;
+ case 'daemon':
+ return $this->daemon();
+ break;
+ case 'test':
+ return $this->test();
+ break;
+ case 'aboutcontactus':
+ return $this->aboutcontactus();
+ break;
+ case 'applyforaccount':
+ return $this->applyforaccount();
+ break;
+ case 'applyfordomainaccount':
+ return $this->applyfordomainaccount();
+ break;
+ case 'setconfigvalue2':
+ return $this->setConfigValue2($id);
+ break;
+ case 'customhttp':
+ return $this->customHttpSettings();
+ break;
+ case 'addcustomhttp':
+ return $this->addCustomHttp();
+ break;
+ case 'deletecustom':
+ return $this->deleteCustomSetting();
+ break;
+ case 'customdns':
+ return $this->customDnsSettings();
+ break;
+ case 'addcustomdns':
+ return $this->addCustomDns();
+ break;
+ case 'dbedituser':
+ return $this->dbEditUser();
+ break;
+ case 'dbadduser':
+ return $this->dbAddUser();
+ break;
+
+ case 'custompermissions':
+ return $this->custompermissions();
+ break;
+ case 'addcustompermission':
+ return $this->addcustompermission();
+ break;
+
+ case 'editemailuser': # same as below
+ case 'editemailuserself':
+ return $this->editEmailUser();
+ break;
+
+ case 'editemailuserautoreplyself':
+ case 'editemailuserautoreply':
+ return $this->editEmailUserAutoreply();
+ break;
+
+ case 'editemailuserpasswordself':
+ case 'editemailuserpassword':
+ return $this->editEmailUserPassword();
+ break;
+ case 'changetemplate':
+ return $this->changetemplate();
+ break;
+ case 'addredirect':
+ return $this->addRedirect();
+ break;
+ case 'adddomainsslcert':
+ return $this->addDomainSSLCert();
+ break;
+ case 'serverstatus':
+ return $this->serverStatus();
+ break;
+ case 'setlanguage':
+ $this->setLanguage($id);
+ $this->displayHome();
+ break;
+ case 'setdefaultdomain':
+ $this->setDefaultDomain();
+ $this->displayHome();
+ break;
+
+ case 'dologin': # default anasayfa, same as below:
+ case '':
+ $this->displayHome();
+ break;
+
+ # virtual machine (vps) opcodes:
+ case 'vps_home':
+ return $this->call_func_in_module('Vps_Module', 'vps_home');
+ break;
+ case 'vps':
+ return $this->call_func_in_module('Vps_Module', 'vps');
+ break;
+ case 'vps_mountimage':
+ return $this->call_func_in_module('Vps_Module', 'vps_mountimage');
+ break;
+ case 'vps_dismountimage':
+ return $this->call_func_in_module('Vps_Module', 'vps_dismountimage');
+ break;
+ case 'add_vps':
+ return $this->call_func_in_module('Vps_Module', 'add_vps');
+ break;
+
+
+ default:
+ return $this->errorText("Internal EHCP Error - Undefined Operation: $op This feature may not be complete.");
+ break;
+
+ } # switch
+ return True;
+
+ } # func runop
+
+ function getWWWUser()
+ {
+ return determineFTPUserFromCMD();
+ }
+
+ function getBindUser()
+ {
+ return determineBindUserFromCMD();
+ }
+
+ function getPHPFPMName()
+ {
+ return determinePHPFPMName();
+ }
+
+ function set_ehcp_dir($dirname)
+ {
+ # extra variables will be removed later, only one should be used.
+ $this->ehcpdir = $dirname;
+ $this->mydir = $dirname;
+ $this->conf['ehcpdir'] = $dirname;
+ }
+
+ function setInitialMiscConfigOptionDefaultsPostInstall()
+ {
+ // Should only really be called once post EHCP installation
+ // Don't call this function more than once or config values could be reset.
+ $success = $this->setConfigValue('disableeditapachetemplate', 'Yes'); // Prevent apache2 template modifications by non-admin users...
+ $success2 = $this->setConfigValue('disableeditdnstemplate', 'Yes'); // Prevent dns template modifications by non-admin users...
+ $success3 = $this->setConfigValue('forcedeletesubdomainfiles', 'Yes'); // Delete files under subdomain home directory when subdomain is deleted by default
+ $success4 = $this->setConfigValue('useglobalsslcert', 'Yes'); // Use invalid system default global https cert for SSL sites by default
+ $success5 = $this->setConfigValue('enablewildcarddomain', 'Yes'); // Use wildcard domains and DNS
+ $success6 = $this->setConfigValue('allowcustomsslnonadmin', 'Yes'); // Use wildcard domains and DNS
+
+ return $success && $success2 && $success3 && $success4 && $success5 && $success6;
+ }
+
+ function initialize()
+ {
+ # burda herhangi class initialization yapilacak.. basta yapilacak isler..
+ global $commandline, $ehcpversion;
+ #if(!$commandline)$this->output.="".$this->appname."
";
+ $this->myversion = $ehcpversion;
+
+ if (isset($this->op) && !empty($this->op)) {
+ $this->op = removeInvalidChars($this->op, "lettersandnumbers");
}
- $this->output.="nginx, For partial, examples:
+
+ $this->connectTodb();
+ $this->debugecho("file:" . __FILE__ . ", Line:" . __LINE__ . ", Function:" . __FUNCTION__, 4, false);
+ $this->syncConfigs();
+
+ $this->passivefilt = "status<>'" . $this->status_active . "' or status is null";
+ $this->activefilt = "status='" . $this->status_active . "'";
+ $this->loadLanguage(); # load default en to handle errors in loadconfig,
+ $this->checkInstall();
+ $this->loadConfig();
+
+ if (!$this->isNoPassOp() and $this->requirePassword)
+ $this->securitycheck();
+ $this->loadLanguage(); # load again to activate actual lang in config.
+
+ if ($this->isadmin()) {
+ $this->globalfilter = ''; # burasi, securitycheck den sonra olmali. isadmin yoksa calismaz.
+ } else
+ $this->globalfilter = "(reseller='" . $this->activeuser . "' or panelusername='" . $this->activeuser . "')";
+
+ if (!$this->isadmin()) {
+ $userinfo = $this->query("select * from " . $this->conf['paneluserstable']['tablename'] . " where panelusername='$this->activeuser'", "dologin2");
+ $this->userinfo = $userinfo[0];
+ if ($this->userinfo['maxpanelusers'] > 0)
+ $this->isreseller = True;
+ }
+
+ $this->loadServerPlan();
+
+ $HTTPMode = $this->EHCPIsUsingHTTPS() ? "https://" : "http://";
+ $this->url = $HTTPMode . $this->conf['dnsip'] . $_SERVER['REQUEST_URI'];
+
+ if ($this->isloggedin)
+ $this->output .= $this->check_failed_logins();
+ if ($commandline)
+ $this->echoln("Finished initialize");
+ #$this->check_mysql_connection();
+ }
+
+ function counter_reached($counter, $count)
+ {
+ # can be used to count something...
+ if (intval($this->miscconfig[$counter]) > 0) {
+ $nextval = intval($this->miscconfig[$counter]) - 1;
+ $this->setConfigValue($counter, $nextval);
+ return False; # check sometime,
+ }
+ $this->setConfigValue($counter, $count);
+ return True;
+ }
+
+ function check_ehcp_version()
+ {
+ global $ehcpversion;
+ if ($this->latest_version <> '')
+ return; # check once
+ if (!$this->counter_reached('versionwarningcounter', 20))
+ return False; # check 20 login later again.
+
+ $this->latest_version = trim(@file_get_contents("http://www.ehcpforce.tk/latest_version.txt"));
+ if ($this->latest_version <> '' and $this->latest_version <> $ehcpversion) {
+ $str = "Your EHCP Force Edition version ($ehcpversion) is different than the latest version ($this->latest_version). Either your EHCP Force Edition installation is old, or you are using a new beta/test version. Check here for updates!";
+ $this->warnings .= $str;
+ $this->infotoadminemail($str, "Version Warning for " . $this->dnsip, false);
+ }
+ }
+
+ function loadServerPlan()
+ {
+ $this->singleserverip = $this->conf['dnsip']; # if there is only one server...
+ #$this->output.=__FUNCTION__.":".$this->singleserverip." ";
+ # more servers will be coded here...
+ }
+
+ function load_module($name)
+ {
+ if (!defined($name . '_file_loaded')) {
+ $this->echoln2(__FUNCTION__ . ": Sory, that module file not loaded yet. check code. (php autoload does not work with CLI)");
+ return False;
+ }
+ if (gettype($this->$name) <> 'object')
+ $this->$name = new $name($this, $name); # initialize new module, only if not done before.
+ return True;
+ }
+
+ function call_func_in_module($name, $func, $params = Null)
+ {
+ if (!$this->load_module($name))
+ return False;
+
+ if ($params == Null)
+ return $this->$name->$func(); # a function with no args
+ else
+ return $this->$name->$func($params); # a func with named arguments (named array), as used in many parts of this file
+ }
+
+ function check_module_tables()
+ {
+ # to be coded later.
+ }
+
+ function activate()
+ {
+ $alanlar = array('panelusername', 'code', 'newpass');
+ foreach ($alanlar as $al)
+ global $$al;
+ $degerler = $this->getVariable($alanlar);
+
+ if ($panelusername) {
+ $info = $this->getPanelUserInfo('', $panelusername);
+ $email = $info['email'];
+ if ($email == '')
+ return;
+ }
+
+
+ if (!$panelusername) {
+ $this->output .= inputform5(
+ array(
+ array('panelusername', 'lefttext' => 'Panel Username:')
+
+ )
+ );
+ } elseif ($panelusername and !$code) {
+ $hash = get_rand_id(10);
+ $r = $this->executeQuery("insert into hash (email,hash)values('$email','$hash')");
+ $msg = "Dear EHCP Force User,
Your EHCP activation code is: $hash";
+ $this->sendEmail($email, "EHCP Activation Code", $msg);
+ $this->output .= "An activation code was sent to your email address of $email. Please insert this code now: " . inputform5(
+ array(
+ array('panelusername', 'lefttext' => 'Panel Username:'),
+ array('code', 'lefttext' => 'Code:'),
+ array('newpass', 'lefttext' => 'New Password:')
+ )
+ );
+ } elseif ($panelusername and $code) {
+ $filt3 = "email='$email' and hash='$hash'";
+ $sayi = $this->recordcount("hash", $filt3);
+ if ($sayi == 0)
+ $this->errorTextExit("Invalid activation information received. Please verify the activation code that was sent to your email.");
+
+ if ($this->conf['logintable']['passwordfunction'] == '') {
+ $set = "'$newpass'";
+ } else {
+ $set = $this->conf['logintable']['passwordfunction'] . "('$newpass')";
+ }
+
+ $this->executeQuery("update panelusers set status='active',{$this->conf['logintable']['passwordfield']}=$set where status='passive' and panelusername='$panelusername'");
+ }
+
+ }
+
+ function pagerewrite()
+ {
+ global $op2, $_insert;
+ $domainname = $this->chooseDomain(__FUNCTION__, $domainname);
+ $this->output .= "This function is being tested with nginx only ";
+
+ $alanlar = array('frompage', 'topage', 'redirecttype');
+ foreach ($alanlar as $al)
+ global $$al;
+ $degerler = $this->getVariable($alanlar);
+
+ $table = $this->conf['customstable'];
+
+
+ if ($op2 == 'add') {
+
+ if ($_insert) {
+ switch ($this->miscconfig['webservertype']) {
+ case 'nginx':
+ if ($redirecttype == 'exactmatch')
+ $val = "rewrite ^($frompage)\$ $topage break; \n";
+ else
+ $val = "rewrite $frompage $topage break; \n";
+ break;
+
+ #case 'apache2:
+ default:
+ $this->errorTextExit("Your webserver does not support changing the EHCP GUI directory: " . $this->miscconfig['webservertype']);
+ }
+
+ #$q="insert into customsettings (panelusername,domainname,name,`value`,webservertype) values ('$this->activeuser','$domainname','pagerewrite','$val','".$this->miscconfig['webservertype']."')";
+ #if($this->executeQuery($q)) $this->output.="Ekleme tamam - OK";
+ $this->addCustomHttpDirect($domainname, $val, "pagerewrite");
+
+ } else {
+ $alanlar = array(array('frompage', 'righttext' => ''), array('topage'), array('redirecttype', 'radio', 'secenekler' => array('exactmatch' => 'Exact Match Ex: frompage: /basvuru topage: /en/basvuru.html', 'partialmatch' => 'Partial Match, nginx style, examples')));
+ $this->output .= inputform5($alanlar);
+ }
+ $this->output .= "nginx, For partial, examples:
frompage: ^(/download/.*)/media/(.*)\..*$
topage: $1/mp3/$2.mp3
frompage: ^/users/(.*)$
topage: /showuser.php?uid=$1 ";
-
- } else
- $this->listTable("Page redirects:","customstable","domainname='$domainname' and comment='pagerewrite'");
-
- $this->showSimilarFunctions("pagerewrite");
-}
-function upload_file($srcfile,$dstfile){
- $srcfilename=$_FILES[$srcfile]['name'];
-
- $this->output.= "Copy (".$_FILES[$srcfile]['tmp_name'].") -> ".$dstfile;
-
- if(copy($_FILES[$srcfile]['tmp_name'], $dstfile)) {
- $this->output.= " Dosya yükleme başarılı ";
- $this->output.= "File Name :".$_FILES[$srcfile]['name']." ";
- $this->output.= "File Size :".$_FILES[$srcfile]['size']." ";
- $this->output.= "File Type :".$_FILES[$srcfile]['type']." ";
+ } else
+ $this->listTable("Page redirects:", "customstable", "domainname='$domainname' and comment='pagerewrite'");
+
+ $this->showSimilarFunctions("pagerewrite");
}
- else {
- $this->output.=" Dosya yüklerken Hata oluştu ($path) ".print_r2($_FILES);
+
+ function upload_file($srcfile, $dstfile)
+ {
+ $srcfilename = $_FILES[$srcfile]['name'];
+
+ $this->output .= "Copy (" . $_FILES[$srcfile]['tmp_name'] . ") -> " . $dstfile;
+
+ if (copy($_FILES[$srcfile]['tmp_name'], $dstfile)) {
+ $this->output .= " Dosya yükleme başarılı ";
+ $this->output .= "File Name :" . $_FILES[$srcfile]['name'] . " ";
+ $this->output .= "File Size :" . $_FILES[$srcfile]['size'] . " ";
+ $this->output .= "File Type :" . $_FILES[$srcfile]['type'] . " ";
+ } else {
+ $this->output .= " Dosya yüklerken Hata oluştu ($path) " . print_r2($_FILES);
+ }
}
-}
-function adjust_ssl(){
- /*
-# steps for ssl adjust
-openssl genrsa -out server.key 2048
-# prepare LocalServer.cnf
-openssl req -new -key server.key -out server.csr -config LocalServer.cnf
-# send your server.csr to your Certificate company.
-# upload key files in ehcp,
+ function adjust_ssl()
+ {
+ /*
+ # steps for ssl adjust
+ openssl genrsa -out server.key 2048
+ # prepare LocalServer.cnf
+ openssl req -new -key server.key -out server.csr -config LocalServer.cnf
+ # send your server.csr to your Certificate company.
+ # upload key files in ehcp,
- * */
- $alanlar=array("step","_insert",'country_name','state','city','company','unit_name','common_name','email','SSLCertificateKeyFile');
- foreach($alanlar as $al) global $$al;
- $this->getVariable($alanlar);
- $this->requireAdmin(); # şimdilik fazla güvenlik almadım, ondan...
- $domainname=$this->chooseDomain(__FUNCTION__,$domainname);
-
- # howto: http://www.digicert.com/ssl-certificate-installation-apache.htm
- $waitstr="Your ssl config is being built now, wait until finished, retry here";
- $file1=$this->ehcpdir."/upload/LocalServer_$domainname.cnf";
- $file2=$this->ehcpdir."/upload/ssl_generated"; #
-
-
- if(!$step){
- unlink($file1); # remove file if exists
- $params=array(
- array('country_name','righttext'=>'Country Name (2 letter code) [ex:TR]'),
- array('state','righttext'=>'State or Province Name (full name) [Some-State], ex: Yorks'),
- array('city'),
- array('company','righttext'=>'optional, Your organization name, i.e, company'),
- array('unit_name','righttext'=>'Organizational Unit Name (eg, section)'),
- array('common_name','righttext'=>'(www.yourdomain.com, fqdn, or *.yourdomain.com to generate for all subdomains) THIS IS MOST IMPORTANT PART this should be the Fully Qualified Domain Name (FQDN) or the web address for which you plan to use your Certificate, e.g. the area of your site you wish customers to connect to using SSL. For example, an SSL Certificate issued for yourdomain.com will not be valid for secure.yourdomain.com, unless you use wildcard *.yourdomain.com'),
- array('email','righttext'=>'optional'),
- array('step','hidden','default'=>'1')
- );
-
- $this->output.="This is experimental, will be improved: Step 1: CSR Generation:".inputform5($params)." Skip to step 2 if you already generated your key files before.";
- } elseif($step==1) {
- $out="
+ * */
+ $alanlar = array("step", "_insert", 'country_name', 'state', 'city', 'company', 'unit_name', 'common_name', 'email', 'SSLCertificateKeyFile');
+ foreach ($alanlar as $al)
+ global $$al;
+ $this->getVariable($alanlar);
+ $this->requireAdmin(); # şimdilik fazla güvenlik almadım, ondan...
+ $domainname = $this->chooseDomain(__FUNCTION__, $domainname);
+
+ # howto: http://www.digicert.com/ssl-certificate-installation-apache.htm
+ $waitstr = "Your ssl config is being built now, wait until finished, retry here";
+ $file1 = $this->ehcpdir . "/upload/LocalServer_$domainname.cnf";
+ $file2 = $this->ehcpdir . "/upload/ssl_generated"; #
+
+
+ if (!$step) {
+ unlink($file1); # remove file if exists
+ $params = array(
+ array('country_name', 'righttext' => 'Country Name (2 letter code) [ex:TR]'),
+ array('state', 'righttext' => 'State or Province Name (full name) [Some-State], ex: Yorks'),
+ array('city'),
+ array('company', 'righttext' => 'optional, Your organization name, i.e, company'),
+ array('unit_name', 'righttext' => 'Organizational Unit Name (eg, section)'),
+ array('common_name', 'righttext' => '(www.yourdomain.com, fqdn, or *.yourdomain.com to generate for all subdomains) THIS IS MOST IMPORTANT PART this should be the Fully Qualified Domain Name (FQDN) or the web address for which you plan to use your Certificate, e.g. the area of your site you wish customers to connect to using SSL. For example, an SSL Certificate issued for yourdomain.com will not be valid for secure.yourdomain.com, unless you use wildcard *.yourdomain.com'),
+ array('email', 'righttext' => 'optional'),
+ array('step', 'hidden', 'default' => '1')
+ );
+
+ $this->output .= "This is experimental, will be improved: Step 1: CSR Generation:" . inputform5($params) . " Skip to step 2 if you already generated your key files before.";
+ } elseif ($step == 1) {
+ $out = "
[ req ]
prompt = no
distinguished_name = server_distinguished_name
@@ -1185,2410 +1662,2573 @@ countryName = $country_name
emailAddress = $email
organizationName = $company
organizationalUnitName = $unit_name";
-
- file_put_contents($file1,$out);
- $this->addDaemonOp('generate_ssl_config1','',$domainname,$file1,'generate_ssl_config');
- $this->output.=$waitstr;
- } elseif($step==2){
- if(file_exists($file2)) $this->output.="Now, put/send your CSR (Certificate Signing Request) to your Certificate Company:
(Start | Stop | Restart) Attention, by stopping your services, you may lose your conn. to panel.
";
- }else{
- $this->output.="
";
+
+
+ function setDefaultDomain()
+ {
+ $domainname = $this->chooseDomain(__FUNCTION__, $domainname);
+ $this->executeQuery("delete from misc where panelusername='$this->activeuser'");
+ $this->executeQuery("insert into misc (panelusername,name,`value`) values('$this->activeuser','defaultdomain','$domainname')");
+ $this->output .= "Domain is set as default: $domainname
";
}
-}
-function serverStatus(){
- $this->requireAdmin();
- #-------------- deconectat edit ---------------------------------------------------------
- # ehcpdeveloper note: in fact, these html should be abstracted from source. left as of now.
-
- $this->output.="
";
-
- // Show only the web server type that is activated
- if($this->miscconfig['webservertype'] == "apache2"){
- $this->check_program_service('apache2','dostartapache2','dostopapache2','dorestartapache2');
- }else if($this->miscconfig['webservertype'] == "nginx"){
- $this->check_program_service('nginx','dostartnginx','dostopnginx','dorestartnginx');
+ function executeProg3($prog, $echooutput = False)
+ {
+ # executes program and return output
+ if ($echooutput)
+ echo "\n" . __FUNCTION__ . ": executing: ($prog)\n";
+ exec($prog, $topcmd);
+ if (!is_array($topcmd))
+ return "";
+ foreach ($topcmd as $t)
+ $topoutput .= $t . "\n";
+ $out = trim($topoutput);
+ if ($echooutput and ($out <> ''))
+ echo "\n$out\n";
+ return $out;
}
-
- $this->check_program_service('php-fpm','dostartphp5fpm','dostopphp5fpm','dorestartphp5fpm');
- $this->check_program_service('mysqld','dostartmysqld','dostopmysqld','dorestartmysqld');
- $this->check_program_service('vsftpd','dostartvsftpd','dostopvsftpd','dorestartvsftpd');
- $this->check_program_service('bind','dostartbind','dostopbind','dorestartbind');
- $this->check_program_service('postfix','dostartpostfix','dostoppostfix','dorestartpostfix');
- $this->output.="
";
- $systemStatus=$this->executeProg3($this->ehcpdir."/misc/serverstatus.sh"); #moved the bash script in a separate file; this way it will be easyer to edit.
+ function check_program_service($progname, $start_opname, $stop_opname, $restart_opname)
+ {
+ $this->output .= "
(Start | Stop | Restart) Attention, by stopping your services, you may lose your conn. to panel.
";
+ } else {
+ $this->output .= "
";
+ }
}
- return True;
-}
-function resetAllCustomTemplates(){
- // This function is used to reset all the custom web templates to the system default (useful when major template updates are released in EHCP)
- if(!$this->commandline) {
- // Require admin if not called from a daemon script
+ function serverStatus()
+ {
$this->requireAdmin();
- }
-
- $success = true;
- $writeOut = "";
-
- // Make a backup of all global custom templates
- $SQL = "SELECT * FROM " . $this->conf['globalwebservertemplatestable']['tablename'] . " WHERE template_value != ''";
- $rs = $this->query($SQL);
- foreach($rs as $r){
- $templateName = $r["template_name"];
- $templateWM = $r["template_webserver_type"];
- $templateValue = $r["template_value"];
- $templateSSLType = $r["template_ssl_type"];
- $writeOut .= "\n\n" . $templateName . " for " . $templateSSLType . " " . $templateWM . ":\n\n" . $templateValue;
- }
-
- // Make a backup of all domain custom templates
- $SQL = "SELECT * FROM " . $this->conf['domainstable']['tablename'] . " WHERE apache2template != '' OR nginxtemplate != ''";
- $rs = $this->query($SQL);
- foreach($rs as $r){
- $domain = $r["domainname"];
- if(!empty($r["apache2template"])){
- $writeOut .= "\n\nCustom apache2template for " . $domain . ":\n\n" . $r["apache2template"];
+ #-------------- deconectat edit ---------------------------------------------------------
+ # ehcpdeveloper note: in fact, these html should be abstracted from source. left as of now.
+
+ $this->output .= "
";
+
+ // Show only the web server type that is activated
+ if ($this->miscconfig['webservertype'] == "apache2") {
+ $this->check_program_service('apache2', 'dostartapache2', 'dostopapache2', 'dorestartapache2');
+ } else if ($this->miscconfig['webservertype'] == "nginx") {
+ $this->check_program_service('nginx', 'dostartnginx', 'dostopnginx', 'dorestartnginx');
}
-
- if(!empty($r["nginxtemplate"])){
- $writeOut .= "\n\nCustom nginxtemplate for " . $domain . ":\n\n" . $r["nginxtemplate"];
+
+ $this->check_program_service('php-fpm', 'dostartphp5fpm', 'dostopphp5fpm', 'dorestartphp5fpm');
+ $this->check_program_service('mysqld', 'dostartmysqld', 'dostopmysqld', 'dorestartmysqld');
+ $this->check_program_service('vsftpd', 'dostartvsftpd', 'dostopvsftpd', 'dorestartvsftpd');
+ $this->check_program_service('bind', 'dostartbind', 'dostopbind', 'dorestartbind');
+ $this->check_program_service('postfix', 'dostartpostfix', 'dostoppostfix', 'dorestartpostfix');
+ $this->output .= "
";
+
+ $systemStatus = $this->executeProg3($this->ehcpdir . "/misc/serverstatus.sh"); #moved the bash script in a separate file; this way it will be easyer to edit.
+
+ $this->output .= "
';
- }else {
- if($clearTemplate){
- $success=$success && $this->executeQuery("update ".$this->conf['domainstable']['tablename']." set $templatefield='' where domainname='" . $domainname . "'");
- $success=$success && $this->addDaemonOp("syncdomains",'xx',$domainname); # sync only domain that is changed. not all domains...
- $this->ok_err_text($success,"The custom template for the domain of " . $domainname . " has been successfully removed and the default template will now be used for the domain." ,"Failed to save domain template modifications.");
- }else if($saveTemplate){
- $continue = true;
-
- // Below is a messy way to check if the template was actually changed from the default global or EHCP default template
- // But it has to be done this way since the template processing replaces certain variables and because textarea fields have \r\n for line breaks when database fields just have \n
- if(!empty($globalDomainTemplate)){
- if($$templatefield==$this->escape(str_replace('{domainname}', $this->selecteddomain, $globalDomainTemplate)) || $$templatefield == $this->escape($globalDomainTemplate)) {
- $$templatefield=''; # if same as in default template file, do not store it in db.
- $this->output.=" The domain template was not changed. No modified entries were stored in the database. ";
+ if (!empty($r["nginxtemplate"])) {
+ $writeOut .= "\n\nCustom nginxtemplate for " . $domain . ":\n\n" . $r["nginxtemplate"];
+ }
+ }
+
+ // Make a backup of all custom http entries
+ $SQL = "SELECT * FROM " . $this->conf['customstable']['tablename'] . " WHERE name = 'customhttp'";
+ $rs = $this->query($SQL);
+ foreach ($rs as $r) {
+ $domain = $r["domainname"];
+ $webserverType = $r["webservertype"];
+ $customValue = $r["value"];
+ $id = $r["id"];
+ $writeOut .= "\n\nCustom " . $webserverType . " http entry with database ID of " . $id . " for " . $domain . ":\n\n" . $customValue;
+ }
+
+ if (isset($writeOut) && !empty($writeOut)) {
+ $date = date("Y_m_d_H_i_s");
+ $backupFile = "/var/www/new/ehcp/custom_domain_template_backups_" . $date . ".conf";
+ $this->write_file_if_not_exists($backupFile, $writeOut);
+ }
+
+ // Clear custom global templates
+ $SQL = "UPDATE " . $this->conf['globalwebservertemplatestable']['tablename'] . " SET template_value=''";
+ $success = $success && $this->executeQuery($SQL);
+
+ // Clear domain templates
+ $success = $success && $this->executeQuery("update " . $this->conf['domainstable']['tablename'] . " set nginxtemplate='', apache2template=''");
+
+ // Clear custom http entries
+ $SQL = "DELETE FROM " . $this->conf['customstable']['tablename'] . " WHERE name = 'customhttp'";
+ $success = $success && $this->executeQuery($SQL);
+
+ // Daemon Operations
+ $success = $success && $this->addDaemonOp('handle_reset_sites_enabled_default', '', '', '', 'reset default sites enabled template');
+ $success = $success && $this->addDaemonOp('handle_reset_mainwebserverconf', '', '', '', 'reset main webserver conf to default');
+ $success = $success && $this->addDaemonOp('syncdomains', '', '', '', 'sync domains');
+
+ $this->ok_err_text($success, "All templates have been reset to their default state. " . (isset($backupFile) ? " A backup file (" . $backupFile . ") of the custom templates was saved." : ""), "Failed to clear all templates.");
+ return $success;
+ }
+
+ function editApacheTemplate()
+ {
+ #$this->output.=print_r2($this->miscconfig);
+
+ $templatefield = $this->miscconfig['webservertype'] . 'template';
+ global $_insert, $apachetemplate, $$templatefield, $saveTemplate, $clearTemplate;
+ $this->getVariable(array('_insert', 'apachetemplate', $templatefield, 'clearTemplate', 'saveTemplate'));
+ if ($this->miscconfig['disableeditapachetemplate'] <> '')
+ $this->requireAdmin();
+
+ $domainname = $this->chooseDomain(__FUNCTION__, $domainname);
+ $domaininfo = $this->domaininfo = $this->getDomainInfo($this->selecteddomain);
+ $this->output .= "Careful, this a dangerous thing, you should know about webserver (" . $this->miscconfig['webservertype'] . ", currently active) configuration syntax! if syntax is broken, a series of fallback operations will be done to make your panel reachable, such as rebuilding config using the default webserver configuration ";
+
+ if ($domaininfo['webserverips'] == '' or $domaininfo['webserverips'] == 'localhost')
+ $templateinfile = file_get_contents("apachetemplate"); # template different, if domain is served in another IP
+ else
+ $templateinfile = file_get_contents("apachetemplate_ipbased");
+
+ // Check for global domain template
+ $globalDomainTemplate = $this->getGlobalDomainTemplate();
+
+ $success = True;
+
+
+ if (!$_insert) {
+ $usingDefault = true;
+ $template = $domaininfo[$templatefield];
+ if ($template == '') {
+ if (empty($globalDomainTemplate)) {
+ $template = $templateinfile;
+ } else {
+ $template = $globalDomainTemplate;
+ }
+ } else {
+ $usingDefault = false;
+ }
+
+ // If the domain was configured to redirect normal HTTP to HTTPS, make sure the template default reflects that here as well
+ $template = $this->adjustDomainTemplateForRedirect($template, $domaininfo, "domain", false);
+
+ $inputparams = array(
+ array($templatefield, 'textarea', 'default' => trim($template), 'cols' => 80, 'rows' => 30, 'lefttext' => 'Current ' . $this->miscconfig['webservertype'] . ' Template:'),
+ array('saveTemplate', 'submit', 'default' => 'Save Template'),
+ array('clearTemplate', 'submit', 'default' => 'Revert to Default'),
+ array('op', 'hidden', 'default' => __FUNCTION__)
+ );
+ $this->output .= '
';
+ } else {
+ if ($clearTemplate) {
+ $success = $success && $this->executeQuery("update " . $this->conf['domainstable']['tablename'] . " set $templatefield='' where domainname='" . $domainname . "'");
+ $success = $success && $this->addDaemonOp("syncdomains", 'xx', $domainname); # sync only domain that is changed. not all domains...
+ $this->ok_err_text($success, "The custom template for the domain of " . $domainname . " has been successfully removed and the default template will now be used for the domain.", "Failed to save domain template modifications.");
+ } else if ($saveTemplate) {
+ $continue = true;
+
+ // Below is a messy way to check if the template was actually changed from the default global or EHCP default template
+ // But it has to be done this way since the template processing replaces certain variables and because textarea fields have \r\n for line breaks when database fields just have \n
+ if (!empty($globalDomainTemplate)) {
+ if ($$templatefield == $this->escape(str_replace('{domainname}', $this->selecteddomain, $globalDomainTemplate)) || $$templatefield == $this->escape($globalDomainTemplate)) {
+ $$templatefield = ''; # if same as in default template file, do not store it in db.
+ $this->output .= " The domain template was not changed. No modified entries were stored in the database. ";
+ $continue = false;
+ }
+ } else if ($this->removeLineCharacterLiteralsFromString($$templatefield) == $this->removeLineCharacterLiteralsFromString($this->escape(str_replace('{domainname}', $this->selecteddomain, $templateinfile))) || $this->removeLineCharacterLiteralsFromString($$templatefield) == $this->removeLineCharacterLiteralsFromString($this->escape($templateinfile))) {
+ $$templatefield = ''; # if same as in default template file, do not store it in db.
+ $this->output .= " The domain template was not changed. No modified entries were stored in the database. ";
$continue = false;
}
- }else if($this->removeLineCharacterLiteralsFromString($$templatefield) == $this->removeLineCharacterLiteralsFromString($this->escape(str_replace('{domainname}', $this->selecteddomain, $templateinfile))) || $this->removeLineCharacterLiteralsFromString($$templatefield) == $this->removeLineCharacterLiteralsFromString($this->escape($templateinfile))){
- $$templatefield=''; # if same as in default template file, do not store it in db.
- $this->output.=" The domain template was not changed. No modified entries were stored in the database. ";
- $continue = false;
- }
-
- if($continue){
- $success=$success && $this->executeQuery("update ".$this->conf['domainstable']['tablename']." set $templatefield='".$$templatefield."' where domainname='$domainname'");
- $success=$success && $this->addDaemonOp("syncdomains",'xx',$domainname); # sync only domain that is changed. not all domains...
- $this->ok_err_text($success,"Domain template modifications were successfully saved and stored in the database.","Failed to save domain template modifications.");
+
+ if ($continue) {
+ $success = $success && $this->executeQuery("update " . $this->conf['domainstable']['tablename'] . " set $templatefield='" . $$templatefield . "' where domainname='$domainname'");
+ $success = $success && $this->addDaemonOp("syncdomains", 'xx', $domainname); # sync only domain that is changed. not all domains...
+ $this->ok_err_text($success, "Domain template modifications were successfully saved and stored in the database.", "Failed to save domain template modifications.");
+ }
}
}
+ $this->showSimilarFunctions('HttpDnsTemplatesAliases');
+ return $success;
}
- $this->showSimilarFunctions('HttpDnsTemplatesAliases');
- return $success;
-}
-function editApacheTemplateSubdomain(){
- global $id;
- $success=True;
-
- $subdomain = $this->getSubdomainInfoById($id);
- if($subdomain === false){
- return false;
- }
-
- $templatefield=$this->miscconfig['webservertype'].'template';
- global $_insert,$apachetemplate,$$templatefield,$saveTemplate,$clearTemplate;
- $this->getVariable(array('_insert','apachetemplate',$templatefield,'clearTemplate','saveTemplate'));
- if($this->miscconfig['disableeditapachetemplate']<>'') $this->requireAdmin();
+ function editApacheTemplateSubdomain()
+ {
+ global $id;
+ $success = True;
- $this->output.="Careful, this a dangerous thing, you should know about webserver (".$this->miscconfig['webservertype'].", currently active) configuration syntax! if syntax is broken, a series of fallback operations will be done to make your panel reachable, such as rebuilding config using default webserver configuration ";
-
- $templateinfile=file_get_contents("apache_subdomain_template"); # template different, if domain is served in another IP
-
- // Check for global domain template
- $globalSubDomainTemplate = $this->getGlobalSubDomainTemplate();
-
- $success=True;
-
-
- if(!$_insert){
- $usingDefault = true;
- $template=$subdomain[$templatefield];
- if($template==''){
- if(empty($globalSubDomainTemplate)){
- $template=$templateinfile;
- }else{
- $template=$globalSubDomainTemplate;
- }
-
- }else{
- $usingDefault = false;
+ $subdomain = $this->getSubdomainInfoById($id);
+ if ($subdomain === false) {
+ return false;
}
-
- // If the subdomain was configured to redirect normal HTTP to HTTPS, make sure the template default reflects that here as well
- $template = $this->adjustDomainTemplateDependingOnSSLSettings($template, $subdomain, "subdomain", false);
- $inputparams=array(
- array($templatefield,'textarea','default'=>trim($template),'cols'=>80,'rows'=>30, 'lefttext'=>'Current ' . $this->miscconfig['webservertype'] . ' Subdomain Template:'),
- array('saveTemplate','submit','default'=>'Save Template'),
- array('clearTemplate','submit','default'=>'Revert to Default'),
- array('op','hidden','default'=>__FUNCTION__)
- );
- $this->output.= '
' . inputform5($inputparams);
- }else {
- if($clearTemplate){
- $success=$success && $this->executeQuery("update ".$this->conf['subdomainstable']['tablename']." set $templatefield='' where domainname='" . $subdomain["domainname"] . "' AND subdomain ='" . $subdomain["subdomain"] . "' AND id ='" . $id . "'");
- $success=$success && $this->addDaemonOp("syncdomains",'xx',$subdomain["domainname"]); # sync only domain that is changed. not all domains...
- $this->ok_err_text($success,"The custom template for the subdomain of " . $subdomain["subdomain"] . "." . $subdomain["domainname"] . " has been successfully removed and the default template will now be used for the subdomain." ,"Failed to save template modifications.");
- }else if($saveTemplate){
- $continue = true;
-
- // Below is a messy way to check if the template was actually changed from the default global or EHCP default template
- // But it has to be done this way since the template processing replaces certain variables and because textarea fields have \r\n for line breaks when database fields just have \n
- $templateWeReceived = str_replace(array('{domainname}', '{subdomain}'), array($subdomain["domainname"], $subdomain["subdomain"]), $templateinfile);
- if(!empty($globalSubDomainTemplate)){
- $templateWeReceived = str_replace(array('{domainname}', '{subdomain}'), array($subdomain["domainname"], $subdomain["subdomain"]), $globalDomainTemplate);
- if($$templatefield==$this->escape($templateWeReceived) || $$templatefield == $this->escape($globalSubDomainTemplate)) {
- $$templatefield=''; # if same as in default template file, do not store it in db.
- $this->output.=" The subdomain template was not changed. No modified entries were stored in the database. ";
+ $templatefield = $this->miscconfig['webservertype'] . 'template';
+ global $_insert, $apachetemplate, $$templatefield, $saveTemplate, $clearTemplate;
+ $this->getVariable(array('_insert', 'apachetemplate', $templatefield, 'clearTemplate', 'saveTemplate'));
+ if ($this->miscconfig['disableeditapachetemplate'] <> '')
+ $this->requireAdmin();
+
+ $this->output .= "Careful, this a dangerous thing, you should know about webserver (" . $this->miscconfig['webservertype'] . ", currently active) configuration syntax! if syntax is broken, a series of fallback operations will be done to make your panel reachable, such as rebuilding config using default webserver configuration ";
+
+ $templateinfile = file_get_contents("apache_subdomain_template"); # template different, if domain is served in another IP
+
+ // Check for global domain template
+ $globalSubDomainTemplate = $this->getGlobalSubDomainTemplate();
+
+ $success = True;
+
+
+ if (!$_insert) {
+ $usingDefault = true;
+ $template = $subdomain[$templatefield];
+ if ($template == '') {
+ if (empty($globalSubDomainTemplate)) {
+ $template = $templateinfile;
+ } else {
+ $template = $globalSubDomainTemplate;
+ }
+
+ } else {
+ $usingDefault = false;
+ }
+
+ // If the subdomain was configured to redirect normal HTTP to HTTPS, make sure the template default reflects that here as well
+ $template = $this->adjustDomainTemplateDependingOnSSLSettings($template, $subdomain, "subdomain", false);
+
+ $inputparams = array(
+ array($templatefield, 'textarea', 'default' => trim($template), 'cols' => 80, 'rows' => 30, 'lefttext' => 'Current ' . $this->miscconfig['webservertype'] . ' Subdomain Template:'),
+ array('saveTemplate', 'submit', 'default' => 'Save Template'),
+ array('clearTemplate', 'submit', 'default' => 'Revert to Default'),
+ array('op', 'hidden', 'default' => __FUNCTION__)
+ );
+ $this->output .= '
' . inputform5($inputparams);
+ } else {
+ if ($clearTemplate) {
+ $success = $success && $this->executeQuery("update " . $this->conf['subdomainstable']['tablename'] . " set $templatefield='' where domainname='" . $subdomain["domainname"] . "' AND subdomain ='" . $subdomain["subdomain"] . "' AND id ='" . $id . "'");
+ $success = $success && $this->addDaemonOp("syncdomains", 'xx', $subdomain["domainname"]); # sync only domain that is changed. not all domains...
+ $this->ok_err_text($success, "The custom template for the subdomain of " . $subdomain["subdomain"] . "." . $subdomain["domainname"] . " has been successfully removed and the default template will now be used for the subdomain.", "Failed to save template modifications.");
+ } else if ($saveTemplate) {
+ $continue = true;
+
+ // Below is a messy way to check if the template was actually changed from the default global or EHCP default template
+ // But it has to be done this way since the template processing replaces certain variables and because textarea fields have \r\n for line breaks when database fields just have \n
+ $templateWeReceived = str_replace(array('{domainname}', '{subdomain}'), array($subdomain["domainname"], $subdomain["subdomain"]), $templateinfile);
+ if (!empty($globalSubDomainTemplate)) {
+ $templateWeReceived = str_replace(array('{domainname}', '{subdomain}'), array($subdomain["domainname"], $subdomain["subdomain"]), $globalDomainTemplate);
+ if ($$templatefield == $this->escape($templateWeReceived) || $$templatefield == $this->escape($globalSubDomainTemplate)) {
+ $$templatefield = ''; # if same as in default template file, do not store it in db.
+ $this->output .= " The subdomain template was not changed. No modified entries were stored in the database. ";
+ $continue = false;
+ }
+ } else if ($this->removeLineCharacterLiteralsFromString($$templatefield) == $this->removeLineCharacterLiteralsFromString($this->escape($templateWeReceived)) || $this->removeLineCharacterLiteralsFromString($$templatefield) == $this->removeLineCharacterLiteralsFromString($this->escape($templateinfile))) {
+ $$templatefield = ''; # if same as in default template file, do not store it in db.
+ $this->output .= " The subdomain template was not changed. No modified entries were stored in the database. ";
$continue = false;
}
- }else if($this->removeLineCharacterLiteralsFromString($$templatefield) == $this->removeLineCharacterLiteralsFromString($this->escape($templateWeReceived)) || $this->removeLineCharacterLiteralsFromString($$templatefield) == $this->removeLineCharacterLiteralsFromString($this->escape($templateinfile))){
- $$templatefield=''; # if same as in default template file, do not store it in db.
- $this->output.=" The subdomain template was not changed. No modified entries were stored in the database. ";
- $continue = false;
- }
-
- if($continue){
- $success=$success && $this->executeQuery("update ".$this->conf['subdomainstable']['tablename']." set $templatefield='".$$templatefield."' where domainname='" . $subdomain["domainname"] . "' AND subdomain ='" . $subdomain["subdomain"] . "' AND id ='" . $id . "'");
- $success=$success && $this->addDaemonOp("syncdomains",'xx',$subdomain["domainname"]); # sync only domain that is changed. not all domains...
- $this->ok_err_text($success,"Subdomain template modifications were successfully saved and stored in the database.","Failed to save subdomain template modifications.");
+
+ if ($continue) {
+ $success = $success && $this->executeQuery("update " . $this->conf['subdomainstable']['tablename'] . " set $templatefield='" . $$templatefield . "' where domainname='" . $subdomain["domainname"] . "' AND subdomain ='" . $subdomain["subdomain"] . "' AND id ='" . $id . "'");
+ $success = $success && $this->addDaemonOp("syncdomains", 'xx', $subdomain["domainname"]); # sync only domain that is changed. not all domains...
+ $this->ok_err_text($success, "Subdomain template modifications were successfully saved and stored in the database.", "Failed to save subdomain template modifications.");
+ }
}
}
+
+ $this->showSimilarFunctions('subdomainsDirs');
+
+ return $success;
}
-
- $this->showSimilarFunctions('subdomainsDirs');
-
- return $success;
-}
-function removeLineCharacterLiteralsFromString($str){
- $str = str_replace('\r\n', '', $str);
- $str = str_replace('\r', '', $str);
- $str = str_replace('\n', '', $str);
- return $str;
-}
+ function removeLineCharacterLiteralsFromString($str)
+ {
+ $str = str_replace('\r\n', '', $str);
+ $str = str_replace('\r', '', $str);
+ $str = str_replace('\n', '', $str);
+ return $str;
+ }
-function editDomainAliases(){
- global $_insert,$aliases;
- $this->getVariable(array('_insert','aliases'));
+ function editDomainAliases()
+ {
+ global $_insert, $aliases;
+ $this->getVariable(array('_insert', 'aliases'));
- $domainname=$this->chooseDomain(__FUNCTION__,$domainname);
- $domaininfo=$this->domaininfo=$this->getDomainInfo($this->selecteddomain);
- $this->output.="Enter one alias per line one by one
+ $domainname = $this->chooseDomain(__FUNCTION__, $domainname);
+ $domaininfo = $this->domaininfo = $this->getDomainInfo($this->selecteddomain);
+ $this->output .= "Enter one alias per line one by one
Example:
www.domain2.com
www.domain3.com
other.domain2.com ";
- $templateinfile=file_get_contents("dnszonetemplate");
- $success=True;
+ $templateinfile = file_get_contents("dnszonetemplate");
+ $success = True;
- if(!$_insert){
- $template=$domaininfo['aliases'];
- $inputparams=array(
- array('aliases','textarea','default'=>$template,'cols'=>80,'rows'=>30, 'lefttext'=>'Domain Aliases:'),
- array('op','hidden','default'=>__FUNCTION__)
- );
- $this->output.=inputform5($inputparams);
+ if (!$_insert) {
+ $template = $domaininfo['aliases'];
+ $inputparams = array(
+ array('aliases', 'textarea', 'default' => $template, 'cols' => 80, 'rows' => 30, 'lefttext' => 'Domain Aliases:'),
+ array('op', 'hidden', 'default' => __FUNCTION__)
+ );
+ $this->output .= inputform5($inputparams);
- }else {
- $success=$success && $this->executeQuery("update ".$this->conf['domainstable']['tablename']." set aliases='".$aliases."' where domainname='$domainname'");
- $success=$success && $this->addDaemonOp("syncdomains",'xx',$domainname,'','sync domains-aliases'); # sync only that domain...
- $success=$success && $this->addDaemonOp("syncdns",'','','','sync dns-aliases');
- $this->ok_err_text($success,"Domain alias(es) were successfully modified. ","Failed to modify domain alias(es).");
- }
-
- $this->showSimilarFunctions('HttpDnsTemplatesAliases');
- return $success;
-}
-
-function editDnsTemplate(){
- global $_insert,$dnstemplate;
- $this->getVariable(array('_insert','dnstemplate'));
- if($this->miscconfig['disableeditdnstemplate']<>'') $this->requireAdmin();
-
- $domainname=$this->chooseDomain(__FUNCTION__,$domainname);
- $domaininfo=$this->domaininfo=$this->getDomainInfo($this->selecteddomain);
- $this->output.="Careful, this a dangerous thing, you should now about dns configuration syntax! ";
- $templateinfile=file_get_contents("dnszonetemplate");
- $success=True;
-
- if(!$_insert){
- $template=$domaininfo['dnstemplate'];
- if($template=='') {$template=$templateinfile;}
-
- $inputparams=array(
- array('dnstemplate','textarea','default'=>$template,'cols'=>80,'rows'=>30, 'lefttext'=>'Current DNS Template:'),
- array('op','hidden','default'=>__FUNCTION__)
- );
-
- $this->output.= '
(in case you have a custom web template and want to protect additional hosts that are not EHCP configured subdomains) (Takes the format of ns3.otherdomain.com{skipdomain},ns4=/var/www/new/ehcp;nextsubhost,n88,a9=/location) subdomains (without domains) separated by "," along with optional {skipdomain} if you don\'t want to append the domain name to the entry, optional path specified with "=" (defaults to domain httpdocs path if left out), next extry follows ";" Leave blank if you don\'t know what you\'re doing.
Click to Remove and Reset SSL Configuration for Domain
" . inputform5($deleteSSLHTML) . "
";
-
- } else {
- if($delete_ssl){
- $success = $this->removeSSLSettingForDomain($domainname);
-
+ return $this->ok_err_text($success, "Domain redirection for '" . $domainname . "' has been removed!", "Failed to remove redirection for '" . $domainname . "'!");
+ } else if ($set_redir) {
+ if (inputValid($todomain, 'url')) {
+ // Strip trailing slashes
+ $todomain = removeAllTrailingSlashes($todomain);
+ $success = $this->setRedirectDomain($domainname, $todomain);
+
// If a redirect operation was successfully completed, add syncdomains op
- if($success){
- $this->addDaemonOp("syncdomains",'xx',$domainname,'','sync domains');
+ if ($success) {
+ $this->addDaemonOp("syncdomains", 'xx', $domainname, '', 'sync domains');
}
-
- return $this->ok_err_text($success,"Domain SSL settings for '" . $domainname . "' have been removed!", "Failed to remove SSL settings for '" . $domainname . "'!");
- }else if($set_ssl){
- $ssl_cert_nonescaped = strip_tags(trim($_POST["ssl_cert"]));
- $ssl_cert_key_nonescaped = strip_tags(trim($_POST["ssl_cert_key"]));
- $ssl_cert_chain_nonescaped = strip_tags(trim($_POST["ssl_cert_chain"]));
-
- if(!empty($ssl_cert) && !empty($ssl_cert_key)){
- if(inputValid($ssl_cert,'certificate') && inputValid($ssl_cert_key,'certificate_key')){
- // To do - better ssl cert chain validation???
- if((!empty($ssl_cert_chain) && inputValid($ssl_cert_chain,'certificate') && testCertificateChainValid($ssl_cert_chain_nonescaped)) || empty($ssl_cert_chain)){
- if((!empty($ssl_cert_chain) && makeSureSSLTestChainFileMatches($ssl_cert_chain_nonescaped)) || empty($ssl_cert_chain)){
- if(testCertificateAndPrivateKeyHashMatch($ssl_cert_nonescaped, $ssl_cert_key_nonescaped)){
- if(makeSureSSLTestFileMatches($ssl_cert_nonescaped, $ssl_cert_key_nonescaped)){
- $arr["cert"] = $ssl_cert; $arr["key"] = $ssl_cert_key; $arr["chain"] = $ssl_cert_chain;
- if(isset($ssl_wild_card) && !empty($ssl_wild_card)){
- $arr["wildcard"] = 1;
- }else{
- $arr["wildcard"] = 0;
- }
-
- if(isset($ssl_redirect_https) && !empty($ssl_redirect_https)){
- $arr["redir_https"] = 1;
- }else{
- $arr["redir_https"] = 0;
- }
-
- $success = $this->setSSLSettingForDomain($domainname, $arr);
-
- // Run daemon ops if successful
- if($success){
- $success=$success && $this->addDaemonOp("process_ssl_certs",'xx',$domainname,'','handle creation of ssl cert files');
- $success=$success && $this->addDaemonOp("syncdomains",'xx',$domainname,'','sync domains');
- }
-
- return $this->ok_err_text($success,"Domain '" . $domainname . "' will use the custom SSL certificate settings provided.","Failed to save custom SSL settings for '" . $domainname . "'!","");
- }else{
- $success=false;
- return $this->ok_err_text($success,"","Test file contents do not match entered key or certificate. Please try again.");
- }
- }else{
- $success=false;
- return $this->ok_err_text($success,"","Certificate and key hash do not match, or the certificate and key combo is not valid!");
- }
- }else{
- $success=false;
- return $this->ok_err_text($success,"","Test file contents do not match entered chain certificate. Please try again.");
- }
- }else{
- $success=false;
- return $this->ok_err_text($success,"","Certificate chain is invalid!");
- }
- }else{
- $success=false;
- return $this->ok_err_text($success,"","You must enter a valid certificate and private key for custom SSL settings!");
- }
- }else{
- $success=false;
- return $this->ok_err_text($success,"","The SSL certificate and private key are required!");
- }
- }else if($ssl_use_letsenc){
- if(isset($ssl_redirect_https) && !empty($ssl_redirect_https)){
- $arr["redir_https"] = 1;
- }else{
- $arr["redir_https"] = 0;
- }
-
- if($this->isadmin()){
- if(isset($lets_enc_additional_hosts) && !empty($lets_enc_additional_hosts)){
- $arr["lets_enc_additional_hosts"] = $lets_enc_additional_hosts;
- }else{
- $arr["lets_enc_additional_hosts"] = "";
- }
- }
-
- $success = $this->setLetsEncryptForDomain($domainname, $arr);
- $success=$success && $this->addDaemonOp("syncdomains",'xx',$domainname,'','sync domains');
- return $this->ok_err_text($success,"Domain will use and automatically renew SSL certificate from Let's Encrypt.","Failed to configure domain to use SSL certificate from Let's Encrypt.");
+
+ return $this->ok_err_text($success, "Domain '" . $domainname . "' is now redirected to '" . $todomain . "'.", "Failed to redirect domain '" . $domainname . "' to '" . $todomain . "'!");
+ } else {
+ $success = false;
+ return $this->ok_err_text($success, "", "Redirect URL '" . $todomain . "' is invalid.");
}
}
- }else{
- $success=false;
- return $this->ok_err_text($success,"","Only the administrator of this server can setup custom SSL certificates for your domain. Please contact support.");
}
- }else{
- $success=false;
- return $this->ok_err_text($success,"","SSL must be enabled on the web server before you can use custom domain SSL settings.");
+
+ $this->showSimilarFunctions('redirect');
+ return True;
+ }
+
+ function addDomainSSLCert()
+ {
+ global $ssl_cert, $ssl_cert_key, $ssl_cert_chain, $_insert, $set_ssl, $delete_ssl, $ssl_use_letsenc, $ssl_wild_card, $ssl_redirect_https, $lets_enc_additional_hosts;
+ $this->getVariable(array('ssl_cert', 'ssl_cert_key', 'ssl_cert_chain', 'delete_ssl', 'set_ssl', '_insert', 'ssl_use_letsenc', 'ssl_wild_card', 'ssl_redirect_https', 'lets_enc_additional_hosts'), true);
+ unset($arr); // Clear array
+
+ // Make sure SSL is enabled on the web server...
+ if ($this->miscconfig['webservermode'] == 'ssl' || $this->miscconfig['webservermode'] == 'sslonly') {
+
+ if ($this->isadmin() || (!$this->isadmin() && !empty($this->miscconfig['allowcustomsslnonadmin']))) {
+
+ // Make sure domain is selected
+ $domainname = $this->chooseDomain(__FUNCTION__, $domainname);
+ $success = True;
+ $curSSLSettingsForDomain = $this->getSSLSettingForDomain($domainname);
+ if (!$_insert) {
+
+ if ($this->miscconfig['webservermode'] == 'ssl') {
+ $toAdd = array('ssl_redirect_https', 'checkbox', 'default' => '1', 'lefttext' => 'Redirect All HTTP Requests to HTTPS:', 'checked' => $curSSLSettingsForDomain["redir_https"]);
+ }
+
+ $letsEncHTML = array(
+ array('ssl_use_letsenc', 'submit', 'default' => 'Use FREE SSL'),
+ array('op', 'hidden', 'default' => __FUNCTION__)
+ );
+
+ $customSSLHTML = array(
+ array('ssl_cert', 'textarea', 'lefttext' => 'SSL Certificate (Raw Text):', 'default' => $curSSLSettingsForDomain["cert"]),
+ array('ssl_cert_key', 'textarea', 'lefttext' => 'SSL Certificate Private Key (Raw Text):', 'default' => $curSSLSettingsForDomain["key"]),
+ array('ssl_cert_chain', 'textarea', 'lefttext' => 'SSL Certificate Chain (Raw Text):', 'default' => $curSSLSettingsForDomain["chain"]),
+ array('ssl_wild_card', 'checkbox', 'default' => '1', 'lefttext' => 'Is Wildcard Certificate:', 'checked' => $curSSLSettingsForDomain["wildcard"]),
+ array('set_ssl', 'submit', 'default' => 'Save SSL Settings'),
+ array('op', 'hidden', 'default' => __FUNCTION__)
+ );
+
+ $deleteSSLHTML = array(
+ array('delete_ssl', 'submit', 'default' => 'Remove Certificate & Reset SSL Settings'),
+ array('op', 'hidden', 'default' => __FUNCTION__)
+ );
+
+ if ($this->isadmin()) {
+ $additionalHostsToProtectLetsEnc = array('lets_enc_additional_hosts', 'textarea', 'lefttext' => 'Additional Valid Let\'s Encrypt SSL Hosts:
(in case you have a custom web template and want to protect additional hosts that are not EHCP configured subdomains) (Takes the format of ns3.otherdomain.com{skipdomain},ns4=/var/www/new/ehcp;nextsubhost,n88,a9=/location) subdomains (without domains) separated by "," along with optional {skipdomain} if you don\'t want to append the domain name to the entry, optional path specified with "=" (defaults to domain httpdocs path if left out), next extry follows ";" Leave blank if you don\'t know what you\'re doing.
Click to Remove and Reset SSL Configuration for Domain
" . inputform5($deleteSSLHTML) . "
";
+
+ } else {
+ if ($delete_ssl) {
+ $success = $this->removeSSLSettingForDomain($domainname);
+
+ // If a redirect operation was successfully completed, add syncdomains op
+ if ($success) {
+ $this->addDaemonOp("syncdomains", 'xx', $domainname, '', 'sync domains');
+ }
+
+ return $this->ok_err_text($success, "Domain SSL settings for '" . $domainname . "' have been removed!", "Failed to remove SSL settings for '" . $domainname . "'!");
+ } else if ($set_ssl) {
+ $ssl_cert_nonescaped = strip_tags(trim($_POST["ssl_cert"]));
+ $ssl_cert_key_nonescaped = strip_tags(trim($_POST["ssl_cert_key"]));
+ $ssl_cert_chain_nonescaped = strip_tags(trim($_POST["ssl_cert_chain"]));
+
+ if (!empty($ssl_cert) && !empty($ssl_cert_key)) {
+ if (inputValid($ssl_cert, 'certificate') && inputValid($ssl_cert_key, 'certificate_key')) {
+ // To do - better ssl cert chain validation???
+ if ((!empty($ssl_cert_chain) && inputValid($ssl_cert_chain, 'certificate') && testCertificateChainValid($ssl_cert_chain_nonescaped)) || empty($ssl_cert_chain)) {
+ if ((!empty($ssl_cert_chain) && makeSureSSLTestChainFileMatches($ssl_cert_chain_nonescaped)) || empty($ssl_cert_chain)) {
+ if (testCertificateAndPrivateKeyHashMatch($ssl_cert_nonescaped, $ssl_cert_key_nonescaped)) {
+ if (makeSureSSLTestFileMatches($ssl_cert_nonescaped, $ssl_cert_key_nonescaped)) {
+ $arr["cert"] = $ssl_cert;
+ $arr["key"] = $ssl_cert_key;
+ $arr["chain"] = $ssl_cert_chain;
+ if (isset($ssl_wild_card) && !empty($ssl_wild_card)) {
+ $arr["wildcard"] = 1;
+ } else {
+ $arr["wildcard"] = 0;
+ }
+
+ if (isset($ssl_redirect_https) && !empty($ssl_redirect_https)) {
+ $arr["redir_https"] = 1;
+ } else {
+ $arr["redir_https"] = 0;
+ }
+
+ $success = $this->setSSLSettingForDomain($domainname, $arr);
+
+ // Run daemon ops if successful
+ if ($success) {
+ $success = $success && $this->addDaemonOp("process_ssl_certs", 'xx', $domainname, '', 'handle creation of ssl cert files');
+ $success = $success && $this->addDaemonOp("syncdomains", 'xx', $domainname, '', 'sync domains');
+ }
+
+ return $this->ok_err_text($success, "Domain '" . $domainname . "' will use the custom SSL certificate settings provided.", "Failed to save custom SSL settings for '" . $domainname . "'!", "");
+ } else {
+ $success = false;
+ return $this->ok_err_text($success, "", "Test file contents do not match entered key or certificate. Please try again.");
+ }
+ } else {
+ $success = false;
+ return $this->ok_err_text($success, "", "Certificate and key hash do not match, or the certificate and key combo is not valid!");
+ }
+ } else {
+ $success = false;
+ return $this->ok_err_text($success, "", "Test file contents do not match entered chain certificate. Please try again.");
+ }
+ } else {
+ $success = false;
+ return $this->ok_err_text($success, "", "Certificate chain is invalid!");
+ }
+ } else {
+ $success = false;
+ return $this->ok_err_text($success, "", "You must enter a valid certificate and private key for custom SSL settings!");
+ }
+ } else {
+ $success = false;
+ return $this->ok_err_text($success, "", "The SSL certificate and private key are required!");
+ }
+ } else if ($ssl_use_letsenc) {
+ if (isset($ssl_redirect_https) && !empty($ssl_redirect_https)) {
+ $arr["redir_https"] = 1;
+ } else {
+ $arr["redir_https"] = 0;
+ }
+
+ if ($this->isadmin()) {
+ if (isset($lets_enc_additional_hosts) && !empty($lets_enc_additional_hosts)) {
+ $arr["lets_enc_additional_hosts"] = $lets_enc_additional_hosts;
+ } else {
+ $arr["lets_enc_additional_hosts"] = "";
+ }
+ }
+
+ $success = $this->setLetsEncryptForDomain($domainname, $arr);
+ $success = $success && $this->addDaemonOp("syncdomains", 'xx', $domainname, '', 'sync domains');
+ return $this->ok_err_text($success, "Domain will use and automatically renew SSL certificate from Let's Encrypt.", "Failed to configure domain to use SSL certificate from Let's Encrypt.");
+ }
+ }
+ } else {
+ $success = false;
+ return $this->ok_err_text($success, "", "Only the administrator of this server can setup custom SSL certificates for your domain. Please contact support.");
+ }
+ } else {
+ $success = false;
+ return $this->ok_err_text($success, "", "SSL must be enabled on the web server before you can use custom domain SSL settings.");
+ }
+ return True;
}
- return True;
-}
-function cmsEditPages(){
- global $output;
+ function cmsEditPages()
+ {
+ global $output;
- $grup=$this->selecteddomain;
- include_once("multicms/cmsindex.php");
-}
+ $grup = $this->selecteddomain;
+ include_once("multicms/cmsindex.php");
+ }
-function updateWebstats(){
- global $skipUpdateWebstats;
- if($skipUpdateWebstats or $this->miscconfig['enablewebstats']=='') {
- # if you put webstats.sh in crontab
- echo "\nSkipping ".__FUNCTION__." because of config directive (\$skipUpdateWebstats) or enablewebstats is not checked in options.\n";
+ function updateWebstats()
+ {
+ global $skipUpdateWebstats;
+ if ($skipUpdateWebstats or $this->miscconfig['enablewebstats'] == '') {
+ # if you put webstats.sh in crontab
+ echo "\nSkipping " . __FUNCTION__ . " because of config directive (\$skipUpdateWebstats) or enablewebstats is not checked in options.\n";
+ return false;
+ }
+
+ $this->requireCommandLine(__FUNCTION__);
+ $res = $this->query("select domainname,homedir from domains where status='$this->status_active' and homedir<>''");
+ $str = '';
+ foreach ($res as $dom) {
+ passthru2("mkdir -p " . $dom['homedir'] . "/httpdocs/webstats/");
+ $str .= "webalizer -Q -p -j -n www." . $dom['domainname'] . " -o " . $dom['homedir'] . "/httpdocs/webstats " . $dom['homedir'] . "/logs/access_log -R 100 TopReferrers -r " . $dom['domainname'] . " HideReferrer \n";
+ }
+ echo $str;
+
+ writeoutput2("/etc/ehcp/webstats.sh", $str, "w");
+ passthru2("chmod a+x /etc/ehcp/webstats.sh");
+ passthru2("/etc/ehcp/webstats.sh");
+ echo "\nwrite webstats file to /etc/ehcp/webstats.sh complete... need to put this in crontab or run automatically.. \n";
+
+ }
+
+ function set_active_server_ip()
+ {
+ $this->requireAdmin();
+
+ global $ip, $_insert;
+ $this->getVariable(array('ip', '_insert'));
+
+ if ($_insert) {
+ if ($ip <> '')
+ $this->validate_ip_address($ip);
+ $this->setConfigValue('activewebserverip', $ip);
+ $this->output .= 'Default Webserver Ip changed in ehcp (not in system)';
+ } else {
+ $inputparams = array(
+ array('ip', 'righttext' => 'leave empty to make it default of your server', 'lefttext' => 'IP Address:')
+ );
+ $this->output .= "Change the server's main IP address that is used in this webserver:" . inputform5($inputparams);
+ }
+
+ $this->showSimilarFunctions('server');
+ }
+
+ function addServer()
+ {
+ $this->requireAdmin();
+
+ global $_insert, $id, $serveroption, $serverip, $accessip, $servertype, $password, $defaultmysqlhostname;
+ $this->getVariable(array('_insert', 'id', 'serveroption', 'servertype', 'serverip', 'accessip', 'password', 'defaultmysqlhostname'));
+ $this->output .= "This is not a cluster setup. These are Individual servers";
+ $res = True;
+
+ if ($servertype == '') {
+ $inputparams = array(
+ 'serverip',
+ array('accessip', 'righttext' => 'leave empty if same as server ip', 'lefttext' => 'Server IP Address:'),
+ array('servertype', 'radio', 'secenekler' => array('mysql' => 'Mysql Database Server', 'binddns' => 'Bind DNS server', 'apache2' => 'Apache Web Server', 'nginx' => 'nginx Web Server')),
+ array('serveroption', 'radio', 'lefttext' => 'Server Option:', 'secenekler' => array('usedalways' => 'This Server is used always in this ehcp', 'optional' => 'This server is optional, may be choosen')),
+ array('isdefault', 'radio', 'lefttext' => 'if Optional: Is Server Default ?', 'secenekler' => array('yes', 'no')),
+ array('password', 'password', 'lefttext' => 'mysql root pass if server is mysql'),
+ array('defaultmysqlhostname', 'lefttext' => 'if mysql server: Default mysql user hostname/ip', 'righttext' => 'This is host of mysql user, to connect from, You should write hostname/ip of your webserver here.. Otherwise, webserver cannot connect to your mysql server..')
+ );
+ $this->output .= "Add Server:" . inputform5($inputparams);
+
+ } else {
+ $this->output .= "Adding server.";
+ if ($accessip == '')
+ $accessip = $serverip;
+
+ $q = "insert into servers (servertype,ip,accessip,mandatory,password,defaultmysqlhostname) values ('$servertype','$serverip','$accessip','" . ($serveroption == 'usedalways' ? 'E' : 'H') . "','$password','$defaultmysqlhostname')"; # E=Yes, H=No
+ $res = $this->executeQuery($q);
+ $this->ok_err_text($res, "Successfully added an additional server.", 'Failed to add an additional server.');
+ }
+ $this->showSimilarFunctions('server');
+
+ return $res;
+
+ }
+
+ function getAllPanelDomains()
+ {
+ $SQL = "SELECT * FROM " . $this->conf['domainstable']['tablename'] . " ORDER BY domainname ASC";
+ $rs = $this->query($SQL);
+ if ($rs !== false) {
+ return $rs;
+ }
return false;
}
- $this->requireCommandLine(__FUNCTION__);
- $res=$this->query("select domainname,homedir from domains where status='$this->status_active' and homedir<>''");
- $str='';
- foreach($res as $dom){
- passthru2("mkdir -p ".$dom['homedir']."/httpdocs/webstats/");
- $str.="webalizer -Q -p -j -n www.".$dom['domainname']." -o ".$dom['homedir']."/httpdocs/webstats ".$dom['homedir']."/logs/access_log -R 100 TopReferrers -r ".$dom['domainname']." HideReferrer \n";
- }
- echo $str;
-
- writeoutput2("/etc/ehcp/webstats.sh",$str,"w");
- passthru2("chmod a+x /etc/ehcp/webstats.sh");
- passthru2("/etc/ehcp/webstats.sh");
- echo "\nwrite webstats file to /etc/ehcp/webstats.sh complete... need to put this in crontab or run automatically.. \n";
-
-}
-
-function set_active_server_ip(){
- $this->requireAdmin();
-
- global $ip,$_insert;
- $this->getVariable(array('ip','_insert'));
-
- if($_insert){
- if($ip<>'') $this->validate_ip_address($ip);
- $this->setConfigValue('activewebserverip',$ip);
- $this->output.='Default Webserver Ip changed in ehcp (not in system)';
- } else {
- $inputparams=array(
- array('ip','righttext'=>'leave empty to make it default of your server', 'lefttext'=>'IP Address:')
- );
- $this->output.="Change the server's main IP address that is used in this webserver:".inputform5($inputparams);
- }
-
- $this->showSimilarFunctions('server');
-}
-
-function addServer(){
- $this->requireAdmin();
-
- global $_insert,$id,$serveroption,$serverip,$accessip,$servertype,$password,$defaultmysqlhostname;
- $this->getVariable(array('_insert','id','serveroption','servertype','serverip','accessip','password','defaultmysqlhostname'));
- $this->output.="This is not a cluster setup. These are Individual servers";
- $res=True;
-
- if($servertype==''){
- $inputparams=array(
- 'serverip',
- array('accessip','righttext'=>'leave empty if same as server ip', 'lefttext'=>'Server IP Address:'),
- array('servertype','radio','secenekler'=>array('mysql'=>'Mysql Database Server','binddns'=>'Bind DNS server','apache2'=>'Apache Web Server','nginx'=>'nginx Web Server')),
- array('serveroption','radio','lefttext'=>'Server Option:','secenekler'=>array('usedalways'=>'This Server is used always in this ehcp','optional'=>'This server is optional, may be choosen')),
- array('isdefault','radio','lefttext'=>'if Optional: Is Server Default ?','secenekler'=>array('yes','no')),
- array('password','password','lefttext'=>'mysql root pass if server is mysql'),
- array('defaultmysqlhostname','lefttext'=>'if mysql server: Default mysql user hostname/ip','righttext'=>'This is host of mysql user, to connect from, You should write hostname/ip of your webserver here.. Otherwise, webserver cannot connect to your mysql server..')
- );
- $this->output.="Add Server:".inputform5($inputparams);
-
- } else {
- $this->output.="Adding server.";
- if($accessip=='')$accessip=$serverip;
-
- $q="insert into servers (servertype,ip,accessip,mandatory,password,defaultmysqlhostname) values ('$servertype','$serverip','$accessip','".($serveroption=='usedalways'?'E':'H')."','$password','$defaultmysqlhostname')"; # E=Yes, H=No
- $res=$this->executeQuery($q);
- $this->ok_err_text($res,"Successfully added an additional server.",'Failed to add an additional server.');
- }
- $this->showSimilarFunctions('server');
-
- return $res;
-
-}
-
-function getAllPanelDomains(){
- $SQL = "SELECT * FROM " . $this->conf['domainstable']['tablename'] . " ORDER BY domainname ASC";
- $rs = $this->query($SQL);
- if($rs !== false){
- return $rs;
- }
- return false;
-}
-
-function getAllPanelDomainsKeyValue(){
- $returnVal = array('NONE'=>'NONE');
- $domains = $this->getAllPanelDomains();
- if($domains !== false){
- foreach($domains as $domain){
- $returnVal[$domain["domainname"]] = $domain["domainname"];
- }
- }
- return $returnVal;
-}
-
-function advancedsettings(){
- $this->requireAdmin();
-
- global $_insert;
- $this->getVariable(array('_insert'));
-
- $optionlist=array(
- array('morethanoneserver','checkbox','righttext'=>'(This is experimental)','checked'=>$this->miscconfig['morethanoneserver'],'default'=>'Yes'),
- array('mysqlcharset','lefttext'=>'Default mysql charset for new databases','righttext'=>'Example: DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci','default'=>$this->miscconfig['mysqlcharset']),
- array('server_id','lefttext'=>'The id of this server, assigned by you, may be empty','righttext'=>'Example: 1 or home, This will be used in future for auto dyndns service inside ehcp','default'=>$this->miscconfig['server_id']),
- array('defaultdnsserverips','lefttext'=>'Default dns server ip\'s that will host new domains:','righttext'=>'Enter list of ip\'s of your dnsservers here, comma separated list (for this server, you may use localhost)','default'=>$this->miscconfig['defaultdnsserverips']),
- array('defaultwebserverips','lefttext'=>'Default webserver ip\'s that will host new domains:','righttext'=>'Enter list of ip\'s of your webservers here, comma separated list (for this server, you may use localhost)','default'=>$this->miscconfig['defaultwebserverips']),
- #array('defaultwebservertypes','lefttext'=>'Webserver type\'s that will run on those webservers above:','righttext'=>'Enter list of webserver type\'s of your webservers here, comma separated list (nginx or apache2, default is apache2 for all if left empty)','default'=>$this->miscconfig['defaultwebservertypes']),
- array('defaultmailserverips','lefttext'=>'Default mailserver ip\'s that will host new domains:','righttext'=>'Enter list of ip\'s of your mailservers here, comma separated list (for this server, you may use localhost)','default'=>$this->miscconfig['defaultmailserverips']),
- array('webservertype','radio','default'=>$this->miscconfig['webservertype'],'righttext'=>'webserver type of this server, default apache2, do not change this unless you know what you are doing','secenekler'=>array('apache2'=>'apache2','nginx'=>'nginx')),
- array('webservermode','radio','default'=>$this->miscconfig['webservermode'],'righttext'=>'Set the SSL mode of the server. The default is non-ssl for port 80 connections (http). SSL is a mixed mode where both port 80 (HTTP) and 443 (HTTPS) resolve. SSLOnly is port 443 HTTPS only.','secenekler'=>array('ssl'=>'ssl','sslonly'=>'sslonly','nonssl'=>'nonssl')),
- array('useglobalsslcert','checkbox','default'=>'Yes','lefttext'=>'Use global SSL certificate for domains WITHOUT user configured certificates','righttext'=>'If selected, an invalid but secure SSL certificate will be used for domains that don\'t have user configured SSL certificates only when a SSL mode is enabled. Leave unchecked if you only want to use SSL for domains that have their own SSL certificates. (Best Mode)','checked'=>$this->miscconfig['useglobalsslcert']),
- array('allowcustomsslnonadmin','checkbox','lefttext'=>'Allow non-admin users to manage and use custom SSL certs for domains','default'=>'Yes','checked'=>$this->miscconfig['allowcustomsslnonadmin'],'righttext'=>'(may break webserver if certificates are invalid)'),
- array('allowanonymousftptodirectory','lefttext'=>'Enable Anonymous READONLY FTP Access to Specific Directory:','righttext'=>'Leave blank to keep disabled. DO NOT USE EHCP DIRECTORIES!','default'=>$this->miscconfig['allowanonymousftptodirectory']),
- array('globalpanelurls', 'textarea', 'lefttext'=>'EHCP Panel Direct URL(s) (Protected by Let\'s Encrypt if SSL is Enabled): (Takes the format of ns3.otherdomain.com,otherdomain.com) Multiple entries separated by comma ",". Leave blank if you don\'t want to configure any. Use only domains or subdomains not currently configured in the panel for best results.', 'default'=> $this->miscconfig['globalpanelurls'], 'skip-ending-colon'=>true),
- array('dkimdomain', 'select', 'secenekler'=>$this->getAllPanelDomainsKeyValue(), 'lefttext'=>'Configure Global DKIM for Emails Using the Domain Of:','righttext'=>'Select "NONE" to Disable DKIM.','default'=>$this->miscconfig['dkimdomain']),
- array('postfixsslcertpath','lefttext'=>'Postfix TLS SSL (Combined in PEM format) Path:','righttext'=>'Leave blank to use the default self-signed certificate.','default'=>$this->miscconfig['postfixsslcertpath']),
- array('restartpostfix','checkbox','lefttext'=>'Reload Postfix SSL (Refresh SSL Cert)','default'=>'Yes'),
- array('sslcouriercertpath','lefttext'=>'POP3-SSL and IMAP-SSL Certificate (Combined in PEM format) Path:','righttext'=>'Leave blank to use the default self-signed certificate.','default'=>$this->miscconfig['sslcouriercertpath']),
- array('restartcourier','checkbox','lefttext'=>'Reload Courier SSL (Refresh SSL Cert)','default'=>'Yes'),
- array('sslvsftpdcertpath','lefttext'=>'VSFTPD Certificate (Combined in PEM format) Path:','righttext'=>'Leave blank to revert back to default VSFTPD configuration.','default'=>$this->miscconfig['sslvsftpdcertpath']),
- array('restartvsftpd','checkbox','lefttext'=>'Reload VSFTPD SSL (Refresh SSL Cert)','default'=>'Yes')
- );
-
- if($this->miscconfig['morethanoneserver']) {
- #$optionlist[]='othersetting';
- $addstr=" List Servers Add Server";
- }
-
- if($_insert){
- $old_webserver_type=$this->miscconfig['webservertype']."-".$this->miscconfig['webservermode'];
- $old_anon_ftp_dir = $this->miscconfig['allowanonymousftptodirectory'];
- $old_globalpanelurls = $this->miscconfig['globalpanelurls'];
- $old_globalcert_type=$this->miscconfig['useglobalsslcert'];
- $old_courier_ssl_cert=$this->miscconfig['sslcouriercertpath'];
- $old_vsftpd_ssl_cert = $this->miscconfig['sslvsftpdcertpath'];
- $old_postfix_ssl_cert = $this->miscconfig['postfixsslcertpath'];
- $old_dkimdomain = $this->miscconfig['dkimdomain'];
-
- if($old_webserver_type=='') $old_webserver_type='apache2-nonssl';
-
- $this->output.="Updating configuration...";
- #$this->debugecho(print_r2($optionlist),3,false);
-
- $optionsToIgnore = array('restartcourier', 'restartvsftpd', 'restartpostfix');
- foreach($optionlist as $option) {
- if(!in_array($option[0], $optionsToIgnore)){
- global ${$option[0]}; # make it global to be able to read in getVariable function..may be we need to fix the global thing..
- $this->getVariable($option[0]);
- $this->setConfigValue($option[0],${$option[0]});
+ function getAllPanelDomainsKeyValue()
+ {
+ $returnVal = array('NONE' => 'NONE');
+ $domains = $this->getAllPanelDomains();
+ if ($domains !== false) {
+ foreach ($domains as $domain) {
+ $returnVal[$domain["domainname"]] = $domain["domainname"];
}
}
+ return $returnVal;
+ }
+ function advancedsettings()
+ {
+ $this->requireAdmin();
- $this->loadConfigWithDaemon(); # loads config for this session, to show below..
- $this->output.="..update complete.";
+ global $_insert;
+ $this->getVariable(array('_insert'));
- $current_webserver_type=$this->miscconfig['webservertype']."-".$this->miscconfig['webservermode'];
- if($old_webserver_type != $current_webserver_type || ($old_globalcert_type != $this->miscconfig['useglobalsslcert'] && $this->miscconfig['webservermode'] = "ssl")){
- $rebuildTriggered = true;
+ $optionlist = array(
+ array('morethanoneserver', 'checkbox', 'righttext' => '(This is experimental)', 'checked' => $this->miscconfig['morethanoneserver'], 'default' => 'Yes'),
+ array('mysqlcharset', 'lefttext' => 'Default mysql charset for new databases', 'righttext' => 'Example: DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci', 'default' => $this->miscconfig['mysqlcharset']),
+ array('server_id', 'lefttext' => 'The id of this server, assigned by you, may be empty', 'righttext' => 'Example: 1 or home, This will be used in future for auto dyndns service inside ehcp', 'default' => $this->miscconfig['server_id']),
+ array('defaultdnsserverips', 'lefttext' => 'Default dns server ip\'s that will host new domains:', 'righttext' => 'Enter list of ip\'s of your dnsservers here, comma separated list (for this server, you may use localhost)', 'default' => $this->miscconfig['defaultdnsserverips']),
+ array('defaultwebserverips', 'lefttext' => 'Default webserver ip\'s that will host new domains:', 'righttext' => 'Enter list of ip\'s of your webservers here, comma separated list (for this server, you may use localhost)', 'default' => $this->miscconfig['defaultwebserverips']),
+ #array('defaultwebservertypes','lefttext'=>'Webserver type\'s that will run on those webservers above:','righttext'=>'Enter list of webserver type\'s of your webservers here, comma separated list (nginx or apache2, default is apache2 for all if left empty)','default'=>$this->miscconfig['defaultwebservertypes']),
+ array('defaultmailserverips', 'lefttext' => 'Default mailserver ip\'s that will host new domains:', 'righttext' => 'Enter list of ip\'s of your mailservers here, comma separated list (for this server, you may use localhost)', 'default' => $this->miscconfig['defaultmailserverips']),
+ array('webservertype', 'radio', 'default' => $this->miscconfig['webservertype'], 'righttext' => 'webserver type of this server, default apache2, do not change this unless you know what you are doing', 'secenekler' => array('apache2' => 'apache2', 'nginx' => 'nginx')),
+ array('webservermode', 'radio', 'default' => $this->miscconfig['webservermode'], 'righttext' => 'Set the SSL mode of the server. The default is non-ssl for port 80 connections (http). SSL is a mixed mode where both port 80 (HTTP) and 443 (HTTPS) resolve. SSLOnly is port 443 HTTPS only.', 'secenekler' => array('ssl' => 'ssl', 'sslonly' => 'sslonly', 'nonssl' => 'nonssl')),
+ array('useglobalsslcert', 'checkbox', 'default' => 'Yes', 'lefttext' => 'Use global SSL certificate for domains WITHOUT user configured certificates', 'righttext' => 'If selected, an invalid but secure SSL certificate will be used for domains that don\'t have user configured SSL certificates only when a SSL mode is enabled. Leave unchecked if you only want to use SSL for domains that have their own SSL certificates. (Best Mode)', 'checked' => $this->miscconfig['useglobalsslcert']),
+ array('allowcustomsslnonadmin', 'checkbox', 'lefttext' => 'Allow non-admin users to manage and use custom SSL certs for domains', 'default' => 'Yes', 'checked' => $this->miscconfig['allowcustomsslnonadmin'], 'righttext' => '(may break webserver if certificates are invalid)'),
+ array('allowanonymousftptodirectory', 'lefttext' => 'Enable Anonymous READONLY FTP Access to Specific Directory:', 'righttext' => 'Leave blank to keep disabled. DO NOT USE EHCP DIRECTORIES!', 'default' => $this->miscconfig['allowanonymousftptodirectory']),
+ array('globalpanelurls', 'textarea', 'lefttext' => 'EHCP Panel Direct URL(s) (Protected by Let\'s Encrypt if SSL is Enabled): (Takes the format of ns3.otherdomain.com,otherdomain.com) Multiple entries separated by comma ",". Leave blank if you don\'t want to configure any. Use only domains or subdomains not currently configured in the panel for best results.', 'default' => $this->miscconfig['globalpanelurls'], 'skip-ending-colon' => true),
+ array('dkimdomain', 'select', 'secenekler' => $this->getAllPanelDomainsKeyValue(), 'lefttext' => 'Configure Global DKIM for Emails Using the Domain Of:', 'righttext' => 'Select "NONE" to Disable DKIM.', 'default' => $this->miscconfig['dkimdomain']),
+ array('postfixsslcertpath', 'lefttext' => 'Postfix TLS SSL (Combined in PEM format) Path:', 'righttext' => 'Leave blank to use the default self-signed certificate.', 'default' => $this->miscconfig['postfixsslcertpath']),
+ array('restartpostfix', 'checkbox', 'lefttext' => 'Reload Postfix SSL (Refresh SSL Cert)', 'default' => 'Yes'),
+ array('sslcouriercertpath', 'lefttext' => 'POP3-SSL and IMAP-SSL Certificate (Combined in PEM format) Path:', 'righttext' => 'Leave blank to use the default self-signed certificate.', 'default' => $this->miscconfig['sslcouriercertpath']),
+ array('restartcourier', 'checkbox', 'lefttext' => 'Reload Courier SSL (Refresh SSL Cert)', 'default' => 'Yes'),
+ array('sslvsftpdcertpath', 'lefttext' => 'VSFTPD Certificate (Combined in PEM format) Path:', 'righttext' => 'Leave blank to revert back to default VSFTPD configuration.', 'default' => $this->miscconfig['sslvsftpdcertpath']),
+ array('restartvsftpd', 'checkbox', 'lefttext' => 'Reload VSFTPD SSL (Refresh SSL Cert)', 'default' => 'Yes')
+ );
+
+ if ($this->miscconfig['morethanoneserver']) {
+ #$optionlist[]='othersetting';
+ $addstr = " List Servers Add Server";
}
-
- if($old_globalpanelurls != $this->miscconfig['globalpanelurls']){
-
- // Get array of entries
- $entries = $this->explodeComma($this->miscconfig['globalpanelurls']);
- $oldEntries = $this->explodeComma($old_globalpanelurls);
-
- // Check to make sure entries are valid
- $valid = $this->checkValidGlobalPanelURLs($entries);
-
- if(!$valid){
- // Reset its value
- $this->setConfigValue('globalpanelurls',$old_globalpanelurls);
- }else{
- // Change is valid, so remove the old lets encrypt certs if they exist
- if($this->hasValueOrZero($old_globalpanelurls) && $oldEntries){
- $this->removeLetsEncryptCertificates($oldEntries);
+
+ if ($_insert) {
+ $old_webserver_type = $this->miscconfig['webservertype'] . "-" . $this->miscconfig['webservermode'];
+ $old_anon_ftp_dir = $this->miscconfig['allowanonymousftptodirectory'];
+ $old_globalpanelurls = $this->miscconfig['globalpanelurls'];
+ $old_globalcert_type = $this->miscconfig['useglobalsslcert'];
+ $old_courier_ssl_cert = $this->miscconfig['sslcouriercertpath'];
+ $old_vsftpd_ssl_cert = $this->miscconfig['sslvsftpdcertpath'];
+ $old_postfix_ssl_cert = $this->miscconfig['postfixsslcertpath'];
+ $old_dkimdomain = $this->miscconfig['dkimdomain'];
+
+ if ($old_webserver_type == '')
+ $old_webserver_type = 'apache2-nonssl';
+
+ $this->output .= "Updating configuration...";
+ #$this->debugecho(print_r2($optionlist),3,false);
+
+ $optionsToIgnore = array('restartcourier', 'restartvsftpd', 'restartpostfix');
+ foreach ($optionlist as $option) {
+ if (!in_array($option[0], $optionsToIgnore)) {
+ global ${$option[0]}; # make it global to be able to read in getVariable function..may be we need to fix the global thing..
+ $this->getVariable($option[0]);
+ $this->setConfigValue($option[0], ${$option[0]});
}
}
-
- // Sync domains after let's encrypt certificate cleanup
- if(!isset($rebuildTriggered) && $rebuildTriggered !== true && $valid){
- $this->addDaemonOp('syncdomains','','','','sync domains');
+
+
+ $this->loadConfigWithDaemon(); # loads config for this session, to show below..
+ $this->output .= "..update complete.";
+
+ $current_webserver_type = $this->miscconfig['webservertype'] . "-" . $this->miscconfig['webservermode'];
+ if ($old_webserver_type != $current_webserver_type || ($old_globalcert_type != $this->miscconfig['useglobalsslcert'] && $this->miscconfig['webservermode'] = "ssl")) {
+ $rebuildTriggered = true;
}
-
- }
-
- if($old_dkimdomain != $this->miscconfig['dkimdomain']){
- if($this->miscconfig['dkimdomain'] != 'NONE' && !empty($this->miscconfig['dkimdomain'])){
- if(isset($old_dkimdomain) && !empty($old_dkimdomain) && $old_dkimdomain != 'NONE'){
- $this->addDaemonOp("manage_dkim",'remove',$old_dkimdomain,'','handle dkim postfix configuration');
+
+ if ($old_globalpanelurls != $this->miscconfig['globalpanelurls']) {
+
+ // Get array of entries
+ $entries = $this->explodeComma($this->miscconfig['globalpanelurls']);
+ $oldEntries = $this->explodeComma($old_globalpanelurls);
+
+ // Check to make sure entries are valid
+ $valid = $this->checkValidGlobalPanelURLs($entries);
+
+ if (!$valid) {
+ // Reset its value
+ $this->setConfigValue('globalpanelurls', $old_globalpanelurls);
+ } else {
+ // Change is valid, so remove the old lets encrypt certs if they exist
+ if ($this->hasValueOrZero($old_globalpanelurls) && $oldEntries) {
+ $this->removeLetsEncryptCertificates($oldEntries);
+ }
}
- $this->addDaemonOp("manage_dkim",'add',$this->miscconfig['dkimdomain'],'','handle dkim postfix configuration');
- }else{
- if(isset($old_dkimdomain) && !empty($old_dkimdomain) && $this->miscconfig['dkimdomain'] == 'NONE'){
- $this->addDaemonOp("manage_dkim",'remove',$old_dkimdomain,'','handle dkim postfix configuration');
+
+ // Sync domains after let's encrypt certificate cleanup
+ if (!isset($rebuildTriggered) && $rebuildTriggered !== true && $valid) {
+ $this->addDaemonOp('syncdomains', '', '', '', 'sync domains');
+ }
+
+ }
+
+ if ($old_dkimdomain != $this->miscconfig['dkimdomain']) {
+ if ($this->miscconfig['dkimdomain'] != 'NONE' && !empty($this->miscconfig['dkimdomain'])) {
+ if (isset($old_dkimdomain) && !empty($old_dkimdomain) && $old_dkimdomain != 'NONE') {
+ $this->addDaemonOp("manage_dkim", 'remove', $old_dkimdomain, '', 'handle dkim postfix configuration');
+ }
+ $this->addDaemonOp("manage_dkim", 'add', $this->miscconfig['dkimdomain'], '', 'handle dkim postfix configuration');
+ } else {
+ if (isset($old_dkimdomain) && !empty($old_dkimdomain) && $this->miscconfig['dkimdomain'] == 'NONE') {
+ $this->addDaemonOp("manage_dkim", 'remove', $old_dkimdomain, '', 'handle dkim postfix configuration');
+ }
}
}
- }
-
- // Handle courier POP3-SSL and IMAP-SSL certificate path
- if($old_courier_ssl_cert != $this->miscconfig['sslcouriercertpath']){
- if($this->hasValueOrZero($this->miscconfig['sslcouriercertpath']) && !isextension($this->miscconfig['sslcouriercertpath'], 'pem')){
- // Reset its value since it's not valid
- $this->setConfigValue('sslcouriercertpath',$old_courier_ssl_cert);
+
+ // Handle courier POP3-SSL and IMAP-SSL certificate path
+ if ($old_courier_ssl_cert != $this->miscconfig['sslcouriercertpath']) {
+ if ($this->hasValueOrZero($this->miscconfig['sslcouriercertpath']) && !isextension($this->miscconfig['sslcouriercertpath'], 'pem')) {
+ // Reset its value since it's not valid
+ $this->setConfigValue('sslcouriercertpath', $old_courier_ssl_cert);
+ }
+ $this->addDaemonOp('handlecouriersslcert', '', '', '', 'handlecouriersslcert');
+ } else {
+ // If they're the same, the certificate may have changed, so we allow a quick way to restart the courier ssl services
+ if ($this->hasValueOrZero($_REQUEST["restartcourier"])) {
+ $this->addDaemonOp('resynccourierssl', '', '', '', 'resynccourierssl');
+ }
}
- $this->addDaemonOp('handlecouriersslcert','','','','handlecouriersslcert');
- }else{
- // If they're the same, the certificate may have changed, so we allow a quick way to restart the courier ssl services
- if($this->hasValueOrZero($_REQUEST["restartcourier"])){
- $this->addDaemonOp('resynccourierssl','','','','resynccourierssl');
+
+ // Handle VSFTPD SSL certificate path
+ if ($old_vsftpd_ssl_cert != $this->miscconfig['sslvsftpdcertpath']) {
+ if ($this->hasValueOrZero($this->miscconfig['sslvsftpdcertpath']) && !isextension($this->miscconfig['sslvsftpdcertpath'], 'pem')) {
+ // Reset its value since it's not valid
+ $this->setConfigValue('sslvsftpdcertpath', $old_vsftpd_ssl_cert);
+ }
+ $this->addDaemonOp('handlevsftpdsslcert', '', '', '', 'handlevsftpdsslcert');
+ } else {
+ // If they're the same, the certificate may have changed, so we allow a quick way to restart the courier ssl services
+ if ($this->hasValueOrZero($_REQUEST["restartvsftpd"])) {
+ $this->addDaemonOp('resyncvsftpdssl', '', '', '', 'resyncvsftpdssl');
+ }
}
- }
-
- // Handle VSFTPD SSL certificate path
- if($old_vsftpd_ssl_cert != $this->miscconfig['sslvsftpdcertpath']){
- if($this->hasValueOrZero($this->miscconfig['sslvsftpdcertpath']) && !isextension($this->miscconfig['sslvsftpdcertpath'], 'pem')){
- // Reset its value since it's not valid
- $this->setConfigValue('sslvsftpdcertpath',$old_vsftpd_ssl_cert);
+
+ // Handle Postfix SSL certificate path
+ if ($old_postfix_ssl_cert != $this->miscconfig['postfixsslcertpath']) {
+ if ($this->hasValueOrZero($this->miscconfig['postfixsslcertpath']) && !isextension($this->miscconfig['postfixsslcertpath'], 'pem')) {
+ // Reset its value since it's not valid
+ $this->setConfigValue('postfixsslcertpath', $old_postfix_ssl_cert);
+ }
+ $this->addDaemonOp('handlepostfixsslcert', '', '', '', 'handlepostfixsslcert');
+ } else {
+ // If they're the same, the certificate may have changed, so we allow a quick way to restart the courier ssl services
+ if ($this->hasValueOrZero($_REQUEST["restartpostfix"])) {
+ $this->addDaemonOp('resyncpostfixssl', '', '', '', 'resyncpostfixssl');
+ }
}
- $this->addDaemonOp('handlevsftpdsslcert','','','','handlevsftpdsslcert');
- }else{
- // If they're the same, the certificate may have changed, so we allow a quick way to restart the courier ssl services
- if($this->hasValueOrZero($_REQUEST["restartvsftpd"])){
- $this->addDaemonOp('resyncvsftpdssl','','','','resyncvsftpdssl');
+
+ // Handle anonymous ftp:
+ if ($old_anon_ftp_dir != $this->miscconfig['allowanonymousftptodirectory']) {
+ $this->addDaemonOp('configure_anon_ftp', '', '', '', 'configure_anon_ftp');
}
- }
-
- // Handle Postfix SSL certificate path
- if($old_postfix_ssl_cert != $this->miscconfig['postfixsslcertpath']){
- if($this->hasValueOrZero($this->miscconfig['postfixsslcertpath']) && !isextension($this->miscconfig['postfixsslcertpath'], 'pem')){
- // Reset its value since it's not valid
- $this->setConfigValue('postfixsslcertpath', $old_postfix_ssl_cert);
+
+ if ($rebuildTriggered) {
+ $this->addDaemonOp('rebuild_webserver_configs', '', '', '', 'rebuild_webserver_configs');
}
- $this->addDaemonOp('handlepostfixsslcert','','','','handlepostfixsslcert');
- }else{
- // If they're the same, the certificate may have changed, so we allow a quick way to restart the courier ssl services
- if($this->hasValueOrZero($_REQUEST["restartpostfix"])){
- $this->addDaemonOp('resyncpostfixssl','','','','resyncpostfixssl');
- }
- }
-
- // Handle anonymous ftp:
- if($old_anon_ftp_dir != $this->miscconfig['allowanonymousftptodirectory']){
- $this->addDaemonOp('configure_anon_ftp','','','','configure_anon_ftp');
- }
-
- if($rebuildTriggered){
- $this->addDaemonOp('rebuild_webserver_configs','','','','rebuild_webserver_configs');
+
+ } else {
+ $optionlist[] = array('op', 'default' => __FUNCTION__, 'type' => 'hidden');
+ $this->output .= "Advanced Settings: (In future: server plans will be done, most of these settings will be filled from serverplans) " . inputform5($optionlist) . $addstr;
}
- } else {
- $optionlist[]=array('op','default'=>__FUNCTION__,'type'=>'hidden');
- $this->output.="Advanced Settings: (In future: server plans will be done, most of these settings will be filled from serverplans) ". inputform5($optionlist).$addstr;
}
-}
-
-function explodeComma($input){
- if($this->hasValueOrZero($input)){
- if(stripos($input, ",") !== false){
- $entries = explode(",", $input);
- }else{
- $entries[] = $input;
+ function explodeComma($input)
+ {
+ if ($this->hasValueOrZero($input)) {
+ if (stripos($input, ",") !== false) {
+ $entries = explode(",", $input);
+ } else {
+ $entries[] = $input;
+ }
+ return $entries;
}
- return $entries;
+ return false;
}
- return false;
-}
-function checkValidGlobalPanelURLs($urls){
-
- foreach($urls as $entry){
- if(!$this->isValidDomain($entry) && !$this->isValidSubDomain($entry)){
- return false;
+ function checkValidGlobalPanelURLs($urls)
+ {
+
+ foreach ($urls as $entry) {
+ if (!$this->isValidDomain($entry) && !$this->isValidSubDomain($entry)) {
+ return false;
+ }
}
+
+ return true;
}
-
- return true;
-}
-function listServers(){
- $this->requireAdmin();
+ function listServers()
+ {
+ $this->requireAdmin();
- $this->output.="Servers ";
- $this->listTable("", "serverstable", $filter);
- $this->showSimilarFunctions('server');
-}
-
-function otherpage($id){# de-selects a domain and display other page whose name is $id_lang.html , function written to be used later...
- $this->deselectdomain2();
- return $this->displayHome($id);
-}
-
-function otheroperations(){ # de-selects a domain and display other operations page.. or some other page
- $this->deselectdomain2();
- if(!$this->isadmin() and $this->userinfo['maxdomains']>1) {
- if($this->selecteddomain=='') $home='homepage_reseller_other';
- } elseif($this->isadmin()) {
- $home='homepage_serveradmin_other';
+ $this->output .= "Servers ";
+ $this->listTable("", "serverstable", $filter);
+ $this->showSimilarFunctions('server');
}
- return $this->displayHome($home);
-}
-function selectdomain($id){ # selects a domain and displays home
- global $domainname;
- $this->getVariable(array("domainname"));
-
- if($id<>'') $domainname=$id;
- $domainname=$this->chooseDomain(__FUNCTION__,$domainname);
- #$this->output.="Domain selected... $domainname, id: $id ";
-
- # reset search session values
- $_SESSION['sess_arananalan']='';
- $_SESSION['sess_aranan']='';
-
- $this->displayHome();
-}
-
-function updateInstallScriptSQL(){
- // Require's admin priv
- $this->requireAdmin();
- $this->addDaemonOp("update_ez_install", '', 'xx', '', 'Update EZ Script Install SQL');
- $this->output.="
Easy installation script SQL has successfully been updated from the ehcpforce.tk master.
";
-
- return True;
-}
-
-function suggestnewscript(){
- global $name,$url,$scriptdirtocopy,$homepage,$description,$lastmsgtoehcpdeveloper;
- $this->getVariable(array('name','url','scriptdirtocopy','homepage','description'));
-
- if(!$url){
- $inputparams=array(
- array('name', 'lefttext'=>'Script Name:'),
- array('url', 'lefttext'=>'Script URL:'),
- array('scriptdirtocopy', 'lefttext'=>'Script Directory To Copy:'),
- array('homepage', 'lefttext'=>'Script Homepage:'),
- array('description','textarea', 'lefttext'=>'Script Description:'),
- array('op','hidden','default'=>__FUNCTION__)
- );
- $this->output.="Suggest a new application integration by providing a detailed description of the script. ".inputform5($inputparams). "The script may be added if approved by an admin. ";
-
- } else {
- $this->output.="Thank you for your submission. The script will be reviewed by the server admin and will be added if approved. ";
- $subj="New Easy Install Script Integration Request";
- $msg="
EHCP Admin:
A user has suggested that an application be integrated with the easy installation scripts module. Name of the script: $name URL to Application: $url Script Homepage: $homepage Description: $description";
- $this->infotoadminemail($msg, $subj);
+ function otherpage($id)
+ { # de-selects a domain and display other page whose name is $id_lang.html , function written to be used later...
+ $this->deselectdomain2();
+ return $this->displayHome($id);
}
-}
-
-
-function read_dir($path,$func="is_file"){
- $dirArray=array();
- $myDirectory = opendir($path);
- while($entryName = readdir($myDirectory)) {
- if($func("$path/$entryName") and $entryName<>'.' and $entryName<>'..' and $entryName <> 'all_templates') $dirArray[] = $entryName;
+ function otheroperations()
+ { # de-selects a domain and display other operations page.. or some other page
+ $this->deselectdomain2();
+ if (!$this->isadmin() and $this->userinfo['maxdomains'] > 1) {
+ if ($this->selecteddomain == '')
+ $home = 'homepage_reseller_other';
+ } elseif ($this->isadmin()) {
+ $home = 'homepage_serveradmin_other';
+ }
+ return $this->displayHome($home);
}
- closedir($myDirectory);
- return $dirArray;
-}
-function changetemplate(){
- global $template;
- $this->getVariable(array('template'));
- $this->requireAdmin(); # only admin can change theme.... normally should be: everybody can change theme, theme of each user stored in their data, after login, every user should see its theme/lang...
- # before login: default theme/lang...
+ function selectdomain($id)
+ { # selects a domain and displays home
+ global $domainname;
+ $this->getVariable(array("domainname"));
+
+ if ($id <> '')
+ $domainname = $id;
+ $domainname = $this->chooseDomain(__FUNCTION__, $domainname);
+ #$this->output.="Domain selected... $domainname, id: $id
Easy installation script SQL has successfully been updated from the ehcpforce.tk master.
";
- $out=" Small statistics of server: Panel User count:".$this->recordcount($this->conf['logintable']['tablename'],'').
- " Domain Count:".$this->recordcount($this->conf['domainstable']['tablename'],'').
- " FTP users count:".$this->recordcount($this->conf['ftpuserstable']['tablename'],'').
- " Email users count:".$this->recordcount($this->conf['emailuserstable']['tablename'],'')." $email Version: $ehcpversion $isaret ";
-
- return $out;
-}
-
-
-function isNoPassOp(){ # is this operation a no password one? such as an application before login, no password required.
- $this->debugecho2("file:".__FILE__.", Line:".__LINE__.", Function:".__FUNCTION__.": kontrol:".$this->op,4);
- $nopassops=array("applyforaccount","applyfordomainaccount",'sifrehatirlat','activate');
- return in_array($this->op,$nopassops);
-
- #** dikkat, burada guvenlik kontrolu yapilmiyor, dikkat edilmesi lazim...
-}
-
-
-function options(){
- $this->requireAdmin();
-
- global $edit,$_insert,$dnsip;
- $this->getVariable(array('edit','_insert','dnsip','localip'));
- #echo print_r2($this->miscconfig);
-
- # new style: options as an array, so, easy addition of new options..
- $optionlist=array(
- array('updatehostsfile','checkbox','lefttext'=>'This machine is used for Desktop access too (Update hosts file with domains)','default'=>'Yes','checked'=>$this->miscconfig['updatehostsfile']),
- array('localip','lefttext'=>'Local ip of server','default'=>$this->miscconfig['localip']),
- array('dnsip','lefttext'=>'dnsip (outside/real/static ip of server)','default'=>$this->miscconfig['dnsip']),
- array('dnsipv6','lefttext'=>'dnsip V6(outside/real/static V6 ip of server)','default'=>$this->miscconfig['dnsipv6'],'righttext'=>'Leave empty to disable (experimental even if enabled)'),
- array('updatednsipfromweb','checkbox','lefttext'=>'Do you use dynamic ip/dns?','righttext'=>'Check this if your server is behind a dynamic IP','default'=>'Yes','checked'=>$this->miscconfig['updatednsipfromweb']),
- array('banner','textarea','default'=>$this->miscconfig['banner']),
- array('adminemail','lefttext'=>'Admin Email','default'=>$this->miscconfig['adminemail']),
- array('defaulttemplate','default'=>$this->miscconfig['defaulttemplate']),
- array('defaultlanguage','default'=>$this->defaultlanguage),
- array('messagetonewuser','textarea','default'=>$this->miscconfig['messagetonewuser']),
- array('disableeditapachetemplate','checkbox','lefttext'=>'Disable Custom http for non-admins','default'=>'Yes','checked'=>$this->miscconfig['disableeditapachetemplate'],'righttext'=>'This is a security measure to disable non-experienced users to break configs'),
- array('disableeditdnstemplate','checkbox','lefttext'=>'Disable Custom dns for non-admins','default'=>'Yes','checked'=>$this->miscconfig['disableeditdnstemplate'],'righttext'=>'This is a security measure to disable non-experienced users to break configs'),
- array('forcedeleteftpuserhomedir','checkbox','lefttext'=>'When an FTP Account is deleted, also delete ALL FILES and FOLDERS that used to be accessible by the deleted FTP account','default'=>'Yes','checked'=>$this->miscconfig['forcedeleteftpuserhomedir'],'righttext'=>'Will delete files that could be owned by a domain, subdomain, other user, or other FTP account. RECOMMENDED: Do NOT Enabled'),
- array('forcedeletesubdomainfiles','checkbox','lefttext'=>'When a subdomain is deleted, delete the subdomain\'s files automatically too.','default'=>'Yes','checked'=>$this->miscconfig['forcedeletesubdomainfiles']),
- array('turnoffoverquotadomains','checkbox','lefttext'=>'Turn off over quota domains','default'=>'Yes','checked'=>$this->miscconfig['turnoffoverquotadomains']),
- array('quotaupdateinterval','default'=>$this->miscconfig['quotaupdateinterval'],'righttext'=>'interval in hours'),
- array('userscansignup','checkbox','default'=>'Yes','checked'=>$this->miscconfig['userscansignup'],'righttext'=>'disabled by default, can users sign up for domains/ftp? (you should approve/reject them in short time)'),
- array('enablewebstats','checkbox','default'=>'Yes','checked'=>$this->miscconfig['enablewebstats'],'righttext'=>'enabled by default, this can use some of server resources, so, disabling it may help some slow servers to speed up'),
- array('enablewildcarddomain','checkbox','default'=>'Yes','checked'=>$this->miscconfig['enablewildcarddomain'],'righttext'=>'do you want xxxx.yourdomain.com to show your domain homepage? disabled by default, and shows server home, which is default index, ehcp home.'),
- array('freednsidentifier','default'=>$this->miscconfig['freednsidentifier'],'righttext'=>'freedns.afraid.org unique identifier, for dynamic dns update, automatic; take your id from freedns.afraid.org if you want to use that. ')
-
- #array('singleserverip','default'=>$this->miscconfig['singleserverip'])
-
- );
-
-
-
- if($_insert){
- $old_webserver_type=$this->miscconfig['webservertype']."-".$this->miscconfig['webservermode'];
- if($old_webserver_type=='') $old_webserver_type='apache2-nonssl';
-
- $this->output.="Updating configuration...";
- $this->validate_ip_address($dnsip);
-
- foreach($optionlist as $option) {
- global ${$option[0]}; # make it global to be able to read in getVariable function..may be we need to fix the global thing..
- $this->getVariable($option[0]);
- $this->setConfigValue($option[0],${$option[0]});
- }
-
- # options that use longvalue:
- $this->setConfigValue("banner","",'value');# delete short value for banner, if there is any.. because longvalue is used for banner.
- $this->setConfigValue("banner",$banner,'longvalue');
-
- # operations that needs daemon or other settings.
-
- if($dnsip != $this->miscconfig['dnsip']){ # fix all dnsip related config if dnsip is changed...
- $this->addDaemonOp("fixmailconfiguration",'','','','fix mail configuration'); # fixes postfix configuration
- $this->addDaemonOp('syncdns','','','','sync dns'); # syncs the DNS zones to use the new IP address
- if($updatehostsfile<>'') {
- $this->addDaemonOp("updatehostsfile",'','','','update hostsfile'); # Update hosts file too
- }
- }
-
- $addSyncOpAfterSettingsReloaded = false;
- if($enablewildcarddomain != $this->miscconfig['enablewildcarddomain']){
- $addSyncOpAfterSettingsReloaded = true;
- }
-
- if($defaultlanguage) { # update for current session too..
- $_SESSION['currentlanguage']='';
- $this->defaultlanguage=$this->currentlanguage=$defaultlanguage;
- }
-
- # load latest config again in this session.
- $this->loadConfigWithDaemon(); # loads config for this session, to show below..
- if($updatehostsfile<>'') $this->addDaemonOp("updatehostsfile",'','','','update hostsfile'); # updateHostsFile degistiginden dolayi
- if($addSyncOpAfterSettingsReloaded){
- $this->addDaemonOp('syncdomains','','','','sync domains');
- $this->addDaemonOp('syncdns','','','','sync dns'); # syncs the DNS zones to use the new IP address
- }
-
- $this->output.="..update complete.";
-
- } elseif ($edit) {
- $optionlist[]=array('op','default'=>__FUNCTION__,'type'=>'hidden');
- $this->output.="
".print_r3($this->miscconfig,"$this->th Option Name $this->th Option Value ");
+ return True;
}
- $this->showSimilarFunctions('options');
- $this->debugecho(print_r2($this->miscconfig),3,false);
-}
+ function suggestnewscript()
+ {
+ global $name, $url, $scriptdirtocopy, $homepage, $description, $lastmsgtoehcpdeveloper;
+ $this->getVariable(array('name', 'url', 'scriptdirtocopy', 'homepage', 'description'));
+
+ if (!$url) {
+ $inputparams = array(
+ array('name', 'lefttext' => 'Script Name:'),
+ array('url', 'lefttext' => 'Script URL:'),
+ array('scriptdirtocopy', 'lefttext' => 'Script Directory To Copy:'),
+ array('homepage', 'lefttext' => 'Script Homepage:'),
+ array('description', 'textarea', 'lefttext' => 'Script Description:'),
+ array('op', 'hidden', 'default' => __FUNCTION__)
+ );
+ $this->output .= "Suggest a new application integration by providing a detailed description of the script. " . inputform5($inputparams) . "The script may be added if approved by an admin. ";
+
+ } else {
+ $this->output .= "Thank you for your submission. The script will be reviewed by the server admin and will be added if approved. ";
+ $subj = "New Easy Install Script Integration Request";
+ $msg = "
EHCP Admin:
A user has suggested that an application be integrated with the easy installation scripts module. Name of the script: $name URL to Application: $url Script Homepage: $homepage Description: $description";
+ $this->infotoadminemail($msg, $subj);
+ }
+ }
-function settings(){
- $this->requireAdmin();
- global $edit,$_insert,$dnsip,$group;
- $this->getVariable(array('edit','_insert','group'));
- #echo print_r2($this->miscconfig);
+ function read_dir($path, $func = "is_file")
+ {
+ $dirArray = array();
+ $myDirectory = opendir($path);
+ while ($entryName = readdir($myDirectory)) {
+ if ($func("$path/$entryName") and $entryName <> '.' and $entryName <> '..' and $entryName <> 'all_templates')
+ $dirArray[] = $entryName;
+ }
+ closedir($myDirectory);
+ return $dirArray;
+ }
- # new style: options as an array, so, easy addition of new options..
+ function changetemplate()
+ {
+ global $template;
+ $this->getVariable(array('template'));
+ $this->requireAdmin(); # only admin can change theme.... normally should be: everybody can change theme, theme of each user stored in their data, after login, every user should see its theme/lang...
+ # before login: default theme/lang...
+
+ if (!$template) {
+ $dirArray = $this->read_dir("./templates", "is_dir");
+ $this->output .= "Select the template : ";
+ foreach ($dirArray as $dir)
+ $this->output .= "$dir ";
+ } else {
+ $this->setConfigValue("defaulttemplate", $template);
+ $this->output .= "Changed default template to : $template ";
+ $this->loadConfigWithDaemon();
+ $this->displayHome();
+ }
+ }
+
+ function smallserverstats($isaret = '')
+ {
+ global $ehcpversion;
+ $email = str_replace('@', '((at))', $this->conf['adminemail']); # to prevent spam...
+
+
+ $out = " Small statistics of server: Panel User count:" . $this->recordcount($this->conf['logintable']['tablename'], '') .
+ " Domain Count:" . $this->recordcount($this->conf['domainstable']['tablename'], '') .
+ " FTP users count:" . $this->recordcount($this->conf['ftpuserstable']['tablename'], '') .
+ " Email users count:" . $this->recordcount($this->conf['emailuserstable']['tablename'], '') . " $email Version: $ehcpversion $isaret ";
+
+ return $out;
+ }
+
+
+ function isNoPassOp()
+ { # is this operation a no password one? such as an application before login, no password required.
+ $this->debugecho2("file:" . __FILE__ . ", Line:" . __LINE__ . ", Function:" . __FUNCTION__ . ": kontrol:" . $this->op, 4);
+ $nopassops = array("applyforaccount", "applyfordomainaccount", 'sifrehatirlat', 'activate');
+ return in_array($this->op, $nopassops);
+
+ #** dikkat, burada guvenlik kontrolu yapilmiyor, dikkat edilmesi lazim...
+ }
+
+
+ function options()
+ {
+ $this->requireAdmin();
+
+ global $edit, $_insert, $dnsip;
+ $this->getVariable(array('edit', '_insert', 'dnsip', 'localip'));
+ #echo print_r2($this->miscconfig);
+
+ # new style: options as an array, so, easy addition of new options..
+ $optionlist = array(
+ array('updatehostsfile', 'checkbox', 'lefttext' => 'This machine is used for Desktop access too (Update hosts file with domains)', 'default' => 'Yes', 'checked' => $this->miscconfig['updatehostsfile']),
+ array('localip', 'lefttext' => 'Local ip of server', 'default' => $this->miscconfig['localip']),
+ array('dnsip', 'lefttext' => 'dnsip (outside/real/static ip of server)', 'default' => $this->miscconfig['dnsip']),
+ array('dnsipv6', 'lefttext' => 'dnsip V6(outside/real/static V6 ip of server)', 'default' => $this->miscconfig['dnsipv6'], 'righttext' => 'Leave empty to disable (experimental even if enabled)'),
+ array('updatednsipfromweb', 'checkbox', 'lefttext' => 'Do you use dynamic ip/dns?', 'righttext' => 'Check this if your server is behind a dynamic IP', 'default' => 'Yes', 'checked' => $this->miscconfig['updatednsipfromweb']),
+ array('banner', 'textarea', 'default' => $this->miscconfig['banner']),
+ array('adminemail', 'lefttext' => 'Admin Email', 'default' => $this->miscconfig['adminemail']),
+ array('defaulttemplate', 'default' => $this->miscconfig['defaulttemplate']),
+ array('defaultlanguage', 'default' => $this->defaultlanguage),
+ array('messagetonewuser', 'textarea', 'default' => $this->miscconfig['messagetonewuser']),
+ array('disableeditapachetemplate', 'checkbox', 'lefttext' => 'Disable Custom http for non-admins', 'default' => 'Yes', 'checked' => $this->miscconfig['disableeditapachetemplate'], 'righttext' => 'This is a security measure to disable non-experienced users to break configs'),
+ array('disableeditdnstemplate', 'checkbox', 'lefttext' => 'Disable Custom dns for non-admins', 'default' => 'Yes', 'checked' => $this->miscconfig['disableeditdnstemplate'], 'righttext' => 'This is a security measure to disable non-experienced users to break configs'),
+ array('forcedeleteftpuserhomedir', 'checkbox', 'lefttext' => 'When an FTP Account is deleted, also delete ALL FILES and FOLDERS that used to be accessible by the deleted FTP account', 'default' => 'Yes', 'checked' => $this->miscconfig['forcedeleteftpuserhomedir'], 'righttext' => 'Will delete files that could be owned by a domain, subdomain, other user, or other FTP account. RECOMMENDED: Do NOT Enabled'),
+ array('forcedeletesubdomainfiles', 'checkbox', 'lefttext' => 'When a subdomain is deleted, delete the subdomain\'s files automatically too.', 'default' => 'Yes', 'checked' => $this->miscconfig['forcedeletesubdomainfiles']),
+ array('turnoffoverquotadomains', 'checkbox', 'lefttext' => 'Turn off over quota domains', 'default' => 'Yes', 'checked' => $this->miscconfig['turnoffoverquotadomains']),
+ array('quotaupdateinterval', 'default' => $this->miscconfig['quotaupdateinterval'], 'righttext' => 'interval in hours'),
+ array('userscansignup', 'checkbox', 'default' => 'Yes', 'checked' => $this->miscconfig['userscansignup'], 'righttext' => 'disabled by default, can users sign up for domains/ftp? (you should approve/reject them in short time)'),
+ array('enablewebstats', 'checkbox', 'default' => 'Yes', 'checked' => $this->miscconfig['enablewebstats'], 'righttext' => 'enabled by default, this can use some of server resources, so, disabling it may help some slow servers to speed up'),
+ array('enablewildcarddomain', 'checkbox', 'default' => 'Yes', 'checked' => $this->miscconfig['enablewildcarddomain'], 'righttext' => 'do you want xxxx.yourdomain.com to show your domain homepage? disabled by default, and shows server home, which is default index, ehcp home.'),
+ array('freednsidentifier', 'default' => $this->miscconfig['freednsidentifier'], 'righttext' => 'freedns.afraid.org unique identifier, for dynamic dns update, automatic; take your id from freedns.afraid.org if you want to use that. ')
+
+ #array('singleserverip','default'=>$this->miscconfig['singleserverip'])
+
+ );
+
+
+
+ if ($_insert) {
+ $old_webserver_type = $this->miscconfig['webservertype'] . "-" . $this->miscconfig['webservermode'];
+ if ($old_webserver_type == '')
+ $old_webserver_type = 'apache2-nonssl';
+
+ $this->output .= "Updating configuration...";
+ $this->validate_ip_address($dnsip);
+
+ foreach ($optionlist as $option) {
+ global ${$option[0]}; # make it global to be able to read in getVariable function..may be we need to fix the global thing..
+ $this->getVariable($option[0]);
+ $this->setConfigValue($option[0], ${$option[0]});
+ }
+
+ # options that use longvalue:
+ $this->setConfigValue("banner", "", 'value'); # delete short value for banner, if there is any.. because longvalue is used for banner.
+ $this->setConfigValue("banner", $banner, 'longvalue');
+
+ # operations that needs daemon or other settings.
+
+ if ($dnsip != $this->miscconfig['dnsip']) { # fix all dnsip related config if dnsip is changed...
+ $this->addDaemonOp("fixmailconfiguration", '', '', '', 'fix mail configuration'); # fixes postfix configuration
+ $this->addDaemonOp('syncdns', '', '', '', 'sync dns'); # syncs the DNS zones to use the new IP address
+ if ($updatehostsfile <> '') {
+ $this->addDaemonOp("updatehostsfile", '', '', '', 'update hostsfile'); # Update hosts file too
+ }
+ }
+
+ $addSyncOpAfterSettingsReloaded = false;
+ if ($enablewildcarddomain != $this->miscconfig['enablewildcarddomain']) {
+ $addSyncOpAfterSettingsReloaded = true;
+ }
+
+ if ($defaultlanguage) { # update for current session too..
+ $_SESSION['currentlanguage'] = '';
+ $this->defaultlanguage = $this->currentlanguage = $defaultlanguage;
+ }
+
+ # load latest config again in this session.
+ $this->loadConfigWithDaemon(); # loads config for this session, to show below..
+ if ($updatehostsfile <> '')
+ $this->addDaemonOp("updatehostsfile", '', '', '', 'update hostsfile'); # updateHostsFile degistiginden dolayi
+ if ($addSyncOpAfterSettingsReloaded) {
+ $this->addDaemonOp('syncdomains', '', '', '', 'sync domains');
+ $this->addDaemonOp('syncdns', '', '', '', 'sync dns'); # syncs the DNS zones to use the new IP address
+ }
+
+ $this->output .= "..update complete.";
+
+ } elseif ($edit) {
+ $optionlist[] = array('op', 'default' => __FUNCTION__, 'type' => 'hidden');
+ $this->output .= "
" . print_r3($this->miscconfig, "$this->th Option Name $this->th Option Value ");
+ }
+
+ $this->showSimilarFunctions('options');
+ $this->debugecho(print_r2($this->miscconfig), 3, false);
+ }
+
+
+ function settings()
+ {
+ $this->requireAdmin();
+
+ global $edit, $_insert, $dnsip, $group;
+ $this->getVariable(array('edit', '_insert', 'group'));
+ #echo print_r2($this->miscconfig);
+
+ # new style: options as an array, so, easy addition of new options..
/*$ip="206.51.230.224";
$netmask="255.255.255.0";
$broadcast="206.51.230.255";
$gateway="206.51.230.1";
*/
-
- if($group=='vps' or $group=='vpsadvanced') {
- $this->load_module('Vps_Module');
- switch($group){
- case 'vps': $optionlist=$this->Vps_Module->vps_settings; break;
- case 'vpsadvanced': $optionlist=$this->Vps_Module->vps_settings_advanced; break;
- }
- }
- else $optionlist=array();
- if($_insert){
- $this->output.="Updating settings for $group...";
-
-
- foreach($optionlist as $option) {
- global ${$option[0]}; # make it global to be able to read in getVariable function..may be we need to fix the global thing..
- $this->getVariable($option[0]);
- $this->setSettingsValue($group,$option[0],${$option[0]});
- }
-
- $this->loadConfigWithDaemon();
- $this->output.="..update complete.";
- } else {
- $optionlist[]=array('op','default'=>__FUNCTION__,'type'=>'hidden');
- $this->output.="
Settings:
".inputform5($optionlist);
-
- }
-
- #$this->showSimilarFunctions('options');
- #$this->print_r2($this->settings);
-
- if($group=='vps' or $group=='vpsadvanced') {
- $this->showSimilarFunctions('vps');
- $this->output.=" Click rescan vps images & templates to check them on server, then wait 10sec, click vps settings again, to see them here
advanced vps settings(vps with 2 interface) ";
- }
-
- $this->debugecho(print_r2($this->miscconfig),3,false);
-}
-
-function disableService($service){
- if(sysIsUsingSystemD()){
- passthru2("systemctl disable $service");
- }else{
- passthru2("update-rc.d -f $service remove");
- passthru2("update-rc.d $service disable");
- }
-}
-
-function enableService($service){
- if(sysIsUsingSystemD()){
- passthru2("systemctl enable $service");
- }else{
- passthru2("update-rc.d $service defaults");
- passthru2("update-rc.d $service enable");
- }
-}
-
-function rebuild_webserver_configs(){
- # this function will rebuild all webserver configs according to current choosen webserver type, ssl etc..
- $this->requireCommandLine(__FUNCTION__,True);
-
- # remove all webservers from auto-start
- $this->disableService("nginx");
- $this->disableService("apache2");
-
- if($this->miscconfig['webservertype']=='apache2'){
- // Web server mode changed so restore the original main config file if it exists
- if(file_exists("/etc/apache2/apache2.conf.bk_used_for_EHCP_DO_NOT_DELETE")){
- passthru2("cp /etc/apache2/apache2.conf.bk_used_for_EHCP_DO_NOT_DELETE /etc/apache2/apache2.conf", true, true);
- }
-
- // Make sure we rebuild password protected directories for apache as well
- $this->handlePasswordProtectedDirs();
- return $this->rebuild_apache2_config();
- }else if($this->miscconfig['webservertype']=='nginx'){
- return $this->rebuild_nginx_config();
- }
-
- return False; # yukardaki webserver tipi degilse, başka bişey...
-}
-
-function configure_anon_ftp(){
- # this function will configure VSFTPD for anonymous read only access if specified by an admin
- $this->requireCommandLine(__FUNCTION__,True);
- $shouldClearSettings = false;
-
- if(!empty($this->miscconfig['allowanonymousftptodirectory'])){
- $this->miscconfig['allowanonymousftptodirectory'] = removeInvalidChars($this->miscconfig['allowanonymousftptodirectory'], "directory");
- $this->miscconfig['allowanonymousftptodirectory'] = rtrim($this->miscconfig['allowanonymousftptodirectory'], '/');
- $this->setConfigValue('allowanonymousftptodirectory', $this->miscconfig['allowanonymousftptodirectory']);
-
- // Admin advanced feature, but let's do a little validation before we let em go wild.
- if(strpos($this->miscconfig['allowanonymousftptodirectory'], "/var/www/") === FALSE && $this->miscconfig['allowanonymousftptodirectory'] != "/var/www" && inputValid($this->miscconfig['allowanonymousftptodirectory'], "directory_at_least_two_levels")){
- exec('bash /var/www/new/ehcp/scripts/anonymous_vsftpd.sh "' . $this->miscconfig['allowanonymousftptodirectory'] . '"');
- }else{
- // Option was not valid, so just reset it
- $this->setConfigValue('allowanonymousftptodirectory', '');
- $shouldClearSettings = true;
- }
- }
-
- if((!isset($this->miscconfig['allowanonymousftptodirectory']) || empty($this->miscconfig['allowanonymousftptodirectory'])) || $shouldClearSettings){
- // Remove vsftpd anonymous access if previously setup
- exec('bash /var/www/new/ehcp/scripts/anonymous_vsftpd.sh');
- }
-
- return true;
-}
-
-function rebuild_apache2_config(){
- $this->requireCommandLine(__FUNCTION__,True);
-
- // Support SSL properly
- if($this->miscconfig['webservermode']=='ssl'){
- $this->fixApacheConfigSsl();
- }else if($this->miscconfig['webservermode']=='nonssl') {
- $this->fixApacheConfigNonSsl();
- }else if($this->miscconfig['webservermode']=='sslonly'){
- $this->fixApacheConfigSslOnly();
- }
-
- if($this->miscconfig['webservertype']=='apache2'){
- $this->enableService("apache2"); # make apache2 auto-start on reboot
- $this->enableService($this->php_fpm_name); # apache2 uses FPM now too
- }
- $this->syncDomains();
-
- return True;
-}
-
-function rebuild_nginx_config(){
- $this->requireCommandLine(__FUNCTION__,True);
-
- // Support SSL properly
- if($this->miscconfig['webservermode']=='ssl'){
- $this->fixApacheConfigSsl();
- }else if($this->miscconfig['webservermode']=='nonssl') {
- $this->fixApacheConfigNonSsl();
- }else if($this->miscconfig['webservermode']=='sslonly'){
- $this->fixApacheConfigSslOnly();
- }
-
- $this->enableService("nginx"); # make nginx auto-start on reboot
- $this->enableService($this->php_fpm_name); # make nginx auto-start on reboot
-
- if($this->miscconfig['webservermode']=='ssl' && !$this->is_webserver_running()) {
- $this->echoln2("webserver seems not working...appearantly, some error occured; rolling back to non-ssl mode again.");
- $this->fixApacheConfigNonSsl();
- }
-
- return True;
-}
-
-function writeToLogFile($message){
- $logFile = "/var/log/ehcpphp.log";
- if(!file_exists($logFile)){
- $stream = fopen("$logFile", "w+");
- }else{
- $stream = fopen("$logFile", "a+");
- }
- $date = date('m/d/Y H:i:s');
- if(strlen($message) > 100){
- $longAster = "****************************************************************************\n";
- fwrite($stream, $longAster);
- fwrite($stream, $date . "\n\n");
- fwrite($stream, $message . "\n");
- fwrite($stream, $longAster);
- }else{
- fwrite($stream, $date . " - ");
- fwrite($stream, $message . "\n");
- }
- fclose($stream);
-}
-
-function useNginxTemplates(){
- passthru2("rm -rvf /etc/nginx/sites-enabled/*", true, true);
- passthru2("cp $this->ehcpdir/etc/nginx/default.nginx /etc/nginx/sites-enabled/default", true, true);
- passthru2("cp $this->ehcpdir/etc/nginx/nginx.conf /etc/nginx/", true, true);
-
- // Update the variables
- $this->updateNginxConfVariablesInFile();
-
- passthru2("cp $this->ehcpdir/etc/nginx/apachetemplate.nginx $this->ehcpdir/apachetemplate", true, true);
- passthru2("cp $this->ehcpdir/etc/nginx/apachetemplate_ehcp_panel.nginx $this->ehcpdir/apachetemplate_ehcp_panel", true, true);
- passthru2("cp $this->ehcpdir/etc/nginx/redirect $this->ehcpdir/apachetemplate_redirect", true, true);
- passthru2("cp $this->ehcpdir/etc/nginx/apachetemplate.nginx $this->ehcpdir/apachetemplate_passivedomains", true, true);
- passthru2("cp $this->ehcpdir/etc/nginx/apache_subdomain_template.nginx $this->ehcpdir/apache_subdomain_template", true, true);
- /*
- // Debug
- $contentsOfFile = file_get_contents("$this->ehcpdir/apachetemplate");
- $this->writeToLogFile("In using nginxtemplates and contents of template is: " . $contentsOfFile);
- */
-}
-
-function listSelector($arr,$print,$link,$linkfield='id',$className="EHCPListItem",$ignoreLinkColumns=array()){
- # for small lists that no paging required...
- $res.="
";
- return $res;
-}
+ } else
+ $optionlist = array();
-function getVariable($variables,$dotrim=true) {
- # get variables by means of $_POST or $_GET globals.., makes them secure for sql injection
- if(!is_array($variables)) $variables=array($variables); # accept non-array, single parameter
+ if ($_insert) {
+ $this->output .= "Updating settings for $group...";
- $varCount=count($variables);
- for ($i=0;$i<$varCount;$i++) {
- $varname=$variables[$i];
- if(is_array($varname)) $varname=$varname[0]; # accept array members.. use 1st element for varname.
- if($varname=='') continue;
- global ${$varname}; # make it global at same time.. may be disabled in future..
+ foreach ($optionlist as $option) {
+ global ${$option[0]}; # make it global to be able to read in getVariable function..may be we need to fix the global thing..
+ $this->getVariable($option[0]);
+ $this->setSettingsValue($group, $option[0], ${$option[0]});
+ }
- if($_POST[$varname]<>"") {
- if(function_exists('get_magic_quotes_gpc') && get_magic_quotes_gpc()) ${$varname}=stripslashes($_POST[$varname]);
- else ${$varname}=$_POST[$varname];
+ $this->loadConfigWithDaemon();
+ $this->output .= "..update complete.";
} else {
- if(function_exists('get_magic_quotes_gpc') && get_magic_quotes_gpc()) ${$varname}=stripslashes($_GET[$varname]);
- else ${$varname}=$_GET[$varname];
- }
-
- // trim should occur before escaping
- if($dotrim) ${$varname}=trim(${$varname});
-
- // Escape each post variable
- $tmp=@$this->escape(${$varname});
- if($tmp!==False) ${$varname}=$tmp; # otherwise, without a db connection, mysqli_real_escape_string returns false. this will skip that; no need to mysqli_real_escape_string when there is no db conn, I think.
+ $optionlist[] = array('op', 'default' => __FUNCTION__, 'type' => 'hidden');
+ $this->output .= "
Settings:
" . inputform5($optionlist);
- $values[$varname]=${$varname};
- };
- #echo print_r2($variables).print_r2($values);
- return $values; # return values as an array too... may be used after disabling global variables...
-}
-
-
-function getDomain($table_description,$id){ # returns dommainname of record with id $id, from table with $table_description (defined in start of file with conf variable)
- return $this->getField($this->conf[$table_description]['tablename'], "domainname", "id=$id");
-}
-
-function setField($table,$field,$value,$func,$wherecondition,$opname='',$isInt=false){
- # prepares an update query based on some parameters, for faster coding...
-
- $tablename=$this->conf[$table]['tablename'];
- if($tablename=='') $tablename=$table; # works both if direct tablename is given, or "table description from conf" is given
-
- $query="update $tablename set $field=";
-
- if(!$isInt) $value="'$value'"; # surround value with ' if not integer..
-
- if($func && $func != null) {# function such as md5, password, encrypt
- if($func=='encrypt') $set="$func($value,'ehcp') "; # encrypt is a special function that produces different results for different 2nd par....
- else $set="$func($value) ";
- }
-
- else $set=" $value ";
-
- if($wherecondition) $wherestr=" where $wherecondition ";
-
- $query.=$set.$wherestr;
- #$this->output.="setfield: query: $query ";
- return $this->executeQuery($query, $opname); # this in turn calls adodb liberary for execute..
-}
-
-function adjustEmailAutoreply($email,$autoreplysubject,$autoreplymessage){
- # set db fields
- $where="email='$email'";
- $this->setField('emailuserstable','autoreplysubject',$autoreplysubject,"",$where,"editemailuser-update email");
- $this->setField('emailuserstable','autoreplymessage',$autoreplymessage,"",$where,"editemailuser-update email");
-
- $autoreplyenabled=($autoreplysubject<>'' and $autoreplymessage<>''); # if both not empty..
-
- # adjust forwardings, if autoreply enabled, delete if not
- $domainpart=getLastPart($email,'@'); # domain part of email
- $beforeat=getFirstPart($email,'@');
-
- $forwarddestination="$email,$beforeat@autoreply.$domainpart";
- $forwardcount=$this->recordcount("forwardings","destination='$forwarddestination'");
-
- if($autoreplyenabled and $forwardcount==0){
- $success=$this->addEmailForwardingDirect($this->activeuser,$domainpart,$email,$forwarddestination);
- } elseif (!$autoreplyenabled and $forwardcount>0){
- $success=$this->executeQuery("delete from forwardings where destination='$forwarddestination'");
- }
-
- if($autoreplyenabled) $this->output.=" Autoreply enabled for email: $email";
-
- # add email transports if autoreply enabled, delete if not
- # check if any email of that domain has autoreply enabled
-
- $autoreplycount=$this->recordcount("emailusers","domainname='$domainpart' and (autoreplysubject<>'' and autoreplymessage<>'')");
- $transportcount=$this->recordcount("transport","domainname='autoreply.$domainpart'");
-
- if($autoreplycount>0 and $transportcount==0){
- $this->executeQuery("insert into transport (domainname,transport) values ('autoreply.$domainpart','ehcp_autoreply')");
- } elseif($autoreplycount==0 and $transportcount>0){
- $this->executeQuery("delete from transport where domainname='autoreply.$domainpart'");
- }
-
-}
-
-function editEmailUser(){
- global $id,$newpass,$newpass2,$_insert,$autoreplysubject,$autoreplymessage,$quota;
- $this->getVariable(array('id','newpass','newpass2','_insert','autoreplysubject','autoreplymessage','quota'));
-
- $email=$this->query("select email, quota from emailusers where id=$id");
-
- if($this->isEmailUser()){ # email users edits itself
- $emailAddr=$this->activeuser;
- } else {
- $dom=$this->getDomain('emailuserstable',$id);
- $this->requireMyDomain($dom);
- $emailAddr=$email[0]['email'];
- }
- $where="email='$emailAddr'";
-
- if($_insert){
- if($newpass and ($newpass==$newpass2)){
- # what this mean: set password field of table emailuserstable with newpass, by applying encrypt function, with id=$id
- $this->setField('emailuserstable','password',$newpass,"encrypt",$where,"editemailuser-update email pass");
- $this->output.=" Success email pass change. ";
- #equivalent: $this->executeQuery("update ".$this->conf['emailuserstable']['tablename']." set password=encrypt($newpass) where id=$id ", "update email pass");
- }
-
- // Update quota as well
- if($quota != $email[0]['quota'] && is_numeric($quota)){
- $this->setField('emailuserstable','quota',$quota,null,$where,"editemailuser-update email quota");
- }
-
- $this->adjustEmailAutoreply($emailAddr,$autoreplysubject,$autoreplymessage);
-
- } else {
- $info=$this->query("select autoreplysubject,autoreplymessage from emailusers where $where");
- $autoreplysubject=$info[0]['autoreplysubject'];
- $autoreplymessage=$info[0]['autoreplymessage'];
-
- $inputparams=array(
- array('newpass','password','lefttext'=>'New Password:','righttext'=>'Leave emtpy for no change'),
- array('newpass2','password','lefttext'=>'New Password Again:','righttext'=>'Leave emtpy for no change'),
- array('quota','text','lefttext'=>'Quota:','righttext'=>'', 'default'=>$email[0]['quota']),
- array('autoreplysubject','default'=>$autoreplysubject,'righttext'=>'Leave emtpy to disable autoreply', 'lefttext'=>'Auto Reply Subject:'),
- array('autoreplymessage','textarea','default'=>$autoreplymessage, 'lefttext'=>'Auto Reply Message:'),
- array('id','hidden','default'=>$id),
- array('op','hidden','default'=>__FUNCTION__)
- );
-
- $infoTitle = "
Editing Email Address \"" . $emailAddr . "\"
";
-
- $this->output .= $infoTitle . inputform5($inputparams);
- }
-
- $this->showSimilarFunctions('email');
-}
-
-function editEmailUserPassword(){
- global $id,$newpass,$newpass2,$_insert,$autoreplysubject,$autoreplymessage;
- $this->getVariable(array('id','newpass','newpass2','_insert','autoreplysubject','autoreplymessage'));
-
- if($this->isEmailUser()){ # email users edits itself
- $email=$this->activeuser;
- } else {
- $dom=$this->getDomain('emailuserstable',$id);
- $this->requireMyDomain($dom);
- $email=$this->query("select email from emailusers where id=$id");
- $email=$email[0]['email'];
- }
- $where="email='$email'";
-
- if($_insert){
- if($newpass and ($newpass==$newpass2)){
- # what this mean: set password field of table emailuserstable with newpass, by applying encrypt function, with id=$id
- $this->setField('emailuserstable','password',$newpass,"encrypt",$where,"editemailuser-update email pass");
- $this->output.=" Success email pass change. ";
- #equivalent: $this->executeQuery("update ".$this->conf['emailuserstable']['tablename']." set password=encrypt($newpass) where id=$id ", "update email pass");
}
- } else {
- $info=$this->query("select autoreplysubject,autoreplymessage from emailusers where $where");
+ #$this->showSimilarFunctions('options');
+ #$this->print_r2($this->settings);
- $inputparams=array(
- array('newpass','password','lefttext'=>'New Password:','righttext'=>'Leave emtpy for no change'),
- array('newpass2','password','lefttext'=>'New Password Again:','righttext'=>'Leave emtpy for no change'),
- array('id','hidden','default'=>$id),
- array('op','hidden','default'=>__FUNCTION__)
- );
- $this->output.=inputform5($inputparams);
- }
-
- $this->showSimilarFunctions('email');
-}
-
-function editEmailUserAutoreply(){
- global $id,$newpass,$newpass2,$_insert,$autoreplysubject,$autoreplymessage;
- $this->getVariable(array('id','newpass','newpass2','_insert','autoreplysubject','autoreplymessage'));
-
- if($this->isEmailUser()){ # email users edits itself
- $email=$this->activeuser;
- } else {
- $dom=$this->getDomain('emailuserstable',$id);
- $this->requireMyDomain($dom);
- $email=$this->query("select email from emailusers where id=$id");
- $email=$email[0]['email'];
- }
- $where="email='$email'";
-
- if($_insert){
- $this->adjustEmailAutoreply($email,$autoreplysubject,$autoreplymessage);
- } else {
- $info=$this->query("select autoreplysubject,autoreplymessage from emailusers where $where");
- $autoreplysubject=$info[0]['autoreplysubject'];
- $autoreplymessage=$info[0]['autoreplymessage'];
-
- $inputparams=array(
- array('autoreplysubject','default'=>$autoreplysubject,'righttext'=>'Leave emtpy to disable autoreply', 'lefttext'=>'Auto Reply Subject:'),
- array('autoreplymessage','textarea','default'=>$autoreplymessage, 'lefttext'=>'Auto Reply Message:'),
- array('id','hidden','default'=>$id),
- array('op','hidden','default'=>__FUNCTION__)
- );
- $this->output.=inputform5($inputparams);
- }
-
- $this->showSimilarFunctions('email');
-}
-
-function mysqlDBInfoValid($dbname, $dbusername, $dbuserpass){
- if(strlen($dbusername) > 16){
- return $this->errorText("Database username cannot be greater than 16 characters.");
- }
-
- if(strlen($dbname) > 64){
- return $this->errorText("Database name cannot be greater than 64 characters.");
- }
-
- if(strlen($dbuserpass) > 32){
- return $this->errorText("Database user passwords cannot be greater than 32 characters.");
- }
-
- $dbnameModified = removeInvalidChars($dbname, "database");
- if($dbnameModified != $dbname){
- return $this->errorText("Database names may only contain alphanumeric characters along with underscores.");
- }
-
- return true;
-}
-
-function dbAddUser(){
- global $dbname,$dbusername,$dbuserpass;
- $this->getVariable(array('dbname','dbusername','dbuserpass'));
-
- $domainname = $this->selecteddomain;
-
- $dbs=$this->query("select * from ".$this->conf['mysqldbstable']['tablename']." where panelusername='$this->activeuser'");
- if(count($dbs)==0){
- $this->output.="You have not any db's yet.. so, use add mysql db link here";
- return false;
- }
- $success=True;
-
- if($dbname){
-
- // Must have validation
- if(!$this->mysqlDBInfoValid($dbname, $dbusername, $dbuserpass)){
- return false;
+ if ($group == 'vps' or $group == 'vpsadvanced') {
+ $this->showSimilarFunctions('vps');
+ $this->output .= " Click rescan vps images & templates to check them on server, then wait 10sec, click vps settings again, to see them here
advanced vps settings(vps with 2 interface) ";
}
- if($this->recordcount($this->conf['mysqldbstable']['tablename'], "panelusername='$this->activeuser' and dbname='$dbname'")==0)
- return $this->errorText("This database is not owned by your account.");
-
- if(empty($domainname)){
- $domainname = $this->getField($this->conf['mysqldbuserstable']['tablename'],'domainname',"panelusername='" . $this->activeuser . "' and dbname='" . $dbname . "'");
- }
-
- $q="grant all privileges on `$dbname`.* to '$dbusername'@'localhost' identified by '$dbuserpass' ";
- $success=$success && $this->mysqlRootQuery($q);
-
- $q="insert into ".$this->conf['mysqldbuserstable']['tablename']." (host,domainname,dbname,dbusername,password,panelusername)values('localhost','$domainname','$dbname','$dbusername','$dbuserpass','$this->activeuser')";
- $success=$success && $s=$this->executeQuery($q,' add mysql user to ehcp db ');
-
- $this->ok_err_text($success,'Successfully added database user.','Failed to add database user.');
-
- } else {
- $inputparams=array(
- array('dbname','leftext'=>'Your Existing Database:'),
- array('dbusername','lefttext'=>'New Database User:'),
- array('dbuserpass','lefttext'=>'Database User Password:'),
- array('op','hidden','default'=>__FUNCTION__)
- );
- $this->output.="Add new database user to an existing database. Enter new database user information: (Works only for local MySQL servers) "
- .inputform5($inputparams);
+ $this->debugecho(print_r2($this->miscconfig), 3, false);
}
- $this->showSimilarFunctions('mysql');
- return $success;
-}
-function dbEditUser(){
- global $dbusername,$newpassword,$newpassword2,$id,$dbremoteaccess;
- $this->getVariable(array('dbusername','newpassword','newpassword2', 'dbremoteaccess'));
- if($dbusername=='') $dbusername=$this->getField($this->conf['mysqldbuserstable']['tablename'],'dbusername',"id=$id");
-
- if($this->recordcount($this->conf['mysqldbuserstable']['tablename'], "panelusername='$this->activeuser' and dbusername='$dbusername'")==0){
- // Admin should be able to edit any MySQL user
- if(!$this->isadmin()){
- return $this->errorText("This database is not owned by your account.");
+ function disableService($service)
+ {
+ if (sysIsUsingSystemD()) {
+ passthru2("systemctl disable $service");
+ } else {
+ passthru2("update-rc.d -f $service remove");
+ passthru2("update-rc.d $service disable");
}
}
- if($newpassword && $newpassword == $newpassword2){
- if(strlen($newpassword) <= 32){
- $remoteAccess = false;
- if($dbremoteaccess && $this->isadmin()){
- // Connect as root
- if(!$myserver) $myserver=$_SESSION['myserver'];
- if(!$myserver) $myserver=$this->getMysqlServer('',false,__FUNCTION__); # get mysql server info..
-
- // Connect to mysql server, local or remote
- if(! $link = mysqli_connect($myserver['host'], $myserver['user'], $myserver['pass'])){
- return $this->errorText("Could not connect as root!");
- }
-
- // Get databases owned by user and convert them to remote access
- $databases = $this->getMySQLDatabasesByUser($dbusername);
- if($databases !== false){
- foreach($databases as $info){
- $dbname = $info["dbname"];
- $s=$this->executeQuery("grant all privileges on `$dbname`.* to '$dbusername'@'%' identified by '$newpassword' ",'grant user rights','',$link);
- }
- }
+ function enableService($service)
+ {
+ if (sysIsUsingSystemD()) {
+ passthru2("systemctl enable $service");
+ } else {
+ passthru2("update-rc.d $service defaults");
+ passthru2("update-rc.d $service enable");
+ }
+ }
+
+ function rebuild_webserver_configs()
+ {
+ # this function will rebuild all webserver configs according to current choosen webserver type, ssl etc..
+ $this->requireCommandLine(__FUNCTION__, True);
+
+ # remove all webservers from auto-start
+ $this->disableService("nginx");
+ $this->disableService("apache2");
+
+ if ($this->miscconfig['webservertype'] == 'apache2') {
+ // Web server mode changed so restore the original main config file if it exists
+ if (file_exists("/etc/apache2/apache2.conf.bk_used_for_EHCP_DO_NOT_DELETE")) {
+ passthru2("cp /etc/apache2/apache2.conf.bk_used_for_EHCP_DO_NOT_DELETE /etc/apache2/apache2.conf", true, true);
}
-
- // Update the information in the panel
- $q="UPDATE ".$this->conf['mysqldbuserstable']['tablename']." SET password = '" . $newpassword . "' WHERE dbusername = '" . $dbusername . "'";
- if(!$this->isadmin()){
- $q .= " AND panelusername = '" . $this->activeuser . "'";
+
+ // Make sure we rebuild password protected directories for apache as well
+ $this->handlePasswordProtectedDirs();
+ return $this->rebuild_apache2_config();
+ } else if ($this->miscconfig['webservertype'] == 'nginx') {
+ return $this->rebuild_nginx_config();
+ }
+
+ return False; # yukardaki webserver tipi degilse, başka bişey...
+ }
+
+ function configure_anon_ftp()
+ {
+ # this function will configure VSFTPD for anonymous read only access if specified by an admin
+ $this->requireCommandLine(__FUNCTION__, True);
+ $shouldClearSettings = false;
+
+ if (!empty($this->miscconfig['allowanonymousftptodirectory'])) {
+ $this->miscconfig['allowanonymousftptodirectory'] = removeInvalidChars($this->miscconfig['allowanonymousftptodirectory'], "directory");
+ $this->miscconfig['allowanonymousftptodirectory'] = rtrim($this->miscconfig['allowanonymousftptodirectory'], '/');
+ $this->setConfigValue('allowanonymousftptodirectory', $this->miscconfig['allowanonymousftptodirectory']);
+
+ // Admin advanced feature, but let's do a little validation before we let em go wild.
+ if (strpos($this->miscconfig['allowanonymousftptodirectory'], "/var/www/") === FALSE && $this->miscconfig['allowanonymousftptodirectory'] != "/var/www" && inputValid($this->miscconfig['allowanonymousftptodirectory'], "directory_at_least_two_levels")) {
+ exec('bash /var/www/new/ehcp/scripts/anonymous_vsftpd.sh "' . $this->miscconfig['allowanonymousftptodirectory'] . '"');
+ } else {
+ // Option was not valid, so just reset it
+ $this->setConfigValue('allowanonymousftptodirectory', '');
+ $shouldClearSettings = true;
}
- $s=$this->executeQuery($q, 'update mysql user in ehcp db');
-
- $this->output.="setting new password for db user: $dbusername";
- $q=" SET PASSWORD FOR '$dbusername'@'localhost' = PASSWORD('$newpassword')";
- $q2=" SET PASSWORD FOR '$dbusername'@'%' = PASSWORD('$newpassword')";
- $result = $this->mysqlRootQuery($q, true);
- $result2 = $this->mysqlRootQuery($q2, true);
- if($result === false && $result2 === false){
- $this->errorText("Error: Password cannot be changed for database user " . $dbusername . ".");
- } else $this->okeyText("Change password success..");
- }else{
- $this->errorText("Error: Password must be less than or equal to 32 characters in length.");
- }
- } else {
- $inputparams=array(
- array('newpassword','password','lefttext'=>'New Password'),
- array('newpassword2','password','lefttext'=>'new password again'),
- array('dbusername','hidden','default'=>$dbusername),
- array('op','hidden','default'=>__FUNCTION__)
- );
-
- if($this->isadmin()){
- $inputparams[] = array("dbremoteaccess", 'checkbox', 'lefttext'=>'Allow remote access to database:','default'=>'1','checked'=>'0');
}
- $this->output.="Change password for database user \"$dbusername\": (Works only for local MySQL servers) "
- .inputform5($inputparams);
+ if ((!isset($this->miscconfig['allowanonymousftptodirectory']) || empty($this->miscconfig['allowanonymousftptodirectory'])) || $shouldClearSettings) {
+ // Remove vsftpd anonymous access if previously setup
+ exec('bash /var/www/new/ehcp/scripts/anonymous_vsftpd.sh');
+ }
+
+ return true;
}
- $this->showSimilarFunctions('mysql');
- return True;
-}
-function getMySQLDatabasesByUser($user){
- $mysqlDBUserInfo = $this->query("select * from ".$this->conf['mysqldbuserstable']['tablename']." where dbusername='" . $user . "'");
- if(count($mysqlDBUserInfo) > 0){
- return $mysqlDBUserInfo;
+ function rebuild_apache2_config()
+ {
+ $this->requireCommandLine(__FUNCTION__, True);
+
+ // Support SSL properly
+ if ($this->miscconfig['webservermode'] == 'ssl') {
+ $this->fixApacheConfigSsl();
+ } else if ($this->miscconfig['webservermode'] == 'nonssl') {
+ $this->fixApacheConfigNonSsl();
+ } else if ($this->miscconfig['webservermode'] == 'sslonly') {
+ $this->fixApacheConfigSslOnly();
+ }
+
+ if ($this->miscconfig['webservertype'] == 'apache2') {
+ $this->enableService("apache2"); # make apache2 auto-start on reboot
+ $this->enableService($this->php_fpm_name); # apache2 uses FPM now too
+ }
+ $this->syncDomains();
+
+ return True;
}
-
- return false;
-}
-function deleteCustomSetting(){
- global $id;
- $this->getVariable(array('id'));
- $q="select * from customsettings where id=$id";
- $info=$this->query($q);
- $info=$info[0];
-
- $domainname=trim($info['domainname']);
- if($domainname=='') {
- $this->output.="Domainname for custom setting is empty. strange.. ";
- return ;
+ function rebuild_nginx_config()
+ {
+ $this->requireCommandLine(__FUNCTION__, True);
+
+ // Support SSL properly
+ if ($this->miscconfig['webservermode'] == 'ssl') {
+ $this->fixApacheConfigSsl();
+ } else if ($this->miscconfig['webservermode'] == 'nonssl') {
+ $this->fixApacheConfigNonSsl();
+ } else if ($this->miscconfig['webservermode'] == 'sslonly') {
+ $this->fixApacheConfigSslOnly();
+ }
+
+ $this->enableService("nginx"); # make nginx auto-start on reboot
+ $this->enableService($this->php_fpm_name); # make nginx auto-start on reboot
+
+ if ($this->miscconfig['webservermode'] == 'ssl' && !$this->is_webserver_running()) {
+ $this->echoln2("webserver seems not working...appearantly, some error occured; rolling back to non-ssl mode again.");
+ $this->fixApacheConfigNonSsl();
+ }
+
+ return True;
}
-
- $success=True;
- $this->output.=' ( should check ownership) Deleting id: '.$id.' ' ;
- $success=$success && $this->executeQuery("delete from ".$this->conf['customstable']['tablename']." where id=$id limit 1");
+ function writeToLogFile($message)
+ {
+ $logFile = "/var/log/ehcpphp.log";
+ if (!file_exists($logFile)) {
+ $stream = fopen("$logFile", "w+");
+ } else {
+ $stream = fopen("$logFile", "a+");
+ }
+ $date = date('m/d/Y H:i:s');
+ if (strlen($message) > 100) {
+ $longAster = "****************************************************************************\n";
+ fwrite($stream, $longAster);
+ fwrite($stream, $date . "\n\n");
+ fwrite($stream, $message . "\n");
+ fwrite($stream, $longAster);
+ } else {
+ fwrite($stream, $date . " - ");
+ fwrite($stream, $message . "\n");
+ }
+ fclose($stream);
+ }
- if($info['name']=='customdns') $success=$success && $this->addDaemonOp("syncdns",'','');
- if($info['name']=='customhttp' or $info['name']=='fileowner') $success=$success && $this->addDaemonOp("syncdomains",'xx',$domainname);
- $this->ok_err_text($success," was deleted successfully.",__FUNCTION__." failed.");
- $this->showSimilarFunctions('customhttpdns');
- return $success;
-}
+ function useNginxTemplates()
+ {
+ passthru2("rm -rvf /etc/nginx/sites-enabled/*", true, true);
+ passthru2("cp $this->ehcpdir/etc/nginx/default.nginx /etc/nginx/sites-enabled/default", true, true);
+ passthru2("cp $this->ehcpdir/etc/nginx/nginx.conf /etc/nginx/", true, true);
-function customHttpSettings(){
- $domainname=$this->chooseDomain(__FUNCTION__,$domainname);
- $this->listTable('Custom http settings:','customstable',"name='customhttp' and domainname='$domainname' and (webservertype is null or webservertype='' or webservertype='".$this->miscconfig['webservertype']."')");
- $this->output.="Add Custom http";
- $this->showSimilarFunctions('customhttpdns');
-}
+ // Update the variables
+ $this->updateNginxConfVariablesInFile();
-function custompermissions(){
- $domainname=$this->chooseDomain(__FUNCTION__,$domainname);
- $this->listTable('Custom file permissinos:','customstable',"name='fileowner' and domainname='$domainname'");
+ passthru2("cp $this->ehcpdir/etc/nginx/apachetemplate.nginx $this->ehcpdir/apachetemplate", true, true);
+ passthru2("cp $this->ehcpdir/etc/nginx/apachetemplate_ehcp_panel.nginx $this->ehcpdir/apachetemplate_ehcp_panel", true, true);
+ passthru2("cp $this->ehcpdir/etc/nginx/redirect $this->ehcpdir/apachetemplate_redirect", true, true);
+ passthru2("cp $this->ehcpdir/etc/nginx/apachetemplate.nginx $this->ehcpdir/apachetemplate_passivedomains", true, true);
+ passthru2("cp $this->ehcpdir/etc/nginx/apache_subdomain_template.nginx $this->ehcpdir/apache_subdomain_template", true, true);
+ /*
+ // Debug
+ $contentsOfFile = file_get_contents("$this->ehcpdir/apachetemplate");
+ $this->writeToLogFile("In using nginxtemplates and contents of template is: " . $contentsOfFile);
+ */
+ }
- $this->showSimilarFunctions('custompermissions');
-}
-
-function emailForwardingsSelf(){
- $this->requireEmailUser();
-
- $filter="source='$this->activeuser'";
- $this->listTable("Email Forwardings", 'emailforwardingstable', $filter);
- if ($this->recordcount($this->conf['emailforwardingstable']['tablename'],$filter)==0)
- $this->output.="Add Email Forwarding";
-}
-
-function addEmailForwardingSelf(){
- # for mail user login..
- global $forwardto;
- $this->getVariable(array('forwardto'));
-
- $this->requireEmailUser();
- $email=$this->activeuser;
-
- # this ensures the ownership of domain
- $domainname=getLastPart($email,'@');
-
-
- if(!$forwardto){
- $this->output.="Email:$email , domain: $domainname Enter target emails one by line";
- $inputparams=array(
- array('forwardto', 'textarea', 'lefttext'=>'Forward To:')
- );
-
- $this->output.=inputform5($inputparams);
-
- } else {
- $this->output.="Will forward $email to mails: $forwardto ";
- $success=$this->addEmailForwardingDirect($email,$domainname,"$email",$forwardto);
- $res=$this->ok_err_text($success, "Successfully added email forwarding.",'Failed to add email forwarding.');
+ function listSelector($arr, $print, $link, $linkfield = 'id', $className = "EHCPListItem", $ignoreLinkColumns = array())
+ {
+ # for small lists that no paging required...
+ $res .= "
";
return $res;
}
-}
+ function getVariable($variables, $dotrim = true)
+ {
+ # get variables by means of $_POST or $_GET globals.., makes them secure for sql injection
+ if (!is_array($variables))
+ $variables = array($variables); # accept non-array, single parameter
-function emailForwardings(){
- global $domainname;
- $this->getVariable(array('domainname'));
+ $varCount = count($variables);
+ for ($i = 0; $i < $varCount; $i++) {
+ $varname = $variables[$i];
+ if (is_array($varname))
+ $varname = $varname[0]; # accept array members.. use 1st element for varname.
+ if ($varname == '')
+ continue;
- $domainname=$this->chooseDomain(__FUNCTION__,$domainname);
+ global ${$varname}; # make it global at same time.. may be disabled in future..
- $filter="panelusername='$this->activeuser' and domainname='$domainname'";
- #$filter=$this->applyGlobalFilter($filter);
+ if ($_POST[$varname] <> "") {
+ if (function_exists('get_magic_quotes_gpc') && get_magic_quotes_gpc())
+ ${$varname} = stripslashes($_POST[$varname]);
+ else
+ ${$varname} = $_POST[$varname];
+ } else {
+ if (function_exists('get_magic_quotes_gpc') && get_magic_quotes_gpc())
+ ${$varname} = stripslashes($_GET[$varname]);
+ else
+ ${$varname} = $_GET[$varname];
+ }
- $this->listTable("Email Forwardings", 'emailforwardingstable', $filter);
- $this->output.="Add Email Forwarding";
- $this->showSimilarFunctions('email');
-}
+ // trim should occur before escaping
+ if ($dotrim)
+ ${$varname} = trim(${$varname});
-function addEmailForwardingDirect($panelusername,$domainname,$fromemail,$forwardto){
- return $this->executeQuery("insert into forwardings (panelusername,domainname,source,destination)values('$panelusername','$domainname','$fromemail','$forwardto')", $opname);
-}
+ // Escape each post variable
+ $tmp = @$this->escape(${$varname});
+ if ($tmp !== False)
+ ${$varname} = $tmp; # otherwise, without a db connection, mysqli_real_escape_string returns false. this will skip that; no need to mysqli_real_escape_string when there is no db conn, I think.
-function addEmailForwarding(){
- global $domainname,$beforeat,$forwardto;
- $this->getVariable(array('domainname','beforeat','forwardto'));
- $domainname=$this->chooseDomain(__FUNCTION__,$domainname);
-
- $success=True;
-
- # this ensures the ownership of domain
-
- if(!$forwardto){
- $inputparams=array(
- array('beforeat','righttext'=>"@$domainname",'lefttext'=>'Email: Leave empty to use the catch-all email (to receive all emails that are not setup)'),
- array('forwardto','textarea', 'lefttext'=>'Forward To'),
- array('domainname','hidden','default'=>$domainname),
- array('op','hidden','default'=>__FUNCTION__)
- );
-
- $this->output.=inputform5($inputparams);
-
- } else {
- $beforeat=getFirstPart($beforeat,'@'); # make sure
- $this->output.="Will forward $beforeat@$domainname to mails: $forwardto ";
- $success=$success && $this->addEmailForwardingDirect($this->activeuser,$domainname,"$beforeat@$domainname",$forwardto);
- $this->ok_err_text($success, "Successfully added email forwarding.",__FUNCTION__.' failed');
- $this->output.=" List Email forwardings ";
- }
- $this->showSimilarFunctions('email');
- return $success;
-}
-
-function delEmailForwarding(){
- global $id;
- $filter=$this->applyGlobalFilter("id=$id");
- $success=$this->executeQuery("delete from ".$this->conf['emailforwardingstable']['tablename']." where $filter", $opname);
- $this->output.=" List Email forwardings ";
- $res=$this->ok_err_text($success, "Email forwarding deleted",'Failed to delete email forwarder.');
- $this->showSimilarFunctions('email');
- return $res;
-}
-
-function addCustomHttpDirect($domainname,$customhttp,$comment){
- $this->output.="Adding customhttp :";
- $success=True;
- $success=$success && ($domainname<>'');
- $success=$success && $this->executeQuery("insert into ".$this->conf['customstable']['tablename']." (domainname,name,value,comment,webservertype) values ('$domainname','customhttp','$customhttp','$comment','".$this->miscconfig['webservertype']."')",'add custom http');
- $success=$success && $this->addDaemonOp("syncdomains",'xx',$domainname,'','sync domains');
-
- return $this->ok_err_text($success,"Custom HTTP settings were added successfully.",'Failed to add custom HTTP settings.');
-
-}
-
-function addCustomHttp(){
- global $domainname,$customhttp,$comment;
- $this->getVariable(array("domainname","customhttp",'comment')); # this gets variables from _GET or _POST
- # Disable custom http if misc disableeditapachetemplate setting is set, as that is a way to break the apache template.
- if($this->miscconfig['disableeditapachetemplate']<>'') $this->requireAdmin();
-
- $domainname=$this->chooseDomain(__FUNCTION__,$domainname);
- $success=True;
-
- if(!$customhttp){
- $inputparams=array(
- array('customhttp','textarea','lefttext'=>'Custom HTTP'),
- array('comment', 'lefttext'=>'Comment'),
- array('domainname','hidden','default'=>$domainname),
- array('op','hidden','default'=>__FUNCTION__)
-
- );
- $this->output.="Adding custom HTTP for domain \"$domainname\" and your current webserver of (".$this->miscconfig['webservertype'].") (Note that this custom HTTP will be active whenever your current webserver type is active): ";
- $this->output.=inputform5($inputparams);
-
- } else{
- $success=$success && $this->addCustomHttpDirect($domainname,$customhttp,$comment);
- $this->ok_err_text($success,"Successfully added custom HTTP settings.",__FUNCTION__." failed.");
+ $values[$varname] = ${$varname};
+ }
+ ;
+ #echo print_r2($variables).print_r2($values);
+ return $values; # return values as an array too... may be used after disabling global variables...
}
- $this->showSimilarFunctions('customhttpdns');
- return $success;
-
-
-}
-
-function addcustompermission(){
- global $domainname,$fileowner,$directory;
- $this->getVariable(array("domainname","fileowner",'directory')); # this gets variables from _GET or _POST
-
- $domainname=$this->chooseDomain(__FUNCTION__,$domainname);
- $success=True;
-
- if(!$fileowner){
- $inputparams=array(
- array('fileowner','righttext'=>'like vsftpd, or: vsftpd:www-data, cannot be root', 'lefttext'=>'File Owner:'),
- array('directory','righttext'=>'relative to domain home, such as wp-content for wordpress,or wp/wp-admin', 'lefttext'=>'Directory'),
- array('domainname','hidden','default'=>$domainname),
- array('op','hidden','default'=>__FUNCTION__)
- );
- $this->output.="Adding custom permission for domain ($domainname): ";
- $this->output.=inputform5($inputparams);
-
- } else{
- $params=array('domainname'=>$domainname,'name'=>'fileowner','value'=>$fileowner,'value2'=>$directory);
- $success=$this->insert_custom_setting_direct($params);
- $success=$success && $this->addDaemonOp("syncdomains",'xx',$domainname);
- $this->ok_err_text($success,"Successfully added custom HTTP settings.",__FUNCTION__." failed.");
+ function getDomain($table_description, $id)
+ { # returns dommainname of record with id $id, from table with $table_description (defined in start of file with conf variable)
+ return $this->getField($this->conf[$table_description]['tablename'], "domainname", "id=$id");
}
- $this->showSimilarFunctions('custompermissions');
- return $success;
+ function setField($table, $field, $value, $func, $wherecondition, $opname = '', $isInt = false)
+ {
+ # prepares an update query based on some parameters, for faster coding...
-}
+ $tablename = $this->conf[$table]['tablename'];
+ if ($tablename == '')
+ $tablename = $table; # works both if direct tablename is given, or "table description from conf" is given
-function customDnsSettings(){
- $domainname=$this->chooseDomain(__FUNCTION__,$domainname);
- $this->listTable('Custom dns settings:','customstable',"name='customdns' and domainname='$domainname'");
- $this->output.='Add Custom dns';
- $this->showSimilarFunctions('customhttpdns');
-}
+ $query = "update $tablename set $field=";
-function getIsSlaveDomain($domainname){
- $dnsmaster = $this->getMasterIP($domainname);
- return ($dnsmaster<>'');
-}
+ if (!$isInt)
+ $value = "'$value'"; # surround value with ' if not integer..
-function addCustomDns(){
- global $domainname,$customdns,$comment;
- $this->getVariable(array("domainname","customdns",'comment')); # this gets variables from _GET or _POST
+ if ($func && $func != null) { # function such as md5, password, encrypt
+ if ($func == 'encrypt')
+ $set = "$func($value,'ehcp') "; # encrypt is a special function that produces different results for different 2nd par....
+ else
+ $set = "$func($value) ";
+ } else
+ $set = " $value ";
- $domainname=$this->chooseDomain(__FUNCTION__,$domainname);
- $success=True;
+ if ($wherecondition)
+ $wherestr = " where $wherecondition ";
- // If is slave domain, do not allow custom DNS
- if($this->getIsSlaveDomain($domainname)) $this->errorTextExit('Custom dns cannot be added for domains with slave dns');
+ $query .= $set . $wherestr;
+ #$this->output.="setfield: query: $query ";
+ return $this->executeQuery($query, $opname); # this in turn calls adodb liberary for execute..
+ }
- if(!$customdns){
- $inputparams=array(
- array('customdns','textarea','lefttext'=>'Custom DNS'),
- array('comment', 'lefttext'=>'Comment'),
- array('domainname','hidden','default'=>$domainname),
- array('op','hidden','default'=>__FUNCTION__)
- );
-
- $this->output.="Adding custom DNS for domain \"$domainname\": Attention! Adding incorrect entries will cause DNS service errors!
Example:
+ function adjustEmailAutoreply($email, $autoreplysubject, $autoreplymessage)
+ {
+ # set db fields
+ $where = "email='$email'";
+ $this->setField('emailuserstable', 'autoreplysubject', $autoreplysubject, "", $where, "editemailuser-update email");
+ $this->setField('emailuserstable', 'autoreplymessage', $autoreplymessage, "", $where, "editemailuser-update email");
+
+ $autoreplyenabled = ($autoreplysubject <> '' and $autoreplymessage <> ''); # if both not empty..
+
+ # adjust forwardings, if autoreply enabled, delete if not
+ $domainpart = getLastPart($email, '@'); # domain part of email
+ $beforeat = getFirstPart($email, '@');
+
+ $forwarddestination = "$email,$beforeat@autoreply.$domainpart";
+ $forwardcount = $this->recordcount("forwardings", "destination='$forwarddestination'");
+
+ if ($autoreplyenabled and $forwardcount == 0) {
+ $success = $this->addEmailForwardingDirect($this->activeuser, $domainpart, $email, $forwarddestination);
+ } elseif (!$autoreplyenabled and $forwardcount > 0) {
+ $success = $this->executeQuery("delete from forwardings where destination='$forwarddestination'");
+ }
+
+ if ($autoreplyenabled)
+ $this->output .= " Autoreply enabled for email: $email";
+
+ # add email transports if autoreply enabled, delete if not
+ # check if any email of that domain has autoreply enabled
+
+ $autoreplycount = $this->recordcount("emailusers", "domainname='$domainpart' and (autoreplysubject<>'' and autoreplymessage<>'')");
+ $transportcount = $this->recordcount("transport", "domainname='autoreply.$domainpart'");
+
+ if ($autoreplycount > 0 and $transportcount == 0) {
+ $this->executeQuery("insert into transport (domainname,transport) values ('autoreply.$domainpart','ehcp_autoreply')");
+ } elseif ($autoreplycount == 0 and $transportcount > 0) {
+ $this->executeQuery("delete from transport where domainname='autoreply.$domainpart'");
+ }
+
+ }
+
+ function editEmailUser()
+ {
+ global $id, $newpass, $newpass2, $_insert, $autoreplysubject, $autoreplymessage, $quota;
+ $this->getVariable(array('id', 'newpass', 'newpass2', '_insert', 'autoreplysubject', 'autoreplymessage', 'quota'));
+
+ $email = $this->query("select email, quota from emailusers where id=$id");
+
+ if ($this->isEmailUser()) { # email users edits itself
+ $emailAddr = $this->activeuser;
+ } else {
+ $dom = $this->getDomain('emailuserstable', $id);
+ $this->requireMyDomain($dom);
+ $emailAddr = $email[0]['email'];
+ }
+ $where = "email='$emailAddr'";
+
+ if ($_insert) {
+ if ($newpass and ($newpass == $newpass2)) {
+ # what this mean: set password field of table emailuserstable with newpass, by applying encrypt function, with id=$id
+ $this->setField('emailuserstable', 'password', $newpass, "encrypt", $where, "editemailuser-update email pass");
+ $this->output .= " Success email pass change. ";
+ #equivalent: $this->executeQuery("update ".$this->conf['emailuserstable']['tablename']." set password=encrypt($newpass) where id=$id ", "update email pass");
+ }
+
+ // Update quota as well
+ if ($quota != $email[0]['quota'] && is_numeric($quota)) {
+ $this->setField('emailuserstable', 'quota', $quota, null, $where, "editemailuser-update email quota");
+ }
+
+ $this->adjustEmailAutoreply($emailAddr, $autoreplysubject, $autoreplymessage);
+
+ } else {
+ $info = $this->query("select autoreplysubject,autoreplymessage from emailusers where $where");
+ $autoreplysubject = $info[0]['autoreplysubject'];
+ $autoreplymessage = $info[0]['autoreplymessage'];
+
+ $inputparams = array(
+ array('newpass', 'password', 'lefttext' => 'New Password:', 'righttext' => 'Leave emtpy for no change'),
+ array('newpass2', 'password', 'lefttext' => 'New Password Again:', 'righttext' => 'Leave emtpy for no change'),
+ array('quota', 'text', 'lefttext' => 'Quota:', 'righttext' => '', 'default' => $email[0]['quota']),
+ array('autoreplysubject', 'default' => $autoreplysubject, 'righttext' => 'Leave emtpy to disable autoreply', 'lefttext' => 'Auto Reply Subject:'),
+ array('autoreplymessage', 'textarea', 'default' => $autoreplymessage, 'lefttext' => 'Auto Reply Message:'),
+ array('id', 'hidden', 'default' => $id),
+ array('op', 'hidden', 'default' => __FUNCTION__)
+ );
+
+ $infoTitle = "
Editing Email Address \"" . $emailAddr . "\"
";
+
+ $this->output .= $infoTitle . inputform5($inputparams);
+ }
+
+ $this->showSimilarFunctions('email');
+ }
+
+ function editEmailUserPassword()
+ {
+ global $id, $newpass, $newpass2, $_insert, $autoreplysubject, $autoreplymessage;
+ $this->getVariable(array('id', 'newpass', 'newpass2', '_insert', 'autoreplysubject', 'autoreplymessage'));
+
+ if ($this->isEmailUser()) { # email users edits itself
+ $email = $this->activeuser;
+ } else {
+ $dom = $this->getDomain('emailuserstable', $id);
+ $this->requireMyDomain($dom);
+ $email = $this->query("select email from emailusers where id=$id");
+ $email = $email[0]['email'];
+ }
+ $where = "email='$email'";
+
+ if ($_insert) {
+ if ($newpass and ($newpass == $newpass2)) {
+ # what this mean: set password field of table emailuserstable with newpass, by applying encrypt function, with id=$id
+ $this->setField('emailuserstable', 'password', $newpass, "encrypt", $where, "editemailuser-update email pass");
+ $this->output .= " Success email pass change. ";
+ #equivalent: $this->executeQuery("update ".$this->conf['emailuserstable']['tablename']." set password=encrypt($newpass) where id=$id ", "update email pass");
+ }
+
+ } else {
+ $info = $this->query("select autoreplysubject,autoreplymessage from emailusers where $where");
+
+ $inputparams = array(
+ array('newpass', 'password', 'lefttext' => 'New Password:', 'righttext' => 'Leave emtpy for no change'),
+ array('newpass2', 'password', 'lefttext' => 'New Password Again:', 'righttext' => 'Leave emtpy for no change'),
+ array('id', 'hidden', 'default' => $id),
+ array('op', 'hidden', 'default' => __FUNCTION__)
+ );
+ $this->output .= inputform5($inputparams);
+ }
+
+ $this->showSimilarFunctions('email');
+ }
+
+ function editEmailUserAutoreply()
+ {
+ global $id, $newpass, $newpass2, $_insert, $autoreplysubject, $autoreplymessage;
+ $this->getVariable(array('id', 'newpass', 'newpass2', '_insert', 'autoreplysubject', 'autoreplymessage'));
+
+ if ($this->isEmailUser()) { # email users edits itself
+ $email = $this->activeuser;
+ } else {
+ $dom = $this->getDomain('emailuserstable', $id);
+ $this->requireMyDomain($dom);
+ $email = $this->query("select email from emailusers where id=$id");
+ $email = $email[0]['email'];
+ }
+ $where = "email='$email'";
+
+ if ($_insert) {
+ $this->adjustEmailAutoreply($email, $autoreplysubject, $autoreplymessage);
+ } else {
+ $info = $this->query("select autoreplysubject,autoreplymessage from emailusers where $where");
+ $autoreplysubject = $info[0]['autoreplysubject'];
+ $autoreplymessage = $info[0]['autoreplymessage'];
+
+ $inputparams = array(
+ array('autoreplysubject', 'default' => $autoreplysubject, 'righttext' => 'Leave emtpy to disable autoreply', 'lefttext' => 'Auto Reply Subject:'),
+ array('autoreplymessage', 'textarea', 'default' => $autoreplymessage, 'lefttext' => 'Auto Reply Message:'),
+ array('id', 'hidden', 'default' => $id),
+ array('op', 'hidden', 'default' => __FUNCTION__)
+ );
+ $this->output .= inputform5($inputparams);
+ }
+
+ $this->showSimilarFunctions('email');
+ }
+
+ function mysqlDBInfoValid($dbname, $dbusername, $dbuserpass)
+ {
+ if (strlen($dbusername) > 16) {
+ return $this->errorText("Database username cannot be greater than 16 characters.");
+ }
+
+ if (strlen($dbname) > 64) {
+ return $this->errorText("Database name cannot be greater than 64 characters.");
+ }
+
+ if (strlen($dbuserpass) > 32) {
+ return $this->errorText("Database user passwords cannot be greater than 32 characters.");
+ }
+
+ $dbnameModified = removeInvalidChars($dbname, "database");
+ if ($dbnameModified != $dbname) {
+ return $this->errorText("Database names may only contain alphanumeric characters along with underscores.");
+ }
+
+ return true;
+ }
+
+ function dbAddUser()
+ {
+ global $dbname, $dbusername, $dbuserpass;
+ $this->getVariable(array('dbname', 'dbusername', 'dbuserpass'));
+
+ $domainname = $this->selecteddomain;
+
+ $dbs = $this->query("select * from " . $this->conf['mysqldbstable']['tablename'] . " where panelusername='$this->activeuser'");
+ if (count($dbs) == 0) {
+ $this->output .= "You have not any db's yet.. so, use add mysql db link here";
+ return false;
+ }
+ $success = True;
+
+ if ($dbname) {
+
+ // Must have validation
+ if (!$this->mysqlDBInfoValid($dbname, $dbusername, $dbuserpass)) {
+ return false;
+ }
+
+ if ($this->recordcount($this->conf['mysqldbstable']['tablename'], "panelusername='$this->activeuser' and dbname='$dbname'") == 0)
+ return $this->errorText("This database is not owned by your account.");
+
+ if (empty($domainname)) {
+ $domainname = $this->getField($this->conf['mysqldbuserstable']['tablename'], 'domainname', "panelusername='" . $this->activeuser . "' and dbname='" . $dbname . "'");
+ }
+
+ $q = "grant all privileges on `$dbname`.* to '$dbusername'@'localhost' identified by '$dbuserpass' ";
+ $success = $success && $this->mysqlRootQuery($q);
+
+ $q = "insert into " . $this->conf['mysqldbuserstable']['tablename'] . " (host,domainname,dbname,dbusername,password,panelusername)values('localhost','$domainname','$dbname','$dbusername','$dbuserpass','$this->activeuser')";
+ $success = $success && $s = $this->executeQuery($q, ' add mysql user to ehcp db ');
+
+ $this->ok_err_text($success, 'Successfully added database user.', 'Failed to add database user.');
+
+ } else {
+ $inputparams = array(
+ array('dbname', 'leftext' => 'Your Existing Database:'),
+ array('dbusername', 'lefttext' => 'New Database User:'),
+ array('dbuserpass', 'lefttext' => 'Database User Password:'),
+ array('op', 'hidden', 'default' => __FUNCTION__)
+ );
+ $this->output .= "Add new database user to an existing database. Enter new database user information: (Works only for local MySQL servers) "
+ . inputform5($inputparams);
+ }
+ $this->showSimilarFunctions('mysql');
+ return $success;
+ }
+
+ function dbEditUser()
+ {
+ global $dbusername, $newpassword, $newpassword2, $id, $dbremoteaccess;
+ $this->getVariable(array('dbusername', 'newpassword', 'newpassword2', 'dbremoteaccess'));
+ if ($dbusername == '')
+ $dbusername = $this->getField($this->conf['mysqldbuserstable']['tablename'], 'dbusername', "id=$id");
+
+ if ($this->recordcount($this->conf['mysqldbuserstable']['tablename'], "panelusername='$this->activeuser' and dbusername='$dbusername'") == 0) {
+ // Admin should be able to edit any MySQL user
+ if (!$this->isadmin()) {
+ return $this->errorText("This database is not owned by your account.");
+ }
+ }
+
+ if ($newpassword && $newpassword == $newpassword2) {
+ if (strlen($newpassword) <= 32) {
+ $remoteAccess = false;
+ if ($dbremoteaccess && $this->isadmin()) {
+ // Connect as root
+ if (!$myserver)
+ $myserver = $_SESSION['myserver'];
+ if (!$myserver)
+ $myserver = $this->getMysqlServer('', false, __FUNCTION__); # get mysql server info..
+
+ // Connect to mysql server, local or remote
+ if (!$link = mysqli_connect($myserver['host'], $myserver['user'], $myserver['pass'])) {
+ return $this->errorText("Could not connect as root!");
+ }
+
+ // Get databases owned by user and convert them to remote access
+ $databases = $this->getMySQLDatabasesByUser($dbusername);
+ if ($databases !== false) {
+ foreach ($databases as $info) {
+ $dbname = $info["dbname"];
+ $s = $this->executeQuery("grant all privileges on `$dbname`.* to '$dbusername'@'%' identified by '$newpassword' ", 'grant user rights', '', $link);
+ }
+ }
+ }
+
+ // Update the information in the panel
+ $q = "UPDATE " . $this->conf['mysqldbuserstable']['tablename'] . " SET password = '" . $newpassword . "' WHERE dbusername = '" . $dbusername . "'";
+ if (!$this->isadmin()) {
+ $q .= " AND panelusername = '" . $this->activeuser . "'";
+ }
+ $s = $this->executeQuery($q, 'update mysql user in ehcp db');
+
+ $this->output .= "setting new password for db user: $dbusername";
+ $q = " SET PASSWORD FOR '$dbusername'@'localhost' = PASSWORD('$newpassword')";
+ $q2 = " SET PASSWORD FOR '$dbusername'@'%' = PASSWORD('$newpassword')";
+ $result = $this->mysqlRootQuery($q, true);
+ $result2 = $this->mysqlRootQuery($q2, true);
+ if ($result === false && $result2 === false) {
+ $this->errorText("Error: Password cannot be changed for database user " . $dbusername . ".");
+ } else
+ $this->okeyText("Change password success..");
+ } else {
+ $this->errorText("Error: Password must be less than or equal to 32 characters in length.");
+ }
+ } else {
+ $inputparams = array(
+ array('newpassword', 'password', 'lefttext' => 'New Password'),
+ array('newpassword2', 'password', 'lefttext' => 'new password again'),
+ array('dbusername', 'hidden', 'default' => $dbusername),
+ array('op', 'hidden', 'default' => __FUNCTION__)
+ );
+
+ if ($this->isadmin()) {
+ $inputparams[] = array("dbremoteaccess", 'checkbox', 'lefttext' => 'Allow remote access to database:', 'default' => '1', 'checked' => '0');
+ }
+
+ $this->output .= "Change password for database user \"$dbusername\": (Works only for local MySQL servers) "
+ . inputform5($inputparams);
+ }
+ $this->showSimilarFunctions('mysql');
+ return True;
+ }
+
+ function getMySQLDatabasesByUser($user)
+ {
+ $mysqlDBUserInfo = $this->query("select * from " . $this->conf['mysqldbuserstable']['tablename'] . " where dbusername='" . $user . "'");
+ if (count($mysqlDBUserInfo) > 0) {
+ return $mysqlDBUserInfo;
+ }
+
+ return false;
+ }
+
+ function deleteCustomSetting()
+ {
+ global $id;
+ $this->getVariable(array('id'));
+ $q = "select * from customsettings where id=$id";
+ $info = $this->query($q);
+ $info = $info[0];
+
+ $domainname = trim($info['domainname']);
+ if ($domainname == '') {
+ $this->output .= "Domainname for custom setting is empty. strange.. ";
+ return;
+ }
+
+ $success = True;
+
+ $this->output .= ' ( should check ownership) Deleting id: ' . $id . ' ';
+ $success = $success && $this->executeQuery("delete from " . $this->conf['customstable']['tablename'] . " where id=$id limit 1");
+
+ if ($info['name'] == 'customdns')
+ $success = $success && $this->addDaemonOp("syncdns", '', '');
+ if ($info['name'] == 'customhttp' or $info['name'] == 'fileowner')
+ $success = $success && $this->addDaemonOp("syncdomains", 'xx', $domainname);
+ $this->ok_err_text($success, " was deleted successfully.", __FUNCTION__ . " failed.");
+ $this->showSimilarFunctions('customhttpdns');
+ return $success;
+ }
+
+ function customHttpSettings()
+ {
+ $domainname = $this->chooseDomain(__FUNCTION__, $domainname);
+ $this->listTable('Custom http settings:', 'customstable', "name='customhttp' and domainname='$domainname' and (webservertype is null or webservertype='' or webservertype='" . $this->miscconfig['webservertype'] . "')");
+ $this->output .= "Add Custom http";
+ $this->showSimilarFunctions('customhttpdns');
+ }
+
+ function custompermissions()
+ {
+ $domainname = $this->chooseDomain(__FUNCTION__, $domainname);
+ $this->listTable('Custom file permissinos:', 'customstable', "name='fileowner' and domainname='$domainname'");
+
+ $this->showSimilarFunctions('custompermissions');
+ }
+
+ function emailForwardingsSelf()
+ {
+ $this->requireEmailUser();
+
+ $filter = "source='$this->activeuser'";
+ $this->listTable("Email Forwardings", 'emailforwardingstable', $filter);
+ if ($this->recordcount($this->conf['emailforwardingstable']['tablename'], $filter) == 0)
+ $this->output .= "Add Email Forwarding";
+ }
+
+ function addEmailForwardingSelf()
+ {
+ # for mail user login..
+ global $forwardto;
+ $this->getVariable(array('forwardto'));
+
+ $this->requireEmailUser();
+ $email = $this->activeuser;
+
+ # this ensures the ownership of domain
+ $domainname = getLastPart($email, '@');
+
+
+ if (!$forwardto) {
+ $this->output .= "Email:$email , domain: $domainname Enter target emails one by line";
+ $inputparams = array(
+ array('forwardto', 'textarea', 'lefttext' => 'Forward To:')
+ );
+
+ $this->output .= inputform5($inputparams);
+
+ } else {
+ $this->output .= "Will forward $email to mails: $forwardto ";
+ $success = $this->addEmailForwardingDirect($email, $domainname, "$email", $forwardto);
+ $res = $this->ok_err_text($success, "Successfully added email forwarding.", 'Failed to add email forwarding.');
+ return $res;
+ }
+
+ }
+
+ function emailForwardings()
+ {
+ global $domainname;
+ $this->getVariable(array('domainname'));
+
+ $domainname = $this->chooseDomain(__FUNCTION__, $domainname);
+
+ $filter = "panelusername='$this->activeuser' and domainname='$domainname'";
+ #$filter=$this->applyGlobalFilter($filter);
+
+ $this->listTable("Email Forwardings", 'emailforwardingstable', $filter);
+ $this->output .= "Add Email Forwarding";
+ $this->showSimilarFunctions('email');
+ }
+
+ function addEmailForwardingDirect($panelusername, $domainname, $fromemail, $forwardto)
+ {
+ return $this->executeQuery("insert into forwardings (panelusername,domainname,source,destination)values('$panelusername','$domainname','$fromemail','$forwardto')", $opname);
+ }
+
+ function addEmailForwarding()
+ {
+ global $domainname, $beforeat, $forwardto;
+ $this->getVariable(array('domainname', 'beforeat', 'forwardto'));
+ $domainname = $this->chooseDomain(__FUNCTION__, $domainname);
+
+ $success = True;
+
+ # this ensures the ownership of domain
+
+ if (!$forwardto) {
+ $inputparams = array(
+ array('beforeat', 'righttext' => "@$domainname", 'lefttext' => 'Email: Leave empty to use the catch-all email (to receive all emails that are not setup)'),
+ array('forwardto', 'textarea', 'lefttext' => 'Forward To'),
+ array('domainname', 'hidden', 'default' => $domainname),
+ array('op', 'hidden', 'default' => __FUNCTION__)
+ );
+
+ $this->output .= inputform5($inputparams);
+
+ } else {
+ $beforeat = getFirstPart($beforeat, '@'); # make sure
+ $this->output .= "Will forward $beforeat@$domainname to mails: $forwardto ";
+ $success = $success && $this->addEmailForwardingDirect($this->activeuser, $domainname, "$beforeat@$domainname", $forwardto);
+ $this->ok_err_text($success, "Successfully added email forwarding.", __FUNCTION__ . ' failed');
+ $this->output .= " List Email forwardings ";
+ }
+ $this->showSimilarFunctions('email');
+ return $success;
+ }
+
+ function delEmailForwarding()
+ {
+ global $id;
+ $filter = $this->applyGlobalFilter("id=$id");
+ $success = $this->executeQuery("delete from " . $this->conf['emailforwardingstable']['tablename'] . " where $filter", $opname);
+ $this->output .= " List Email forwardings ";
+ $res = $this->ok_err_text($success, "Email forwarding deleted", 'Failed to delete email forwarder.');
+ $this->showSimilarFunctions('email');
+ return $res;
+ }
+
+ function addCustomHttpDirect($domainname, $customhttp, $comment)
+ {
+ $this->output .= "Adding customhttp :";
+ $success = True;
+ $success = $success && ($domainname <> '');
+ $success = $success && $this->executeQuery("insert into " . $this->conf['customstable']['tablename'] . " (domainname,name,value,comment,webservertype) values ('$domainname','customhttp','$customhttp','$comment','" . $this->miscconfig['webservertype'] . "')", 'add custom http');
+ $success = $success && $this->addDaemonOp("syncdomains", 'xx', $domainname, '', 'sync domains');
+
+ return $this->ok_err_text($success, "Custom HTTP settings were added successfully.", 'Failed to add custom HTTP settings.');
+
+ }
+
+ function addCustomHttp()
+ {
+ global $domainname, $customhttp, $comment;
+ $this->getVariable(array("domainname", "customhttp", 'comment')); # this gets variables from _GET or _POST
+ # Disable custom http if misc disableeditapachetemplate setting is set, as that is a way to break the apache template.
+ if ($this->miscconfig['disableeditapachetemplate'] <> '')
+ $this->requireAdmin();
+
+ $domainname = $this->chooseDomain(__FUNCTION__, $domainname);
+ $success = True;
+
+ if (!$customhttp) {
+ $inputparams = array(
+ array('customhttp', 'textarea', 'lefttext' => 'Custom HTTP'),
+ array('comment', 'lefttext' => 'Comment'),
+ array('domainname', 'hidden', 'default' => $domainname),
+ array('op', 'hidden', 'default' => __FUNCTION__)
+
+ );
+ $this->output .= "Adding custom HTTP for domain \"$domainname\" and your current webserver of (" . $this->miscconfig['webservertype'] . ") (Note that this custom HTTP will be active whenever your current webserver type is active): ";
+ $this->output .= inputform5($inputparams);
+
+ } else {
+ $success = $success && $this->addCustomHttpDirect($domainname, $customhttp, $comment);
+ $this->ok_err_text($success, "Successfully added custom HTTP settings.", __FUNCTION__ . " failed.");
+ }
+
+ $this->showSimilarFunctions('customhttpdns');
+ return $success;
+
+
+
+ }
+
+ function addcustompermission()
+ {
+ global $domainname, $fileowner, $directory;
+ $this->getVariable(array("domainname", "fileowner", 'directory')); # this gets variables from _GET or _POST
+
+ $domainname = $this->chooseDomain(__FUNCTION__, $domainname);
+ $success = True;
+
+ if (!$fileowner) {
+ $inputparams = array(
+ array('fileowner', 'righttext' => 'like vsftpd, or: vsftpd:www-data, cannot be root', 'lefttext' => 'File Owner:'),
+ array('directory', 'righttext' => 'relative to domain home, such as wp-content for wordpress,or wp/wp-admin', 'lefttext' => 'Directory'),
+ array('domainname', 'hidden', 'default' => $domainname),
+ array('op', 'hidden', 'default' => __FUNCTION__)
+ );
+ $this->output .= "Adding custom permission for domain ($domainname): ";
+ $this->output .= inputform5($inputparams);
+
+ } else {
+ $params = array('domainname' => $domainname, 'name' => 'fileowner', 'value' => $fileowner, 'value2' => $directory);
+ $success = $this->insert_custom_setting_direct($params);
+ $success = $success && $this->addDaemonOp("syncdomains", 'xx', $domainname);
+ $this->ok_err_text($success, "Successfully added custom HTTP settings.", __FUNCTION__ . " failed.");
+ }
+
+ $this->showSimilarFunctions('custompermissions');
+ return $success;
+
+ }
+
+ function customDnsSettings()
+ {
+ $domainname = $this->chooseDomain(__FUNCTION__, $domainname);
+ $this->listTable('Custom dns settings:', 'customstable', "name='customdns' and domainname='$domainname'");
+ $this->output .= 'Add Custom dns';
+ $this->showSimilarFunctions('customhttpdns');
+ }
+
+ function getIsSlaveDomain($domainname)
+ {
+ $dnsmaster = $this->getMasterIP($domainname);
+ return ($dnsmaster <> '');
+ }
+
+ function addCustomDns()
+ {
+ global $domainname, $customdns, $comment;
+ $this->getVariable(array("domainname", "customdns", 'comment')); # this gets variables from _GET or _POST
+
+ $domainname = $this->chooseDomain(__FUNCTION__, $domainname);
+ $success = True;
+
+ // If is slave domain, do not allow custom DNS
+ if ($this->getIsSlaveDomain($domainname))
+ $this->errorTextExit('Custom dns cannot be added for domains with slave dns');
+
+ if (!$customdns) {
+ $inputparams = array(
+ array('customdns', 'textarea', 'lefttext' => 'Custom DNS'),
+ array('comment', 'lefttext' => 'Comment'),
+ array('domainname', 'hidden', 'default' => $domainname),
+ array('op', 'hidden', 'default' => __FUNCTION__)
+ );
+
+ $this->output .= "Adding custom DNS for domain \"$domainname\": Attention! Adding incorrect entries will cause DNS service errors!
Example:
www2 IN A YOURIP "
- .inputform5($inputparams);
-
- $this->output.="Following dns records already added from template, you may modify template (dnszonetemplate file) in filesystem.
".
- file_get_contents('dnszonetemplate')."
";
-
- } else{
- $this->output.="Adding customdns :";
- $success=$success && $this->executeQuery("insert into ".$this->conf['customstable']['tablename']." (domainname,name,value,comment) values ('$domainname','customdns','$customdns','$comment')",'add custom dns');
- $success=$success && $this->addDaemonOp("syncdns",'','','','sync dns');
- $this->ok_err_text($success,"Successfully added custom DNS entries!",'Failed to add custom DNS entries.');
- }
-
- $this->showSimilarFunctions('customhttpdns');
- return $success;
-}
+ . inputform5($inputparams);
+
+ $this->output .= "Following dns records already added from template, you may modify template (dnszonetemplate file) in filesystem.
" .
+ file_get_contents('dnszonetemplate') . "
";
+
+ } else {
+ $this->output .= "Adding customdns :";
+ $success = $success && $this->executeQuery("insert into " . $this->conf['customstable']['tablename'] . " (domainname,name,value,comment) values ('$domainname','customdns','$customdns','$comment')", 'add custom dns');
+ $success = $success && $this->addDaemonOp("syncdns", '', '', '', 'sync dns');
+ $this->ok_err_text($success, "Successfully added custom DNS entries!", 'Failed to add custom DNS entries.');
+ }
+
+ $this->showSimilarFunctions('customhttpdns');
+ return $success;
+ }
-function listBackups(){
- $this->requireAdmin();
+ function listBackups()
+ {
+ $this->requireAdmin();
$this->echoln(' Backups are placed in /var/backup directory. Note filename to a secure place to restore it later.
you will need this filename if you need restore from a clean install of ehcp
Refresh your page to see latest status...');
- $this->listTable('','backups_table','');
+ $this->listTable('', 'backups_table', '');
$this->echoln("You may delete all these files and records manually... from shell and phpmyadmin gui.. Refresh List");
$this->showSimilarFunctions('backup');
return True;
-}
+ }
-function doRestore(){
- global $backupname,$filename;
- $this->getVariable(array('backupname','filename'));
+ function doRestore()
+ {
+ global $backupname, $filename;
+ $this->getVariable(array('backupname', 'filename'));
- $this->requireAdmin();
+ $this->requireAdmin();
- if(!$backupname){
- $inputparams=array(
- array('backupname','lefttext'=>'Enter your backup file name which is located at /var/backup (with .tgz extension)','default'=>$filename),
- array('domainname','hidden','default'=>$domainname),
- array('op','hidden','default'=>__FUNCTION__)
+ if (!$backupname) {
+ $inputparams = array(
+ array('backupname', 'lefttext' => 'Enter your backup file name which is located at /var/backup (with .tgz extension)', 'default' => $filename),
+ array('domainname', 'hidden', 'default' => $domainname),
+ array('op', 'hidden', 'default' => __FUNCTION__)
+ );
+
+ $this->output .= "
Attention! Backup data including domains, users, files, and MySQL databases will be restored. Your current data will be permanently deleted!
"
+ . inputform5($inputparams);
+ } else {
+ $this->echoln("Will restore from file: " . $backupname);
+ $this->executeQuery("insert into backups (backupname,filename,date,status) values ('restore','$backupname','" . date_tarih() . "','Restore command issued by gui')");
+ $this->addDaemonOp("daemonrestore", '', $backupname, '', 'opname:restore');
+ $this->echoln("doRestore called...Restore will be started on your Server soon. Click here to list backups/restores ");
+ }
+
+ $this->showSimilarFunctions('backup');
+ return True;
+ }
+
+
+ function daemonRestore($action, $info, $info2 = '')
+ {
+ $this->requireCommandLine(__FUNCTION__, True);
+
+ $filename = securefilename($info);
+ $backupname = $filename;
+ $filename = str_replace('.tgz', '', $filename);
+ $filename = str_replace('.gz', '', $filename);
+ $tarwithparams = "tar --same-owner --preserve-permissions -zxvf ";
+
+ echo "\n\nRestore starting..: backupname:$backupname, filename:$filename .. this is critic place...\n\n";
+ $this->executeQuery("update backups set status='restore processing now... by daemon' where filename='$filename' and backupname='restore'");
+
+
+ $mydir = getcwd();
+
+ # restore files first
+ chdir("/var/backup");
+
+ $this->pwdls('extracting backup file ' . $backupname);
+ passthru2("$tarwithparams $backupname");
+ $this->pwdls('extraction of backup file ' . $backupname . ' complete!');
+
+ if (file_exists('/var/backup/' . $filename)) {
+ $this->pwdls('extraction directory of /var/backup/' . $filename . ' exists as it should!');
+ } else {
+ $this->pwdls('extraction directory of /var/backup/' . $filename . ' does NOT exist! This is a critical problem');
+ }
+
+ $this->pwdls('changing to extraction directory of /var/backup/' . $filename);
+ chdir("/var/backup/" . $filename);
+
+ $this->pwdls('before extract files');
+
+ #writeoutput($this->conf['vhosts']."/ehcp/nohup.out",'');
+
+ #passthru2("/bin/cat '' > ".$this->conf['vhosts']."/ehcp/nohup.out"); # truncate this file in case this may be big
+ passthru2("$tarwithparams files.tgz");
+ $this->pwdls('after files, before ehcp');
+ passthru2("$tarwithparams ehcp.tgz"); # this will normally give error if there is no ehcp backup
+ $this->pwdls('after ehcp, before copy');
+
+ # restore email contents, if any
+ passthru2("$tarwithparams home_vmail.tgz");
+
+ # Email fix: should be "cp -Rvf --preserve=all home/vmail /home/" (starting from relative directory where home_vmail.tgz was unzipped) as the "*" in vmail/* was getting escaped which ruined the command
+ # Changed from vmail/*
+ passthru2("cp -Rvf --preserve=all home/vmail /home/");
+ passthru2("chown -Rf vmail:vmail /home/vmail");
+
+
+
+ passthru2("cp -Rvf --preserve=all var/www/vhosts /var/www/"); # here, var/www/vhosts is inside /var/backup... so, I used var/www/vhosts
+
+
+ #restore mysql ehcp db..
+
+ echo "\nrestoring your whole mysql.. \n\n";
+ $cmd = "mysql -u root --password=" . $this->conf['mysqlrootpass'] . " < mysql.sql";
+ passthru3($cmd, __FUNCTION__);
+
+ sleep(1);
+ $this->executeQuery("delete from operations"); # delete operations to avoid re-run of backup/restore..
+ #$this->executeQuery("Flush tables");
+ echo "\nfinished restoring your whole mysql.. \n";
+
+ echo "\nfinished copying and mysql ops, deleting remaining files... \n";
+ $this->pwdls('will just delete files...');
+ passthru2("rm -rf /var/backup/$filename");
+
+ chdir($mydir); # return back to original dir
+ sleep(1);
+ $this->syncAll();
+ sleep(1);
+ $this->executeQuery("update backups set status='restore complete' where filename='$filename' and backupname='restore'");
+ $this->executeQuery("insert into backups (backupname,filename,status) values ('restore complete','$filename','after restore')");
+ sleep(1); # sleep to let mysql handle latest updates...
+
+ echo "\n\nRestore complete.... you should restart the ehcp daemon...";
+ $this->infotoadminemail("The EHCP backup was successfully restored!", "Backup Restored", False);
+
+ // Restart web server and EHCP daemon
+ // Things could change post restore, so make sure we run what needs to be done.
+ $this->loadConfig();
+ $this->addDaemonOp('rebuild_webserver_configs', '', '', '', 'rebuild_webserver_configs');
+ $this->addDaemonOp('syncdomains', '', '', '', 'sync domains');
+ $this->addDaemonOp('syncdns', '', '', '', 'sync dns');
+ $this->addDaemonOp('syncftp', '', '', '', 'sync ftp');
+ $this->addDaemonOp('rebuild_crontab', '', '', '', 'rebuild crontab');
+ manageService("ehcp", "restart");
+ $this->restart_webserver();
+
+ return True;
+ }
+
+ function backups()
+ {
+ # domain based backups, not whole server or not all domains.
+ global $_insert, $op2, $filename;
+ $this->getVariable(array('_insert', 'op2', 'filename'));
+
+ #$this->output.="This section is not working fully!
";
+
+ $domainname = $this->chooseDomain(__FUNCTION__, $domainname); # choose domain, or selecteddomain..
+
+ switch ($op2) {
+ case 'dobackup':
+ $this->add_daemon_op(array('op' => 'daemon_backup_domain', 'info' => $domainname));
+ $this->executeQuery("insert into backups (domainname,date,status) values ('$domainname',now(),'command sent to ehcp daemon by ehcp gui')");
+ break;
+
+ default:
+ $this->output .= "Start a new domain backup (your domain backup will be started in background)";
+ break;
+ }
+
+ $this->listTable('', 'backups_table', "domainname='$domainname'");
+ $this->output .= " Refresh/list";
+
+ return True;
+ }
+
+ function doBackup()
+ {
+ $this->requireAdmin();
+
+ $inputparams = array(
+ array('backupname', 'lefttext' => 'Enter a name for your backup', 'default' => 'My Backup'),
+ array('backupmysql', 'checkbox', 'lefttext' => 'Backup mysql databases (that are listed in ehcp):', 'default' => '1', 'checked' => '1'),
+ array('backupfiles', 'checkbox', 'lefttext' => 'Backup Site files:', 'default' => '1', 'checked' => '1'),
+ array('backupehcpfiles', 'checkbox', 'lefttext' => 'Backup ehcp files itself:', 'default' => '1'),
+ array('backupehcpdb', 'checkbox', 'lefttext' => 'Backup ehcp database itself:', 'default' => '1', 'checked' => '1'),
+ array('emailme', 'checkbox', 'lefttext' => 'Email me when backup finished (may not work yet):', 'default' => '1', 'checked' => '1'),
+ array('myemail', 'lefttext' => 'My Email, enter different if you wish:', 'default' => $this->conf['adminemail']),
+ array('emailaccounts', 'checkbox', 'lefttext' => 'Backup email accounts:', 'default' => '1', 'checked' => '1'),
+ array('emailcontents', 'checkbox', 'lefttext' => 'Backup email contents/files:', 'default' => '1', 'checked' => '1'),
+ array('gzipbackup', 'checkbox', 'lefttext' => 'tar-gzip backup dir/file:', 'righttext' => 'This is useful, but requires some extra space temporarily. uncheck if you have little space', 'default' => '1', 'checked' => '1'),
+
+ array('domainname', 'hidden', 'default' => $domainname),
+ array('_insert', 'hidden', 'default' => '1'),
+ array('op', 'hidden', 'default' => __FUNCTION__)
);
- $this->output.="
Attention! Backup data including domains, users, files, and MySQL databases will be restored. Your current data will be permanently deleted!
"
- .inputform5($inputparams);
- } else {
- $this->echoln("Will restore from file: ".$backupname);
- $this->executeQuery("insert into backups (backupname,filename,date,status) values ('restore','$backupname','".date_tarih()."','Restore command issued by gui')");
- $this->addDaemonOp("daemonrestore",'',$backupname,'','opname:restore');
- $this->echoln("doRestore called...Restore will be started on your Server soon. Click here to list backups/restores ");
- }
+ # instead of: #$this->getVariable(array('_insert','backupmysql','backupfiles','backupehcpfiles','backupehcpdb','backupname'));
+ foreach ($inputparams as $p) { # howto avoid global variables ?
+ global ${$p[0]};
+ $this->getVariable($p[0]);
+ }
- $this->showSimilarFunctions('backup');
- return True;
-}
+ if (!$_insert) {
+ $this->output .= "Caution: System may take a while to complete backup operations. The compressed backup file may consume lots of hard disk space depending on how many domains and files are backed-up." . inputform5($inputparams);
+ } else {
-function daemonRestore($action,$info,$info2='') {
- $this->requireCommandLine(__FUNCTION__,True);
-
- $filename=securefilename($info);
- $backupname=$filename;
- $filename=str_replace('.tgz','',$filename);
- $filename=str_replace('.gz','',$filename);
- $tarwithparams="tar --same-owner --preserve-permissions -zxvf ";
-
- echo "\n\nRestore starting..: backupname:$backupname, filename:$filename .. this is critic place...\n\n";
- $this->executeQuery("update backups set status='restore processing now... by daemon' where filename='$filename' and backupname='restore'");
-
-
- $mydir=getcwd();
-
- # restore files first
- chdir("/var/backup");
-
- $this->pwdls('extracting backup file ' . $backupname);
- passthru2("$tarwithparams $backupname");
- $this->pwdls('extraction of backup file ' . $backupname . ' complete!');
-
- if(file_exists('/var/backup/' . $filename)){
- $this->pwdls('extraction directory of /var/backup/' . $filename . ' exists as it should!');
- }else{
- $this->pwdls('extraction directory of /var/backup/' . $filename . ' does NOT exist! This is a critical problem');
- }
-
- $this->pwdls('changing to extraction directory of /var/backup/' . $filename);
- chdir("/var/backup/" . $filename);
-
- $this->pwdls('before extract files');
-
- #writeoutput($this->conf['vhosts']."/ehcp/nohup.out",'');
-
- #passthru2("/bin/cat '' > ".$this->conf['vhosts']."/ehcp/nohup.out"); # truncate this file in case this may be big
- passthru2("$tarwithparams files.tgz");
- $this->pwdls('after files, before ehcp');
- passthru2("$tarwithparams ehcp.tgz"); # this will normally give error if there is no ehcp backup
- $this->pwdls('after ehcp, before copy');
-
- # restore email contents, if any
- passthru2("$tarwithparams home_vmail.tgz");
-
- # Email fix: should be "cp -Rvf --preserve=all home/vmail /home/" (starting from relative directory where home_vmail.tgz was unzipped) as the "*" in vmail/* was getting escaped which ruined the command
- # Changed from vmail/*
- passthru2("cp -Rvf --preserve=all home/vmail /home/");
- passthru2("chown -Rf vmail:vmail /home/vmail");
-
-
-
- passthru2("cp -Rvf --preserve=all var/www/vhosts /var/www/"); # here, var/www/vhosts is inside /var/backup... so, I used var/www/vhosts
-
-
- #restore mysql ehcp db..
-
- echo "\nrestoring your whole mysql.. \n\n";
- $cmd="mysql -u root --password=".$this->conf['mysqlrootpass']." < mysql.sql";
- passthru3($cmd,__FUNCTION__);
-
- sleep(1);
- $this->executeQuery("delete from operations");# delete operations to avoid re-run of backup/restore..
- #$this->executeQuery("Flush tables");
- echo "\nfinished restoring your whole mysql.. \n";
-
- echo "\nfinished copying and mysql ops, deleting remaining files... \n";
- $this->pwdls('will just delete files...');
- passthru2("rm -rf /var/backup/$filename");
-
- chdir($mydir);# return back to original dir
- sleep(1);
- $this->syncAll();
- sleep(1);
- $this->executeQuery("update backups set status='restore complete' where filename='$filename' and backupname='restore'");
- $this->executeQuery("insert into backups (backupname,filename,status) values ('restore complete','$filename','after restore')");
- sleep(1); # sleep to let mysql handle latest updates...
-
- echo "\n\nRestore complete.... you should restart the ehcp daemon...";
- $this->infotoadminemail("The EHCP backup was successfully restored!","Backup Restored",False);
-
- // Restart web server and EHCP daemon
- // Things could change post restore, so make sure we run what needs to be done.
- $this->loadConfig();
- $this->addDaemonOp('rebuild_webserver_configs','','','','rebuild_webserver_configs');
- $this->addDaemonOp('syncdomains','','','','sync domains');
- $this->addDaemonOp('syncdns','','','','sync dns');
- $this->addDaemonOp('syncftp','','','','sync ftp');
- $this->addDaemonOp('rebuild_crontab','','','','rebuild crontab');
- manageService("ehcp", "restart");
- $this->restart_webserver();
-
- return True;
-}
-
-function backups(){
- # domain based backups, not whole server or not all domains.
- global $_insert,$op2,$filename;
- $this->getVariable(array('_insert','op2','filename'));
-
- #$this->output.="This section is not working fully!
";
-
- $domainname=$this->chooseDomain(__FUNCTION__,$domainname); # choose domain, or selecteddomain..
-
- switch($op2) {
- case 'dobackup': $this->add_daemon_op(array('op'=>'daemon_backup_domain','info'=>$domainname));
- $this->executeQuery("insert into backups (domainname,date,status) values ('$domainname',now(),'command sent to ehcp daemon by ehcp gui')");
- break;
-
- default:$this->output.="Start a new domain backup (your domain backup will be started in background)";break;
- }
-
- $this->listTable('','backups_table',"domainname='$domainname'");
- $this->output.=" Refresh/list";
-
- return True;
-}
-
-function doBackup(){
- $this->requireAdmin();
-
- $inputparams=array(
- array('backupname','lefttext'=>'Enter a name for your backup','default'=>'My Backup'),
- array('backupmysql','checkbox','lefttext'=>'Backup mysql databases (that are listed in ehcp):','default'=>'1','checked'=>'1'),
- array('backupfiles','checkbox','lefttext'=>'Backup Site files:','default'=>'1','checked'=>'1'),
- array('backupehcpfiles','checkbox','lefttext'=>'Backup ehcp files itself:','default'=>'1'),
- array('backupehcpdb','checkbox','lefttext'=>'Backup ehcp database itself:','default'=>'1','checked'=>'1'),
- array('emailme','checkbox','lefttext'=>'Email me when backup finished (may not work yet):','default'=>'1','checked'=>'1'),
- array('myemail','lefttext'=>'My Email, enter different if you wish:','default'=>$this->conf['adminemail']),
- array('emailaccounts','checkbox','lefttext'=>'Backup email accounts:','default'=>'1','checked'=>'1'),
- array('emailcontents','checkbox','lefttext'=>'Backup email contents/files:','default'=>'1','checked'=>'1'),
- array('gzipbackup','checkbox','lefttext'=>'tar-gzip backup dir/file:','righttext'=>'This is useful, but requires some extra space temporarily. uncheck if you have little space','default'=>'1','checked'=>'1'),
-
- array('domainname','hidden','default'=>$domainname),
- array('_insert','hidden','default'=>'1'),
- array('op','hidden','default'=>__FUNCTION__)
- );
-
- # instead of: #$this->getVariable(array('_insert','backupmysql','backupfiles','backupehcpfiles','backupehcpdb','backupname'));
- foreach($inputparams as $p) { # howto avoid global variables ?
- global ${$p[0]};
- $this->getVariable($p[0]);
- }
-
- if(!$_insert){
- $this->output.="Caution: System may take a while to complete backup operations. The compressed backup file may consume lots of hard disk space depending on how many domains and files are backed-up.".inputform5($inputparams);
- } else {
-
-
- $filename='backup-'.date('Y-m-d_H-i-s');
- $this->output.="What will do/backup:
+ $filename = 'backup-' . date('Y-m-d_H-i-s');
+ $this->output .= "What will do/backup:
Backup mysql:$backupmysql
Backup site files:$backupfiles
Backup ehcp files:$backupehcpfiles
@@ -3598,234 +4238,255 @@ function doBackup(){
Gzip backup:$gzipbackup
";
- $backup=''; # what will be backup
- if($backupmysql) $backup.='-mysql';
- if($backupfiles) $backup.='-files';
- if($backupehcpfiles) $backup.='-ehcpfiles';
- if($backupehcpdb) $backup.='-ehcpdb';
- if($emailme) $backup.='-emailme';
- if($emailaccounts) $backup.='-emailaccounts';
- if($emailcontents) $backup.='-emailcontents';
- if($gzipbackup) $backup.='-gzipbackup';
+ $backup = ''; # what will be backup
+ if ($backupmysql)
+ $backup .= '-mysql';
+ if ($backupfiles)
+ $backup .= '-files';
+ if ($backupehcpfiles)
+ $backup .= '-ehcpfiles';
+ if ($backupehcpdb)
+ $backup .= '-ehcpdb';
+ if ($emailme)
+ $backup .= '-emailme';
+ if ($emailaccounts)
+ $backup .= '-emailaccounts';
+ if ($emailcontents)
+ $backup .= '-emailcontents';
+ if ($gzipbackup)
+ $backup .= '-gzipbackup';
- $backupname.='-Backups:'.$backup;
+ $backupname .= '-Backups:' . $backup;
- $this->executeQuery("insert into backups (backupname,filename,date,status) values ('$backupname','$filename','".date_tarih()."','command sent to ehcp daemon by ehcp gui')");
- $this->addDaemonOp("daemonbackup",'',$filename,$backup,'opname:backup');
- $this->echoln("Backup will be started on your Server soon. Click here to list backups and see status ");
- }
-
- $this->showSimilarFunctions('backup');
- return True;
-}
-
-function pwdls($comment='',$dir=''){
- echo "\n $comment \npwd is:".getcwd()."\n";
- passthru('ls -l '.$dir);
- echo "\n\n";
- sleep(1);
-}
-
-function backup_databases2($dbs,$mysqlusers,$file){
- $this->requireCommandLine(__FUNCTION__);
- $foundEHCPDB = false;
- # set empty file then fill with dump of each mysql database, in ehcp, (before vers 0.27: all databases were dumped, that caused: malfunction because of restore of mysql db itself... now, mysql db is not restored... so, passwords of new mysql server are kept after restore... )
-
- print_r($dbs);
-
- if(count($dbs)>0){
- foreach($dbs as $db) {
- $sql = "";
- if($db['dbname'] == "ehcp"){
- $foundEHCPDB = true;
- // Delete EHCP database since importing the backup will fail if there's existing values in it.
- $sql .= "DROP DATABASE IF EXISTS `".$db['dbname']."`;\n";
- }
-
- $sql .= "create database if not exists `".$db['dbname']."`;\n";
- $sql .= "use `".$db['dbname']."`;\n";
- writeoutput2($file,$sql,"a");
-
- $cmd=escapeshellcmd("mysqldump ".$db['dbname']." -u root --password=".$this->conf['mysqlrootpass'])." >> ".escapeshellcmd($file);
- passthru3($cmd,__FUNCTION__);
+ $this->executeQuery("insert into backups (backupname,filename,date,status) values ('$backupname','$filename','" . date_tarih() . "','command sent to ehcp daemon by ehcp gui')");
+ $this->addDaemonOp("daemonbackup", '', $filename, $backup, 'opname:backup');
+ $this->echoln("Backup will be started on your Server soon. Click here to list backups and see status ");
}
+
+ $this->showSimilarFunctions('backup');
+ return True;
}
- if(count($mysqlusers)>0){
- foreach($mysqlusers as $user){
- #print_r($user);
- // Get MySQL User and DB Information
- $dbname=$user['dbname'];
- $dbusername=$user['dbusername'];
- $dbuserpass=$user['password'];
+ function pwdls($comment = '', $dir = '')
+ {
+ echo "\n $comment \npwd is:" . getcwd() . "\n";
+ passthru('ls -l ' . $dir);
+ echo "\n\n";
+ sleep(1);
+ }
+
+ function backup_databases2($dbs, $mysqlusers, $file)
+ {
+ $this->requireCommandLine(__FUNCTION__);
+ $foundEHCPDB = false;
+ # set empty file then fill with dump of each mysql database, in ehcp, (before vers 0.27: all databases were dumped, that caused: malfunction because of restore of mysql db itself... now, mysql db is not restored... so, passwords of new mysql server are kept after restore... )
+
+ print_r($dbs);
+
+ if (count($dbs) > 0) {
+ foreach ($dbs as $db) {
+ $sql = "";
+ if ($db['dbname'] == "ehcp") {
+ $foundEHCPDB = true;
+ // Delete EHCP database since importing the backup will fail if there's existing values in it.
+ $sql .= "DROP DATABASE IF EXISTS `" . $db['dbname'] . "`;\n";
+ }
+
+ $sql .= "create database if not exists `" . $db['dbname'] . "`;\n";
+ $sql .= "use `" . $db['dbname'] . "`;\n";
+ writeoutput2($file, $sql, "a");
+
+ $cmd = escapeshellcmd("mysqldump " . $db['dbname'] . " -u root --password=" . $this->conf['mysqlrootpass']) . " >> " . escapeshellcmd($file);
+ passthru3($cmd, __FUNCTION__);
+ }
+ }
+
+ if (count($mysqlusers) > 0) {
+ foreach ($mysqlusers as $user) {
+ #print_r($user);
+ // Get MySQL User and DB Information
+ $dbname = $user['dbname'];
+ $dbusername = $user['dbusername'];
+ $dbuserpass = $user['password'];
- // Put grant usage permissions into the file
- $sql = "GRANT USAGE ON *.* TO '$dbusername'@'localhost' IDENTIFIED BY '$dbuserpass';";
- $sql .= "\n" . "GRANT ALL PRIVILEGES ON `" . $dbname . "`.* TO '$dbusername'@'localhost';";
-
- // Check for remote access permissions
- $q=" SET PASSWORD FOR '$dbusername'@'%' = PASSWORD('$dbuserpass')";
- $result = $this->mysqlRootQuery($q, true);
- if($result !== false){
// Put grant usage permissions into the file
- $sql .= "\nGRANT USAGE ON *.* TO '$dbusername'@'%' IDENTIFIED BY '$dbuserpass';";
- $sql .= "\n" . "GRANT ALL PRIVILEGES ON `" . $dbname . "`.* TO '$dbusername'@'%';";
+ $sql = "GRANT USAGE ON *.* TO '$dbusername'@'localhost' IDENTIFIED BY '$dbuserpass';";
+ $sql .= "\n" . "GRANT ALL PRIVILEGES ON `" . $dbname . "`.* TO '$dbusername'@'localhost';";
+
+ // Check for remote access permissions
+ $q = " SET PASSWORD FOR '$dbusername'@'%' = PASSWORD('$dbuserpass')";
+ $result = $this->mysqlRootQuery($q, true);
+ if ($result !== false) {
+ // Put grant usage permissions into the file
+ $sql .= "\nGRANT USAGE ON *.* TO '$dbusername'@'%' IDENTIFIED BY '$dbuserpass';";
+ $sql .= "\n" . "GRANT ALL PRIVILEGES ON `" . $dbname . "`.* TO '$dbusername'@'%';";
+ }
+
+ writeoutput2($file, $sql, "a");
}
-
- writeoutput2($file,$sql,"a");
}
- }
-
- // Flush privileges to activate the new user accounts and passwords
- $fixAccounts = "FLUSH PRIVILEGES;";
- writeoutput2($file,$fixAccounts,"a");
-}
+ // Flush privileges to activate the new user accounts and passwords
+ $fixAccounts = "FLUSH PRIVILEGES;";
+ writeoutput2($file, $fixAccounts, "a");
-function backup_databases($filt,$file){ # yeni fonks.
- $this->requireCommandLine(__FUNCTION__);
-
- if($filt<>'') $where=" where $filt";
- else $where="";
-
- $dbs=$this->query("select dbname from mysqldb $where");
- $mysqlusers=$this->query("select * from mysqlusers $where");
-
- $this->backup_databases2($dbs,$mysqlusers,$file);
-}
-
-function daemonBackup($action,$info,$info2='') {
- $this->requireCommandLine(__FUNCTION__);
-
- # do all operations inside /var/backup
-
- $filename=securefilename($info);
- $backupdir=$this->miscconfig['backupdir'];
- if($backupdir=='') $backupdir="/var/backup";
- $dirname="$backupdir/$filename";# this may be a variable in misc/options table
-
- echo "Backup starting..: dirname:$dirname, filename:$filename ($info2)";
- $this->executeQuery("update backups set status='processing now... by daemon' where filename='$filename'");
- $this->executeQuery("delete from operations");# delete operations to avoid re-run of backup/restore..
- #$this->executeQuery("Flush tables");
- $tarwithparams="tar -zcvf ";
-
- passthru2("mkdir -p $dirname");
- chdir($dirname);
-
- $this->pwdls();
-
- $dbs=array();
-
- if(strstr($info2,'-mysql')) {
- $dbs=$this->query("select dbname from mysqldb");
- $mysqlusers=$this->query("select * from mysqlusers");
}
- if(strstr($info2,'-ehcpdb')) $dbs[]=array("dbname"=>"ehcp");
-
- $this->backup_databases2($dbs,$mysqlusers,"$dirname/mysql.sql");
-
-
+ function backup_databases($filt, $file)
+ { # yeni fonks.
+ $this->requireCommandLine(__FUNCTION__);
- $this->pwdls();
+ if ($filt <> '')
+ $where = " where $filt";
+ else
+ $where = "";
- if(strstr($info2,'-ehcpfiles'))
- passthru2("$tarwithparams ehcp.tgz ".$this->ehcpdir); # ehcp files will be backedup
+ $dbs = $this->query("select dbname from mysqldb $where");
+ $mysqlusers = $this->query("select * from mysqlusers $where");
- if(strstr($info2,'-files'))
- passthru2("$tarwithparams files.tgz ".$this->vhostsdir." --exclude=".$this->ehcpdir); # files will be backedup
+ $this->backup_databases2($dbs, $mysqlusers, $file);
+ }
- if(strstr($info2,'-emailcontents'))
- passthru2("$tarwithparams home_vmail.tgz /home/vmail"); # files will be backedup
+ function daemonBackup($action, $info, $info2 = '')
+ {
+ $this->requireCommandLine(__FUNCTION__);
- $this->pwdls();
+ # do all operations inside /var/backup
- # combine all in one file
- if(strstr($info2,'-gzipbackup')) {
- chdir('/var/backup');
- passthru2("$tarwithparams $filename.tgz $filename");
- $size = filesize("$filename.tgz");
- if(!$size) $size=0;
+ $filename = securefilename($info);
+ $backupdir = $this->miscconfig['backupdir'];
+ if ($backupdir == '')
+ $backupdir = "/var/backup";
+ $dirname = "$backupdir/$filename"; # this may be a variable in misc/options table
+
+ echo "Backup starting..: dirname:$dirname, filename:$filename ($info2)";
+ $this->executeQuery("update backups set status='processing now... by daemon' where filename='$filename'");
+ $this->executeQuery("delete from operations"); # delete operations to avoid re-run of backup/restore..
+ #$this->executeQuery("Flush tables");
+ $tarwithparams = "tar -zcvf ";
+
+ passthru2("mkdir -p $dirname");
+ chdir($dirname);
$this->pwdls();
- passthru2("rm -rf ".$filename);
- } else {
- $size=0;
- $filename='Not gzipped into single file, as you requested';
- }
-
- $commandPostBackup = 'echo 1 > /var/backup/' . $filename . '_STATUS';
- passthru3($commandPostBackup);
-
- $this->check_mysql_connection();
- $this->executeQuery("update backups set status='complete',size=$size where filename='$filename'");
-
-
- echo "finished backups...";
- chdir($this->ehcpdir);# return back to original dir
- $this->infotoadminemail("An EHCP backup has successfully been created. More information about this backup can be viewed in the panel.","Backup Created",False);
- return True;
+ $dbs = array();
-
-}
-
-function is_email_user(){
- return strstr($this->activeuser,'@');
-}
-
-function displayHome($homefile=''){
-
- # display different home pages depending on logedin user.. admin, reseller, domain admin, email user (There are four levels of login..)
-
-if($this->userinfo['maxdomains']==1) {
- $domainname=$this->getField($this->conf['domainstable']['tablename'], "domainname", "panelusername='$this->activeuser'");
- $this->setselecteddomain($domainname);
-}
-
-if($this->selecteddomain<>''){
- $this->domaininfo=$this->getDomainInfo($this->selecteddomain);
-}
-
-if ($homefile<>'') {
- $homepage=$homefile ;
-} elseif($this->selecteddomain<>'' and $this->domaininfo['serverip']<>''){
- $homepage='homepage_remotehosting_dnsonly';
- $this->output.=" This domain is dns hosted, directed to ip:".$this->domaininfo['serverip']." ";
-} elseif($this->is_email_user()){
- $homepage='homepage_emailuser';
-} elseif($this->userinfo['maxdomains']==1) {
- $homepage='homepage_domainadmin';
-} elseif(!$this->isadmin() and $this->userinfo['maxdomains']>1) {
- if($this->selecteddomain==''){
- if($this->userinfo['maxpanelusers'] > 0){
- $homepage='homepage_reseller';
- }else{
- $homepage='homepage_paneluser';
-
- // Older theme compatibility
- $file="templates/$this->template/$this->currentlanguage/".$homepage."_".$this->currentlanguage.".html";
- if(!file_exists($file)){
- $homepage='homepage_reseller';
- }
+ if (strstr($info2, '-mysql')) {
+ $dbs = $this->query("select dbname from mysqldb");
+ $mysqlusers = $this->query("select * from mysqlusers");
}
- }else{
- $homepage='homepage_domainadmin_forreseller';
- }
-} elseif($this->isadmin()) {
- if($this->selecteddomain=='') $homepage='homepage_serveradmin';
- else $homepage='homepage_domainadmin_forreseller'; # domain pages for reseller and admin are same
-}
-else $homepage='homepage_domainadmin'; # this line should never be executed..
+
+ if (strstr($info2, '-ehcpdb'))
+ $dbs[] = array("dbname" => "ehcp");
+
+ $this->backup_databases2($dbs, $mysqlusers, "$dirname/mysql.sql");
- # buraya bide email girisi icin homepage yapilacak, emailde bitek sifre degistirme, ve belkide yonlendirme olacak...
-$pageinfo="Homepage Template used to generate this page: ".$homepage."_".$this->currentlanguage.".html ";
+ $this->pwdls();
-$this->output.=str_replace(array("{selecteddomain}"),array($this->selecteddomain),$this->loadTemplate($homepage));
-$this->output.=" Your language: $this->currentlanguage
+ if (strstr($info2, '-ehcpfiles'))
+ passthru2("$tarwithparams ehcp.tgz " . $this->ehcpdir); # ehcp files will be backedup
+
+ if (strstr($info2, '-files'))
+ passthru2("$tarwithparams files.tgz " . $this->vhostsdir . " --exclude=" . $this->ehcpdir); # files will be backedup
+
+ if (strstr($info2, '-emailcontents'))
+ passthru2("$tarwithparams home_vmail.tgz /home/vmail"); # files will be backedup
+
+ $this->pwdls();
+
+ # combine all in one file
+ if (strstr($info2, '-gzipbackup')) {
+ chdir('/var/backup');
+ passthru2("$tarwithparams $filename.tgz $filename");
+ $size = filesize("$filename.tgz");
+ if (!$size)
+ $size = 0;
+
+ $this->pwdls();
+
+ passthru2("rm -rf " . $filename);
+ } else {
+ $size = 0;
+ $filename = 'Not gzipped into single file, as you requested';
+ }
+
+ $commandPostBackup = 'echo 1 > /var/backup/' . $filename . '_STATUS';
+ passthru3($commandPostBackup);
+
+ $this->check_mysql_connection();
+ $this->executeQuery("update backups set status='complete',size=$size where filename='$filename'");
+
+
+ echo "finished backups...";
+ chdir($this->ehcpdir); # return back to original dir
+ $this->infotoadminemail("An EHCP backup has successfully been created. More information about this backup can be viewed in the panel.", "Backup Created", False);
+ return True;
+
+
+ }
+
+ function is_email_user()
+ {
+ return strstr($this->activeuser, '@');
+ }
+
+ function displayHome($homefile = '')
+ {
+
+ # display different home pages depending on logedin user.. admin, reseller, domain admin, email user (There are four levels of login..)
+
+ if ($this->userinfo['maxdomains'] == 1) {
+ $domainname = $this->getField($this->conf['domainstable']['tablename'], "domainname", "panelusername='$this->activeuser'");
+ $this->setselecteddomain($domainname);
+ }
+
+ if ($this->selecteddomain <> '') {
+ $this->domaininfo = $this->getDomainInfo($this->selecteddomain);
+ }
+
+ if ($homefile <> '') {
+ $homepage = $homefile;
+ } elseif ($this->selecteddomain <> '' and $this->domaininfo['serverip'] <> '') {
+ $homepage = 'homepage_remotehosting_dnsonly';
+ $this->output .= " This domain is dns hosted, directed to ip:" . $this->domaininfo['serverip'] . " ";
+ } elseif ($this->is_email_user()) {
+ $homepage = 'homepage_emailuser';
+ } elseif ($this->userinfo['maxdomains'] == 1) {
+ $homepage = 'homepage_domainadmin';
+ } elseif (!$this->isadmin() and $this->userinfo['maxdomains'] > 1) {
+ if ($this->selecteddomain == '') {
+ if ($this->userinfo['maxpanelusers'] > 0) {
+ $homepage = 'homepage_reseller';
+ } else {
+ $homepage = 'homepage_paneluser';
+
+ // Older theme compatibility
+ $file = "templates/$this->template/$this->currentlanguage/" . $homepage . "_" . $this->currentlanguage . ".html";
+ if (!file_exists($file)) {
+ $homepage = 'homepage_reseller';
+ }
+ }
+ } else {
+ $homepage = 'homepage_domainadmin_forreseller';
+ }
+ } elseif ($this->isadmin()) {
+ if ($this->selecteddomain == '')
+ $homepage = 'homepage_serveradmin';
+ else
+ $homepage = 'homepage_domainadmin_forreseller'; # domain pages for reseller and admin are same
+ } else
+ $homepage = 'homepage_domainadmin'; # this line should never be executed..
+
+
+ # buraya bide email girisi icin homepage yapilacak, emailde bitek sifre degistirme, ve belkide yonlendirme olacak...
+
+ $pageinfo = "Homepage Template used to generate this page: " . $homepage . "_" . $this->currentlanguage . ".html ";
+
+ $this->output .= str_replace(array("{selecteddomain}"), array($this->selecteddomain), $this->loadTemplate($homepage));
+ $this->output .= " Your language: $this->currentlanguage
(EnTr
@@ -3852,206 +4513,226 @@ $pageinfo
";
- $this->output.="
Welcome ".$this->activeuser;
- $_SESSION['myserver']=false; # reset mysql server data..
-}
+ $this->output .= "
Welcome " . $this->activeuser;
+ $_SESSION['myserver'] = false; # reset mysql server data..
+ }
-function changeMyPass(){
- global $oldpass,$newpass,$newpass2,$_insert;
- $this->getVariable(array('oldpass','newpass','newpass2','_insert'));
+ function changeMyPass()
+ {
+ global $oldpass, $newpass, $newpass2, $_insert;
+ $this->getVariable(array('oldpass', 'newpass', 'newpass2', '_insert'));
- if(!$_insert){
- $inputparams=array(
- array('oldpass','password','lefttext'=>'Your Old Password:'),
- array('newpass','password','lefttext'=>'New Password:'),
- array('newpass2','password','lefttext'=>'New Password Again:'),
- array('op','hidden','default'=>__FUNCTION__)
- );
- $this->output.=inputform5($inputparams);
+ if (!$_insert) {
+ $inputparams = array(
+ array('oldpass', 'password', 'lefttext' => 'Your Old Password:'),
+ array('newpass', 'password', 'lefttext' => 'New Password:'),
+ array('newpass2', 'password', 'lefttext' => 'New Password Again:'),
+ array('op', 'hidden', 'default' => __FUNCTION__)
+ );
+ $this->output .= inputform5($inputparams);
- } else {
- if($newpass<>$newpass2){
- $this->errorText("Both entered passwords do not match. Please try again.");
- } elseif(!$this->isPasswordOk($this->activeuser,$oldpass)) {
- $this->errorText("Your current password is not correct.");
- } elseif($newpass=='' || $newpass2=='') {
- $this->output.="You did not enter a new unique password!";
} else {
-
- if($this->conf['logintable']['passwordfunction']==''){
- $set="'$newpass'";
+ if ($newpass <> $newpass2) {
+ $this->errorText("Both entered passwords do not match. Please try again.");
+ } elseif (!$this->isPasswordOk($this->activeuser, $oldpass)) {
+ $this->errorText("Your current password is not correct.");
+ } elseif ($newpass == '' || $newpass2 == '') {
+ $this->output .= "You did not enter a new unique password!";
} else {
- $set=$this->conf['logintable']['passwordfunction']."('$newpass')";
+
+ if ($this->conf['logintable']['passwordfunction'] == '') {
+ $set = "'$newpass'";
+ } else {
+ $set = $this->conf['logintable']['passwordfunction'] . "('$newpass')";
+ }
+ $where = $this->conf['logintable']['usernamefield'] . "='" . $this->activeuser . "'";
+ $q = "update " . $this->conf['logintable']['tablename'] . " set " . $this->conf['logintable']['passwordfield'] . "=$set where $where";
+ $this->executeQuery($q);
+ $this->okeyText('Changed your pass ');
}
- $where=$this->conf['logintable']['usernamefield']."='".$this->activeuser."'";
- $q="update ".$this->conf['logintable']['tablename']." set ".$this->conf['logintable']['passwordfield']."=$set where $where";
- $this->executeQuery($q);
- $this->okeyText('Changed your pass ');
}
}
-}
- function stopvsftpd(){
+ function stopvsftpd()
+ {
$this->requireCommandLine(__FUNCTION__);
- return passthru2(getServiceActionStr("vsftpd","stop"));
+ return passthru2(getServiceActionStr("vsftpd", "stop"));
}
- function startvsftpd(){
+ function startvsftpd()
+ {
$this->requireCommandLine(__FUNCTION__);
- return passthru2(getServiceActionStr("vsftpd","start"));
+ return passthru2(getServiceActionStr("vsftpd", "start"));
}
- function restartvsftpd(){
+ function restartvsftpd()
+ {
$this->requireCommandLine(__FUNCTION__);
- return passthru2(getServiceActionStr("vsftpd","restart"));
+ return passthru2(getServiceActionStr("vsftpd", "restart"));
}
- function stopmysqld(){
+ function stopmysqld()
+ {
$this->requireCommandLine(__FUNCTION__);
- return passthru2(getServiceActionStr("mysql","stop"));
+ return passthru2(getServiceActionStr("mysql", "stop"));
}
- function startmysqld(){
+ function startmysqld()
+ {
$this->requireCommandLine(__FUNCTION__);
- return passthru2(getServiceActionStr("mysql","start"));
+ return passthru2(getServiceActionStr("mysql", "start"));
}
- function restartmysqld(){
+ function restartmysqld()
+ {
$this->requireCommandLine(__FUNCTION__);
- return passthru2(getServiceActionStr("mysql","restart"));
+ return passthru2(getServiceActionStr("mysql", "restart"));
}
- function stopbind9(){
+ function stopbind9()
+ {
$this->requireCommandLine(__FUNCTION__);
- return passthru2(getServiceActionStr("bind9","stop"));
+ return passthru2(getServiceActionStr("bind9", "stop"));
}
- function startbind9(){
+ function startbind9()
+ {
$this->requireCommandLine(__FUNCTION__);
- return passthru2(getServiceActionStr("bind9","start"));
+ return passthru2(getServiceActionStr("bind9", "start"));
}
- function restartbind9(){
+ function restartbind9()
+ {
$this->requireCommandLine(__FUNCTION__);
- return passthru2(getServiceActionStr("bind9","restart"));
+ return passthru2(getServiceActionStr("bind9", "restart"));
}
- function stopapache2(){
+ function stopapache2()
+ {
$this->requireCommandLine(__FUNCTION__);
- return passthru2(getServiceActionStr("apache2","stop"));
+ return passthru2(getServiceActionStr("apache2", "stop"));
}
- function startapache2(){
+ function startapache2()
+ {
$this->requireCommandLine(__FUNCTION__);
- return passthru2(getServiceActionStr("apache2","start"));
+ return passthru2(getServiceActionStr("apache2", "start"));
}
- function restartapache2(){
+ function restartapache2()
+ {
$this->requireCommandLine(__FUNCTION__);
- return passthru2(getServiceActionStr("apache2","restart"));
+ return passthru2(getServiceActionStr("apache2", "restart"));
}
- function service($name,$op){
+ function service($name, $op)
+ {
$this->requireCommandLine(__FUNCTION__);
return passthru2("service $name $op");
}
-function editdomain(){
- # sadece reseller/admin edit edebilmeli..
+ function editdomain()
+ {
+ # sadece reseller/admin edit edebilmeli..
- global $domainname,$_insert,$status;
- $this->getVariable(array('domainname','_insert','status'));
+ global $domainname, $_insert, $status;
+ $this->getVariable(array('domainname', '_insert', 'status'));
- $domainname=$this->chooseDomain(__FUNCTION__,$domainname);
- $domaininfo=$this->getDomainInfo($domainname);
- $success=True;
+ $domainname = $this->chooseDomain(__FUNCTION__, $domainname);
+ $domaininfo = $this->getDomainInfo($domainname);
+ $success = True;
- if(!$_insert){
- $inputparams=array(
- array('status','select','secenekler'=>$this->statusActivePassive,'default'=>$domaininfo['status'], 'lefttext'=>'Status'),
- array('domainname','hidden','default'=>$domainname),
- array('op','hidden','default'=>__FUNCTION__)
- );
+ if (!$_insert) {
+ $inputparams = array(
+ array('status', 'select', 'secenekler' => $this->statusActivePassive, 'default' => $domaininfo['status'], 'lefttext' => 'Status'),
+ array('domainname', 'hidden', 'default' => $domainname),
+ array('op', 'hidden', 'default' => __FUNCTION__)
+ );
- $this->output.= inputform5($inputparams);
+ $this->output .= inputform5($inputparams);
- } else {# editpaneluser icinde active/passive yapilmasi lazim. kullanici aktiflestirmede, eger tek domaini varsa, paneluser'ini da aktiflestirmek lazim.
- $filt=$this->applyGlobalFilter("domainname='$domainname'");
- $domaininfo=$this->getDomainInfo($domainname);
- $domainpaneluser=$domaininfo['panelusername'];
- $domainsayisi=$this->recordcount("domains","panelusername='$domainpaneluser'"); # bu paneluser'in kac tane domaini var ? howmany domains this paneluser has?
+ } else { # editpaneluser icinde active/passive yapilmasi lazim. kullanici aktiflestirmede, eger tek domaini varsa, paneluser'ini da aktiflestirmek lazim.
+ $filt = $this->applyGlobalFilter("domainname='$domainname'");
+ $domaininfo = $this->getDomainInfo($domainname);
+ $domainpaneluser = $domaininfo['panelusername'];
+ $domainsayisi = $this->recordcount("domains", "panelusername='$domainpaneluser'"); # bu paneluser'in kac tane domaini var ? howmany domains this paneluser has?
- $this->debugtext("filter: $filt");
- $success=$this->executeQuery("update ".$this->conf['domainstable']['tablename']." set status='$status',reseller='".$this->activeuser."' where $filt");
- if($domainsayisi==1) $success=$this->executeQuery("update panelusers set status='$status' where panelusername='$domainpaneluser' and reseller='".$this->activeuser."'");
+ $this->debugtext("filter: $filt");
+ $success = $this->executeQuery("update " . $this->conf['domainstable']['tablename'] . " set status='$status',reseller='" . $this->activeuser . "' where $filt");
+ if ($domainsayisi == 1)
+ $success = $this->executeQuery("update panelusers set status='$status' where panelusername='$domainpaneluser' and reseller='" . $this->activeuser . "'");
- $success=$success && $this->addDaemonOp("syncdomains",'xx',$domainname,'','sync domains');
- return $this->ok_err_text($success,'Domain status was successfully updated.','Unable to update domain status.');
+ $success = $success && $this->addDaemonOp("syncdomains", 'xx', $domainname, '', 'sync domains');
+ return $this->ok_err_text($success, 'Domain status was successfully updated.', 'Unable to update domain status.');
+
+ }
}
-}
+ function applyfordomainaccount()
+ { # add domain, paneluser and ftp user once
+ if ($this->miscconfig['userscansignup'] == '')
+ $this->showUnauthorized();
-function applyfordomainaccount(){ # add domain, paneluser and ftp user once
- if($this->miscconfig['userscansignup']=='')
- $this->showUnauthorized();
+ global $domainname, $ftpusername, $ftppassword, $quota, $upload, $download, $panelusername, $paneluserpass, $_insert;
+ $this->getVariable(array("domainname", "ftpusername", "ftppassword", "quota", "upload", "download", "panelusername", "paneluserpass", "_insert"));
- global $domainname,$ftpusername,$ftppassword,$quota,$upload,$download,$panelusername,$paneluserpass,$_insert;
- $this->getVariable(array("domainname","ftpusername","ftppassword","quota","upload","download","panelusername","paneluserpass","_insert"));
-
- if(!$_insert) {
- #if(!$this->beforeInputControls("adddomain",array())) return false;
- $inputparams=array(
- 'domainname',
- array('panelusername','lefttext'=>'Panel username:'),
- array('paneluserpass','password_with_generate','lefttext'=>'Panel user password:'),
- array('ftpusername','lefttext'=>'FTP username:'),
- array('ftppassword','password_with_generate','lefttext'=>'FTP Password:'),
- array('quota','lefttext'=>'Quota (MB)','default'=>100),
- array('upload','lefttext'=>'Upload Bandwidth (KB/s)','default'=>1000),
- array('download','lefttext'=>'Download Bandwidth (KB/s)','default'=>1000),
- array('id','hidden','default'=>$id),
- array('op','hidden','default'=>__FUNCTION__)
- );
- $this->output.=inputform5($inputparams);
- } else {
- # existcontrol addDomainDirect icinde
- if($this->addDomainDirect($domainname,$panelusername,$paneluserpass,$ftpusername,$ftppassword,$this->status_passive))
- $this->output.="Your application is recieved. You will be informed when your domain is activated.";
+ if (!$_insert) {
+ #if(!$this->beforeInputControls("adddomain",array())) return false;
+ $inputparams = array(
+ 'domainname',
+ array('panelusername', 'lefttext' => 'Panel username:'),
+ array('paneluserpass', 'password_with_generate', 'lefttext' => 'Panel user password:'),
+ array('ftpusername', 'lefttext' => 'FTP username:'),
+ array('ftppassword', 'password_with_generate', 'lefttext' => 'FTP Password:'),
+ array('quota', 'lefttext' => 'Quota (MB)', 'default' => 100),
+ array('upload', 'lefttext' => 'Upload Bandwidth (KB/s)', 'default' => 1000),
+ array('download', 'lefttext' => 'Download Bandwidth (KB/s)', 'default' => 1000),
+ array('id', 'hidden', 'default' => $id),
+ array('op', 'hidden', 'default' => __FUNCTION__)
+ );
+ $this->output .= inputform5($inputparams);
+ } else {
+ # existcontrol addDomainDirect icinde
+ if ($this->addDomainDirect($domainname, $panelusername, $paneluserpass, $ftpusername, $ftppassword, $this->status_passive))
+ $this->output .= "Your application is recieved. You will be informed when your domain is activated.";
$this->infotoadminemail('A new domain application has been received.', 'New Domain Application');
+ }
}
-}
-function applyforaccount(){
- if($this->miscconfig['userscansignup']=='')
- $this->showUnauthorized();
+ function applyforaccount()
+ {
+ if ($this->miscconfig['userscansignup'] == '')
+ $this->showUnauthorized();
- $this->output.="Apply for Web Hosting Account ";
-}
+ $this->output .= "Apply for Web Hosting Account ";
+ }
-function aboutcontactus(){
- $alanlar=array("email","msn","skype","adisoyadi","firma","sehir","adres","tel","fax","talepler");
- foreach($alanlar as $al) global $$al;
- $this->getVariable($alanlar);
- if(isset($email) and $talepler<>'') {
- $subject="New EHCP Message";
- $mesaj="Dear Admin,
The following message was successfully submitted via the panel: