当前位置: 首页>>代码示例>>PHP>>正文


PHP ctype_xdigit函数代码示例

本文整理汇总了PHP中ctype_xdigit函数的典型用法代码示例。如果您正苦于以下问题:PHP ctype_xdigit函数的具体用法?PHP ctype_xdigit怎么用?PHP ctype_xdigit使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了ctype_xdigit函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: pickImageDir

 function pickImageDir($directory, $levels)
 {
     if ($levels) {
         $dirs = array();
         // Check which subdirs are actually present...
         $dir = opendir($directory);
         while (false !== ($entry = readdir($dir))) {
             if (ctype_xdigit($entry) && strlen($entry) == 1) {
                 $dirs[] = $entry;
             }
         }
         closedir($dir);
         $place = mt_rand(0, count($dirs) - 1);
         // In case all dirs are not filled,
         // cycle through next digits...
         for ($j = 0; $j < count($dirs); $j++) {
             $char = $dirs[($place + $j) % count($dirs)];
             $return = $this->pickImageDir("{$directory}/{$char}", $levels - 1);
             if ($return) {
                 return $return;
             }
         }
         // Didn't find any images in this directory... empty?
         #echo "found not image";
         return false;
     } else {
         return $this->pickImageFromDir($directory);
     }
 }
开发者ID:ErdemA,项目名称:wikihow,代码行数:29,代码来源:FancyCaptcha.class.php

示例2: extendedCode

 public function extendedCode($command, $value)
 {
     if (!ctype_xdigit($command) || !ctype_xdigit($value)) {
         throw new \Exception("Command and value in custom extended code must both be hex codes.");
     }
     return $this->rawCommand(__METHOD__, func_get_args(), "{$command} {$value}");
 }
开发者ID:marioveyna,项目名称:x10php,代码行数:7,代码来源:X10DevicePower.php

示例3: check

 public function check($args)
 {
     if (ctype_xdigit($args)) {
         return true;
     }
     return false;
 }
开发者ID:cantescape,项目名称:validation,代码行数:7,代码来源:Hex.php

示例4: clm_function_is_color

function clm_function_is_color($colorCode)
{
    if (!ctype_xdigit($colorCode) || strlen($colorCode) != 6 && strlen($colorCode) != 3) {
        return false;
    }
    return true;
}
开发者ID:kbaerthel,项目名称:com_clm,代码行数:7,代码来源:is_color.php

示例5: validatePasswordLogin

/**
 * Function validatePasswordLogin
 *
 * compare user password-hash with given user-password
 * and check if they are the same
 * additionally it updates the hash if the system settings changed
 * or if the very old md5() sum is used
 *
 * @param array $userinfo user-data from table
 * @param string $password the password to validate
 * @param string $table either panel_customers or panel_admins
 * @param string $uid user-id-field in $table
 *
 * @return boolean
 */
function validatePasswordLogin($userinfo = null, $password = null, $table = 'panel_customers', $uid = 'customerid')
{
    $systype = 3;
    // SHA256
    if (Settings::Get('system.passwordcryptfunc') !== null) {
        $systype = (int) Settings::Get('system.passwordcryptfunc');
    }
    $pwd_hash = $userinfo['password'];
    $update_hash = false;
    // check for good'ole md5
    if (strlen($pwd_hash) == 32 && ctype_xdigit($pwd_hash)) {
        $pwd_check = md5($password);
        $update_hash = true;
    } else {
        // cut out the salt from the hash
        $pwd_salt = str_replace(substr(strrchr($pwd_hash, "\$"), 1), "", $pwd_hash);
        // create same hash to compare
        $pwd_check = crypt($password, $pwd_salt);
        // check whether the hash needs to be updated
        $hash_type_chk = substr($pwd_hash, 0, 3);
        if ($systype == 1 && $hash_type_chk != '$1$' || $systype == 2 && $hash_type_chk != '$2$' || $systype == 3 && $hash_type_chk != '$5$' || $systype == 4 && $hash_type_chk != '$6$') {
            $update_hash = true;
        }
    }
    if ($pwd_hash == $pwd_check) {
        // check for update of hash
        if ($update_hash) {
            $upd_stmt = Database::prepare("\n\t\t\t\tUPDATE " . $table . " SET `password` = :newpasswd WHERE `" . $uid . "` = :uid\n\t\t\t");
            $params = array('newpasswd' => makeCryptPassword($password), 'uid' => $userinfo[$uid]);
            Database::pexecute($upd_stmt, $params);
        }
        return true;
    }
    return false;
}
开发者ID:mowamed,项目名称:Froxlor,代码行数:50,代码来源:function.validatePasswordLogin.php

