本文整理汇总了PHP中user_error函数的典型用法代码示例。如果您正苦于以下问题:PHP user_error函数的具体用法?PHP user_error怎么用?PHP user_error使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了user_error函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: convert_uudecode
function convert_uudecode($string)
{
// Sanity check
if (!is_scalar($string)) {
user_error('convert_uuencode() expects parameter 1 to be string, ' . gettype($string) . ' given', E_USER_WARNING);
return false;
}
if (strlen($string) < 8) {
user_error('convert_uuencode() The given parameter is not a valid uuencoded string', E_USER_WARNING);
return false;
}
$decoded = '';
foreach (explode("\n", $string) as $line) {
$c = count($bytes = unpack('c*', substr(trim($line), 1)));
while ($c % 4) {
$bytes[++$c] = 0;
}
foreach (array_chunk($bytes, 4) as $b) {
$b0 = $b[0] == 0x60 ? 0 : $b[0] - 0x20;
$b1 = $b[1] == 0x60 ? 0 : $b[1] - 0x20;
$b2 = $b[2] == 0x60 ? 0 : $b[2] - 0x20;
$b3 = $b[3] == 0x60 ? 0 : $b[3] - 0x20;
$b0 <<= 2;
$b0 |= $b1 >> 4 & 0x3;
$b1 <<= 4;
$b1 |= $b2 >> 2 & 0xf;
$b2 <<= 6;
$b2 |= $b3 & 0x3f;
$decoded .= pack('c*', $b0, $b1, $b2);
}
}
return rtrim($decoded, "");
}
开发者ID:poppen,项目名称:p2,代码行数:33,代码来源:convert_uudecode.php
示例2: republish
function republish($original)
{
if (self::$disable_realtime) {
return;
}
$urls = array();
if ($this->owner->hasMethod('pagesAffectedByChanges')) {
$urls = $this->owner->pagesAffectedByChanges($original);
} else {
$pages = Versioned::get_by_stage('SiteTree', 'Live', '', '', '', 10);
if ($pages) {
foreach ($pages as $page) {
$urls[] = $page->AbsoluteLink();
}
}
}
// Note: Similiar to RebuildStaticCacheTask->rebuildCache()
foreach ($urls as $i => $url) {
if (!is_string($url)) {
user_error("Bad URL: " . var_export($url, true), E_USER_WARNING);
continue;
}
// Remove leading slashes from all URLs (apart from the homepage)
if (substr($url, -1) == '/' && $url != '/') {
$url = substr($url, 0, -1);
}
$urls[$i] = $url;
}
$urls = array_unique($urls);
$this->publishPages($urls);
}
开发者ID:rixrix,项目名称:silverstripe-cms,代码行数:31,代码来源:StaticPublisher.php
示例3: convert_uuencode
function convert_uuencode($string)
{
// Sanity check
if (!is_scalar($string)) {
user_error('convert_uuencode() expects parameter 1 to be string, ' . gettype($string) . ' given', E_USER_WARNING);
return false;
}
$u = 0;
$encoded = '';
while ($c = count($bytes = unpack('c*', substr($string, $u, 45)))) {
$u += 45;
$encoded .= pack('c', $c + 0x20);
while ($c % 3) {
$bytes[++$c] = 0;
}
foreach (array_chunk($bytes, 3) as $b) {
$b0 = ($b[0] & 0xfc) >> 2;
$b1 = (($b[0] & 0x3) << 4) + (($b[1] & 0xf0) >> 4);
$b2 = (($b[1] & 0xf) << 2) + (($b[2] & 0xc0) >> 6);
$b3 = $b[2] & 0x3f;
$b0 = $b0 ? $b0 + 0x20 : 0x60;
$b1 = $b1 ? $b1 + 0x20 : 0x60;
$b2 = $b2 ? $b2 + 0x20 : 0x60;
$b3 = $b3 ? $b3 + 0x20 : 0x60;
$encoded .= pack('c*', $b0, $b1, $b2, $b3);
}
$encoded .= "\n";
}
// Add termination characters
$encoded .= "`\n";
return $encoded;
}
开发者ID:casan,项目名称:eccube-2_13,代码行数:32,代码来源:convert_uuencode.php
示例4: str_word_count
function str_word_count($string, $format = null)
{
if ($format !== 1 && $format !== 2 && $format !== null) {
user_error('str_word_count() The specified format parameter, "' . $format . '" is invalid', E_USER_WARNING);
return false;
}
$word_string = preg_replace('/[0-9]+/', '', $string);
$word_array = preg_split('/[^A-Za-z0-9_\']+/', $word_string, -1, PREG_SPLIT_NO_EMPTY);
switch ($format) {
case null:
$result = count($word_array);
break;
case 1:
$result = $word_array;
break;
case 2:
$lastmatch = 0;
$word_assoc = array();
foreach ($word_array as $word) {
$word_assoc[$lastmatch = strpos($string, $word, $lastmatch)] = $word;
$lastmatch += strlen($word);
}
$result = $word_assoc;
break;
}
return $result;
}
开发者ID:hbustun,项目名称:agilebill,代码行数:27,代码来源:str_word_count.php
示例5: handleRequest
/**
* @uses ModelAsController::getNestedController()
* @param SS_HTTPRequest $request
* @param DataModel $model
* @return SS_HTTPResponse
*/
public function handleRequest(SS_HTTPRequest $request, DataModel $model)
{
$this->setRequest($request);
$this->setDataModel($model);
$this->pushCurrent();
// Create a response just in case init() decides to redirect
$this->response = new SS_HTTPResponse();
$this->init();
// If we had a redirection or something, halt processing.
if ($this->response->isFinished()) {
$this->popCurrent();
return $this->response;
}
// If the database has not yet been created, redirect to the build page.
if (!DB::is_active() || !ClassInfo::hasTable('SiteTree')) {
$this->response->redirect(Director::absoluteBaseURL() . 'dev/build?returnURL=' . (isset($_GET['url']) ? urlencode($_GET['url']) : null));
$this->popCurrent();
return $this->response;
}
try {
$result = $this->getNestedController();
if ($result instanceof RequestHandler) {
$result = $result->handleRequest($this->getRequest(), $model);
} else {
if (!$result instanceof SS_HTTPResponse) {
user_error("ModelAsController::getNestedController() returned bad object type '" . get_class($result) . "'", E_USER_WARNING);
}
}
} catch (SS_HTTPResponse_Exception $responseException) {
$result = $responseException->getResponse();
}
$this->popCurrent();
return $result;
}
开发者ID:kamrandotpk,项目名称:silverstripe-cms,代码行数:40,代码来源:ModelAsController.php
示例6: read
function read($pref_name, $user_id = false, $die_on_error = false)
{
$pref_name = db_escape_string($pref_name);
$profile = false;
if (!$user_id) {
$user_id = $_SESSION["uid"];
@($profile = $_SESSION["profile"]);
} else {
$user_id = sprintf("%d", $user_id);
}
if (isset($this->cache[$pref_name])) {
$tuple = $this->cache[$pref_name];
return $this->convert($tuple["value"], $tuple["type"]);
}
if ($profile) {
$profile_qpart = "profile = '{$profile}' AND";
} else {
$profile_qpart = "profile IS NULL AND";
}
if (get_schema_version() < 63) {
$profile_qpart = "";
}
$result = db_query("SELECT value,ttrss_prefs_types.type_name as type_name\n FROM\n ttrss_user_prefs,ttrss_prefs,ttrss_prefs_types\n WHERE\n {$profile_qpart}\n ttrss_user_prefs.pref_name = '{$pref_name}' AND\n ttrss_prefs_types.id = type_id AND\n owner_uid = '{$user_id}' AND\n ttrss_user_prefs.pref_name = ttrss_prefs.pref_name");
if (db_num_rows($result) > 0) {
$value = db_fetch_result($result, 0, "value");
$type_name = db_fetch_result($result, 0, "type_name");
if ($user_id == $_SESSION["uid"]) {
$this->cache[$pref_name]["type"] = $type_name;
$this->cache[$pref_name]["value"] = $value;
}
return $this->convert($value, $type_name);
}
user_error("Fatal error, unknown preferences key: {$pref_name} (owner: {$user_id})", $die_on_error ? E_USER_ERROR : E_USER_WARNING);
return null;
}
开发者ID:adrianpietka,项目名称:bfrss,代码行数:35,代码来源:prefs.php
示例7: Factory
public static function Factory(&$source, $conf_file = NULL, $conf_section = NULL, $strict = TRUE)
{
if (!is_array($source)) {
user_error('$source ' . $source . ' is not an array', E_USER_NOTICE);
}
$cage = new Inspekt_Cage_Session();
$cage->_setSource($source);
$cage->_parseAndApplyAutoFilters($conf_file);
if (ini_get('session.use_cookies') || ini_get('session.use_only_cookies')) {
if (isset($_COOKIE) && isset($_COOKIE[session_name()])) {
session_id($_COOKIE[session_name()]);
} elseif ($cookie = Inspekt::makeSessionCage()) {
session_id($cookie->getAlnum(session_name()));
}
} else {
// we're using session ids passed via GET
if (isset($_GET) && isset($_GET[session_name()])) {
session_id($_GET[session_name()]);
} elseif ($cookie = Inspekt::makeSessionCage()) {
session_id($cookie->getAlnum(session_name()));
}
}
if ($strict) {
$source = NULL;
}
return $cage;
register_shutdown_function();
register_shutdown_function(array($this, '_repopulateSession'));
}
开发者ID:reneartweb,项目名称:finnplus,代码行数:29,代码来源:Session.php
示例8: __construct
function __construct($agentData, $sessionLink = '', $POST = true, $formVarname = 'form')
{
if ($agentData) {
if ($formVarname) {
if (isset($agentData->{$formVarname})) {
user_error(__CLASS__ . ": Overwriting existing \$agentData->{$formVarname}! If this is the intended behavior, unset(\$agentData->{$formVarname}) to remove this warning.");
}
$agentData->{$formVarname} = $this;
}
$this->agentData = $agentData;
} else {
$this->agentData = false;
}
$this->POST = (bool) $POST;
if ($this->POST) {
p::canPost();
if (isset($_POST['_POST_BACKUP'])) {
// This should only be used for field persistence, not as valid input
$this->rawValues =& $GLOBALS['_POST_BACKUP'];
// $this->filesValues =& $GLOBALS['_FILES_BACKUP'];
} else {
$this->rawValues =& $_POST;
$this->filesValues =& $_FILES;
}
} else {
$this->rawValues =& $_GET;
}
if ($sessionLink) {
s::bind($sessionLink, $this->sessionLink);
if (!$this->sessionLink) {
$this->sessionLink = array(0);
}
}
}
开发者ID:nicolas-grekas,项目名称:Patchwork,代码行数:34,代码来源:pForm.php
示例9: __construct
/**
* Most of the code below was copied from ManyManyComplexTableField.
* Painful, but necessary, until PHP supports multiple inheritance.
*/
function __construct($controller, $name, $sourceClass, $fieldList, $detailFormFields = null, $sourceFilter = "", $sourceSort = "Created DESC", $sourceJoin = "")
{
parent::__construct($controller, $name, $sourceClass, $fieldList, $detailFormFields, $sourceFilter, $sourceSort, $sourceJoin);
$manyManyTable = false;
$classes = array_reverse(ClassInfo::ancestry($this->controllerClass()));
foreach ($classes as $class) {
if ($class != "Object") {
$singleton = singleton($class);
$manyManyRelations = $singleton->uninherited('many_many', true);
if (isset($manyManyRelations) && array_key_exists($this->name, $manyManyRelations)) {
$this->manyManyParentClass = $class;
$manyManyTable = $class . '_' . $this->name;
break;
}
$belongsManyManyRelations = $singleton->uninherited('belongs_many_many', true);
if (isset($belongsManyManyRelations) && array_key_exists($this->name, $belongsManyManyRelations)) {
$this->manyManyParentClass = $class;
$manyManyTable = $belongsManyManyRelations[$this->name] . '_' . $this->name;
break;
}
}
}
if (!$manyManyTable) {
user_error("I could not find the relation {$this}-name in " . $this->controllerClass() . " or any of its ancestors.", E_USER_WARNING);
}
$tableClasses = ClassInfo::dataClassesFor($this->sourceClass);
$source = array_shift($tableClasses);
$sourceField = $this->sourceClass;
if ($this->manyManyParentClass == $sourceField) {
$sourceField = 'Child';
}
$parentID = $this->controller->ID;
$this->sourceJoin .= " LEFT JOIN `{$manyManyTable}` ON (`{$source}`.`ID` = `{$sourceField}ID` AND `{$this->manyManyParentClass}ID` = '{$parentID}')";
$this->joinField = 'Checked';
}
开发者ID:racontemoi,项目名称:shibuichi,代码行数:39,代码来源:ManyManyDataObjectManager.php
示例10: strripos
function strripos($haystack, $needle, $offset = null)
{
// Sanity check
if (!is_scalar($haystack)) {
user_error('strripos() expects parameter 1 to be scalar, ' . gettype($haystack) . ' given', E_USER_WARNING);
return false;
}
if (!is_scalar($needle)) {
user_error('strripos() expects parameter 2 to be scalar, ' . gettype($needle) . ' given', E_USER_WARNING);
return false;
}
if (!is_int($offset) && !is_bool($offset) && !is_null($offset)) {
user_error('strripos() expects parameter 3 to be long, ' . gettype($offset) . ' given', E_USER_WARNING);
return false;
}
// Initialise variables
$needle = strtolower($needle);
$haystack = strtolower($haystack);
$needle_fc = $needle[0];
$needle_len = strlen($needle);
$haystack_len = strlen($haystack);
$offset = (int) $offset;
$leftlimit = $offset >= 0 ? $offset : 0;
$p = $offset >= 0 ? $haystack_len : $haystack_len + $offset + 1;
// Reverse iterate haystack
while (--$p >= $leftlimit) {
if ($needle_fc === $haystack[$p] && substr($haystack, $p, $needle_len) === $needle) {
return $p;
}
}
return false;
}
开发者ID:casan,项目名称:eccube-2_13,代码行数:32,代码来源:strripos.php
示例11: array_diff_assoc
function array_diff_assoc()
{
// Check we have enough arguments
$args = func_get_args();
$count = count($args);
if (count($args) < 2) {
user_error('Wrong parameter count for array_diff_assoc()', E_USER_WARNING);
return;
}
// Check arrays
for ($i = 0; $i < $count; $i++) {
if (!is_array($args[$i])) {
user_error('array_diff_assoc() Argument #' . ($i + 1) . ' is not an array', E_USER_WARNING);
return;
}
}
// Get the comparison array
$array_comp = array_shift($args);
--$count;
// Traverse values of the first array
foreach ($array_comp as $key => $value) {
// Loop through the other arrays
for ($i = 0; $i < $count; $i++) {
// Loop through this arrays key/value pairs and compare
foreach ($args[$i] as $comp_key => $comp_value) {
if ((string) $key === (string) $comp_key && (string) $value === (string) $comp_value) {
unset($array_comp[$key]);
}
}
}
}
return $array_comp;
}
开发者ID:hbustun,项目名称:agilebill,代码行数:33,代码来源:array_diff_assoc.php
示例12: ob_handler
function ob_handler($buffer)
{
$this->releaseLock();
$this->queueNext();
'' !== $buffer && user_error($buffer);
return '';
}
开发者ID:nicolas-grekas,项目名称:Patchwork,代码行数:7,代码来源:pTask.php
示例13: transform
public function transform(FormField $field)
{
// Look for a performXXTransformation() method on the field itself.
// performReadonlyTransformation() is a pretty commonly applied method.
// Otherwise, look for a transformXXXField() method on this object.
// This is more commonly done in custom transformations
// We iterate through each array simultaneously, looking at [0] of both, then [1] of both.
// This provides a more natural failover scheme.
$transNames = array_reverse(array_values(ClassInfo::ancestry($this->class)));
$fieldClasses = array_reverse(array_values(ClassInfo::ancestry($field->class)));
$len = max(sizeof($transNames), sizeof($fieldClasses));
for ($i = 0; $i < $len; $i++) {
// This is lets fieldClasses be longer than transNames
if ($transName = $transNames[$i]) {
if ($field->hasMethod('perform' . $transName)) {
$funcName = 'perform' . $transName;
//echo "<li>$field->class used $funcName";
return $field->{$funcName}($this);
}
}
// And this one does the reverse.
if ($fieldClass = $fieldClasses[$i]) {
if ($this->hasMethod('transform' . $fieldClass)) {
$funcName = 'transform' . $fieldClass;
//echo "<li>$field->class used $funcName";
return $this->{$funcName}($field);
}
}
}
user_error("FormTransformation:: Can't perform '{$this->class}' on '{$field->class}'", E_USER_ERROR);
}
开发者ID:ivoba,项目名称:silverstripe-framework,代码行数:31,代码来源:FormTransformation.php
示例14: array_walk_recursive
function array_walk_recursive(&$input, $funcname)
{
if (!is_callable($funcname)) {
if (is_array($funcname)) {
$funcname = $funcname[0] . '::' . $funcname[1];
}
user_error('array_walk_recursive() Not a valid callback ' . $user_func, E_USER_WARNING);
return;
}
if (!is_array($input)) {
user_error('array_walk_recursive() The argument should be an array', E_USER_WARNING);
return;
}
$args = func_get_args();
foreach ($input as $key => $item) {
if (is_array($item)) {
array_walk_recursive($item, $funcname, $args);
$input[$key] = $item;
} else {
$args[0] =& $item;
$args[1] =& $key;
call_user_func_array($funcname, $args);
$input[$key] = $item;
}
}
}
开发者ID:hbustun,项目名称:agilebill,代码行数:26,代码来源:array_walk_recursive.php
示例15: update_form
/**
* Add the spam protector field to a form
* @param Form the form that the protecter field added into
* @param string the name of the field that the protecter field will be added in front of
* @param array an associative array
* with the name of the spam web service's field, for example post_title, post_body, author_name
* and a string of field names
* @param String Title for the captcha field
* @param String RightTitle for the captcha field
* @return SpamProtector object on success or null if the spamprotector class is not found
* also null if spamprotectorfield creation fails.
*/
static function update_form($form, $before = null, $fieldsToSpamServiceMapping = array(), $title = null, $rightTitle = null)
{
$protectorClass = self::get_spam_protector();
// Don't update if no protector is set
if (!$protectorClass) {
return false;
}
if (!class_exists($protectorClass)) {
return user_error("Spam Protector class '{$protectorClass}' does not exist. Please define a valid Spam Protector", E_USER_WARNING);
}
try {
$protector = new $protectorClass();
$field = $protector->getFormField("Captcha", $title, null, $form, $rightTitle);
if ($field) {
// update the mapping
$field->setFieldMapping($fieldsToSpamServiceMapping);
// add the form field
if ($before && $form->Fields()->fieldByName($before)) {
$form->Fields()->insertBefore($field, $before);
} else {
$form->Fields()->push($field);
}
}
} catch (Exception $e) {
return user_error("SpamProtectorManager::update_form(): '{$protectorClass}' is not correctly set up. " . $e, E_USER_WARNING);
}
}
开发者ID:nicmart,项目名称:comperio-site,代码行数:39,代码来源:SpamProtectorManager.php
示例16: stripos
function stripos($haystack, $needle, $offset = null)
{
if (!is_scalar($haystack)) {
user_error('stripos() expects parameter 1 to be string, ' . gettype($haystack) . ' given', E_USER_WARNING);
return false;
}
if (!is_scalar($needle)) {
user_error('stripos() needle is not a string or an integer.', E_USER_WARNING);
return false;
}
if (!is_int($offset) && !is_bool($offset) && !is_null($offset)) {
user_error('stripos() expects parameter 3 to be long, ' . gettype($offset) . ' given', E_USER_WARNING);
return false;
}
// Manipulate the string if there is an offset
$fix = 0;
if (!is_null($offset)) {
if ($offset > 0) {
$haystack = substr($haystack, $offset, strlen($haystack) - $offset);
$fix = $offset;
}
}
$segments = explode(strtolower($needle), strtolower($haystack), 2);
// Check there was a match
if (count($segments) === 1) {
return false;
}
$position = strlen($segments[0]) + $fix;
return $position;
}
开发者ID:rbraband,项目名称:iSefrengo-Dev,代码行数:30,代码来源:stripos.php
示例17: query
function query($query)
{
if (!$query) {
return false;
}
if (b1n_DEBUG_MODE) {
echo "<pre class='debug'>{$query}</pre>";
}
if (!$this->isConnected()) {
user_error("PostgreSQLL NOT CONNECTED");
return false;
}
$result = pg_query($this->db_link, $query);
if (is_bool($result)) {
return $result;
}
$num = pg_num_rows($result);
if ($num > 0) {
for ($i = 0; $i < $num; $i++) {
$row[] = pg_fetch_array($result, $i, PGSQL_ASSOC);
}
return $row;
}
return true;
}
开发者ID:mmr,项目名称:b1n,代码行数:25,代码来源:sqllink.lib.php
示例18: _setSource
/**
* {@internal we use this to set the data array in Factory()}}
*
* @see Factory()
* @param array $newsource
*/
function _setSource(&$newsource)
{
if (!is_array($newsource)) {
user_error('$source is not an array', E_USER_NOTICE);
}
$this->_source = $newsource;
}
开发者ID:ekhtsasy,项目名称:inspekt,代码行数:13,代码来源:Cage.php
示例19: php_compat_bcpowmod
/**
* Replace bcpowmod()
*
* @category PHP
* @package PHP_Compat
* @license LGPL - http://www.gnu.org/licenses/lgpl.html
* @copyright 2004-2007 Aidan Lister <[email protected]>, Arpad Ray <[email protected]>
* @link http://php.net/function.bcpowmod
* @author Sara Golemon <[email protected]>
* @version $Revision: 1.1 $
* @since PHP 5.0.0
* @require PHP 4.0.0 (user_error)
*/
function php_compat_bcpowmod($x, $y, $modulus, $scale = 0)
{
// Sanity check
if (!is_scalar($x)) {
user_error('bcpowmod() expects parameter 1 to be string, ' . gettype($x) . ' given', E_USER_WARNING);
return false;
}
if (!is_scalar($y)) {
user_error('bcpowmod() expects parameter 2 to be string, ' . gettype($y) . ' given', E_USER_WARNING);
return false;
}
if (!is_scalar($modulus)) {
user_error('bcpowmod() expects parameter 3 to be string, ' . gettype($modulus) . ' given', E_USER_WARNING);
return false;
}
if (!is_scalar($scale)) {
user_error('bcpowmod() expects parameter 4 to be integer, ' . gettype($scale) . ' given', E_USER_WARNING);
return false;
}
$t = '1';
while (bccomp($y, '0')) {
if (bccomp(bcmod($y, '2'), '0')) {
$t = bcmod(bcmul($t, $x), $modulus);
$y = bcsub($y, '1');
}
$x = bcmod(bcmul($x, $x), $modulus);
$y = bcdiv($y, '2');
}
return $t;
}
开发者ID:akshayxhtmljunkies,项目名称:brownglock,代码行数:43,代码来源:bcpowmod.php
示例20: array_intersect_key
function array_intersect_key()
{
$args = func_get_args();
if (count($args) < 2) {
user_error('Wrong parameter count for array_intersect_key()', E_USER_WARNING);
return;
}
// Check arrays
$array_count = count($args);
for ($i = 0; $i !== $array_count; $i++) {
if (!is_array($args[$i])) {
user_error('array_intersect_key() Argument #' . ($i + 1) . ' is not an array', E_USER_WARNING);
return;
}
}
// Compare entries
$result = array();
foreach ($args[0] as $key1 => $value1) {
for ($i = 1; $i !== $array_count; $i++) {
foreach ($args[$i] as $key2 => $value2) {
if ((string) $key1 === (string) $key2) {
$result[$key1] = $value1;
}
}
}
}
return $result;
}
开发者ID:hbustun,项目名称:agilebill,代码行数:28,代码来源:array_intersect_key.php
注:本文中的user_error函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论