本文整理汇总了PHP中raise_error函数的典型用法代码示例。如果您正苦于以下问题:PHP raise_error函数的具体用法?PHP raise_error怎么用?PHP raise_error使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了raise_error函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: _load_config
private function _load_config()
{
$fpath_config_dist = $this->home . '/config.inc.php.dist';
$fpath_config = $this->home . '/config.inc.php';
if (is_file($fpath_config_dist) and is_readable($fpath_config_dist)) {
$found_config_dist = true;
}
if (is_file($fpath_config) and is_readable($fpath_config)) {
$found_config = true;
}
if ($found_config_dist or $found_config) {
ob_start();
if ($found_config_dist) {
include $fpath_config_dist;
$vboxadm_config_dist = $vboxadm_config;
}
if ($found_config) {
include $fpath_config;
}
$config_array = array_merge($vboxadm_config_dist, $vboxadm_config);
$this->config = $config_array;
$this->vboxapi->setConfig($this->config);
//$this->vboxapi->setDebug(1);
ob_end_clean();
} else {
raise_error(array('code' => 527, 'type' => 'php', 'message' => "Failed to load vboxadm plugin config"), true, true);
}
}
示例2: filter
public static function filter($type, DirItem $item)
{
if (is_array($type)) {
foreach ($type as $_type) {
if (self::filter($_type, $item)) {
return true;
}
}
}
/*
* Обработаем callback
*/
if (is_callable($type)) {
return !!call_user_func($type, $item);
}
$type = $type ? $type : self::ALL;
switch ($type) {
case self::ALL:
return true;
case self::IMAGES:
return $item->isImg();
case self::DIRS:
return $item->isDir();
case self::FILES:
return $item->isFile();
case self::ARCHIVES:
return $item->checkExtension(array(PsConst::EXT_RAR, PsConst::EXT_ZIP));
default:
//Если ни один из фильтров не подошел, проверим, может мы фильтруем по расшерению?
if (PsConst::hasExt($type)) {
return $item->checkExtension($type);
}
raise_error("Unknown dir item filter type: [{$type}].");
}
}
示例3: __autoload
function __autoload($class)
{
// parse the class into the correct file format
$class_file = strtolower($class) . '.php';
// an array of possible paths containing the class
$paths = array('library/', 'application/controllers/', 'application/models/', 'application/library');
// get the config object
$config = get_config();
// get the system path
$sys_path = $config->get('path.system');
// loop through the paths
foreach ($paths as $path) {
// append the system path
$path = $sys_path . '/' . $path;
// append the class file to each path
$path .= $class_file;
// check if the file exists
if (file_exists($path)) {
// include the class
require_once $path;
// break once we have a matching path
break;
}
}
// check if we have the class
if (!class_exists($class)) {
// fake the class' existence if not
eval("class " . $class . "{}");
// raise custom error
raise_error('Cannot find class: ' . $class);
}
}
示例4: inst
/**
* Основной метод получения экземпляра.
*
* @param type $silentOnDoubleTry - признак, стоит ли нам ругаться, если мы
* обнаруживаем зацикливание при попытке получения экземпляра класса.
*
* Это нужно для классов, которые выполняют сложную логику в конструкторе, которая
* может привести к повторному вызову ::inst() внутри этого конструктора.
*
* Классы, которые используют эту возможность:
* @link DbChangeListener - менеджер прослушивания изменений в БД
*/
protected static function inst($silentOnDoubleTry = false)
{
$class = get_called_class();
if (array_key_exists($class, self::$_insts_)) {
return self::$_insts_[$class];
}
if (array_key_exists($class, self::$_instsrq_)) {
if ($silentOnDoubleTry) {
return null;
}
raise_error("Double try to get singleton of [{$class}]");
}
self::$_instsrq_[$class] = true;
//Создаём экземпляр
$sec = Secundomer::startedInst("Creating singleton of {$class}");
self::$_insts_[$class] = new $class();
$sec->stop();
//Экземпляр успешно создан
unset(self::$_instsrq_[$class]);
//Теперь добавим в профайлер. Всё это нужно для защиты от зацикливания.
PsProfiler::inst(__CLASS__)->add($class, $sec);
//Добавим к глобальному секундомеру - текущий
$SECUNDOMER = self::$_secundomer_ ? self::$_secundomer_ : (self::$_secundomer_ = Secundomer::inst());
$SECUNDOMER->addSecundomer($sec);
//Отлогируем
PsLogger::inst(__CLASS__)->info("+ {$class} ({$sec->getAverage()} / {$SECUNDOMER->getTotalTimeRounded()})");
return self::$_insts_[$class];
}
示例5: password_save
/**
* Dovecot Password File Driver (dovecotpfd)
*
* Roundcube password plugin driver that adds functionality to change passwords stored in
* Dovecot passwd/userdb files (see: http://wiki.dovecot.org/AuthDatabase/PasswdFile)
*
* Copyright (C) 2011, Charlie Orford
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2
* as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
*
* SCRIPT REQUIREMENTS:
*
* - PHP 5.3.0 or higher, shell access and the ability to run php scripts from the CLI
*
* - chgdovecotpw and dovecotpfd-setuid.c (these two files should have been bundled with this driver)
*
* - dovecotpfd-setuid.c must be compiled and the resulting dovecotpfd-setuid binary placed in the same directory
* as this script (see dovecotpfd-setuid.c source for compilation instructions, security info and options)
*
* - chgdovecotpw must be placed in a location where dovecotpfd-setuid can access it once it has changed UID (normally /usr/sbin is a good choice)
*
* - chgdovecotpw should only be executable by the user dovecotpfd-setuid changes UID to
*
* - the dovecot passwd/userdb file must be accessible and writable by the same user dovecotpfd-setuid changes UID to
*
* - dovecotpw (usually packaged with dovecot itself and found in /usr/sbin) must be available and executable by chgdovecotpw
*
*
* @version 1.1 (2011-09-08)
* @author Charlie Orford (charlie.orford@attackplan.net)
**/
function password_save($currpass, $newpass)
{
$rcmail = rcmail::get_instance();
$currdir = realpath(dirname(__FILE__));
list($user, $domain) = explode("@", $_SESSION['username']);
$username = rcmail::get_instance()->config->get('password_dovecotpfd_format') == "%n" ? $user : $_SESSION['username'];
$scheme = rcmail::get_instance()->config->get('password_dovecotpfd_scheme');
// Set path to dovecot passwd/userdb file
// (the example below shows how you can support multiple passwd files, one for each domain. If you just use one file, replace sprintf with a simple string of the path to the passwd file)
$passwdfile = sprintf("/home/mail/%s/passwd", $domain);
// Build command to call dovecotpfd-setuid wrapper
$exec_cmd = sprintf("%s/dovecotpfd-setuid -f=%s -u=%s -s=%s -p=\"%s\" 2>&1", $currdir, escapeshellcmd(realpath($passwdfile)), escapeshellcmd($username), escapeshellcmd($scheme), escapeshellcmd($newpass));
// Call wrapper to change password
if ($ph = @popen($exec_cmd, "r")) {
$response = "";
while (!feof($ph)) {
$response .= fread($ph, 8192);
}
if (pclose($ph) == 0) {
return PASSWORD_SUCCESS;
}
raise_error(array('code' => 600, 'type' => 'php', 'file' => __FILE__, 'line' => __LINE__, 'message' => "Password plugin: {$currdir}/dovecotpfd-setuid returned an error"), true, false);
return PASSWORD_ERROR;
} else {
raise_error(array('code' => 600, 'type' => 'php', 'file' => __FILE__, 'line' => __LINE__, 'message' => "Password plugin: error calling {$currdir}/dovecotpfd-setuid"), true, false);
return PASSWORD_ERROR;
}
}
示例6: registerDestructable
/**
* Основной метод, регистрирующий класс для закрытия
*
* @param Destructable $inst - Экземпляр класса, которй будет гарантированно закрыт в свою очередь
* @param int $order - порядок закрытия
*/
public static function registerDestructable(Destructable $inst, $order)
{
/*
* Класс получаем через get_called_class(), так как PsShotdownSdk может быть переопределён проектным
*/
$class = get_called_class();
/*
* Проверяем, что нам передан валидный order
*/
$order = PsUtil::assertClassHasConstVithValue($class, null, PsCheck::int($order));
/*
* Регистрируем shutdown
*/
if (is_null(self::$DESTRUCTS)) {
PsUtil::assertClassHasDifferentConstValues($class);
self::$DESTRUCTS = array();
register_shutdown_function(array(__CLASS__, '_doShotdown'));
}
/*
* Проверим, что нет попытки повторной регистрации с тем-же order
*/
if (array_key_exists($order, self::$DESTRUCTS)) {
raise_error("Попытка повторно зарегистрировать Destructable с порядком [{$order}] для класса " . get_class($inst));
}
/*
* Регистрируем класс на закрытие
*/
self::$DESTRUCTS[$order] = $inst;
}
示例7: __construct
public function __construct($name, $comment)
{
check_condition(defined($name), "Глобальное свойство [{$name}] не определено.");
$this->name = $name;
$this->val = constant($name);
$this->comment = $comment;
$type = gettype($this->val);
//Определим тип
switch ($type) {
case PsConst::PHP_TYPE_BOOLEAN:
$this->type = self::TYPE_BOOLEAN;
break;
case PsConst::PHP_TYPE_INTEGER:
case PsConst::PHP_TYPE_DOUBLE:
case PsConst::PHP_TYPE_FLOAT:
$this->type = self::TYPE_NUMERIC;
break;
case PsConst::PHP_TYPE_STRING:
$this->type = self::TYPE_STRING;
break;
default:
/*
* "array"
* "object"
* "resource"
* "NULL"
* "unknown type"
*/
raise_error("Неизвестный тип [{$type}] для глобального свойства {$name}.");
break;
}
$this->info = "{$this->name} ({$this->type})";
}
示例8: register
/**
* Метод регистрируем маппинг
*/
protected final function register(Mapping $mapping)
{
if (array_key_exists($mapping->getHash(), $this->mappings)) {
raise_error("Маппинг '{$mapping}' уже заругистрирован");
} else {
$this->mappings[$mapping->getHash()] = $mapping;
}
}
示例9: load
function load($file)
{
if (!file_exists($file)) {
raise_error("{$file}: File does not exist", 'YamlParserError');
return false;
}
return Spyc::YAMLLoad($file);
}
示例10: save
function save($currpass, $newpass)
{
$rcmail = rcmail::get_instance();
$format = $rcmail->config->get('password_virtualmin_format', 0);
$username = $_SESSION['username'];
switch ($format) {
case 1:
// username%domain
$domain = substr(strrchr($username, "%"), 1);
break;
case 2:
// username.domain (could be bogus)
$pieces = explode(".", $username);
$domain = $pieces[count($pieces) - 2] . "." . end($pieces);
break;
case 3:
// domain.username (could be bogus)
$pieces = explode(".", $username);
$domain = $pieces[0] . "." . $pieces[1];
break;
case 4:
// username-domain
$domain = substr(strrchr($username, "-"), 1);
break;
case 5:
// domain-username
$domain = str_replace(strrchr($username, "-"), "", $username);
break;
case 6:
// username_domain
$domain = substr(strrchr($username, "_"), 1);
break;
case 7:
// domain_username
$pieces = explode("_", $username);
$domain = $pieces[0];
break;
case 8:
// domain taken from alias, username left as it was
$email = $rcmail->user->data['alias'];
$domain = substr(strrchr($email, "@"), 1);
break;
default:
// username@domain
$domain = substr(strrchr($username, "@"), 1);
}
$username = escapeshellcmd($username);
$domain = escapeshellcmd($domain);
$newpass = escapeshellcmd($newpass);
$curdir = INSTALL_PATH . 'plugins/password/helpers';
exec("{$curdir}/chgvirtualminpasswd modify-user --domain {$domain} --user {$username} --pass {$newpass}", $output, $returnvalue);
if ($returnvalue == 0) {
return PASSWORD_SUCCESS;
} else {
raise_error(array('code' => 600, 'type' => 'php', 'file' => __FILE__, 'line' => __LINE__, 'message' => "Password plugin: Unable to execute {$curdir}/chgvirtualminpasswd"), true, false);
}
return PASSWORD_ERROR;
}
示例11: _db_connect
private function _db_connect($mode)
{
$this->db = rcube_db::factory($this->config['db_dsn'], '', false);
$this->db->db_connect($mode);
// check DB connections and exit on failure
if ($err_str = $this->db->is_error()) {
raise_error(array('code' => 603, 'type' => 'db', 'message' => $err_str), FALSE, TRUE);
}
}
示例12: __construct
/**
* Constructor
*
* @param string $lang Language code
*/
function __construct($lang = 'en')
{
$this->rc = rcmail::get_instance();
$this->engine = $this->rc->config->get('spellcheck_engine', 'googie');
$this->lang = $lang ? $lang : 'en';
if ($this->engine == 'pspell' && !extension_loaded('pspell')) {
raise_error(array('code' => 500, 'type' => 'php', 'file' => __FILE__, 'line' => __LINE__, 'message' => "Pspell extension not available"), true, true);
}
$this->options = array('ignore_syms' => $this->rc->config->get('spellcheck_ignore_syms'), 'ignore_nums' => $this->rc->config->get('spellcheck_ignore_nums'), 'ignore_caps' => $this->rc->config->get('spellcheck_ignore_caps'), 'dictionary' => $this->rc->config->get('spellcheck_dictionary'));
}
示例13: password_save
/**
* chpasswd Driver
*
* Driver that adds functionality to change the systems user password via
* the 'chpasswd' command.
*
* For installation instructions please read the README file.
*
* @version 1.0
* @author Alex Cartwright <acartwright@mutinydesign.co.uk)
*/
function password_save($currpass, $newpass)
{
$cmd = sprintf('echo \'%1$s:%2$s\' | %3$s; echo $?', addcslashes($_SESSION['username'], "'"), addcslashes($newpass, "'"), rcmail::get_instance()->config->get('password_chpasswd_cmd'));
if (exec($cmd) == 0) {
return PASSWORD_SUCCESS;
} else {
raise_error(array('code' => 600, 'type' => 'php', 'file' => __FILE__, 'message' => "Password plugin: Unable to execute {$cmd}"), true, false);
}
return PASSWORD_ERROR;
}
示例14: ident
public static function ident($item)
{
if ($item instanceof AbstractPost) {
return self::postId($item->getPostType(), $item->getIdent());
}
if ($item instanceof Rubric) {
return self::rubricId($item->getPostType(), $item->getIdent());
}
raise_error('В IdHelper передан элемент неподдрживаемого типа: ' . PsUtil::getClassName($item));
}
示例15: replace
/**
* Метод ищет в строке подстроки, удовлетворяющие шаблону и заменяет их по очереди на подстановки,
* переданные в виде массива. Поиск идёт по регулярному выражению!
*
* @param string $pattern - шаблон
* @param string $text - текст
* @param array $tokens - массив подстановок
* @return string
*/
public static function replace($pattern, $text, array $tokens)
{
self::$inst = self::$inst ? self::$inst : new PregReplaceCyclic();
self::$inst->tokens = check_condition($tokens, 'Не переданы элементы для замены');
if (is_assoc_array($tokens)) {
raise_error('Недопустим ассоциативный массив подстановок. Передан: ' . array_to_string($tokens, true));
}
self::$inst->idx = 0;
self::$inst->count = count($tokens);
return preg_replace_callback($pattern, array(self::$inst, '_replace'), $text);
}