本文整理汇总了PHP中ctype_print函数的典型用法代码示例。如果您正苦于以下问题:PHP ctype_print函数的具体用法?PHP ctype_print怎么用?PHP ctype_print使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了ctype_print函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: json
/**
* JSON encode a PHP value.
*
* @param {void*} $value Any arbitrary PHP value.
* @return {string} JSON representation of specified PHP value.
*/
public static function json($value)
{
// note: binary strings will fuck up the encoding process, remove them.
$maskBinary = function (&$value) use(&$maskBinary) {
if ($value instanceof \JsonSerializable) {
$value = $value->jsonSerialize();
}
if (is_object($value)) {
foreach (get_object_vars($value) as $key => $_value) {
$maskBinary($value->{$key});
}
unset($_value);
} else {
if (is_array($value)) {
array_walk($value, $maskBinary);
} else {
if (is_string($value) && $value && !ctype_print($value) && json_encode($value) === false) {
$value = '[binary string]';
}
}
}
};
$maskBinary($value);
return json_encode($value);
}
示例2: __construct
/**
* Constructor
*
* @param array $config Configuration settings:
* 'realm' => <string>
* 'identity' => <string> The identity to match
* 'credential' => <string> The credential to match
* @throws Zend_Auth_Adapter_Exception
* @return void
*/
public function __construct(array $config)
{
if (empty($config['identity'])) {
throw new Zend_Auth_Adapter_Exception('Config key identity is required');
} else {
$this->_identity = $config['identity'];
}
if (empty($config['credential'])) {
throw new Zend_Auth_Adapter_Exception('Config key credential is required');
} else {
$this->_credential = $config['credential'];
}
// Taken from Zend_Auth_Adapter_Http
// Double-quotes are used to delimit the realm string in the HTTP header,
// and colons are field delimiters in the password file.
if (empty($config['realm']) || !ctype_print($config['realm']) || strpos($config['realm'], ':') !== false || strpos($config['realm'], '"') !== false) {
/**
* @see Zend_Auth_Adapter_Exception
*/
require_once 'Zend/Auth/Adapter/Exception.php';
throw new Zend_Auth_Adapter_Exception('Config key \'realm\' is required, and must contain only printable ' . 'characters, excluding quotation marks and colons');
} else {
$this->_realm = $config['realm'];
}
}
示例3: setLabel
/**
* @param string $label
*
* @return AccessTokenInterface
*/
public function setLabel($label)
{
if (!empty($label) && is_string($label) && ctype_print($label)) {
$this->label = trim($label);
}
return $this;
}
示例4: authenticate
/**
* Performs an authentication attempt
*
* @return \Zend\Authentication\Result
* @throws \Zend\Authentication\Adapter\Exception\ExceptionInterface If authentication cannot be performed
*/
public function authenticate()
{
$getHeader = $this->options['proxy_auth'] ? 'Proxy-Authorization' : 'Authorization';
if (!($authHeader = $this->request->headers->get($getHeader))) {
return $this->challengeClient();
}
// Decode the Authorization header
$authorizationHeader = base64_decode(substr($authHeader, strlen('Basic ')));
if (!$authorizationHeader) {
throw new RuntimeException('Unable to base64_decode Authorization header value');
}
// See ZF-1253. Validate the credentials the same way the digest
// implementation does. If invalid credentials are detected,
// re-challenge the client.
if (!ctype_print($authorizationHeader)) {
return $this->challengeClient();
}
// Fix for ZF-1515: Now re-challenges on empty username or password
$credentials = array_filter(explode(':', $authorizationHeader));
if (count($credentials) !== 2) {
return $this->challengeClient();
}
$result = $this->resolver->resolve($credentials[0], $this->options['realm'], $credentials[1]);
if ($result instanceof Result && $result->isValid()) {
return $result;
}
if (!$result instanceof Result && !is_array($result) && Utils::compareStrings($result, $credentials[1])) {
$identity = ['username' => $credentials[0], 'realm' => $this->options['realm']];
return new Result(Result::SUCCESS, $identity);
} elseif (is_array($result)) {
return new Result(Result::SUCCESS, $result);
}
return $this->challengeClient();
}
示例5: fromSong
/**
* Generate the downloadable path for a song.
*
* @param Song $song
*
* @return string
*/
protected function fromSong(Song $song)
{
if ($s3Params = $song->s3_params) {
// The song is hosted on Amazon S3.
// We download it back to our local server first.
$localPath = rtrim(sys_get_temp_dir(), '/') . '/' . basename($s3Params['key']);
$url = $song->getObjectStoragePublicUrl();
abort_unless($url, 404);
// The following function require allow_url_fopen to be ON.
// We're just assuming that to be the case here.
copy($url, $localPath);
} else {
// The song is hosted locally. Make sure the file exists.
abort_unless(file_exists($song->path), 404);
$localPath = $song->path;
}
// The BinaryFileResponse factory only accept ASCII-only file names.
if (ctype_print($localPath)) {
return $localPath;
}
// For those with high-byte characters in names, we copy it into a safe name
// as a workaround.
$newPath = rtrim(sys_get_temp_dir(), '/') . '/' . utf8_decode(basename($song->path));
if ($s3Params) {
// If the file is downloaded from S3, we rename it directly.
// This will save us some disk space.
rename($localPath, $newPath);
} else {
// Else we copy it to another file to not mess up the original one.
copy($localPath, $newPath);
}
return $newPath;
}
示例6: insertAll
public function insertAll($rows)
{
$generic = Factory::getGeneric();
$rowsSql = array();
foreach ($rows as $row) {
$values = array();
foreach ($row as $name => $value) {
if (is_null($value)) {
$values[] = 'NULL';
} else {
if (is_numeric($value)) {
$values[] = $value;
} else {
if (!ctype_print($value)) {
$values[] = $generic->bin2dbRawInsert($value);
} else {
if (is_bool($value)) {
$values[] = $value ? '1' : '0';
} else {
$values[] = "'{$value}'";
}
}
}
}
}
$rowsSql[] = "(" . implode(',', $values) . ")";
}
$sql = 'INSERT INTO ' . $this->table . ' VALUES ' . implode(',', $rowsSql);
$this->db->query($sql);
}
示例7: read
/**
* {@inheritdoc}
*/
public function read($filename)
{
$meta = new ValueBag();
try {
$fileEntity = $this->reader->reset()->files($filename)->first();
} catch (\Exception $e) {
return $meta;
}
if ($fileEntity->getMetadatas()->containsKey('File:ImageWidth')) {
$meta->set('image.width', new MetaValue((int) $fileEntity->getMetadatas()->get('File:ImageWidth')->getValue()->asString()));
} elseif ($fileEntity->getMetadatas()->containsKey('PNG:ImageWidth')) {
$meta->set('image.width', new MetaValue((int) $fileEntity->getMetadatas()->get('PNG:ImageWidth')->getValue()->asString()));
}
if ($fileEntity->getMetadatas()->containsKey('File:ImageHeight')) {
$meta->set('image.height', new MetaValue((int) $fileEntity->getMetadatas()->get('File:ImageHeight')->getValue()->asString()));
} elseif ($fileEntity->getMetadatas()->containsKey('PNG:ImageHeight')) {
$meta->set('image.height', new MetaValue((int) $fileEntity->getMetadatas()->get('PNG:ImageHeight')->getValue()->asString()));
}
foreach ($fileEntity->getMetadatas() as $metadata) {
/* @var $metadata Metadata */
if (ValueInterface::TYPE_BINARY === $metadata->getValue()->getType()) {
continue;
}
$groupName = $metadata->getTag()->getGroupName();
$name = $metadata->getTag()->getName();
$value = (string) $metadata->getValue();
if ($groupName === 'System' || !ctype_print($value)) {
continue;
}
$path = "{$groupName}.{$name}";
$meta->set($path, new MetaValue($value));
}
return $meta;
}
示例8: isValid
public function isValid($value)
{
if (ctype_print($value)) {
return true;
}
$this->setError("invalid");
return false;
}
示例9: create
/**
* Static function to create a new Imagecow instance from an image file or string
*
* @param string $image The name of the image file or binary string
* @param string $library The name of the image library to use (Gd or Imagick). If it's not defined, detects automatically the library to use.
*
* @return Image The Imagecow instance
*/
public static function create($image, $library = null)
{
//check if it's a binary string
if (!ctype_print($image)) {
return static::createFromString($image, $library);
}
return static::createFromFile($image, $library);
}
示例10: getAcceptLanguage
/**
* Retrieve accept language
*
* @return string
*/
protected function getAcceptLanguage()
{
$acceptLanguage = empty($_SERVER['HTTP_ACCEPT_LANGUAGE']) ? null : $_SERVER['HTTP_ACCEPT_LANGUAGE'];
if (!ctype_print($acceptLanguage)) {
$acceptLanguage = null;
}
return $acceptLanguage;
}
示例11: testGenerateToken
public function testGenerateToken()
{
$token = $this->generator->generateToken();
$this->assertTrue(ctype_print($token), 'is printable');
$this->assertStringNotMatchesFormat('%S+%S', $token, 'is URI safe');
$this->assertStringNotMatchesFormat('%S/%S', $token, 'is URI safe');
$this->assertStringNotMatchesFormat('%S=%S', $token, 'is URI safe');
}
示例12: extract
/**
* Helper function to transform the ip and format it correctly for extraction.
* If inputted with a string, it will leave it the same.
* If inputted with a binary string, it will output an unpacked human readable string.
*
* @return $ip string
*/
public function extract($ip)
{
//human readable string
if (ctype_print($ip)) {
return $ip;
}
return inet_ntop($ip);
}
示例13: find
/**
* Modified find static function to accept both string and binary versions of uuid
* @param mixed $id The id (binary or hex string)
* @param array $columns The columns to be returned (defaults to *)
* @return mixed The model or null
*/
public static function find($id, $columns = array('*'))
{
if (ctype_print($id)) {
return static::where('id', '=', hex2bin($id))->first($columns);
} else {
return parent::where('id', '=', $id)->first($columns);
}
}
示例14: findOrFail
/**
* Modified findOrFail static function to accept both string and binary versions of uuid
* @param mixed $id The id (binary or hex string)
* @param array $columns The columns to be returned (defaults to *)
* @return mixed The model or null
*/
public static function findOrFail($id, $columns = array('*'))
{
if (ctype_print($id)) {
$idFinal = property_exists(static::class, 'uuidOptimization') && static::$uuidOptimization ? self::toOptimized($id) : hex2bin($id);
return static::where('id', '=', $idFinal)->firstOrFail($columns);
} else {
return parent::where('id', '=', $id)->firstOrFail($columns);
}
}
示例15: __construct
/**
* @param string $type type of MFA, used in audit logs
* @param string $message user-friendly message used in player kick message
* @param string $data printable, single-line string used in audit logs as data for this
*
* @throws \InvalidArgumentException if $data is not printable or single-line
*/
public function __construct($type, $message, $data = "")
{
if (!ctype_print($data)) {
throw new \InvalidArgumentException("\$data is not printable");
}
$this->type = $type;
$this->message = $message;
$this->data = $data;
}