public function note_drawer() { $this->backend->SetFont('arial', '', 10); $drawer = '<b>' . trans('Note drawer:') . '</b><br>'; $tmp = $this->data['division_header']; $accounts = array(bankaccount($this->data['customerid'], $this->data['account'])); if (ConfigHelper::checkConfig('invoices.show_all_accounts')) { $accounts = array_merge($accounts, $this->data['bankaccounts']); } foreach ($accounts as &$account) { $account = format_bankaccount($account); } $tmp = str_replace('%bankaccount', implode("\n", $accounts), $tmp); $tmp = preg_split('/\\r?\\n/', $tmp); foreach ($tmp as $line) { $drawer .= $line . '<br>'; } $this->backend->Ln(0); $this->backend->writeHTMLCell(80, '', '', 45, $drawer, 0, 1, 0, true, 'L'); }
protected function simple_fill_mip($x, $y, $scale) { if (ConfigHelper::checkConfig('finances.control_lines')) { $this->backend->line(7 * $scale + $x, 180 * $scale + $y, 7 * $scale + $x, 210 * $scale + $y); $this->backend->line(7 * $scale + $x, 180 * $scale + $y, 37 * $scale + $x, 180 * $scale + $y); $this->backend->line(370 * $scale + $x, 180 * $scale + $y, 370 * $scale + $x, 210 * $scale + $y); $this->backend->line(370 * $scale + $x, 180 * $scale + $y, 340 * $scale + $x, 180 * $scale + $y); $this->backend->line(7 * $scale + $x, 726 * $scale + $y, 7 * $scale + $x, 696 * $scale + $y); $this->backend->line(7 * $scale + $x, 726 * $scale + $y, 37 * $scale + $x, 726 * $scale + $y); $this->backend->line(370 * $scale + $x, 726 * $scale + $y, 370 * $scale + $x, 696 * $scale + $y); $this->backend->line(370 * $scale + $x, 726 * $scale + $y, 340 * $scale + $x, 726 * $scale + $y); } $this->backend->addtext(15 * $scale + $x, 560 * $scale + $y, 30 * $scale, $this->data['d_shortname']); $this->backend->addtext(15 * $scale + $x, 525 * $scale + $y, 30 * $scale, $this->data['d_address']); $this->backend->addtext(15 * $scale + $x, 490 * $scale + $y, 30 * $scale, $this->data['d_zip'] . ' ' . $this->data['d_city']); $this->backend->addtext(15 * $scale + $x, 680 * $scale + $y, 30 * $scale, substr(bankaccount($this->data['id'], $this->data['account']), 0, 17)); $this->backend->addtext(15 * $scale + $x, 620 * $scale + $y, 30 * $scale, substr(bankaccount($this->data['id'], $this->data['account']), 18, 200)); $this->backend->addtext(15 * $scale + $x, 435 * $scale + $y, 30 * $scale, '**' . number_format($this->data['total'], 2, ',', '') . '**'); // $this->backend->addtext(15 * $scale + $x, 310 * $scale+$y, 30 * $scale, $this->data['name']); $font_size = 30; while ($this->backend->getTextWidth($font_size * $scale, $this->data['name']) > 135) { $font_size -= 1; } $this->backend->addtext(15 * $scale + $x, 310 * $scale + $y, $font_size * $scale, $this->data['name']); $font_size = 30; while ($this->backend->getTextWidth($font_size * $scale, $this->data['address']) > 135) { $font_size -= 1; } $this->backend->addtext(15 * $scale + $x, 275 * $scale + $y, $font_size * $scale, $this->data['address']); $this->backend->addtext(15 * $scale + $x, 240 * $scale + $y, 30 * $scale, $this->data['zip'] . ' ' . $this->data['city']); $font_size = 30; while ($this->backend->getTextWidth($font_size * $scale, trans('Invoice No. $a', $this->data['t_number'])) > 135) { $font_size -= 1; } $this->backend->addtext(15 * $scale + $x, 385 * $scale + $y, $font_size * $scale, trans('Invoice No. $a', $this->data['t_number'])); }
if (sizeof($_POST['marks'])) { foreach ($_POST['marks'] as $id => $mark) { $ilm[$id] = $mark; } } if (sizeof($ilm)) { foreach ($ilm as $mark) { $ids[] = $mark; } } if (sizeof($ids)) { foreach ($ids as $invoiceid) { list($cid, $closed) = array_values($DB->GetRow('SELECT customerid, closed FROM documents WHERE id = ?', array($invoiceid))); // add payment if (ConfigHelper::checkConfig('phpui.invoice_check_payment') && $cid && !$closed) { $value = $DB->GetOne('SELECT CASE reference WHEN 0 THEN SUM(a.value*a.count) ELSE SUM((a.value+b.value)*(a.count+b.count)) - SUM(b.value*b.count) END FROM documents d JOIN invoicecontents a ON (a.docid = d.id) LEFT JOIN invoicecontents b ON (d.reference = b.docid AND a.itemid = b.itemid) WHERE d.id = ? GROUP BY d.reference', array($invoiceid)); if ($value != 0) { $LMS->AddBalance(array('type' => 1, 'time' => time(), 'value' => $value, 'customerid' => $cid, 'comment' => trans('Accounted'))); } } if ($SYSLOG) { $args = array(SYSLOG::RES_DOC => $invoiceid, SYSLOG::RES_CUST => $cid, 'closed' => intval(!$closed)); $SYSLOG->AddMessage(SYSLOG::RES_DOC, SYSLOG::OPER_UPDATE, $args); } $DB->Execute('UPDATE documents SET closed =
} if (!empty($auth) && !preg_match('/^LOGIN|PLAIN|CRAM-MD5|NTLM$/i', $auth)) { die("Fatal error: smtp_auth setting not supported! Can't continue, exiting." . PHP_EOL); } //$currtime = localtime2() + $timeoffset; $currtime = localtime2(); //$daystart = intval($currtime / 86400) * 86400 - $timeoffset; $daystart = intval($currtime / 86400) * 86400; $dayend = $daystart + 86399; $deadline = ConfigHelper::getConfig('payments.deadline', ConfigHelper::getConfig('invoices.paytime', 0)); // Include required files (including sequence is important) require_once LIB_DIR . DIRECTORY_SEPARATOR . 'language.php'; include_once LIB_DIR . DIRECTORY_SEPARATOR . 'definitions.php'; require_once LIB_DIR . DIRECTORY_SEPARATOR . 'unstrip.php'; require_once LIB_DIR . DIRECTORY_SEPARATOR . 'common.php'; if (ConfigHelper::checkConfig('phpui.logging') && class_exists('SYSLOG')) { $SYSLOG = new SYSLOG($DB); } else { $SYSLOG = null; } // Initialize Session, Auth and LMS classes $AUTH = NULL; $LMS = new LMS($DB, $AUTH, $SYSLOG); $LMS->ui_lang = $_ui_language; $LMS->lang = $_language; if (!empty($mail_fname)) { $mail_from = qp_encode($mail_fname) . ' <' . $mail_from . '>'; } //include(LIB_DIR . DIRECTORY_SEPARATOR . 'plugins' . DIRECTORY_SEPARATOR . 'mtsms.php'); function parse_customer_data($data, $row) {
$listdata['customer'] = $c; $listdata['numberplan'] = $p; $listdata['from'] = $from; $listdata['to'] = $to; $listdata['status'] = $s; unset($documentlist['total']); unset($documentlist['order']); unset($documentlist['direction']); $pagelimit = ConfigHelper::getConfig('phpui.documentlist_pagelimit'); $page = !isset($_GET['page']) ? ceil($listdata['total'] / $pagelimit) : intval($_GET['page']); $start = ($page - 1) * $pagelimit; $layout['pagetitle'] = trans('Documents List'); $SESSION->save('backto', $_SERVER['QUERY_STRING']); if ($docid = $SESSION->get('documentprint')) { $SMARTY->assign('docid', $docid); $SESSION->remove('documentprint'); } if ($listdata['total']) { $SMARTY->assign('docrights', $DB->GetAllByKey('SELECT doctype, rights FROM docrights WHERE userid = ? AND rights > 1', 'doctype', array($AUTH->id))); } if (!ConfigHelper::checkConfig('phpui.big_networks')) { $SMARTY->assign('customers', $LMS->GetCustomerNames()); } $SMARTY->assign('numberplans', $LMS->GetNumberPlans(array('doctype' => array(DOC_CONTRACT, DOC_ANNEX, DOC_PROTOCOL, DOC_ORDER, DOC_SHEET, -6, -7, -8, -9, -99, DOC_PRICELIST, DOC_PROMOTION, DOC_WARRANTY, DOC_REGULATIONS, DOC_OTHER)))); $SMARTY->assign('documentlist', $documentlist); $SMARTY->assign('pagelimit', $pagelimit); $SMARTY->assign('page', $page); $SMARTY->assign('start', $start); $SMARTY->assign('listdata', $listdata); $SMARTY->display('document/documentlist.html');
if (!isset($_GET['d'])) { $SESSION->restore('cld', $d); } else { $d = $_GET['d']; } $SESSION->save('cld', $d); if (!isset($_GET['page'])) { $SESSION->restore('clp', $_GET['page']); } $page = !$_GET['page'] ? 1 : intval($_GET['page']); $per_page = intval(ConfigHelper::getConfig('phpui.customerlist_pagelimit', 100)); $offset = ($page - 1) * $per_page; $summary = $LMS->GetCustomerList($o, $s, $n, $g, NULL, NULL, 'AND', $ng, $d, null, null, true); $total = intval($summary['total']); $customerlist = $LMS->GetCustomerList($o, $s, $n, $g, NULL, NULL, 'AND', $ng, $d, $per_page, $offset); $pagination = LMSPaginationFactory::getPagination($page, $total, $per_page, ConfigHelper::checkConfig('phpui.short_pagescroller')); $listdata['below'] = $summary['below']; $listdata['over'] = $summary['over']; $listdata['total'] = $customerlist['total']; $listdata['order'] = $customerlist['order']; $listdata['direction'] = $customerlist['direction']; $listdata['network'] = $n; $listdata['nodegroup'] = $ng; $listdata['customergroup'] = $g; $listdata['division'] = $d; $listdata['state'] = $s; $SESSION->save('clp', $page); unset($customerlist['total']); unset($customerlist['state']); unset($customerlist['order']); unset($customerlist['below']);
$reply = $LMS->GetMessage($_GET['id']); if ($reply['replyto']) { $message['destination'] = preg_replace('/^.* <(.+@.+)>/', '\\1', $reply['replyto']); } else { $message['destination'] = preg_replace('/^.* <(.+@.+)>/', '\\1', $reply['mailfrom']); } if (!$message['destination'] && !$reply['userid']) { $message['destination'] = $LMS->GetCustomerEmail($message['customerid']); if (!empty($message['destination'])) { $message['destination'] = implode(',', $message['destination']); } } $message['subject'] = 'Re: ' . $reply['subject']; $message['inreplyto'] = $reply['id']; $message['references'] = $reply['messageid']; if (ConfigHelper::checkConfig('phpui.helpdesk_reply_body')) { $body = explode("\n", textwrap(strip_tags($reply['body']), 74)); foreach ($body as $line) { $message['body'] .= '> ' . $line . "\n"; } } if (!preg_match('/\\[RT#[0-9]{6}\\]/i', $message['subject'])) { $message['subject'] .= sprintf(' [RT#%06d]', $message['ticketid']); } } } $layout['pagetitle'] = trans('New Message'); $SESSION->save('backto', $_SERVER['QUERY_STRING']); $SMARTY->assign('message', $message); $SMARTY->assign('error', $error); $SMARTY->assign('userlist', $LMS->GetUserNames());
* it under the terms of the GNU General Public License Version 2 as * published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, * USA. * * $Id$ */ if (!ConfigHelper::checkConfig('privileges.superuser') && !ConfigHelper::checkConfig('privileges.reports')) { access_denied(); } $type = isset($_GET['type']) ? $_GET['type'] : ''; switch ($type) { case 'stats': /******************************************/ $days = !empty($_GET['days']) ? intval($_GET['days']) : intval($_POST['days']); $times = !empty($_GET['times']) ? intval($_GET['times']) : intval($_POST['times']); $queue = !empty($_GET['queue']) ? intval($_GET['queue']) : intval($_POST['queue']); $categories = !empty($_GET['categories']) ? $_GET['categories'] : $_POST['categories']; if ($queue) { $where[] = 'queueid = ' . $queue; } if ($days) { $where[] = 'rttickets.createtime > ' . mktime(0, 0, 0, date('n'), date('j') - $days);
$plugin_manager->executeHook('userpanel_lms_initialized', $LMS); $plugin_manager->executeHook('userpanel_smarty_initialized', $SMARTY); if($SESSION->islogged) { $module = isset($_GET['m']) ? $_GET['m'] : ''; if (isset($USERPANEL->MODULES[$module])) $USERPANEL->MODULES[$module]['selected'] = true; // Userpanel rights module $rights = $USERPANEL->GetCustomerRights($SESSION->id); $SMARTY->assign('rights', $rights); if(ConfigHelper::checkConfig('userpanel.hide_nodes_modules')) { if(!$DB->GetOne('SELECT COUNT(*) FROM nodes WHERE ownerid = ? LIMIT 1', array($SESSION->id))) { unset($USERPANEL->MODULES['notices']); unset($USERPANEL->MODULES['stats']); } } // Userpanel popup for urgent notice $res = $LMS->ExecHook('userpanel_module_call_before', array('module' => $USERPANEL->MODULES['notices'])); $LMS->executeHook('userpanel_' . $module . '_on_load'); $module_dir = null; foreach ($modules_dirs as $suspected_module_dir)
protected function invoice_footnote($x, $y, $width, $font_size) { if (!empty($this->data['division_footer'])) { $y = $y - $this->backend->getFontHeight($font_size); //$y = $y - $this->backend->text_align_left($x, $y, $font_size, '<b>' . trans('Notes:') . '</b>'); $tmp = $this->data['division_footer']; $accounts = array(bankaccount($this->data['customerid'], $this->data['account'])); if (ConfigHelper::checkConfig('invoices.show_all_accounts')) { $accounts = array_merge($accounts, $this->data['bankaccounts']); } foreach ($accounts as &$account) { $account = format_bankaccount($account); } $tmp = str_replace('%bankaccount', implode("\n", $accounts), $tmp); $tmp = preg_split('/\\r?\\n/', $tmp); foreach ($tmp as $line) { $y = $this->backend->text_wrap($x, $y, $width, $font_size, $line, "full"); } } }
* * $Id$ */ $LMS->executeHook('welcome_on_load'); @(include LIB_DIR . '/locale/' . $_language . '/fortunes.php'); $layout['pagetitle'] = 'LAN Management System'; $layout['dbversion'] = $DB->GetDBVersion(); $layout['dbtype'] = ConfigHelper::getConfig('database.type'); if (ConfigHelper::checkConfig('privileges.superuser')) { $content = $LMS->CheckUpdates(); if (isset($content['newer_version'])) { list($v, ) = preg_split('/\\s+/', $LMS->_version); if (version_compare($content['newer_version'], $v) > 0) { $SMARTY->assign('newer_version', $content['newer_version']); } } $SMARTY->assign('regdata', $LMS->GetRegisterData()); } $SMARTY->assign('_dochref', is_dir('doc/html/' . $LMS->ui_lang) ? 'doc/html/' . $LMS->ui_lang . '/' : 'doc/html/en/'); $SMARTY->assign('rtstats', $LMS->RTStats()); if (!ConfigHelper::checkConfig('privileges.hide_sysinfo')) { $SI = new Sysinfo(); $SMARTY->assign('sysinfo', $SI->get_sysinfo()); } if (!ConfigHelper::checkConfig('privileges.hide_summaries')) { $SMARTY->assign('customerstats', $LMS->CustomerStats()); $SMARTY->assign('nodestats', $LMS->NodeStats()); } $template_file = 'welcome.html'; $template_file = $LMS->executeHook('welcome_before_display', $template_file); $SMARTY->display($template_file);
if (isset($_GET['o'])) { $o = $_GET['o']; } else { $SESSION->restore('dnlo', $o); } $SESSION->save('dnlo', $o); if (isset($_POST['cat'])) { $c = $_POST['cat']; } else { $SESSION->restore('dnlc', $c); } $SESSION->save('dnlc', $c); if (isset($_POST['search'])) { $h = isset($_POST['hideclosed']); } elseif (($h = $SESSION->get('dnlh')) === NULL) { $h = ConfigHelper::checkConfig('notes.hide_closed'); } $SESSION->save('dnlh', $h); if (isset($_POST['group'])) { $g = $_POST['group']; $ge = isset($_POST['groupexclude']) ? $_POST['groupexclude'] : NULL; } else { $SESSION->restore('dnlg', $g); $SESSION->restore('dnlge', $ge); } $SESSION->save('dnlg', $g); $SESSION->save('dnlge', $ge); if ($c == 'cdate' && $s && preg_match('/^[0-9]{4}\\/[0-9]{2}\\/[0-9]{2}$/', $s)) { list($year, $month, $day) = explode('/', $s); $s = mktime(0, 0, 0, $month, $day, $year); } elseif ($c == 'month' && $s && preg_match('/^[0-9]{4}\\/[0-9]{2}$/', $s)) {
$LMS->setPluginManager($plugin_manager); // Initialize Swekey class if (ConfigHelper::checkConfig('phpui.use_swekey')) { require_once LIB_DIR . '/swekey/lms_integration.php'; $LMS_SWEKEY = new LmsSwekeyIntegration($DB, $AUTH, $LMS); $SMARTY->assign('lms_swekey', $LMS_SWEKEY->GetIntegrationScript($AUTH->id)); } // Set some template and layout variables $SMARTY->setTemplateDir(null); $custom_templates_dir = ConfigHelper::getConfig('phpui.custom_templates_dir'); if (!empty($custom_templates_dir) && file_exists(SMARTY_TEMPLATES_DIR . '/' . $custom_templates_dir) && !is_file(SMARTY_TEMPLATES_DIR . '/' . $custom_templates_dir)) { $SMARTY->AddTemplateDir(SMARTY_TEMPLATES_DIR . '/' . $custom_templates_dir); } $SMARTY->AddTemplateDir(array(SMARTY_TEMPLATES_DIR . '/default', SMARTY_TEMPLATES_DIR)); $SMARTY->setCompileDir(SMARTY_COMPILE_DIR); $SMARTY->debugging = ConfigHelper::checkConfig('phpui.smarty_debug'); $layout['logname'] = $AUTH->logname; $layout['logid'] = $AUTH->id; $layout['lmsdbv'] = $DB->GetVersion(); $layout['smarty_version'] = SMARTY_VERSION; $layout['hostname'] = hostname(); $layout['lmsv'] = '1.11-git'; //$layout['lmsvr'] = $LMS->_revision.'/'.$AUTH->_revision; $layout['lmsvr'] = ''; $layout['dberrors'] = $DB->GetErrors(); $layout['dbdebug'] = $_DBDEBUG; $layout['popup'] = isset($_GET['popup']) ? true : false; $SMARTY->assignByRef('layout', $layout); $SMARTY->assignByRef('LANGDEFS', $LANGDEFS); $SMARTY->assignByRef('_ui_language', $LMS->ui_lang); $SMARTY->assignByRef('_language', $LMS->lang);
* published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, * USA. * * $Id$ */ global $LMS, $SESSION, $SMARTY, $invoice, $layout, $type; $type = ConfigHelper::checkConfig('userpanel.invoice_duplicate') ? trans('DUPLICATE') : trans('ORIGINAL'); if (strtolower(ConfigHelper::getConfig('invoices.type')) == 'pdf') { include 'invoice_pdf.php'; die; } header('Content-Type: ' . ConfigHelper::getConfig('invoices.content_type')); if (ConfigHelper::getConfig('invoices.attachment_name') != '') { header('Content-Disposition: attachment; filename=' . ConfigHelper::getConfig('invoices.attachment_name')); } $SMARTY->assign('css', file(ConfigHelper::getConfig('directories.sys_dir') . '/img/style_print.css')); // use LMS templates directory define('SMARTY_TEMPLATES_DIR', ConfigHelper::getConfig('directories.smarty_templates_dir', ConfigHelper::getConfig('directories.sys_dir') . '/templates')); $SMARTY->setTemplateDir(null); $custom_templates_dir = ConfigHelper::getConfig('phpui.custom_templates_dir'); if (!empty($custom_templates_dir) && file_exists(SMARTY_TEMPLATES_DIR . '/' . $custom_templates_dir) && !is_file(SMARTY_TEMPLATES_DIR . '/' . $custom_templates_dir)) { $SMARTY->AddTemplateDir(SMARTY_TEMPLATES_DIR . '/' . $custom_templates_dir);
public function SendSMS($number, $message, $messageid = 0, $script_service = null) { $msg_len = mb_strlen($message); if (!$msg_len) { return trans('SMS message is empty!'); } $debug_phone = ConfigHelper::getConfig('sms.debug_phone'); if (!empty($debug_phone)) { $number = ConfigHelper::getConfig('sms.debug_phone'); } $prefix = ConfigHelper::getConfig('sms.prefix', ''); $number = preg_replace('/[^0-9]/', '', $number); $number = preg_replace('/^0+/', '', $number); // add prefix to the number if needed if ($prefix && substr($number, 0, strlen($prefix)) != $prefix) { $number = $prefix . $number; } // message ID must be unique if (!$messageid) { $messageid = '0.' . time(); } $message = preg_replace("/\r/", "", $message); if (ConfigHelper::checkConfig('sms.transliterate_message')) { $message = iconv('UTF-8', 'ASCII//TRANSLIT', $message); } $max_length = ConfigHelper::getConfig('sms.max_length'); if (!empty($max_length) && intval($max_length) > 6 && $msg_len > intval($max_length)) { $message = mb_substr($message, 0, $max_length - 6) . ' [...]'; } $service = ConfigHelper::getConfig('sms.service'); if ($script_service) { $service = $script_service; } elseif (empty($service)) { return trans('SMS "service" not set!'); } $errors = array(); foreach (explode(',', $service) as $service) { $data = array('number' => $number, 'message' => $message, 'messageid' => $messageid, 'service' => $service); // call external SMS handler(s) $data = $this->ExecHook('send_sms_before', $data); $data = $this->executeHook('send_sms_before', $data); if ($data['abort']) { if (is_string($data['result'])) { $errors[] = $data['result']; continue; } else { return $data['result']; } } $number = $data['number']; $message = $data['message']; $messageid = $data['messageid']; if (in_array($service, array('smscenter', 'serwersms', 'smsapi'))) { if (!function_exists('curl_init')) { $errors[] = trans('Curl extension not loaded!'); continue; } $username = ConfigHelper::getConfig('sms.username'); if (empty($username)) { $errors[] = trans('SMSCenter username not set!'); continue; } $password = ConfigHelper::getConfig('sms.password'); if (empty($password)) { $errors[] = trans('SMSCenter username not set!'); continue; } $from = ConfigHelper::getConfig('sms.from'); if (empty($from)) { $errors[] = trans('SMS "from" not set!'); continue; } if (strlen($number) > 16 || strlen($number) < 4) { $errors[] = trans('Wrong phone number format!'); continue; } } switch ($service) { case 'smscenter': if ($msg_len < 160) { $type_sms = 'sms'; } else { if ($msg_len <= 459) { $type_sms = 'concat'; } else { $errors[] = trans('SMS Message too long!'); continue 2; } } $type = ConfigHelper::getConfig('sms.smscenter_type', 'dynamic'); $message .= $type == 'static' ? "\n\n" . $from : ''; $args = array('user' => ConfigHelper::getConfig('sms.username'), 'pass' => ConfigHelper::getConfig('sms.password'), 'type' => $type_sms, 'number' => $number, 'text' => $message, 'from' => $from); $encodedargs = array(); foreach (array_keys($args) as $thiskey) { array_push($encodedargs, urlencode($thiskey) . "=" . urlencode($args[$thiskey])); } $encodedargs = implode('&', $encodedargs); $curl = curl_init(); curl_setopt($curl, CURLOPT_URL, 'http://api.statsms.net/send.php'); curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1); curl_setopt($curl, CURLOPT_POST, 1); curl_setopt($curl, CURLOPT_POSTFIELDS, $encodedargs); curl_setopt($curl, CURLOPT_TIMEOUT, 10); $page = curl_exec($curl); if (curl_error($curl)) { $errors[] = 'SMS communication error. ' . curl_error($curl); continue 2; } $info = curl_getinfo($curl); if ($info['http_code'] != '200') { $errors[] = 'SMS communication error. Http code: ' . $info['http_code']; continue 2; } curl_close($curl); $smsc = explode(', ', $page); $smsc_result = array(); foreach ($smsc as $element) { $tmp = explode(': ', $element); array_push($smsc_result, $tmp[1]); } switch ($smsc_result[0]) { case '002': case '003': case '004': case '008': case '011': return MSG_SENT; case '001': $errors[] = 'Smscenter error 001, Incorrect login or password'; continue 3; case '009': $errors[] = 'Smscenter error 009, GSM network error (probably wrong prefix number)'; continue 3; case '012': $errors[] = 'Smscenter error 012, System error please contact smscenter administrator'; continue 3; case '104': $errors[] = 'Smscenter error 104, Incorrect sender field or field empty'; continue 3; case '201': $errors[] = 'Smscenter error 201, System error please contact smscenter administrator'; continue 3; case '202': $errors[] = 'Smscenter error 202, Unsufficient funds on account to send this text'; continue 3; case '204': $errors[] = 'Smscenter error 204, Account blocked'; continue 3; default: $errors[] = 'Smscenter error ' . $smsc_result[0] . '. Please contact smscenter administrator'; continue 3; } break; case 'smstools': $dir = ConfigHelper::getConfig('sms.smstools_outdir', DIRECTORY_SEPARATOR . 'var' . DIRECTORY_SEPARATOR . 'spool' . DIRECTORY_SEPARATOR . 'sms' . DIRECTORY_SEPARATOR . 'outgoing'); if (!file_exists($dir)) { $errors[] = trans('SMSTools outgoing directory not exists ($a)!', $dir); continue 2; } if (!is_writable($dir)) { $errors[] = trans('Unable to write to SMSTools outgoing directory ($a)!', $dir); continue 2; } $filename = $dir . DIRECTORY_SEPARATOR . 'lms-' . $messageid . '-' . $number; $latin1 = iconv('UTF-8', 'ASCII', $message); $alphabet = ''; if (strlen($latin1) != mb_strlen($message, 'UTF-8')) { $alphabet = "Alphabet: UCS2\n"; $message = iconv('UTF-8', 'UNICODEBIG', $message); } //$message = clear_utf($message); $file = sprintf("To: %s\n%s\n%s", $number, $alphabet, $message); if ($fp = fopen($filename, 'w')) { fwrite($fp, $file); fclose($fp); } else { $errors[] = trans('Unable to create file $a!', $filename); continue 2; } return MSG_NEW; case 'serwersms': $args = array('akcja' => 'wyslij_sms', 'login' => ConfigHelper::getConfig('sms.username'), 'haslo' => ConfigHelper::getConfig('sms.password'), 'numer' => $number, 'wiadomosc' => $message, 'nadawca' => $from); if ($messageid) { $args['usmsid'] = $messageid; } $fast = ConfigHelper::getConfig('sms.fast'); if (!empty($fast)) { $args['speed'] = 1; } $encodedargs = http_build_query($args); $curl = curl_init(); curl_setopt($curl, CURLOPT_URL, 'https://api1.serwersms.pl/zdalnie/index.php'); curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1); curl_setopt($curl, CURLOPT_POST, 1); curl_setopt($curl, CURLOPT_POSTFIELDS, $encodedargs); curl_setopt($curl, CURLOPT_TIMEOUT, 10); $page = curl_exec($curl); if (curl_error($curl)) { $errors[] = 'SMS communication error. ' . curl_error($curl); continue 2; } $info = curl_getinfo($curl); if ($info['http_code'] != '200') { $errors[] = 'SMS communication error. Http code: ' . $info['http_code']; continue 2; } curl_close($curl); $lines = explode("\n", $page); foreach ($lines as $lineidx => $line) { $lines[$lineidx] = trim($line); } $page = implode('', $lines); if (preg_match('/<Blad>([^<]*)<\\/Blad>/i', $page, $matches)) { $errors[] = 'Serwersms error: ' . $matches[1]; continue 2; } if (!preg_match('/<Skolejkowane><SMS id="[^"]+" numer="[^"]+" godzina_skolejkowania="[^"]+"\\/><\\/Skolejkowane>/', $page)) { $errors[] = 'Serwersms error: message has not been sent!'; continue 2; } return MSG_SENT; case 'smsapi': $args = array('username' => ConfigHelper::getConfig('sms.username'), 'password' => md5(ConfigHelper::getConfig('sms.password')), 'to' => $number, 'message' => $message, 'from' => !empty($from) ? $from : 'ECO', 'encoding' => 'utf-8'); $fast = ConfigHelper::getConfig('sms.fast'); if (!empty($fast)) { $args['fast'] = 1; } if ($messageid) { $args['idx'] = $messageid; } $encodedargs = http_build_query($args); $curl = curl_init(); curl_setopt($curl, CURLOPT_URL, 'https://ssl.smsapi.pl/sms.do'); curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1); curl_setopt($curl, CURLOPT_POST, 1); curl_setopt($curl, CURLOPT_POSTFIELDS, $encodedargs); curl_setopt($curl, CURLOPT_TIMEOUT, 10); $page = curl_exec($curl); if (curl_error($curl)) { $errors[] = 'SMS communication error. ' . curl_error($curl); continue 2; } $info = curl_getinfo($curl); if ($info['http_code'] != '200') { $errors[] = 'SMS communication error. Http code: ' . $info['http_code']; continue 2; } curl_close($curl); if (preg_match('/^OK:/', $page)) { return MSG_SENT; } if (preg_match('/^ERROR:([0-9]+)/', $page, $matches)) { $errors[] = 'Smsapi error: ' . $matches[1]; continue 2; } $errors[] = 'Smsapi error: message has not been sent!'; continue 2; default: $errors[] = trans('Unknown SMS service!'); continue 2; } } return implode(', ', $errors); }
public function GetQueueNames() { return $this->db->GetAll('SELECT q.id, name FROM rtqueues q' . (!ConfigHelper::checkConfig('privileges.superuser') ? ' JOIN rtrights r ON r.queueid = q.id WHERE r.rights <> 0 AND r.userid = ?' : '') . ' ORDER BY name', array($this->auth->id)); }
$dnote_filetype = ConfigHelper::getConfig('notes.type', '', true); $smtp_host = ConfigHelper::getConfig('sendinvoices.smtp_host'); $smtp_port = ConfigHelper::getConfig('sendinvoices.smtp_port'); $smtp_user = ConfigHelper::getConfig('sendinvoices.smtp_user'); $smtp_pass = ConfigHelper::getConfig('sendinvoices.smtp_pass'); $smtp_auth = ConfigHelper::getConfig('sendinvoices.smtp_auth'); $debug_email = ConfigHelper::getConfig('sendinvoices.debug_email', '', true); $sender_name = ConfigHelper::getConfig('sendinvoices.sender_name', '', true); $sender_email = ConfigHelper::getConfig('sendinvoices.sender_email', '', true); $mail_subject = ConfigHelper::getConfig('sendinvoices.mail_subject', 'Invoice No. %invoice'); $mail_body = ConfigHelper::getConfig('sendinvoices.mail_body', ConfigHelper::getConfig('mail.sendinvoice_mail_body')); $invoice_filename = ConfigHelper::getConfig('sendinvoices.invoice_filename', 'invoice_%docid'); $dnote_filename = ConfigHelper::getConfig('sendinvoices.debitnote_filename', 'dnote_%docid'); $notify_email = ConfigHelper::getConfig('sendinvoices.notify_email', '', true); $reply_email = ConfigHelper::getConfig('sendinvoices.reply_email', '', true); $add_message = ConfigHelper::checkConfig('sendinvoices.add_message'); $dsn_email = ConfigHelper::getConfig('sendinvoices.dsn_email', '', true); $mdn_email = ConfigHelper::getConfig('sendinvoices.mdn_email', '', true); if (empty($sender_email)) { echo '<span class="red">' . trans("Fatal error: sender_email unset! Can't continue, exiting.") . '</span><br>'; } $smtp_auth = empty($smtp_auth) ? ConfigHelper::getConfig('mail.smtp_auth_type') : $smtp_auth; if (!empty($smtp_auth) && !preg_match('/^LOGIN|PLAIN|CRAM-MD5|NTLM$/i', $smtp_auth)) { echo '<span class="red">' . trans("Fatal error: smtp_auth value not supported! Can't continue, exiting.") . '</span><br>'; } if (isset($_POST['marks'])) { if ($_GET['marks'] == 'invoice') { $docids = array_map('intval', array_values($_POST['marks'])); } else { $docids = $DB->GetCol("SELECT docid FROM cash c\n\t\t\t\tJOIN documents d ON d.id = c.docid\n\t\t\t\tWHERE d.type IN (?, ?, ?)\n\t\t\t\t\tAND c.id IN (" . implode(',', array_map('intval', array_values($_POST['marks']))) . ")", array(DOC_INVOICE, DOC_CNOTE, DOC_DNOTE)); }
* it under the terms of the GNU General Public License Version 2 as * published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, * USA. * * $Id$ */ if (!ConfigHelper::checkConfig('privileges.reports')) { access_denied(); } $type = isset($_GET['type']) ? $_GET['type'] : ''; switch ($type) { case 'stats': /******************************************/ $days = !empty($_GET['days']) ? intval($_GET['days']) : intval($_POST['days']); $times = !empty($_GET['times']) ? intval($_GET['times']) : intval($_POST['times']); $queue = !empty($_GET['queue']) ? intval($_GET['queue']) : intval($_POST['queue']); $categories = !empty($_GET['categories']) ? $_GET['categories'] : $_POST['categories']; if ($queue) { $where[] = 'queueid = ' . $queue; } if ($days) { $where[] = 'rttickets.createtime > ' . mktime(0, 0, 0, date('n'), date('j') - $days);
public static function getInstance($force = false) { if (self::$syslog == null && ($force || ConfigHelper::checkConfig('phpui.logging'))) { self::$syslog = new SYSLOG(); } return self::$syslog; }
$a['at'] = $d . '/' . $m; } else { list($d, $m) = explode('/', $a['at']); } if (!$error) { if ($d > 30 || $d < 1 || $d > 28 && $m == 2) { $error['at'] = trans('This month doesn\'t contain specified number of days'); } if ($m > 6 || $m < 1) { $error['at'] = trans('Incorrect month number (max.6)!'); } $at = ($m - 1) * 100 + $d; } break; case YEARLY: if (ConfigHelper::checkConfig('phpui.use_current_payday') && !$a['at']) { $d = date('j', time()); $m = date('n', time()); $a['at'] = $d . '/' . $m; } elseif (!preg_match('/^[0-9]{2}\\/[0-9]{2}$/', $a['at'])) { $error['at'] = trans('Incorrect date format! Enter date in DD/MM format!'); } else { list($d, $m) = explode('/', $a['at']); } if (!$error) { if ($d > 30 || $d < 1 || $d > 28 && $m == 2) { $error['at'] = trans('This month doesn\'t contain specified number of days'); } if ($m > 12 || $m < 1) { $error['at'] = trans('Incorrect month number'); }
*/ @(include LIB_DIR . '/locale/' . $_language . '/fortunes.php'); $layout['pagetitle'] = 'LAN Management System'; $layout['dbversion'] = $DB->GetDBVersion(); $layout['dbtype'] = ConfigHelper::getConfig('database.type'); if (ConfigHelper::checkConfig('privileges.superuser')) { $content = $LMS->CheckUpdates(); if (isset($content['newer_version'])) { list($v, ) = preg_split('/\\s+/', $LMS->_version); if (version_compare($content['newer_version'], $v) > 0) { $SMARTY->assign('newer_version', $content['newer_version']); } } $SMARTY->assign('regdata', $LMS->GetRegisterData()); } $SMARTY->assign('_dochref', is_dir('doc/html/' . $LMS->ui_lang) ? 'doc/html/' . $LMS->ui_lang . '/' : 'doc/html/en/'); $SMARTY->assign('rtstats', $LMS->RTStats()); if (ConfigHelper::checkConfig('privileges.superuser') || !ConfigHelper::checkConfig('privileges.hide_sysinfo')) { $SI = new Sysinfo(); $SMARTY->assign('sysinfo', $SI->get_sysinfo()); } if (ConfigHelper::checkConfig('privileges.superuser') || !ConfigHelper::checkConfig('privileges.hide_summaries')) { $SMARTY->assign('customerstats', $LMS->CustomerStats()); $SMARTY->assign('nodestats', $LMS->NodeStats()); if (file_exists(ConfigHelper::getConfig('directories.userpanel_dir') . DIRECTORY_SEPARATOR . 'index.php')) { $customerschanges = $DB->GetOne('SELECT COUNT(id) FROM up_info_changes'); $SMARTY->assign('customerschanges', $customerschanges ? $customerschanges : 0); } } $layout['plugins'] = $plugin_manager->getAllPluginInfo(); $SMARTY->display('welcome/welcome.html');
* but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, * USA. * * $Id$ */ $layout['pagetitle'] = trans('Configuration Reload'); $_RELOAD_TYPE = ConfigHelper::getConfig('phpui.reload_type'); $_EXECCMD = ConfigHelper::getConfig('phpui.reload_execcmd'); $serverTime = date("r"); if (ConfigHelper::checkConfig('phpui.reload_timer')) { $SMARTY->assign('serverTime', $serverTime); } switch ($_RELOAD_TYPE) { case 'exec': $hosts = $DB->GetAll('SELECT id, name, lastreload, reload, description FROM hosts ORDER BY name'); if (isset($_GET['setreloads']) && isset($_POST['hosts'])) { $SMARTY->display('clearheader.html'); echo '<H1>' . $layout['pagetitle'] . '</H1>'; $execlist = explode(';', $_EXECCMD); foreach ($hosts as $host) { if (in_array($host['id'], $_POST['hosts'])) { echo '<H3>' . trans('Host:') . ' ' . $host['name'] . '</H3>'; echo '<TABLE WIDTH="100%" class="superlight" CELLPADDING="5"><TR><TD class="fall">'; foreach ($execlist as $execcmd) { $execcmd = str_replace('%host', $host['name'], $execcmd);
protected function invoice_footnote() { if (!empty($this->data['division_footer'])) { $this->backend->Ln(7); //$this->backend->SetFont('arial', 'B', 10); //$this->backend->Write(0, trans('Notes:'), '', 0, 'L', true, 0, false, false, 0); $tmp = $this->data['division_footer']; $accounts = array(bankaccount($this->data['customerid'], $this->data['account'])); if (ConfigHelper::checkConfig('invoices.show_all_accounts')) { $accounts = array_merge($accounts, $this->data['bankaccounts']); } foreach ($accounts as &$account) { $account = format_bankaccount($account); } $tmp = str_replace('%bankaccount', implode("\n", $accounts), $tmp); $this->backend->SetFont('arial', '', 8); $h = $this->backend->getStringHeight(0, $tmp); $tmp = mb_ereg_replace('\\r?\\n', '<br>', $tmp); $this->backend->writeHTMLCell(0, 0, '', 188 - $h, $tmp, 0, 1, 0, true, 'C'); } }
if (!empty($helpdesk_sender_name)) { $mailfname = $helpdesk_sender_name; if ($mailfname == 'queue') { $mailfname = $queue['name']; } elseif ($mailfname == 'user') { $mailfname = $user['name']; } $mailfname = '"' . $mailfname . '"'; } $mailfrom = $user['email'] ? $user['email'] : $queue['email']; $headers['From'] = $mailfname . ' <' . $mailfrom . '>'; $headers['Subject'] = sprintf("[RT#%06d] %s", $note['ticketid'], $DB->GetOne('SELECT subject FROM rttickets WHERE id = ?', array($note['ticketid']))); $headers['Reply-To'] = $headers['From']; $sms_body = $headers['Subject'] . "\n" . $note['body']; $body = $note['body'] . "\n\nhttp" . (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on' ? 's' : '') . '://' . $_SERVER['HTTP_HOST'] . substr($_SERVER['REQUEST_URI'], 0, strrpos($_SERVER['REQUEST_URI'], '/') + 1) . '?m=rtticketview&id=' . $note['ticketid']; if (ConfigHelper::checkConfig('phpui.helpdesk_customerinfo') && ($cid = $DB->GetOne('SELECT customerid FROM rttickets WHERE id = ?', array($note['ticketid'])))) { $info = $DB->GetRow('SELECT id, pin, ' . $DB->Concat('UPPER(lastname)', "' '", 'name') . ' AS customername, address, zip, city FROM customeraddressview WHERE id = ?', array($cid)); $info['contacts'] = $DB->GetAll('SELECT contact, name, type FROM customercontacts WHERE customerid = ?', array($cid)); $emails = array(); $phones = array(); if (!empty($info['contacts'])) { foreach ($info['contacts'] as $contact) { $target = $contact['contact'] . (strlen($contact['name']) ? ' (' . $contact['name'] . ')' : ''); if ($contact['type'] & CONTACT_EMAIL) { $emails[] = $target; } else { $phones[] = $target; } }
function module_main() { global $SMARTY, $LMS, $SESSION, $DB; $error = NULL; $id = isset($_GET['id']) ? intval($_GET['id']) : 0; if (isset($_FILES['files'])) { $files = array(); foreach ($_FILES['files']['name'] as $fileidx => $filename) { if (!empty($filename)) { if (is_uploaded_file($_FILES['files']['tmp_name'][$fileidx]) && $_FILES['files']['size'][$fileidx]) { $filecontents = ''; $fd = fopen($_FILES['files']['tmp_name'][$fileidx], 'r'); if ($fd) { while (!feof($fd)) { $filecontents .= fread($fd, 256); } fclose($fd); } $files[] = array('name' => $filename, 'tmp_name' => $_FILES['files']['tmp_name'][$fileidx], 'type' => $_FILES['files']['type'][$fileidx], 'contents' => $filecontents); } else { // upload errors if (isset($error['files'])) { $error['files'] .= "\n"; } else { $error['files'] = ''; } switch ($_FILES['files']['error'][$fileidx]) { case 1: case 2: $error['files'] .= trans('File is too large: $a', $filename); break; case 3: $error['files'] .= trans('File upload has finished prematurely: $a', $filename); break; case 4: $error['files'] .= trans('Path to file was not specified: $a', $filename); break; default: $error['files'] .= trans('Problem during file upload: $a', $filename); break; } } } } } if (!$id && isset($_POST['helpdesk'])) { $ticket = $_POST['helpdesk']; $ticket['queue'] = intval($ticket['queue']); $ticket['categories'] = ConfigHelper::getConfig('userpanel.default_categories'); $ticket['subject'] = strip_tags($ticket['subject']); $ticket['body'] = strip_tags($ticket['body']); if (!$ticket['queue'] || !$ticket['categories']) { header('Location: ?m=helpdesk'); die; } if ($ticket['subject'] == '' && $ticket['body'] == '') { header('Location: ?m=helpdesk'); die; } if ($ticket['subject'] == '') { $error['subject'] = trans('Ticket must have its title!'); } if ($ticket['body'] == '') { $error['body'] = trans('Ticket must have its body!'); } if (!$error) { $ticket['email'] = $LMS->GetCustomerEmail($SESSION->id); if (!empty($ticket['email'])) { $ticket['email'] = $ticket['email'][0]; } $ticket['mailfrom'] = $ticket['email'] ? $ticket['email'] : ''; $ts = time(); $DB->Execute('INSERT INTO rttickets (queueid, customerid, subject, createtime) VALUES (?, ?, ?, ?)', array($ticket['queue'], $SESSION->id, $ticket['subject'], $ts)); $id = $DB->GetLastInsertID('rttickets'); $DB->Execute('INSERT INTO rtmessages (ticketid, customerid, createtime, subject, body, mailfrom) VALUES (?, ?, ?, ?, ?, ?)', array($id, $SESSION->id, $ts, $ticket['subject'], $ticket['body'], $ticket['mailfrom'])); foreach (explode(',', $ticket['categories']) as $catid) { $DB->Execute('INSERT INTO rtticketcategories (ticketid, categoryid) VALUES (?, ?)', array($id, $catid)); } if (!empty($files) && ConfigHelper::getConfig('rt.mail_dir')) { $msgid = $DB->GetLastInsertID('rtmessages'); $dir = ConfigHelper::getConfig('rt.mail_dir') . sprintf('/%06d/%06d', $id, $msgid); @mkdir(ConfigHelper::getConfig('rt.mail_dir') . sprintf('/%06d', $id), 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($msgid, $file['name'], $file['type'])); } } } if (ConfigHelper::checkConfig('phpui.newticket_notify')) { $user = $LMS->GetUserInfo(ConfigHelper::getConfig('userpanel.default_userid')); if ($mailfname = ConfigHelper::getConfig('phpui.helpdesk_sender_name')) { if ($mailfname == 'queue') { $mailfname = $LMS->GetQueueName($ticket['queue']); } if ($mailfname == 'user') { $mailfname = $user['name']; } $mailfname = '"' . $mailfname . '"'; } if ($user['email']) { $mailfrom = $user['email']; } elseif ($qemail = $LMS->GetQueueEmail($ticket['queue'])) { $mailfrom = $qemail; } else { $mailfrom = $ticket['mailfrom']; } $headers['Date'] = date('r'); $headers['From'] = $mailfname . ' <' . $mailfrom . '>'; $headers['Subject'] = sprintf("[RT#%06d] %s", $id, $ticket['subject']); $headers['Reply-To'] = $headers['From']; $sms_body = $headers['Subject'] . "\n" . $ticket['body']; $body = $ticket['body'] . "\n\n" . ConfigHelper::getConfig('userpanel.lms_url') . '/?m=rtticketview&id=' . $id; $info = $DB->GetRow('SELECT id AS customerid, pin, ' . $DB->Concat('UPPER(lastname)', "' '", 'name') . ' AS customername, address, zip, city FROM customers WHERE id = ?', array($SESSION->id)); $info['contacts'] = $DB->GetAll('SELECT contact, name FROM customercontacts WHERE customerid = ?', array($SESSION->id)); $emails = array(); $phones = array(); if (!empty($info['contacts'])) { foreach ($info['contacts'] as $contact) { $contact = $contact['contact'] . (strlen($contact['name']) ? ' (' . $contact['name'] . ')' : ''); if ($contact['type'] & (CONTACT_EMAIL | CONTACT_INVOICES | CONTACT_NOTIFICATIONS) > 0) { $emails[] = $contact; } else { $phones[] = $contact; } } } if (ConfigHelper::checkConfig('phpui.helpdesk_customerinfo')) { $body .= "\n\n-- \n"; $body .= trans('Customer:') . ' ' . $info['customername'] . "\n"; $body .= trans('ID:') . ' ' . sprintf('%04d', $info['customerid']) . "\n"; $body .= trans('Address:') . ' ' . $info['address'] . ', ' . $info['zip'] . ' ' . $info['city'] . "\n"; if (!empty($phones)) { $body .= trans('Phone:') . ' ' . implode(', ', $phones) . "\n"; } if (!empty($emails)) { $body .= trans('E-mail:') . ' ' . implode(', ', $emails); } $sms_body .= "\n"; $sms_body .= trans('Customer:') . ' ' . $info['customername']; $sms_body .= ' ' . sprintf('(%04d)', $ticket['customerid']) . '. '; $sms_body .= $info['address'] . ', ' . $info['zip'] . ' ' . $info['city'] . '. '; if (!empty($phones)) { $sms_body .= '. ' . trans('Phone:') . ' ' . preg_replace('/([0-9])[\\s-]+([0-9])/', '\\1\\2', implode(',', $phones)); } } $queuedata = $LMS->GetQueue($ticket['queue']); if (!empty($queuedata['newticketsubject']) && !empty($queuedata['newticketbody']) && !empty($emails)) { $custmail_subject = $queuedata['newticketsubject']; $custmail_subject = str_replace('%tid', $id, $custmail_subject); $custmail_subject = str_replace('%title', $ticket['subject'], $custmail_subject); $custmail_body = $queuedata['newticketbody']; $custmail_body = str_replace('%tid', $id, $custmail_body); $custmail_body = str_replace('%cid', $SESSION->id, $custmail_body); $custmail_body = str_replace('%pin', $info['pin'], $custmail_body); $custmail_body = str_replace('%customername', $info['customername'], $custmail_body); $custmail_body = str_replace('%title', $ticket['subject'], $custmail_body); $custmail_headers = array('From' => $headers['From'], 'To' => '<' . $info['email'] . '>', 'Reply-To' => $headers['From'], 'Subject' => $custmail_subject); $LMS->SendMail(implode(',', $emails), $custmail_headers, $custmail_body); } // send email if ($recipients = $DB->GetCol('SELECT DISTINCT email FROM users, rtrights WHERE users.id = userid AND email != \'\' AND (rtrights.rights & 8) = 8 AND (ntype & ?) = ? AND queueid = ?', array(MSG_MAIL, MSG_MAIL, intval($ticket['queue'])))) { foreach ($recipients as $email) { $headers['To'] = '<' . $email . '>'; $LMS->SendMail($email, $headers, $body); } } // send sms $service = ConfigHelper::getConfig('sms.service'); if (!empty($service) && ($recipients = $DB->GetCol('SELECT DISTINCT phone FROM users, rtrights WHERE users.id = userid AND phone != \'\' AND (rtrights.rights & 8) = 8 AND (ntype & ?) = ? AND queueid = ?', array(MSG_SMS, MSG_SMS, intval($ticket['queue']))))) { foreach ($recipients as $phone) { $LMS->SendSMS($phone, $sms_body); } } } header('Location: ?m=helpdesk&op=view&id=' . $id); die; } else { $SMARTY->assign('error', $error); $SMARTY->assign('helpdesk', $ticket); } } elseif ($id && isset($_POST['helpdesk']) && ($DB->GetOne('SELECT state FROM rttickets WHERE id = ?', array($id)) != RT_RESOLVED || ConfigHelper::getConfig('userpanel.allow_message_add_to_closed_tickets'))) { $ticket = $_POST['helpdesk']; $ticket['body'] = strip_tags($ticket['body']); $ticket['subject'] = strip_tags($ticket['subject']); $ticket['inreplyto'] = intval($ticket['inreplyto']); $ticket['id'] = intval($_GET['id']); if ($ticket['subject'] == '') { $error['subject'] = trans('Ticket must have its title!'); } if ($ticket['body'] == '') { $error['body'] = trans('Ticket must have its body!'); } if (!$DB->GetOne('SELECT 1 FROM rttickets WHERE id = ? AND customerid = ?', array($ticket['id'], $SESSION->id))) { $error = true; } if (!$error) { $ticket['customerid'] = $SESSION->id; // add message $DB->Execute('INSERT INTO rtmessages (ticketid, createtime, subject, body, customerid, inreplyto) VALUES (?, ?NOW?, ?, ?, ?, ?)', array($ticket['id'], $ticket['subject'], $ticket['body'], $ticket['customerid'], $ticket['inreplyto'])); if (!empty($files) && ConfigHelper::getConfig('rt.mail_dir')) { $msgid = $DB->GetLastInsertID('rtmessages'); $dir = ConfigHelper::getConfig('rt.mail_dir') . sprintf('/%06d/%06d', $id, $msgid); @mkdir(ConfigHelper::getConfig('rt.mail_dir') . sprintf('/%06d', $id), 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($msgid, $file['name'], $file['type'])); } } } // re-open ticket $DB->Execute('UPDATE rttickets SET state = CASE state WHEN 0 THEN 0 WHEN 1 THEN 1 WHEN 2 THEN 1 WHEN 3 THEN 1 END WHERE id = ?', array($ticket['id'])); $user = $LMS->GetUserInfo(ConfigHelper::getConfig('userpanel.default_userid')); $ticket['queue'] = $LMS->GetQueueByTicketId($ticket['id']); if ($mailfname = ConfigHelper::getConfig('phpui.helpdesk_sender_name')) { if ($mailfname == 'queue') { $mailfname = $ticket['queue']['name']; } if ($mailfname == 'user') { $mailfname = $user['name']; } $mailfname = '"' . $mailfname . '"'; } $ticket['email'] = $LMS->GetCustomerEmail($SESSION->id); $ticket['mailfrom'] = $ticket['email'] ? $ticket['email'] : ''; if ($user['email']) { $mailfrom = $user['email']; } elseif (!empty($ticket['queue']['email'])) { $mailfrom = $ticket['queue']['email']; } else { $mailfrom = $ticket['mailfrom']; } $headers['Date'] = date('r'); $headers['From'] = $mailfname . ' <' . $mailfrom . '>'; $headers['Subject'] = sprintf("[RT#%06d] %s", $ticket['id'], $ticket['subject']); $headers['Reply-To'] = $headers['From']; $sms_body = $headers['Subject'] . "\n" . $ticket['body']; $body = $ticket['body'] . "\n\n" . ConfigHelper::getConfig('userpanel.lms_url') . '/?m=rtticketview&id=' . $ticket['id']; if (ConfigHelper::checkConfig('phpui.helpdesk_customerinfo')) { $info = $DB->GetRow('SELECT c.id AS customerid, ' . $DB->Concat('UPPER(lastname)', "' '", 'c.name') . ' AS customername, cc.contact AS email, address, zip, city, (SELECT contact AS phone FROM customercontacts WHERE customerid = customers.id AND (customercontacts.type < ?) ORDER BY id LIMIT 1) AS phone FROM customers c LEFT JOIN customercontacts cc ON cc.customerid = c.id AND cc.type & ? > 0 WHERE c.id = ?', array(CONTACT_MOBILE, CONTACT_EMAIL | CONTACT_INVOICES | CONTACT_NOTIFICATIONS, $SESSION->id)); $body .= "\n\n-- \n"; $body .= trans('Customer:') . ' ' . $info['customername'] . "\n"; $body .= trans('ID:') . ' ' . sprintf('%04d', $info['customerid']) . "\n"; $body .= trans('Address:') . ' ' . $info['address'] . ', ' . $info['zip'] . ' ' . $info['city'] . "\n"; $body .= trans('Phone:') . ' ' . $info['phone'] . "\n"; $body .= trans('E-mail:') . ' ' . $info['email']; $sms_body .= "\n"; $sms_body .= trans('Customer:') . ' ' . $info['customername']; $sms_body .= ' ' . sprintf('(%04d)', $ticket['customerid']) . '. '; $sms_body .= $info['address'] . ', ' . $info['zip'] . ' ' . $info['city'] . '. '; $sms_body .= $info['phone']; } //print_r($headers);die; // send email if ($recipients = $DB->GetCol('SELECT DISTINCT email FROM users, rtrights WHERE users.id = userid AND email != \'\' AND (rtrights.rights & 8) = 8 AND (ntype & ?) = ? AND queueid = ?', array(MSG_MAIL, MSG_MAIL, intval($ticket['queue']['id'])))) { foreach ($recipients as $email) { $headers['To'] = '<' . $email . '>'; $LMS->SendMail($email, $headers, $body); } } // send sms $service = ConfigHelper::getConfig('sms.service'); if (!empty($service) && ($recipients = $DB->GetCol('SELECT DISTINCT phone FROM users, rtrights WHERE users.id = userid AND phone != \'\' AND (rtrights.rights & 8) = 8 AND (ntype & ?) = ? AND queueid = ?', array(MSG_SMS, MSG_SMS, intval($ticket['queue']['id']))))) { foreach ($recipients as $phone) { $LMS->SendSMS($phone, $sms_body); } } header('Location: ?m=helpdesk&op=view&id=' . $ticket['id']); die; } else { $SMARTY->assign('error', $error); $SMARTY->assign('helpdesk', $ticket); $_GET['op'] = 'message'; } } if (isset($_GET['op']) && $_GET['op'] == 'view') { if (preg_match('/^[0-9]+$/', $_GET['id'])) { $ticket = $LMS->GetTicketContents($_GET['id']); } $ticket['id'] = $_GET['id']; $SMARTY->assign('title', trans('Request No. $a / Queue: $b', sprintf('%06d', $ticket['ticketid']), $ticket['queuename'])); if ($ticket['customerid'] == $SESSION->id) { $SMARTY->assign('ticket', $ticket); $SMARTY->display('module:helpdeskview.html'); die; } } elseif (isset($_GET['op']) && $_GET['op'] == 'message') { if (preg_match('/^[0-9]+$/', $_GET['id'])) { $ticket = $LMS->GetTicketContents($_GET['id']); } $ticket['id'] = $_GET['id']; if (isset($_GET['msgid']) && preg_match('/^[0-9]+$/', $_GET['msgid'])) { $helpdesk['subject'] = $DB->GetOne('SELECT subject FROM rtmessages WHERE ticketid = ? AND id = ?', array($ticket['id'], $_GET['msgid'])); $helpdesk['subject'] = preg_replace('/^Re:\\s*/', '', $helpdesk['subject']); $helpdesk['subject'] = 'Re: ' . $helpdesk['subject']; $SMARTY->assign('helpdesk', $helpdesk); } $SMARTY->assign('title', trans('Request No. $a / Queue: $b', sprintf('%06d', $ticket['ticketid']), $ticket['queuename'])); if ($ticket['customerid'] == $SESSION->id) { $SMARTY->assign('ticket', $ticket); $SMARTY->display('module:helpdeskreply.html'); die; } } if ($helpdesklist = $LMS->GetCustomerTickets($SESSION->id)) { foreach ($helpdesklist as $idx => $key) { $helpdesklist[$idx]['lastmod'] = $LMS->DB->GetOne('SELECT MAX(createtime) FROM rtmessages WHERE ticketid = ?', array($key['id'])); } } $queues = $LMS->DB->GetAll('SELECT id, name FROM rtqueues WHERE id IN (' . str_replace(';', ',', ConfigHelper::getConfig('userpanel.queues')) . ')'); $SMARTY->assign('queues', $queues); $SMARTY->assign('helpdesklist', $helpdesklist); $SMARTY->display('module:helpdesk.html'); }
$access = AccessRights::getInstance(); $accesslist = $access->getArray($rights); } foreach ($LMS->GetUserInfo($id) as $key => $value) { if (!isset($userinfo[$key])) { $userinfo[$key] = $value; } } if (!isset($userinfo['selected'])) { $userinfo['selected'] = $DB->GetAllByKey('SELECT g.id, g.name FROM customergroups g, excludedgroups WHERE customergroupid = g.id AND userid = ? ORDER BY name', 'id', array($userinfo['id'])); } $layout['pagetitle'] = trans('User Edit: $a', $userinfo['login']); $SESSION->save('backto', $_SERVER['QUERY_STRING']); if ($SYSLOG && (ConfigHelper::checkConfig('privileges.superuser') || ConfigHelper::checkConfig('privileges.transaction_logs'))) { $trans = $SYSLOG->GetTransactions(array('userid' => $id)); if (!empty($trans)) { foreach ($trans as $idx => $tran) { $SYSLOG->DecodeTransaction($trans[$idx]); } } $SMARTY->assign('transactions', $trans); $SMARTY->assign('userid', $id); } $SMARTY->assign('accesslist', $accesslist); $SMARTY->assign('available', $DB->GetAllByKey('SELECT id, name FROM customergroups ORDER BY name', 'id')); $SMARTY->assign('userinfo', $userinfo); $SMARTY->assign('error', $error); $SMARTY->display('user/useredit.html');
* * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, * USA. * * $Id$ */ $id = intval($_GET['id']); if ($id && $_GET['is_sure'] == '1') { if ($LMS->isDocumentPublished($id) && !ConfigHelper::checkConfig('privileges.superuser')) { return; } $DB->BeginTrans(); if ($SYSLOG) { $customerid = $DB->GetOne('SELECT customerid FROM documents WHERE id = ?', array($id)); $args = array(SYSLOG::RES_DOC => $id, SYSLOG::RES_CUST => $customerid); $SYSLOG->AddMessage(SYSLOG::RES_DOC, SYSLOG::OPER_DELETE, $args); $dnoteitems = $DB->GetCol('SELECT id FROM debitnotecontents WHERE docid = ?', array($id)); foreach ($dnoteitems as $item) { $args = array(SYSLOG::RES_DNOTECONT => $item, SYSLOG::RES_DOC => $id, SYSLOG::RES_CUST => $customerid); $SYSLOG->AddMessage(SYSLOG::RES_DNOTECONT, SYSLOG::OPER_DELETE, $args); } $cashitems = $DB->GetCol('SELECT id FROM cash WHERE docid = ?', array($id)); foreach ($cashitems as $item) { $args = array(SYSLOG::RES_CASH => $item, SYSLOG::RES_DOC => $id, SYSLOG::RES_CUST => $customerid);
$body .= trans('Address:') . ' ' . (empty($info['locations']) ? $info['address'] . ', ' . $info['zip'] . ' ' . $info['city'] : implode(', ', $info['locations'])) . "\n"; if (!empty($phones)) { $body .= trans('Phone:') . ' ' . implode(', ', $phones) . "\n"; } if (!empty($emails)) { $body .= trans('E-mail:') . ' ' . implode(', ', $emails); } $sms_body .= "\n"; $sms_body .= trans('Customer:') . ' ' . $info['customername']; $sms_body .= ' ' . sprintf('(%04d)', $cid) . '. '; $sms_body .= empty($info['locations']) ? $info['address'] . ', ' . $info['zip'] . ' ' . $info['city'] : implode(', ', $info['locations']); if (!empty($phones)) { $sms_body .= '. ' . trans('Phone:') . ' ' . preg_replace('/([0-9])[\\s-]+([0-9])/', '\\1\\2', implode(',', $phones)); } } $notify_author = ConfigHelper::checkConfig('phpui.helpdesk_author_notify'); $args = array('queue' => $queue['id'], 'user' => $AUTH->id); if ($notify_author) { unset($args['user']); } // send email $args['type'] = MSG_MAIL; if ($recipients = $DB->GetCol('SELECT DISTINCT email FROM users, rtrights WHERE users.id=userid AND queueid = ? AND email != \'\' AND (rtrights.rights & 8) = 8 AND deleted = 0' . ($notify_author ? '' : ' AND users.id <> ?') . ' AND (ntype & ?) > 0', array_values($args))) { foreach ($recipients as $email) { $headers['To'] = '<' . $email . '>'; $LMS->SendMail($email, $headers, $body); } }
$ilm[$id] = $mark; } } if (sizeof($ilm)) { foreach ($ilm as $mark) { $ids[] = intval($mark); } } if (sizeof($ids)) { foreach ($ids as $noteid) { list($cid, $value, $closed) = array_values($DB->GetRow('SELECT customerid, (SELECT SUM(value) FROM debitnotecontents WHERE docid = d.id) AS value, closed FROM documents d WHERE id = ?', array($noteid))); // add payment if (ConfigHelper::checkConfig('phpui.note_check_payment') && !$closed) { if ($value != 0) { $LMS->AddBalance(array('type' => 1, 'time' => time(), 'value' => $value, 'customerid' => $cid, 'comment' => trans('Accounted'))); } } if ($SYSLOG) { $args = array(SYSLOG::RES_DOC => $noteid, SYSLOG::RES_CUST => $cid, 'closed' => intval(!$closed)); $SYSLOG->AddMessage(SYSLOG::RES_DOC, SYSLOG::OPER_UPDATE, $args); } $DB->Execute('UPDATE documents SET closed = (CASE closed WHEN 0 THEN 1 ELSE 0 END) WHERE id = ?', array($noteid)); } } $SESSION->redirect('?' . $SESSION->get('backto'));
* along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, * USA. * * $Id$ */ if (!$LMS->TicketExists($_GET['id'])) { $SESSION->redirect('?m=rtqueuelist'); } if (!$LMS->GetUserRightsRT($AUTH->id, 0, $_GET['id'])) { $SMARTY->display('noaccess.html'); $SESSION->close(); die; } $ticket = $LMS->GetTicketContents($_GET['id']); if ($ticket['customerid'] && ConfigHelper::checkConfig('phpui.helpdesk_stats')) { $yearago = mktime(0, 0, 0, date('n'), date('j'), date('Y') - 1); $stats = $DB->GetAllByKey('SELECT COUNT(*) AS num, cause FROM rttickets WHERE customerid = ? AND createtime >= ? GROUP BY cause', 'cause', array($ticket['customerid'], $yearago)); $SMARTY->assign('stats', $stats); } if ($ticket['customerid']) { $SMARTY->assign('customerinfo', $LMS->GetCustomer($ticket['customerid'])); $SMARTY->assign('customernodes', $LMS->GetCustomerNodes($ticket['customerid'])); } $layout['pagetitle'] = trans('Ticket No. $a', sprintf("%06d", $ticket['ticketid'])); $SESSION->save('backto', $_SERVER['QUERY_STRING']); $SMARTY->assign('ticket', $ticket); $SMARTY->assign('messages', isset($_GET['messages']) ? 1 : 0); $SMARTY->assign('notes', isset($_GET['notes']) ? 1 : 0);