本文整理汇总了PHP中return_error函数的典型用法代码示例。如果您正苦于以下问题:PHP return_error函数的具体用法?PHP return_error怎么用?PHP return_error使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了return_error函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getdata
function getdata($servers, $extensions)
{
$line = '';
$extbyhost = array();
foreach ($extensions as $extension => $extension_data) {
if (!array_key_exists('host', $extension_data)) {
continue;
}
if (!array_key_exists($extension_data['host'], $extbyhost)) {
$extbyhost[$extension_data['host']] = array();
}
$extbyhost[$extension_data['host']][$extension] = False;
}
unset($extensions);
foreach ($extbyhost as $host => $extensions) {
if ($line) {
$line .= ',';
}
if (array_key_exists($host, $servers)) {
$line .= get_data_from_server($host, $servers[$host]['port'], @array_keys($extbyhost[$host]));
} else {
$line .= get_data_from_server($servers[0]['host'], $servers[0]['port'], @array_keys($extbyhost[$host]));
}
}
if (!$extbyhost) {
return return_error(3, 'no extension states');
}
if (!$line) {
return return_error(101, 'NO DATA');
}
return $line;
}
示例2: run
public function run($arg)
{
static $created_table = array();
$func_arg = $arg['function_info']['arg'];
switch (strtolower($arg['function_info']['function'])) {
case 'percentile':
if ($func_arg[0]['expr_type'] != 'colref') {
return return_error('PERCENTILE: Only column references are allowed as the first argument to this function', $arg['tmp_shard'], 'ERR_SQ_INVALID_FUNC_CALL');
}
if ($func_arg[1]['expr_type'] != 'const') {
return return_error('PERCENTILE: Only constants are allowed as the second argument to this function', $arg['tmp_shard'], 'ERR_SQ_INVALID_FUNC_CALL');
}
if (!empty($func_arg[2])) {
return return_error('PERCENTILE: Wrong number of arguments to this function', $arg['tmp_shard'], 'ERR_SQ_INVALID_FUNC_CALL');
}
$colname = $arg['function_info']['colref_map'][$func_arg['0']['base_expr']];
$conn = SimpleDAL::factory($arg['tmp_shard']);
if ($conn->my_error()) {
return return_error('Failed to connect to storage node', $arg['tmp_shard'], $conn->my_error());
}
$conn->my_select_db($arg['tmp_shard']['db']);
if (empty($created_table[$arg['func_call_id']])) {
$sql = "CREATE TABLE IF NOT EXISTS`" . $arg['func_call_id'] . "` (gb_hash char(40) primary key, retval double) ";
$result = $conn->my_query($sql);
if (!$result || $conn->my_error()) {
return return_error('SQL error:', $arg['tmp_shard'], $conn->my_error());
}
$created_table[$arg['func_call_id']] = 1;
}
$sql = "select count(distinct {$colname}) cnt from `" . $arg['table'] . "` where gb_hash = '" . $arg['gb_hash'] . "'";
$result = $conn->my_query($sql);
if (!$result || $conn->my_error()) {
return return_error('SQL error:', $arg['tmp_shard'], $conn->my_error());
}
$row = $conn->my_fetch_assoc();
if (!$row) {
return return_error('No row found for given gb_hash:' . $arg['gb_hash'], $arg['tmp_shard'], 'ERR_SQ_NO_ROW_FOUND');
}
$percentile_at = $func_arg[1]['base_expr'];
$limit = floor(0.01 * $percentile_at * $row['cnt']);
if ($limit < 1) {
$limit = 0;
}
$sql = "insert into `" . $arg['func_call_id'] . "` select distinct '" . $arg['gb_hash'] . "', {$colname} from `" . $arg['table'] . "` where gb_hash ='" . $arg['gb_hash'] . "' order by {$colname} limit {$limit},1";
$conn->my_query($sql);
if (!$result || $conn->my_error()) {
return return_error('SQL error:', $arg['tmp_shard'], $conn->my_error());
}
return true;
break;
}
}
示例3: send_telegram
function send_telegram($config, $name, $message)
{
# Check if the message is base64 encoded
if (!validBase64($message)) {
return_error("Error: Message invalid");
} else {
$message = date("H:i:s") . " - " . $name . ": " . base64_decode($message);
}
$post_fields = array();
$post_fields['chat_id'] = $config['userid'];
$post_fields['disable_web_page_preview'] = 1;
$post_fields['text'] = $message;
$req = curl_init('https://api.telegram.org/bot' . $config['apikey'] . '/sendMessage');
curl_setopt($req, CURLOPT_RETURNTRANSFER, true);
curl_setopt($req, CURLOPT_POSTFIELDS, $post_fields);
$response = curl_exec($req);
curl_close($req);
$return_string = json_decode($response);
return $return_string->ok;
}
示例4: return_error
if (is_null($node)) {
return false;
}
if (!$node->hasAttribute('mode')) {
return false;
}
$logout_mode = $node->getAttribute('mode');
return $logout_mode;
}
if (!array_key_exists('session_id', $_SESSION)) {
echo return_error(1, 'Usage: missing "session_id" $_SESSION parameter');
die;
}
$ret = parse_logout_XML(@file_get_contents('php://input'));
if (!$ret) {
return_error(2, 'Client does not send a valid XML');
}
$session = Abstract_Session::load($_SESSION['session_id']);
if (is_object($session)) {
if ($ret == 'suspend') {
$session->setStatus(Session::SESSION_STATUS_INACTIVE, Session::SESSION_END_STATUS_LOGOUT);
} else {
$session->setStatus(Session::SESSION_STATUS_WAIT_DESTROY, Session::SESSION_END_STATUS_LOGOUT);
}
}
header('Content-Type: text/xml; charset=utf-8');
$dom = new DomDocument('1.0', 'utf-8');
$logout_node = $dom->createElement('logout');
$logout_node->setAttribute('mode', $ret);
$dom->appendChild($logout_node);
$xml = $dom->saveXML();
示例5: showRoutes
//.........这里部分代码省略.........
echo $page;
?>
&dir=<?php
echo $dir_order_by["train"];
?>
#table"><?php
echo $img_order_by["train"] . Lang::l_('Train');
?>
</a></th>
</tr>
</thead>
<tbody>
<?php
//generate and execute query
$query = "SELECT * FROM osm_train_details ORDER BY `" . @$con->real_escape_string($order_by) . "` " . @$con->real_escape_string($dir) . " LIMIT " . $start . "," . $amount;
$result = @$con->query($query);
if ($result) {
//show routes
while ($row = @$result->fetch_array()) {
$mysql_id = $row["id"];
//get Train
unset($train);
$train = new Train($row["train"]);
?>
<tr>
<td><a href="?id=<?php
echo $row["id"];
?>
&train=<?php
echo $train->ref;
?>
" title="<?php
echo Lang::l_('Show Route');
?>
"><?php
echo Route::showRef($row["ref"], $row["route"], $row["service"], $row["ref_colour"], $row["ref_textcolour"]);
?>
</a></td>
<td><?php
echo $row["from"];
?>
</td>
<td><?php
echo $row["to"];
?>
</td>
<td><?php
echo $row["operator"];
?>
</td>
<td class="nowrap"><?php
echo round($row["length"], 1);
?>
km</td>
<td class="nowrap"><?php
echo round($row["time"], 0);
?>
min</td>
<td class="nowrap"><?php
echo round($row["ave_speed"]);
?>
km/h</td>
<td class="nowrap"><?php
echo round($row["max_speed"]);
?>
km/h</td>
<td style="width:150px"><div style="height:50px;width:150px;display:inline-block;background-image:url('img/trains/<?php
echo $train->image;
?>
');background-repeat:no-repeat;background-position:right;background-size:auto 50px" title="<?php
echo $train->name;
?>
"></div></td>
</tr>
<?php
}
} else {
?>
<tr>
<td colspan="9">
<?php
return_error("mysql", "message", $con);
?>
</td>
</tr>
<?php
}
?>
</tbody>
</table>
</div>
<div class="panel-body">
<?php
pagination($page, $lastpage, $order_by, $dir);
?>
</div>
</div>
</div>
<?php
}
示例6: WSUserSubscribedInCourse
/**
* Web service to tell if a given user is subscribed to the course
* @param array $params Array of parameters (course and user_id)
* @return bool|null|soap_fault A simple boolean (true if user is subscribed, false otherwise)
*/
function WSUserSubscribedInCourse ($params)
{
global $debug;
if ($debug) error_log('WSUserSubscribedInCourse');
if ($debug) error_log('Params '. print_r($params, 1));
if (!WSHelperVerifyKey($params)) {
return return_error(WS_ERROR_SECRET_KEY);
}
$courseCode = $params['course']; //Course code
$userId = $params['user_id']; //chamilo user id
return (CourseManager::is_user_subscribed_in_course($userId,$courseCode));
}
示例7: WSDeleteUserFromGroup
function WSDeleteUserFromGroup($params)
{
if (!WSHelperVerifyKey($params['secret_key'])) {
return return_error(WS_ERROR_SECRET_KEY);
}
$userGroup = new UserGroup();
return $userGroup->delete_user_rel_group($params['user_id'], $params['group_id']);
}
示例8: DomDocument
$dom->appendChild($logout_node);
$xml = $dom->saveXML();
$dom = new DomDocument('1.0', 'utf-8');
$buf = @$dom->loadXML(query_sm_post_xml($sessionmanager_url . '/logout.php', $xml));
if (!$buf) {
echo return_error(0, 'Invalid XML');
die;
}
if (!$dom->hasChildNodes()) {
echo return_error(0, 'Invalid XML');
die;
}
$logout_nodes = $dom->getElementsByTagName('logout');
if (count($logout_nodes) != 1) {
echo return_error(1, 'Invalid XML: No session node');
die;
}
$logout_node = $logout_nodes->item(0);
if (!is_object($logout_node)) {
echo return_error(1, 'Invalid XML: No session node');
die;
}
$logout = array('mode' => $logout_node->getAttribute('mode'));
$dom = new DomDocument('1.0', 'utf-8');
$logout_node = $dom->createElement('logout');
$logout_node->setAttribute('mode', $logout['mode']);
$dom->appendChild($logout_node);
$xml = $dom->saveXML();
echo $xml;
unset($_SESSION['ovd-client']);
die;
示例9: MWTrackback
$tb = new MWTrackback('', '');
$trackbacks = $tb->auto_discovery($content);
}
if (!empty($trackbacks)) {
foreach ($trackbacks as $t) {
if (!empty($pinged) && in_array($t, $pinged)) {
continue;
}
$toping[] = $t;
}
}
$post->setVar('toping', !empty($toping) ? $toping : '');
$return = $edit ? $post->update() : $post->save();
if ($return) {
if (!$edit) {
$xoopsUser->incrementPost();
}
showMessage($edit ? __('Post updated successfully', 'mywords') : __('Post saved successfully', 'mywords'), 0);
$url = MWFunctions::get_url();
if ($mc->permalinks > 1) {
$url .= $frontend ? 'edit/' . $post->id() : 'posts.php?op=edit&id=' . $post->id();
} else {
$url .= $frontend ? '?edit=' . $post->id() : 'posts.php?op=edit&id=' . $post->id();
}
$rtn = array('message' => $edit ? __('Post updated successfully', 'mywords') : __('Post saved successfully', 'mywords'), 'token' => $xoopsSecurity->createToken(), 'link' => '<strong>' . __('Permalink:', 'mywords') . '</strong> ' . $post->permalink(), 'post' => $post->id(), 'url' => $url);
echo json_encode($rtn);
die;
} else {
return_error(__('Errors ocurred while trying to save this post.', 'mywords') . '<br />' . $post->errors(), true);
die;
}
示例10: elseif
$web_interface_settings = $prefs->get('general', 'web_interface_settings');
if (array_key_exists('public_webservices_access', $web_interface_settings) && $web_interface_settings['public_webservices_access'] == 1) {
// ok
} elseif (array_key_exists('session_id', $_SESSION)) {
$session = Abstract_Session::load($_SESSION['session_id']);
if (!$session) {
echo return_error(3, 'No such session "' . $_SESSION['session_id'] . '"');
die;
}
/*if (! in_array($_GET['id'], $session->applications)) {
echo return_error(4, 'Unauthorized application');
die();
}*/
} else {
Logger::debug('main', '(client/applications) No Session id nor public_webservices_access');
echo return_error(7, 'No Session id nor public_webservices_access');
die;
}
$applicationDB = ApplicationDB::getInstance();
$applications = $applicationDB->getApplicationsWithMimetype($_GET['id']);
$apps = array();
foreach ($applications as $application) {
if (!$application->haveIcon()) {
continue;
}
$score = count($application->groups());
if ($application->getAttribute('type') == 'windows') {
$score += 10;
}
$apps[$score] = $application;
}
示例11: WSListSessions
/**
* Get a list of sessions (id, title, url, date_start, date_end) and
* return to caller. Date start can be set to ask only for the sessions
* starting at or after this date. Date end can be set to ask only for the
* sessions ending before or at this date.
* Function registered as service. Returns strings in UTF-8.
* @param array List of parameters (security key, date_start and date_end)
* @return array Sessions list (id=>[title=>'title',url='http://...',date_start=>'...',date_end=>''])
*/
function WSListSessions($params)
{
if (!WSHelperVerifyKey($params)) {
return return_error(WS_ERROR_SECRET_KEY);
}
$sql_params = array();
// Dates should be provided in YYYY-MM-DD format, UTC
if (!empty($params['date_start'])) {
$sql_params['date_start >='] = $params['date_start'];
}
if (!empty($params['date_end'])) {
$sql_params['date_end <='] = $params['date_end'];
}
$sessions_list = SessionManager::get_sessions_list($sql_params);
$return_list = array();
foreach ($sessions_list as $session) {
$return_list[] = array('id' => $session['id'], 'title' => $session['name'], 'url' => api_get_path(WEB_CODE_PATH) . 'session/index.php?session_id=' . $session['id'], 'date_start' => $session['date_start'], 'date_end' => $session['date_end']);
}
return $return_list;
}
示例12: array
$rarr = array('success' => false, 'notify' => array());
switch ($_POST['step']) {
case '1':
// read template database file
$conts = @file_get_contents('inc/common/site/default/database.php');
if ($conts === false) {
return_error('Failed to read database.php file. Does server have read permissions?', 'Read Failed');
}
// replace values
$conts = str_replace('%dbhost%', $_POST['db']['host'], $conts);
$conts = str_replace('%dbuser%', $_POST['db']['user'], $conts);
$conts = str_replace('%dbpass%', $_POST['db']['pass'], $conts);
$conts = str_replace('%dbname%', $_POST['db']['name'], $conts);
// write database file
if (@file_put_contents('inc/common/site/database.php', $conts) === false) {
return_error('Failed to write database.php file. Does server have write permissions?', 'Write Failed');
}
// create database tables & default users
if ($_POST['db']['create'] == 'Y') {
require 'inc/common/site/database.php';
require 'inc/classes/database.class.php';
$db = new database();
// drop tables if they exist
$db->query('DROP TABLE IF EXISTS groups');
$db->query('DROP TABLE IF EXISTS users');
// create groups table
$db->query('CREATE TABLE IF NOT EXISTS groups (
id INT UNSIGNED AUTO_INCREMENT PRIMARY KEY,
grp VARCHAR(20),
description VARCHAR(255)
);');
示例13: return_error
$_SESSION['ovd-client']['gateway'] = true;
}
$user_node = $session_node->getElementsByTagName('user');
if (count($user_node) != 1) {
echo return_error(2, 'internal_error');
die;
}
$user_node = $user_node->item(0);
if (!is_object($user_node)) {
echo return_error(2, 'internal_error');
die;
}
$_SESSION['ovd-client']['session_displayname'] = $user_node->getAttribute('displayName');
$server_nodes = $session_node->getElementsByTagName('server');
if (count($server_nodes) < 1) {
echo return_error(3, 'internal_error');
die;
}
$_SESSION['ovd-client']['explorer'] = false;
$profile_node = $session_node->getElementsByTagName('profile')->item(0);
$sharedfolder_node = $session_node->getElementsByTagName('sharedfolder')->item(0);
$sharedfolder_nodes = $session_node->getElementsByTagName('sharedfolder');
if (is_object($profile_node) || is_object($sharedfolder_node) && is_object($sharedfolder_nodes)) {
if (is_dir(dirname(__FILE__) . '/ajaxplorer/')) {
$_SESSION['ovd-client']['explorer'] = true;
}
$_SESSION['ovd-client']['ajxp'] = array();
$_SESSION['ovd-client']['ajxp']['applications'] = '';
$_SESSION['ovd-client']['ajxp']['repositories'] = array();
$_SESSION['ovd-client']['ajxp']['folders'] = array();
}
示例14: return_error
//проверка пользовательского запроса
include ".php/track.php";
//отслеживание посетителей
if (test(REQUEST_AJAX)) {
include ".php/ajax.php";
} else {
if (test(ERROR_AJAX)) {
return_error(AUTORIZATION_ERROR);
} else {
if (test(REQUEST_UPLOAD)) {
include ".php/upload.php";
} else {
if (test(REQUEST_DOWNLOAD)) {
include ".php/download.php";
} else {
if (test(REQUEST_AUTHORIZATION)) {
include ".php/main.php";
} else {
if (test(ERROR_UPLOAD)) {
return_error(UPLOAD_AUTORIZATION_ERROR);
} else {
include ".php/login.php";
}
}
}
}
}
}
#ini_set('display_errors', 1);
#error_reporting(E_ALL);
exit;
示例15: getDTD
function getDTD($col_info,$layer_type,$layer_tablename){
if(count($col_info) > 0) {
$dtd = "<?xml version=\"1.0\" encoding=\"utf-8\" ?>";
$dtd .= "<!ELEMENT kml (Document)>\n";
$dtd .= "<!ATTLIST kml xmlns CDATA \"\">\n";
$dtd .= "<!ELEMENT Document (Folder+)>\n";
$dtd .= "<!ELEMENT Folder (name,Placemark+)>\n";
$dtd .= "<!ELEMENT Placemark (description,Point)>\n";
$dtd .= "<!ELEMENT description (";
foreach($col_info as $col_name => $col_desc){
$dtd .= $col_name .",";
}
$dtd .= ")>\n<!ELEMENT ".strtolower($layer_type)." (coordinates)>\n";
$dtd .= "<!ELEMENT coordinates (#PCDATA)>\n";
$dtd .= "<!ELEMENT name (#PCDATA)>";
foreach($col_info as $col_name => $col_desc){
$dtd .= "<!ELEMENT ".$col_name." (#PCDATA)>\n";
$dtd .= "<!-- ".$col_name." ".$col_desc." -->\n";
}
} else {
$dtd = "";
}
$file = "upload/dtd_".$layer_tablename.".xml";
if (!($fp = fopen($file, "w+"))) {
die(return_error("Error opening DTD file"));
}
fwrite($fp,$dtd);
fclose($fp);
return htmlentities($dtd);
}