Example #1
0
 /**
  * @param $output
  * @return string
  */
 protected function addInfiniteScroll($output)
 {
     if (($config = $this->configHelper->getInfiniteScroll()) !== false) {
         $output = $output . $this->infiniteScroll->getJs($config);
     }
     return $output;
 }
 /**
  * Constructor
  *
  * @param AnalyticsOverview $overview
  *
  * @return array
  */
 protected function getTimestamps(AnalyticsOverview &$overview)
 {
     // if yearoverview set the begin time to the first day of this year
     $profileStartDate = explode('T', $this->configHelper->getActiveProfile()['created'])[0];
     if ($overview->getUseYear()) {
         $begin_date = date('Y-m-d', mktime(0, 0, 0, 1, 1, date('Y')));
         $begin = strtotime($profileStartDate) > strtotime($begin_date) ? date('Y-m-d', strtotime($profileStartDate)) : $begin_date;
     } else {
         // check if timespan is't more than existence of the profile; if so, use the creation time in stead of the timespan time
         $begin = strtotime($profileStartDate) > strtotime('-' . $overview->getTimespan() . ' days') ? date('Y-m-d', strtotime($profileStartDate)) : date('Y-m-d', strtotime('-' . $overview->getTimespan() . ' days'));
     }
     // set the end time
     $end = date('Y-m-d', strtotime('-' . $overview->getStartOffset() . ' days'));
     return array('begin' => $begin, 'end' => $end);
 }
