/** * Returns singleton database handler. * * @return \LMSDBInterface */ public static function getInstance() { if (self::$db === null) { $_DBTYPE = LMSConfig::getIniConfig()->getSection('database')->getVariable('type')->getValue(); $_DBHOST = LMSConfig::getIniConfig()->getSection('database')->getVariable('host')->getValue(); $_DBUSER = LMSConfig::getIniConfig()->getSection('database')->getVariable('user')->getValue(); $_DBPASS = LMSConfig::getIniConfig()->getSection('database')->getVariable('password')->getValue(); $_DBNAME = LMSConfig::getIniConfig()->getSection('database')->getVariable('database')->getValue(); $_DBDEBUG = false; if (LMSConfig::getIniConfig()->getSection('database')->hasVariable('debug')) { $_DBDEBUG = ConfigHelper::checkValue(LMSConfig::getIniConfig()->getSection('database')->getVariable('debug')->getValue()); } self::$db = self::getDB($_DBTYPE, $_DBHOST, $_DBUSER, $_DBPASS, $_DBNAME, $_DBDEBUG); } return self::$db; }
/** * Checks if config variable exists * * @param string $name Config variable name in section.variable format * @return boolean */ public static function checkConfig($name) { list($section_name, $variable_name) = explode('.', $name, 2); if (empty($variable_name)) { return false; } if ($section_name === 'privileges' && !self::getConfig($name)) { return preg_match('/^hide/', $variable_name) ? false : true; } if (!LMSConfig::getConfig()->hasSection($section_name)) { return false; } if (!LMSConfig::getConfig()->getSection($section_name)->hasVariable($variable_name)) { return false; } return self::checkValue(LMSConfig::getConfig()->getSection($section_name)->getVariable($variable_name)->getValue()); }
/** * Checks if config variable exists * * @param string $name Config variable name in section.variable format * @return boolean */ public static function checkConfig($name) { list($section_name, $variable_name) = explode('.', $name, 2); if (empty($variable_name)) { return false; } if ($section_name === 'privileges') { $value = self::getConfig($name); return $value; } if (!LMSConfig::getConfig()->hasSection($section_name)) { return false; } if (!LMSConfig::getConfig()->getSection($section_name)->hasVariable($variable_name)) { return false; } return self::checkValue(LMSConfig::getConfig()->getSection($section_name)->getVariable($variable_name)->getValue()); }
function module_submit_setup() { global $DB, $LMS; // write main configuration if ($test = $DB->GetOne("SELECT 1 FROM uiconfig WHERE section = 'userpanel' AND var = 'hint'")) { $DB->Execute("UPDATE uiconfig SET value = ? WHERE section = 'userpanel' AND var = 'hint'", array($_POST['hint'])); } else { $DB->Execute("INSERT INTO uiconfig (section, var, value) VALUES('userpanel', 'hint', ?)", array($_POST['hint'])); } if ($DB->GetOne("SELECT 1 FROM uiconfig WHERE section = 'userpanel' AND var = 'style'")) { $DB->Execute("UPDATE uiconfig SET value = ? WHERE section = 'userpanel' AND var = 'style'", array($_POST['style'])); } else { $DB->Execute("INSERT INTO uiconfig (section, var, value) VALUES('userpanel', 'style', ?)", array($_POST['style'])); } if ($DB->GetOne("SELECT 1 FROM uiconfig WHERE section = 'userpanel' AND var = 'hide_nodes_modules'")) { $DB->Execute("UPDATE uiconfig SET value = ? WHERE section = 'userpanel' AND var = 'hide_nodes_modules'", array(isset($_POST['hide_nodes_modules']) ? 1 : 0)); } else { $DB->Execute("INSERT INTO uiconfig (section, var, value) VALUES('userpanel', 'hide_nodes_modules', ?)", array(isset($_POST['hide_nodes_modules']) ? 1 : 0)); } if ($DB->GetOne("SELECT 1 FROM uiconfig WHERE section = 'userpanel' AND var = 'reminder_mail_sender'")) { $DB->Execute("UPDATE uiconfig SET value = ? WHERE section = 'userpanel' AND var = 'reminder_mail_sender'", array($_POST['reminder_mail_sender'])); } else { $DB->Execute("INSERT INTO uiconfig (section, var, value) VALUES('userpanel', 'reminder_mail_sender', ?)", array($_POST['reminder_mail_sender'])); } if ($DB->GetOne("SELECT 1 FROM uiconfig WHERE section = 'userpanel' AND var = 'reminder_mail_subject'")) { $DB->Execute("UPDATE uiconfig SET value = ? WHERE section = 'userpanel' AND var = 'reminder_mail_subject'", array($_POST['reminder_mail_subject'])); } else { $DB->Execute("INSERT INTO uiconfig (section, var, value) VALUES('userpanel', 'reminder_mail_subject', ?)", array($_POST['reminder_mail_subject'])); } if ($DB->GetOne("SELECT 1 FROM uiconfig WHERE section = 'userpanel' AND var = 'reminder_mail_body'")) { $DB->Execute("UPDATE uiconfig SET value = ? WHERE section = 'userpanel' AND var = 'reminder_mail_body'", array($_POST['reminder_mail_body'])); } else { $DB->Execute("INSERT INTO uiconfig (section, var, value) VALUES('userpanel', 'reminder_mail_body', ?)", array($_POST['reminder_mail_body'])); } if ($DB->GetOne("SELECT 1 FROM uiconfig WHERE section = 'userpanel' AND var = 'reminder_sms_body'")) { $DB->Execute("UPDATE uiconfig SET value = ? WHERE section = 'userpanel' AND var = 'reminder_sms_body'", array($_POST['reminder_sms_body'])); } else { $DB->Execute("INSERT INTO uiconfig (section, var, value) VALUES('userpanel', 'reminder_sms_body', ?)", array($_POST['reminder_sms_body'])); } LMSConfig::getConfig(array('force' => true, 'force_ui_only' => true)); module_setup(); }
function invoice_main_form_fill($x, $y, $scale) { global $pdf, $invoice; $finances = LMSConfig::getConfig()->getSection('finances'); $pdf->setlinestyle(1); $pdf->line(7 * $scale + $x, 724 * $scale + $y, 7 * $scale + $x, 694 * $scale + $y); $pdf->line(7 * $scale + $x, 724 * $scale + $y, 37 * $scale + $x, 724 * $scale + $y); $pdf->line(970 * $scale + $x, 724 * $scale + $y, 970 * $scale + $x, 694 * $scale + $y); $pdf->line(970 * $scale + $x, 724 * $scale + $y, 940 * $scale + $x, 724 * $scale + $y); $pdf->line(7 * $scale + $x, 172 * $scale + $y, 7 * $scale + $x, 202 * $scale + $y); $pdf->line(7 * $scale + $x, 172 * $scale + $y, 37 * $scale + $x, 172 * $scale + $y); text_autosize(15 * $scale + $x, 680 * $scale + $y, 30 * $scale, iconv("UTF-8", "ISO-8859-2", $finances->getVariable('name')->getValue()), 950 * $scale); text_autosize(15 * $scale + $x, 617 * $scale + $y, 30 * $scale, iconv("UTF-8", "ISO-8859-2", $finances->getVariable('address')->getValue() . " " . $finances->getVariable('zip')->getValue() . " " . $finances->getVariable('city')->getValue()), 950 * $scale); text_autosize(15 * $scale + $x, 555 * $scale + $y, 30 * $scale, iconv("UTF-8", "ISO-8859-2", $finances->getVariable('account')->getValue()), 950 * $scale); $pdf->addtext(330 * $scale + $x, 495 * $scale + $y, 30 * $scale, 'X'); text_autosize(550 * $scale + $x, 495 * $scale + $y, 30 * $scale, "*" . number_format($invoice['total'], 2, ',', '') . "*", 400 * $scale); text_autosize(15 * $scale + $x, 434 * $scale + $y, 30 * $scale, iconv("UTF-8", "ISO-8859-2", trans('$a dollars $b cents', to_words(floor($invoice['total'])), to_words(round(($invoice['total'] - floor($invoice['total'])) * 100)))), 950 * $scale); text_autosize(15 * $scale + $x, 372 * $scale + $y, 30 * $scale, iconv("UTF-8", "ISO-8859-2", $invoice['name']), 950 * $scale); text_autosize(15 * $scale + $x, 312 * $scale + $y, 30 * $scale, iconv("UTF-8", "ISO-8859-2", $invoice['address'] . " " . $invoice['zip'] . " " . $invoice['city']), 950 * $scale); $tmp = docnumber($invoice['number'], $invoice['template'], $invoice['cdate']); text_autosize(15 * $scale + $x, 250 * $scale + $y, 30 * $scale, iconv("UTF-8", "ISO-8859-2", trans('Payment for invoice No. $a', $tmp)), 950 * $scale); }
// can't working without database die("Fatal error: cannot connect to database!" . PHP_EOL); } $host = ConfigHelper::getConfig($config_section . '.smtp_host'); $port = ConfigHelper::getConfig($config_section . '.smtp_port'); $user = ConfigHelper::getConfig($config_section . '.smtp_user'); $pass = ConfigHelper::getConfig($config_section . '.smtp_pass'); $auth = ConfigHelper::getConfig($config_section . '.smtp_auth'); $debug_email = ConfigHelper::getConfig($config_section . '.debug_email', ''); $mail_from = ConfigHelper::getConfig($config_section . '.mailfrom', ''); $mail_fname = ConfigHelper::getConfig($config_section . '.mailfname', ''); $notify_email = ConfigHelper::getConfig($config_section . '.notify_email', ''); $debug_phone = ConfigHelper::getConfig($config_section . '.debug_phone', ''); $script_service = ConfigHelper::getConfig($config_section . '.service', ''); if ($script_service) { LMSConfig::getConfig()->getSection('sms')->addVariable(new ConfigVariable('service', $script_service)); } // contracts - contracts being finished some day before notify // debtors - debtors notify // reminder - reminder notify // invoices - new invoice notify // notes - new debit note notify // warnings - send message to customers with warning flag set for node // messages - send message to customers which have awaiting www messages $notifications = array(); foreach (array('contracts', 'debtors', 'reminder', 'invoices', 'notes', 'warnings', 'messages') as $type) { $notifications[$type] = array(); $notifications[$type]['limit'] = intval(ConfigHelper::getConfig($config_section . '.' . $type . '_limit', 0)); $notifications[$type]['message'] = ConfigHelper::getConfig($config_section . '.' . $type . '_message', $type . ' notification'); $notifications[$type]['subject'] = ConfigHelper::getConfig($config_section . '.' . $type . '_subject', $type . ' notification'); $notifications[$type]['days'] = intval(ConfigHelper::getConfig($config_section . '.' . $type . '_days', 0));
function module_submit_setup() { global $DB, $LMS; if (empty($_POST)) { module_setup(); return; } // write main configuration if ($test = $DB->GetOne("SELECT 1 FROM uiconfig WHERE section = 'userpanel' AND var = 'hint'")) { $DB->Execute("UPDATE uiconfig SET value = ? WHERE section = 'userpanel' AND var = 'hint'", array($_POST['hint'])); } else { $DB->Execute("INSERT INTO uiconfig (section, var, value) VALUES('userpanel', 'hint', ?)", array($_POST['hint'])); } if ($DB->GetOne("SELECT 1 FROM uiconfig WHERE section = 'userpanel' AND var = 'style'")) { $DB->Execute("UPDATE uiconfig SET value = ? WHERE section = 'userpanel' AND var = 'style'", array($_POST['style'])); } else { $DB->Execute("INSERT INTO uiconfig (section, var, value) VALUES('userpanel', 'style', ?)", array($_POST['style'])); } if ($DB->GetOne("SELECT 1 FROM uiconfig WHERE section = 'userpanel' AND var = 'hide_nodes_modules'")) { $DB->Execute("UPDATE uiconfig SET value = ? WHERE section = 'userpanel' AND var = 'hide_nodes_modules'", array(isset($_POST['hide_nodes_modules']) ? 1 : 0)); } else { $DB->Execute("INSERT INTO uiconfig (section, var, value) VALUES('userpanel', 'hide_nodes_modules', ?)", array(isset($_POST['hide_nodes_modules']) ? 1 : 0)); } if ($DB->GetOne("SELECT 1 FROM uiconfig WHERE section = 'userpanel' AND var = 'reminder_mail_sender'")) { $DB->Execute("UPDATE uiconfig SET value = ? WHERE section = 'userpanel' AND var = 'reminder_mail_sender'", array($_POST['reminder_mail_sender'])); } else { $DB->Execute("INSERT INTO uiconfig (section, var, value) VALUES('userpanel', 'reminder_mail_sender', ?)", array($_POST['reminder_mail_sender'])); } if ($DB->GetOne("SELECT 1 FROM uiconfig WHERE section = 'userpanel' AND var = 'reminder_mail_subject'")) { $DB->Execute("UPDATE uiconfig SET value = ? WHERE section = 'userpanel' AND var = 'reminder_mail_subject'", array($_POST['reminder_mail_subject'])); } else { $DB->Execute("INSERT INTO uiconfig (section, var, value) VALUES('userpanel', 'reminder_mail_subject', ?)", array($_POST['reminder_mail_subject'])); } if ($DB->GetOne("SELECT 1 FROM uiconfig WHERE section = 'userpanel' AND var = 'reminder_mail_body'")) { $DB->Execute("UPDATE uiconfig SET value = ? WHERE section = 'userpanel' AND var = 'reminder_mail_body'", array($_POST['reminder_mail_body'])); } else { $DB->Execute("INSERT INTO uiconfig (section, var, value) VALUES('userpanel', 'reminder_mail_body', ?)", array($_POST['reminder_mail_body'])); } if ($DB->GetOne("SELECT 1 FROM uiconfig WHERE section = 'userpanel' AND var = 'page_header'")) { $DB->Execute("UPDATE uiconfig SET value = ? WHERE section = 'userpanel' AND var = 'page_header'", array($_POST['page_header'])); } else { $DB->Execute("INSERT INTO uiconfig (section, var, value) VALUES('userpanel', 'page_header', ?)", array($_POST['page_header'])); } if ($DB->GetOne("SELECT 1 FROM uiconfig WHERE section = 'userpanel' AND var = 'company_logo'")) { $DB->Execute("UPDATE uiconfig SET value = ? WHERE section = 'userpanel' AND var = 'company_logo'", array($_POST['company_logo'])); } else { $DB->Execute("INSERT INTO uiconfig (section, var, value) VALUES('userpanel', 'company_logo', ?)", array($_POST['company_logo'])); } if ($DB->GetOne("SELECT 1 FROM uiconfig WHERE section = 'userpanel' AND var = 'reminder_sms_body'")) { $DB->Execute("UPDATE uiconfig SET value = ? WHERE section = 'userpanel' AND var = 'reminder_sms_body'", array($_POST['reminder_sms_body'])); } else { $DB->Execute("INSERT INTO uiconfig (section, var, value) VALUES('userpanel', 'reminder_sms_body', ?)", array($_POST['reminder_sms_body'])); } if ($DB->GetOne("SELECT 1 FROM uiconfig WHERE section = 'userpanel' AND var = 'auth_type'")) { $DB->Execute("UPDATE uiconfig SET value = ? WHERE section = 'userpanel' AND var = 'auth_type'", array($_POST['auth_type'])); } else { $DB->Execute("INSERT INTO uiconfig (section, var, value) VALUES('userpanel', 'auth_type', ?)", array($_POST['auth_type'])); } if ($DB->GetOne("SELECT 1 FROM uiconfig WHERE section = 'userpanel' AND var = 'force_ssl'")) { $DB->Execute("UPDATE uiconfig SET value = ? WHERE section = 'userpanel' AND var = 'force_ssl'", array(isset($_POST['force_ssl']) ? 1 : 0)); } else { $DB->Execute("INSERT INTO uiconfig (section, var, value) VALUES('userpanel', 'force_ssl', ?)", array(isset($_POST['force_ssl']) ? 1 : 0)); } if (isset($_POST['enabled_modules'])) { $enabled_modules = implode(',', array_keys($_POST['enabled_modules'])); } else { $enabled_modules = ''; } if ($DB->GetOne("SELECT 1 FROM uiconfig WHERE section = 'userpanel' AND var = 'enabled_modules'")) { $DB->Execute("UPDATE uiconfig SET value = ? WHERE section = 'userpanel' AND var = 'enabled_modules'", array($enabled_modules)); } else { $DB->Execute("INSERT INTO uiconfig (section, var, value) VALUES('userpanel', 'enabled_modules', ?)", array($enabled_modules)); } LMSConfig::getConfig(array('force' => true, 'force_ui_only' => true)); module_setup(); }
// Check privileges and execute modules if ($AUTH->islogged) { // Load plugin files and register hook callbacks $plugins = preg_split('/[;,\\s\\t\\n]+/', ConfigHelper::getConfig('phpui.plugins'), -1, PREG_SPLIT_NO_EMPTY); if (!empty($plugins)) { foreach ($plugins as $plugin_name) { if (is_readable(LIB_DIR . '/plugins/' . $plugin_name . '.php')) { require LIB_DIR . '/plugins/' . $plugin_name . '.php'; } } } $res = $LMS->ExecHook('access_table_init', array('accesstable' => $access['table'])); if (isset($res['accesstable'])) { $access['table'] = $res['accesstable']; } LMSConfig::getConfig(array('force' => true, 'force_user_rights_only' => true, 'access_table' => $access['table'], 'user_id' => $AUTH->id)); $module = isset($_GET['m']) ? preg_replace('/[^a-zA-Z0-9_-]/', '', $_GET['m']) : ''; $deny = $allow = FALSE; $res = $LMS->ExecHook('module_load_before', array('module' => $module)); if ($res['abort']) { $SESSION->close(); $DB->Destroy(); die; } $module = $res['module']; if ($AUTH->passwdrequiredchange) { $module = 'chpasswd'; } if ($module == '') { $module = ConfigHelper::getConfig('phpui.default_module'); }
$documents_dirs = array(DOC_DIR); $documents_dirs = $plugin_manager->executeHook('documents_dir_initialized', $documents_dirs); // Check privileges and execute modules if ($AUTH->islogged) { // Load plugin files and register hook callbacks $plugins = $plugin_manager->getAllPluginInfo(LMSPluginManager::OLD_STYLE); if (!empty($plugins)) { foreach ($plugins as $plugin_name => $plugin) { if ($plugin['enabled']) { require LIB_DIR . DIRECTORY_SEPARATOR . 'plugins' . DIRECTORY_SEPARATOR . $plugin_name . '.php'; } } } $LMS->ExecHook('access_table_init'); $LMS->executeHook('access_table_initialized'); LMSConfig::getConfig(array('force' => true, 'force_user_rights_only' => true, 'user_id' => $AUTH->id)); $module = isset($_GET['m']) ? preg_replace('/[^a-zA-Z0-9_-]/', '', $_GET['m']) : ''; $deny = $allow = FALSE; $res = $LMS->ExecHook('module_load_before', array('module' => $module)); if (array_key_exists('abort', $res) && $res['abort']) { $SESSION->close(); $DB->Destroy(); die; } $module = $res['module']; if ($AUTH->passwdrequiredchange) { $module = 'chpasswd'; } if ($module == '') { $module = ConfigHelper::getConfig('phpui.default_module'); }
/** * Returns merged ini and ui configs * * Avaliable options are: * force - forces to reload whole ini config * ini_file_path - path to ini file * ui_merge_priority - ui merge priority * ini_merge_priority - ini merge priority * * @param array $options Associative array of options * @return ConfigContainer Config */ public static function getConfig(array $options = array()) { $force = isset($options['force']) ? $options['force'] : false; if ($force || self::$config === null) { self::$config = self::mergeConfigs($options); } return self::$config; }