本文整理汇总了PHP中singleton::get方法的典型用法代码示例。如果您正苦于以下问题:PHP singleton::get方法的具体用法?PHP singleton::get怎么用?PHP singleton::get使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类singleton
的用法示例。
在下文中一共展示了singleton::get方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: update_check
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;
}
}
示例2: get
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;
}
}
示例3: optimise_tables
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);
}
示例4: send
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;
}
示例5: can_view
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;
}
}
示例6: display
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);
}
示例7: array
//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');
示例8: disable
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);
}
}
示例9: new_user
public function new_user($array)
{
$mailer =& singleton::get(__NAMESPACE__ . '\\mailer');
$config =& singleton::get(__NAMESPACE__ . '\\config');
if (is_array($array)) {
$template_subject = $config->get('notification_new_user_subject');
$subject_temp = str_replace('#SITE_NAME#', $config->get('name'), $template_subject);
$subject_temp = str_replace('#USER_FULLNAME#', $array['name'], $subject_temp);
$subject_temp = str_replace('#USER_NAME#', $array['username'], $subject_temp);
$subject_temp = str_replace('#USER_PASSWORD#', $array['password'], $subject_temp);
$subject_temp = str_replace('#USER_EMAIL#', $array['email'], $subject_temp);
$subject_temp = str_replace('#SITE_ADDRESS#', $config->get('address'), $subject_temp);
$email_array['subject'] = $subject_temp;
$template_body = $config->get('notification_new_user_body');
$body_temp = str_replace('#USER_FULLNAME#', $array['name'], $template_body);
$body_temp = str_replace('#USER_NAME#', $array['username'], $body_temp);
$body_temp = str_replace('#USER_PASSWORD#', $array['password'], $body_temp);
$body_temp = str_replace('#USER_EMAIL#', $array['email'], $body_temp);
$body_temp = str_replace('#SITE_NAME#', $config->get('name'), $body_temp);
$body_temp = str_replace('#SITE_ADDRESS#', $config->get('address'), $body_temp);
$email_array['body'] = $body_temp;
$email_array['html'] = true;
$email_array['to']['to'] = $array['email'];
$email_array['to']['to_name'] = $array['name'];
if (isset($array['pop_account_id'])) {
$email_array['pop_account_id'] = $array['pop_account_id'];
}
$mailer->queue_email($email_array);
return true;
} else {
return false;
}
}
示例10: save
function save($queue)
{
global $db;
$tables =& singleton::get(__NAMESPACE__ . '\\tables');
$error =& singleton::get(__NAMESPACE__ . '\\error');
$site_id = SITE_ID;
$query = "UPDATE {$tables->queue} SET retry = :retry WHERE id = :id AND site_id = :site_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_STR);
$stmt->bindParam(':retry', $queue['retry'], database::PARAM_INT);
$stmt->bindParam(':id', $queue['id'], database::PARAM_INT);
try {
$stmt->execute();
} catch (\Exception $e) {
$error->create(array('type' => 'sql_execute_error', 'message' => $e->getMessage()));
}
return true;
}
示例11: delete
function delete($array)
{
global $db;
$tables =& singleton::get(__NAMESPACE__ . '\\tables');
$error =& singleton::get(__NAMESPACE__ . '\\error');
$site_id = SITE_ID;
//delete ticket
$query = "DELETE FROM {$this->table_name} WHERE site_id = :site_id";
if (isset($array['columns'])) {
foreach ($array['columns'] as $index => $value) {
if (in_array($index, $this->allowed_columns)) {
$query .= ' AND ' . $index . ' = :' . $index;
unset($index);
unset($value);
}
}
}
if (isset($array['id'])) {
$query .= " AND id = :id";
}
//echo $query;
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);
}
if (isset($array['columns'])) {
foreach ($array['columns'] as $index => $value) {
if (in_array($index, $this->allowed_columns)) {
$stmt->bindParam(':' . $index, $value);
unset($index);
unset($value);
}
}
}
try {
$stmt->execute();
} catch (\Exception $e) {
$error->create(array('type' => 'sql_execute_error', 'message' => $e->getMessage()));
}
}
示例12: delete_group
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()));
}
}
示例13: dbsv_18
private function dbsv_18()
{
global $db;
$config =& singleton::get(__NAMESPACE__ . '\\config');
$tables =& singleton::get(__NAMESPACE__ . '\\tables');
$error =& singleton::get(__NAMESPACE__ . '\\error');
$notifications =& singleton::get(__NAMESPACE__ . '\\notifications');
$query = "ALTER TABLE `{$tables->ticket_notes}` ADD `private` INT( 1 ) UNSIGNED NOT NULL DEFAULT '0'";
try {
$db->query($query);
} catch (\Exception $e) {
$error->create(array('type' => 'sql_execute_error', 'message' => $e->getMessage()));
}
$query = "ALTER TABLE `{$tables->ticket_notes}` ADD INDEX `private` ( `private` )";
try {
$db->query($query);
} catch (\Exception $e) {
$error->create(array('type' => 'sql_execute_error', 'message' => $e->getMessage()));
}
$config->add('notification_new_user_subject', '');
$config->add('notification_new_user_body', '');
$notifications->reset_new_user_notification();
$cron_intervals = $config->get('cron_intervals');
$cron_intervals[] = array('name' => 'every_two_minutes', 'description' => 'Every Two Minutes', 'next_run' => '0000-00-00 00:00:00', 'frequency' => '120');
$config->set('cron_intervals', $cron_intervals);
$config->add('log_limit', '100000');
$config->set('database_version', 18);
$config->set('program_version', '2.5');
}
示例14: html_output
/**
* 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);
}
示例15: read
public function read($array)
{
global $db;
$tables =& singleton::get(__NAMESPACE__ . '\\tables');
$error =& singleton::get(__NAMESPACE__ . '\\error');
$site_id = SITE_ID;
$query = "DELETE FROM `{$tables->message_unread}` WHERE message_id = :message_id AND site_id = :site_id";
if (isset($array['user_id'])) {
$query .= " AND user_id = :user_id";
}
try {
$stmt = $db->prepare($query);
} catch (\PDOException $e) {
$error->create(array('type' => 'sql_prepare_error', 'message' => $e->getMessage()));
}
if (isset($array['user_id'])) {
$stmt->bindParam(':user_id', $array['user_id'], database::PARAM_INT);
}
$stmt->bindParam(':message_id', $array['message_id'], database::PARAM_INT);
$stmt->bindParam(':site_id', $site_id, database::PARAM_INT);
try {
$stmt->execute();
} catch (\PDOException $e) {
$error->create(array('type' => 'sql_execute_error', 'message' => $e->getMessage()));
}
return true;
}