本文整理汇总了PHP中PEAR::throwError方法的典型用法代码示例。如果您正苦于以下问题:PHP PEAR::throwError方法的具体用法?PHP PEAR::throwError怎么用?PHP PEAR::throwError使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PEAR
的用法示例。
在下文中一共展示了PEAR::throwError方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: restoreEncrypted
function restoreEncrypted()
{
$encoded = basename($_SERVER['PATH_INFO']);
$rc4 =& new Crypt_RC4(SECRET_KEY);
$encoded = base64_decode(str_replace('^', '/', $encoded));
$rc4->decrypt($encoded);
$params = unserialize($encoded);
if (is_array($params)) {
foreach ($params as $name => $value) {
$_REQUEST[$name] = $_GET[$name] = $value;
}
unset($params['crc32_chk']);
if (CHECK_URLS_CRC32) {
if (!isset($_GET['crc32_chk']) || crc32(serialize($params)) != $_GET['crc32_chk']) {
return PEAR::throwError('URL Error: URL Manipulation', URL_MANIPULATION, array('class' => 'SAUrl', 'file' => __FILE__, 'line' => __LINE__));
}
}
}
return URL_OK;
}
示例2: authenticate
/**
* Authenticate
*
* Auth process (not yet standarized but used any way)
* http://www.mibsoftware.com/userkt/nntpext/index.html
*
* @param string $user The username
* @param optional string $pass The password
* @param optional string $mode The authentication mode (original, simple, generic).
*
* @return mixed (bool) true on success or (object) pear_error on failure
* @access public
* @see Net_NNTP_Client::connect()
* @see Net_NNTP_Client::connectAuthenticated()
*/
function authenticate($user, $pass, $mode = NET_NNTP_CLIENT_AUTH_ORIGINAL)
{
// Username is a must...
if ($user == null) {
return PEAR::throwError('No username supplied', null);
}
// Use selected authentication method
switch ($mode) {
case NET_NNTP_CLIENT_AUTH_ORIGINAL:
return $this->cmdAuthinfo($user, $pass);
break;
case NET_NNTP_CLIENT_AUTH_SIMPLE:
return $this->cmdAuthinfoSimple($user, $pass);
break;
case NET_NNTP_CLIENT_AUTH_GENERIC:
return $this->cmdAuthinfoGeneric($user, $pass);
break;
default:
return PEAR::throwError("The auth mode: '{$mode}' is unknown", null);
}
}
示例3: command
/**
* Issue a command to the NNTP server
*
* @param string $cmd The command to launch, ie: "ARTICLE 1004853"
*
* @return mixed (int) response code on success or (object) pear_error on failure
* @access public
*/
function command($cmd)
{
$code = $this->_sendCommand($cmd);
if (PEAR::isError($code)) {
return PEAR::throwError($code);
}
return $code . ' ' . $this->currentStatusResponse() . "\r\n";
}
示例4: _sendCommand
/**
* Send a command to the server. A carriage return / linefeed (CRLF) sequence
* will be appended to each command string before it is sent to the IMAP server.
*
* @param string $cmd The command to launch, ie: "ARTICLE 1004853"
*
* @return mixed (int) response code on success or (object) pear_error on failure
* @access private
*/
function _sendCommand($cmd)
{
// NNTP/RFC977 only allows command up to 512 (-2) chars.
if (!strlen($cmd) > 510) {
return PEAR::throwError('Failed to write to socket! (Command to long - max 510 chars)');
}
// Check if connected
if (!$this->isConnected()) {
return PEAR::throwError('Failed to write to socket! (connection lost!)');
}
// Send the command
$R = $this->_socket->writeLine($cmd);
if (PEAR::isError($R)) {
return PEAR::throwError('Failed to write to socket!', null, $R->getMessage());
}
if ($this->_debug) {
echo "C: {$cmd}\r\n";
}
return $this->_getStatusResponse();
}
示例5: error
/**
*
* Extended behavior for PEAR_Error.
*
* @access public
*
* @return void
*
*/
function error()
{
// throw a PEAR_Error
PEAR::throwError($this->text, $this->code, $this->info);
}
示例6: setPersistantOptions
/**
* Sets which items should be persistant
*
* Sets which items should have the disabled attribute
* to keep it persistant
*
* @param mixed $optionValues Options (key-values) that should be persistant
* @param bool $persistant (optional) TRUE if persistant, FALSE otherwise
*
* @since version 1.5.0 (2009-02-15)
* @access public
* @return PEAR_Error on error and TRUE on success
* @throws PEAR_Error
*/
function setPersistantOptions($optionValues, $persistant = true)
{
if (!is_bool($persistant)) {
return PEAR::throwError('Argument 2 of HTML_QuickForm_advmultiselect::' . 'setPersistantOptions is not a boolean', HTML_QUICKFORM_ADVMULTISELECT_ERROR_INVALID_INPUT, array('level' => 'exception'));
}
if (is_string($optionValues)) {
$optionValues = array($optionValues);
}
if (!is_array($optionValues)) {
return PEAR::throwError('Argument 1 of HTML_QuickForm_advmultiselect::' . 'setPersistantOptions is not a valid array', HTML_QUICKFORM_ADVMULTISELECT_ERROR_INVALID_INPUT, array('level' => 'exception'));
}
foreach ($this->_options as $k => $v) {
if (in_array($v['attr']['value'], $optionValues)) {
if ($persistant) {
$this->_options[$k]['attr']['disabled'] = 'disabled';
} else {
unset($this->_options[$k]['attr']['disabled']);
}
}
}
return true;
}
示例7: factory
/**
* Factory for Net_Ping_Result
*
* @access public
* @param array $result Net_Ping result
* @param string $sysname OS_Guess::sysname
*/
function factory($result, $sysname)
{
if (!Net_Ping_Result::_prepareParseResult($sysname)) {
return PEAR::throwError(NET_PING_RESULT_UNSUPPORTED_BACKEND_MSG, NET_PING_RESULT_UNSUPPORTED_BACKEND);
} else {
return new Net_Ping_Result($result, $sysname);
}
}
示例8: login
/**
* Login function
*
* @access private
* @return void
*/
function login()
{
$login_ok = false;
if (method_exists($this, '_loadStorage')) {
$this->_loadStorage();
}
$this->storage->_auth_obj->_sessionName =& $this->_sessionName;
/**
* When the user has already entered a username,
* we have to validate it.
*/
if (!empty($this->username) && !empty($this->password)) {
if ($this->authType == 'basic' && !$this->options['forceDigestOnly']) {
if (true === $this->storage->fetchData($this->username, $this->password)) {
$login_ok = true;
}
} else {
/* digest authentication */
if (!$this->getAuth() || $this->getAuthData('a1') == null) {
/*
* note:
* - only PEAR::DB is supported as container.
* - password should be stored in container as plain-text
* (if $options['cryptType'] == 'none') or
* A1 hashed form (md5('username:realm:password'))
* (if $options['cryptType'] == 'md5')
*/
$dbs = $this->storage;
if (!DB::isConnection($dbs->db)) {
$dbs->_connect($dbs->options['dsn']);
}
$query = 'SELECT ' . $dbs->options['passwordcol'] . " FROM " . $dbs->options['table'] . ' WHERE ' . $dbs->options['usernamecol'] . " = '" . $dbs->db->quoteString($this->username) . "' ";
$pwd = $dbs->db->getOne($query);
// password stored in container.
if (DB::isError($pwd)) {
include_once 'PEAR.php';
return PEAR::throwError($pwd->getMessage(), $pwd->getCode());
}
if ($this->options['cryptType'] == 'none') {
$a1 = md5($this->username . ':' . $this->options['digestRealm'] . ':' . $pwd);
} else {
$a1 = $pwd;
}
$this->setAuthData('a1', $a1, true);
} else {
$a1 = $this->getAuthData('a1');
}
$login_ok = $this->validateDigest($this->password, $a1);
if ($this->nextNonce == false) {
$login_ok = false;
}
}
if (!$login_ok && is_callable($this->loginFailedCallback)) {
call_user_func($this->loginFailedCallback, $this->username, $this);
}
}
if (!empty($this->username) && $login_ok) {
$this->setAuth($this->username);
if (is_callable($this->loginCallback)) {
call_user_func($this->loginCallback, $this->username, $this);
}
}
/**
* If the login failed or the user entered no username,
* output the login screen again.
*/
if (!empty($this->username) && !$login_ok) {
$this->status = AUTH_WRONG_LOGIN;
}
if ((empty($this->username) || !$login_ok) && $this->showLogin) {
$this->drawLogin($this->storage->activeUser);
return;
}
if (!empty($this->username) && $login_ok && $this->authType == 'digest' && $this->auth['qop'] == 'auth') {
$this->authenticationInfo();
}
}
示例9: DB_Table_Database
/**
* Constructor
*
* If an error is encountered during instantiation, the error
* message is stored in the $this->error property of the resulting
* object. See $error property docblock for a discussion of error
* handling.
*
* @param object &$db DB/MDB2 database connection object
* @param string $name the database name
* @return object DB_Table_Database
* @access public
*/
function DB_Table_Database(&$db, $name)
{
// Is $db an DB/MDB2 object or null?
if (is_a($db, 'db_common')) {
$this->backend = 'db';
$this->fetchmode = DB_FETCHMODE_ORDERED;
} elseif (is_a($db, 'mdb2_driver_common')) {
$this->backend = 'mdb2';
$this->fetchmode = MDB2_FETCHMODE_ORDERED;
} else {
$code = DB_TABLE_DATABASE_ERR_DB_OBJECT;
$text = $GLOBALS['_DB_TABLE_DATABASE']['error'][$code] . ' DB_Table_Database';
$this->error = PEAR::throwError($text, $code);
return;
}
$this->db =& $db;
$this->name = $name;
$this->_primary_subclass = 'DB_TABLE_DATABASE';
$this->setFixCase(false);
}
示例10:
/**
*
* Specialized version of throwError() modeled on PEAR_Error.
*
* Throws a PEAR_Error with a DB_Table error message based on a
* DB_Table constant error code.
*
* @static
*
* @access public
*
* @param string $code A DB_Table error code constant.
*
* @param string $extra Extra text for the error (in addition to the
* regular error message).
*
* @return object PEAR_Error
*
*/
function &throwError($code, $extra = null)
{
// get the error message text based on the error code
$text = $GLOBALS['_DB_TABLE']['error'][$code];
// add any additional error text
if ($extra) {
$text .= ' ' . $extra;
}
// done!
$error = PEAR::throwError($text, $code);
return $error;
}
示例11: Auth
/**
* Constructor
*
* Set up the storage driver.
*
* @param string Type of the storage driver
* @param mixed Additional options for the storage driver
* (example: if you are using DB as the storage
* driver, you have to pass the dsn string here)
*
* @param string Name of the function that creates the login form
* @param boolean Should the login form be displayed if neccessary?
* @return void
*/
function Auth($storageDriver, $options = '', $loginFunction = '', $showLogin = true)
{
$this->applyAuthOptions($options);
// Start the session suppress error if already started
if (!session_id()) {
@session_start();
if (!session_id()) {
// Throw error
include_once 'lib/pear/PEAR.php';
PEAR::throwError('Session could not be started by Auth, ' . 'possibly headers are already sent, try putting ' . 'ob_start in the beginning of your script');
}
}
// Make Sure Auth session variable is there
if (!isset($_SESSION[$this->_sessionName])) {
$_SESSION[$this->_sessionName] = array();
}
// Assign Some globals to internal references, this will replace _importGlobalVariable
$this->session =& $_SESSION[$this->_sessionName];
$this->server =& $_SERVER;
$this->post =& $_POST;
$this->cookie =& $_COOKIE;
if ($loginFunction != '' && is_callable($loginFunction)) {
$this->loginFunction = $loginFunction;
}
if (is_bool($showLogin)) {
$this->showLogin = $showLogin;
}
if (is_object($storageDriver)) {
$this->storage =& $storageDriver;
// Pass a reference to auth to the container, ugly but works
// this is used by the DB container to use method setAuthData not staticaly.
$this->storage->_auth_obj =& $this;
} else {
// $this->storage = $this->_factory($storageDriver, $options);
//
$this->storage_driver = $storageDriver;
$this->storage_options =& $options;
}
}
示例12: factory
/**
* Factory for Net_Traceroute_Result
*
* @param array $result Net_Traceroute result
* @param string $sysname OS_Guess::sysname
* @access public
*/
function factory($result, $sysname)
{
if (!Net_Traceroute_Result::_prepareParseResult($sysname)) {
return PEAR::throwError(NET_TRACEROUTE_RESULT_UNSUPPORTED_BACKEND_MSG, NET_TRACEROUTE_RESULT_UNSUPPORTED_BACKEND);
} else {
return new Net_Traceroute_Result($result, $sysname);
}
}
示例13: ProcessException
/**
*
* Simple error-object generator.
*
* @access public
*
* @param string $message The error message.
*
* @return object PEAR_Error
*
*/
function &error($message)
{
throw new ProcessException($message);
// FIX?
if (!class_exists('PEAR_Error')) {
include_once 'PEAR.php';
}
return PEAR::throwError($message);
}
示例14:
/**
*
* Simple error-object generator.
*
* @access public
*
* @param string $message The error message.
*
* @return object PEAR_Error
*
*/
function &error($message)
{
if (!class_exists('PEAR_Error')) {
include_once 'PEAR.php';
}
return PEAR::throwError($message);
}
示例15: assertDriverConfig
/**
* Checks if all necessary parameters for a driver's configuration are set
* and returns a PEAR_Error if something is missing.
*
* @param array $params The configuration array with all parameters.
* @param array $fields An array with mandatory parameter names for this
* driver.
* @param string $name The clear text name of the driver. If not
* specified, the application name will be used.
* @param array $info A hash containing detailed information about the
* driver. Will be passed as the userInfo to the
* PEAR_Error.
*/
function assertDriverConfig($params, $fields, $name, $info = array())
{
$info = array_merge($info, array('params' => $params, 'fields' => $fields, 'name' => $name));
if (!is_array($params) || !count($params)) {
require_once 'PEAR.php';
return PEAR::throwError(sprintf(_("No configuration information specified for %s."), $name), HORDE_ERROR_DRIVER_CONFIG_MISSING, $info);
}
foreach ($fields as $field) {
if (!isset($params[$field])) {
require_once 'PEAR.php';
return PEAR::throwError(sprintf(_("Required \"%s\" not specified in configuration."), $field, $name), HORDE_ERROR_DRIVER_CONFIG, $info);
}
}
}