function denetle($verilen, $tarif) { foreach ($tarif as $ne => $bilgi) { $kosul = array_shift($bilgi); switch ($ne) { case 'dolu': $hata = $kosul && empty($verilen); break; case 'esit': $hata = $kosul != strlen($verilen); break; case 'enfazla': $hata = strlen($verilen) > $kosul; break; case 'enaz': $hata = strlen($verilen) < $kosul; break; case 'degeri': $hata = $kosul != $verilen; break; case 'tamsayi': $hata = $kosul && !ctype_digit($verilen); break; case 'ozel': $hata = $kosul && $kosul($verilen); break; } if ($hata) { return array_shift($bilgi); } } }
function StdDecodePeerId($id_data, $id_name) { $version_str = ''; for ($i = 0; $i <= strlen($id_data); $i++) { $c = $id_data[$i]; if ($id_name == 'BitTornado' || $id_name == 'ABC') { if ($c != '-' && ctype_digit($c)) { $version_str .= $c . '.'; } elseif ($c != '-' && ctype_alpha($c)) { $version_str .= ord($c) - 55 . '.'; } else { break; } } elseif ($id_name == 'BitComet' || $id_name == 'BitBuddy' || $id_name == 'Lphant' || $id_name == 'BitPump' || $id_name == 'BitTorrent Plus! v2') { if ($c != '-' && ctype_alnum($c)) { $version_str .= $c; if ($i == 0) { $version_str = (int) $version_str . '.'; } } else { $version_str .= '.'; break; } } else { if ($c != '-' && ctype_alnum($c)) { $version_str .= $c . '.'; } else { break; } } } $version_str = substr($version_str, 0, strlen($version_str) - 1); return $id_name . ' ' . $version_str; }
/** * Does this role have the given permission name, id or object? * * @param string|int|Permission * @return bool * */ public function hasPermission($name) { $has = false; if (empty($name)) { // do nothing } else { if ($name instanceof Page) { $has = $this->permissions->has($name); } else { if (ctype_digit("{$name}")) { $name = (int) $name; foreach ($this->permissions as $permission) { if ((int) $permission->id === $name) { $has = true; break; } } } else { if (is_string($name)) { foreach ($this->permissions as $permission) { if ($permission->name === $name) { $has = true; break; } } } } } } return $has; }
/** * Creates a feed from the given parameters. * * @param array feed information * @param array items to add to the feed * @param string define which format to use (only rss2 is supported) * @param string define which encoding to use * @return string */ public static function create($info, $items, $format = 'rss2', $encoding = 'UTF-8') { $info += array('title' => 'Generated Feed', 'link' => '', 'generator' => 'KohanaPHP'); $feed = '<?xml version="1.0" encoding="' . $encoding . '"?><rss version="2.0"><channel></channel></rss>'; $feed = simplexml_load_string($feed); foreach ($info as $name => $value) { if (($name === 'pubDate' or $name === 'lastBuildDate') and (is_int($value) or ctype_digit($value))) { // Convert timestamps to RFC 822 formatted dates $value = date(DATE_RFC822, $value); } elseif (($name === 'link' or $name === 'docs') and strpos($value, '://') === FALSE) { // Convert URIs to URLs $value = url::site($value, 'http'); } // Add the info to the channel $feed->channel->addChild($name, $value); } foreach ($items as $item) { // Add the item to the channel $row = $feed->channel->addChild('item'); foreach ($item as $name => $value) { if ($name === 'pubDate' and (is_int($value) or ctype_digit($value))) { // Convert timestamps to RFC 822 formatted dates $value = date(DATE_RFC822, $value); } elseif (($name === 'link' or $name === 'guid') and strpos($value, '://') === FALSE) { // Convert URIs to URLs $value = url::site($value, 'http'); } // Add the info to the row $row->addChild($name, $value); } } return $feed->asXML(); }
/** * Gets a value from an array using a dot separated path. * * // Get the value of $array['foo']['bar'] * $value = Arr::path($array, 'foo.bar'); * * @param array array to search * @param string key path, dot separated * @param mixed default value if the path is not set * @return mixed */ public static function path($array, $path, $default = NULL) { // Split the keys by slashes $keys = explode('.', $path); do { $key = array_shift($keys); if (ctype_digit($key)) { // Make the key an integer $key = (int) $key; } if (isset($array[$key])) { if ($keys) { if (is_array($array[$key])) { // Dig down into the next part of the path $array = $array[$key]; } else { // Unable to dig deeper break; } } else { // Found the path requested return $array[$key]; } } else { // Unable to dig deeper break; } } while ($keys); // Unable to find the value requested return $default; }
/** * {@inheritDoc} */ public function getConfigTreeBuilder() { $treeBuilder = new TreeBuilder(); $rootNode = $treeBuilder->root('hearsay_require_js'); $rootNode->children()->scalarNode('require_js_src')->cannotBeEmpty()->defaultValue('//cdnjs.cloudflare.com/ajax/libs/require.js/2.1.8/require.min.js')->end()->scalarNode('initialize_template')->cannotBeEmpty()->defaultValue('HearsayRequireJSBundle::initialize.html.twig')->end()->scalarNode('base_url')->defaultValue('js')->end()->scalarNode('base_dir')->isRequired()->cannotBeEmpty()->end()->arrayNode('paths')->defaultValue(array())->useAttributeAsKey('path')->normalizeKeys(false)->prototype('array')->beforeNormalization()->ifString()->then(function ($v) { return array('location' => $v); })->end()->children()->variableNode('location')->isRequired()->cannotBeEmpty()->validate()->always(function ($v) { if (!is_string($v) && !is_array($v)) { throw new InvalidTypeException(); } $vs = !is_array($v) ? (array) $v : $v; $er = preg_grep('~\\.js$~', $vs); if ($er) { throw new InvalidPathException(); } return $v; })->end()->end()->booleanNode('external')->cannotBeEmpty()->defaultFalse()->end()->end()->end()->end()->arrayNode('shim')->defaultValue(array())->useAttributeAsKey('name')->normalizeKeys(false)->prototype('array')->children()->arrayNode('deps')->defaultValue(array())->prototype('scalar')->end()->end()->scalarNode('exports')->end()->end()->end()->end()->arrayNode('options')->defaultValue(array())->useAttributeAsKey('name')->prototype('array')->beforeNormalization()->always(function ($v) { return array('value' => $v); })->end()->children()->variableNode('value')->isRequired()->end()->end()->end()->end()->arrayNode('optimizer')->children()->scalarNode('path')->isRequired()->cannotBeEmpty()->end()->booleanNode('hide_unoptimized_assets')->defaultFalse()->end()->booleanNode('declare_module_name')->defaultFalse()->end()->arrayNode('exclude')->defaultValue(array())->prototype('scalar')->end()->end()->arrayNode('modules')->defaultValue(array())->useAttributeAsKey('name')->prototype('array')->children()->scalarNode('name')->cannotBeEmpty()->end()->arrayNode('include')->defaultValue(array())->prototype('scalar')->end()->end()->arrayNode('exclude')->defaultValue(array())->prototype('scalar')->end()->end()->end()->end()->end()->arrayNode('options')->defaultValue(array())->useAttributeAsKey('name')->prototype('array')->beforeNormalization()->always(function ($v) { return array('value' => $v); })->end()->children()->variableNode('value')->isRequired()->end()->end()->end()->end()->scalarNode('timeout')->cannotBeEmpty()->validate()->ifTrue(function ($v) { return !(is_int($v) || ctype_digit($v)); })->thenInvalid('Invalid number of seconds "%s"')->end()->defaultValue(60)->end()->scalarNode('almond_path')->defaultFalse()->end()->end()->end()->end(); return $treeBuilder; }
/** * 日历课程接口 */ public function actionGetSubjectSchedule() { if (!isset($_REQUEST['teacherId']) || !isset($_REQUEST['token']) || !isset($_REQUEST['date'])) { $this->_return('MSG_ERR_LESS_PARAM'); } $user_id = trim(Yii::app()->request->getParam('teacherId', null)); $token = trim(Yii::app()->request->getParam('token', null)); $date = trim(Yii::app()->request->getParam('date', null)); if (!ctype_digit($user_id)) { $this->_return('MSG_ERR_FAIL_PARAM'); } // 用户名不存在,返回错误 if ($user_id < 1) { $this->_return('MSG_ERR_NO_USER'); } // 验证日期格式合法 if (!$this->isDate($date)) { $this->_return('MSG_ERR_FAIL_DATE_FORMAT'); } $year = mb_substr($date, 0, 4, 'utf8'); $month = mb_substr($date, 5, 2, 'utf8'); $day = mb_substr($date, 8, 2, 'utf8'); if (empty($year) || empty($month) || empty($day)) { $this->_return('MSG_ERR_FAIL_DATE_LESS'); } // 验证token if (Token::model()->verifyToken($user_id, $token)) { // 获取日历课程 $data = Lesson::model()->getSubjectSchedule($user_id, $year, $month, $day, $date); $this->_return('MSG_SUCCESS', $data); } else { $this->_return('MSG_ERR_TOKEN'); } }
/** * 提交消息信息 */ public function actionPostNoticeReturn() { if (!isset($_REQUEST['userId']) || !isset($_REQUEST['token']) || !isset($_REQUEST['noticeId']) || !isset($_REQUEST['status'])) { $this->_return('MSG_ERR_LESS_PARAM'); } $user_id = trim(Yii::app()->request->getParam('userId')); $token = trim(Yii::app()->request->getParam('token')); $noticeId = trim(Yii::app()->request->getParam('noticeId')); $status = trim(Yii::app()->request->getParam('status')); if (!ctype_digit($user_id) || $user_id < 1) { $this->_return('MSG_ERR_NO_USER'); } if (!ctype_digit($noticeId) || $noticeId < 1 || !Notice::model()->isExistNoticeId($noticeId, $user_id)) { $this->_return('MSG_ERR_FAIL_NOTICE'); } if (!ctype_digit($status) || !in_array($status, array(1, 2, 3, 4))) { $this->_return('MSG_ERR_FAIL_NOTICE_STATUS'); } // 验证token if (Token::model()->verifyToken($user_id, $token)) { $data = Notice::model()->postNoticeReturn($noticeId, $status); $this->_return('MSG_SUCCESS', $data); } else { $this->_return('MSG_ERR_TOKEN'); } }
/** * @dataProvider provider_testTimestampedUID */ public function testTimestampedUID($method, $digitlen, $bits, $tbits, $hostbits) { $id = call_user_func(array('UIDGenerator', $method)); $this->assertEquals(true, ctype_digit($id), "UID made of digit characters"); $this->assertLessThanOrEqual($digitlen, strlen($id), "UID has the right number of digits"); $this->assertLessThanOrEqual($bits, strlen(wfBaseConvert($id, 10, 2)), "UID has the right number of bits"); $ids = array(); for ($i = 0; $i < 300; $i++) { $ids[] = call_user_func(array('UIDGenerator', $method)); } $lastId = array_shift($ids); if ($hostbits) { $lastHost = substr(wfBaseConvert($lastId, 10, 2, $bits), -$hostbits); } $this->assertArrayEquals(array_unique($ids), $ids, "All generated IDs are unique."); foreach ($ids as $id) { $id_bin = wfBaseConvert($id, 10, 2); $lastId_bin = wfBaseConvert($lastId, 10, 2); $this->assertGreaterThanOrEqual(substr($id_bin, 0, $tbits), substr($lastId_bin, 0, $tbits), "New ID timestamp ({$id_bin}) >= prior one ({$lastId_bin})."); if ($hostbits) { $this->assertEquals(substr($id_bin, 0, -$hostbits), substr($lastId_bin, 0, -$hostbits), "Host ID of ({$id_bin}) is same as prior one ({$lastId_bin})."); } $lastId = $id; } }
function check_input($details) { global $ALERT, $this_page; $errors = array(); // Check each of the things the user has input. // If there is a problem with any of them, set an entry in the $errors array. // This will then be used to (a) indicate there were errors and (b) display // error messages when we show the form again. // Check email address is valid and unique. if ($details["email"] == "") { $errors["email"] = "Please enter your email address"; } elseif (!validate_email($details["email"])) { // validate_email() is in includes/utilities.php $errors["email"] = "Please enter a valid email address"; } if (!ctype_digit($details['pid']) && $details['pid'] != '') { $errors['pid'] = 'Please choose a valid person'; } # if (!$details['keyword']) # $errors['keyword'] = 'Please enter a search term'; if ((get_http_var('submitted') || get_http_var('only')) && !$details['pid'] && !$details['keyword']) { $errors['keyword'] = 'Please choose a person and/or enter a keyword'; } // Send the array of any errors back... return $errors; }
/** * Allows a model to be loaded by username. */ public function unique_key($id) { if (!empty($id) and is_string($id) and !ctype_digit($id)) { return $this->columns['username']; } return parent::unique_key($id); }
/** * Allows loading by token string. */ public function unique_key($id) { if (!empty($id) and is_string($id) and !ctype_digit($id)) { return 'token'; } return parent::unique_key($id); }
protected function column_value(\ebi\Dao $dao, $name, $value) { if ($value === null) { return null; } try { switch ($dao->prop_anon($name, 'type')) { case 'timestamp': if (!ctype_digit($value)) { $value = strtotime($value); } // UTCとして扱う return date('Y-m-d H:i:s', $value - $this->timezone_offset); case 'date': if (!ctype_digit($value)) { $value = strtotime($value); } return date('Y-m-d', $value); case 'boolean': return (int) $value; } } catch (\Exception $e) { } return $value; }
public function __construct($id = NULL) { parent::__construct(); if ($id != NULL and (ctype_digit($id) or is_int($id))) { // try and get a row with this ID $data = $this->db->getwhere($this->table_name, array('id' => $id))->result(FALSE); // try and assign the data if (count($data) == 1 and $data = $data->current()) { foreach ($data as $key => $value) { $this->data[$key] = $value; } } } else { if ($id != NULL and is_string($id)) { // try and get a row with this username/email $data = $this->db->orwhere(array('url_name' => $id))->get($this->table_name)->result(FALSE); // try and assign the data if (count($data) == 1 and $data = $data->current()) { foreach ($data as $key => $value) { $this->data[$key] = $value; } } } } }
public function resolveMessageText(Room $room, string $text, int $flags = self::MATCH_ANY) : Promise { if (preg_match('~^:\\d+\\s+(.+)~', $text, $match)) { $text = $match[1]; } return resolve(function () use($room, $text, $flags) { if ($flags & self::MATCH_PERMALINKS) { try { $messageID = $this->resolveMessageIDFromPermalink($text); $text = (yield $this->chatClient->getMessageText($room, $messageID)); return $flags & self::RECURSE ? $this->resolveMessageText($room, $text, $flags | self::MATCH_LITERAL_TEXT) : $text; } catch (MessageIDNotFoundException $e) { /* ignore, there may be other matches */ } } if ($flags & self::MATCH_MESSAGE_IDS && ctype_digit($text)) { $text = (yield $this->chatClient->getMessageText($room, (int) $text)); return $flags & self::RECURSE ? $this->resolveMessageText($room, $text, $flags | self::MATCH_LITERAL_TEXT) : $text; } if ($flags & self::MATCH_LITERAL_TEXT) { return $text; } throw new MessageFetchFailureException(); }); }
public function check($args) { if (ctype_digit($args)) { return true; } return false; }
protected function validate($integer) { if (is_int($integer)) { return true; } return ctype_digit($integer); }
public function validate_uint($value) { if (!ctype_digit($value) || strstr($value, '.') || $value < 0) { return array(_t('This field must be a positive integer.', $this->class_name)); } return array(); }
public function httpPostMethod(Http $http, array $formFields) { /* * Méthode appelée en cas de requête HTTP POST * * L'argument $http est un objet permettant de faire des redirections etc. * L'argument $formFields contient l'équivalent de $_POST en PHP natif. */ $userSession = new UserSession(); if ($userSession->isAdminAuthenticated() == false) { $http->redirectTo('/'); } //var_dump($formFields); //var_dump($_FILES); if (array_key_exists('Modification', $formFields)) { if ($http->hasUploadedFile('Photo')) { $pathinfo = $http->moveUploadedFile('Photo', '/images/meals'); var_dump($pathinfo); $mealModel = new MealModel(); $mealModel->modifyPicture($pathinfo, $formFields['Id']); } $mealModel = new MealModel(); $result = $mealModel->modifyMeal($formFields['Name'], $formFields['Description'], $formFields['QuantityInStock'], $formFields['BuyPrice'], $formFields['SalePrice'], $formFields['Id']); $http->redirectTo('/Admin/List'); } elseif (ctype_digit($formFields['meal_Id'])) { $mealModel = new MealModel(); $meal = $mealModel->find($formFields['meal_Id']); return ['meal' => $meal]; } }
public function home() { $search = $this->request->query('q'); $page = $this->request->query('p'); if ($search != null) { $searchKeywordsEncoded = urlencode($search); if ($page != null) { if (!ctype_digit($page)) { $page = 1; } else { if (intval($page) < 1) { $page = 1; } else { if (intval($page) > 10) { $page = 10; } } } } else { $page = 1; } $this->set('doNotShowSearchBarInHeader', true); $searchResult = $this->amazon->search($searchKeywordsEncoded, $page); $tableOnly = $this->request->query('tableOnly') == "true"; $this->set(compact('searchResult', 'page', 'search', 'tableOnly')); } else { $this->set('doNotShowSearchBarInHeader', false); $productsTable = TableRegistry::get('Products'); $query = $productsTable->find()->contain(['Prices'])->where(['image_link is not' => null])->limit(30); $products = $query->toArray(); $this->set(compact("products")); } }
function twig_date_format_filter($date, $format = 'F j, Y H:i') { if (!$date instanceof DateTime) { $date = new DateTime((ctype_digit($date) ? '@' : '') . $date); } return $date->format($format); }
public function __invoke($number) { if (ctype_digit($number) && strlen($number) == 10) { $number = '(' . substr($number, 0, 3) . ') ' . substr($number, 3, 3) . '-' . substr($number, 6); } return $number; }
public function store($id, $name, $strict = FALSE) { $namelen = strlen($name); if ($namelen < 1 || $namelen > 255) { throw new Exception('invalid-name', $name); } if (!ctype_digit(strval($id))) { throw new Exception('invalid-id', $id); } $namecheck = $this->byID($id); if ($namecheck == $name) { return TRUE; } if ($namecheck !== null) { $this->delete($id, $namecheck); } $idcheck = $this->byName($name); if ($id != $idcheck && $idcheck !== null) { if ($strict) { throw new Exception('name-taken'); } $this->delete($idcheck, $name); } $table = $this->table(); $db = $this->db(); $sql = "INSERT INTO `{$table}` (`id`, `name`) VALUES (%i, %s)"; if (!$strict) { $sql .= " ON DUPLICATE KEY UPDATE `id` = VALUES(`id`), `name` = VALUES(`name`)"; } $rs = $db->execute($sql, $id, $name); return TRUE; }
public function generate() { $input = Input::get('number'); $birthday = Input::get('bd'); $location = Input::get('l'); if (!ctype_digit($input)) { return Redirect::back()->with('message', 'You did not enter a number!'); } $input = intval($input); if ($input < 0 || $input > 99) { return Redirect::back()->with('message', 'You have to enter number between 1 to 99!'); } $faker = \Faker\Factory::create(); $users = array(); for ($i = 0; $i < $input; $i++) { if (is_null($birthday) && is_null($location)) { $users[$i] = "<p>" . $faker->userName . "</p>"; } elseif (isset($birthday) && !isset($location)) { $users[$i] = "<p>" . $faker->userName . "</br>" . $faker->dateTimeThisCentury->format('Y-m-d') . "</p>"; } elseif (!isset($birthday) && isset($location)) { $users[$i] = $faker->userName . "</br>" . $faker->city; } else { $users[$i] = "<p>" . $faker->userName . "</br>" . $faker->dateTimeThisCentury->format('Y-m-d') . "</br>" . $faker->city . "</p>"; } } $generated = implode('<br>', $users); return view('randomuser')->with('generated', $generated); }
/** * @see sfValidatorBase */ protected function doClean($value) { if (is_array($value)) { $clean = $this->convertDateArrayToTimestamp($value); } else { if ($regex = $this->getOption('date_format')) { if (!preg_match($regex, $value, $match)) { throw new sfValidatorError($this, 'bad_format', array('value' => $value, 'date_format' => $this->getOption('date_format_error') ? $this->getOption('date_format_error') : $this->getOption('date_format'))); } $clean = $this->convertDateArrayToTimestamp($match); } else { if (!ctype_digit($value)) { $clean = strtotime($value); if (false === $clean) { throw new sfValidatorError($this, 'invalid', array('value' => $value)); } } else { $clean = (int) $value; } } } if ($this->hasOption('max') && $clean > $this->getOption('max')) { throw new sfValidatorError($this, 'max', array('value' => $value, 'max' => date($this->getOption('date_format_range_error'), $this->getOption('max')))); } if ($this->hasOption('min') && $clean < $this->getOption('min')) { throw new sfValidatorError($this, 'min', array('value' => $value, 'min' => date($this->getOption('date_format_range_error'), $this->getOption('min')))); } return $clean === $this->getEmptyValue() ? $clean : date($this->getOption('with_time') ? $this->getOption('datetime_output') : $this->getOption('date_output'), $clean); }
public function withIdentifiers(array $identifiers) { $identifiers = array_fuse($identifiers); $ids = array(); $callsigns = array(); $phids = array(); $monograms = array(); $slugs = array(); foreach ($identifiers as $identifier) { if (ctype_digit((string) $identifier)) { $ids[$identifier] = $identifier; continue; } if (preg_match('/^(r[A-Z]+|R[1-9]\\d*)\\z/', $identifier)) { $monograms[$identifier] = $identifier; continue; } $repository_type = PhabricatorRepositoryRepositoryPHIDType::TYPECONST; if (phid_get_type($identifier) === $repository_type) { $phids[$identifier] = $identifier; continue; } if (preg_match('/^[A-Z]+\\z/', $identifier)) { $callsigns[$identifier] = $identifier; continue; } $slugs[$identifier] = $identifier; } $this->numericIdentifiers = $ids; $this->callsignIdentifiers = $callsigns; $this->phidIdentifiers = $phids; $this->monogramIdentifiers = $monograms; $this->slugIdentifiers = $slugs; return $this; }
/** * Renders the widget. * * @param string $name The element name * @param string $value The time displayed in this widget * @param array $attributes An array of HTML attributes to be merged with the default HTML attributes * @param array $errors An array of errors for the field * * @return string An HTML tag string * * @see sfWidgetForm */ public function render($name, $value = null, $attributes = array(), $errors = array()) { // convert value to an array $default = array('hour' => null, 'minute' => null, 'second' => null); if (is_array($value)) { $value = array_merge($default, $value); } else { $value = ctype_digit($value) ? (int) $value : strtotime($value); if (false === $value) { $value = $default; } else { // int cast required to get rid of leading zeros $value = array('hour' => (int) date('H', $value), 'minute' => (int) date('i', $value), 'second' => (int) date('s', $value)); } } $time = array(); $emptyValues = $this->getOption('empty_values'); // hours $widget = new sfWidgetFormSelect(array('choices' => $this->getOption('can_be_empty') ? array('' => $emptyValues['hour']) + $this->getOption('hours') : $this->getOption('hours'), 'id_format' => $this->getOption('id_format')), array_merge($this->attributes, $attributes)); $time['%hour%'] = $widget->render($name . '[hour]', $value['hour']); // minutes $widget = new sfWidgetFormSelect(array('choices' => $this->getOption('can_be_empty') ? array('' => $emptyValues['minute']) + $this->getOption('minutes') : $this->getOption('minutes'), 'id_format' => $this->getOption('id_format')), array_merge($this->attributes, $attributes)); $time['%minute%'] = $widget->render($name . '[minute]', $value['minute']); if ($this->getOption('with_seconds')) { // seconds $widget = new sfWidgetFormSelect(array('choices' => $this->getOption('can_be_empty') ? array('' => $emptyValues['second']) + $this->getOption('seconds') : $this->getOption('seconds'), 'id_format' => $this->getOption('id_format')), array_merge($this->attributes, $attributes)); $time['%second%'] = $widget->render($name . '[second]', $value['second']); } return strtr($this->getOption('with_seconds') ? $this->getOption('format') : $this->getOption('format_without_seconds'), $time); }
public function timestamp($mapping, $value) { if ($value instanceof MongoDate) { return $value->sec; } else { if ($value === NULL) { return NULL; } else { if (is_int($value) || is_float($value)) { return (int) $value; } else { if ($value instanceof Zend_Date) { return $value->getTimestamp(); } else { if (is_array($value) && isset($value['sec'])) { return $value['sec']; } else { if (!strlen($value)) { return NULL; } else { if (ctype_digit($value)) { return intval($value); } else { if (($time = strtotime($value)) !== false) { return $time; } } } } } } } } return NULL; }
public function unique_key($id = NULL) { if (!empty($id) && is_string($id) && !ctype_digit($id)) { return 'url_identifier'; } return parent::unique_key($id); }
public static function path($array, $path, $default = NULL) { $path = trim($path, '.* '); $keys = explode('.', $path); do { $key = array_shift($keys); if (ctype_digit($key)) { $key = (int) $key; } if (isset($array[$key])) { if ($keys) { if (is_array($array[$key])) { $array = $array[$key]; } else { break; } } else { return $array[$key]; } } else { break; } } while ($keys); return $default; }