/** * This function returns a instance (and creates a new one * if there isnt already one) of a class. * * @author Johannes Klose <*****@*****.**> * @param string $class Class from where an instance should be returned. * @return object Instance of $class **/ function &singleton($class) { static $singleton; if (!is_object($singleton)) { $singleton = new singleton(); } return $singleton->instance($class); }
public static function getInstance(&$sql, $location, $var, $type) { // 确定类型 switch ($type) { default: // 默认使用字符串类型 // 默认使用字符串类型 case 'STRING': $var = addslashes($var); // 转义 $var = "'" . $var . "'"; // 加上单引号.sql语句中字符串插入必须加单引号 break; case 'INTEGER': case 'INT': $var = (int) $var; // 强制转换成int // 还可以增加更多的类型... } $pos = 0; // 判断该类是否是第一次被实例化 if (self::$instance == NULL) { self::$instance = new singleton(); for ($i = 1; $i <= $location; $i++) { $pos = strpos($sql, '?', $pos + 1); } } else { for ($i = 1; $i <= $location - 1; $i++) { $pos = strpos($sql, '?', $pos + 1); } } return $sql = substr($sql, 0, $pos) . $var . substr($sql, $pos + 1); }
public static function get_instance($text) { if (!isset(singleton::$singleton)) { singleton::$singleton = new singleton($text); } return singleton::$singleton; }
/** * When the user enters the source location when creating a new gallery. * * Won't work publically yet, because the user needs to be authenticated to subscribe to push notifications. * Also, does not currently work with albums. * * @return [type] [description] */ private function _vimeography_subscribe_to_trigger($resource, $gallery_id) { $callback = network_site_url() . '/vimeography/' . $gallery_id . '/refresh/'; $response = $this->_vimeo->request('/triggers', array('actions' => 'added, removed', 'callback' => $callback, 'resource_uri' => $resource . '/videos'), 'POST'); echo '<pre>'; var_dump($response); echo '</pre>'; die; switch ($response['status']) { case 201: //successful return TRUE; break; case 403: if ($this->_token === FALSE) { // Trigger unsuccessful, rely on 304 headers. break; // This line will only work when the Vimeo API supports triggers without being authenticated // Though, the user could technically be subscribing to a collection that isn't actually supported in PRO, either. // So be specific in which sources are currently supported. //throw new Vimeography_Exception('Vimeography PRO allows you to show videos from all of your users, channels, albums, & groups.'); } else { throw new Vimeography_Exception(__("Looks like you don't have the permission to subscribe to this collection.", 'vimeography')); } break; case 405: case 500: // Unsupported container uri throw new Vimeography_Exception(__('The resource that was entered is currently unsupported.', 'vimeography')); break; default: throw new Vimeography_Exception(serialize($response)); break; } }
public static function getInstance() { if (NULL === self::$instance) { self::$instance = new self(); } return self::$instance; }
public static function getInstance() { if (!self::$_instance) { self::$_instance = new self(); } return self::$_instance; }
public static function getInstance() { if (self::$instance == null) { self::$instance = new singleton(); } return self::$instance; }
public static function getInstance() { if (!self::$_INSTANCE instanceof self) { self::$_INSTANCE = new self(); } return self::$_INSTANCE; }
public function update_check() { $config =& singleton::get(__NAMESPACE__ . '\\config'); $apptrack =& singleton::get(__NAMESPACE__ . '\\apptrack'); $send_data['application_id'] = 1; $send_data['version'] = $config->get('program_version'); $data = $apptrack->send($send_data); if (!empty($data)) { $config->set('last_update_response', $data); return true; } else { $log =& singleton::get(__NAMESPACE__ . '\\log'); $log_array['event_severity'] = 'warning'; $log_array['event_number'] = E_USER_WARNING; $log_array['event_description'] = 'Unable to contact update server.'; $log_array['event_file'] = __FILE__; $log_array['event_file_line'] = __LINE__; $log_array['event_type'] = 'update_check'; $log_array['event_source'] = 'cron'; $log_array['event_version'] = '1'; $log_array['log_backtrace'] = false; $log->add($log_array); return false; } }
protected static function getInstance($class = __CLASS__) { if (is_null(self::$o)) { self::$o = true; // in case new fails self::$o = new $class(); } return self::$o; }
public static function init($type = null) { if (self::$base === null) { $class = get_called_class(); self::$base = new $class($type); return self::$base; } else { return self::$base; } }
public function get($name) { $error =& singleton::get(__NAMESPACE__ . '\\error'); if (isset($this->language_array[$name])) { //return '試験'; //return '試験' . $this->language_array[$name]; return $this->language_array[$name]; } else { //$error->create(array('type' => 'language_item_missing', 'message' => 'Unable to find language item "'.$name.'".')); return $name; } }
public function optimise_tables() { global $db; $tables =& singleton::get(__NAMESPACE__ . '\\tables'); $log =& singleton::get(__NAMESPACE__ . '\\log'); $log_array['event_severity'] = 'notice'; $log_array['event_number'] = E_USER_NOTICE; $log_array['event_description'] = 'Optimising Tables'; $log_array['event_file'] = __FILE__; $log_array['event_file_line'] = __LINE__; $log_array['event_type'] = 'optimise_tables'; $log_array['event_source'] = 'db_maintenance'; $log_array['event_version'] = '1'; $log_array['log_backtrace'] = false; $log->add($log_array); $optimise_tables = ''; foreach ($tables->get() as $value => $index) { $optimise_tables .= $index . ','; } $optimise_tables = substr($optimise_tables, 0, strlen($optimise_tables) - 1); $query = 'OPTIMIZE TABLE ' . $optimise_tables; foreach ($db->query($query, database::FETCH_ASSOC) as $row) { if ($row['Msg_type'] == 'error') { $number = E_USER_WARNING; $type = 'warning'; } else { $number = E_USER_NOTICE; $type = 'notice'; } $log_array['event_severity'] = $type; $log_array['event_number'] = $number; $log_array['event_description'] = 'Table "' . $row['Table'] . '"<br />Message "' . $row['Msg_text'] . '"'; $log_array['event_file'] = __FILE__; $log_array['event_file_line'] = __LINE__; $log_array['event_type'] = 'optimise_tables'; $log_array['event_source'] = 'db_maintenance'; $log_array['event_version'] = '1'; $log_array['log_backtrace'] = false; $log->add($log_array); } $log_array['event_severity'] = 'notice'; $log_array['event_number'] = E_USER_NOTICE; $log_array['event_description'] = 'Optimising Tables Complete'; $log_array['event_file'] = __FILE__; $log_array['event_file_line'] = __LINE__; $log_array['event_type'] = 'optimise_tables'; $log_array['event_source'] = 'db_maintenance'; $log_array['event_version'] = '1'; $log_array['log_backtrace'] = false; $log->add($log_array); }
public function send($array) { $log =& singleton::get(__NAMESPACE__ . '\\log'); $array['token'] = $this->app_key; /* Limit to 512 chars as per pushover limit. */ $remove = 0; if (isset($array['title'])) { $remove = (int) strlen($array['title']); } if (isset($array['message'])) { $array['message'] = substr($array['message'], 0, 512 - $remove); } $options = array('http' => array('user_agent' => user_agent(), 'timeout' => 5, 'method' => 'POST', 'header' => 'Content-type: application/x-www-form-urlencoded', 'content' => http_build_query($array))); $context = stream_context_create($options); $result = @file_get_contents($this->api_url, false, $context); if ($result) { $return_data = json_decode($result, true); if ($return_data['status'] == 1) { return true; } else { $larray['event_severity'] = 'error'; $larray['event_number'] = E_USER_ERROR; $larray['event_description'] = 'Unable to send pushover message.'; $larray['event_file'] = __FILE__; $larray['event_file_line'] = __LINE__; $larray['event_type'] = 'send'; $larray['event_source'] = 'pushover'; $larray['event_version'] = '1'; $larray['log_backtrace'] = true; $log->add($larray); } } else { $larray['event_severity'] = 'error'; $larray['event_number'] = E_USER_ERROR; $larray['event_description'] = 'Unable to send pushover message.'; $larray['event_file'] = __FILE__; $larray['event_file_line'] = __LINE__; $larray['event_type'] = 'send'; $larray['event_source'] = 'pushover'; $larray['event_version'] = '1'; $larray['log_backtrace'] = true; $log->add($larray); } return false; }
/** * validateAddPortfolio * * Validate new portfolio * @param($_POST) * @return(boolean) */ public function validateAddPortfolio() { # get the modal $oPortfolio = singleton::getInstance('Portfolio'); # the slug $page_slug = $_POST['page_slug']; # create empty error $aErrors = array(); if (strlen($_POST['portfolio_title']) >= 30) { $aErrors['title'] = true; } if (strlen($_POST['portfolio_description']) >= 1000) { $aErrors['description'] = true; } if (strlen($_POST['portfolio_github_link']) >= 100) { $aErrors['github'] = true; } if (strlen($_POST['portfolio_website_link']) >= 100) { $aErrors['portfolio_website_link'] = true; } if (strlen($_POST['portfolio_meta_title']) >= 100) { $aErrors['portfolio_meta_title'] = true; } if (strlen($_POST['portfolio_meta_keyword']) >= 1000) { $aErrors['portfolio_meta_title'] = true; } if (strlen($_POST['portfolio_meta_desc']) >= 2) { $aErrors['portfolio_meta_desc'] = true; } if (strlen($page_slug) >= 25) { $aErrors['page_slug_too_long'] = true; } # check regex if (!preg_match('/^[a-z0-9-]+$/', $page_slug)) { $aErrors['not_a_valid_regex'] = true; } # check if availble if (!$oPortfolio->checkSlugAvailable($page_slug)) { $aErrors['slug_not_available'] = true; } if ($aErrors) { return var_dump($aErrors); } else { return true; } }
private function can_view($array) { $auth =& singleton::get(__NAMESPACE__ . '\\auth'); $tickets =& singleton::get(__NAMESPACE__ . '\\tickets'); $user_level = (int) $auth->get('user_level'); switch ($user_level) { case 6: //admin break; case 5: //moderator $get_array['department_or_assigned_or_user_id'] = $auth->get('id'); break; case 4: //staff member $get_array['department_or_assigned_or_user_id'] = $auth->get('id'); break; case 3: //user $get_array['assigned_or_user_id'] = $auth->get('id'); break; case 2: //global moderator break; default: //sub $get_array['user_id'] = $auth->get('id'); break; } $get_array['count'] = true; $get_array['id'] = (int) $array['id']; $result = $tickets->get($get_array); if (!empty($result) && $result[0]['count'] != 0) { return true; } else { return false; } }
function display() { $config =& singleton::get(__NAMESPACE__ . '\\config'); $language =& singleton::get(__NAMESPACE__ . '\\language'); header("Content-type: image/png"); if (isset($this->text) && !empty($this->text)) { $capture_text = $this->text; } else { $capture_text = $language->get('Error'); } $string = strtoupper($capture_text); $r = rand(0, 150); $g = rand(0, 150); $b = rand(0, 150); $im = imagecreatefrompng(THEMES . '/' . CURRENT_THEME . '/images/captcha_background.png'); $colour = imagecolorallocate($im, $r, $g, $b); $size = rand(20, 25); $angle = rand(0, 3); $left = rand(5, 17); $bottomleft = 38; imagettftext($im, $size, $angle, $left, $bottomleft, $colour, SYSTEM . "/fonts/delicious.otf", $string); imagepng($im); imagedestroy($im); }
public static function getInstance() { return parent::getInstance(get_class()); }
public static function getInstance($v4a8a08f09d37b73795649038408b5f33 = NULL) { return parent::getInstance(__CLASS__); }
/** * Returns an HTML string while stripping out bad HTML * * @param string $string The HTML to make safe * @return string The safe HTML */ function html_output($string) { $purifier =& singleton::get('HTMLPurifier'); return $purifier->purify($string); }
function get($array = NULL) { global $db; $tables =& singleton::get(__NAMESPACE__ . '\\tables'); $error =& singleton::get(__NAMESPACE__ . '\\error'); $site_id = SITE_ID; $query = "SELECT mn.*, {$tables->users}.name, {$tables->users}.email FROM {$tables->message_notes} mn, {$tables->users} WHERE mn.site_id = :site_id"; if (isset($array['id'])) { $query .= " AND mn.id = :id"; } if (isset($array['user_id'])) { $query .= " AND mn.user_id = :user_id"; } if (isset($array['message_id'])) { $query .= " AND mn.message_id = :message_id"; } $query .= " AND {$tables->users}.id = mn.user_id"; $query .= " ORDER BY mn.id"; try { $stmt = $db->prepare($query); } catch (\PDOException $e) { $error->create(array('type' => 'sql_prepare_error', 'message' => $e->getMessage())); } $stmt->bindParam(':site_id', $site_id, database::PARAM_INT); if (isset($array['id'])) { $stmt->bindParam(':id', $array['id'], database::PARAM_INT); } if (isset($array['user_id'])) { $stmt->bindParam(':user_id', $array['user_id'], database::PARAM_INT); } if (isset($array['message_id'])) { $stmt->bindParam(':message_id', $array['message_id'], database::PARAM_INT); } try { $stmt->execute(); } catch (\PDOException $e) { $error->create(array('type' => 'sql_execute_error', 'message' => $e->getMessage())); } $items = $stmt->fetchAll(database::FETCH_ASSOC); return $items; }
function delete_group($array = NULL) { global $db; if (!isset($array['id'])) { return false; } $error =& singleton::get(__NAMESPACE__ . '\\error'); $log =& singleton::get(__NAMESPACE__ . '\\log'); $tables =& singleton::get(__NAMESPACE__ . '\\tables'); $auth =& singleton::get(__NAMESPACE__ . '\\auth'); $config =& singleton::get(__NAMESPACE__ . '\\config'); $site_id = SITE_ID; $query = "DELETE FROM {$tables->ticket_field_values} WHERE site_id = :site_id"; if (isset($array['id'])) { $query .= " AND ticket_field_group_id = :id"; } try { $stmt = $db->prepare($query); } catch (\Exception $e) { $error->create(array('type' => 'sql_prepare_error', 'message' => $e->getMessage())); } $stmt->bindParam(':site_id', $site_id, database::PARAM_INT); if (isset($array['id'])) { $stmt->bindParam(':id', $array['id'], database::PARAM_INT); } try { $stmt->execute(); } catch (\Exception $e) { $error->create(array('type' => 'sql_execute_error', 'message' => $e->getMessage())); } $query = "DELETE FROM {$tables->ticket_fields} WHERE site_id = :site_id"; if (isset($array['id'])) { $query .= " AND ticket_field_group_id = :id"; } try { $stmt = $db->prepare($query); } catch (\Exception $e) { $error->create(array('type' => 'sql_prepare_error', 'message' => $e->getMessage())); } $stmt->bindParam(':site_id', $site_id, database::PARAM_INT); if (isset($array['id'])) { $stmt->bindParam(':id', $array['id'], database::PARAM_INT); } try { $stmt->execute(); } catch (\Exception $e) { $error->create(array('type' => 'sql_execute_error', 'message' => $e->getMessage())); } $query = "DELETE FROM {$tables->ticket_field_group} WHERE site_id = :site_id"; if (isset($array['id'])) { $query .= " AND id = :id"; } try { $stmt = $db->prepare($query); } catch (\Exception $e) { $error->create(array('type' => 'sql_prepare_error', 'message' => $e->getMessage())); } $stmt->bindParam(':site_id', $site_id, database::PARAM_INT); if (isset($array['id'])) { $stmt->bindParam(':id', $array['id'], database::PARAM_INT); } try { $stmt->execute(); } catch (\Exception $e) { $error->create(array('type' => 'sql_execute_error', 'message' => $e->getMessage())); } }
/** * Logs out the current user. */ public function logout() { $plugins =& singleton::get(__NAMESPACE__ . '\\plugins'); $plugins->run('auth_logout_start'); unset($this->current_user); session_destroy(); }
function disable($plugin_name) { $config =& singleton::get(__NAMESPACE__ . '\\config'); $log =& singleton::get(__NAMESPACE__ . '\\log'); if (in_array($plugin_name, $this->installed_plugins)) { $key = array_search($plugin_name, $this->installed_plugins); unset($this->installed_plugins[$key]); $this->installed_plugins = array_values($this->installed_plugins); $log_array['event_severity'] = 'notice'; $log_array['event_number'] = E_USER_NOTICE; $log_array['event_description'] = 'Plugin Disabled "' . $plugin_name . '"'; $log_array['event_file'] = __FILE__; $log_array['event_file_line'] = __LINE__; $log_array['event_type'] = 'disable'; $log_array['event_source'] = 'plugins'; $log_array['event_version'] = '1'; $log_array['log_backtrace'] = false; $log->add($log_array); $config->set('plugin_data', $this->installed_plugins); } }
Sedan2::what_vehicle(); class singleton { public static $instance; private function __construct() { echo 'Contruct of singleton class called' . "\n"; } public static function get_instance() { if (!static::$instance instanceof static) { static::$instance = new static(); } return static::$instance; } public function test() { echo 'test function called' . "\n"; } } class B extends singleton { public static $instance; protected function __construct() { echo 'Construct of Class B called' . "\n"; } } singleton::get_instance()->test(); B::get_instance()->test(); B::get_instance()->test();
function delete($array = NULL) { global $db; $tables =& singleton::get(__NAMESPACE__ . '\\tables'); $error =& singleton::get(__NAMESPACE__ . '\\error'); $log =& singleton::get(__NAMESPACE__ . '\\log'); $site_id = SITE_ID; //delete user permissions if (isset($array['id'])) { $query = "DELETE FROM {$tables->users_to_departments} WHERE site_id = :site_id AND department_id = :department_id"; try { $stmt = $db->prepare($query); } catch (\PDOException $e) { $error->create(array('type' => 'sql_prepare_error', 'message' => $e->getMessage())); } $stmt->bindParam(':site_id', $site_id, database::PARAM_INT); $stmt->bindParam(':department_id', $array['id'], database::PARAM_INT); try { $stmt->execute(); } catch (\PDOException $e) { $error->create(array('type' => 'sql_execute_error', 'message' => $e->getMessage())); } } //delete ticket departments $query = "DELETE FROM {$tables->ticket_departments} WHERE site_id = :site_id"; if (isset($array['id'])) { $query .= " AND id = :id"; } if (isset($array['enabled'])) { $query .= " AND enabled = :enabled"; } try { $stmt = $db->prepare($query); } catch (\PDOException $e) { $error->create(array('type' => 'sql_prepare_error', 'message' => $e->getMessage())); } $stmt->bindParam(':site_id', $site_id, database::PARAM_INT); if (isset($array['id'])) { $stmt->bindParam(':id', $array['id'], database::PARAM_INT); } if (isset($array['enabled'])) { $stmt->bindParam(':enabled', $array['enabled'], database::PARAM_INT); } try { $stmt->execute(); } catch (\PDOException $e) { $error->create(array('type' => 'sql_execute_error', 'message' => $e->getMessage())); } $log_array['event_severity'] = 'notice'; $log_array['event_number'] = E_USER_NOTICE; $log_array['event_description'] = 'Ticket Department Deleted ID ' . safe_output($array['id']); $log_array['event_file'] = __FILE__; $log_array['event_file_line'] = __LINE__; $log_array['event_type'] = 'delete'; $log_array['event_source'] = 'ticket_departments'; $log_array['event_version'] = '1'; $log_array['log_backtrace'] = false; $log->add($log_array); }
/** * intance */ public static function get_instance() { return parent::_get_instance(__CLASS__); }
public function send_email($array) { $config =& singleton::get(__NAMESPACE__ . '\\config'); $log =& singleton::get(__NAMESPACE__ . '\\log'); $pop_accounts =& singleton::get(__NAMESPACE__ . '\\pop_accounts'); $smtp_accounts =& singleton::get(__NAMESPACE__ . '\\smtp_accounts'); try { //clear any current info $this->phpmailer->ClearAllRecipients(); $this->phpmailer->ClearAttachments(); $this->phpmailer->From = 'do_not_reply@' . $config->get('domain'); $found_smtp_account = false; if (isset($array['pop_account_id']) && !empty($array['pop_account_id'])) { $pop_array = $pop_accounts->get(array('id' => $array['pop_account_id'], 'get_other_data' => true)); if (!empty($pop_array) && !empty($pop_array[0]['smtp_hostname']) && $pop_array[0]['smtp_enabled'] == 1) { $smtp['hostname'] = $pop_array[0]['smtp_hostname']; $smtp['port'] = $pop_array[0]['smtp_port']; $smtp['tls'] = $pop_array[0]['smtp_tls']; $smtp['username'] = $pop_array[0]['smtp_username']; $smtp['password'] = decode($pop_array[0]['smtp_password']); $smtp['authentication'] = $pop_array[0]['smtp_authentication']; $smtp['email_address'] = $pop_array[0]['smtp_email_address']; $found_smtp_account = true; } } else { if (isset($array['smtp_account_id']) && !empty($array['smtp_account_id'])) { $smtp_array = $smtp_accounts->get(array('id' => $array['smtp_account_id'])); if (!empty($smtp_array) && !empty($smtp_array[0]['hostname']) && $smtp_array[0]['enabled'] == 1) { $smtp['hostname'] = $smtp_array[0]['hostname']; $smtp['port'] = $smtp_array[0]['port']; $smtp['tls'] = $smtp_array[0]['tls']; $smtp['username'] = $smtp_array[0]['username']; $smtp['password'] = decode($smtp_array[0]['password']); $smtp['authentication'] = $smtp_array[0]['authentication']; $smtp['email_address'] = $smtp_array[0]['email_address']; $found_smtp_account = true; } } } if (!$found_smtp_account) { $smtp_array = $smtp_accounts->get(array('id' => $config->get('default_smtp_account'))); if (!empty($smtp_array) && !empty($smtp_array[0]['hostname']) && $smtp_array[0]['enabled'] == 1) { $smtp['hostname'] = $smtp_array[0]['hostname']; $smtp['port'] = $smtp_array[0]['port']; $smtp['tls'] = $smtp_array[0]['tls']; $smtp['username'] = $smtp_array[0]['username']; $smtp['password'] = decode($smtp_array[0]['password']); $smtp['authentication'] = $smtp_array[0]['authentication']; $smtp['email_address'] = $smtp_array[0]['email_address']; $found_smtp_account = true; } } if ($found_smtp_account) { //what server to send the email to $this->phpmailer->Host = $smtp['hostname']; $this->phpmailer->Mailer = 'smtp'; //setup authentication if required if ($smtp['authentication']) { $this->phpmailer->SMTPAuth = true; // turn on SMTP authentication $this->phpmailer->Username = $smtp['username']; $this->phpmailer->Password = $smtp['password']; } if ($smtp['tls']) { $this->phpmailer->SMTPSecure = 'tls'; } $this->phpmailer->Port = (int) $smtp['port']; //setup the basic email stuff if (isset($array['from'])) { $this->phpmailer->From = $array['from']; } else { if (!empty($smtp['email_address'])) { $this->phpmailer->From = $smtp['email_address']; } } } else { $this->phpmailer->Mailer = 'mail'; if (isset($array['from'])) { $this->phpmailer->From = $array['from']; } } //increase the default timeout to 15 seconds $this->phpmailer->Timeout = 15; $this->phpmailer->CharSet = 'utf-8'; if (isset($array['html']) && $array['html'] == true) { $this->phpmailer->IsHTML(true); } if (isset($array['from_name'])) { $this->phpmailer->FromName = $array['from_name']; } else { $this->phpmailer->FromName = $config->get('name'); } $this->phpmailer->Subject = $array['subject']; $this->phpmailer->Body = $array['body']; if (isset($array['to']) && is_array($array['to'])) { if (!empty($array['to']['to'])) { $this->phpmailer->AddAddress($array['to']['to'], $array['to']['to_name']); } } //add multiple files if (isset($array['file']) && is_array($array['file'])) { foreach ($array['file'] as $file) { if (file_exists($file['file'])) { $this->phpmailer->AddAttachment($file['file'], $file['file_name']); } } } //add multiple files via a string (I haven't really tested this yet) if (isset($array['string_file']) && is_array($array['string_file'])) { foreach ($array['string_file'] as $string) { $this->phpmailer->AddStringAttachment($string['string'], $string['string_name']); } } //let's try and send the email now $this->phpmailer->Send(); $array['event_severity'] = 'notice'; $array['event_number'] = E_USER_NOTICE; if (isset($array['to']) && is_array($array['to'])) { $array['event_description'] = 'Email sent to "' . safe_output($array['to']['to']) . '" from "' . $this->phpmailer->From . '"'; } else { $array['event_description'] = 'Email sent from "' . $this->phpmailer->From . '"'; } $array['event_file'] = __FILE__; $array['event_file_line'] = __LINE__; $array['event_type'] = 'email_sent'; $array['event_source'] = 'mailer'; $array['event_version'] = '1'; $array['log_backtrace'] = false; $log->add($array); return true; } catch (\phpmailerException $e) { $array['event_severity'] = 'warning'; $array['event_number'] = E_USER_WARNING; $array['event_description'] = $e->errorMessage(); $array['event_file'] = __FILE__; $array['event_file_line'] = __LINE__; $array['event_type'] = 'email_not_sent'; $array['event_source'] = 'mailer'; $array['event_version'] = '1'; $array['log_backtrace'] = true; $log->add($array); return false; } catch (\Exception $e) { $array['event_severity'] = 'warning'; $array['event_number'] = E_USER_WARNING; $array['event_description'] = $e->getMessage(); $array['event_file'] = __FILE__; $array['event_file_line'] = __LINE__; $array['event_type'] = 'email_not_sent'; $array['event_source'] = 'mailer'; $array['event_version'] = '1'; $array['log_backtrace'] = true; $log->add($array); return false; } }
//message_notes $ticket_custom_fields =& singleton::get(__NAMESPACE__ . '\\ticket_custom_fields'); //pushover $pushover =& singleton::get(__NAMESPACE__ . '\\pushover'); //users_to_departments $users_to_departments =& singleton::get(__NAMESPACE__ . '\\users_to_departments'); //db_maintenance $db_maintenance =& singleton::get(__NAMESPACE__ . '\\db_maintenance'); require FUNCTIONS . '/default_tasks.php'; /** * * URL Handling Code. Everything is redirected with the .htaccess file to index.php?url= * */ if (isset($_GET['url'])) { $input_url = $_GET['url']; } else { $input_url = ''; } $url =& singleton::get(__NAMESPACE__ . '\\url', array('url' => $input_url)); unset($input_url); $auth->load(); //html purifier include LIB . '/htmlpurifier/HTMLPurifier.auto.php'; $htmlpurifier_config = \HTMLPurifier_Config::createDefault(); //default html is set to XHTML 1.1 //$htmlpurifier_config->set('Core.Encoding', 'XHTML 1.1'); //create the class we are going to use. $purifier =& singleton::get('HTMLPurifier', $htmlpurifier_config); $plugins->load(); $plugins->run('loader');
<?php $oPortfolio = singleton::getInstance('Portfolio'); $oFile = singleton::getInstance('FileModel'); # get the portfolios amount $countPortfolios = $oPortfolio->countPortfolios(); $oSmarty->assign('countPortfolios', $countPortfolios); # get the users file amount if ($oUser->isAdmin()) { $oSmarty->assign('countFiles', $oFile->countFiles($id = $oUser->getUserId(), $deleted = true)); } else { $oSmarty->assign('countFiles', $oFile->countFiles($id = $oUser->getUserId())); }