示例6: show

 public function show()
 {
     //move new email to mongo
     if (is_numeric($this->messageId)) {
         $query = array('_id' => new MongoId(substr(hash('sha1', $this->messageId), 0, 24)), 'modKey' => hash('sha512', $this->modKey));
         if ($ref = Yii::app()->mongo->findOne('personalFolders', $query, array('_id' => 1, 'meta' => 1, 'body' => 1))) {
             $result['results']['messageHash'] = $this->messageId;
             $result['results']['meta'] = base64_encode(substr($ref['meta']->bin, 0, 16)) . ';' . base64_encode(substr($ref['meta']->bin, 16));
             $result['results']['body'] = base64_encode(substr($ref['body']->bin, 0, 16)) . ';' . base64_encode(substr($ref['body']->bin, 16));
             echo json_encode($result);
         } else {
             echo '{"results":"empty"}';
         }
     } else {
         if (ctype_xdigit($this->messageId) && strlen($this->messageId) == 24) {
             $query = array('_id' => new MongoId($this->messageId), 'modKey' => hash('sha512', $this->modKey));
             if ($ref = Yii::app()->mongo->findOne('personalFolders', $query, array('_id' => 1, 'meta' => 1, 'body' => 1))) {
                 $result['results']['messageHash'] = $this->messageId;
                 $result['results']['meta'] = base64_encode(substr($ref['meta']->bin, 0, 16)) . ';' . base64_encode(substr($ref['meta']->bin, 16));
                 $result['results']['body'] = base64_encode(substr($ref['body']->bin, 0, 16)) . ';' . base64_encode(substr($ref['body']->bin, 16));
                 echo json_encode($result);
             } else {
                 echo '{"results":"empty"}';
             }
         } else {
             echo '{"results":"empty"}';
         }
     }
 }
开发者ID:blackdragon199154,项目名称:scryptmail,代码行数:29,代码来源:ShowMessage.php

示例7: retrieve

 public function retrieve($id)
 {
     if (!ctype_xdigit($id)) {
         throw new Exception\ClientException('Job ID is invalid');
     }
     return $this->get("jobs/{$id}");
 }
开发者ID:wondernetwork,项目名称:wiuphp,代码行数:7,代码来源:API.php

示例8: testSaltedFieldnameIsHashed

 function testSaltedFieldnameIsHashed()
 {
     $input = new T_Form_Upload('myalias', 'mylabel');
     $input->setFieldnameSalt('mysalt', new T_Filter_RepeatableHash());
     $this->assertNotEquals('myalias', $input->getFieldname());
     $this->assertTrue(ctype_xdigit($input->getFieldname()));
 }
开发者ID:robtuley,项目名称:knotwerk,代码行数:7,代码来源:Upload.php

示例9: doTransform

 /**
  * Checks that the data is a valid hexadecimal hash (32 characters long).
  *
  * @param string $value  data to filter
  * @return string  hex hash
  * @throws T_Exception_Filter  if the input is not a valid hex hash
  */
 protected function doTransform($value)
 {
     if (!ctype_xdigit($value) || strlen($value) !== 32) {
         throw new T_Exception_Filter("Invalid hexadecimal 32-char hash {$value}");
     }
     return $value;
 }
开发者ID:robtuley,项目名称:knotwerk,代码行数:14,代码来源:HexHash.php

示例10: get_visibility_value

 public function get_visibility_value()
 {
     $return = (object) ["templates" => get_page_templates()];
     if (isset($_REQUEST["layout_id"]) && ctype_xdigit($_REQUEST["layout_id"]) && isset($_REQUEST["id"]) && is_numeric($_REQUEST["id"])) {
         $field_id = $_REQUEST["layout_id"];
         $post_id = $_REQUEST["id"];
     } else {
         wp_send_json_success($return);
     }
     $post = get_post($post_id);
     $post_obj = unserialize($post->post_content);
     $found = false;
     foreach ($post_obj["layouts"] as $obj) {
         if ($obj["key"] == $field_id) {
             $found = true;
             break;
         }
     }
     if (!$found) {
         wp_send_json_success($return);
     }
     if (is_array($obj) && isset($obj["visibility"])) {
         if (!empty($obj["visibility"])) {
             $return->visibility = explode(",", $obj["visibility"]);
             wp_send_json_success($return);
         } else {
             wp_send_json_success($return);
         }
     } else {
         wp_send_json_success($return);
     }
 }
开发者ID:devgeniem,项目名称:acf-flexible-visibility,代码行数:32,代码来源:plugin.php

