/**
 * store the default index-file in a given destination folder
 * 
 * @param string  $loginname   customers loginname
 * @param string  $destination path where to create the file
 * @param object  $logger      FroxlorLogger object
 * @param boolean $force       force creation whatever the settings say (needed for task #2, create new user)
 * 
 * @return null
 */
function storeDefaultIndex($loginname = null, $destination = null, $logger = null, $force = false)
{
    if ($force || (int) Settings::Get('system.store_index_file_subs') == 1) {
        $result_stmt = Database::prepare("\n\t\t\tSELECT `t`.`value`, `c`.`email` AS `customer_email`, `a`.`email` AS `admin_email`, `c`.`loginname` AS `customer_login`, `a`.`loginname` AS `admin_login`\n\t\t\tFROM `" . TABLE_PANEL_CUSTOMERS . "` AS `c` INNER JOIN `" . TABLE_PANEL_ADMINS . "` AS `a`\n\t\t\tON `c`.`adminid` = `a`.`adminid`\n\t\t\tINNER JOIN `" . TABLE_PANEL_TEMPLATES . "` AS `t`\n\t\t\tON `a`.`adminid` = `t`.`adminid`\n\t\t\tWHERE `varname` = 'index_html' AND `c`.`loginname` = :loginname");
        Database::pexecute($result_stmt, array('loginname' => $loginname));
        if (Database::num_rows() > 0) {
            $template = $result_stmt->fetch(PDO::FETCH_ASSOC);
            $replace_arr = array('SERVERNAME' => Settings::Get('system.hostname'), 'CUSTOMER' => $template['customer_login'], 'ADMIN' => $template['admin_login'], 'CUSTOMER_EMAIL' => $template['customer_email'], 'ADMIN_EMAIL' => $template['admin_email']);
            $htmlcontent = replace_variables($template['value'], $replace_arr);
            $indexhtmlpath = makeCorrectFile($destination . '/index.' . Settings::Get('system.index_file_extension'));
            $index_html_handler = fopen($indexhtmlpath, 'w');
            fwrite($index_html_handler, $htmlcontent);
            fclose($index_html_handler);
            if ($logger !== null) {
                $logger->logAction(CRON_ACTION, LOG_NOTICE, 'Creating \'index.' . Settings::Get('system.index_file_extension') . '\' for Customer \'' . $template['customer_login'] . '\' based on template in directory ' . escapeshellarg($indexhtmlpath));
            }
        } else {
            $destination = makeCorrectDir($destination);
            if ($logger !== null) {
                $logger->logAction(CRON_ACTION, LOG_NOTICE, 'Running: cp -a ' . FROXLOR_INSTALL_DIR . '/templates/misc/standardcustomer/* ' . escapeshellarg($destination));
            }
            safe_exec('cp -a ' . FROXLOR_INSTALL_DIR . '/templates/misc/standardcustomer/* ' . escapeshellarg($destination));
        }
    }
    return;
}
/**
 * store the default index-file in a given destination folder
 * 
 * @param string  $loginname   customers loginname
 * @param string  $destination path where to create the file
 * @param object  $logger      FroxlorLogger object
 * @param boolean $force       force creation whatever the settings say (needed for task #2, create new user)
 * 
 * @return null
 */
