static function getCompanyEmail($company_id) { // Get the email address for the company // Use the first Technical address that is not defined as name TICKET_SUPPORT // TICKET_SUPPORT is defined in conf/config.php // If that does not exist, use the main address $config = Config::Instance(); $contact = ''; $company = new Company(); $company->load($company_id); $party = $company->party; $sh = new SearchHandler(new PartyContactMethodCollection(new PartyContactMethod()), false); $sh->AddConstraint(new Constraint('type', '=', 'E')); $ticket_support = $config->get('TICKET_SUPPORT'); if (!empty($ticket_support)) { $sh->AddConstraint(new Constraint('name', '!=', $ticket_support)); } $party->addSearchHandler('contactmethods', $sh); $methods = $party->contactmethods; foreach ($methods as $method) { if ($method->technical == true) { // Technical contact favoured above all else $contact = $method->contact; break; } if ($method->main == true) { // If no contact yet found and this contact is the main contact, use this instead $contact = $method->contact; } } return $contact; }
public static function GetINI() { $INI = Config::Instance('php'); $SYS = Table::Fetch('system', 1); $SYS = Utility::ExtraDecode($SYS['value']); $INI = Config::MergeINI($INI, $SYS); return self::BuildINI($INI); }
function I($key) { global $lang_properties, $LC; if (!$lang_properties) { $ini = DIR_ROOT . '/i18n/' . $LC . '/properties.ini'; $lang_properties = Config::Instance($ini); } return isset($lang_properties[$key]) ? $lang_properties[$key] : $key; }
function uzerp_exception_handler($exception) { $smarty = new Smarty(); $config = Config::Instance(); $smarty->assign('config', $config->get_all()); $smarty->compile_dir = DATA_ROOT . 'templates_c'; $smarty->assign('exception_message', $exception->getMessage()); $smarty->assign('support_email', $config->get('ADMIN_EMAIL')); $email_body = "Request: " . $_SERVER['REQUEST_URI'] . "\n"; $email_body .= "uzERP Version: " . $config->get('SYSTEM_VERSION') . "\n\n" . $exception->getMessage(); $smarty->assign('email_body', rawurlencode($email_body)); $smarty->display(STANDARD_TPL_ROOT . 'error.tpl'); }
function __construct() { $config = Config::Instance('php'); $host = (string) $config['db']['host']; $user = (string) $config['db']['user']; $pass = (string) $config['db']['pass']; $name = (string) $config['db']['name']; self::$mConnection = mysql_connect($host, $user, $pass); if (mysql_errno()) { throw new Exception("Connect failed: " . mysql_error()); } @mysql_select_db($name, self::$mConnection); @mysql_query("SET NAMES UTF8;", self::$mConnection); }
private static function _CreateCacheInstance() { $ini = Config::Instance('ini'); settype($ini['memcache'], 'array'); if (!class_exists('Memcache')) { return new FalseCache(); } $cache_instance = new Memcache(); foreach ($ini['memcache'] as $one) { $server = (string) $one; list($ip, $port, $weight) = explode(':', $server); $cache_instance->addServer($ip, $port, true, $weight, 1, 15, true, array('Cache', 'FailureCallback')); } return $cache_instance; }
private function Connect() { if (!self::$_connectSource) { if (Config::Instance()->DB["port"] != "") { //存在端口号 self::$_connectSource = mysql_connect(Config::Instance()->DB["host"] . ":" . Config::Instance()->DB["port"], Config::Instance()->DB["user"], Config::Instance()->DB["password"]); } else { self::$_connectSource = mysql_connect(Config::Instance()->DB["host"], Config::Instance()->DB["user"], Config::Instance()->DB["password"]); } if (!self::$_connectSource) { throw new Exception("mysql connect error" . mysql_error()); } mysql_select_db(Config::Instance()->DB["database"], self::$_connectSource); mysql_query("set names UTF8", self::$_connectSource); } return self::$_connectSource; }
public static function GetINI() { global $INI; /* load from php*/ $dbphp = DIR_CONFIGURE . '/db.php'; if (file_exists($dbphp)) { configure_load(); } else { /* end */ $INI = Config::Instance('php'); $SYS = Table::Fetch('system', 1); $SYS = Utility::ExtraDecode($SYS['value']); $INI = Config::MergeINI($INI, $SYS); } $INI = ZSystem::WebRoot(); return self::BuildINI($INI); }
static function GetTag($tagname = 'dochead', $ass = null) { $xml = Config::Instance('xml'); $r = array(); if (!$xml->{$tagname}->item) { return $r; } foreach ($xml->{$tagname}->item as $one) { $attr = $one->attributes(); $pa = array(); foreach ($attr as $k => $v) { $pa[strval($k)] = strval($v); } $r[] = $pa; } if ($ass) { return Utility::AssColumn($r, 'id'); } return $r; }
private static function _CreateCacheInstance() { global $INI; $ini = Config::Instance('php'); settype($ini['memcache'], 'array'); if (!class_exists('Memcache', false)) { return new FalseCache(); } $cache_instance = new Memcache(); foreach ($INI['memcache'] as $one) { $server = (string) $one; list($ip, $port, $weight) = explode(':', $server); if (!$ip || !$port || !$weight) { continue; } $cache_instance->addServer($ip, $port, true, $weight, 1, 15, true, array('Cache', 'FailureCallback')); self::$mIndex++; } return self::$mIndex ? $cache_instance : new FalseCache(); }
function __construct($type = 'master') { $config = Config::Instance('php'); $s_host = (string) $config['db']['host']['s']; $m_host = (string) $config['db']['host']['m']; $user = (string) $config['db']['user']; $pass = (string) $config['db']['pass']; $name = (string) $config['db']['name']; if ($type == 'master') { self::$mConnection = mysql_connect($m_host, $user, $pass, true); @mysql_select_db($name, self::$mConnection); @mysql_query("SET NAMES UTF8;", self::$mConnection); } else { self::$sConnection = mysql_connect($s_host, $user, $pass, true); @mysql_select_db($name, self::$sConnection); @mysql_query("SET NAMES UTF8;", self::$sConnection); } if (mysql_errno()) { throw new Exception("Connect failed: " . mysql_error()); } }
/** * Constructor is private final. Can only be instantiated via WebRequest::Instance() * @access private * @final */ private final function __construct() { $this->mh = curl_multi_init(); if (isset(Config::Instance()->Endpoint['timeout'])) { $this->_options[CURLOPT_TIMEOUT] = Config::Instance()->Endpoint['timeout']; } $this->_options[CURLOPT_USERAGENT] = 'Instaphp/v' . INSTAPHP_VERSION; //-- this is an interesting hack to make curl+ssl+windows follow redirects //-- without skipping verification. For some reason, the version of libcurl/curl //-- included with ZendServer CE doesn't use the systems CA bundle, so, we specify //-- the path to the cert here (via config setting) if (isset(Config::Instance()->Instaphp->CACertBundlePath) && !empty(Config::Instance()->Instaphp->CACertBundlePath)) { $this->_options[CURLOPT_SSL_VERIFYPEER] = true; $this->_options[CURLOPT_SSL_VERIFYHOST] = 2; $this->_options[CURLOPT_SSLVERSION] = 3; $this->_options[CURLOPT_CAINFO] = Config::Instance()->Instaphp->CACertBundlePath; } $this->_options[CURLOPT_HTTPHEADER] = array("Connection: keep-alive", "Keep-Alive: 300", "Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7", "Accept-Language: en-us,en;q=0.5"); $this->_requests = array(); $this->_responses = array(); }
function set_config($key, $value) { $config = Config::Instance(); return $config->get($key, $value); }
public function test_class_wrap_read() { $config = Config::Instance(); $this->_class_wrap_read(); $this->assertEquals($config->variable('array'), $GLOBALS['var']); }
function GetUserToken() { return ToolMethod::Instance()->GetCookies(Config::Instance()->LoginUser["UserToken"]); }
public function xmlrpcServer() { if (!$this->check_system()) { return; } $this->load_essential(); if (!defined('EGS_USERNAME')) { $config = Config::Instance(); define('EGS_USERNAME', $config->get('TICKET_USER')); } include PLUGINS_ROOT . 'xmlrpc/xmlrpc.inc'; include PLUGINS_ROOT . 'xmlrpc/xmlrpcs.inc'; $this->references('ticketing', 'model'); // Need to load definitions for introspection purposes // TODO: register in database and retrieve from there $newOther_sig = array(array('struct', 'subject' => 'string', 'string', 'string')); $newOther_doc = 'Another new uzERP xml rpc function'; $newOther = array('function' => 'newOther', 'signature' => $newOther_sig, 'docstring' => $newOther_doc); // $ticketRequest_sig = array(array('struct', 'subject'=>'string', 'from_email'=>'string', 'request'=>'string', 'to_email'=>'string')); $ticketRequest_sig = array(array('struct', 'string', 'string', 'struct', 'string')); $ticketRequest_doc = 'Submit uzERP ticket'; $ticketRequest = array('function' => 'xmlrpcTicket::request', 'signature' => $ticketRequest_sig, 'docstring' => $ticketRequest_doc); new xmlrpc_server(array('uzerp.newOther' => $newOther, 'support.request' => $ticketRequest)); }
public static function getReplyAddress($ticket) { $from = ''; $config = Config::Instance(); $ticket_support = $config->get('TICKET_SUPPORT'); if (!is_null($ticket->originator_company_id) && !empty($ticket_support)) { // use the ticket support email address for the company // TICKET_SUPPORT should be defined in the conf/config.php $from = $ticket->company->getContactDetail('E', $ticket_support); } if (empty($from)) { // no ticket support email address for the company // so use the queue email address $queue = new TicketQueue(); $queue->load($ticket->ticket_queue_id); $from = $queue->email_address; } return $from; }
static function get_fk_field_type() { $config = Config::Instance(); $field_type = get_config('DB_TYPE') . '_fk_field_type'; return self::$field_type($_field_type); }
function request($params) { $errors = array(); // Parse parameters. $p1 = $params->getParam(0); $subject = $p1->scalarval(); $p2 = $params->getParam(1); $from_email = $p2->scalarval(); $p3 = $params->getParam(2); $parts = array(); foreach ($p3->scalarval() as $body) { $parts[] = $body->scalarval(); } $content = $parts[0]['content']; $request = $content->scalarval(); unset($parts[0]); $p4 = $params->getParam(3); $to_email = $p4->scalarval(); /* - mandatory fields summary character varying NOT NULL, client_ticket_priority_id bigint NOT NULL, client_ticket_severity_id bigint NOT NULL, ticket_queue_id bigint NOT NULL, ticket_category_id bigint NOT NULL, internal_ticket_priority_id bigint NOT NULL, internal_ticket_severity_id bigint NOT NULL, internal_ticket_status_id bigint NOT NULL, client_ticket_status_id bigint NOT NULL, - optional fields originator_person_id character varying, originator_company_id bigint, company_sla_id bigint, action_code character varying(4), originator_email_address character varying, assigned_to character varying, */ $config = Config::Instance(); $companyid = ''; $contact = new PartyContactMethodCollection(new PartyContactMethod()); $sh = new SearchHandler($contact, false, false); $sh->addConstraint(new Constraint('name', '=', $config->get('TICKET_SUPPORT'))); $sh->addConstraint(new Constraint('type', '=', 'E')); $sh->addConstraint(new Constraint('technical', 'is', TRUE)); $sh->addConstraint(new Constraint('contact', '=', $to_email)); $contact->load($sh); if ($contact->count() > 0) { $party_ids = array(); foreach ($contact as $party) { $party_ids[] = $party->party_id; $usercompanyid = $party->usercompanyid; } if (!defined('EGS_COMPANY_ID')) { define('EGS_COMPANY_ID', $usercompanyid); } $company = new Company(); $cc = new ConstraintChain(); $cc->add(new Constraint('party_id', 'in', '(' . implode(',', $party_ids) . ')')); $companylist = $company->getAll($cc); if (count($companylist) != 1) { $errors[] = '1) Unable to find your support details - please contact technical support'; } else { $company->load(key($companylist), true); $companyid = $company->id; $usercompanyid = $company->usercompanyid; } } else { $errors[] = '2) Unable to find your support details - please contact technical support'; } $data['attachments'] = $parts; $data['TicketResponse']['body'] = $request; $data['TicketResponse']['type'] = 'site'; $data['Ticket']['originator_company_id'] = $companyid; $data['reply_address'] = $to_email; $start = strpos($subject, '['); $end = strpos($subject, ']'); $mid = strpos($subject, '-'); if ($start > 0 && $mid > 0 && $end > 0 && $start < $end && $start < $mid && $mid < $end) { $ticket = substr($subject, $mid + 1, $end - $mid - 1); } if (empty($request)) { $errors[] = 'No request details submitted'; } elseif (count($errors) == 0) { if (isset($ticket) && is_numeric($ticket)) { $data['TicketResponse']['ticket_id'] = $ticket; self::updateRequest($data, $errors); $response = "Your response for Ticket " . $ticket . " has been received. The person dealing with your query has been notified."; } else { $data['Ticket']['summary'] = $subject; $data['Ticket']['originator_email_address'] = $from_email; $data['Ticket']['usercompanyid'] = $usercompanyid; self::newRequest($data, $errors); $response = "Your request has been received and assigned ticket no. " . $data['TicketResponse']['ticket_id'] . ". A confirmation email has been sent."; } } if (count($errors) > 0) { $errors[] = $sh->constraints->__toString(); $result = "ERROR\n"; $response = "Subject:" . $subject . "\n"; $response .= 'Email:' . $from_email . "\n"; $response .= 'Request:' . $request . ";\n\n"; $response .= "Errors:\n"; $response .= implode(";\n", $errors); } else { $result = 'SUCCESS'; } $struct = array('result' => new xmlrpcval($result, 'string'), 'response' => new xmlrpcval($response, 'string')); return new xmlrpcresp(new xmlrpcval($struct, 'struct')); }