Example #3
0
function MessageAdd($msg, $headers, $files = NULL)
{
    global $DB, $LMS;
    $time = time();
    $head = '';
    if ($headers) {
        foreach ($headers as $idx => $header) {
            $head .= $idx . ": " . $header . "\n";
        }
    }
    $DB->Execute('INSERT INTO rtmessages (ticketid, createtime, subject, body, userid, customerid, mailfrom, inreplyto, messageid, replyto, headers)
			VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)', array($msg['ticketid'], $time, $msg['subject'], preg_replace("/\r/", "", $msg['body']), $msg['userid'], $msg['customerid'], $msg['mailfrom'], $msg['inreplyto'], $msg['messageid'], isset($msg['replyto']) ? $msg['replyto'] : $headers['Reply-To'], $head));
    $mail_dir = ConfigHelper::getConfig('rt.mail_dir');
    if (!empty($files) && !empty($mail_dir)) {
        $id = $DB->GetLastInsertId('rtmessages');
        $dir = $mail_dir . sprintf('/%06d/%06d', $msg['ticketid'], $id);
        @mkdir($mail_dir . sprintf('/%06d', $msg['ticketid']), 0700);
        @mkdir($dir, 0700);
        foreach ($files as $file) {
            $newfile = $dir . '/' . $file['name'];
            if (@rename($file['tmp_name'], $newfile)) {
                $DB->Execute('INSERT INTO rtattachments (messageid, filename, contenttype) 
						VALUES (?,?,?)', array($id, $file['name'], $file['type']));
            }
        }
    }
}
Example #4
0
function invoice_body()
{
    global $invoice, $pdf;
    if (isset($invoice['invoice'])) {
        $template = ConfigHelper::getConfig('invoices.cnote_template_file');
    } else {
        $template = ConfigHelper::getConfig('invoices.template_file');
    }
    switch ($template) {
        case "standard":
            invoice_body_standard();
            break;
        case "FT-0100":
            invoice_body_ft0100();
            break;
        default:
            if (file_exists($template)) {
                require $template;
            } else {
                //go to LMS modules directory
                require MODULES_DIR . '/' . $template;
            }
    }
    if (!isset($invoice['last'])) {
        new_page();
    }
}
Example #5
0
 public function note_recipient()
 {
     $oldy = $this->backend->GetY();
     $recipient = '<b>' . trans('Note recipient:') . '</b><br>';
     $recipient .= $this->data['name'] . '<br>';
     $recipient .= $this->data['address'] . '<br>';
     $recipient .= $this->data['zip'] . ' ' . $this->data['city'] . '<br>';
     if ($this->data['ten']) {
         $recipient .= trans('TEN') . ': ' . $this->data['ten'] . '<br>';
     } elseif ($this->data['ssn']) {
         $recipient .= trans('SSN') . ': ' . $this->data['ssn'] . '<br>';
     }
     $this->backend->SetFont('arial', '', 10);
     $this->backend->writeHTMLCell(80, '', 125, 50, $recipient, 0, 1, 0, true, 'L');
     $y = $this->backend->GetY();
     if (ConfigHelper::checkValue(ConfigHelper::getConfig('invoices.customer_bankaccount', true))) {
         $bankaccount = trans('Bank account:') . ' <b>' . format_bankaccount(bankaccount($this->data['customerid'], $this->data['account'])) . '</b>';
         $this->backend->SetFont('arial', 'B', 8);
         $this->backend->writeHTMLCell('', '', 125, $oldy + round(($y - $oldy - 8) / 2), $bankaccount, 0, 1, 0, true, 'L');
     }
     if (ConfigHelper::checkValue(ConfigHelper::getConfig('invoices.customer_credentials', true))) {
         $pin = '<b>' . trans('Customer ID: $a', sprintf('%04d', $this->data['customerid'])) . '</b><br>';
         $pin .= '<b>PIN: ' . sprintf('%04d', $this->data['customerpin']) . '</b><br>';
         $this->backend->SetFont('arial', 'B', 8);
         $this->backend->writeHTMLCell('', '', 125, $oldy + round(($y - $oldy) / 2), $pin, 0, 1, 0, true, 'L');
     }
     $this->backend->SetY($y);
 }
Example #6
0
 protected function SetLanguage($aLanguages)
 {
     if (ConfigHelper::Get('/languages/switch') == 'host') {
         $sLanguage = substr($_SERVER['SERVER_NAME'], 0, 2);
         if (array_key_exists($sLanguage, $aLanguages) && substr($_SERVER['SERVER_NAME'], 2, 1) == '.') {
             $this->sLanguage = $sLanguage;
         } else {
             $this->sLanguage = 'en';
         }
     } else {
         // check for request to change language
         // if not present check for cookie specifiying language
         // finally fall back to english
         if (isset($_GET['lang']) && array_key_exists($_GET['lang'], $aLanguages)) {
             $this->sLanguage = $_GET['lang'];
             setcookie('lang', $this->sLanguage, time() + 60 * 60 * 24 * 365, '/');
             header('Location: /');
             exit;
         } elseif (isset($_COOKIE['lang']) && array_key_exists($_COOKIE['lang'], $aLanguages)) {
             $this->sLanguage = $_COOKIE['lang'];
         } else {
             $this->sLanguage = 'en';
         }
     }
 }
Example #7
0
 protected function main_form($x, $y)
 {
     $balance = $this->data['balance'] < 0 ? -$this->data['balance'] : $this->data['balance'];
     $font_size = 14;
     $lineh = 25;
     $x += ConfigHelper::getConfig('finances.leftmargin', 0, true);
     $y += ConfigHelper::getConfig('finances.bottommargin', 0, true);
     $y += 275;
     $this->backend->addText($x, $y, $font_size, $this->data['d_name']);
     $y -= $lineh;
     $this->backend->addText($x, $y, $font_size, trim($this->data['d_zip'] . ' ' . $this->data['d_city'] . ' ' . $this->data['d_address']));
     $y -= $lineh;
     $this->backend->addText($x, $y, $font_size, format_bankaccount(bankaccount($this->data['id'], $this->data['account'])));
     $y -= $lineh;
     $this->backend->addText($x + 220, $y, $font_size, sprintf('%.2f', $balance));
     $y -= $lineh;
     $this->backend->addText($x, $y, $font_size, trans('$a dollars $b cents', to_words(floor($balance)), to_words(round(($balance - floor($balance)) * 100))));
     $y -= $lineh;
     $this->backend->addText($x, $y, $font_size, $this->truncate($this->data['customername']));
     $y -= $lineh;
     $this->backend->addText($x, $y, $font_size, $this->truncate(trim($this->data['zip'] . ' ' . $this->data['city'] . ' ' . $this->data['address'])));
     $y -= $lineh;
     $this->backend->addText($x, $y, $font_size, ConfigHelper::getConfig('finances.pay_title', trans('Not set')));
     $y -= $lineh;
     $this->backend->addText($x, $y, $font_size, trans('Customer ID: $a', sprintf('%04d', $this->data['id'])));
 }
Example #8
0
function module_setup()
{
    global $SMARTY, $DB, $USERPANEL, $layout, $LMS;
    $layout['pagetitle'] = trans('Userpanel Configuration');
    $SMARTY->assign('page_header', ConfigHelper::getConfig('userpanel.page_header', ''));
    $SMARTY->assign('company_logo', ConfigHelper::getConfig('userpanel.company_logo', ''));
    $SMARTY->assign('stylelist', getdir(USERPANEL_DIR . DIRECTORY_SEPARATOR . 'style', '^[a-z0-9]*$'));
    $SMARTY->assign('style', ConfigHelper::getConfig('userpanel.style', 'default'));
    $SMARTY->assign('hint', ConfigHelper::getConfig('userpanel.hint', 'modern'));
    $SMARTY->assign('hide_nodes_modules', ConfigHelper::getConfig('userpanel.hide_nodes_modules', 0));
    $SMARTY->assign('reminder_mail_sender', ConfigHelper::getConfig('userpanel.reminder_mail_sender', ''));
    $SMARTY->assign('reminder_mail_subject', ConfigHelper::getConfig('userpanel.reminder_mail_subject', trans('credential reminder')));
    $SMARTY->assign('reminder_mail_body', ConfigHelper::getConfig('userpanel.reminder_mail_body', "ID: %id\nPIN: %pin"));
    $SMARTY->assign('reminder_sms_body', ConfigHelper::getConfig('userpanel.reminder_sms_body', "ID: %id, PIN: %pin"));
    $SMARTY->assign('auth_type', ConfigHelper::getConfig('userpanel.auth_type', 1));
    $SMARTY->assign('force_ssl', ConfigHelper::getConfig('userpanel.force_ssl', ConfigHelper::getConfig('phpui.force_ssl', 1)));
    $enabled_modules = ConfigHelper::getConfig('userpanel.enabled_modules', null, true);
    if (is_null($enabled_modules)) {
        $enabled_modules = array();
        if (!empty($USERPANEL->MODULES)) {
            foreach ($USERPANEL->MODULES as $module) {
                $enabled_modules[] = $module['module'];
            }
        }
        $DB->Execute("INSERT INTO uiconfig (section, var, value) VALUES (?, ?, ?)", array('userpanel', 'enabled_modules', implode(',', $enabled_modules)));
    } else {
        $enabled_modules = explode(',', $enabled_modules);
    }
    $SMARTY->assign('enabled_modules', $enabled_modules);
    $SMARTY->assign('total', sizeof($USERPANEL->MODULES));
    $SMARTY->display('file:' . USERPANEL_DIR . DIRECTORY_SEPARATOR . 'templates' . DIRECTORY_SEPARATOR . 'setup.html');
}
Example #9
0
function tla_ads()
{
    // Number of seconds before connection to XML times out
    // (This can be left the way it is)
    $CONNECTION_TIMEOUT = 10;
    // Local file to store XML
    // This file MUST be writable by web server
    // You should create a blank file and CHMOD it to 666
    $LOCAL_XML_FILENAME = ConfigHelper::Get('/cache/tla/dir') . ConfigHelper::Get('/cache/tla/file');
    if (!file_exists($LOCAL_XML_FILENAME)) {
        die("Script error: {$LOCAL_XML_FILENAME} does not exist. Please create a blank file named {$LOCAL_XML_FILENAME}.");
    }
    if (!is_writable($LOCAL_XML_FILENAME)) {
        die("Script error: {$LOCAL_XML_FILENAME} is not writable. Please set write permissions on {$LOCAL_XML_FILENAME}.");
    }
    if (filemtime($LOCAL_XML_FILENAME) < time() - 3600 || filesize($LOCAL_XML_FILENAME) < 20) {
        $request_uri = isset($_SERVER['REQUEST_URI']) ? $_SERVER['REQUEST_URI'] : "";
        $user_agent = isset($_SERVER['HTTP_USER_AGENT']) ? $_SERVER['HTTP_USER_AGENT'] : "";
        tla_updateLocalXML("http://www.text-link-ads.com/xml.php?inventory_key=Z73AUCI0OTG7DAHAYCKP&referer=" . urlencode($request_uri) . "&user_agent=" . urlencode($user_agent), $LOCAL_XML_FILENAME, $CONNECTION_TIMEOUT);
    }
    $xml = tla_getLocalXML($LOCAL_XML_FILENAME);
    $arr_xml = tla_decodeXML($xml);
    if (is_array($arr_xml)) {
        echo "\n<ul id=\"text-links\">\n";
        for ($i = 0; $i < count($arr_xml['URL']); $i++) {
            if (isset($arr_xml['PostID'][$i]) && $arr_xml['PostID'][$i] > 0) {
                continue;
            }
            echo "<li>" . $arr_xml['BeforeText'][$i] . " <a href=\"" . $arr_xml['URL'][$i] . "\">" . $arr_xml['Text'][$i] . "</a> " . $arr_xml['AfterText'][$i] . "</li>\n";
        }
        echo "</ul>";
    }
}
Example #10
0
 public function WriteToBrowser($filename = null)
 {
     $this->PrepareFullContents();
     header('Content-Type: ' . ConfigHelper::getConfig($this->config_section . '.content_type'));
     if (!is_null($filename)) {
         header('Content-Disposition: inline; filename=' . $filename);
     }
     echo $this->contents;
 }
Example #11
0
 public function Draw($data)
 {
     parent::Draw($data);
     $template_file = ConfigHelper::getConfig('notes.template_file');
     if (!$this->smarty->templateExists($template_file)) {
         $template_file = 'note' . DIRECTORY_SEPARATOR . $template_file;
     }
     $this->smarty->assign('note', $this->data);
     $this->contents .= $this->smarty->fetch($template_file);
 }
Example #12
0
 function module_setup()
 {
     global $SMARTY, $LMS;
     $SMARTY->assign('disable_transferform', ConfigHelper::getConfig('userpanel.disable_transferform'));
     $SMARTY->assign('disable_invoices', ConfigHelper::getConfig('userpanel.disable_invoices'));
     $SMARTY->assign('invoice_duplicate', ConfigHelper::getConfig('userpanel.invoice_duplicate'));
     $SMARTY->assign('show_tariffname', ConfigHelper::getConfig('userpanel.show_tariffname'));
     $SMARTY->assign('show_speeds', ConfigHelper::getConfig('userpanel.show_speeds'));
     $SMARTY->display('module:finances:setup.html');
 }
Example #13
0
 public function __construct(&$DB, &$SESSION)
 {
     // ustawia zmienne klasy
     $this->DB =& $DB;
     $this->SESSION =& $SESSION;
     $module_order = ConfigHelper::getConfig('userpanel.module_order', '', true);
     if (strlen($module_order)) {
         $this->module_order = array_flip(explode(',', $module_order));
     }
 }
Example #14
0
function pngdrawtext($image, $font, $x, $y, $text, $color, $bgcolor)
{
    if (ConfigHelper::getConfig('phpui.gd_translate_to')) {
        $text = iconv('UTF-8', ConfigHelper::getConfig('phpui.gd_translate_to'), $text);
    }
    imagestring($image, $font, $x + 1, $y + 1, $text, $bgcolor);
    imagestring($image, $font, $x + 1, $y - 1, $text, $bgcolor);
    imagestring($image, $font, $x - 1, $y + 1, $text, $bgcolor);
    imagestring($image, $font, $x - 1, $y - 1, $text, $bgcolor);
    imagestring($image, $font, $x, $y, $text, $color);
}
 public function GetMenuUrl($sAppRoot, $sSection)
 {
     if ($sSection != 'home') {
         if (ConfigHelper::Get('/urls/rewritten')) {
             return $sAppRoot . "section/{$sSection}";
         } else {
             return $sAppRoot . "?view={$sSection}";
         }
     }
     return $sAppRoot;
 }
Example #16
0
 public function Draw($data)
 {
     parent::Draw($data);
     $template_file = ConfigHelper::getConfig('receipts.template_file');
     if (!$this->smarty->templateExists('file:' . $template_file)) {
         $template_file = 'receipt' . DIRECTORY_SEPARATOR . $template_file;
     }
     $this->smarty->assign('type', $this->data['which']);
     $this->smarty->assign('receipt', $this->data);
     $this->contents .= $this->smarty->fetch('file:' . $template_file);
 }
Example #17
0
function module_get_timestamp($tpl_name, &$tpl_timestamp, $smarty_obj)
{
    global $LMS;
    $template = explode(':', $tpl_name);
    $template_path = ConfigHelper::getConfig('directories.userpanel_dir') . '/modules/' . $template[0] . '/templates/' . $template[1];
    if (file_exists($template_path)) {
        $tpl_timestamp = filectime($template_path);
        return true;
    } else {
        return false;
    }
}
 public function smartyCashImportOKBS(Smarty $hook_data)
 {
     $template_dirs = $hook_data->getTemplateDir();
     $plugin_templates = PLUGINS_DIR . DIRECTORY_SEPARATOR . LMSCustomersAgePlugin::PLUGIN_DIRECTORY_NAME . DIRECTORY_SEPARATOR . 'templates';
     $custom_templates_dir = ConfigHelper::getConfig('phpui.custom_templates_dir');
     if (!empty($custom_templates_dir) && file_exists($plugin_templates . DIRECTORY_SEPARATOR . $custom_templates_dir) && !is_file($plugin_tempaltes . DIRECTORY_SEPARATOR . $custom_templates_dir)) {
         $plugin_templates = PLUGINS_DIR . DIRECTORY_SEPARATOR . LMSCustomersAgePlugin::PLUGIN_DIRECTORY_NAME . DIRECTORY_SEPARATOR . 'templates' . DIRECTORY_SEPARATOR . $custom_templates_dir;
     }
     array_unshift($template_dirs, $plugin_templates);
     $hook_data->setTemplateDir($template_dirs);
     return $hook_data;
 }
Example #19
0
 /**
  * Get imap configuration
  */
 private function _getConfig()
 {
     $config = ConfigHelper::getImapConfig();
     $this->hostname = $config->imap_host;
     $this->username = $config->imap_user;
     $this->password = $config->imap_pass;
     // Validate config
     if (strlen($this->hostname) == 0 || strlen($this->username) == 0 || strlen($this->password) == 0) {
         return false;
     } else {
         return true;
     }
 }
Example #20
0
 /**
  * Loads plugins
  *
  * @throws Exception Throws exception if plugin not found
  */
 public function __construct()
 {
     $dirs = getdir(PLUGINS_DIR, '^[0-9a-zA-Z]+$');
     if (empty($dirs)) {
         return;
     }
     asort($dirs);
     $plugins_config = ConfigHelper::getConfig('phpui.plugins');
     $plugins_tuples = empty($plugins_config) ? array() : preg_split('/[;,\\s\\t\\n]+/', $plugins_config, -1, PREG_SPLIT_NO_EMPTY);
     $plugin_priorities = array();
     foreach ($plugins_tuples as $idx => $plugin_tuple) {
         $plugin_props = explode(':', $plugin_tuple);
         $plugin_priorities[$plugin_props[0]] = count($plugin_props) == 2 ? intval($plugin_props[1]) : SubjectInterface::LAST_PRIORITY;
         $plugins_tuples[$idx] = $plugin_props[0];
     }
     foreach ($dirs as $plugin_name) {
         if (class_exists($plugin_name)) {
             $plugin_name::loadLocales();
             $plugin_info = array('name' => $plugin_name, 'enabled' => false, 'new_style' => true, 'dbcurrschversion' => null, 'dbschversion' => defined($plugin_name . '::PLUGIN_DBVERSION') ? constant($plugin_name . '::PLUGIN_DBVERSION') : null, 'fullname' => defined($plugin_name . '::PLUGIN_NAME') ? trans(constant($plugin_name . '::PLUGIN_NAME')) : null, 'description' => defined($plugin_name . '::PLUGIN_DESCRIPTION') ? trans(constant($plugin_name . '::PLUGIN_DESCRIPTION')) : null, 'author' => defined($plugin_name . '::PLUGIN_AUTHOR') ? constant($plugin_name . '::PLUGIN_AUTHOR') : null);
             if (array_key_exists($plugin_name, $plugin_priorities)) {
                 $plugin = new $plugin_name();
                 if (!$plugin instanceof LMSPlugin) {
                     throw new Exception("Plugin object must be instance of LMSPlugin class");
                 }
                 $plugin_info = array_merge($plugin_info, array('enabled' => true, 'priority' => $plugin_priorities[$plugin_name], 'dbcurrschversion' => $plugin->getDbSchemaVersion()));
                 $this->registerObserver($plugin, $plugin_info['priority']);
             }
             $this->new_style_plugins[$plugin_name] = $plugin_info;
         } else {
             writesyslog("Unknown plugin {$plugin_name} at position {$position}", LOG_ERR);
             continue;
         }
     }
     $files = getdir(LIB_DIR . DIRECTORY_SEPARATOR . 'plugins', '^[0-9a-zA-Z_\\-]+\\.php$');
     if (empty($files)) {
         return;
     }
     asort($files);
     $old_plugins = array_diff($plugins_tuples, array_keys($this->new_style_plugins));
     foreach ($files as $plugin_name) {
         if (!is_readable(LIB_DIR . DIRECTORY_SEPARATOR . 'plugins' . DIRECTORY_SEPARATOR . $plugin_name)) {
             continue;
         }
         $plugin_name = str_replace('.php', '', $plugin_name);
         $plugin_info = array('name' => $plugin_name, 'enabled' => false, 'new_style' => false);
         if (array_key_exists($plugin_name, $plugin_priorities)) {
             $plugin_info['enabled'] = true;
         }
         $this->old_style_plugins[$plugin_name] = $plugin_info;
     }
 }
Example #21
0
function DBLoad($filename = NULL)
{
    global $DB, $SYSLOG;
    if (!$filename) {
        return FALSE;
    }
    $finfo = pathinfo($filename);
    $ext = $finfo['extension'];
    if ($ext == 'gz' && extension_loaded('zlib')) {
        $file = gzopen($filename, 'r');
    } else {
        $file = fopen($filename, 'r');
    }
    if (!$file) {
        return FALSE;
    }
    $DB->BeginTrans();
    // przyspieszmy działanie jeżeli baza danych obsługuje transakcje
    while (!feof($file)) {
        $line = fgets($file, 8192);
        if ($line != '') {
            $line = str_replace(";\n", '', $line);
            $DB->Execute($line);
        }
    }
    $DB->CommitTrans();
    if (extension_loaded('zlib') && $ext == 'gz') {
        gzclose($file);
    } else {
        fclose($file);
    }
    // Okej, zróbmy parę bzdurek db depend :S
    // Postgres sux ! (warden)
    // Tak, a łyżka na to 'niemożliwe' i poleciała za wanną potrącając bannanem musztardę (lukasz)
    switch (ConfigHelper::getConfig('database.type')) {
        case 'postgres':
            // actualize postgres sequences ...
            foreach ($DB->ListTables() as $tablename) {
                // ... where we have *_id_seq
                if (!in_array($tablename, array('rtattachments', 'dbinfo', 'invoicecontents', 'receiptcontents', 'documentcontents', 'stats', 'eventassignments', 'sessions'))) {
                    $DB->Execute("SELECT setval('" . $tablename . "_id_seq',max(id)) FROM " . $tablename);
                }
            }
            break;
    }
    if ($SYSLOG) {
        $SYSLOG->AddMessage(SYSLOG_RES_DBBACKUP, SYSLOG_OPER_DBBACKUPRECOVER, array('filename' => $filename), null);
    }
}
Example #22
0
function module_setup()
{
    global $SMARTY, $DB, $USERPANEL, $layout, $LMS;
    $layout['pagetitle'] = trans('Userpanel Configuration');
    $SMARTY->assign('stylelist', getdir(USERPANEL_DIR . '/style', '^[a-z0-9]*$'));
    $SMARTY->assign('style', ConfigHelper::getConfig('userpanel.style', 'default'));
    $SMARTY->assign('hint', ConfigHelper::getConfig('userpanel.hint', 'modern'));
    $SMARTY->assign('hide_nodes_modules', ConfigHelper::getConfig('userpanel.hide_nodes_modules', 0));
    $SMARTY->assign('reminder_mail_sender', ConfigHelper::getConfig('userpanel.reminder_mail_sender', ''));
    $SMARTY->assign('reminder_mail_subject', ConfigHelper::getConfig('userpanel.reminder_mail_subject', trans('credential reminder')));
    $SMARTY->assign('reminder_mail_body', ConfigHelper::getConfig('userpanel.reminder_mail_body', "ID: %id\nPIN: %pin"));
    $SMARTY->assign('reminder_sms_body', ConfigHelper::getConfig('userpanel.reminder_sms_body', "ID: %id, PIN: %pin"));
    $SMARTY->assign('total', sizeof($USERPANEL->MODULES));
    $SMARTY->display(USERPANEL_DIR . '/templates/setup.html');
}
Example #23
0
    public function GetCustomerTickets($id)
    {
        $queues = array();
        if (ConfigHelper::getConfig('userpanel.tickets_from_selected_queues')) {
            $queues = $this->DB->GetCol('SELECT id FROM rtqueues
				WHERE id IN (' . str_replace(';', ',', ConfigHelper::getConfig('userpanel.queues')) . ')');
        }
        $tickets = $this->DB->GetAll('SELECT * FROM rttickets WHERE customerid=?' . (isset($queues) && !empty($queues) ? ' AND queueid IN (' . implode(',', $queues) . ')' : '') . ' ORDER BY createtime DESC', array($id));
        if (!empty($tickets)) {
            foreach ($tickets as $idx => $ticket) {
                $tickets[$idx]['queuename'] = $this->DB->GetOne('SELECT name FROM rtqueues WHERE id = ?', array($ticket['queueid']));
            }
        }
        return $tickets;
    }
Example #24
0
function GetDomainList($order = 'name,asc', $customer = '', $filtr = '')
{
    global $DB;
    list($order, $direction) = sscanf($order, '%[^,],%s');
    $direction != 'desc' ? $direction = 'asc' : ($direction = 'desc');
    switch ($order) {
        case 'id':
            $sqlord = " ORDER BY d.id {$direction}";
            break;
        case 'description':
            $sqlord = " ORDER BY d.description {$direction}";
            break;
        case 'customer':
            $sqlord = " ORDER BY customername {$direction}";
            break;
        case 'type':
            $sqlord = " ORDER BY type {$direction}";
            break;
        default:
            $sqlord = " ORDER BY d.name {$direction}";
            break;
    }
    if ($filtr == '0-9') {
        if (ConfigHelper::getConfig('database.type') == 'postgres') {
            $where[] = "d.name ~ '^[0-9]'";
        } else {
            $where[] = "d.name REGEXP '^[0-9]'";
        }
    } else {
        if ($filtr) {
            $filtr = substr($filtr, 0, 1);
            $where[] = 'd.name ?LIKE? ' . $DB->Escape("{$filtr}%");
        }
    }
    if ($customer != '') {
        $where[] = 'd.ownerid = ' . intval($customer);
    }
    $where = !empty($where) ? ' WHERE ' . implode(' AND ', $where) : '';
    $list = $DB->GetAll('SELECT d.id AS id, d.name AS name, d.description, 
		d.ownerid, d.type, (SELECT COUNT(*) FROM passwd WHERE domainid = d.id) AS cnt, ' . $DB->Concat('lastname', "' '", 'c.name') . ' AS customername 
		FROM domains d
		LEFT JOIN customers c ON (d.ownerid = c.id)' . $where . ($sqlord != '' ? $sqlord : ''));
    $list['total'] = sizeof($list);
    $list['order'] = $order;
    $list['direction'] = $direction;
    $list['customer'] = $customer;
    return $list;
}
Example #25
0
 /**
  * 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;
 }
Example #26
0
 public function Draw($data)
 {
     parent::Draw($data);
     if (isset($this->data['invoice'])) {
         $template_file = ConfigHelper::getConfig('invoices.cnote_template_file');
     } else {
         $template_file = ConfigHelper::getConfig('invoices.template_file');
     }
     if (!$this->smarty->templateExists('file:' . $template_file)) {
         $template_file = 'invoice' . DIRECTORY_SEPARATOR . $template_file;
     }
     $this->smarty->assign('type', $this->data['type']);
     $this->smarty->assign('duplicate', $this->data['type'] == trans('DUPLICATE'));
     $this->smarty->assign('invoice', $this->data);
     $this->contents .= $this->smarty->fetch('file:' . $template_file);
 }
 /**
  * Fetch a template's modification time from database
  *
  * @note implementing this method is optional. Only implement it if modification times can be accessed faster than loading the comple template source.
  * @param string $name template name
  * @return integer timestamp (epoch) the template was modified
  */
 protected function fetchTimestamp($name)
 {
     global $module_dir;
     $module = $_GET['m'];
     $style = ConfigHelper::getConfig('userpanel.style', 'default');
     $template_path = $module_dir . $module . DIRECTORY_SEPARATOR . 'style' . DIRECTORY_SEPARATOR . $style . DIRECTORY_SEPARATOR . 'templates' . DIRECTORY_SEPARATOR . $name;
     if (file_exists($template_path)) {
         return filectime($template_path);
     } else {
         $template_path = $module_dir . $module . DIRECTORY_SEPARATOR . 'templates' . DIRECTORY_SEPARATOR . $name;
         if (file_exists($template_path)) {
             return filectime($template_path);
         } else {
             return 0;
         }
     }
 }
Example #28
0
 public function Draw($data)
 {
     parent::Draw($data);
     if (isset($this->data['invoice'])) {
         $template = ConfigHelper::getConfig('invoices.cnote_template_file');
     } else {
         $template = ConfigHelper::getConfig('invoices.template_file');
     }
     switch ($template) {
         case "standard":
             $this->invoice_body_standard();
             break;
         case "FT-0100":
             $this->invoice_body_ft0100();
             break;
     }
 }
Example #29
0
 public function Footer()
 {
     $cur_y = $this->y;
     $this->SetTextColor(0, 0, 0);
     $line_width = 0.85 / $this->k;
     $this->SetLineStyle(array('width' => $line_width, 'cap' => 'butt', 'join' => 'miter', 'dash' => 0, 'color' => array(0, 0, 0)));
     /* print barcode with invoice number in footer */
     $barcode = $this->getBarcode();
     if (!empty($barcode) && ConfigHelper::getConfig('invoices.template_file') == 'standard') {
         $this->Ln($line_width);
         $style = array('position' => 'L', 'align' => 'L', 'stretch' => false, 'fitwidth' => true, 'cellfitalign' => '', 'border' => false, 'padding' => 0, 'fgcolor' => array(0, 0, 0), 'bgcolor' => false, 'text' => true, 'font' => 'times', 'fontsize' => 6, 'stretchtext' => 0);
         $this->write1DBarcode($barcode, 'C128', '', $cur_y + $line_width - 0.25, '', $this->footer_margin - 2, 0.3, $style, '');
         /* draw line */
         $this->SetY($cur_y);
         $this->SetX($this->original_rMargin);
         $this->Cell(0, 0, '', array('T' => array('width' => 0.1)), 0, 'L');
     }
 }
Example #30
0
 /**
  * Loads plugins
  * 
  * @throws Exception Throws exception if plugin not found
  */
 public function __construct()
 {
     $plugins_config = ConfigHelper::getConfig('phpui.plugins');
     if ($plugins_config) {
         $plugins_tuples = explode(';', $plugins_config);
         foreach ($plugins_tuples as $position => $plugin_tuple) {
             list($plugin_name, $plugin_priority) = explode(":", $plugin_tuple);
             if (!class_exists($plugin_name)) {
                 throw new Exception("Unknown plugin {$plugin_name} at position {$position}");
             }
             $plugin = new $plugin_name();
             if (!$plugin instanceof LMSPlugin) {
                 throw new Exception("Plugin object must be instance of LMSPlugin class");
             }
             if ($plugin_priority === null) {
                 $plugin_priority = SubjectInterface::LAST_PRIORITY;
             }
             $this->registerObserver($plugin, $plugin_priority);
         }
     }
 }