public static function getRegistrations($SIPInterface) { $cache = Cache::instance(); $sipRegCache = $cache->get('cache_' . $SIPInterface); if (!$sipRegCache) { $eslManager = new EslManager(); $cmd = 'sofia xmlstatus profile ' . $SIPInterface; $result = $eslManager->api($cmd); $xml = $eslManager->getResponse($result); $registrations = array(); if ($xml !== 'Command execution failed.') { $xml = @simplexml_load_string($xml); if ($xml and $xml->registrations and $xml->registrations->registration and $xml->registrations->registration != '') { $registrations = $xml->registrations->registration; } else { Kohana::log('info', 'No XML returned'); } } else { Kohana::log('info', $cmd . ': ' . 'Command execution failed.'); } $result = array(); foreach ($registrations as $r) { $r = (array) $r; $r['interface'] = $SIPInterface; $result[] = $r; } return $result; //array ('user' => 'blah', '') } else { Kohana::log('info', 'Using cached registration'); return $sipRegCache; } }
/** * Attempts to load a view and pre-load view data. * * @throws Kohana_Exception if the requested view cannot be found * @param string $name view name * @param string $page_type page type: album, photo, tags, etc * @param string $theme_name view name * @return void */ public function __construct($name, $page_type) { $theme_name = module::get_var("gallery", "active_site_theme"); if (!file_exists("themes/{$theme_name}")) { module::set_var("gallery", "active_site_theme", "default"); theme::load_themes(); Kohana::log("error", "Unable to locate theme '{$theme_name}', switching to default theme."); } parent::__construct($name); $this->theme_name = module::get_var("gallery", "active_site_theme"); if (user::active()->admin) { $this->theme_name = Input::instance()->get("theme", $this->theme_name); } $this->item = null; $this->tag = null; $this->set_global("theme", $this); $this->set_global("user", user::active()); $this->set_global("page_type", $page_type); $this->set_global("page_title", null); if ($page_type == "album") { $this->set_global("thumb_proportion", $this->thumb_proportion()); } $maintenance_mode = Kohana::config("core.maintenance_mode", false, false); if ($maintenance_mode) { message::warning(t("This site is currently in maintenance mode")); } }
/** * Handle the creation of a new photo. * @todo Get tags from the XMP and/or IPTC data in the image * * @param Item_Model $photo */ static function item_created($photo) { $tags = array(); if ($photo->is_photo()) { $path = $photo->file_path(); $size = getimagesize($photo->file_path(), $info); if (is_array($info) && !empty($info["APP13"])) { $iptc = iptcparse($info["APP13"]); if (!empty($iptc["2#025"])) { foreach ($iptc["2#025"] as $tag) { $tag = str_replace("", "", $tag); foreach (preg_split("/,/", $tag) as $word) { $word = trim($word); if (function_exists("mb_detect_encoding") && mb_detect_encoding($word) != "UTF-8") { $word = utf8_encode($word); } $tags[$word] = 1; } } } } } // @todo figure out how to read the keywords from xmp foreach (array_keys($tags) as $tag) { try { tag::add($photo, $tag); } catch (Exception $e) { Kohana::log("error", "Error adding tag: {$tag}\n" . $e->getMessage() . "\n" . $e->getTraceAsString()); } } return; }
public function index($msg = NULL) { $results = NULL; $results2 = NULL; $query = NULL; $view = new View('search_example'); $view->bind("results", $results)->bind("results2", $results2)->bind("query", $query)->bind("msg", $msg); if (!empty($_GET["q"])) { try { $query = $_GET["q"]; $form = $_GET["form"]; if ($form == "artists") { $results = Search::instance()->find($query); } else { Search::instance()->load_search_libs(); $query = Zend_Search_Lucene_Search_QueryParser::parse($query); $hits = Search::instance()->find($query); if (sizeof($hits) > 0) { $results2 = $query->highlightMatches(iconv('UTF-8', 'ASCII//TRANSLIT', $hits[0]->body)); } else { $results2 = '<p style="color:#f00">No results found</p>'; } } } catch (Exception $e) { Kohana::log("error", $e); } } $view->render(TRUE); }
public static function register($driver, $hook) { $driverName = Telephony::getDriverName(); if (!$driverName or $driverName == 'none') { return true; } elseif (!class_exists($driverName)) { Kohana::log('error', 'Telephony -> Unable to register the dialplan driver \'' . $driverName . '\''); return false; } $hookClass = $driverName . '_' . $driver . '_Driver'; if (!class_exists($hookClass)) { Kohana::log('error', 'Telephony -> Unable to register the dialplan hook \'' . $driver . '\'(' . $hookClass . ')'); return false; } if (empty(self::$dialplanSections)) { kohana::log('debug', 'Telephony -> EVAL ' . $driverName . '::getDialplanSections();'); $sections = eval('return ' . $driverName . '::getDialplanSections();'); if (is_array($sections)) { self::$dialplanSections = $sections; } } if (!in_array($hook, self::$dialplanSections)) { //Logger::ExceptionByCaller(); throw new Exception('The hook ' . $hook . ' is not a recognized telephony global hook. (While trying to register callback ' . $driver . ')'); } // Register event as _telephony.action with the callback array as the callback Event::add('_telephony.' . $hook, array($hookClass, $hook)); Kohana::log('debug', 'Telephony -> Added hook for _telephony.' . $hook . ' to call ' . $hookClass . '::' . $hook); return TRUE; }
public static function dialplan($number) { $xml = Telephony::getDriver()->xml; $destination = $number['Destination']; $xmlText = ' <action application="set" data="api_hangup_hook=conference ' . $destination['pgg_id'] . ' kick all"/> <action application="answer"/> <action application="set" data="conference_auto_outcall_caller_id_name=${effective_caller_id_name}"/> <action application="set" data="conference_auto_outcall_caller_id_number=${effective_caller_id_number}"/> <action application="set" data="conference_auto_outcall_timeout=3"/> <action application="set" data="conference_auto_outcall_prefix={sip_auto_answer=true,sip_h_Alert-Info=Alert-Info:sip://127.0.0.1\\;info=Ring_Answer,sip_h_Call-Info=Call-Info:sip://127.0.0.1\\;answer-after=0}"/> <action application="set" data="sip_exclude_contact=${network_addr}"/> '; if ($destination['pgg_type'] === 'page') { $xmlText .= ' <action application="set" data="conference_auto_outcall_flags=mute"/> '; } else { $xmlText .= ' <action application="set" data="conference_auto_outcall_flags=none"/> '; } foreach ($destination['pgg_device_ids'] as $deviceid) { $deviceobj = Doctrine::getTable('Device')->FindOneBy('device_id', $deviceid); Kohana::log('debug', print_r($deviceobj['registry'], true)); $xmlText .= ' <action application="conference_set_auto_outcall" data="user/' . $deviceobj->plugins['sip']['username'] . '@$${location_' . $deviceobj->User->location_id . '}"/> '; } $conftype = $destination['pgg_type'] == 'page' ? 'Paging' : 'Intercom'; $confobj = Doctrine::getTable('Conference')->findOneByName($conftype); $xmlText .= ' <action application="conference" data="' . $destination['pgg_id'] . '@conference_' . $confobj['conference_id'] . '"/> <action application="conference" data="' . $destination['pgg_id'] . ' kick all"/> '; $xml->replaceWithXml($xmlText); }
public function __construct($e) { $this->message = $e->getMessage(); $this->code = $e->getCode(); $err = $e->getMessage() . "\n" . Kohana::debug($e->getTraceAsString()); Kohana::log('error', $err); }
/** * get full information for an upload * * @param string $file * @param array $file_data * @return array * @author Andy Bennett */ function get_upload_data($file, $file_data) { $filename = self::save($file); if (APPENV == 'frontend') { $upl_dir = str_replace('frontend', 'backend', Kohana::config('upload.directory')); if (!copy($filename, $upl_dir . basename($filename))) { Kohana::log('error', "COPY FAILED: copy({$filename}, {$upl_dir}.basename({$filename}))"); } } $pp = pathinfo($filename); $ext = $pp['extension']; $file_type = self::check_filetype($file_data['type'], $filename); $d = Kohana::config('upload.directory'); $upload_data['file_name'] = $pp['basename']; $upload_data['file_type'] = $file_type; $upload_data['file_path'] = $d; $upload_data['full_path'] = $filename; $upload_data['raw_name'] = $pp['filename']; $upload_data['orig_name'] = $file_data['name']; $upload_data['file_ext'] = '.' . strtolower($ext); $upload_data['file_size'] = $file_data['size']; $upload_data['is_image'] = file::is_image($file_type); $upload_data['date_added'] = date('Y-m-d H:i:s'); if ($upload_data['is_image']) { $properties = file::get_image_properties($filename); if (!empty($properties)) { $upload_data = array_merge($upload_data, $properties); } } return $upload_data; }
/** * Loads encryption configuration and validates the data. * * @param array|string custom configuration or config group name * @throws Kohana_Exception */ public function __construct($config = FALSE) { if (!defined('MCRYPT_ENCRYPT')) { throw new Kohana_Exception('encrypt.requires_mcrypt'); } if (is_string($config)) { $name = $config; // Test the config group name if (($config = Kohana::config('encryption.' . $config)) === NULL) { throw new Kohana_Exception('encrypt.undefined_group', $name); } } if (is_array($config)) { // Append the default configuration options $config += Kohana::config('encryption.default'); } else { // Load the default group $config = Kohana::config('encryption.default'); } if (empty($config['key'])) { throw new Kohana_Exception('encrypt.no_encryption_key'); } // Find the max length of the key, based on cipher and mode $size = mcrypt_get_key_size($config['cipher'], $config['mode']); if (strlen($config['key']) > $size) { // Shorten the key to the maximum size $config['key'] = substr($config['key'], 0, $size); } // Find the initialization vector size $config['iv_size'] = mcrypt_get_iv_size($config['cipher'], $config['mode']); // Cache the config in the object $this->config = $config; Kohana::log('debug', 'Encrypt Library initialized'); }
public function __construct($config = array()) { // Append default fURI configuration $config += Kohana::config('furi'); // Check for 'auto' driver and adjust configuration if (strtolower($config['driver'] == 'auto')) { if (function_exists('curl_init')) { $config['driver'] = 'cURL'; } else { $config['driver'] = 'Stream'; } } // Save the config in the object $this->config = $config; // Set the driver class name $driver = 'Furi_' . $config['driver'] . '_Driver'; if (!Kohana::auto_load($driver)) { throw new Kohana_Exception('core.driver_not_found', $config['driver'], get_class($this)); } // Load the driver $driver = new $driver($config); if (!$driver instanceof Furi_Driver) { throw new Kohana_Exception('core.driver_implements', $config['driver'], get_class($this), 'Furi_Driver'); } // Load the driver for access $this->driver = $driver; Kohana::log('debug', 'Furi Library loaded'); }
public function notify_admins($subject = NULL, $message = NULL) { // Don't show the exceptions for this operation to the user. Log them // instead try { if ($subject && $message) { $settings = kohana::config('settings'); $from = array(); $from[] = $settings['site_email']; $from[] = $settings['site_name']; $users = ORM::factory('user')->where('notify', 1)->find_all(); foreach ($users as $user) { if ($user->has(ORM::factory('role', 'admin'))) { $address = $user->email; $message .= "\n\n\n\n~~~~~~~~~~~~\n" . Kohana::lang('notifications.admin_footer') . "\n" . url::base() . "\n\n" . Kohana::lang('notifications.admin_login_url') . "\n" . url::base() . "admin"; if (!email::send($address, $from, $subject, $message, FALSE)) { Kohana::log('error', "email to {$address} could not be sent"); } } } } else { Kohana::log('error', "email to {$address} could not be sent\n\t\t\t\t - Missing Subject or Message"); } } catch (Exception $e) { Kohana::log('error', "An exception occured " . $e->__toString()); } }
/** * Sets the config for the class. * * @param : array - config passed from the payment library constructor */ public function __construct($config) { $this->test_mode = $config['test_mode']; if ($this->test_mode) { $this->fields['USER'] = $config['SANDBOX_USER']; $this->fields['PWD'] = $config['SANDBOX_PWD']; $this->fields['SIGNATURE'] = $config['SANDBOX_SIGNATURE']; $this->fields['ENDPOINT'] = $config['SANDBOX_ENDPOINT']; } else { $this->fields['USER'] = $config['USER']; $this->fields['PWD'] = $config['PWD']; $this->fields['SIGNATURE'] = $config['SIGNATURE']; $this->fields['ENDPOINT'] = $config['ENDPOINT']; } $this->fields['VERSION'] = $config['VERSION']; $this->fields['CURRENCYCODE'] = $config['CURRENCYCODE']; $this->required_fields['USER'] = !empty($config['USER']); $this->required_fields['PWD'] = !empty($config['PWD']); $this->required_fields['SIGNATURE'] = !empty($config['SIGNATURE']); $this->required_fields['ENDPOINT'] = !empty($config['ENDPOINT']); $this->required_fields['VERSION'] = !empty($config['VERSION']); $this->required_fields['CURRENCYCODE'] = !empty($config['CURRENCYCODE']); $this->curl_config = $config['curl_config']; Kohana::log('debug', 'Paypalpro Payment Driver Initialized'); }
public static function addInterface($name, $ip = '', $port = 5060, $auth = TRUE, $use_inbound_acl = TRUE, $nat = FALSE, $context = 'Inbound Routes') { Kohana::log('debug', 'Adding SIP interface for IP ' . $ip . ' on port ' . $port); $sipInterface = new SipInterface(); $sipInterface['name'] = $name; $sipInterface['ip_address'] = $ip; $sipInterface['port'] = $port; $sipInterface['auth'] = $auth; $sipInterface['nat_type'] = 1; Kohana::log('debug', 'got here2'); //$sipInterface['Context'] = Doctrine::getTable('Context')->findOneByName($context); Kohana::log('debug', 'got here'); $sipInterface['nat_net_list_id'] = netlists::getSystemListId('nat.auto'); Kohana::log('debug', 'got here'); $sipInterface['inbound_net_list_id'] = $use_inbound_acl ? netlists::getSystemListId('trunks.auto') : 0; $sipInterface['register_net_list_id'] = 0; $registry = array('options_ping' => $auth, 'force_rport' => $nat); Kohana::log('debug', 'got here3'); $location = Doctrine::getTable('Location')->findOneByName('Main Location'); if (!empty($location['location_id'])) { $registry['force_register_domain'] = $location['location_id']; } Kohana::log('debug', 'got here4'); $sipInterface['registry'] = $registry; $sipInterface->save(); return TRUE; }
/** * Tests that the storage location is a directory and is writable. */ public function __construct($filename) { // Get the directory name $directory = str_replace('\\', '/', realpath(pathinfo($filename, PATHINFO_DIRNAME))) . '/'; // Set the filename from the real directory path $filename = $directory . basename($filename); // Make sure the cache directory is writable if (!is_dir($directory) or !is_writable($directory)) { throw new Kohana_Exception('cache.unwritable', $directory); } // Make sure the cache database is writable if (is_file($filename) and !is_writable($filename)) { throw new Kohana_Exception('cache.unwritable', $filename); } // Open up an instance of the database $this->db = new SQLiteDatabase($filename, '0666', $error); // Throw an exception if there's an error if (!empty($error)) { throw new Kohana_Exception('cache.driver_error', sqlite_error_string($error)); } $query = "SELECT name FROM sqlite_master WHERE type = 'table' AND name = 'caches'"; $tables = $this->db->query($query, SQLITE_BOTH, $error); // Throw an exception if there's an error if (!empty($error)) { throw new Kohana_Exception('cache.driver_error', sqlite_error_string($error)); } if ($tables->numRows() == 0) { Kohana::log('error', 'Cache: Initializing new SQLite cache database'); // Issue a CREATE TABLE command $this->db->unbufferedQuery(Kohana::config('cache_sqlite.schema')); } }
/** * Loads the configured driver and validates it. * @param array|string|bool $config custom configuration or config group name * @throws Kohana_Exception */ public function __construct($config = FALSE) { if (is_string($config)) { $name = $config; // Test the config group name if (($config = Kohana::config('redis.' . $config)) === NULL) { throw new Kohana_Exception('cache.undefined_group', $name); } } if (is_array($config)) { // Append the default configuration options $config += Kohana::config('redis.default'); } else { // Load the default group $config = Kohana::config('redis.default'); } // Cache the config in the object $this->config = $config; parent::connect($this->config['host'], $this->config['port'], $this->config['timeout']); if (!empty($config['auth'])) { parent::auth($config['auth']); } if (!empty($config['db'])) { parent::select($config['db']); } Kohana::log('debug', 'Redis Library initialized'); }
/** * Sets the config for the class. * * @param array database configuration */ public function __construct($config) { $this->db_config = $config; $this->tables_cache = array(); $this->fields_cache = array(); Kohana::log('debug', 'MySQL Database Driver Initialized'); }
public static function add($controller_name, $method_name, $parameters = array(), $priority = 5, $application_path = '') { if ($priority < 1 or $priority > 10) { Kohana::log('error', 'The priority of the task was out of range!'); return FALSE; } $application_path = empty($application_path) ? APPPATH : $application_path; $old_module_list = Kohana::config('core.modules'); Kohana::config_set('core.modules', array_merge($old_module_list, array($application_path))); // Make sure the controller name and method are valid if (Kohana::auto_load($controller_name)) { // Only add it to the queue if the controller method exists if (Kohana::config('queue.validate_methods') and !method_exists($controller_name, $method_name)) { Kohana::log('error', 'The method ' . $controller_name . '::' . $method_name . ' does not exist.'); return FALSE; } // Add the action to the run queue with the priority $task = new Task_Model(); $task->set_fields(array('application' => $application_path, 'class' => $controller_name, 'method' => $method_name, 'params' => serialize($parameters), 'priority' => $priority)); $task->save(); // Restore the module list Kohana::config_set('core.modules', $old_module_list); return TRUE; } Kohana::log('error', 'The class ' . $controller_name . ' does not exist.'); return FALSE; }
static function item_created($item) { // Only works on photos if (!$item->is_photo()) { return; } // Locate jhead if (!is_file($path = exec('which jhead'))) { // @todo throw an exception ? Kohana::log('error', 'jhead is not installed'); } $binary = str_replace('\\', '/', realpath(dirname($path))); $binary .= '/jhead'; $binary .= PHP_SHLIB_SUFFIX === 'dll' ? '.exe' : ''; if (!is_file($binary)) { // @todo throw an exception ? Kohana::log('error', 'Unable to locate jhead binary'); } // Invoke jhead if ($error = exec(escapeshellcmd($binary) . ' -q -autorot ' . $item->file_path())) { // @todo throw an exception ? Kohana::log('error', 'Error during execution of jhead'); } // Update item $image_info = getimagesize($item->file_path()); $item->width = $image_info[0]; $item->height = $image_info[1]; $item->resize_dirty = 1; $item->thumb_dirty = 1; $item->save(); graphics::generate($item); }
static function get_hit_countries($range = 30, $dp1 = null, $dp2 = null) { $settings = ORM::factory('settings', 1); $stat_id = $settings->stat_id; $twodates = ''; if ($dp1 !== null && $dp2 !== null) { $twodates = '&twodates=' . urlencode($dp1 . ',' . $dp2); } $stat_url = 'http://tracker.ushahidi.com/px.php?stat_key=' . $settings->stat_key . '&task=stats&siteid=' . urlencode($stat_id) . '&period=day&range=' . urlencode($range) . $twodates; $response = simplexml_load_string(self::_curl_req($stat_url)); // If we encounter an error, return false if (isset($response->result->error[0]) || isset($response->error[0])) { Kohana::log('error', "Error on stats request"); return false; } $data = array(); foreach ($response->countries->result as $res) { $date = (string) $res['date']; foreach ($res->row as $row) { $code = (string) $row->code; $data[$date][$code]['label'] = (string) $row->label; $data[$date][$code]['uniques'] = (string) $row->nb_uniq_visitors; $data[$date][$code]['logo'] = 'http://tracker.ushahidi.com/piwik/' . (string) $row->logo; } } return $data; }
/** * On first session instance creation, sets up the driver and creates session. */ public function __construct() { $this->input = Input::instance(); // This part only needs to be run once if (self::$instance === NULL) { // Load config self::$config = Kohana::config('session'); // Makes a mirrored array, eg: foo=foo self::$protect = array_combine(self::$protect, self::$protect); // Configure garbage collection ini_set('session.gc_probability', (int) self::$config['gc_probability']); ini_set('session.gc_divisor', 100); ini_set('session.gc_maxlifetime', self::$config['expiration'] == 0 ? 86400 : self::$config['expiration']); // Create a new session $this->create(); if (self::$config['regenerate'] > 0 and $_SESSION['total_hits'] % self::$config['regenerate'] === 0) { // Regenerate session id and update session cookie $this->regenerate(); } else { // Always update session cookie to keep the session alive cookie::set(self::$config['name'], $_SESSION['session_id'], self::$config['expiration']); } // Close the session just before sending the headers, so that // the session cookie(s) can be written. Event::add('system.send_headers', array($this, 'write_close')); // Make sure that sessions are closed before exiting register_shutdown_function(array($this, 'write_close')); // Singleton instance self::$instance = $this; } Kohana::log('debug', 'Session Library initialized'); }
public static function step($note = '', $type = self::HIT) { $footstep = ORM::factory('footstep'); $footstep->occurred = date('Y-m-d H:i:s'); $footstep->request_uri = isset($_SERVER['REQUEST_URI']) ? $_SERVER['REQUEST_URI'] : ''; $footstep->query_string = isset($_SERVER['QUERY_STRING']) ? $_SERVER['QUERY_STRING'] : ''; $footstep->controller = router::$controller; $footstep->method = router::$method; $footstep->sessionid = Session::instance()->id(); $footstep->referral = isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : ''; $footstep->ip = isset($_SERVER['REMOTE_ADDR']) ? $_SERVER['REMOTE_ADDR'] : ''; $footstep->note = $note; $footstep->type = $type; if (Auth::instance()->logged_in()) { $footstep->user_username = Auth::instance()->get_user()->username; $footstep->user_id = Auth::instance()->get_user()->id; } else { $footstep->user_username = $footstep->ip; $footstep->user_id = 0; } $footstep->save(); if (!$footstep->saved) { Kohana::log('error', 'Could not save footstep!'); } }
public function delete($id, $tag = FALSE) { if ($tag !== FALSE) { Kohana::log('error', 'Cache: tags are unsupported by the Xcache driver'); return TRUE; } elseif ($id !== TRUE) { if (xcache_isset($id)) { return xcache_unset($id); } return FALSE; } else { // Do the login $this->auth(); $result = TRUE; for ($i = 0, $max = xcache_count(XC_TYPE_VAR); $i < $max; $i++) { if (xcache_clear_cache(XC_TYPE_VAR, $i) !== NULL) { $result = FALSE; break; } } // Undo the login $this->auth(TRUE); return $result; } return TRUE; }
public static function dialplan($number) { $xml = Telephony::getDriver()->xml; $faxProfile = $number['Destination']; $faxpackage = Doctrine::getTable('package')->findOneBy('name', 'fax'); $dpentry = DOCROOT . '/ ' . $faxpackage->basedir . '/libraries/dispositions/sendasemail.php'; if (isset($faxProfile['registry']['admin_email']) && $faxProfile['registry']['admin_email'] != '') { $dpentry .= ' -s ' . $faxProfile['registry']['admin_email']; } if (isset($faxProile['registry']['from_address']) && $faxProile['registry']['from_address'] != '') { $dpentry .= ' -f ' . $faxProfile['registry']['from_address']; } if (isset($faxProfile['registry']['from_name']) && $faxProfile['registry']['from_name'] != '') { $dpentry .= ' -n \'' . $faxProfile['registry']['from_name'] . '\''; } if (isset($faxProfile['registry']['email_subject']) && $faxProfile['registry']['email_subject'] != '') { $dpentry .= ' -u \'' . $faxProfile['registry']['email_subject'] . '\''; } if (isset($faxProfile['registry']['email_body']) && $faxProfile['registry']['email_body'] != '') { $dpentry .= ' -b \'' . $faxProfile['registry']['email_body'] . '\''; } if (isset($faxProfile['registry']['dest_email']) && $faxProfile['registry']['dest_email'] != '') { $dpentry .= ' -d \'' . $faxProfile['registry']['dest_email'] . '\''; } else { $dpentry .= ' -d \'${dialedEmail}\''; } if (isset($faxProfile['registry']['send_status']) && !$faxProfile['registry']['send_status']) { $dpentry .= ' -e'; } $dpentry .= ' -ocidname \'${caller_id_name}\' -ocidnum \'${caller_id_number}\' -r \\\\${fax_result_code} -t \'\\\\${fax_result_text}\' -i \'\\\\${fax_remote_station_id}\' -pr \\\\${fax_document_transferred_pages} -pt \\\\${fax_document_total_pages} ' . $faxProfile->fxp_spool_dir . '/infax-${uuid}.tiff'; Kohana::log('debug', $dpentry); $xml->update('/action[@application="set"][@bluebox="settingHangupHook"][@data="api_hangup_hook=' . str_replace(array('/', '@', '$', '{', '}', '-'), array('\\/', '\\@', '\\$', '\\{', '\\}', '\\-'), $dpentry) . '"]'); parent::dialplan($number); }
public function addXMLCDR($xml) { try { $this->xml_cdr = new SimpleXMLElement($xml); } catch (Exception $e) { Kohana::log('error', $e->getMessage()); return; } $cdr = array(); $cdr['caller_id_name'] = (string) $this->xml_cdr->callflow[0]->caller_profile->caller_id_name; $cdr['caller_id_number'] = (string) $this->xml_cdr->callflow[0]->caller_profile->caller_id_number; $cdr['destination_number'] = (string) $this->xml_cdr->callflow[0]->caller_profile->destination_number; $cdr['user_name'] = (string) $this->xml_cdr->callflow[0]->caller_profile->user_name; $cdr['context'] = (string) $this->xml_cdr->callflow[0]->caller_profile->context; $cdr['start_stamp'] = urldecode($this->xml_cdr->variables->start_stamp); $cdr['answer_stamp'] = urldecode($this->xml_cdr->variables->answer_stamp); $cdr['end_stamp'] = urldecode($this->xml_cdr->variables->end_stamp); $cdr['duration'] = (int) $this->xml_cdr->variables->duration; $cdr['billsec'] = (int) $this->xml_cdr->variables->billsec; $cdr['hangup_cause'] = (string) $this->xml_cdr->variables->hangup_cause; $cdr['uuid'] = (string) $this->xml_cdr->callflow[0]->caller_profile->uuid; $cdr['bleg_uuid'] = (string) $this->xml_cdr->callflow[0]->caller_profile->bleg_uuid; $cdr['accountcode'] = (string) $this->xml_cdr->variables->accountcode; $cdr['domain_name'] = (string) $this->xml_cdr->variables->domain_name; $cdr['user_context'] = (string) $this->xml_cdr->variables->user_context; $cdr['read_codec'] = (string) $this->xml_cdr->variables->read_codec; $cdr['write_codec'] = (string) $this->xml_cdr->variables->write_codec; $cdr['dialed_domain'] = (string) $this->xml_cdr->variables->dialed_domain; $cdr['dialed_user'] = (string) $this->xml_cdr->variables->dialed_user; foreach ($cdr as $k => $p) { fwrite($this->fp, "{$k} {$p}\n"); } //fwrite($this->fp, $_POST['cdr'] ); //getDomain() if (strlen($cdr['domain_name']) == 0) { $domain = $cdr['dialed_domain']; $direction = 'in'; } else { $domain = $cdr['domain_name']; $direction = 'out'; } fwrite($this->fp, "\n==direction: {$direction} \n"); $domain = str_replace('.', '_', trim($domain)); $account = $cdr['accountcode']; $cdr['account'] = $account; $cdr['domain'] = $domain; $cdr['direction'] = $direction; $cdr['start'] = new MongoDate(strtotime($cdr['start_stamp'])); fwrite($this->fp, "\n==domain: {$domain} \n"); fwrite($this->fp, "== account: {$account} \n"); try { $db = $this->selectDB('cdr'); $collection = $db->selectCollection('record'); $collection->insert($cdr); } catch (Exception $e) { fwrite($this->fp, $e->getMessage()); echo $e->getMessage() . "\n"; } }
/** * Loads configuration options. * * @return void */ public function __construct($config = array()) { // Append default tags configuration $config += Kohana::config('tags'); // Save the config in the object $this->config = $config; Kohana::log('debug', 'Tags Library loaded'); }
function error_404() { if (Kohana::$instance == NULL) { Kohana::$instance = new Errors_Controller(); } Kohana::log('error', 'Error 404 (steam.core.hooks): ' . URI::instance()->string()); Kohana::show_404(null, 'common/error_404'); }
public function __set($prop, $value) { Kohana::log('debug', $prop . ' -> ' . Kohana::debug($value)); if ('tags' == $prop && is_string($value)) { return $this->set_tags($value); } return parent::__set($prop, $value); }
/** * Loads third-party adLDAP library. */ public function __construct($config = array()) { // Append default adldap configuration $config += Kohana::config('adldap'); // Store instantiation of adLDAP library $this->adldap = new adLDAP($config); Kohana::log('debug', 'KadLDAP Library loaded'); }
public function __construct() { // Load Encrypt library if (Kohana::config('session.encryption')) { $this->encrypt = new Encrypt(); } Kohana::log('debug', 'Session Cache Driver Initialized'); }
public function write($id, $data) { $data = empty($this->encrypt) ? base64_encode($data) : $this->encrypt->encode($data); if (strlen($data) > 4048) { Kohana::log('error', 'Session (' . $id . ') data exceeds the 4KB limit, ignoring write.'); return FALSE; } return cookie::set($this->cookie_name, $data, Kohana::config('session.expiration')); }