function WriteCronFile() { global $zdbh; $line = ""; $sql = "SELECT * FROM x_cronjobs WHERE ct_deleted_ts IS NULL"; $numrows = $zdbh->query($sql); if ($numrows->fetchColumn() != 0) { $sql = $zdbh->prepare($sql); $sql->execute(); $line .= "#################################################################################" . fs_filehandler::NewLine(); $line .= "# CRONTAB FOR ZPANEL CRON MANAGER MODULE " . fs_filehandler::NewLine(); $line .= "# Module Developed by Bobby Allen, 17/12/2009 " . fs_filehandler::NewLine(); $line .= "# Automatically generated by ZPanel " . sys_versions::ShowZpanelVersion() . " " . fs_filehandler::NewLine(); $line .= "#################################################################################" . fs_filehandler::NewLine(); $line .= "# WE DO NOT RECOMMEND YOU MODIFY THIS FILE DIRECTLY, PLEASE USE ZPANEL INSTEAD! " . fs_filehandler::NewLine(); $line .= "#################################################################################" . fs_filehandler::NewLine(); if (sys_versions::ShowOSPlatformVersion() == "Windows") { $line .= "# Cron Debug infomation can be found in this file here:- " . fs_filehandler::NewLine(); $line .= "# C:\\WINDOWS\\System32\\crontab.txt " . fs_filehandler::NewLine(); $line .= "#################################################################################" . fs_filehandler::NewLine(); $line .= "" . ctrl_options::GetSystemOption('daemon_timing') . " " . ctrl_options::GetSystemOption('php_exer') . " " . ctrl_options::GetSystemOption('daemon_exer') . "" . fs_filehandler::NewLine(); $line .= "#################################################################################" . fs_filehandler::NewLine(); } $line .= "# DO NOT MANUALLY REMOVE ANY OF THE CRON ENTRIES FROM THIS FILE, USE ZPANEL " . fs_filehandler::NewLine(); $line .= "# INSTEAD! THE ABOVE ENTRIES ARE USED FOR ZPANEL TASKS, DO NOT REMOVE THEM! " . fs_filehandler::NewLine(); $line .= "#################################################################################" . fs_filehandler::NewLine(); while ($rowcron = $sql->fetch()) { //$rowclient = $zdbh->query("SELECT * FROM x_accounts WHERE ac_id_pk=" . $rowcron['ct_acc_fk'] . " AND ac_deleted_ts IS NULL")->fetch(); $numrows = $zdbh->prepare("SELECT * FROM x_accounts WHERE ac_id_pk=:userid AND ac_deleted_ts IS NULL"); $numrows->bindParam(':userid', $rowcron['ct_acc_fk']); $numrows->execute(); $rowclient = $numrows->fetch(); if ($rowclient && $rowclient['ac_enabled_in'] != 0) { $line .= "# CRON ID: " . $rowcron['ct_id_pk'] . "" . fs_filehandler::NewLine(); $line .= "" . $rowcron['ct_timing_vc'] . " " . ctrl_options::GetSystemOption('php_exer') . " " . $rowcron['ct_fullpath_vc'] . "" . fs_filehandler::NewLine(); $line .= "# END CRON ID: " . $rowcron['ct_id_pk'] . "" . fs_filehandler::NewLine(); } } if (fs_filehandler::UpdateFile(ctrl_options::GetSystemOption('cron_file'), 0777, $line)) { return true; } else { return false; } } }
function WriteVhostConfigFile() { global $zdbh; //Get email for server admin of zpanel $getserveremail = $zdbh->query("SELECT ac_email_vc FROM x_accounts where ac_id_pk=1")->fetch(); if ($getserveremail['ac_email_vc'] != "") { $serveremail = $getserveremail['ac_email_vc']; } else { $serveremail = "postmaster@" . ctrl_options::GetSystemOption('zpanel_domain'); } $customPorts = array(); $portQuery = $zdbh->prepare("SELECT vh_custom_port_in, vh_deleted_ts FROM zpanel_core.x_vhosts WHERE vh_custom_port_in IS NOT NULL AND vh_deleted_ts IS NULL"); $portQuery->execute(); while ($rowport = $portQuery->fetch()) { $customPorts[] = $rowport['vh_custom_port_in']; } $customPortList = array_unique($customPorts); /* * ############################################################################################################## * # * # Default Virtual Host Container * # * ############################################################################################################## */ $line = "################################################################" . fs_filehandler::NewLine(); $line .= "# Apache VHOST configuration file" . fs_filehandler::NewLine(); $line .= "# Automatically generated by ZPanel " . sys_versions::ShowZpanelVersion() . fs_filehandler::NewLine(); $line .= "# Generated on: " . date(ctrl_options::GetSystemOption('zpanel_df'), time()) . fs_filehandler::NewLine(); $line .= "################################################################" . fs_filehandler::NewLine(); $line .= "" . fs_filehandler::NewLine(); /** * NameVirtualHost is still needed for Apache 2.2 * @todo conditionally run this for apache version > 2.2 * warning apache verion not available in php functions when running over cli */ $line .= "NameVirtualHost *:" . ctrl_options::GetSystemOption('apache_port') . "" . fs_filehandler::NewLine(); foreach ($customPortList as $port) { $line .= "NameVirtualHost *:" . $port . "" . fs_filehandler::NewLine(); } $line .= "" . fs_filehandler::NewLine(); $line .= "# Configuration for ZPanel control panel." . fs_filehandler::NewLine(); $line .= "<VirtualHost *:" . ctrl_options::GetSystemOption('sentora_port') . ">" . fs_filehandler::NewLine(); $line .= "ServerAdmin " . $serveremail . fs_filehandler::NewLine(); $line .= "DocumentRoot \"" . ctrl_options::GetSystemOption('zpanel_root') . "\"" . fs_filehandler::NewLine(); $line .= "ServerName " . ctrl_options::GetSystemOption('zpanel_domain') . "" . fs_filehandler::NewLine(); $line .= "AddType application/x-httpd-php .php" . fs_filehandler::NewLine(); $line .= "<Directory \"" . ctrl_options::GetSystemOption('zpanel_root') . "\">" . fs_filehandler::NewLine(); $line .= "Options +FollowSymLinks -Indexes" . fs_filehandler::NewLine(); $line .= " AllowOverride All" . fs_filehandler::NewLine(); $line .= " Order allow,deny" . fs_filehandler::NewLine(); $line .= " Allow from all" . fs_filehandler::NewLine(); $line .= "</Directory>" . fs_filehandler::NewLine(); $line .= "" . fs_filehandler::NewLine(); $line .= "# Custom settings are loaded below this line (if any exist)" . fs_filehandler::NewLine(); // Global custom zpanel entry $line .= ctrl_options::GetSystemOption('global_zpcustom') . fs_filehandler::NewLine(); $line .= "</VirtualHost>" . fs_filehandler::NewLine(); $line .= "" . fs_filehandler::NewLine(); $line .= "################################################################" . fs_filehandler::NewLine(); $line .= "# ZPanel generated VHOST configurations below....." . fs_filehandler::NewLine(); $line .= "################################################################" . fs_filehandler::NewLine(); $line .= "" . fs_filehandler::NewLine(); /* * ############################################################################################################## * # * # All Virtual Host Containers * # * ############################################################################################################## */ // Zpanel virtual host container configuration $sql = $zdbh->prepare("SELECT * FROM x_vhosts WHERE vh_deleted_ts IS NULL"); $sql->execute(); while ($rowvhost = $sql->fetch()) { // Grab some variables we will use for later... $vhostuser = ctrl_users::GetUserDetail($rowvhost['vh_acc_fk']); $bandwidth = ctrl_users::GetQuotaUsages('bandwidth', $vhostuser['userid']); $diskspace = ctrl_users::GetQuotaUsages('diskspace', $vhostuser['userid']); // Set the vhosts to "LIVE" $vsql = $zdbh->prepare("UPDATE x_vhosts SET vh_active_in=1 WHERE vh_id_pk=:id"); $vsql->bindParam(':id', $rowvhost['vh_id_pk']); $vsql->execute(); // Add a default email if no email found for client. if (fs_director::CheckForEmptyValue($vhostuser['email'])) { $useremail = "postmaster@" . $rowvhost['vh_name_vc']; } else { $useremail = $vhostuser['email']; } // Check if domain or subdomain to see if we add an alias with 'www' if ($rowvhost['vh_type_in'] == 2) { $serveralias = $rowvhost['vh_name_vc']; } else { $serveralias = $rowvhost['vh_name_vc'] . " www." . $rowvhost['vh_name_vc']; } if (fs_director::CheckForEmptyValue($rowvhost['vh_custom_port_in'])) { $vhostPort = ctrl_options::GetSystemOption('apache_port'); } else { $vhostPort = $rowvhost['vh_custom_port_in']; } if (fs_director::CheckForEmptyValue($rowvhost['vh_custom_ip_vc'])) { $vhostIp = "*"; } else { $vhostIp = $rowvhost['vh_custom_ip_vc']; } //Domain is enabled //Line1: Domain enabled - Client also is enabled. //Line2: Domain enabled - Client may be disabled, but 'Allow Disabled' = 'true' in apache settings. if ($rowvhost['vh_enabled_in'] == 1 && ctrl_users::CheckUserEnabled($rowvhost['vh_acc_fk']) || $rowvhost['vh_enabled_in'] == 1 && ctrl_options::GetSystemOption('apache_allow_disabled') == strtolower("true")) { /* * ################################################## * # * # Disk Quotas Check * # * ################################################## */ //Domain is beyond its diskusage if ($vhostuser['diskquota'] != 0 && $diskspace > $vhostuser['diskquota']) { $line .= "# DOMAIN: " . $rowvhost['vh_name_vc'] . fs_filehandler::NewLine(); $line .= "# THIS DOMAIN HAS BEEN DISABLED FOR QUOTA OVERAGE" . fs_filehandler::NewLine(); $line .= "<virtualhost " . $vhostIp . ":" . $vhostPort . ">" . fs_filehandler::NewLine(); $line .= "ServerName " . $rowvhost['vh_name_vc'] . fs_filehandler::NewLine(); $line .= "ServerAlias " . $rowvhost['vh_name_vc'] . " www." . $rowvhost['vh_name_vc'] . fs_filehandler::NewLine(); $line .= "ServerAdmin " . $useremail . fs_filehandler::NewLine(); $line .= "DocumentRoot \"" . ctrl_options::GetSystemOption('static_dir') . "diskexceeded\"" . fs_filehandler::NewLine(); $line .= "<Directory />" . fs_filehandler::NewLine(); $line .= " Options +FollowSymLinks -Indexes" . fs_filehandler::NewLine(); $line .= " AllowOverride All" . fs_filehandler::NewLine(); $line .= " Order Allow,Deny" . fs_filehandler::NewLine(); $line .= " Allow from all" . fs_filehandler::NewLine(); $line .= "</Directory>" . fs_filehandler::NewLine(); $line .= ctrl_options::GetSystemOption('php_handler') . fs_filehandler::NewLine(); $line .= ctrl_options::GetSystemOption('dir_index') . fs_filehandler::NewLine(); $line .= "</virtualhost>" . fs_filehandler::NewLine(); $line .= "# END DOMAIN: " . $rowvhost['vh_name_vc'] . fs_filehandler::NewLine(); $line .= "################################################################" . fs_filehandler::NewLine(); $line .= fs_filehandler::NewLine(); if ($rowvhost['vh_portforward_in'] != 0) { $line .= BuildVhostPortForward($rowvhost['vh_name_vc'], $vhostPort, $useremail); } $line .= fs_filehandler::NewLine(); /* * ################################################## * # * # Bandwidth Quotas Check * # * ################################################## */ //Domain is beyond its quota } elseif ($vhostuser['bandwidthquota'] != 0 && $bandwidth > $vhostuser['bandwidthquota']) { $line .= "# DOMAIN: " . $rowvhost['vh_name_vc'] . fs_filehandler::NewLine(); $line .= "# THIS DOMAIN HAS BEEN DISABLED FOR BANDWIDTH OVERAGE" . fs_filehandler::NewLine(); $line .= "<virtualhost " . $vhostIp . ":" . $vhostPort . ">" . fs_filehandler::NewLine(); $line .= "ServerName " . $rowvhost['vh_name_vc'] . fs_filehandler::NewLine(); $line .= "ServerAlias " . $rowvhost['vh_name_vc'] . " www." . $rowvhost['vh_name_vc'] . fs_filehandler::NewLine(); $line .= "ServerAdmin " . $useremail . fs_filehandler::NewLine(); $line .= "DocumentRoot \"" . ctrl_options::GetSystemOption('static_dir') . "bandwidthexceeded\"" . fs_filehandler::NewLine(); $line .= "<Directory />" . fs_filehandler::NewLine(); $line .= " Options +FollowSymLinks -Indexes" . fs_filehandler::NewLine(); $line .= " AllowOverride All" . fs_filehandler::NewLine(); $line .= " Order Allow,Deny" . fs_filehandler::NewLine(); $line .= " Allow from all" . fs_filehandler::NewLine(); $line .= "</Directory>" . fs_filehandler::NewLine(); $line .= ctrl_options::GetSystemOption('php_handler') . fs_filehandler::NewLine(); $line .= ctrl_options::GetSystemOption('dir_index') . fs_filehandler::NewLine(); $line .= "</virtualhost>" . fs_filehandler::NewLine(); $line .= "# END DOMAIN: " . $rowvhost['vh_name_vc'] . fs_filehandler::NewLine(); $line .= "################################################################" . fs_filehandler::NewLine(); $line .= fs_filehandler::NewLine(); if ($rowvhost['vh_portforward_in'] != 0) { $line .= BuildVhostPortForward($rowvhost['vh_name_vc'], $vhostPort, $useremail); } $line .= fs_filehandler::NewLine(); /* * ################################################## * # * # Parked Domain * # * ################################################## */ //Domain is a PARKED domain. } elseif ($rowvhost['vh_type_in'] == 3) { $line .= "# DOMAIN: " . $rowvhost['vh_name_vc'] . fs_filehandler::NewLine(); $line .= "<virtualhost " . $vhostIp . ":" . $vhostPort . ">" . fs_filehandler::NewLine(); $line .= "ServerName " . $rowvhost['vh_name_vc'] . fs_filehandler::NewLine(); $line .= "ServerAlias " . $rowvhost['vh_name_vc'] . " www." . $rowvhost['vh_name_vc'] . fs_filehandler::NewLine(); $line .= "ServerAdmin " . $useremail . fs_filehandler::NewLine(); $line .= "DocumentRoot \"" . ctrl_options::GetSystemOption('parking_path') . "\"" . fs_filehandler::NewLine(); $line .= "<Directory />" . fs_filehandler::NewLine(); $line .= " Options +FollowSymLinks -Indexes" . fs_filehandler::NewLine(); $line .= " AllowOverride All" . fs_filehandler::NewLine(); $line .= " Order Allow,Deny" . fs_filehandler::NewLine(); $line .= " Allow from all" . fs_filehandler::NewLine(); $line .= "</Directory>" . fs_filehandler::NewLine(); $line .= ctrl_options::GetSystemOption('php_handler') . fs_filehandler::NewLine(); $line .= ctrl_options::GetSystemOption('dir_index') . fs_filehandler::NewLine(); $line .= "# Custom Global Settings (if any exist)" . fs_filehandler::NewLine(); $line .= ctrl_options::GetSystemOption('global_vhcustom') . fs_filehandler::NewLine(); $line .= "# Custom VH settings (if any exist)" . fs_filehandler::NewLine(); $line .= $rowvhost['vh_custom_tx'] . fs_filehandler::NewLine(); $line .= "</virtualhost>" . fs_filehandler::NewLine(); $line .= "# END DOMAIN: " . $rowvhost['vh_name_vc'] . fs_filehandler::NewLine(); $line .= "################################################################" . fs_filehandler::NewLine(); $line .= fs_filehandler::NewLine(); if ($rowvhost['vh_portforward_in'] != 0) { $line .= BuildVhostPortForward($rowvhost['vh_name_vc'], $vhostPort, $useremail); } $line .= fs_filehandler::NewLine(); /* * ################################################## * # * # Regular or Sub domain * # * ################################################## */ //Domain is a regular domain or a subdomain. } else { $line .= "# DOMAIN: " . $rowvhost['vh_name_vc'] . fs_filehandler::NewLine(); $line .= "<virtualhost " . $vhostIp . ":" . $vhostPort . ">" . fs_filehandler::NewLine(); /* * todo */ // Bandwidth Settings //$line .= "Include C:/ZPanel/bin/apache/conf/mod_bw/mod_bw/mod_bw_Administration.conf" . fs_filehandler::NewLine(); // Server name, alias, email settings $line .= "ServerName " . $rowvhost['vh_name_vc'] . fs_filehandler::NewLine(); $line .= "ServerAlias " . $serveralias . fs_filehandler::NewLine(); $line .= "ServerAdmin " . $useremail . fs_filehandler::NewLine(); // Document root $line .= "DocumentRoot \"" . ctrl_options::GetSystemOption('hosted_dir') . $vhostuser['username'] . "/public_html" . $rowvhost['vh_directory_vc'] . "\"" . fs_filehandler::NewLine(); // Get Package openbasedir and suhosin enabled options if (ctrl_options::GetSystemOption('use_openbase') == "true") { if ($rowvhost['vh_obasedir_in'] != 0) { $line .= "php_admin_value open_basedir \"" . ctrl_options::GetSystemOption('hosted_dir') . $vhostuser['username'] . "/public_html" . $rowvhost['vh_directory_vc'] . ctrl_options::GetSystemOption('openbase_seperator') . ctrl_options::GetSystemOption('openbase_temp') . "\"" . fs_filehandler::NewLine(); } } if (ctrl_options::GetSystemOption('use_suhosin') == "true") { if ($rowvhost['vh_suhosin_in'] != 0) { $line .= ctrl_options::GetSystemOption('suhosin_value') . fs_filehandler::NewLine(); } } // Logs if (!is_dir(ctrl_options::GetSystemOption('log_dir') . "domains/" . $vhostuser['username'] . "/")) { fs_director::CreateDirectory(ctrl_options::GetSystemOption('log_dir') . "domains/" . $vhostuser['username'] . "/"); } $line .= "ErrorLog \"" . ctrl_options::GetSystemOption('log_dir') . "domains/" . $vhostuser['username'] . "/" . $rowvhost['vh_name_vc'] . "-error.log\" " . fs_filehandler::NewLine(); $line .= "CustomLog \"" . ctrl_options::GetSystemOption('log_dir') . "domains/" . $vhostuser['username'] . "/" . $rowvhost['vh_name_vc'] . "-access.log\" " . ctrl_options::GetSystemOption('access_log_format') . fs_filehandler::NewLine(); $line .= "CustomLog \"" . ctrl_options::GetSystemOption('log_dir') . "domains/" . $vhostuser['username'] . "/" . $rowvhost['vh_name_vc'] . "-bandwidth.log\" " . ctrl_options::GetSystemOption('bandwidth_log_format') . fs_filehandler::NewLine(); // Directory options $line .= "<Directory />" . fs_filehandler::NewLine(); $line .= " Options +FollowSymLinks -Indexes" . fs_filehandler::NewLine(); $line .= " AllowOverride All" . fs_filehandler::NewLine(); $line .= " Order Allow,Deny" . fs_filehandler::NewLine(); $line .= " Allow from all" . fs_filehandler::NewLine(); $line .= "</Directory>" . fs_filehandler::NewLine(); // Get Package php and cgi enabled options $rows = $zdbh->prepare("SELECT * FROM x_packages WHERE pk_id_pk=:packageid AND pk_deleted_ts IS NULL"); $rows->bindParam(':packageid', $vhostuser['packageid']); $rows->execute(); $packageinfo = $rows->fetch(); if ($packageinfo['pk_enablephp_in'] != 0) { $line .= ctrl_options::GetSystemOption('php_handler') . fs_filehandler::NewLine(); } if ($packageinfo['pk_enablecgi_in'] != 0) { $line .= ctrl_options::GetSystemOption('cgi_handler') . fs_filehandler::NewLine(); if (!is_dir(ctrl_options::GetSystemOption('hosted_dir') . $vhostuser['username'] . "/public_html" . $rowvhost['vh_directory_vc'] . "/_cgi-bin")) { fs_director::CreateDirectory(ctrl_options::GetSystemOption('hosted_dir') . $vhostuser['username'] . "/public_html" . $rowvhost['vh_directory_vc'] . "/_cgi-bin"); } } // Error documents:- Error pages are added automatically if they are found in the _errorpages directory // and if they are a valid error code, and saved in the proper format, i.e. <error_number>.html $errorpages = ctrl_options::GetSystemOption('hosted_dir') . $vhostuser['username'] . "/public_html" . $rowvhost['vh_directory_vc'] . "/_errorpages"; if (is_dir($errorpages)) { if ($handle = opendir($errorpages)) { while (($file = readdir($handle)) !== false) { if ($file != "." && $file != "..") { $page = explode(".", $file); if (!fs_director::CheckForEmptyValue(CheckErrorDocument($page[0]))) { $line .= "ErrorDocument " . $page[0] . " /_errorpages/" . $page[0] . ".html" . fs_filehandler::NewLine(); } } } closedir($handle); } } // Directory indexes $line .= ctrl_options::GetSystemOption('dir_index') . fs_filehandler::NewLine(); // Global custom global vh entry $line .= "# Custom Global Settings (if any exist)" . fs_filehandler::NewLine(); $line .= ctrl_options::GetSystemOption('global_vhcustom') . fs_filehandler::NewLine(); // Client custom vh entry $line .= "# Custom VH settings (if any exist)" . fs_filehandler::NewLine(); $line .= $rowvhost['vh_custom_tx'] . fs_filehandler::NewLine(); // End Virtual Host Settings $line .= "</virtualhost>" . fs_filehandler::NewLine(); $line .= "# END DOMAIN: " . $rowvhost['vh_name_vc'] . fs_filehandler::NewLine(); $line .= "################################################################" . fs_filehandler::NewLine(); $line .= fs_filehandler::NewLine(); if ($rowvhost['vh_portforward_in'] != 0) { $line .= BuildVhostPortForward($rowvhost['vh_name_vc'], $vhostPort, $useremail); } $line .= fs_filehandler::NewLine(); } /* * ################################################## * # * # Disabled domain * # * ################################################## */ } else { //Domain is NOT enabled $line .= "# DOMAIN: " . $rowvhost['vh_name_vc'] . fs_filehandler::NewLine(); $line .= "# THIS DOMAIN HAS BEEN DISABLED" . fs_filehandler::NewLine(); $line .= "<virtualhost " . $vhostIp . ":" . $vhostPort . ">" . fs_filehandler::NewLine(); $line .= "ServerName " . $rowvhost['vh_name_vc'] . fs_filehandler::NewLine(); $line .= "ServerAlias " . $rowvhost['vh_name_vc'] . " www." . $rowvhost['vh_name_vc'] . fs_filehandler::NewLine(); $line .= "ServerAdmin " . $useremail . fs_filehandler::NewLine(); $line .= "DocumentRoot \"" . ctrl_options::GetSystemOption('static_dir') . "disabled\"" . fs_filehandler::NewLine(); $line .= "<Directory />" . fs_filehandler::NewLine(); $line .= " Options +FollowSymLinks -Indexes" . fs_filehandler::NewLine(); $line .= " AllowOverride All" . fs_filehandler::NewLine(); $line .= " Order Allow,Deny" . fs_filehandler::NewLine(); $line .= " Allow from all" . fs_filehandler::NewLine(); $line .= "</Directory>" . fs_filehandler::NewLine(); $line .= ctrl_options::GetSystemOption('dir_index') . fs_filehandler::NewLine(); $line .= "</virtualhost>" . fs_filehandler::NewLine(); $line .= "# END DOMAIN: " . $rowvhost['vh_name_vc'] . fs_filehandler::NewLine(); $line .= "################################################################" . fs_filehandler::NewLine(); } } /* * ############################################################################################################## * # * # Write vhost file to disk * # * ############################################################################################################## */ // write the vhost config file $vhconfigfile = ctrl_options::GetSystemOption('apache_vhost'); if (fs_filehandler::UpdateFile($vhconfigfile, 0777, $line)) { // Reset Apache settings to reflect that config file has been written, until the next change. $time = time(); $vsql = $zdbh->prepare("UPDATE x_settings\n SET so_value_tx=:time\n WHERE so_name_vc='apache_changed'"); $vsql->bindParam(':time', $time); $vsql->execute(); echo "Finished writting Apache Config... Now reloading Apache..." . fs_filehandler::NewLine(); $returnValue = 0; if (sys_versions::ShowOSPlatformVersion() == "Windows") { system("" . ctrl_options::GetSystemOption('httpd_exe') . " " . ctrl_options::GetSystemOption('apache_restart') . "", $returnValue); } else { $command = ctrl_options::GetSystemOption('zsudo'); $args = array("service", ctrl_options::GetSystemOption('apache_sn'), ctrl_options::GetSystemOption('apache_restart')); $returnValue = ctrl_system::systemCommand($command, $args); } echo "Apache reload " . (0 === $returnValue ? "suceeded" : "failed") . "." . fs_filehandler::NewLine(); } else { return false; } }
static function WriteCronFile() { global $zdbh; $currentuser = ctrl_users::GetUserDetail(); $line = ""; $sql = "SELECT * FROM x_cronjobs WHERE ct_deleted_ts IS NULL"; $numrows = $zdbh->query($sql); if ($numrows->fetchColumn() != 0) { $sql = $zdbh->prepare($sql); $sql->execute(); $line .= "#################################################################################" . fs_filehandler::NewLine(); $line .= "# CRONTAB FOR ZPANEL CRON MANAGER MODULE " . fs_filehandler::NewLine(); $line .= "# Module Developed by Bobby Allen, 17/12/2009 " . fs_filehandler::NewLine(); $line .= "# Automatically generated by ZPanel " . sys_versions::ShowZpanelVersion() . " " . fs_filehandler::NewLine(); $line .= "#################################################################################" . fs_filehandler::NewLine(); $line .= "# WE DO NOT RECOMMEND YOU MODIFY THIS FILE DIRECTLY, PLEASE USE ZPANEL INSTEAD! " . fs_filehandler::NewLine(); $line .= "#################################################################################" . fs_filehandler::NewLine(); if (sys_versions::ShowOSPlatformVersion() == "Windows") { $line .= "# Cron Debug infomation can be found in this file here:- " . fs_filehandler::NewLine(); $line .= "# C:\\WINDOWS\\System32\\crontab.txt " . fs_filehandler::NewLine(); $line .= "#################################################################################" . fs_filehandler::NewLine(); $line .= "" . ctrl_options::GetSystemOption('daemon_timing') . " " . ctrl_options::GetSystemOption('php_exer') . " -d suhosin.executor.func.blacklist=\"passthru, show_source, shell_exec, system, pcntl_exec, popen, pclose, proc_open, proc_nice, proc_terminate, proc_get_status, proc_close, leak, apache_child_terminate, posix_kill, posix_mkfifo, posix_setpgid, posix_setsid, posix_setuid, escapeshellcmd, escapeshellarg, exec\" -d open_basedir=\"" . ctrl_options::GetSystemOption('hosted_dir') . $currentuser['username'] . "/" . ctrl_options::GetSystemOption('openbase_seperator') . ctrl_options::GetSystemOption('openbase_temp') . "\" " . ctrl_options::GetSystemOption('daemon_exer') . "" . fs_filehandler::NewLine(); $line .= "#################################################################################" . fs_filehandler::NewLine(); } $line .= "# DO NOT MANUALLY REMOVE ANY OF THE CRON ENTRIES FROM THIS FILE, USE ZPANEL " . fs_filehandler::NewLine(); $line .= "# INSTEAD! THE ABOVE ENTRIES ARE USED FOR ZPANEL TASKS, DO NOT REMOVE THEM! " . fs_filehandler::NewLine(); $line .= "#################################################################################" . fs_filehandler::NewLine(); while ($rowcron = $sql->fetch()) { $fetchRows = $zdbh->prepare("SELECT * FROM x_accounts WHERE ac_id_pk=:userid AND ac_deleted_ts IS NULL"); $fetchRows->bindParam(':userid', $rowcron['ct_acc_fk']); $fetchRows->execute(); $rowclient = $fetchRows->fetch(); if ($rowclient && $rowclient['ac_enabled_in'] != 0) { $line .= "# CRON ID: " . $rowcron['ct_id_pk'] . "" . fs_filehandler::NewLine(); $line .= "" . $rowcron['ct_timing_vc'] . " " . ctrl_options::GetSystemOption('php_exer') . " -d suhosin.executor.func.blacklist=\"passthru, show_source, shell_exec, system, pcntl_exec, popen, pclose, proc_open, proc_nice, proc_terminate, proc_get_status, proc_close, leak, apache_child_terminate, posix_kill, posix_mkfifo, posix_setpgid, posix_setsid, posix_setuid, escapeshellcmd, escapeshellarg, exec\" -d open_basedir=\"" . ctrl_options::GetSystemOption('hosted_dir') . $currentuser['username'] . "/" . ctrl_options::GetSystemOption('openbase_seperator') . ctrl_options::GetSystemOption('openbase_temp') . "\" " . $rowcron['ct_fullpath_vc'] . "" . fs_filehandler::NewLine(); $line .= "# END CRON ID: " . $rowcron['ct_id_pk'] . "" . fs_filehandler::NewLine(); } } if (fs_filehandler::UpdateFile(ctrl_options::GetSystemOption('cron_file'), 0644, $line)) { if (sys_versions::ShowOSPlatformVersion() != "Windows") { $returnValue = ctrl_system::systemCommand(ctrl_options::GetSystemOption('zsudo'), array(ctrl_options::GetSystemOption('cron_reload_command'), ctrl_options::GetSystemOption('cron_reload_flag'), ctrl_options::GetSystemOption('cron_reload_user'), ctrl_options::GetSystemOption('cron_reload_path'))); //var_dump( $returnValue ); } return true; } else { return false; } } else { $line .= "#################################################################################" . fs_filehandler::NewLine(); $line .= "# CRONTAB FOR ZPANEL CRON MANAGER MODULE " . fs_filehandler::NewLine(); $line .= "# Module Developed by Bobby Allen, 17/12/2009 " . fs_filehandler::NewLine(); $line .= "# Automatically generated by ZPanel " . sys_versions::ShowZpanelVersion() . " " . fs_filehandler::NewLine(); $line .= "#################################################################################" . fs_filehandler::NewLine(); $line .= "# WE DO NOT RECOMMEND YOU MODIFY THIS FILE DIRECTLY, PLEASE USE ZPANEL INSTEAD! " . fs_filehandler::NewLine(); $line .= "#################################################################################" . fs_filehandler::NewLine(); if (sys_versions::ShowOSPlatformVersion() == "Windows") { $line .= "# Cron Debug infomation can be found in this file here:- " . fs_filehandler::NewLine(); $line .= "# C:\\WINDOWS\\System32\\crontab.txt " . fs_filehandler::NewLine(); $line .= "#################################################################################" . fs_filehandler::NewLine(); $line .= "" . ctrl_options::GetSystemOption('daemon_timing') . " " . ctrl_options::GetSystemOption('php_exer') . " " . ctrl_options::GetSystemOption('daemon_exer') . "" . fs_filehandler::NewLine(); $line .= "#################################################################################" . fs_filehandler::NewLine(); } $line .= "# DO NOT MANUALLY REMOVE ANY OF THE CRON ENTRIES FROM THIS FILE, USE ZPANEL " . fs_filehandler::NewLine(); $line .= "# INSTEAD! THE ABOVE ENTRIES ARE USED FOR ZPANEL TASKS, DO NOT REMOVE THEM! " . fs_filehandler::NewLine(); $line .= "#################################################################################" . fs_filehandler::NewLine(); if (fs_filehandler::UpdateFile(ctrl_options::GetSystemOption('cron_file'), 0644, $line)) { if (sys_versions::ShowOSPlatformVersion() != "Windows") { $returnValue = ctrl_system::systemCommand(ctrl_options::GetSystemOption('zsudo'), array(ctrl_options::GetSystemOption('cron_reload_command'), ctrl_options::GetSystemOption('cron_reload_flag'), ctrl_options::GetSystemOption('cron_reload_user'), ctrl_options::GetSystemOption('cron_reload_path'))); //var_dump( $returnValue ); } return true; } else { return false; } } }
$versionsql->bindParam(':latest_version', $latest_version); $versionsql->bindParam(':downloadurl', $downloadurl); $versionsql->execute(); } else { $versionsql = $zdbh->prepare("UPDATE x_modules SET mo_updatever_vc = '', mo_updateurl_tx = '' WHERE mo_id_pk = :mo_id_pk"); $versionsql->bindParam(':mo_id_pk', $modules['mo_id_pk']); $versionsql->execute(); } } else { echo "The remote file was not parsed correctly or does not exist." . fs_filehandler::NewLine(); } } else { echo "The remote file does not exist." . fs_filehandler::NewLine(); } } else { echo "Couldn't open the module XML file for (" . $modules['mo_name_vc'] . ")" . fs_filehandler::NewLine(); } } echo "END getting module version update information!" . fs_filehandler::NewLine(); /* * Please DO NOT remove the below code, this helps us at the ZPanel project * find out non-personal infomation about how people are running ZPanel. The only infomation * that we are passing back here is just your ZPanel version and what OS you are running it on. * * We also collec the email address of the default 'zadmin' account to enable automatic email * notficiations of new releases. */ $zdbh->bindQuery('SELECT ac_email_vc AS email FROM x_accounts WHERE ac_user_vc = :user', array(':user' => 'zadmin')); $zadmin = $zdbh->returnRow(); ws_generic::DoPostRequest('http://api.sentora.io/hello.json', "version=" . sys_versions::ShowZpanelVersion() . "&platform=" . sys_versions::ShowOSPlatformVersion() . "&url=" . ctrl_options::GetSystemOption('zpanel_domain') . "mail=" . $zadmin['email']); return true;
public static function Template() { return sys_versions::ShowZpanelVersion(); }