本文整理汇总了PHP中PEAR::raiseError方法的典型用法代码示例。如果您正苦于以下问题:PHP PEAR::raiseError方法的具体用法?PHP PEAR::raiseError怎么用?PHP PEAR::raiseError使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PEAR
的用法示例。
在下文中一共展示了PEAR::raiseError方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: switch
/**
* Factory class. Returns an object of the request
* type.
*
* @param string $type One of: Anonymous
* Plain
* CramMD5
* DigestMD5
* Types are not case sensitive
*/
function &factory($type)
{
switch (strtolower($type)) {
case 'anonymous':
$filename = 'Auth/SASL/Anonymous.php';
$classname = 'Auth_SASL_Anonymous';
break;
case 'login':
$filename = 'Auth/SASL/Login.php';
$classname = 'Auth_SASL_Login';
break;
case 'plain':
$filename = 'Auth/SASL/Plain.php';
$classname = 'Auth_SASL_Plain';
break;
case 'crammd5':
$filename = 'Auth/SASL/CramMD5.php';
$classname = 'Auth_SASL_CramMD5';
break;
case 'digestmd5':
$filename = 'Auth/SASL/DigestMD5.php';
$classname = 'Auth_SASL_DigestMD5';
break;
default:
return PEAR::raiseError('Mecanismo do tipo SASL inválido');
break;
}
require_once $filename;
$obj = new $classname();
return $obj;
}
示例2: handle
function handle(&$params)
{
if (!@$_REQUEST['email']) {
return PEAR::raiseError("No email address specified");
}
import('HTML/QuickForm.php');
$form = new HTML_QuickForm('opt_out_form', 'post');
$form->addElement('hidden', 'email', $_REQUEST['email']);
$form->addElement('hidden', '-action', 'email_opt_out');
$form->addElement('submit', 'submit', 'Cancel Subscription');
if ($form->validate()) {
$res = mysql_query("replace into dataface__email_blacklist (email) values ('" . addslashes($_REQUEST['email']) . "')", df_db());
if (!$res) {
trigger_error(mysql_error(df_db()), E_USER_ERROR);
}
header('Location: ' . DATAFACE_SITE_HREF . '?--msg=' . urlencode('You have successfully opted out of our mail list. You will no longer receive emails from us.'));
exit;
}
ob_start();
$form->display();
$html = ob_get_contents();
ob_end_clean();
$context = array();
$context['form'] = $html;
df_register_skin('email', DATAFACE_PATH . '/modules/Email/templates');
df_display($context, 'email/opt_out_form.html');
}
示例3: parse_ini_file
/**
* Parses the data of the given configuration file
*
* @access public
* @param string $datasrc path to the configuration file
* @param object $obj reference to a config object
* @return mixed returns a PEAR_ERROR, if error occurs or true if ok
*/
function &parseDatasrc($datasrc, &$obj)
{
if (!file_exists($datasrc)) {
return PEAR::raiseError("Datasource file does not exist.", null, PEAR_ERROR_RETURN);
}
$currentSection =& $obj->container;
$confArray = parse_ini_file($datasrc, true);
if (!$confArray) {
return PEAR::raiseError("File '{$datasrc}' does not contain configuration data.", null, PEAR_ERROR_RETURN);
}
foreach ($confArray as $key => $value) {
if (is_array($value)) {
$currentSection =& $obj->container->createSection($key);
foreach ($value as $directive => $content) {
// try to split the value if comma found
if (strpos($content, '"') === false) {
$values = preg_split('/\\s*,\\s+/', $content);
if (count($values) > 1) {
foreach ($values as $k => $v) {
$currentSection->createDirective($directive, $v);
}
} else {
$currentSection->createDirective($directive, $content);
}
} else {
$currentSection->createDirective($directive, $content);
}
}
} else {
$currentSection->createDirective($key, $value);
}
}
return true;
}
示例4: extract
/**
* Extract a ZIP compressed file to a given path
*
* @access public
* @param string $archive Path to ZIP archive to extract
* @param string $destination Path to extract archive into
* @param array $options Extraction options [unused]
* @return boolean True if successful
* @since 1.5
*/
function extract($archive, $destination, $options = array())
{
// Initialize variables
$this->_data = null;
$this->_metadata = null;
if (!($this->_data = file_get_contents($archive))) {
return PEAR::raiseError('Unable to read archive');
}
if (!$this->_getTarInfo($this->_data)) {
return PEAR::raiseError('Unable to decompress data');
}
for ($i = 0, $n = count($this->_metadata); $i < $n; $i++) {
$type = strtolower($this->_metadata[$i]['type']);
if ($type == 'file' || $type == 'unix file') {
$buffer = $this->_metadata[$i]['data'];
$path = extPath::clean($destination . DS . $this->_metadata[$i]['name']);
// Make sure the destination folder exists
if (!extMkdirR(dirname($path))) {
return PEAR::raiseError('Unable to create destination');
}
if (file_put_contents($path, $buffer) === false) {
return PEAR::raiseError('Unable to write entry');
}
}
}
return true;
}
示例5: Structures_DataGrid_Record_DataObject
/**
* Constructor
*
* Builds the record if specified. The data must be of type DB_DataObject.
*
* @access public
* @see DB::DB_DataObject
*/
function Structures_DataGrid_Record_DataObject($data = null)
{
$result = $this->setRecord($data);
if (PEAR::isError($result)) {
PEAR::raiseError($result->toString());
}
}
示例6: display
/**
* A method to launch and display the widget
*
* @param array $aParams The parameters array, usually $_REQUEST
*/
function display()
{
if (!$this->oTpl->is_cached()) {
RV::disableErrorHandling();
$oRss = new XML_RSS($this->url);
$result = $oRss->parse();
RV::enableErrorHandling();
// ignore bad character error which could appear if rss is using invalid characters
if (PEAR::isError($result)) {
if (!strstr($result->getMessage(), 'Invalid character')) {
PEAR::raiseError($result);
// rethrow
$this->oTpl->caching = false;
}
}
$aPost = array_slice($oRss->getItems(), 0, $this->posts);
foreach ($aPost as $key => $aValue) {
$aPost[$key]['origTitle'] = $aValue['title'];
if (strlen($aValue['title']) > 38) {
$aPost[$key]['title'] = substr($aValue['title'], 0, 38) . '...';
}
}
$this->oTpl->assign('title', $this->title);
$this->oTpl->assign('feed', $aPost);
$this->oTpl->assign('siteTitle', $this->siteTitle);
$this->oTpl->assign('siteUrl', $this->siteUrl);
}
$this->oTpl->display();
}
示例7: _validateName
function _validateName()
{
if (!isset($this->routingCode)) {
return PEAR::raiseError('Name is required');
}
return true;
}
示例8: enable_domain
/**
* Enable or disable domain
*
* Possible options:
*
* did (int) default: null
* id of domain which will be en/disabled
* this option is REQUIRED
*
* disable (bool) default: false
* if true domain will be disabled, otherwise wil be enabled
*
* @param array $opt associative array of options
* @return bool TRUE on success, FALSE on failure
*/
function enable_domain($opt)
{
global $config;
$errors = array();
if (!$this->connect_to_db($errors)) {
ErrorHandler::add_error($errors);
return false;
}
/* table's name */
$td_name =& $config->data_sql->domain->table_name;
/* col names */
$cd =& $config->data_sql->domain->cols;
/* flags */
$fd =& $config->data_sql->domain->flag_values;
$o_did = isset($opt['did']) ? $opt['did'] : null;
$o_disable = isset($opt['disable']) ? $opt['disable'] : false;
if (is_null($o_did)) {
ErrorHandler::log_errors(PEAR::raiseError('domain for en/disable is not specified'));
return false;
}
$q = "update " . $td_name . " set ";
if ($o_disable) {
$q .= $cd->flags . " = " . $cd->flags . " | " . $fd['DB_DISABLED'];
} else {
$q .= $cd->flags . " = " . $cd->flags . " & ~" . $fd['DB_DISABLED'];
}
$q .= " where " . $cd->did . " = " . $this->sql_format($o_did, "s");
$res = $this->db->query($q);
if (DB::isError($res)) {
ErrorHandler::log_errors($res);
return false;
}
return true;
}
示例9: initRecordDriver
/**
* initSearchObject
*
* This constructs a search object for the specified engine.
*
* @param array $record The fields retrieved from the Solr index.
*
* @return object The record driver for handling the record.
* @access public
*/
static function initRecordDriver($record)
{
global $configArray;
// Determine driver path based on record type and try a Local version first:
$driver = ucwords($record['recordtype']) . 'RecordLocal';
$path = "RecordDrivers/{$driver}.php";
// Then the regular version:
if (!is_readable($path)) {
$driver = ucwords($record['recordtype']) . 'Record';
$path = "RecordDrivers/{$driver}.php";
}
// If we can't load the driver, fall back to the default, index-based one:
if (!is_readable($path)) {
$driver = 'IndexRecord';
$path = "RecordDrivers/{$driver}.php";
}
// Build the object:
include_once $path;
if (class_exists($driver)) {
$obj = new $driver($record);
return $obj;
}
// If we got here, something went very wrong:
PEAR::raiseError(new PEAR_Error("Problem loading record driver: {$driver}"));
}
示例10: handle
function handle(&$params)
{
$app =& Dataface_Application::getInstance();
$query = $app->getQuery();
$query['-skip'] = 0;
$query['-limit'] = 999999999;
$at = Dataface_ActionTool::getInstance();
$emailAction = $at->getAction(array('name' => 'email'));
if (!isset($emailAction) or !isset($emailAction['email_column'])) {
return PEAR::raiseError("No email column specified");
}
$col = $emailAction['email_column'];
$qb = new Dataface_QueryBuilder($query['-table'], $query);
$sql = "select `" . $col . "` " . $qb->_from() . $qb->_secure($qb->_where());
$res = mysql_query($sql, df_db());
if (!$res) {
trigger_error(mysql_error(df_db()), E_USER_ERROR);
}
$addresses = array();
while ($row = mysql_fetch_row($res)) {
$addresses[] = $row[0];
}
@mysql_free_result($res);
header("Content-type: text/plain");
echo implode(', ', $addresses);
exit;
}
示例11: close
/**
* Take care of getting rid of any active resources.
*/
function close()
{
if (is_null($this->fh)) {
return PEAR::raiseError(_kt('Not open'));
}
return fclose($this->fh);
}
示例12: formatFile
/**
* format a file or URL
*
* @access public
* @param string $file filename
* @param mixed $newFile filename for beautified XML file (if none is given, the XML string will be returned.)
* if you want overwrite the original file, use XML_BEAUTIFIER_OVERWRITE
* @param string $renderer Renderer to use, default is the plain xml renderer
* @return mixed XML string of no file should be written, true if file could be written
* @throws PEAR_Error
* @uses _loadRenderer() to load the desired renderer
*/
function formatFile($file, $newFile = null, $renderer = "Plain")
{
if ($this->apiVersion() != '1.0') {
return $this->raiseError('API version must be 1.0');
}
/**
* Split the document into tokens
* using the XML_Tokenizer
*/
require_once dirname(__FILE__) . '/Tokenizer.php';
$tokenizer = new phpDocumentor_XML_Beautifier_Tokenizer();
$tokens = $tokenizer->tokenize($file, true);
if (PEAR::isError($tokens)) {
return $tokens;
}
include_once dirname(__FILE__) . '/Plain.php';
$renderer = new PHPDoc_XML_Beautifier_Renderer_Plain($this->_options);
$xml = $renderer->serialize($tokens);
if ($newFile == null) {
return $xml;
}
$fp = @fopen($newFile, "w");
if (!$fp) {
return PEAR::raiseError("Could not write to output file", XML_BEAUTIFIER_ERROR_NO_OUTPUT_FILE);
}
flock($fp, LOCK_EX);
fwrite($fp, $xml);
flock($fp, LOCK_UN);
fclose($fp);
return true;
}
示例13: __construct
/**
* Constructor
*
* @access public
*/
public function __construct()
{
global $interface;
global $configArray;
// Call parent constructor
parent::__construct();
// Fetch Record
$config = getExtraConfigArray('MetaLib');
$metalib = new MetaLib();
$this->record = $metalib->getRecord($_REQUEST['id']);
if (PEAR::isError($this->record)) {
PEAR::raiseError($this->record);
}
// Get record driver
$this->recordDriver = RecordDriverFactory::initRecordDriver($this->record);
// Set Proxy URL
$interface->assign('proxy', isset($configArray['EZproxy']['host']) ? $configArray['EZproxy']['host'] : false);
// Whether RSI is enabled
if (isset($configArray['OpenURL']['use_rsi']) && $configArray['OpenURL']['use_rsi']) {
$interface->assign('rsi', true);
}
// Whether embedded openurl autocheck is enabled
if (isset($configArray['OpenURL']['autocheck']) && $configArray['OpenURL']['autocheck']) {
$interface->assign('openUrlAutoCheck', true);
}
// Send record ID to template
$interface->assign('id', $_REQUEST['id']);
// Send down legal export formats (if any):
$interface->assign('exportFormats', array('RefWorks', 'EndNote'));
// Set AddThis User
$interface->assign('addThis', isset($configArray['AddThis']['key']) ? $configArray['AddThis']['key'] : false);
// Get core metadata
$interface->assign('coreMetadata', $this->recordDriver->getCoreMetadata());
}
示例14: processInstallation
function processInstallation($pkg, $atts, $file, $tmp_path, $layer = null)
{
$test = parent::processInstallation($pkg, $atts, $file, $tmp_path, $layer);
if (@file_exists($test[2])) {
// configuration has already been installed, check for mods
if (md5_file($test[2]) !== md5_file($test[3])) {
// configuration has been modified, so save our version as
// configfile-version
$old = $test[2];
$test[2] .= '.new-' . $pkg->getVersion();
// backup original and re-install it
PEAR::pushErrorHandling(PEAR_ERROR_RETURN);
$tmpcfg = $this->config->get('temp_dir');
$newloc = System::mkdir(array('-p', $tmpcfg));
if (!$newloc) {
// try temp_dir
$newloc = System::mktemp(array('-d'));
if (!$newloc || PEAR::isError($newloc)) {
PEAR::popErrorHandling();
return PEAR::raiseError('Could not save existing configuration file ' . $old . ', unable to install. Please set temp_dir ' . 'configuration variable to a writeable location and try again');
}
} else {
$newloc = $tmpcfg;
}
if (!@copy($old, $newloc . DIRECTORY_SEPARATOR . 'savefile')) {
PEAR::popErrorHandling();
return PEAR::raiseError('Could not save existing configuration file ' . $old . ', unable to install. Please set temp_dir ' . 'configuration variable to a writeable location and try again');
}
PEAR::popErrorHandling();
$this->installer->addFileOperation('rename', array($newloc . DIRECTORY_SEPARATOR . 'savefile', $old, false));
$this->installer->addFileOperation('delete', array($newloc . DIRECTORY_SEPARATOR . 'savefile'));
}
}
return $test;
}
示例15: switch
/**
* Factory class. Returns an object of the request
* type.
*
* @param string $type One of: Anonymous
* Plain
* CramMD5
* DigestMD5
* Types are not case sensitive
*/
function &factory($type)
{
switch (strtolower($type)) {
case 'anonymous':
$filename = 'lib/pear/SASL/Anonymous.php';
$classname = 'Auth_SASL_Anonymous';
break;
case 'login':
$filename = 'lib/pear/SASL/Login.php';
$classname = 'Auth_SASL_Login';
break;
case 'plain':
$filename = 'lib/pear/SASL/Plain.php';
$classname = 'Auth_SASL_Plain';
break;
case 'external':
$filename = 'lib/pear/SASL/External.php';
$classname = 'Auth_SASL_External';
break;
case 'crammd5':
$filename = 'lib/pear/SASL/CramMD5.php';
$classname = 'Auth_SASL_CramMD5';
break;
case 'digestmd5':
$filename = 'lib/pear/SASL/DigestMD5.php';
$classname = 'Auth_SASL_DigestMD5';
break;
default:
return PEAR::raiseError('Invalid SASL mechanism type');
break;
}
require_once $filename;
$obj = new $classname();
return $obj;
}