本文整理汇总了PHP中handle_error函数的典型用法代码示例。如果您正苦于以下问题:PHP handle_error函数的具体用法?PHP handle_error怎么用?PHP handle_error使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了handle_error函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: authorize_user
function authorize_user($groups = NULL)
{
// No need to check groups if there aren't cookies set
if (!isset($_SESSION['user_id']) || !strlen($_SESSION['user_id']) > 0) {
header('Location: signin.php?' . 'error_message=You must login to see this page.');
exit;
}
// If no groups passed in, the authorization above is enough
if (is_null($groups) || empty($groups)) {
return;
}
// Set up the query string
$query_string = "SELECT ug.user_id" . " FROM user_groups ug, groups g" . " WHERE g.name = '%s'" . " AND g.id = ug.group_id" . " AND ug.user_id = " . mysql_real_escape_string($_SESSION['user_id']);
// Run through each group and check membership
foreach ($groups as $group) {
$query = sprintf($query_string, mysql_real_escape_string($group));
$result = mysql_query($query);
if (isset($result) && mysql_num_rows($result) == 1) {
// If we got a result, the user should be allowed access
// Just return so the script will continue to run
return;
}
}
// If we got here, no matches were found for any group
// The user isn't allowed access
handle_error("You are not authorized to see this page.");
exit;
}
示例2: set_item_data
public function set_item_data($user_id, $canceled = FALSE)
{
if (is_class($user_id, 'User')) {
$user_id = $user_id->get_id();
}
if (isset($this->index_object) && is_int($user_id) && $this->index_object->get_field('user_id') == $user_id) {
//不允許跟標註使用者相同的使用者新增
handle_error('annotation_like_collection.deny_annotation_author.exception');
return $this;
}
return parent::set_item_data($user_id, array('canceled' => $canceled));
}
示例3: get_referer_url
function get_referer_url($show_exception = FALSE)
{
$url = getenv("HTTP_REFERER");
if ($url !== FALSE) {
if (substr($url, -1, 1) == "/") {
$url = substr($url, 0, -1);
}
return $url;
} else {
if ($show_exception) {
handle_error('Cannot get referer url.');
}
return FALSE;
}
}
示例4: _post_update
protected function _post_update()
{
parent::_post_update();
//假如是喜歡的話……
$canceled = $this->get_field('canceled');
if ($canceled === FALSE or $canceled == 'FALSE' or $canceled == 'f') {
$annotation_id = intval($this->get_field('annotation_id'));
$user_id = intval($this->get_field('user_id'));
if ($annotation_id != 0 && $user_id != 0) {
$this->_CI_load('library', 'kals_resource/Annotation', 'annotation');
$this->_CI_load('library', 'kals_actor/User', 'user');
$trigger_resource = new Annotation($annotation_id);
$association_user = $trigger_resource->get_user();
$trigger_actor = new User($user_id);
$this->_CI_load('library', 'kals_actor/Notification_liked', 'notification_liked');
$notification = $this->CI->notification_liked->create_notification($association_user, $trigger_resource, $trigger_actor);
if (is_null($notification)) {
handle_error($this->lang->line('notification.liked.create_notification.exception'));
}
}
}
//if ($canceled == FALSE OR $canceled == 'FALSE')
}
示例5: get_referer_url
function get_referer_url($show_exception = FALSE)
{
$url = getenv("HTTP_REFERER");
if ($url === FALSE) {
if (isset($GLOBALS['context']) !== FALSE) {
$url = $GLOBALS['context']->get_referer_url();
}
}
if ($url !== FALSE) {
/**
* 加入刪除多餘首頁檔案名稱的修正
* @author Pulipuli Chen 20131117
*/
$url = url_strip_index($url);
if (substr($url, -1, 1) == "/") {
$url = substr($url, 0, -1);
}
if (isset($GLOBALS['context']) !== FALSE) {
$GLOBALS['context']->set_referer_url($url);
}
$CI =& get_instance();
$localhost_domains = $CI->config->item("web_apps.localhost_domains");
$localhost_domains[] = "http://127.0.0.1/";
foreach ($localhost_domains as $key => $domain) {
if (starts_with($url, $domain)) {
$url = str_replace($domain, "http://localhost/", $url);
break;
}
}
return $url;
} else {
if ($show_exception) {
handle_error('Cannot get referer url.');
}
return FALSE;
}
}
示例6: IteroAPI
<?php
include 'config.php';
include 'iteroapi.php';
$contractid = $_GET['contractid'];
// Get a default self service portal URL
// from Itero for a sepcific contract
$itero = new IteroAPI($clientid, $clientsecret);
$token = $itero->get_selfservice_token($contractid);
if (!$token) {
handle_error(500, "Could not fetch token");
}
$portalurl = $token->Url;
?>
<!doctype html>
<html>
<head>
<title>Customer Portal</title>
</head>
<body>
<a href="/customers.php">Back to customer list</a>
<iframe width="100%" height="2000px" src="<?php
echo $portalurl;
?>
"></iframe>
</body>
</html>
示例7: _get_post_json
/**
* 取得POST的值
*
* @author Pulipuli Chen <pulipuli.chen@gmail.com>
* 20131225 來自於annotation_setter
* @return String
*/
protected function _get_post_json()
{
if (isset($_POST['json'])) {
//return urldecode($_POST['json']);
//return $_POST['json'];
$json = $_POST["json"];
/**
* 20121224 Pulipuli Chen
* 移除scope中text包含\'的資料
*/
$json = str_replace("\\'", "'", $json);
return $json;
} else {
handle_error('Cannot get json data.');
}
}
示例8: login_require
function login_require($show_exception = TRUE)
{
$logined = FALSE;
if (isset($GLOBALS['context']) === FALSE) {
$logined = FALSE;
} else {
$user = get_context_user();
if (isset($user)) {
$domain = $user->get_domain();
$host = $domain->get_host();
if (get_referer_host(FALSE) === $host) {
$logined = TRUE;
}
}
}
if ($show_exception && $logined === FALSE) {
handle_error('login_require');
}
return $logined;
}
示例9: set_project_environment
/**
* Function set_project_environment
*
* Analyses configuration and current session to identify which project area
* is to be used.
* If a project is specified in the HTTP parameters then that is used, otherwise
* the current SESSION project is used. If none of these are specified then the default
* "reports" project is used
*/
function set_project_environment()
{
global $g_project;
global $g_menu;
global $g_menu_title;
$project = session_request_item("project", "reports");
$menu = false;
$menu_title = "Set Menu Title";
// Now we now the project include the relevant config.php
$projpath = "projects/" . $project;
$configfile = $projpath . "/config.php";
$menufile = $projpath . "/menu.php";
if (!is_file($projpath)) {
find_file_to_include($projpath, $projpath);
}
if (!$projpath) {
find_file_to_include("config.php", $configfile);
if ($configfile) {
include_once $configfile;
}
$g_project = false;
$g_menu = false;
$g_menu_title = "";
$old_error_handler = set_error_handler("ErrorHandler");
handle_error("Project Directory {$project} not found. Check INCLUDE_PATH or project name");
return;
}
if (!is_file($configfile)) {
find_file_to_include($configfile, $configfile);
}
if (!is_file($menufile)) {
find_file_to_include($menufile, $menufile);
}
if ($configfile) {
include_once $configfile;
if (is_file($menufile)) {
include_once $menufile;
} else {
handle_error("Menu Definition file menu.php not found in project {$project}", E_USER_WARNING);
}
} else {
find_file_to_include("config.php", $configfile);
if ($configfile) {
include_once $configfile;
}
$g_project = false;
$g_menu = false;
$g_menu_title = "";
$old_error_handler = set_error_handler("ErrorHandler");
handle_error("Configuration Definition file config.php not found in project {$project}", E_USER_ERROR);
}
$g_project = $project;
$g_menu = $menu;
$g_menu_title = $menu_title;
return $project;
}
示例10: handle_error
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
include 'config.php';
function handle_error($status = '404 Not Found', $header, $text)
{
global $config;
header('HTTP/1.0 ' . $status);
header('Status: ' . $status);
do_header();
echo '<h3>' . $header . '</h3>';
echo '<p class="warning">Sorry :-(</p>';
echo '<p>' . $text . '</p>';
echo '<p class="leave"><a href="' . $config['base'] . '">Go to ' . $config['shortener'] . '</a></p>';
do_footer();
die;
}
$short = get_params($_SERVER['PATH_INFO']);
$short_url = clean($short[0]);
if (empty($short_url)) {
go_to('/');
}
$query = mysql_query("SELECT long_url, status FROM urls WHERE short_url = CONVERT('{$short_url}' USING binary) LIMIT 1");
$result = mysql_fetch_row($query, MYSQL_ASSOC);
if (empty($result)) {
handle_error('404 Not Found', 'Not Found', 'We couldn\'t find that URL.');
}
if ($result['status'] == 'suspended') {
handle_error('403 Forbidden', 'Suspended URL', 'This URL has been suspended.');
}
$long_url = $result['long_url'];
go_to($long_url);
示例11: _post_update
protected function _post_update()
{
parent::_post_update();
if (isset($this->index_object)) {
$members = $this->_pre_update($this->members);
foreach ($members as $trigger_resource) {
$this->_CI_load('library', 'kals_actor/User', 'user');
$association_user = $trigger_resource->get_user();
$trigger_actor = $this->index_object->get_user();
$this->_CI_load('library', 'kals_actor/Notification_responded', 'notification_responded');
$notification = $this->CI->notification_responded->create_notification($association_user, $trigger_resource, $trigger_actor);
if (is_null($notification)) {
handle_error($this->lang->line('notification.responded.create_notification.exception'));
}
}
//foreach($members AS $trigger_resource)
}
//if (isset($index_id))
return $this;
}
示例12: transform_xml
function transform_xml()
{
global $bodyXML;
global $ct_style;
$bpDefDirectory = "";
$bodyStylesheetFileName = $bpDefDirectory . $ct_style;
$xsl = new DomDocument();
if (!$xsl->load($bodyStylesheetFileName)) {
$systemErrMsg = 'Unable to load batch process template: ' . $bodyStylesheetFileName;
handle_error($systemErrMsg, $outtype);
}
$stylesheet = new XsltProcessor();
$stylesheet->importStylesheet($xsl);
if (!($htmlBody = $stylesheet->transformToXML($bodyXML))) {
$systemErrMsg = 'XSL translation failed for report template: ' . $bodyStylesheetFileName;
handle_error($systemErrMsg, $outtype);
}
return $htmlBody;
}
示例13: is_admin
/**
* 檢查該actor是否能夠管理該resource。也就是allow的管理版
* @param KALSActor $actor
* @return boolean
*/
function is_admin($actor = NULL)
{
if (get_ignore_authorize()) {
return TRUE;
}
$actor = $this->_filter_actor($actor);
$is_admin = FALSE;
$resource = $this->resource;
switch ($resource->get_type_id()) {
case 1:
$action = $this->action_factory->create(1);
$is_admin = $this->allow($action);
break;
case 2:
$action = $this->action_factory->create(2);
$is_admin = $this->allow($action);
break;
case 3:
$author = $resource->get_user();
$is_admin = $author->equals($actor);
if ($is_admin === FALSE && $this->throw_exception) {
handle_error($this->lang->line('action.annotation.administration.exception'));
return FALSE;
}
break;
default:
$is_admin = FALSE;
}
return $is_admin;
}
示例14: set_load_callback
/**
* 設定callback的函式名稱,並檢查此函式能否運作。callback會在第一次取用此集合的成員時,先進行讀取成員資料的動作。
* @param string $function_name
* @param string $obj_or_clss
* @return Collection
*/
public function set_load_callback($function_name, $obj_or_clss = NULL)
{
$callback = NULL;
if ($obj_or_clss) {
$callback = array($obj_or_clss, $function_name);
} else {
$callback = $function_name;
}
if (FALSE === is_callable($callback, FALSE, $callable_name)) {
//throw new Exception("$callable_name is not callable as a parameter to onload");
handle_error("{$callable_name} is not callable as a parameter to onload");
return FALSE;
}
$this->onload = $callback;
$this->is_loaded = FALSE;
return $this;
}
示例15: reportico_meta_sql_criteria
static function reportico_meta_sql_criteria(&$in_query, $in_string, $prev_col_value = false)
{
// Replace user parameters with values
$external_param1 = get_reportico_session_param("external_param1");
$external_param2 = get_reportico_session_param("external_param2");
$external_param3 = get_reportico_session_param("external_param3");
$external_user = get_reportico_session_param("external_user");
if ( $external_param1 ) $in_string = preg_replace ("/{EXTERNAL_PARAM1}/", "'".$external_param1."'", $in_string);
if ( $external_param2 ) $in_string = preg_replace ("/{EXTERNAL_PARAM2}/", "'".$external_param2."'", $in_string);
if ( $external_param3 ) $in_string = preg_replace ("/{EXTERNAL_PARAM3}/", "'".$external_param3."'", $in_string);
if ( $external_user ) $in_string = preg_replace ("/{FRAMEWORK_USER}/", "'".$external_user."'", $in_string);
// Replace External parameters specified by {USER_PARAM,xxxxx}
if ( preg_match_all ( "/{USER_PARAM,([^}]*)}/", $in_string, $matches ) )
{
foreach ( $matches[0] as $k => $v )
{
$param = $matches[1][$k];
if ( isset($in_query->user_parameters[$param] ) )
{
$in_string = preg_replace("/{USER_PARAM,$param}/", $in_query->user_parameters[$param], $in_string);
}
else
{
trigger_error("User parameter $param, specified but not provided to reportico", E_USER_ERROR);
}
}
}
$looping = true;
$out_string = $in_string;
$ct = 0;
while ( $looping )
{
$ct++;
if ( $ct > 100 )
{
echo "Problem with SQL cannot resolve Criteria Items<br>";
break;
}
$regpat = "/{([^}]*)/";
if ( preg_match ( $regpat, $out_string, $matches ) )
{
$crit = $matches[1];
$first = substr($crit, 0, 1);
$critexp = $crit;
if ( $first == "=" )
{
$crit = substr ( $crit, 1 );
$critexp = $crit;
if ( array_key_exists($crit, $in_query->lookup_queries) )
$clause = $in_query->lookup_queries[$crit]->get_criteria_clause(false, false, true);
else if ( $cl = get_query_column($crit, $this->query->columns ) )
if ( $prev_col_value )
$clause = $cl->old_column_value;
else
$clause = $cl->column_value;
else
{
handle_error( "Unknown Criteria Item $crit in Query $in_string");
return $in_string;
}
}
else
{
$eltype = "VALUE";
$showquotes = true;
if ( preg_match ( "/(.*),(.*),(.*)/", $crit, $critel ) )
{
$crit = $critel[1];
$eltype = $critel[2];
if ( $critel[3] == "false" )
$showquotes = false;
}
if ( preg_match ( "/(.*),(.*)/", $crit, $critel ) )
{
$crit = $critel[1];
if ( $critel[2] == "false" )
$showquotes = false;
else
$eltype = $critel[2];
}
if ( array_key_exists($crit, $in_query->lookup_queries) )
{
switch ( $eltype )
{
case "FULL" :
$clause = $in_query->lookup_queries[$crit]->get_criteria_clause(true, true, true, false, false, $showquotes);
break;
case "RANGE1" :
$clause = $in_query->lookup_queries[$crit]->get_criteria_clause(false, false, false, true, false, $showquotes);
break;
case "RANGE2" :
$clause = $in_query->lookup_queries[$crit]->get_criteria_clause(false, false, false, false, true, $showquotes);
break;
//.........这里部分代码省略.........