示例11: filter

 /**
  * Filter Stream Through Buckets
  *
  * @param resource $in userfilter.bucket brigade
  *                         pointer to a group of buckets objects containing the data to be filtered
  * @param resource $out userfilter.bucket brigade
  *                         pointer to another group of buckets for storing the converted data
  * @param int $consumed counter passed by reference that must be incremented by the length
  *                         of converted data
  * @param boolean $closing flag that is set to TRUE if we are in the last cycle and the stream is
  *                           about to close
  * @return int
  */
 function filter($in, $out, &$consumed, $closing)
 {
     // $in and $out are opaque "bucket brigade" objects which consist of a
     // sequence of opaque "buckets", which contain the actual stream data.
     // The only way to use these objects is the stream_bucket_* functions.
     // Unfortunately, there doesn't seem to be any way to access a bucket
     // without turning it into a string using stream_bucket_make_writeable(),
     // even if you want to pass the bucket along unmodified.
     // Each call to this pops a bucket from the bucket brigade and
     // converts it into an object with two properties: datalen and data.
     // This same object interface is accepted by stream_bucket_append().
     while ($bucket = stream_bucket_make_writeable($in)) {
         $outbuffer = '';
         $offset = 0;
         // Loop through the string.  For efficiency, we don't advance a character
         // at a time but try to zoom ahead to where we think the next chunk
         // boundary should be.
         // Since the stream filter divides the data into buckets arbitrarily,
         // we have to maintain state ($this->chunkremaining) across filter() calls.
         while ($offset < $bucket->datalen) {
             if ($this->chunkremaining === 0) {
                 // start of new chunk, or the start of the transfer
                 $firstline = strpos($bucket->data, "\r\n", $offset);
                 $chunkline = substr($bucket->data, $offset, $firstline - $offset);
                 $chunklen = current(explode(';', $chunkline, 2));
                 // ignore MIME-like extensions
                 $chunklen = trim($chunklen);
                 if (!ctype_xdigit($chunklen)) {
                     // There should have been a chunk length specifier here, but since
                     // there are non-hex digits something must have gone wrong.
                     return PSFS_ERR_FATAL;
                 }
                 $this->chunkremaining = hexdec($chunklen);
                 // $firstline already includes $offset in it
                 $offset = $firstline + 2;
                 // +2 is CRLF
                 if ($this->chunkremaining === 0) {
                     //end of the transfer
                     break;
                 }
                 // ignore possible trailing headers
             }
             // get as much data as available in a single go...
             $nibble = substr($bucket->data, $offset, $this->chunkremaining);
             $nibblesize = strlen($nibble);
             $offset += $nibblesize;
             // ...but recognize we may not have got all of it
             if ($nibblesize === $this->chunkremaining) {
                 $offset += 2;
             }
             // skip over trailing CRLF
             $this->chunkremaining -= $nibblesize;
             $outbuffer .= $nibble;
         }
         $consumed += $bucket->datalen;
         $bucket->data = $outbuffer;
         stream_bucket_append($out, $bucket);
     }
     return PSFS_PASS_ON;
 }
开发者ID:phPoirot,项目名称:Connection,代码行数:73,代码来源:DechunkFilter.php

示例12: test

	/**
	 * Method to test for a valid color in hexadecimal.
	 *
	 * @param   SimpleXMLElement  $element  The SimpleXMLElement object representing the <field /> tag for the form field object.
	 * @param   mixed             $value    The form field value to validate.
	 * @param   string            $group    The field name group control value. This acts as as an array container for the field.
	 *                                      For example if the field has name="foo" and the group value is set to "bar" then the
	 *                                      full field name would end up being "bar[foo]".
	 * @param   JRegistry         $input    An optional JRegistry object with the entire data set to validate against the entire form.
	 * @param   JForm             $form     The form object for which the field is being tested.
	 *
	 * @return  boolean  True if the value is valid, false otherwise.
	 *
	 * @since   11.2
	 */
	public function test(SimpleXMLElement $element, $value, $group = null, JRegistry $input = null, JForm $form = null)
	{
		$value = trim($value);

		if (empty($value))
		{
			// A color field can't be empty, we default to black. This is the same as the HTML5 spec.
			$value = '#000000';

			return true;
		}

		if ($value[0] != '#')
		{
			return false;
		}

		// Remove the leading # if present to validate the numeric part
		$value = ltrim($value, '#');

		// The value must be 6 or 3 characters long
		if (!((strlen($value) == 6 || strlen($value) == 3) && ctype_xdigit($value)))
		{
			return false;
		}

		// Prepend the # again
		$value = '#' . $value;

		return true;
	}
开发者ID:realityking,项目名称:joomla-platform,代码行数:46,代码来源:color.php

示例13: getHUID