function storeDefaultIndex($loginname = null, $destination = null, $logger = null, $force = false)
{
    global $db, $settings, $pathtophpfiles;
    if ($force || (int) $settings['system']['store_index_file_subs'] == 1) {
        $result = $db->query("SELECT `t`.`value`, `c`.`email` AS `customer_email`, `a`.`email` AS `admin_email`, `c`.`loginname` AS `customer_login`, `a`.`loginname` AS `admin_login` FROM `" . TABLE_PANEL_CUSTOMERS . "` AS `c` INNER JOIN `" . TABLE_PANEL_ADMINS . "` AS `a` ON `c`.`adminid` = `a`.`adminid` INNER JOIN `" . TABLE_PANEL_TEMPLATES . "` AS `t` ON `a`.`adminid` = `t`.`adminid` WHERE `varname` = 'index_html' AND `c`.`loginname` = '" . $db->escape($loginname) . "'");
        if ($db->num_rows($result) > 0) {
            $template = $db->fetch_array($result);
            $replace_arr = array('SERVERNAME' => $settings['system']['hostname'], 'CUSTOMER' => $template['customer_login'], 'ADMIN' => $template['admin_login'], 'CUSTOMER_EMAIL' => $template['customer_email'], 'ADMIN_EMAIL' => $template['admin_email']);
            $htmlcontent = replace_variables($template['value'], $replace_arr);
            $indexhtmlpath = makeCorrectFile($destination . '/index.' . $settings['system']['index_file_extension']);
            $index_html_handler = fopen($indexhtmlpath, 'w');
            fwrite($index_html_handler, $htmlcontent);
            fclose($index_html_handler);
            if ($logger !== null) {
                $logger->logAction(CRON_ACTION, LOG_NOTICE, 'Creating \'index.' . $settings['system']['index_file_extension'] . '\' for Customer \'' . $template['customer_login'] . '\' based on template in directory ' . escapeshellarg($indexhtmlpath));
            }
        } else {
            $destination = makeCorrectDir($destination);
            if ($logger !== null) {
                $logger->logAction(CRON_ACTION, LOG_NOTICE, 'Running: cp -a ' . $pathtophpfiles . '/templates/misc/standardcustomer/* ' . escapeshellarg($destination));
            }
            safe_exec('cp -a ' . $pathtophpfiles . '/templates/misc/standardcustomer/* ' . escapeshellarg($destination));
        }
    }
    return;
}
 /**
  * create fpm-pool config
  *
  * @param array $phpconfig
  */
 public function createConfig($phpconfig)
 {
     $fh = @fopen($this->getConfigFile(), 'w');
     if ($fh) {
         $fpm_pm = Settings::Get('phpfpm.pm');
         $fpm_children = (int) Settings::Get('phpfpm.max_children');
         $fpm_start_servers = (int) Settings::Get('phpfpm.start_servers');
         $fpm_min_spare_servers = (int) Settings::Get('phpfpm.min_spare_servers');
         $fpm_max_spare_servers = (int) Settings::Get('phpfpm.max_spare_servers');
         $fpm_requests = (int) Settings::Get('phpfpm.max_requests');
         $fpm_process_idle_timeout = (int) Settings::Get('phpfpm.idle_timeout');
         if ($fpm_children == 0) {
             $fpm_children = 1;
         }
         $fpm_config = ';PHP-FPM configuration for "' . $this->_domain['domain'] . '" created on ' . date("Y.m.d H:i:s") . "\n";
         $fpm_config .= '[' . $this->_domain['domain'] . ']' . "\n";
         $fpm_config .= 'listen = ' . $this->getSocketFile() . "\n";
         if ($this->_domain['loginname'] == 'froxlor.panel') {
             $fpm_config .= 'listen.owner = ' . $this->_domain['guid'] . "\n";
             $fpm_config .= 'listen.group = ' . $this->_domain['guid'] . "\n";
         } else {
             $fpm_config .= 'listen.owner = ' . $this->_domain['loginname'] . "\n";
             $fpm_config .= 'listen.group = ' . $this->_domain['loginname'] . "\n";
         }
         // see #1418 why this is 0660
         $fpm_config .= 'listen.mode = 0660' . "\n";
         if ($this->_domain['loginname'] == 'froxlor.panel') {
             $fpm_config .= 'user = '******'guid'] . "\n";
             $fpm_config .= 'group = ' . $this->_domain['guid'] . "\n";
         } else {
             $fpm_config .= 'user = '******'loginname'] . "\n";
             $fpm_config .= 'group = ' . $this->_domain['loginname'] . "\n";
         }
         $fpm_config .= 'pm = ' . $fpm_pm . "\n";
         $fpm_config .= 'pm.max_children = ' . $fpm_children . "\n";
         if ($fpm_pm == 'dynamic') {
             // honor max_children
             if ($fpm_children < $fpm_min_spare_servers) {
                 $fpm_min_spare_servers = $fpm_children;
             }
             if ($fpm_children < $fpm_max_spare_servers) {
                 $fpm_max_spare_servers = $fpm_children;
             }
             // failsafe, refs #955
             if ($fpm_start_servers < $fpm_min_spare_servers) {
                 $fpm_start_servers = $fpm_min_spare_servers;
             }
             if ($fpm_start_servers > $fpm_max_spare_servers) {
                 $fpm_start_servers = $fpm_start_servers - ($fpm_start_servers - $fpm_max_spare_servers + 1);
             }
             $fpm_config .= 'pm.start_servers = ' . $fpm_start_servers . "\n";
             $fpm_config .= 'pm.min_spare_servers = ' . $fpm_min_spare_servers . "\n";
             $fpm_config .= 'pm.max_spare_servers = ' . $fpm_max_spare_servers . "\n";
         } elseif ($fpm_pm == 'ondemand') {
             $fpm_config .= 'pm.process_idle_timeout = ' . $fpm_process_idle_timeout . "\n";
         }
         $fpm_config .= 'pm.max_requests = ' . $fpm_requests . "\n";
         // possible slowlog configs
         if ($phpconfig['fpm_slowlog'] == '1') {
             $fpm_config .= 'request_terminate_timeout = ' . $phpconfig['fpm_reqterm'] . "\n";
             $fpm_config .= 'request_slowlog_timeout = ' . $phpconfig['fpm_reqslow'] . "\n";
             $slowlog = makeCorrectFile(Settings::Get('system.logfiles_directory') . '/' . $this->_domain['loginname'] . '-php-slow.log');
             $fpm_config .= 'slowlog = ' . $slowlog . "\n";
             $fpm_config .= 'catch_workers_output = yes' . "\n";
         }
         $fpm_config .= ';chroot = ' . makeCorrectDir($this->_domain['documentroot']) . "\n";
         $tmpdir = makeCorrectDir(Settings::Get('phpfpm.tmpdir') . '/' . $this->_domain['loginname'] . '/');
         if (!is_dir($tmpdir)) {
             $this->getTempDir();
         }
         $fpm_config .= 'env[TMP] = ' . $tmpdir . "\n";
         $fpm_config .= 'env[TMPDIR] = ' . $tmpdir . "\n";
         $fpm_config .= 'env[TEMP] = ' . $tmpdir . "\n";
         $openbasedir = '';
         if ($this->_domain['loginname'] != 'froxlor.panel') {
             if ($this->_domain['openbasedir'] == '1') {
                 $_phpappendopenbasedir = '';
                 $_custom_openbasedir = explode(':', Settings::Get('phpfpm.peardir'));
                 foreach ($_custom_openbasedir as $cobd) {
                     $_phpappendopenbasedir .= appendOpenBasedirPath($cobd);
                 }
                 $_custom_openbasedir = explode(':', Settings::Get('system.phpappendopenbasedir'));
                 foreach ($_custom_openbasedir as $cobd) {
                     $_phpappendopenbasedir .= appendOpenBasedirPath($cobd);
                 }
                 if ($this->_domain['openbasedir_path'] == '0' && strstr($this->_domain['documentroot'], ":") === false) {
                     $openbasedir = appendOpenBasedirPath($this->_domain['documentroot'], true);
                 } else {
                     $openbasedir = appendOpenBasedirPath($this->_domain['customerroot'], true);
                 }
                 $openbasedir .= appendOpenBasedirPath($this->getTempDir());
                 $openbasedir .= $_phpappendopenbasedir;
                 $openbasedir = explode(':', $openbasedir);
                 $clean_openbasedir = array();
                 foreach ($openbasedir as $number => $path) {
                     if (trim($path) != '/') {
                         $clean_openbasedir[] = makeCorrectDir($path);
                     }
                 }
                 $openbasedir = implode(':', $clean_openbasedir);
             }
         }
         $fpm_config .= 'php_admin_value[session.save_path] = ' . makeCorrectDir(Settings::Get('phpfpm.tmpdir') . '/' . $this->_domain['loginname'] . '/') . "\n";
         $fpm_config .= 'php_admin_value[upload_tmp_dir] = ' . makeCorrectDir(Settings::Get('phpfpm.tmpdir') . '/' . $this->_domain['loginname'] . '/') . "\n";
         $admin = $this->_getAdminData($this->_domain['adminid']);
         $php_ini_variables = array('SAFE_MODE' => 'Off', 'PEAR_DIR' => Settings::Get('system.mod_fcgid_peardir'), 'TMP_DIR' => $this->getTempDir(), 'CUSTOMER_EMAIL' => $this->_domain['email'], 'ADMIN_EMAIL' => $admin['email'], 'DOMAIN' => $this->_domain['domain'], 'CUSTOMER' => $this->_domain['loginname'], 'ADMIN' => $admin['loginname'], 'OPEN_BASEDIR' => $openbasedir, 'OPEN_BASEDIR_C' => '');
         $phpini = replace_variables($phpconfig['phpsettings'], $php_ini_variables);
         $phpini_array = explode("\n", $phpini);
         $fpm_config .= "\n\n";
         foreach ($phpini_array as $inisection) {
             $is = explode("=", $inisection);
             foreach ($this->_ini as $sec => $possibles) {
                 if (in_array(trim($is[0]), $possibles)) {
                     // check explictly for open_basedir
                     if (trim($is[0]) == 'open_basedir' && $openbasedir == '') {
                         continue;
                     }
                     $fpm_config .= $sec . '[' . trim($is[0]) . '] = ' . trim($is[1]) . "\n";
                 }
             }
         }
         // now check if 'sendmail_path' has not beed set in the custom-php.ini
         // if not we use our fallback-default as usual
         if (strpos($fpm_config, 'php_admin_value[sendmail_path]') === false) {
             $fpm_config .= 'php_admin_value[sendmail_path] = /usr/sbin/sendmail -t -i -f ' . $this->_domain['email'] . "\n";
         }
         fwrite($fh, $fpm_config, strlen($fpm_config));
         fclose($fh);
     }
 }
