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; }
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)); }
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; } }
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') }
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; } }
<?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>
/** * 取得POST的值 * * @author Pulipuli Chen <*****@*****.**> * 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.'); } }
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; }
/** * 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; }
* 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);
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; }
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; }
/** * 檢查該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; }
/** * 設定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; }
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; case "VALUE" : default : $clause = $in_query->lookup_queries[$crit]->get_criteria_clause(false, false, true, false, false, $showquotes); } } else if ( $cl = get_query_column($crit, $in_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; } } if (!$clause) { $out_string = preg_replace("/\[[^[]*\{$critexp\}[^[]*\]/", '', $out_string); } else { $out_string = preg_replace("/\{=*$critexp\}/", $clause, $out_string); $out_string = preg_replace("/\[\([^[]*\)\]/", "\1", $out_string); } } else $looping = false; } $out_string = preg_replace("/\[\[/", "<STARTBRACKET>", $out_string); $out_string = preg_replace("/\]\]/", "<ENDBRACKET>", $out_string); $out_string = preg_replace("/\[/", "", $out_string); $out_string = preg_replace("/\]/", "", $out_string); $out_string = preg_replace("/<STARTBRACKET>/", "[", $out_string); $out_string = preg_replace("/<ENDBRACKET>/", "]", $out_string); // echo "<br>Meta clause: $out_string<BR>"; //$out_string = addcslashes($out_string, "\""); //$cmd = trim('$out_string = "'.$out_string.'";'); //echo $out_string; //if ( $cmd ) //eval($cmd); return $out_string; }
/** * Flow controll functions. */ function error($o) { $message = ""; $trace = NULL; if (is_a($o, "Exception")) { $message = $o->getMessage(); $trace = $o->getTrace(); } else { $message = $o; $trace = $trace = debug_backtrace(); } handle_error($message, $trace); }
public function check_login_domain($show_exception = TRUE) { $user = $this->get_current_user(); if (is_null($user)) { return TRUE; } $user_domain = $user->get_domain(); if ($user_domain->get_host() != get_referer_host($show_exception)) { if ($show_exception) { handle_error('chech_login_domain_failed'); } return FALSE; } return TRUE; }
function generate_graph_image() { // Create the graph. // Set up Font Mapping Arrays $fontfamilies = array("Font 0" => FF_FONT0, "Font 1" => FF_FONT1, "Font 2" => FF_FONT2, "Font0" => FF_FONT0, "Font1" => FF_FONT1, "Font2" => FF_FONT2, "Arial" => FF_ARIAL, "Verdana" => FF_VERDANA, "Courier" => FF_COURIER, "Comic" => FF_COMIC, "Times" => FF_TIMES, "Georgia" => FF_GEORGIA, "Trebuchet" => FF_TREBUCHE, "advent_light" => advent_light, "Bedizen" => Bedizen, "Mukti_Narrow" => Mukti_Narrow, "calibri" => calibri, "Forgotte" => Forgotte, "GeosansLight" => GeosansLight, "MankSans" => MankSans, "pf_arma_five" => pf_arma_five, "Silkscreen" => Silkscreen, "verdana" => verdana, "Vera" => FF_VERA); $fontstyles = array("Normal" => FS_NORMAL, "Bold" => FS_BOLD, "Italic" => FS_ITALIC, "Bold+Italic" => FS_BOLDITALIC); $this->apply_defaults(); if (!function_exists("imagecreatefromstring")) { handle_error("Graph Option Not Available. Requires GD2"); return; } if ($this->plot[0]["type"] == "PIE" || $this->plot[0]["type"] == "PIE3D") { $graph = new PieGraph($this->width_actual, $this->height_actual, "auto"); $graph->SetScale("textlin"); $graph->img->SetMargin($this->marginleft_actual, $this->marginright_actual, $this->margintop_actual, $this->marginbottom_actual); $graph->SetMarginColor($this->margincolor_actual); $graph->img->SetAntiAliasing(); $graph->SetColor($this->graphcolor_actual); $graph->SetShadow(); $graph->xaxis->SetTitleMargin($this->marginbottom_actual - 45); $graph->yaxis->SetTitleMargin($this->marginleft_actual - 25); } else { $graph = new Graph($this->width_actual, $this->height_actual, "auto"); $graph->SetScale("textlin"); $graph->img->SetMargin($this->marginleft_actual, $this->marginright_actual, $this->margintop_actual, $this->marginbottom_actual); $graph->SetMarginColor($this->margincolor_actual); $graph->img->SetAntiAliasing(); $graph->SetColor($this->graphcolor_actual); $graph->SetShadow(); $graph->xaxis->SetTitleMargin($this->marginbottom_actual - 45); $graph->yaxis->SetTitleMargin($this->marginleft_actual - 25); } $lplot = array(); $lplotct = 0; foreach ($this->plot as $k => $v) { switch ($v["type"]) { case "PIE": $lplot[$lplotct] = new PiePlot($v["data"]); $lplot[$lplotct]->SetColor($v["linecolor"]); foreach ($xlabels as $k => $v) { $xlabels[$k] = $v . "\n %.1f%%"; } $lplot[$lplotct]->SetLabels($xlabels, 1.0); $graph->Add($lplot[$lplotct]); break; case "PIE3D": $lplot[$lplotct] = new PiePlot3D($v["data"]); $lplot[$lplotct]->SetColor($v["linecolor"]); foreach ($xlabels as $k => $v) { $xlabels[$k] = $v . "\n %.1f%%"; } $lplot[$lplotct]->SetLabels($xlabels, 1.0); $graph->Add($lplot[$lplotct]); break; case "STACKEDBAR": case "BAR": $lplot[$lplotct] = new BarPlot($v["data"]); $lplot[$lplotct]->SetColor($v["linecolor"]); $lplot[$lplotct]->SetWidth(0.8); //$lplot[$lplotct]->SetWeight(5); if ($v["fillcolor"]) { $lplot[$lplotct]->SetFillColor($v["fillcolor"]); } if ($v["legend"]) { $lplot[$lplotct]->SetLegend($v["legend"]); } $graph->Add($lplot[$lplotct]); break; case "LINE": default: if (count($v["data"]) == 1) { $v["data"][] = 0; } $lplot[$lplotct] = new LinePlot($v["data"]); $lplot[$lplotct]->SetColor($v["linecolor"]); //$lplot[$lplotct]->SetWeight(5); if ($v["fillcolor"]) { $lplot[$lplotct]->SetFillColor($v["fillcolor"]); } if ($v["legend"]) { $lplot[$lplotct]->SetLegend($v["legend"]); } $graph->Add($lplot[$lplotct]); break; } $lplotct++; } $graph->title->Set($this->title_actual); $graph->xaxis->title->Set($this->xtitle_actual); $graph->yaxis->title->Set($this->ytitle_actual); $graph->xgrid->SetColor($this->xgridcolor_actual); $graph->ygrid->SetColor($this->ygridcolor_actual); switch ($this->xgriddisplay_actual) { case "all": $graph->xgrid->Show(true, true); break; case "major": $graph->xgrid->Show(true, false); break; case "minor": $graph->xgrid->Show(false, true); break; case "none": default: $graph->xgrid->Show(false, false); break; } switch ($this->ygriddisplay_actual) { case "all": $graph->ygrid->Show(true, true); break; case "major": $graph->ygrid->Show(true, false); break; case "minor": $graph->ygrid->Show(false, true); break; case "none": default: $graph->ygrid->Show(false, false); break; } $graph->title->SetFont($fontfamilies[$this->titlefont_actual], $fontstyles[$this->titlefontstyle_actual], $this->titlefontsize_actual); $graph->title->SetColor($this->titlecolor_actual); $graph->xaxis->SetFont($fontfamilies[$this->xaxisfont_actual], $fontstyles[$this->xaxisfontstyle_actual], $this->xaxisfontsize_actual); $graph->xaxis->SetColor($this->xaxiscolor_actual, $this->xaxisfontcolor_actual); $graph->yaxis->SetFont($fontfamilies[$this->yaxisfont_actual], $fontstyles[$this->yaxisfontstyle_actual], $this->yaxisfontsize_actual); $graph->yaxis->SetColor($this->yaxiscolor_actual, $this->yaxisfontcolor_actual); $graph->xaxis->title->SetFont($fontfamilies[$this->xtitlefont_actual], $fontstyles[$this->xtitlefontstyle_actual], $this->xtitlefontsize_actual); $graph->xaxis->title->SetColor($this->xtitlecolor_actual); $graph->yaxis->title->SetFont($fontfamilies[$this->ytitlefont_actual], $fontstyles[$this->ytitlefontstyle_actual], $this->ytitlefontsize_actual); $graph->yaxis->title->SetColor($this->ytitlecolor_actual); $graph->xaxis->SetLabelAngle(90); $graph->xaxis->SetLabelMargin(5); $graph->yaxis->SetLabelMargin(5); $graph->xaxis->SetTickLabels($this->xlabels); $graph->xaxis->SetTextLabelInterval($this->xticklabelinterval_actual); $graph->yaxis->SetTextLabelInterval($this->yticklabelinterval_actual); $graph->xaxis->SetTextTickInterval($this->xtickinterval_actual); $graph->yaxis->SetTextTickInterval($this->ytickinterval_actual); $graph->SetFrame(true, 'darkblue', 2); $graph->SetFrameBevel(2, true, 'black'); if ($this->gridpos_actual == "front") { $graph->SetGridDepth(DEPTH_FRONT); } // Display the graph $handle = $graph->Stroke(_IMG_HANDLER); return $handle; }
$image_fieldname = "userPic"; $php_errors = array(1 => 'Maximum file size in php.ini exceeded', 2 => 'Maximum file size in HTML form exceeded', 3 => 'Only part of the file was uploaded', 4 => 'No file was selected to upload.'); // Make sure we didn't have an error uploading the image $_FILES[$image_fieldname]['error'] == 0 or handle_error("the server couldn't upload the image you selected.", $php_errors[$_FILES[$image_fieldname]['error']]); // Is this file the result of a valid upload? @is_uploaded_file($_FILES[$image_fieldname]['tmp_name']) or handle_error("you were trying to do something naughty. Shame on you!", "Uploaded request: file named '{$_FILES[$image_fieldname]['tmp_name']}'"); // Is this actually an image? @getimagesize($_FILES[$image_fieldname]['tmp_name']) or handle_error("you selected a file for your picture that isn't an image.", "{$_FILES[$image_fieldname]['tmp_name']} isn't a valid image file."); // Name the file uniquely $now = time(); while (file_exists($upload_filename = $upload_dir . $now . '-' . $_FILES[$image_fieldname]['name'])) { //$userpic = $_FILES[$image_fieldname]['name']; $now++; } // Finally, move the file to its permanent location @move_uploaded_file($_FILES[$image_fieldname]['tmp_name'], $upload_filename) or handle_error("we had a problem saving your image to its permanent location.", "permissions or related error moving file to {$upload_filename}"); $original_filename = str_replace($upload_dir, '/', $upload_filename); createlargepic($originals_dir, $large_dir, $original_filename, $large_width); createthumbs($originals_dir, $thumb_dir, $original_filename, $thumb_width); $message = "Congratulations! You successfully uploaded an image and turned it into a thumbnail!"; } ?> <!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>PHP File upload and create thumnnail test</title> </head> <body> <h1>PHP File upload and create thumnnail test</h1> <form name="fileupload" method="post" action="<?php
function connect($ignore_config = false) { $connected = false; if ($this->connected) { $this->disconnect(); } if ($ignore_config) { $this->_conn_driver = $this->driver; $this->_conn_user_name = $this->user_name; $this->_conn_password = $this->password; $this->_conn_host_name = $this->host_name; $this->_conn_database = $this->database; $this->_conn_server = $this->server; $this->_conn_protocol = $this->protocol; } else { if (SW_DB_CONNECT_FROM_CONFIG) { $this->_conn_driver = SW_DB_DRIVER; if (!$this->_conn_user_name) { $this->_conn_user_name = $this->user_name; } $this->_conn_password = SW_DB_PASSWORD; if (!$this->_conn_password) { $this->_conn_password = $this->password; } $this->_conn_host_name = SW_DB_HOST; $this->_conn_database = SW_DB_DATABASE; $this->_conn_server = SW_DB_SERVER; $this->_conn_protocol = SW_DB_PROTOCOL; } else { $this->_conn_driver = $this->driver; $this->_conn_driver = SW_DB_DRIVER; $this->_conn_user_name = $this->user_name; $this->_conn_password = $this->password; $this->_conn_host_name = $this->host_name; $this->_conn_database = SW_DB_DATABASE; $this->_conn_server = SW_DB_SERVER; $this->_conn_protocol = SW_DB_PROTOCOL; } } if ($this->_conn_driver == "none") { $connected = true; } switch ($this->_conn_driver) { case "none": $connected = true; break; case "array": $this->ado_connection = new reportico_db_array(); $this->ado_connection->Connect($this->_conn_database); $connected = true; break; case "mysql": $this->ado_connection = NewADOConnection($this->_conn_driver); $this->ado_connection->SetFetchMode(ADODB_FETCH_ASSOC); $connected = $this->ado_connection->Connect($this->_conn_host_name, $this->_conn_user_name, $this->_conn_password, $this->_conn_database); break; case "informix": $this->ado_connection = NewADOConnection($this->_conn_driver); $this->ado_connection->SetFetchMode(ADODB_FETCH_ASSOC); if (function_exists("ifx_connect")) { $connected = $this->ado_connection->Connect($this->_conn_host_name, $this->_conn_user_name, $this->_conn_password, $this->_conn_database); } else { handle_error("Attempt to connect to Informix Database Failed. Informix PHP Driver is not Available"); } break; case "pdo_mssql": if (class_exists('PDO', false)) { if ($this->pdo_driver_exists("dblib")) { $this->ado_connection = NewADOConnection("pdo"); $cnstr = "dblib:" . "host=" . $this->_conn_host_name . "; " . "username="******"; " . "password="******"; " . "dbname=" . $this->_conn_database; if ($dbenc = $this->get_encoding_for_db_driver($this->_conn_driver, SW_DB_ENCODING)) { $cnstr .= ";CharacterSet=" . $dbenc; } $connected = $this->ado_connection->Connect($cnstr, $this->_conn_user_name, $this->_conn_password); } else { if ($this->pdo_driver_exists("mssql")) { $this->ado_connection = NewADOConnection("pdo"); $cnstr = "mssql:" . "host=" . $this->_conn_host_name . "; " . "username="******"; " . "password="******"; " . "dbname=" . $this->_conn_database; if ($dbenc = $this->get_encoding_for_db_driver($this->_conn_driver, SW_DB_ENCODING)) { $cnstr .= ";CharacterSet=" . $dbenc; } $connected = $this->ado_connection->Connect($cnstr, $this->_conn_user_name, $this->_conn_password); } else { trigger_error("PDO driver for mssql not found. Drivers \"dblib\" and \"mssql\" not found. Available drivers are " . $this->pdo_drivers_as_string()); } } } else { handle_error("Attempt to connect to MSSQL Database Failed. PDO Support does not seem to be Available"); } break; case "pdo_mssql": if (class_exists('PDO', false)) { $this->ado_connection = NewADOConnection("pdo"); $cnstr = "dblib:" . "host=" . $this->_conn_host_name . "; " . "username="******"; " . "password="******"; " . "dbname=" . $this->_conn_database; $connected = $this->ado_connection->Connect($cnstr, $this->_conn_user_name, $this->_conn_password); } else { handle_error("Attempt to connect to MSSQL Database Failed. PDO Support does not seem to be Available"); } break; case "pdo_sqlsrv": if (class_exists('PDO', false)) { $this->ado_connection = NewADOConnection("pdo"); if ($this->_conn_protocol) { $cnstr = "sqlsrv:" . "Server=" . $this->_conn_host_name . "," . $this->_conn_protocol . "; " . "Database=" . $this->_conn_database; } else { $cnstr = "sqlsrv:" . "Server=" . $this->_conn_host_name . "; " . "Database=" . $this->_conn_database; } $connected = $this->ado_connection->Connect($cnstr, $this->_conn_user_name, $this->_conn_password); } else { handle_error("Attempt to connect to MSSQL Database Failed. PDO Support does not seem to be Available"); } break; case "oci8": $this->ado_connection = NewADOConnection($this->_conn_driver); $this->ado_connection->SetFetchMode(ADODB_FETCH_ASSOC); $connected = $this->ado_connection->Connect($this->_conn_host_name, $this->_conn_user_name, $this->_conn_password, $this->_conn_database); break; case "pdo_oci": if (class_exists('PDO', false)) { if (!$this->pdo_driver_exists("oci")) { trigger_error("PDO driver \"oci\" not found. Available drivers are " . $this->pdo_drivers_as_string()); } else { $this->ado_connection = NewADOConnection("pdo"); if ($this->_conn_protocol) { $cnstr = "oci:" . "dbname=//" . $this->_conn_host_name . ":" . $this->_conn_protocol . "/" . $this->_conn_database; } else { $cnstr = "oci:" . "dbname=//" . $this->_conn_host_name . "/" . $this->_conn_database; } if ($dbenc = $this->get_encoding_for_db_driver($this->_conn_driver, SW_DB_ENCODING)) { $cnstr .= ";charset=" . $dbenc; } $connected = $this->ado_connection->Connect($cnstr, $this->_conn_user_name, $this->_conn_password); } } else { handle_error("Attempt to connect to Oracle Database Failed. PDO Support does not seem to be Available"); } break; case "pdo_pgsql": if (class_exists('PDO', false)) { if (!$this->pdo_driver_exists("pgsql")) { trigger_error("PDO driver \"pgsql\" not found. Available drivers are " . $this->pdo_drivers_as_string()); } else { $this->ado_connection = NewADOConnection("pdo"); $hostarr = explode(":", $this->_conn_host_name); if (count($hostarr) > 1) { $cnstr = "pgsql:" . "host=" . $hostarr[0] . "; " . "port=" . $hostarr[1] . "; " . "user="******"; " . "password="******"; " . "dbname=" . $this->_conn_database; } else { $cnstr = "pgsql:" . "host=" . $hostarr[0] . "; " . "user="******"; " . "password="******"; " . "dbname=" . $this->_conn_database; } $connected = $this->ado_connection->Connect($cnstr, $this->_conn_user_name, $this->_conn_password); if ($connected) { if ($dbenc = $this->get_encoding_for_db_driver($this->_conn_driver, SW_DB_ENCODING)) { $this->ado_connection->Execute("set names '" . $dbenc . "'"); } } } } else { handle_error("Attempt to connect to PostgreSQL Database Failed. PDO Support does not seem to be Available"); } break; case "pdo_mysql": if (class_exists('PDO', false)) { if (!$this->pdo_driver_exists("mysql")) { trigger_error("PDO driver \"mysql\" not found. Available drivers are " . $this->pdo_drivers_as_string()); } else { $this->ado_connection = NewADOConnection("pdo"); // Extract port from host if necessary $hostarr = explode(":", $this->_conn_host_name); if (count($hostarr) > 1) { $cnstr = "mysql:" . "host=" . $hostarr[0] . "; " . "port=" . $hostarr[1] . "; " . "username="******"; " . "password="******"; " . "dbname=" . $this->_conn_database; } else { $cnstr = "mysql:" . "host=" . $this->_conn_host_name . "; " . "username="******"; " . "password="******"; " . "dbname=" . $this->_conn_database; } $connected = $this->ado_connection->Connect($cnstr, $this->_conn_user_name, $this->_conn_password); if ($connected) { if ($dbenc = $this->get_encoding_for_db_driver($this->_conn_driver, SW_DB_ENCODING)) { $this->ado_connection->Execute("set names '" . $dbenc . "'"); } } } } else { handle_error("Attempt to connect to MySQL Database Failed. PDO Support does not seem to be Available"); } break; case "pdo_sqlite3": if (class_exists('PDO', false)) { $this->ado_connection = NewADOConnection("pdo"); $cnstr = "sqlite:" . $this->_conn_database; $connected = $this->ado_connection->Connect($cnstr, '', ''); } else { handle_error("Attempt to connect to SQLite-3 Database Failed. PDO Driver is not Available"); } break; case "sqlite": $driver = 'sqlite'; $database = $this->_conn_host_name . $this->_conn_database; $query = 'select * from Chave'; $db = ADONewConnection($driver); if ($db && $db->PConnect($database, "", "", "")) { } else { die("* CONNECT TO SQLite-2 FAILED"); } break; case "pdo_informix": if (class_exists('PDO', false)) { $this->ado_connection = NewADOConnection("pdo"); $cnstr = "informix:" . "host=" . $this->_conn_host_name . "; " . "server=" . $this->_conn_server . "; " . "protocol=" . $this->_conn_protocol . "; " . "username="******"; " . "password="******"; " . "database=" . $this->_conn_database; $connected = $this->ado_connection->Connect($cnstr, $this->_conn_user_name, $this->_conn_password); } else { handle_error("Attempt to connect to Informix Database Failed. PDO Support does not seem to be Available"); } break; case "odbc": $this->ado_connection = NewADOConnection($this->_conn_driver); $this->ado_connection->SetFetchMode(ADODB_FETCH_ASSOC); $connected = $this->ado_connection->Connect($this->_conn_host_name, $this->_conn_user_name, $this->_conn_password); break; case "unknown": handle_error("Database driver of unknown specified - please configure your project database connectivity"); break; case "SW_FRAMEWORK_DB_DRIVER": handle_error("You have configured your project to connnect to a database held within a web framework or Content Management System. You need to set constants SW_FRAMEWORK_DB_DRIVER, SW_FRAMEWORK_DB_USER,SW_FRAMEWORK_DB_PASSWORD,SW_FRAMEWORK_DB_HOST,SW_FRAMEWORK_DB_DATABASE from within the calling framework in order to run in this way. You are probably not trying to run from within a framework"); break; default: $this->ado_connection = NewADOConnection($this->_conn_driver); if ($this->ado_connection) { $this->ado_connection->SetFetchMode(ADODB_FETCH_ASSOC); $connected = $this->ado_connection->Connect($this->_conn_host_name, $this->_conn_user_name, $this->_conn_password, $this->_conn_database); } } // Note force connected for SQLite3 if ($this->_conn_driver == "sqlite") { $connected = true; } else { if ($this->ado_connection && !$connected && $this->_conn_driver != "unknown") { handle_error("Error in Connection to {$this->_conn_driver} database :" . $this->ado_connection->ErrorMsg()); } } $this->connected = $connected; return $this->connected; }
<?php require_once 'app_config.php'; mysql_connect(DATABASE_HOST, DATABASE_USERNAME, DATABASE_PASSWORD) or handle_error("There was a problem connecting to the database " . "that holds the information we need to get you connected.", mysql_error()); mysql_select_db(DATABASE_NAME) or handle_error("There's a configuration problem with our database.", mysql_error());
$facebook_url = "http://www.facebook.com/" . $facebook_url; } $twitter_handle = trim($_REQUEST['twitter_handle']); $twitter_url = "http://www.twitter.com/"; $position = strpos($twitter_handle, "@"); if ($position === false) { $twitter_url = $twitter_url . $twitter_handle; } else { $twitter_url = $twitter_url . substr($twitter_handle, $position + 1); } // Make sure we didn't have an error uploading the image $_FILES[$image_fieldname]['error'] == 0 or handle_error("the server couldn't upload the image you selected.", $php_errors[$_FILES[$image_fieldname]['error']]); // Is this file the result of a valid upload? @is_uploaded_file($_FILES[$image_fieldname]['tmp_name']) or handle_error("you were trying to do something naughty. Shame on you!", "Uploaded request: file named " . "'{$_FILES[$image_fieldname]['tmp_name']}'"); // Is this actually an image? @getimagesize($_FILES[$image_fieldname]['tmp_name']) or handle_error("you selected a file for your picture " . "that isn't an image.", "{$_FILES[$image_fieldname]['tmp_name']} " . "isn't a valid image file."); // Name the file uniquely $now = time(); while (file_exists($upload_filename = $upload_dir . $now . '-' . $_FILES[$image_fieldname]['name'])) { $now++; } $insert_sql = "INSERT INTO users (first_name, last_name, email, bio," . "facebook_url, twitter_handle)" . "VALUES ('{$first_name}', '{$last_name}', '{$email}', '{$bio}', " . "'{$facebook_url}', '{$twitter_handle}');"; // Insert the user into the database mysql_query($insert_sql) or die(mysql_error()); // Insert the image into the images table $image = $_FILES[$image_fieldname]; $image_filename = $image['name']; $image_info = getimagesize($image['tmp_name']); $image_mime_type = $image_info['mime']; $image_size = $image['size']; $image_data = file_get_contents($image['tmp_name']);
function parse_date($in_keyword, $in_time = false, $in_mask = "%d/%m/%Y") { $in_mask = get_locale_date_format($in_mask); if (!$in_time) { $in_time = time(); } $now = localtime($in_time, true); // Begin calculating the required data/time value switch ($in_keyword) { case "FIRSTOFLASTMONTH": $now["tm_mday"] = 1; $now["tm_mon"]--; if ($now["tm_mon"] < 0) { $now["tm_year"]--; $now["tm_mon"] = 11; } break; case "FIRSTOFYEAR": $now["tm_mday"] = 1; $now["tm_mon"] = 0; break; case "FIRSTOFLASTYEAR": $now["tm_mday"] = 1; $now["tm_mon"] = 0; $now["tm_year"]--; break; case "LASTOFYEAR": $now["tm_mday"] = 31; $now["tm_mon"] = 11; break; case "LASTOFLASTYEAR": $now["tm_mday"] = 31; $now["tm_mon"] = 11; $now["tm_year"]--; break; case "LASTOFLASTMONTH": case "FIRSTOFMONTH": $now["tm_mday"] = 1; break; case "LASTOFMONTH": $now["tm_mday"] = 1; $now["tm_mon"]++; if ($now["tm_mon"] == 12) { $now["tm_year"]++; $now["tm_mon"] = 0; } break; case "STARTOFWEEK": case "ENDOFWEEK": case "STARTOFLASTWEEK": case "ENDOFLASTWEEK": case "YESTERDAY": case "TOMORROW": case "TODAY": break; default: return $in_keyword; } if ($now["tm_year"] < 1000) { $now["tm_year"] += 1900; } // Convert the modified date time values back to to UNIX time $new_time = mktime($now["tm_hour"], $now["tm_min"], $now["tm_sec"], $now["tm_mon"] + 1, $now["tm_mday"], $now["tm_year"]); //$now["tm_isdst"] ); // Apply any element transformations to get the reuqired UNIX date switch ($in_keyword) { case "YESTERDAY": $new_time -= 60 * 60 * 24; break; case "TOMORROW": $new_time += 60 * 60 * 24; break; case "LASTOFLASTMONTH": case "LASTOFMONTH": $new_time -= 60 * 60 * 24; break; case "STARTOFWEEK": ///$new_time = strtotime("last Saturday"); $new_time = strtotime("this week"); break; case "ENDOFWEEK": $new_time = strtotime("next week - 1 day"); break; case "STARTOFLASTWEEK": ///$new_time = strtotime("last Saturday"); $new_time = strtotime("last week"); break; case "ENDOFLASTWEEK": $new_time = strtotime("this week - 1 day"); break; case "FIRSTOFMONTH": default: break; } if (!class_exists("DateTime", false)) { handle_error("This version of PHP does not have the DateTime class. Must be PHP >= 5.3 to use date criteria"); return false; } try { $datetime = new DateTime("@{$new_time}"); } catch (Exception $e) { handle_error("Error in date formatting<BR>" . $e->getMessage()); return ""; } $ret = $datetime->format($in_mask); return $ret; }
$result = mysql_query($select_query); if ($result) { $row = mysql_fetch_array($result); $first_name = $row['first_name']; $last_name = $row['last_name']; $bio = preg_replace("/[\r\n]+/", "</p><p>", $row['bio']); $email = $row['email']; $facebook_url = $row['facebook_url']; $twitter_handle = $row['twitter_handle']; $image_id = $row['profile_pic_id']; $image_query = sprintf("SELECT * FROM images WHERE image_id = %d", $profile_pic_id); $image_result = mysql_query($image_query); // Turn $twitter_handle into a URL $twitter_url = "http://www.twitter.com/" . substr($twitter_handle, $position + 1); } else { handle_error("There was a problem finding your " . "information in our system.", "Error locating user with ID {$user_id}"); } ?> <html> <head> <link href="../../css/phpMM.css" rel="stylesheet" type="text/css" /> </head> <body> <div id="header"><h1>PHP & MySQL: The Missing Manual</h1></div> <div id="example">User Profile</div> <div id="content"> <div class="user_profile">
$contract = $itero->get_contract($contractid); if (!$contract) { handle_error(500, "Could not fetch contract"); } $customer = $itero->get_customer($contract->CustomerId); if (!$customer) { handle_error(500, "Could not fetch customer"); } //Get mongodb instance $m = new MongoClient($GLOBALS['mongodb'], array("connect" => TRUE)); //$m = new MongoClient(); if (!$m) { handle_error(500, "Could not open mongodb"); } $db = $m->{$GLOBALS}['dbname']; if (!$db) { handle_error(500, "Could not open db"); } //Store new customer $customer->contractid = $contractid; $c_customers = $db->customers; $c_customers->save($customer); //Get new id and pass it to Itero as external id $ownId = (string) $customer->_id; $customer->ExternalCustomerId = $ownId; $itero->put_customer($customer); function handle_error($httpcode, $message) { http_response_code($httpcode); exit($message); }
function test_query($in_query, $sql) { $conn =& $in_query->datasource->ado_connection; if ($this->haswhere) { // In order to test an SQL statement with a where clause add an "1 = 0 AND " $tmp = substr($sql, $this->whereoffset); $tmp = substr($sql, 0, $this->whereoffset); $tmp .= " 1 = 0 AND"; $tmp .= substr($sql, $this->whereoffset); $sql = $tmp; } else { // No where statement add a WHERE 1 = 0 $tmp = substr($sql, $this->whereoffset); $tmp = substr($sql, 0, $this->whereoffset); $tmp .= " WHERE 1 = 0 "; $tmp .= substr($sql, $this->whereoffset); $sql = $tmp; } // Remove any meta_sql criteria links between "[" and "]" $sql = preg_replace("/WHERE 1 = 1/i", "WHERE 1 = 0", $sql); $sql = preg_replace("/\\[.*\\]/U", '', $sql); // Replace External parameters specified by {USER_PARAM,xxxxx} if (preg_match_all("/{USER_PARAM,([^}]*)}/", $sql, $matches)) { foreach ($matches[0] as $k => $v) { $param = $matches[1][$k]; if (isset($in_query->user_parameters[$param])) { $sql = preg_replace("/{USER_PARAM,{$param}}/", $in_query->user_parameters[$param], $sql); } else { trigger_error("User parameter {$param}, specified but not provided to reportico", E_USER_ERROR); } } } $errorCode = false; $errorMessage = false; $recordSet = false; try { $recordSet = $conn->Execute($sql); } catch (PDOException $Exception) { $errorNumber = $Exception->getCode(); $errorMessage = $Exception->getMessage(); // PHP Fatal Error. Second Argument Has To Be An Integer, But PDOException::getCode Returns A // String. } // Begin Target Output if (!$recordSet) { if ($errorMessage) { handle_error("Error in Connection: " . $errorMessage . "<BR><BR>(Note that if the error warns of a missing temporary table that will be created at runtime, it is safe to ignore this message)"); } else { handle_error("Error ( " . $conn->ErrorNo() . ") in Connection: " . $conn->ErrorMsg() . "<BR><BR>(Note that if the error warns of a missing temporary table that will be created at runtime, it is safe to ignore this message)"); } return false; } else { return true; } }
/** * 檢查外鍵。但是暫時還不會用到… * @param integer $id */ protected static function _fk_check($id, $db, $fk, $exception_msg) { if (is_null($id)) { return; } //$fk = $this->foreign_keys; //$db = $this->db; foreach ($fk as $table_name => $field) { $db->where($field, $id); $count = $db->count_all_results($table_name); if ($count > 0) { //handle_error($this->lang->line('generic_object.fk_check.exception')); handle_error($exception_msg); } } }
// Configuration Section Begin //**************************************************** // Some global variables needed. $MySQLServer = "mysql.library.nd.edu"; $MySQLUser = "******"; $MySQLPassword = "******"; $MySQLDbName = 'coral_usage_prod'; $Base_URL = 'https://coral.library.nd.edu/usage/'; // Error messages $contact = "Contact <a href=\"mailto:rmalott@nd.edu\">Robin Malott</a> regarding this problem.<br/>"; $error_text = "Please include the error text above in your email.<br/><br/>"; //**************************************************** // Configuration Section End //**************************************************** //Creates the connection result string ($link) used throughout the php scripts if (!($link = mysql_connect("{$MySQLServer}", "{$MySQLUser}", "{$MySQLPassword}"))) { handle_error(mysql_error(), $contact, $error_text); } if (!mysql_select_db("{$MySQLDbName}")) { handle_error("Could not connect to E-Resources Database.", $contact, $error_text); } // Error handling function used in all scripts function handle_error($msg, $contact, $error_text) { echo "<H3>There is a problem with the database:<br/>\n{$msg}</H3>"; echo "<br/>\n{$contact} {$error_text} \n"; mysql_free_result($result); mysql_close($link); exit; } error_reporting(E_ERROR | E_WARNING | E_PARSE);
<?php require_once '../../scripts/app_config.php'; mysql_connect(DATABASE_HOST, DATABASE_USERNAME, "foo") or handle_error("There was a problem connecting to the database that holds the information we need to get you connected.", mysql_error()); echo "<p>Connected to MySQL!"; mysql_select_db(DATABASE_NAME) or die("<p>Error selecting the database " . DATABASE_NAME . mysql_error() . "</p>"); echo "<p>Connected to MySQL, using database " . DATABASE_NAME . "</p>"; $result = mysql_query("SHOW TABLES;"); if (!$result) { die("<p>Error in listing tables: " . mysql_error() . "</p>"); } echo "<p>Tables in database:</p>"; echo "<ul>"; while ($row = mysql_fetch_row($result)) { echo "<li>Table: " . $row[0] . "</li>"; } echo "</ul>";
/** * 設定推薦 * @param Annotation $annotation * @return \Annotation_tutor */ public function setup_recommend(Annotation $annotation) { //test_msg('Annotation_tutor->setup_recommend()', 1); $threshold = $this->_get_recommended_threshold(); $score = $this->_get_integrated_score($annotation); //test_msg('Annotation_tutor->setup_recommend()', 2); if ($score < $threshold) { //test_msg('Annotation_tutor->setup_recommend()', 3); //如果分數到達門檻,才進行推薦,否則不作推薦 $recommend_annotation = $this->_find_recommend_annotation($annotation); $this->_CI_load('library', 'recommend/Annotation_recommend', 'annotation_recommend'); $cond = array('recommended_annotation_id' => $annotation->get_id(), 'recommended_webpage_id' => $this->webpage->get_id()); $recommend = $this->CI->annotation_recommend->find($cond); //test_msg('Annotation_tutor->setup_recommend()', 4); if (is_null($recommend)) { $recommend = new Annotation_recommend(); $recommend->set_webpage($this->webpage); $recommend->set_recommended($annotation); } //test_msg('Annotation_tutor->setup_recommend()', 5); if (isset($recommend_annotation)) { $recommend->set_recommend_by($recommend_annotation); } //test_msg('Annotation_tutor->setup_recommend() 6', 6); // @TODO #170 20140410 這個步驟會出錯 $recommend->update(); //加入通知 $trigger_resource = $annotation; $association_user = $annotation->get_user(); //test_msg('Annotation_tutor->setup_recommend()', 7); $this->_CI_load('library', 'kals_actor/Notification_recommended', 'ntification_recommended'); $notification = $this->CI->ntification_recommended->create_notification($association_user, $trigger_resource); if (is_null($notification)) { handle_error($this->lang->line('notification.recommend.create_notification.exception')); } //test_msg('Annotation_tutor->setup_recommend()', 8); $annotation->set_recommend($recommend); //test_msg('Annotation_tutor->setup_recommend()', 9); } return $this; }