/** 
 * Generate a Host Unique Identifier
 * 
 * @param string $primaryNS    The primary namespace, 4 hexadecimal characters
 * @param string $secondaryNS  The secondary namespace, 3 hexadecimal characters
 * @param string $format       The desired output format, one of 'str', 'hex', 'bin', or 'obj'. Default 'str'
 *                              - str: Return a 36 character string in the format AAAAAAAAAAAAAA-BBBBB-CCCC-DDDD-EEEEE
 *                              - hex: Return a 32 digit hexadecimal value in the format AAAAAAAAAAAAAABBBBBCCCCDDDDEEEEE
 *                              - bin: Return a 16 byte binary string
 *                              - obj: Return an object containing all 3 formats
 * 
 * @return mixed  Returns a string in the requested format, or false if parameters are incorrect
 * @example /reference/php/example.php
 */
function getHUID($primaryNS, $secondaryNS, $format = 'str')
{
    if (strlen($primaryNS) === 4 && strlen($secondaryNS) === 4 && ctype_xdigit($primaryNS . $secondaryNS)) {
        if (in_array($format, ['hex', 'bin'])) {
            $delimiter = '';
        } else {
            $delimiter = '-';
        }
        $huid = strtolower(str_pad(dechex(time()), 14, '0', STR_PAD_LEFT) . $delimiter . str_pad(dechex(substr(microtime(), 2, 5)), 5, '0', STR_PAD_LEFT) . $delimiter . $primaryNS . $delimiter . $secondaryNS . $delimiter . str_pad(dechex(mt_rand(0, 0xfffff)), 5, '0', STR_PAD_LEFT));
        switch ($format) {
            case 'bin':
                return hex2bin($huid);
                break;
            case 'obj':
                $huids = new stdClass();
                $huids->str = $huid;
                $huids->hex = str_replace('-', '', $huid);
                $huids->bin = hex2bin($huids->hex);
                return $huids;
                break;
            default:
                return $huid;
                break;
        }
    }
    return false;
}
开发者ID:KeMBro2012,项目名称:HUID,代码行数:41,代码来源:huid.php

示例14: decrypt

 public static function decrypt($string, $key = null, $salt = null, $iv = null)
 {
     $config = ConfigManager::getConfig('Crypto', 'AES256')->AuxConfig;
     if ($key === null) {
         $key = $config->key;
     }
     if ($salt === null) {
         $salt = $config->salt;
     }
     if ($iv === null) {
         $iv = $config->iv;
     }
     $td = mcrypt_module_open('rijndael-128', '', MCRYPT_MODE_CBC, '');
     $ks = mcrypt_enc_get_key_size($td);
     $bs = mcrypt_enc_get_block_size($td);
     $iv = substr(hash("sha256", $iv), 0, $bs);
     // Create key
     $key = Crypto::pbkdf2("sha512", $key, $salt, $config->pbkdfRounds, $ks);
     // Initialize encryption module for decryption
     mcrypt_generic_init($td, $key, $iv);
     $decryptedString = "";
     // Decrypt encrypted string
     try {
         if (ctype_xdigit($string)) {
             $decryptedString = trim(mdecrypt_generic($td, pack("H*", $string)));
         }
     } catch (ErrorException $e) {
     }
     // Terminate decryption handle and close module
     mcrypt_generic_deinit($td);
     mcrypt_module_close($td);
     // Show string
     return $decryptedString;
 }
开发者ID:Welvin,项目名称:stingle,代码行数:34,代码来源:AES256.class.php

示例15: delete

 public function delete()
 {
     if (count($this->messageIds) > 0) {
         foreach ($this->messageIds as $i => $row) {
             if (is_numeric($row['id'])) {
                 $mngData[] = array('_id' => new MongoId(substr(hash('sha1', $row['id']), 0, 24)), 'modKey' => isset($row['modKey']) ? hash('sha512', $row['modKey']) : '');
             } else {
                 if (ctype_xdigit($row['id'])) {
                     $mngData[] = array('_id' => new MongoId($row['id']), 'modKey' => isset($row['modKey']) ? hash('sha512', $row['modKey']) : '');
                 }
             }
         }
         $mngDataAgregate = array('$or' => $mngData);
         if ($ref = Yii::app()->mongo->findAll('personalFolders', $mngDataAgregate, array('_id' => 1, 'file' => 1))) {
             foreach ($ref as $doc) {
                 if ($files = json_decode($doc['file'], true)) {
                     foreach ($files as $names) {
                         FileWorks::deleteFile($names);
                     }
                 }
             }
         }
         if (Yii::app()->mongo->removeAll('personalFolders', $mngDataAgregate)) {
             echo '{"results":"success"}';
         } else {
             echo '{"results":"fail"}';
         }
     }
 }
开发者ID:blackdragon199154,项目名称:scryptmail,代码行数:29,代码来源:DeleteMessage.php


注:本文中的ctype_xdigit函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。