示例#4
0
     $password = substr($rnd, (int) ($minlength / 2), $minlength);
 }
 if ($adminchecked) {
     $db->query("UPDATE `" . TABLE_PANEL_ADMINS . "` SET `password`='" . md5($password) . "'\n\t\t\t\t\t\t\t\tWHERE `loginname`='" . $user['loginname'] . "'\n\t\t\t\t\t\t\t\tAND `email`='" . $user['email'] . "'");
 } else {
     $db->query("UPDATE `" . TABLE_PANEL_CUSTOMERS . "` SET `password`='" . md5($password) . "'\n\t\t\t\t\t\t\t\tWHERE `loginname`='" . $user['loginname'] . "'\n\t\t\t\t\t\t\t\tAND `email`='" . $user['email'] . "'");
 }
 $rstlog = FroxlorLogger::getInstanceOf(array('loginname' => 'password_reset'), $db, $settings);
 $rstlog->logAction(USR_ACTION, LOG_WARNING, "Password for user '" . $user['loginname'] . "' has been reset!");
 $replace_arr = array('SALUTATION' => getCorrectUserSalutation($user), 'USERNAME' => $user['loginname'], 'PASSWORD' => $password);
 $body = strtr($lng['pwdreminder']['body'], array('%s' => $user['firstname'] . ' ' . $user['name'], '%p' => $password));
 $def_language = $user['def_language'] != '' ? $user['def_language'] : $settings['panel']['standardlanguage'];
 $result = $db->query_first('SELECT `value` FROM `' . TABLE_PANEL_TEMPLATES . '` WHERE `adminid`=\'' . (int) $user['adminid'] . '\' AND `language`=\'' . $db->escape($def_language) . '\' AND `templategroup`=\'mails\' AND `varname`=\'password_reset_subject\'');
 $mail_subject = html_entity_decode(replace_variables($result['value'] != '' ? $result['value'] : $lng['pwdreminder']['subject'], $replace_arr));
 $result = $db->query_first('SELECT `value` FROM `' . TABLE_PANEL_TEMPLATES . '` WHERE `adminid`=\'' . (int) $user['adminid'] . '\' AND `language`=\'' . $db->escape($def_language) . '\' AND `templategroup`=\'mails\' AND `varname`=\'password_reset_mailbody\'');
 $mail_body = html_entity_decode(replace_variables($result['value'] != '' ? $result['value'] : $body, $replace_arr));
 $_mailerror = false;
 try {
     $mail->Subject = $mail_subject;
     $mail->AltBody = $mail_body;
     $mail->MsgHTML(str_replace("\n", "<br />", $mail_body));
     $mail->AddAddress($user['email'], $user['firstname'] . ' ' . $user['name']);
     $mail->Send();
 } catch (phpmailerException $e) {
     $mailerr_msg = $e->errorMessage();
     $_mailerror = true;
 } catch (Exception $e) {
     $mailerr_msg = $e->getMessage();
     $_mailerror = true;
 }
 if ($_mailerror) {
示例#5
0
 }
 if ($sendpassword == '1') {
     $srv_hostname = Settings::Get('system.hostname');
     if (Settings::Get('system.froxlordirectlyviahostname') == '0') {
         $srv_hostname .= '/froxlor';
     }
     $srv_ip_stmt = Database::prepare("\n\t\t\t\t\t\t\tSELECT ip, port FROM `" . TABLE_PANEL_IPSANDPORTS . "`\n\t\t\t\t\t\t\tWHERE `id` = :defaultip\n\t\t\t\t\t\t");
     $srv_ip = Database::pexecute_first($srv_ip_stmt, array('defaultip' => Settings::Get('system.defaultip')));
     $replace_arr = array('FIRSTNAME' => $firstname, 'NAME' => $name, 'COMPANY' => $company, 'SALUTATION' => getCorrectUserSalutation(array('firstname' => $firstname, 'name' => $name, 'company' => $company)), 'USERNAME' => $loginname, 'PASSWORD' => $password, 'SERVER_HOSTNAME' => $srv_hostname, 'SERVER_IP' => isset($srv_ip['ip']) ? $srv_ip['ip'] : '', 'SERVER_PORT' => isset($srv_ip['port']) ? $srv_ip['port'] : '', 'DOMAINNAME' => $_stdsubdomain);
     // Get mail templates from database; the ones from 'admin' are fetched for fallback
     $result_stmt = Database::prepare("\n\t\t\t\t\t\t\tSELECT `value` FROM `" . TABLE_PANEL_TEMPLATES . "`\n\t\t\t\t\t\t\tWHERE `adminid` = :adminid AND `language` = :deflang AND `templategroup` = 'mails' AND `varname` = 'createcustomer_subject'");
     $result = Database::pexecute_first($result_stmt, array('adminid' => $userinfo['adminid'], 'deflang' => $def_language));
     $mail_subject = html_entity_decode(replace_variables($result['value'] != '' ? $result['value'] : $lng['mails']['createcustomer']['subject'], $replace_arr));
     $result_stmt = Database::prepare("\n\t\t\t\t\t\t\tSELECT `value` FROM `" . TABLE_PANEL_TEMPLATES . "`\n\t\t\t\t\t\t\tWHERE `adminid` = :adminid AND `language` = :deflang AND `templategroup` = 'mails' AND `varname` = 'createcustomer_mailbody'");
     $result = Database::pexecute_first($result_stmt, array('adminid' => $userinfo['adminid'], 'deflang' => $def_language));
     $mail_body = html_entity_decode(replace_variables($result['value'] != '' ? $result['value'] : $lng['mails']['createcustomer']['mailbody'], $replace_arr));
     $_mailerror = false;
     try {
         $mail->Subject = $mail_subject;
         $mail->AltBody = $mail_body;
         $mail->MsgHTML(str_replace("\n", "<br />", $mail_body));
         $mail->AddAddress($email, getCorrectUserSalutation(array('firstname' => $firstname, 'name' => $name, 'company' => $company)));
         $mail->Send();
     } catch (phpmailerException $e) {
         $mailerr_msg = $e->errorMessage();
         $_mailerror = true;
     } catch (Exception $e) {
         $mailerr_msg = $e->getMessage();
         $_mailerror = true;
     }
     if ($_mailerror) {
示例#6
0
         echo "Please check you Webserver settings\n";
     }
 } elseif ($row['type'] == '2') {
     fwrite($debugHandler, '  cron_tasks: Task2 started - create new home' . "\n");
     $cronlog->logAction(CRON_ACTION, LOG_INFO, 'Task2 started - create new home');
     if (is_array($row['data'])) {
         $cronlog->logAction(CRON_ACTION, LOG_NOTICE, 'Running: mkdir -p ' . escapeshellarg($settings['system']['documentroot_prefix'] . $row['data']['loginname'] . '/webalizer'));
         safe_exec('mkdir -p ' . escapeshellarg($settings['system']['documentroot_prefix'] . $row['data']['loginname'] . '/webalizer'));
         $cronlog->logAction(CRON_ACTION, LOG_NOTICE, 'Running: mkdir -p ' . escapeshellarg($settings['system']['vmail_homedir'] . $row['data']['loginname']));
         safe_exec('mkdir -p ' . escapeshellarg($settings['system']['vmail_homedir'] . $row['data']['loginname']));
         //check if admin of customer has added template for new customer directories
         $result = $db->query("SELECT `t`.`value`, `c`.`email` AS `customer_email`, `a`.`email` AS `admin_email`, `c`.`loginname` AS `customer_login`, `a`.`loginname` AS `admin_login` FROM `" . TABLE_PANEL_CUSTOMERS . "` AS `c` INNER JOIN `" . TABLE_PANEL_ADMINS . "` AS `a` ON `c`.`adminid` = `a`.`adminid` INNER JOIN `" . TABLE_PANEL_TEMPLATES . "` AS `t` ON `a`.`adminid` = `t`.`adminid` WHERE `varname` = 'index_html' AND `c`.`loginname` = '" . $db->escape($row['data']['loginname']) . "'");
         if ($db->num_rows($result) > 0) {
             $template = $db->fetch_array($result);
             $replace_arr = array('SERVERNAME' => $settings['system']['hostname'], 'CUSTOMER' => $template['customer_login'], 'ADMIN' => $template['admin_login'], 'CUSTOMER_EMAIL' => $template['customer_email'], 'ADMIN_EMAIL' => $template['admin_email']);
             $htmlcontent = replace_variables($template['value'], $replace_arr);
             $indexhtmlpath = $settings['system']['documentroot_prefix'] . $row['data']['loginname'] . '/index.' . $settings['system']['index_file_extension'];
             $index_html_handler = fopen($indexhtmlpath, 'w');
             fwrite($index_html_handler, $htmlcontent);
             fclose($index_html_handler);
             $cronlog->logAction(CRON_ACTION, LOG_NOTICE, 'Creating \'index.' . $settings['system']['index_file_extension'] . '\' for Customer \'' . $template['customer_login'] . '\' based on template in directory ' . escapeshellarg($indexhtmlpath));
         } else {
             $cronlog->logAction(CRON_ACTION, LOG_NOTICE, 'Running: cp -a ' . $pathtophpfiles . '/templates/misc/standardcustomer/* ' . escapeshellarg($settings['system']['documentroot_prefix'] . $row['data']['loginname'] . '/'));
             safe_exec('cp -a ' . $pathtophpfiles . '/templates/misc/standardcustomer/* ' . escapeshellarg($settings['system']['documentroot_prefix'] . $row['data']['loginname'] . '/'));
         }
         $cronlog->logAction(CRON_ACTION, LOG_NOTICE, 'Running: chown -R ' . (int) $row['data']['uid'] . ':' . (int) $row['data']['gid'] . ' ' . escapeshellarg($settings['system']['documentroot_prefix'] . $row['data']['loginname']));
         safe_exec('chown -R ' . (int) $row['data']['uid'] . ':' . (int) $row['data']['gid'] . ' ' . escapeshellarg($settings['system']['documentroot_prefix'] . $row['data']['loginname']));
         $cronlog->logAction(CRON_ACTION, LOG_NOTICE, 'Running: chown -R ' . (int) $settings['system']['vmail_uid'] . ':' . (int) $settings['system']['vmail_gid'] . ' ' . escapeshellarg($settings['system']['vmail_homedir'] . $row['data']['loginname']));
         safe_exec('chown -R ' . (int) $settings['system']['vmail_uid'] . ':' . (int) $settings['system']['vmail_gid'] . ' ' . escapeshellarg($settings['system']['vmail_homedir'] . $row['data']['loginname']));
     }
 } elseif ($row['type'] == '3') {
 /**
  * create customized php.ini
  *
  * @param array $phpconfig
  */
 public function createIniFile($phpconfig)
 {
     $openbasedir = '';
     $openbasedirc = ';';
     if ($this->_domain['openbasedir'] == '1') {
         $openbasedirc = '';
         $_phpappendopenbasedir = '';
         $_custom_openbasedir = explode(':', Settings::Get('system.mod_fcgid_peardir'));
         foreach ($_custom_openbasedir as $cobd) {
             $_phpappendopenbasedir .= appendOpenBasedirPath($cobd);
         }
         $_custom_openbasedir = explode(':', Settings::Get('system.phpappendopenbasedir'));
         foreach ($_custom_openbasedir as $cobd) {
             $_phpappendopenbasedir .= appendOpenBasedirPath($cobd);
         }
         if ($this->_domain['openbasedir_path'] == '0' && strstr($this->_domain['documentroot'], ":") === false) {
             $openbasedir = appendOpenBasedirPath($this->_domain['documentroot'], true);
         } else {
             $openbasedir = appendOpenBasedirPath($this->_domain['customerroot'], true);
         }
         $openbasedir .= appendOpenBasedirPath($this->getTempDir());
         $openbasedir .= $_phpappendopenbasedir;
         $openbasedir = explode(':', $openbasedir);
         $clean_openbasedir = array();
         foreach ($openbasedir as $number => $path) {
             if (trim($path) != '/') {
                 $clean_openbasedir[] = makeCorrectDir($path);
             }
         }
         $openbasedir = implode(':', $clean_openbasedir);
     } else {
         $openbasedir = 'none';
         $openbasedirc = ';';
     }
     $admin = $this->_getAdminData($this->_domain['adminid']);
     $php_ini_variables = array('SAFE_MODE' => 'Off', 'PEAR_DIR' => Settings::Get('system.mod_fcgid_peardir'), 'OPEN_BASEDIR' => $openbasedir, 'OPEN_BASEDIR_C' => $openbasedirc, 'OPEN_BASEDIR_GLOBAL' => Settings::Get('system.hpappendopenbasedir'), 'TMP_DIR' => $this->getTempDir(), 'CUSTOMER_EMAIL' => $this->_domain['email'], 'ADMIN_EMAIL' => $admin['email'], 'DOMAIN' => $this->_domain['domain'], 'CUSTOMER' => $this->_domain['loginname'], 'ADMIN' => $admin['loginname']);
     //insert a small header for the file
     $phpini_file = ";\n";
     $phpini_file .= "; php.ini created/changed on " . date("Y.m.d H:i:s") . " for domain '" . $this->_domain['domain'] . "' with id #" . $this->_domain['id'] . " from php template '" . $phpconfig['description'] . "' with id #" . $phpconfig['id'] . "\n";
     $phpini_file .= "; Do not change anything in this file, it will be overwritten by the Froxlor Cronjob!\n";
     $phpini_file .= ";\n\n";
     $phpini_file .= replace_variables($phpconfig['phpsettings'], $php_ini_variables);
     $phpini_file = str_replace('"none"', 'none', $phpini_file);
     $phpini_file = preg_replace('/\\"+/', '"', $phpini_file);
     $phpini_file_handler = fopen($this->getIniFile(), 'w');
     fwrite($phpini_file_handler, $phpini_file);
     fclose($phpini_file_handler);
     safe_exec('chown root:0 ' . escapeshellarg($this->getIniFile()));
     safe_exec('chmod 0644 ' . escapeshellarg($this->getIniFile()));
 }
示例#8
0
 /**
  * Mail notifications
  */
 public function sendMail($customerid = -1, $template_subject = null, $default_subject = null, $template_body = null, $default_body = null)
 {
     global $mail;
     // Some checks are to be made here in the future
     if ($customerid != -1) {
         // Get e-mail message for customer
         $usr = $this->db->query_first('SELECT `name`, `firstname`, `company`, `email`
                            FROM `' . TABLE_PANEL_CUSTOMERS . '` 
                            WHERE `customerid` = "' . (int) $customerid . '"');
         $replace_arr = array('FIRSTNAME' => $usr['firstname'], 'NAME' => $usr['name'], 'COMPANY' => $usr['company'], 'SALUTATION' => getCorrectUserSalutation($usr), 'SUBJECT' => $this->Get('subject', true));
     } else {
         $replace_arr = array('SUBJECT' => $this->Get('subject', true));
     }
     $result = $this->db->query_first('SELECT `value` FROM `' . TABLE_PANEL_TEMPLATES . '`
                             WHERE `adminid`=\'' . (int) $this->userinfo['adminid'] . '\' 
                             AND `language`=\'' . $this->db->escape($this->userinfo['def_language']) . '\' 
                             AND `templategroup`=\'mails\' 
                             AND `varname`=\'' . $template_subject . '\'');
     $mail_subject = html_entity_decode(replace_variables($result['value'] != '' ? $result['value'] : $default_subject, $replace_arr));
     $result = $this->db->query_first('SELECT `value` FROM `' . TABLE_PANEL_TEMPLATES . '`
                             WHERE `adminid`=\'' . (int) $this->userinfo['adminid'] . '\' 
                             AND `language`=\'' . $this->db->escape($this->userinfo['def_language']) . '\' 
                             AND `templategroup`=\'mails\' 
                             AND `varname`=\'' . $template_body . '\'');
     $mail_body = html_entity_decode(replace_variables($result['value'] != '' ? $result['value'] : $default_body, $replace_arr));
     if ($customerid != -1) {
         $_mailerror = false;
         try {
             $mail->SetFrom($this->settings['ticket']['noreply_email'], $this->settings['ticket']['noreply_name']);
             $mail->Subject = $mail_subject;
             $mail->AltBody = $mail_body;
             $mail->MsgHTML(str_replace("\n", "<br />", $mail_body));
             $mail->AddAddress($usr['email'], $usr['firstname'] . ' ' . $usr['name']);
             $mail->Send();
         } catch (phpmailerException $e) {
             $mailerr_msg = $e->errorMessage();
             $_mailerror = true;
         } catch (Exception $e) {
             $mailerr_msg = $e->getMessage();
             $_mailerror = true;
         }
         if ($_mailerror) {
             $rstlog = FroxlorLogger::getInstanceOf(array('loginname' => 'ticket_class'), $this->db, $this->settings);
             $rstlog->logAction(ADM_ACTION, LOG_ERR, "Error sending mail: " . $mailerr_msg);
             standard_error('errorsendingmail', $usr['email']);
         }
         $mail->ClearAddresses();
     } else {
         $admin = $this->db->query_first("SELECT `name`, `email` FROM `" . TABLE_PANEL_ADMINS . "` WHERE `adminid`='" . (int) $this->userinfo['adminid'] . "'");
         $_mailerror = false;
         try {
             $mail->SetFrom($this->settings['ticket']['noreply_email'], $this->settings['ticket']['noreply_name']);
             $mail->Subject = $mail_subject;
             $mail->AltBody = $mail_body;
             $mail->MsgHTML(str_replace("\n", "<br />", $mail_body));
             $mail->AddAddress($admin['email'], $admin['name']);
             $mail->Send();
         } catch (phpmailerException $e) {
             $mailerr_msg = $e->errorMessage();
             $_mailerror = true;
         } catch (Exception $e) {
             $mailerr_msg = $e->getMessage();
             $_mailerror = true;
         }
         if ($_mailerror) {
             $rstlog = FroxlorLogger::getInstanceOf(array('loginname' => 'ticket_class'), $this->db, $this->settings);
             $rstlog->logAction(ADM_ACTION, LOG_ERR, "Error sending mail: " . $mailerr_msg);
             standard_error('errorsendingmail', $admin['email']);
         }
         $mail->ClearAddresses();
     }
 }
示例#9
0
 $stmt = Database::prepare("UPDATE `" . TABLE_PANEL_CUSTOMERS . "`\n\t\t\t\t\t\tSET `ftps_used` = `ftps_used` + 1,\n\t\t\t\t\t\t`ftp_lastaccountnumber` = `ftp_lastaccountnumber` + 1\n\t\t\t\t\t\tWHERE `customerid` = :customerid");
 Database::pexecute($stmt, array("customerid" => $userinfo['customerid']));
 $log->logAction(USR_ACTION, LOG_INFO, "added ftp-account '" . $username . " (" . $path . ")'");
 inserttask(5);
 if ($sendinfomail == 1) {
     $replace_arr = array('SALUTATION' => getCorrectUserSalutation($userinfo), 'CUST_NAME' => getCorrectUserSalutation($userinfo), 'USR_NAME' => $username, 'USR_PASS' => $password, 'USR_PATH' => makeCorrectDir(str_replace($userinfo['documentroot'], "/", $path)));
     $def_language = $userinfo['def_language'];
     $result_stmt = Database::prepare("SELECT `value` FROM `" . TABLE_PANEL_TEMPLATES . "`\n\t\t\t\t\t\t\tWHERE `adminid` = :adminid\n\t\t\t\t\t\t\tAND `language` = :lang\n\t\t\t\t\t\t\tAND `templategroup`='mails'\n\t\t\t\t\t\t\tAND `varname`='new_ftpaccount_by_customer_subject'");
     Database::pexecute($result_stmt, array("adminid" => $userinfo['adminid'], "lang" => $def_language));
     $result = $result_stmt->fetch(PDO::FETCH_ASSOC);
     $mail_subject = html_entity_decode(replace_variables($result['value'] != '' ? $result['value'] : $lng['mails']['new_ftpaccount_by_customer']['subject'], $replace_arr));
     $def_language = $userinfo['def_language'];
     $result_stmt = Database::prepare("SELECT `value` FROM `" . TABLE_PANEL_TEMPLATES . "`\n\t\t\t\t\t\t\tWHERE `adminid` = :adminid\n\t\t\t\t\t\t\tAND `language` = :lang\n\t\t\t\t\t\t\tAND `templategroup`='mails'\n\t\t\t\t\t\t\tAND `varname`='new_ftpaccount_by_customer_mailbody'");
     Database::pexecute($result_stmt, array("adminid" => $userinfo['adminid'], "lang" => $def_language));
     $result = $result_stmt->fetch(PDO::FETCH_ASSOC);
     $mail_body = html_entity_decode(replace_variables($result['value'] != '' ? $result['value'] : $lng['mails']['new_ftpaccount_by_customer']['mailbody'], $replace_arr));
     $_mailerror = false;
     try {
         $mail->Subject = $mail_subject;
         $mail->AltBody = $mail_body;
         $mail->MsgHTML(str_replace("\n", "<br />", $mail_body));
         $mail->AddAddress($userinfo['email'], getCorrectUserSalutation($userinfo));
         $mail->Send();
     } catch (phpmailerException $e) {
         $mailerr_msg = $e->errorMessage();
         $_mailerror = true;
     } catch (Exception $e) {
         $mailerr_msg = $e->getMessage();
         $_mailerror = true;
     }
     if ($_mailerror) {
示例#10
0
 /**
  * process special config as template, by substituting {VARIABLE} with the
  * respective value.
  *
  * The following variables are known at the moment:
  *
  * {DOMAIN} - domain name
  * {IP} - IP for this domain
  * {PORT} - Port for this domain
  * {CUSTOMER} - customer name
  * {IS_SSL} - evaluates to 'ssl' if domain/ip is ssl, otherwise it is an empty string
  * {DOCROOT} - document root for this domain
  *
  * @param
  *        	$template
  * @return string
  */
 protected function processSpecialConfigTemplate($template, $domain, $ip, $port, $is_ssl_vhost)
 {
     $templateVars = array('DOMAIN' => $domain['domain'], 'CUSTOMER' => $domain['loginname'], 'IP' => $ip, 'PORT' => $port, 'SCHEME' => $is_ssl_vhost ? 'https' : 'http', 'DOCROOT' => $domain['documentroot']);
     return replace_variables($template, $templateVars);
 }
示例#11
0
function get_contents_dataset($source, $command, $nodeType)
{
    global $thisProcess;
    global $mysqli;
    if ($source == "sql_procedure") {
        $returnArr = array();
        $paramString = "";
        if ($nodeType == 'contents') {
            $parameters = $thisProcess[0]->email_contents->parameters->parameter;
        }
        if ($nodeType == 'recipients') {
            $parameters = $thisProcess[0]->recipient_list->parameters->parameter;
        }
        if (count($parameters) > 0) {
            foreach ($parameters as $parameter) {
                $parameter = replace_variables($parameter);
                $paramString .= "'" . $parameter . "',";
            }
            if ($paramString != '') {
                $paramString = substr($paramString, 0, strlen($paramString) - 1);
            }
        } else {
            $paramString = "";
        }
        $query = "CALL afids." . $command . "(" . $paramString . ")";
        //echo $query;
        //exit;
        if ($mysqli->multi_query($query)) {
            do {
                /* store first result set */
                if ($result = $mysqli->store_result()) {
                    while ($row = $result->fetch_assoc()) {
                        $returnArr[] = $row;
                    }
                    $result->free();
                }
            } while ($mysqli->next_result());
            $recordCount = 1;
        } else {
            $recordCount = 0;
        }
    }
    if ($source == "sql_text") {
        $report_dataSet = mysql_query($command);
        if (mysql_error()) {
            $systemErrMsg = "MySql error: " . mysql_error() . " " . $command;
            handle_error($systemErrMsg);
        }
        while ($row = mysql_fetch_assoc($report_dataSet)) {
            $returnArr[] = $row;
        }
    }
    return $returnArr;
}
示例#12
0
    /**
     * Mail notifications
     */
    public function sendMail($customerid = -1, $template_subject = null, $default_subject = null, $template_body = null, $default_body = null)
    {
        global $mail, $theme;
        // Some checks are to be made here in the future
        if ($customerid != -1) {
            // Get e-mail message for customer
            $usr_stmt = Database::prepare('
				SELECT `name`, `firstname`, `company`, `email`
				FROM `' . TABLE_PANEL_CUSTOMERS . '` WHERE `customerid` = :customerid');
            $usr = Database::pexecute_first($usr_stmt, array('customerid' => $customerid));
            $replace_arr = array('FIRSTNAME' => $usr['firstname'], 'NAME' => $usr['name'], 'COMPANY' => $usr['company'], 'SALUTATION' => getCorrectUserSalutation($usr), 'SUBJECT' => $this->Get('subject', true));
        } else {
            $replace_arr = array('SUBJECT' => $this->Get('subject', true));
        }
        $tpl_seldata = array('adminid' => $this->userinfo['adminid'], 'lang' => $this->userinfo['def_language'], 'tplsubject' => $template_subject);
        $result_stmt = Database::prepare("\n\t\t\tSELECT `value` FROM `" . TABLE_PANEL_TEMPLATES . "`\n\t\t\tWHERE `adminid`= :adminid\n\t\t\tAND `language`= :lang\n\t\t\tAND `templategroup`= 'mails' AND `varname`= :tplsubject");
        $result = Database::pexecute_first($result_stmt, $tpl_seldata);
        $mail_subject = html_entity_decode(replace_variables($result['value'] != '' ? $result['value'] : $default_subject, $replace_arr));
        unset($tpl_seldata['tplsubject']);
        $tpl_seldata['tplmailbody'] = $template_body;
        $result_stmt = Database::prepare("\n\t\t\tSELECT `value` FROM `" . TABLE_PANEL_TEMPLATES . "`\n\t\t\tWHERE `adminid`= :adminid\n\t\t\tAND `language`= :lang\n\t\t\tAND `templategroup`= 'mails' AND `varname`= :tplmailbody");
        $result = Database::pexecute_first($result_stmt, $tpl_seldata);
        $mail_body = html_entity_decode(replace_variables($result['value'] != '' ? $result['value'] : $default_body, $replace_arr));
        if ($customerid != -1) {
            $_mailerror = false;
            try {
                $mail->SetFrom(Settings::Get('ticket.noreply_email'), Settings::Get('ticket.noreply_name'));
                $mail->Subject = $mail_subject;
                $mail->AltBody = $mail_body;
                $mail->MsgHTML(str_replace("\n", "<br />", $mail_body));
                $mail->AddAddress($usr['email'], $usr['firstname'] . ' ' . $usr['name']);
                $mail->Send();
            } catch (phpmailerException $e) {
                $mailerr_msg = $e->errorMessage();
                $_mailerror = true;
            } catch (Exception $e) {
                $mailerr_msg = $e->getMessage();
                $_mailerror = true;
            }
            if ($_mailerror) {
                $rstlog = FroxlorLogger::getInstanceOf(array('loginname' => 'ticket_class'));
                $rstlog->logAction(ADM_ACTION, LOG_ERR, "Error sending mail: " . $mailerr_msg);
                standard_error('errorsendingmail', $usr['email']);
            }
            $mail->ClearAddresses();
        } else {
            $admin_stmt = Database::prepare("\n\t\t\t\tSELECT `name`, `email` FROM `" . TABLE_PANEL_ADMINS . "`\n\t\t\t\tWHERE `adminid` = :adminid");
            $admin = Database::pexecute_first($admin_stmt, array('adminid' => $this->userinfo['adminid']));
            $_mailerror = false;
            try {
                $mail->SetFrom(Settings::Get('ticket.noreply_email'), Settings::Get('ticket.noreply_name'));
                $mail->Subject = $mail_subject;
                $mail->AltBody = $mail_body;
                $mail->MsgHTML(str_replace("\n", "<br />", $mail_body));
                $mail->AddAddress($admin['email'], $admin['name']);
                $mail->Send();
            } catch (phpmailerException $e) {
                $mailerr_msg = $e->errorMessage();
                $_mailerror = true;
            } catch (Exception $e) {
                $mailerr_msg = $e->getMessage();
                $_mailerror = true;
            }
            if ($_mailerror) {
                $rstlog = FroxlorLogger::getInstanceOf(array('loginname' => 'ticket_class'));
                $rstlog->logAction(ADM_ACTION, LOG_ERR, "Error sending mail: " . $mailerr_msg);
                standard_error('errorsendingmail', $admin['email']);
            }
            $mail->ClearAddresses();
        }
    }
示例#13
0
 /**
  * Mail notifications.
  */
 public function sendMail($customerid = -1, $template_subject = null, $default_subject = null, $template_body = null, $default_body = null)
 {
     global $mail;
     // Some checks are to be made here in the future
     if ($customerid != -1) {
         // Get e-mail message for customer
         $usr = $this->db->query_first('SELECT `name`, `firstname`, `email` 
                            FROM `' . TABLE_PANEL_CUSTOMERS . '` 
                            WHERE `customerid` = "' . (int) $customerid . '"');
         $replace_arr = array('FIRSTNAME' => $usr['firstname'], 'NAME' => $usr['name'], 'SUBJECT' => $this->Get('subject', true));
     } else {
         $replace_arr = array('SUBJECT' => $this->Get('subject', true));
     }
     $result = $this->db->query_first('SELECT `value` FROM `' . TABLE_PANEL_TEMPLATES . '` 
                             WHERE `adminid`=\'' . (int) $this->userinfo['adminid'] . '\' 
                             AND `language`=\'' . $this->db->escape($this->userinfo['def_language']) . '\' 
                             AND `templategroup`=\'mails\' 
                             AND `varname`=\'' . $template_subject . '\'');
     $mail_subject = html_entity_decode(replace_variables($result['value'] != '' ? $result['value'] : $default_subject, $replace_arr));
     $result = $this->db->query_first('SELECT `value` FROM `' . TABLE_PANEL_TEMPLATES . '` 
                             WHERE `adminid`=\'' . (int) $this->userinfo['adminid'] . '\' 
                             AND `language`=\'' . $this->db->escape($this->userinfo['def_language']) . '\' 
                             AND `templategroup`=\'mails\' 
                             AND `varname`=\'' . $template_body . '\'');
     $mail_body = html_entity_decode(replace_variables($result['value'] != '' ? $result['value'] : $default_body, $replace_arr));
     if ($customerid != -1) {
         $mail->From = $this->settings['ticket']['noreply_email'];
         $mail->FromName = $this->settings['ticket']['noreply_name'];
         $mail->Subject = $mail_subject;
         $mail->Body = $mail_body;
         $mail->AddAddress($usr['email'], $usr['firstname'] . ' ' . $usr['name']);
         if (!$mail->Send()) {
             standard_error(array('errorsendingmail', $usr['email']));
         }
         $mail->ClearAddresses();
     } else {
         $admin = $this->db->query_first('SELECT `email` FROM `' . TABLE_PANEL_ADMINS . "` WHERE `adminid`='" . (int) $this->userinfo['adminid'] . "'");
         $mail->From = $this->settings['ticket']['noreply_email'];
         $mail->FromName = $this->settings['ticket']['noreply_name'];
         $mail->Subject = $mail_subject;
         $mail->Body = $mail_body;
         $mail->AddAddress($admin['email'], $admin['firstname'] . ' ' . $admin['name']);
         if (!$mail->Send()) {
             standard_error(array('errorsendingmail', $admin['email']));
         }
         $mail->ClearAddresses();
     }
 }
示例#14
0
 } else {
     $lngfile = Database::pexecute_first($lngfile_stmt, array('deflang' => Settings::Get('panel.standardlanguage')));
     $langfile = $lngfile['file'];
 }
 // include english language file (fallback)
 include_once makeCorrectFile(FROXLOR_INSTALL_DIR . '/lng/english.lng.php');
 // include admin/customer language file
 include_once makeCorrectFile(FROXLOR_INSTALL_DIR . '/' . $langfile);
 // Get mail templates from database; the ones from 'admin' are fetched for fallback
 $result2_stmt = Database::prepare("\n\t\t\tSELECT `value` FROM `" . TABLE_PANEL_TEMPLATES . "`\n\t\t\tWHERE `adminid` = :adminid\n\t\t\tAND `language` = :lang\n\t\t\tAND `templategroup` = 'mails' AND `varname` = :varname\n\t\t");
 $resul2_data = array('adminid' => $row['adminid'], 'lang' => $row['def_language'], 'varname' => 'trafficmaxpercent_subject');
 $result2 = Database::pexecute_first($result2_stmt, $result2_data);
 $mail_subject = html_entity_decode(replace_variables($result2['value'] != '' ? $result2['value'] : $lng['mails']['trafficmaxpercent']['subject'], $replace_arr));
 $resul2_data['varname'] = 'trafficmaxpercent_mailbody';
 $result2 = Database::pexecute_first($result2_stmt, $result2_data);
 $mail_body = html_entity_decode(replace_variables($result2['value'] != '' ? $result2['value'] : $lng['mails']['trafficmaxpercent']['mailbody'], $replace_arr));
 $_mailerror = false;
 try {
     $mail->SetFrom($row['email'], $row['name']);
     $mail->Subject = $mail_subject;
     $mail->AltBody = $mail_body;
     $mail->MsgHTML(nl2br($mail_body));
     $mail->AddAddress($row['email'], $row['name']);
     $mail->Send();
 } catch (phpmailerException $e) {
     $mailerr_msg = $e->errorMessage();
     $_mailerror = true;
 } catch (Exception $e) {
     $mailerr_msg = $e->getMessage();
     $_mailerror = true;
 }
示例#15
0
<?php

function replace_variables($text, $params)
{
    $c = function ($matches) use(&$params, &$text) {
        $text = preg_replace('/(\\?)/', array_shift($params), $text, 1);
    };
    preg_replace_callback('/(\\?)/', $c, $text);
    return $text;
}
echo replace_variables('a=?', array('0')) . "\n";
echo replace_variables('a=?, b=?', array('0', '1')) . "\n";
echo replace_variables('a=?, b=?, c=?', array('0', '1', '2')) . "\n";
echo "Done\n";
示例#16
0
 // Statement modifyed for Database description -- PH 2004-11-29
 $databasedescription = validate($_POST['description'], 'description');
 $external_access_val = isset($_POST['mysql_allow_external_access']) ? '1' : '0';
 $result = $db->query('INSERT INTO `' . TABLE_PANEL_DATABASES . '` (`customerid`, `databasename`, `description`, `dbserver`, `allow_external_access`) VALUES ("' . (int) $userinfo['customerid'] . '", "' . $db->escape($username) . '", "' . $db->escape($databasedescription) . '", "' . $db->escape($dbserver) . '", "' . $external_access_val . '")');
 $result = $db->query('UPDATE `' . TABLE_PANEL_CUSTOMERS . '` SET `mysqls_used`=`mysqls_used`+1, `mysql_lastaccountnumber`=`mysql_lastaccountnumber`+1 WHERE `customerid`="' . (int) $userinfo['customerid'] . '"');
 if ($sendinfomail == 1) {
     $pma = $lng['admin']['notgiven'];
     if ($settings['panel']['phpmyadmin_url'] != '') {
         $pma = $settings['panel']['phpmyadmin_url'];
     }
     $replace_arr = array('CUST_NAME' => getCorrectUserSalutation($userinfo), 'DB_NAME' => $username, 'DB_PASS' => $password, 'DB_DESC' => $databasedescription, 'DB_SRV' => $_SERVER["SERVER_NAME"], 'PMA_URI' => $pma);
     $def_language = $userinfo['def_language'];
     $result = $db->query_first('SELECT `value` FROM `' . TABLE_PANEL_TEMPLATES . '` WHERE `adminid`=\'' . (int) $userinfo['adminid'] . '\' AND `language`=\'' . $db->escape($def_language) . '\' AND `templategroup`=\'mails\' AND `varname`=\'new_database_by_customer_subject\'');
     $mail_subject = html_entity_decode(replace_variables($result['value'] != '' ? $result['value'] : $lng['customer']['mysql_add']['infomail_subject'], $replace_arr));
     $result = $db->query_first('SELECT `value` FROM `' . TABLE_PANEL_TEMPLATES . '` WHERE `adminid`=\'' . (int) $userinfo['adminid'] . '\' AND `language`=\'' . $db->escape($def_language) . '\' AND `templategroup`=\'mails\' AND `varname`=\'new_database_by_customer_mailbody\'');
     $mail_body = html_entity_decode(replace_variables($result['value'] != '' ? $result['value'] : $lng['customer']['mysql_add']['infomail_body']['main'], $replace_arr));
     $_mailerror = false;
     try {
         $mail->Subject = $mail_subject;
         $mail->AltBody = $mail_body;
         $mail->MsgHTML(str_replace("\n", "<br />", $mail_body));
         $mail->AddAddress($userinfo['email'], getCorrectUserSalutation($userinfo));
         $mail->Send();
     } catch (phpmailerException $e) {
         $mailerr_msg = $e->errorMessage();
         $_mailerror = true;
     } catch (Exception $e) {
         $mailerr_msg = $e->getMessage();
         $_mailerror = true;
     }
     if ($_mailerror) {
示例#17
0
文件: index.php 项目: mowamed/Froxlor
                    $result_stmt = Database::prepare('SELECT `value` FROM `' . TABLE_PANEL_TEMPLATES . '`
						WHERE `adminid`= :adminid
						AND `language`= :lang
						AND `templategroup`=\'mails\'
						AND `varname`=\'password_reset_subject\'');
                    Database::pexecute($result_stmt, array("adminid" => $user['adminid'], "lang" => $def_language));
                    $result = $result_stmt->fetch(PDO::FETCH_ASSOC);
                    $mail_subject = html_entity_decode(replace_variables($result['value'] != '' ? $result['value'] : $lng['mails']['password_reset']['subject'], $replace_arr));
                    $result_stmt = Database::prepare('SELECT `value` FROM `' . TABLE_PANEL_TEMPLATES . '`
						WHERE `adminid`= :adminid
						AND `language`= :lang
						AND `templategroup`=\'mails\'
						AND `varname`=\'password_reset_mailbody\'');
                    Database::pexecute($result_stmt, array("adminid" => $user['adminid'], "lang" => $def_language));
                    $result = $result_stmt->fetch(PDO::FETCH_ASSOC);
                    $mail_body = html_entity_decode(replace_variables($result['value'] != '' ? $result['value'] : $lng['mails']['password_reset']['mailbody'], $replace_arr));
                    $_mailerror = false;
                    try {
                        $mail->Subject = $mail_subject;
                        $mail->AltBody = $mail_body;
                        $mail->MsgHTML(str_replace("\n", "<br />", $mail_body));
                        $mail->AddAddress($user['email'], getCorrectUserSalutation($user));
                        $mail->Send();
                    } catch (phpmailerException $e) {
                        $mailerr_msg = $e->errorMessage();
                        $_mailerror = true;
                    } catch (Exception $e) {
                        $mailerr_msg = $e->getMessage();
                        $_mailerror = true;
                    }
                    if ($_mailerror) {
示例#18
0
     $mailerr_msg = $e->errorMessage();
     $_mailerror = true;
 } catch (Exception $e) {
     $mailerr_msg = $e->getMessage();
     $_mailerror = true;
 }
 if ($_mailerror) {
     $log->logAction(USR_ACTION, LOG_ERR, "Error sending mail: " . $mailerr_msg);
     standard_error('errorsendingmail', $email_full);
 }
 $mail->ClearAddresses();
 if (validateEmail($alternative_email) && $settings['panel']['sendalternativemail'] == 1) {
     $result = $db->query_first('SELECT `value` FROM `' . TABLE_PANEL_TEMPLATES . '` WHERE `adminid`=\'' . (int) $userinfo['adminid'] . '\' AND `language`=\'' . $db->escape($userinfo['def_language']) . '\' AND `templategroup`=\'mails\' AND `varname`=\'pop_success_alternative_subject\'');
     $mail_subject = replace_variables($result['value'] != '' ? $result['value'] : $lng['mails']['pop_success_alternative']['subject'], $replace_arr);
     $result = $db->query_first('SELECT `value` FROM `' . TABLE_PANEL_TEMPLATES . '` WHERE `adminid`=\'' . (int) $userinfo['adminid'] . '\' AND `language`=\'' . $db->escape($userinfo['def_language']) . '\' AND `templategroup`=\'mails\' AND `varname`=\'pop_success_alternative_mailbody\'');
     $mail_body = replace_variables($result['value'] != '' ? $result['value'] : $lng['mails']['pop_success_alternative']['mailbody'], $replace_arr);
     $_mailerror = false;
     try {
         $mail->SetFrom($admin['email'], getCorrectUserSalutation($admin));
         $mail->Subject = $mail_subject;
         $mail->AltBody = $mail_body;
         $mail->MsgHTML(str_replace("\n", "<br />", $mail_body));
         $mail->AddAddress($idna_convert->encode($alternative_email), getCorrectUserSalutation($userinfo));
         $mail->Send();
     } catch (phpmailerException $e) {
         $mailerr_msg = $e->errorMessage();
         $_mailerror = true;
     } catch (Exception $e) {
         $mailerr_msg = $e->getMessage();
         $_mailerror = true;
     }
 protected function composePhpOptions($domain)
 {
     $php_options_text = '';
     if ($domain['phpenabled'] == '1') {
         // This vHost has PHP enabled and we are using mod_fcgid
         //create basic variables for config
         $configdir = makeCorrectDir($this->settings['system']['mod_fcgid_configdir'] . '/' . $domain['loginname'] . '/' . $domain['domain'] . '/');
         $starter_filename = makeCorrectFile($configdir . '/php-fcgi-starter');
         $phpini_filename = makeCorrectFile($configdir . '/php.ini');
         $tmpdir = makeCorrectDir($this->settings['system']['mod_fcgid_tmpdir'] . '/' . $domain['loginname'] . '/');
         // create config dir if necessary
         if (!is_dir($configdir)) {
             safe_exec('mkdir -p ' . escapeshellarg($configdir));
             safe_exec('chown ' . $domain['guid'] . ':' . $domain['guid'] . ' ' . escapeshellarg($configdir));
         }
         // create tmp dir if necessary
         if (!is_dir($tmpdir)) {
             safe_exec('mkdir -p ' . escapeshellarg($tmpdir));
             safe_exec('chown -R ' . $domain['guid'] . ':' . $domain['guid'] . ' ' . escapeshellarg($tmpdir));
             safe_exec('chmod 0750 ' . escapeshellarg($tmpdir));
         }
         // Load php config
         $phpconfig = $this->getPhpConfig((int) $domain['phpsettingid']);
         if ((int) $this->settings['system']['mod_fcgid_wrapper'] == 0) {
             $php_options_text .= '  SuexecUserGroup "' . $domain['loginname'] . '" "' . $domain['loginname'] . '"' . "\n";
             $php_options_text .= '  ScriptAlias /php/ ' . $configdir . "\n";
         } else {
             $php_options_text .= '  SuexecUserGroup "' . $domain['loginname'] . '" "' . $domain['loginname'] . '"' . "\n";
             $php_options_text .= '  <Directory "' . $domain['documentroot'] . '">' . "\n";
             $file_extensions = explode(' ', $phpconfig['file_extensions']);
             $php_options_text .= '    AddHandler fcgid-script .' . implode(' .', $file_extensions) . "\n";
             foreach ($file_extensions as $file_extension) {
                 $php_options_text .= '    FCGIWrapper ' . $starter_filename . ' .' . $file_extension . "\n";
             }
             $php_options_text .= '    Options +ExecCGI' . "\n";
             $php_options_text .= '  </Directory>' . "\n";
         }
         // create starter
         $starter_file = "#!/bin/sh\n\n";
         $starter_file .= "#\n";
         $starter_file .= "# starter created/changed on " . date("Y.m.d H:i:s") . " for domain '" . $domain['domain'] . "' with id #" . $domain['id'] . " from php template '" . $phpconfig['description'] . "' with id #" . $phpconfig['id'] . "\n";
         $starter_file .= "# Do not change anything in this file, it will be overwritten by the SysCP Cronjob!\n";
         $starter_file .= "#\n\n";
         $starter_file .= "PHPRC=" . escapeshellarg($configdir) . "\n";
         $starter_file .= "export PHPRC\n";
         // set number of processes for one domain
         if ((int) $domain['mod_fcgid_starter'] != -1) {
             $starter_file .= "PHP_FCGI_CHILDREN=" . (int) $domain['mod_fcgid_starter'] . "\n";
         } else {
             if ((int) $phpconfig['mod_fcgid_starter'] != -1) {
                 $starter_file .= "PHP_FCGI_CHILDREN=" . (int) $phpconfig['mod_fcgid_starter'] . "\n";
             } else {
                 $starter_file .= "PHP_FCGI_CHILDREN=" . (int) $this->settings['system']['mod_fcgid_starter'] . "\n";
             }
         }
         $starter_file .= "export PHP_FCGI_CHILDREN\n";
         // set number of maximum requests for one domain
         if ((int) $domain['mod_fcgid_maxrequests'] != -1) {
             $starter_file .= "PHP_FCGI_MAX_REQUESTS=" . (int) $domain['mod_fcgid_maxrequests'] . "\n";
         } else {
             if ((int) $phpconfig['mod_fcgid_maxrequests'] != -1) {
                 $starter_file .= "PHP_FCGI_MAX_REQUESTS=" . (int) $phpconfig['mod_fcgid_maxrequests'] . "\n";
             } else {
                 $starter_file .= "PHP_FCGI_MAX_REQUESTS=" . (int) $this->settings['system']['mod_fcgid_maxrequests'] . "\n";
             }
         }
         $starter_file .= "export PHP_FCGI_MAX_REQUESTS\n";
         // Set Binary
         $starter_file .= "exec " . $phpconfig['binary'] . " -c " . escapeshellarg($configdir) . "\n";
         //remove +i attibute, so starter can be overwritten
         if (file_exists($starter_filename)) {
             safe_exec('chattr -i ' . escapeshellarg($starter_filename));
         }
         $starter_file_handler = fopen($starter_filename, 'w');
         fwrite($starter_file_handler, $starter_file);
         fclose($starter_file_handler);
         safe_exec('chmod 750 ' . escapeshellarg($starter_filename));
         safe_exec('chown ' . $domain['guid'] . ':' . $domain['guid'] . ' ' . escapeshellarg($starter_filename));
         safe_exec('chattr +i ' . escapeshellarg($starter_filename));
         // define the php.ini
         $openbasedir = '';
         if ($domain['openbasedir'] == '1') {
             if ($domain['openbasedir_path'] == '0') {
                 $openbasedir = makeCorrectDir($domain['documentroot']) . ':' . $tmpdir . ':' . $this->settings['system']['mod_fcgid_peardir'] . ':' . $this->settings['system']['phpappendopenbasedir'];
             } else {
                 $openbasedir = makeCorrectDir($domain['customerroot']) . ':' . $tmpdir . ':' . $this->settings['system']['mod_fcgid_peardir'] . ':' . $this->settings['system']['phpappendopenbasedir'];
             }
             $openbasedir = explode(':', $openbasedir);
             foreach ($openbasedir as $number => $path) {
                 $openbasedir[$number] = makeCorrectDir($path);
             }
             $openbasedir = implode(':', $openbasedir);
         } else {
             $openbasedir = 'none';
         }
         $admin = $this->getAdminData($domain['adminid']);
         $php_ini_variables = array('SAFE_MODE' => $domain['safemode'] == '0' ? 'Off' : 'On', 'PEAR_DIR' => $this->settings['system']['mod_fcgid_peardir'], 'OPEN_BASEDIR' => $openbasedir, 'OPEN_BASEDIR_GLOBAL' => $this->settings['system']['phpappendopenbasedir'], 'TMP_DIR' => $tmpdir, 'CUSTOMER_EMAIL' => $domain['email'], 'ADMIN_EMAIL' => $admin['email'], 'DOMAIN' => $domain['domain'], 'CUSTOMER' => $domain['loginname'], 'ADMIN' => $admin['loginname']);
         //insert a small header for the file
         $phpini_file = ";\n";
         $phpini_file .= "; php.ini created/changed on " . date("Y.m.d H:i:s") . " for domain '" . $domain['domain'] . "' with id #" . $domain['id'] . " from php template '" . $phpconfig['description'] . "' with id #" . $phpconfig['id'] . "\n";
         $phpini_file .= "; Do not change anything in this file, it will be overwritten by the SysCP Cronjob!\n";
         $phpini_file .= ";\n\n";
         $phpini_file .= replace_variables($phpconfig['phpsettings'], $php_ini_variables);
         $phpini_file = str_replace('"none"', 'none', $phpini_file);
         $phpini_file = preg_replace('/\\"+/', '"', $phpini_file);
         $phpini_file_handler = fopen($phpini_filename, 'w');
         fwrite($phpini_file_handler, $phpini_file);
         fclose($phpini_file_handler);
         safe_exec('chown root:0 ' . escapeshellarg($phpini_filename));
         safe_exec('chmod 0644 ' . escapeshellarg($phpini_filename));
     } else {
         $php_options_text .= '  # PHP is disabled for this vHost' . "\n";
     }
     return $php_options_text;
 }