本文整理汇总了PHP中setError函数的典型用法代码示例。如果您正苦于以下问题:PHP setError函数的具体用法?PHP setError怎么用?PHP setError使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了setError函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: Save
function Save($text, $bStripSlashes = true)
{
//remove due to serialize bug $text=stripslashes($text);
if ($bStripSlashes) {
$text = stripslashes($text);
}
if (is_file($this->path) && !is_writable($this->path)) {
return setError(sprintf(_("Can not open file %s for writing."), $this->getName()) . ' ' . _("Check file permissisons"));
}
if (!is_dir($this->getParentPath())) {
$oDirParent = $this->getParent();
if (!$oDirParent->mkdir()) {
return false;
}
}
$fic = fopen($this->path, "w");
if (!$fic) {
return setError(sprintf(_("Can not open file %s for writing."), $this->getName()) . ' ' . _("Check file permissisons"));
}
//replace the $text
if ($this->getExtension() == 'xml') {
$text = str_replace(array('<textareatag', '</textareatag'), array('<textarea', '</textarea'), $text);
}
if (strlen($text) > 0) {
if (fwrite($fic, $text) == FALSE) {
setError(_("An error occur while writing text"));
fclose($fic);
return false;
}
}
fclose($fic);
return true;
}
示例2: getItems
public static function getItems($period, $user, $yachs = 'ntime', $sport = '*', $currentpage = 'weekpage')
{
$db = JFactory::getDbo();
$query = $db->getQuery(true);
$query->select('a.method, a.location,a.tdate,s.sport_abbr, a.competition');
$query->from($db->quoteName('#__htraininglogs_tr_sessions') . ' AS a');
$query->join('LEFT', $db->quoteName('#__htraininglogs_tr_competitions') . ' AS cc ON a.id = cc.tr_id');
$query->select('cc.title as comptitle,cc.class_place,cc.is_team,cc.owntime,cc.toptimecat,cc.comp_cat');
$query->select('s.sport_abbr');
$query->join('LEFT', $db->quoteName('#__htraininglogs_cfg_sport') . ' AS s ON a.sport_id = s.id');
$query->select('c1.title as category,c1.keyvalue');
$query->join('LEFT', $db->quoteName('#__htraininglogs_conf_groups') . ' AS c1 ON (c1.keyvalue = cc.comp_cat) AND c1.ctype =300');
$query->select('c2.title as type,c1.keyvalue');
$query->join('LEFT', $db->quoteName('#__htraininglogs_conf_groups') . ' AS c2 ON (c2.keyvalue = cc.is_champ) AND c2.ctype =400');
$query->select('tt.title as toptime,tt.ordering');
$query->join('LEFT', $db->quoteName('#__htraininglogs_cfg_toptime') . ' AS tt ON (tt.id = cc.toptimecat)');
$query->where('(a.competition IN (2, 1))');
$query->where('a.state =1');
$query->where('a.tdate BETWEEN "' . $period->anfdat->format('Y-m-d') . ' 0:00:00" AND "' . $period->enddat->format('Y-m-d') . ' 23:59:59"');
$query->order('a.tdate ASC');
$db->setQuery($query);
$items = $db->loadObjectlist();
if ($db->getErrorNum()) {
setError(JText::_('COM_HTRAININGLOGS_GET_VALUEBASEDGRAPH_FAIL'));
return false;
}
return $items;
}
示例3: deleteLayerGroup
function deleteLayerGroup($xmlDoc, &$rootNode, $paramsNode) {
$isAdmin = false;
$user = $GLOBALS['user'];
$user_roles = $user->roles;
if($user->uid) {
if(in_array(SITE_ADMIN_ROLE, $user_roles)) {
$isAdmin = true;
}
}
if(!$isAdmin) {
setError($xmlDoc, $rootNode, "You are not authorized.");
return;
}
$groupNode = $paramsNode->getElementsByTagName('group')->item(0);
$group_id = $groupNode->getAttribute("id");
if($group_id == NULL || $group_id == '' || $group_id == 0) {
setError($xmlDoc, $rootNode, "Select a layer group to delete.");
return;
}
$query = 'delete from "Layer_Group" where id = %d';
$query_args = array($group_id);
$result = db_query($query, $query_args);
if(!$result) {
setError($xmlDoc, $rootNode, "Could not delete the group. Please try after sometime.");
} else {
setNoError($xmlDoc, $rootNode, "The group has been deleted successfully.");
}
}
示例4: secureArea
function secureArea($group)
{
global $SETTINGS;
if (!isUserInRole($group)) {
setError('Du besitzt nicht die nötigen Rechte!');
header("location: {$SETTINGS['url']}/");
exit;
}
}
示例5: actionUpdate
/**
* Updates an existing StudentPhone model.
* If update is successful, the browser will be redirected to the 'view' page.
* @param integer $id
* @return mixed
*/
public function actionUpdate($id)
{
$model = $this->findModel($id);
$studentId = $model->student_id;
$student = Student::findOne($studentId);
if (!user()->can('updateStudent', ['student' => $student])) {
setError('Access denied.');
return $this->redirect(['/student/view', 'id' => $studentId], 403);
}
if ($model->load(Yii::$app->request->post()) && $model->save()) {
return $this->redirect(['view', 'id' => $model->id]);
} else {
return $this->render('update', ['student' => $student, 'model' => $model]);
}
}
示例6: extrapage_sitemap
/**
* extrapage_sitemap
* This is the extrapagesite map event function
* This function check the name of the page and if it is sitemap.xml, generate the site map.
*
* @param unknown_type $strPage
* @param unknown_type $site
* @return unknown
*/
function extrapage_sitemap($strPage, &$site)
{
if ($strPage == 'sitemap.xml') {
$strTplFile = dirname(__FILE__) . SLASH . 'google_sitemap.tpl';
if (!$site->template_exists($strTplFile)) {
setError('Error in plugin google site map. Can not find the google_sitemap.tpl file.');
printFatalHtmlError();
die;
}
header('Content-Type: text/xml;');
$site->display($strTplFile);
return true;
}
return false;
}
示例7: checkKey
function checkKey()
{
if (stristr($_SERVER['SERVER_NAME'], 'localhost') !== FALSE) {
return true;
}
//try to connect to server licence
if (!isset($_SERVER['HTTP_HOST'])) {
return setError(__('HTTP_HOST not defined'));
}
$strLicenceStatus = file_get_contents(LICENCE_URL . urlencode($_SERVER['HTTP_HOST']));
if ($strLicenceStatus === 'OK') {
return true;
}
return setError($strLicenceStatus);
}
示例8: sendErrorResponse
function sendErrorResponse($msg) {
// create a new XML document
$doc = new DomDocument('1.0');
// create root node
$respNode = $doc->createElement('response');
$respNode = $doc->appendChild($respNode);
setError($doc, $respNode, $msg);
// get completed xml document
$xml_string = $doc->saveXML();
return $xml_string;
}
示例9: motopressSetPageTemplate
function motopressSetPageTemplate()
{
require_once 'verifyNonce.php';
require_once 'access.php';
require_once 'functions.php';
require_once 'getLanguageDict.php';
$pageId = $_POST['pageId'];
$template = $_POST['template'];
$lang = getLanguageDict();
if (!$pageId or !$template) {
setError($lang->setPageTemplateError);
}
if (!update_post_meta($pageId, '_wp_page_template', $template)) {
setError($lang->setPageTemplateError);
}
exit;
}
示例10: init
function init()
{
require 'lib.searchengine.php';
$oPlugin = new PPluginDir(dirname(__FILE__));
$oConfigFile =& $oPlugin->oConfig;
$bActivate = $oConfigFile->getDirectParam('ACTIVATE');
if ($bActivate !== "true") {
return setError(_('Please check your configuration. You must activate it befor try to index the content'));
}
if (!createBase()) {
return false;
}
if (!synchroBase()) {
return false;
}
echo gettext('Data base has been populated successfully');
return true;
}
示例11: setLocalePath
function setLocalePath($strPath = false, $strDomain = false)
{
$strDomain = !$strDomain ? 'messages' : $strDomain;
$strPath = !$strPath ? SITE_PATH . 'core/locale' : $strPath;
if (!is_dir($strPath)) {
return setError(sprintf('Can not change the local path to %s. Directory not exists'), $strPath);
}
global $configFile;
$locale = $configFile->getDirectParam('USER_LANGUAGE');
T_setlocale(LC_ALL, $locale);
bindtextdomain($strDomain, $strPath);
// bind_textdomain_codeset is supported only in PHP 4.2.0+
if (function_exists('bind_textdomain_codeset')) {
bind_textdomain_codeset($strDomain, 'utf-8');
}
textdomain($strDomain);
return true;
}
示例12: getItems
public static function getItems($period, $user, $yachs = 'ntime', $sport = '*', $currentpage = 'weekpage')
{
$db = JFactory::getDbo();
$query = $db->getQuery(true);
$query->select('count(ft.id) as days,ft.ft_id, cf.title,avg(ft.fitness_value) as value,cf.unit,cf.color');
$query->from($db->quoteName('#__htraininglogs_ft_fitness') . ' AS ft');
$query->leftjoin('#__htraininglogs_cfg_fitness AS cf ON ft.ft_id = cf.id');
$query->where('cf.user_id = ' . $user->id);
$query->where('ft.date1 BETWEEN "' . $period->anfdat->format('Y-m-d') . ' 0:00:00" AND "' . $period->enddat->format('Y-m-d') . ' 23:59:59"');
$query->group('cf.title,unit');
$query->order('cf.ordering');
$db->setQuery($query);
$valuebased = $db->loadObjectlist();
if ($db->getErrorNum()) {
setError(JText::_('COM_HTRAININGLOGS_GET_TRSESSION_FAIL'));
return false;
}
return $valuebased;
}
示例13: f
function f($e)
{
if ($e instanceof ForbiddenException) {
return setError(403, 'FORBIDDEN');
} else {
if ($e instanceof WrongMethodException) {
return setError(405, 'WRONG METHOD');
} else {
if ($e instanceof BadRequestException) {
return setError(400, 'BAD REQUEST');
} else {
if ($e instanceof NotFoundException) {
return setError(404, 'NOT FOUND');
} else {
return setError(500, 'INTERNAL SERVER ERROR');
}
}
}
}
}
示例14: getGroupparams
public static function getGroupparams()
{
$db = JFactory::getDbo();
$query = $db->getQuery(true);
$query->select('*');
$query->from($db->quoteName('#__htraininglogs_cfg_category') . ' AS ft');
$query->where('(ctype="b") or (ctype="g")');
$db->setQuery($query);
$data = $db->loadObjectlist();
if ($db->getErrorNum()) {
setError(JText::_('COM_HTRAININGLOGS_GET_TRSESSION_FAIL'));
return false;
}
$groupparam = array('RECOM', 'GA!', 'KA1', 'GA2', 'KA2', 'WSA', 'ALT', 'STD', 'BELSTD', 'KM', 'CLMB');
foreach ($data as $sub) {
$groupparam[$sub->cat_abbr] = new stdClass();
$groupparam[$sub->cat_abbr]->color = $sub->color;
}
return $groupparam;
}
示例15: doLogin
function doLogin()
{
if ($_SERVER['REQUEST_METHOD'] == 'GET') {
return;
}
if (!isset($_POST['username']) || !isset($_POST['login'])) {
setError('Ungültige Anmeldedaten');
return;
}
$username = trim($_POST['username']);
$password = trim($_POST['password']);
if ($username == '' || $password == '') {
setError('Ungültige Anmeldedaten');
return;
}
if (authenticate($username, $password)) {
session_start();
session_unset();
session_regenerate_id(true);
$_SESSION['username'] = $_POST['username'];
}
}