/** * download a package from the distribution server and move the downloaded file in the temporary directory * * @param url url to download * @param application string identifying the application name * @param version string identifying the application version * @return success true/error false */ private function DownloadPackage($Url, $Application, $Version) { $Downloads = self::FetchSubUrls($Url . '/'); //make url valid $path = dirname($Url); $file = urlencode(basename($Url)); $file_url = 'http://' . $this->RequestDomain . $path . '/' . $file . '.aps' . $Downloads[0]; //get content from website url $this->_cronlog->logAction(CRON_ACTION, LOG_NOTICE, "Downloading '" . $file_url . "'"); $Content = @file_get_contents($file_url); if ($Content != false) { //open file to write contents on disk $FileHandle = fopen($this->RootDir . 'temp/' . $Application . '-' . $Version . '.app.zip', 'wb'); if ($FileHandle == true) { //write results to disk fwrite($FileHandle, $Content); fclose($FileHandle); //set right permissions chmod($this->RootDir . 'temp/' . $Application . '-' . $Version . '.app.zip', 0664); return true; } else { return false; } } else { return false; } }
/** * Constructor * Parses all available checks into $this->available */ public function __construct() { global $userinfo; if (!isset($userinfo) || !is_array($userinfo)) { $userinfo = array('loginname' => 'integrity-check'); } $this->_log = FroxlorLogger::getInstanceOf($userinfo); $this->available = get_class_methods($this); unset($this->available[array_search('__construct', $this->available)]); unset($this->available[array_search('checkAll', $this->available)]); unset($this->available[array_search('fixAll', $this->available)]); sort($this->available); }
/** * Class constructor. * * @param array userinfo */ protected function __construct($userinfo) { $this->userinfo = $userinfo; self::$logtypes = array(); if ((Settings::Get('logger.logtypes') == null || Settings::Get('logger.logtypes') == '') && (Settings::Get('logger.enabled') !== null && Settings::Get('logger.enabled'))) { self::$logtypes[0] = 'syslog'; self::$logtypes[1] = 'mysql'; } else { if (Settings::Get('logger.logtypes') !== null && Settings::Get('logger.logtypes') != '') { self::$logtypes = explode(',', Settings::Get('logger.logtypes')); } else { self::$logtypes = null; } } }
/** * Class constructor. * * @param array userinfo * @param array settings */ protected function __construct($userinfo, $db, $settings) { $this->userinfo = $userinfo; $this->db = $db; $this->settings = $settings; self::$logtypes = array(); if (!isset($this->settings['logger']['logtypes']) && (!isset($this->settings['logger']['logtypes']) || $this->settings['logger']['logtypes'] == '') && isset($this->settings['logger']['enabled']) && $this->settings['logger']['enabled']) { self::$logtypes[0] = 'syslog'; self::$logtypes[1] = 'mysql'; } else { if (isset($this->settings['logger']['logtypes']) && $this->settings['logger']['logtypes'] != '') { self::$logtypes = explode(',', $this->settings['logger']['logtypes']); } else { self::$logtypes = null; } } }
try { // Initialize Lescript with documentroot $le = new lescript($cronlog); // Initialize Lescript $le->initAccount($certrow); // Request the new certificate (old key may be used) $return = $le->signDomains($domains, $certrow['ssl_key_file'], $certrow['ssl_csr_file']); // We are interessted in the expirationdate $newcert = openssl_x509_parse($return['crt']); // Store the new data Database::pexecute($updcert_stmt, array('id' => $certrow['id'], 'domainid' => $certrow['domainid'], 'crt' => $return['crt'], 'key' => $return['key'], 'ca' => $return['chain'], 'chain' => $return['chain'], 'csr' => $return['csr'], 'expirationdate' => date('Y-m-d H:i:s', $newcert['validTo_time_t']))); if ($certrow['ssl_redirect'] == 3) { Database::pexecute($upddom_stmt, array('domainid' => $certrow['domainid'])); } $cronlog->logAction(CRON_ACTION, LOG_INFO, "Updated Let's Encrypt certificate for " . $certrow['domain']); $changedetected = 1; } catch (Exception $e) { $cronlog->logAction(CRON_ACTION, LOG_ERR, "Could not get Let's Encrypt certificate for " . $certrow['domain'] . ": " . $e->getMessage()); } } else { $cronlog->logAction(CRON_ACTION, LOG_WARNING, "Skipping Let's Encrypt generation for " . $certrow['domain'] . " due to an enabled ssl_redirect"); } } // If we have a change in a certificate, we need to update the webserver - configs // This is easiest done by just creating a new task ;) if ($changedetected) { inserttask(1); } // reset logger $cronlog = FroxlorLogger::getInstanceOf(array('loginname' => 'cronjob')); $cronlog->logAction(CRON_ACTION, LOG_INFO, "Let's Encrypt certificates have been updated");
$_mailerror = true; } catch (Exception $e) { $mailerr_msg = $e->getMessage(); $_mailerror = true; } if ($_mailerror) { $rstlog = FroxlorLogger::getInstanceOf(array('loginname' => 'password_reset'), $db, $settings); $rstlog->logAction(ADM_ACTION, LOG_ERR, "Error sending mail: " . $mailerr_msg); redirectTo('index.php', array('showmessage' => '4', 'customermail' => $user['email']), true); exit; } $mail->ClearAddresses(); redirectTo('index.php', array('showmessage' => '1'), true); exit; } else { $rstlog = FroxlorLogger::getInstanceOf(array('loginname' => 'password_reset'), $db, $settings); $rstlog->logAction(USR_ACTION, LOG_WARNING, "User '" . $loginname . "' tried to reset pwd but wasn't found in database!"); $message = $lng['login']['combination_not_found']; } unset($user); } } else { $message = $lng['login']['usernotfound']; } } if ($adminchecked) { if ($settings['panel']['allow_preset_admin'] != '1') { $message = $lng['pwdreminder']['notallowed']; unset($adminchecked); } } else {
* This file is part of the Froxlor project. * Copyright (c) 2003-2009 the SysCP Team (see authors). * Copyright (c) 2010 the Froxlor Team (see authors). * * For the full copyright and license information, please view the COPYING * file that was distributed with this source code. You can also view the * COPYING file online at http://files.froxlor.org/misc/COPYING.txt * * @copyright (c) the authors * @author Florian Lippert <*****@*****.**> (2003-2009) * @author Froxlor team <*****@*****.**> (2010-) * @license GPLv2 http://files.froxlor.org/misc/COPYING.txt * @package Install * */ $updatelog = FroxlorLogger::getInstanceOf(array('loginname' => 'updater')); $updatelogfile = validateUpdateLogFile(makeCorrectFile(dirname(__FILE__) . '/update.log')); $filelog = FileLogger::getInstanceOf(array('loginname' => 'updater')); $filelog->setLogFile($updatelogfile); // if first writing does not work we'll stop, tell the user to fix it // and then let him try again. try { $filelog->logAction(ADM_ACTION, LOG_WARNING, '-------------- START LOG --------------'); } catch (Exception $e) { standard_error('exception', $e->getMessage()); } /* * since froxlor, we have to check if there's still someone * out there using syscp and needs to upgrade */ if (!isFroxlor()) {
$group = $settings['system']['mod_fcgid_httpgroup']; // all the files and folders have to belong to the local user // now because we also use fcgid for our own vhost safe_exec('chown -R ' . $user . ':' . $group . ' ' . escapeshellarg($mypath)); } /** * be sure HTMLPurifier's cache folder is writable */ safe_exec('chmod -R 0755 ' . escapeshellarg(dirname(__FILE__) . '/classes/htmlpurifier/library/HTMLPurifier/DefinitionCache/Serializer')); /** * end of HTMLPurifier check */ if (!isset($settings['panel']['version']) || $settings['panel']['version'] != $version) { /** * Do not proceed further if the Database version is not the same as the script version */ fclose($debugHandler); unlink($lockfile); die('Version of file doesnt match version of database. Exiting...'); } fwrite($debugHandler, 'Froxlor version and database version are correct' . "\n"); $cronscriptDebug = $settings['system']['debug_cron'] == '1' ? true : false; /** * Create a new idna converter */ $idna_convert = new idna_convert_wrapper(); /** * Initialize logging */ $cronlog = FroxlorLogger::getInstanceOf(array('loginname' => 'cronjob'), $db, $settings); fwrite($debugHandler, 'Logger has been included' . "\n");
unset($userinfo); $params = array("script" => basename($_SERVER["SCRIPT_NAME"]), "qrystr" => $_SERVER["QUERY_STRING"]); redirectTo('index.php', $params); exit; } /** * Initialize Template Engine */ $templatecache = array(); /** * Logic moved out of lng-file */ if (isset($userinfo['loginname']) && $userinfo['loginname'] != '') { $lng['menue']['main']['username'] .= $userinfo['loginname']; //Initialize logging $log = FroxlorLogger::getInstanceOf($userinfo); } /** * Fills variables for navigation, header and footer */ if (AREA == 'admin' || AREA == 'customer') { if (hasUpdates($version)) { /* * if froxlor-files have been updated * but not yet configured by the admin * we only show logout and the update-page */ $navigation_data = array('admin' => array('index' => array('url' => 'admin_index.php', 'label' => $lng['admin']['overview'], 'elements' => array(array('label' => $lng['menue']['main']['username']), array('url' => 'admin_index.php?action=logout', 'label' => $lng['login']['logout']))), 'server' => array('label' => $lng['admin']['server'], 'required_resources' => 'change_serversettings', 'elements' => array(array('url' => 'admin_updates.php?page=overview', 'label' => $lng['update']['update'], 'required_resources' => 'change_serversettings'))))); $navigation = buildNavigation($navigation_data['admin'], $userinfo); } else { $navigation_data = loadConfigArrayDir('lib/navigation/');
/** * 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(); } }
/** * 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(); } }
/** * setter for crondebug-flag * * @param bool $_flag * * @return void */ public function setCronDebugFlag($_flag = false) { self::$crondebug_flag = (bool) $_flag; }
* This file is part of the Froxlor project. * Copyright (c) 2003-2009 the SysCP Team (see authors). * Copyright (c) 2010 the Froxlor Team (see authors). * * For the full copyright and license information, please view the COPYING * file that was distributed with this source code. You can also view the * COPYING file online at http://files.froxlor.org/misc/COPYING.txt * * @copyright (c) the authors * @author Florian Lippert <*****@*****.**> (2003-2009) * @author Froxlor team <*****@*****.**> (2010-) * @license GPLv2 http://files.froxlor.org/misc/COPYING.txt * @package Install * */ $updatelog = FroxlorLogger::getInstanceOf(array('loginname' => 'updater'), $db, $settings); $updatelogfile = validateUpdateLogFile(makeCorrectFile(dirname(__FILE__) . '/update.log')); $filelog = FileLogger::getInstanceOf(array('loginname' => 'updater'), $settings); $filelog->setLogFile($updatelogfile); // if first writing does not work we'll stop, tell the user to fix it // and then let him try again. try { $filelog->logAction(ADM_ACTION, LOG_WARNING, '-------------- START LOG --------------'); } catch (Exception $e) { standard_error('exception', $e->getMessage()); } /* * since froxlor, we have to check if there's still someone * out there using syscp and needs to upgrade */ if (!isFroxlor()) {
redirectTo('index.php'); exit; } /** * Initialize Template Engine */ $templatecache = array(); /** * Logic moved out of lng-file */ if (isset($userinfo['loginname']) && $userinfo['loginname'] != '') { $lng['menue']['main']['username'] .= $userinfo['loginname']; /** * Initialize logging */ $log = FroxlorLogger::getInstanceOf($userinfo, $db, $settings); } /** * Fills variables for navigation, header and footer */ if (AREA == 'admin' || AREA == 'customer') { if (hasUpdates($version)) { /* * if froxlor-files have been updated * but not yet configured by the admin * we only show logout and the update-page */ $navigation_data = array('admin' => array('index' => array('url' => 'admin_index.php', 'label' => $lng['admin']['overview'], 'elements' => array(array('label' => $lng['menue']['main']['username']), array('url' => 'admin_index.php?action=logout', 'label' => $lng['login']['logout']))), 'server' => array('label' => $lng['admin']['server'], 'required_resources' => 'change_serversettings', 'elements' => array(array('url' => 'admin_updates.php?page=overview', 'label' => $lng['update']['update'], 'required_resources' => 'change_serversettings'))))); $navigation = buildNavigation($navigation_data['admin'], $userinfo); } else { $navigation_data = loadConfigArrayDir('./lib/navigation/');