本文整理汇总了PHP中Valid类的典型用法代码示例。如果您正苦于以下问题:PHP Valid类的具体用法?PHP Valid怎么用?PHP Valid使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Valid类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: _login
private function _login()
{
$array = $this->request->post('login');
$array = Validation::factory($array)->label('username', 'Username')->label('password', 'Password')->label('email', 'Email')->rules('username', array(array('not_empty')))->rules('password', array(array('not_empty')));
$fieldname = Valid::email(Arr::get($array, 'username')) ? Auth::EMAIL : Auth::USERNAME;
// Get the remember login option
$remember = isset($array['remember']);
Observer::notify('admin_login_validation', $array);
if ($array->check()) {
Observer::notify('admin_login_before', $array);
if (Auth::instance()->login($array['username'], $array['password'], $remember)) {
Observer::notify('admin_login_success', $array['username']);
Session::instance()->delete('install_data');
Kohana::$log->add(Log::INFO, ':user login')->write();
if ($next_url = Flash::get('redirect')) {
$this->go($next_url);
}
// $this->go to defaut controller and action
$this->go_backend();
} else {
Observer::notify('admin_login_failed', $array);
Messages::errors(__('Login failed. Please check your login data and try again.'));
$array->error($fieldname, 'incorrect');
Kohana::$log->add(Log::ALERT, 'Try to login with :field: :value. Incorrect data', array(':field' => $fieldname, ':value' => $array['username']))->write();
}
} else {
Messages::errors($array->errors('validation'));
}
$this->go(Route::get('user')->uri(array('action' => 'login')));
}
开发者ID:ZerGabriel,项目名称:cms-1,代码行数:30,代码来源:login.php
示例2: __construct
public function __construct($loggly_input_key)
{
if (!Valid::exact_length($loggly_input_key, self::LOGGLY_KEY_LENGTH)) {
throw new Kohana_Exception('Loggly input key must be exactly :length characters long.', [':length' => self::LOGGLY_KEY_LENGTH]);
}
$this->_loggly_input_key = $loggly_input_key;
}
开发者ID:anroots,项目名称:kohana-loggly,代码行数:7,代码来源:Loggly.php
示例3: download
public static function download($url, $directory, $filename = NULL)
{
$url = str_replace(' ', '%20', $url);
if (!Valid::url($url)) {
return FALSE;
}
$curl = curl_init($url);
$file = Upload_Util::combine($directory, uniqid());
$handle = fopen($file, 'w');
$headers = new HTTP_Header();
curl_setopt($curl, CURLOPT_FILE, $handle);
curl_setopt($curl, CURLOPT_FOLLOWLOCATION, TRUE);
curl_setopt($curl, CURLOPT_HEADERFUNCTION, array($headers, 'parse_header_string'));
if (curl_exec($curl) === FALSE or curl_getinfo($curl, CURLINFO_HTTP_CODE) !== 200) {
fclose($handle);
unlink($file);
throw new Kohana_Exception('Curl: Download Error: :error, status :status on url :url', array(':url' => $url, ':status' => curl_getinfo($curl, CURLINFO_HTTP_CODE), ':error' => curl_error($curl)));
}
fclose($handle);
if ($filename === NULL) {
if (!isset($headers['content-disposition']) or !($filename = Upload_Util::filename_from_content_disposition($headers['content-disposition']))) {
$mime_type = curl_getinfo($curl, CURLINFO_CONTENT_TYPE);
$url = urldecode(curl_getinfo($curl, CURLINFO_EFFECTIVE_URL));
$filename = Upload_Util::filename_from_url($url, $mime_type);
}
}
$filename = substr(pathinfo($filename, PATHINFO_FILENAME), 0, 60) . '.' . pathinfo($filename, PATHINFO_EXTENSION);
$result_file = Upload_Util::combine($directory, $filename);
rename($file, $result_file);
return is_file($result_file) ? $filename : FALSE;
}
开发者ID:Konro1,项目名称:pms,代码行数:31,代码来源:Util.php
示例4: parse
/**
* Parse a remote feed into an array.
*
* @param string $feed Remote feed URL
* @param integer $limit Item limit to fetch [Optional]
*
* @return array
*
* @uses Valid::url
*/
public function parse($feed, $limit = 0)
{
// Make limit an integer
$limit = (int) $limit;
// Disable error reporting while opening the feed
$error_level = error_reporting(0);
// Allow loading by filename or raw XML string
$load = (is_file($feed) or Valid::url($feed)) ? 'simplexml_load_file' : 'simplexml_load_string';
// Load the feed
$feed = $load($feed, 'SimpleXMLElement', LIBXML_NOCDATA);
// Restore error reporting
error_reporting($error_level);
// Feed could not be loaded
if (!$feed) {
return array();
}
$namespaces = $feed->getNamespaces(TRUE);
// This only for RSS 1.0/2.0 are supported
$feed = $feed->xpath('//item');
$i = 0;
$items = array();
foreach ($feed as $item) {
if ($limit > 0 and $i++ === $limit) {
break;
}
$item_fields = (array) $item;
// get namespaced tags
foreach ($namespaces as $ns) {
$item_fields += (array) $item->children($ns);
}
$items[] = $item_fields;
}
return $items;
}
开发者ID:MenZil-Team,项目名称:cms,代码行数:44,代码来源:rss.php
示例5: content
/**
* Render content.
*
* @return string
*/
public function content()
{
ob_start();
// Stamp
echo HTML::time(Date('l ', $this->event->stamp_begin) . Date::format('DDMMYYYY', $this->event->stamp_begin), $this->event->stamp_begin, true);
// Location
if ($this->event->venue) {
echo ' @ ', HTML::anchor(Route::model($this->event->venue), HTML::chars($this->event->venue->name)), ', ', HTML::chars($this->event->venue->city_name);
} elseif ($this->event->venue_name) {
echo ' @ ', $this->event->venue_url ? HTML::anchor($this->event->venue_url, $this->event->venue_name) : HTML::chars($this->event->venue_name), $this->event->city_name ? ', ' . HTML::chars($this->event->city_name) : '';
} elseif ($this->event->city_name) {
echo ' @ ', HTML::chars($this->event->city_name);
}
// Flyer
if ($this->event->flyer_front) {
echo '<figure>', HTML::image($this->event->flyer_front->get_url(Model_Image::SIZE_THUMBNAIL)), '</figure>';
} elseif ($this->event->flyer_back) {
echo '<figure>', HTML::image($this->event->flyer_back->get_url(Model_Image::SIZE_THUMBNAIL)), '</figure>';
} elseif (Valid::url($this->event->flyer_front_url)) {
echo '<br /><figure>', HTML::image($this->event->flyer_front_url, array('width' => 160)), '</figure>';
}
// Favorites
if ($this->event->favorite_count) {
echo '<span class="stats"><i class="icon-heart"></i> ' . $this->event->favorite_count . '</span>';
}
return ob_get_clean();
}
开发者ID:anqh,项目名称:events,代码行数:32,代码来源:hovercard.php
示例6: action_update
/**
* CRUD controller: UPDATE
*/
public function action_update()
{
$this->template->title = __('Update') . ' ' . __($this->_orm_model) . ' ' . $this->request->param('id');
$form = new FormOrm($this->_orm_model, $this->request->param('id'));
if ($this->request->post()) {
if ($success = $form->submit()) {
if (Valid::email($form->object->email, TRUE)) {
//check we have this email in the DB
$user = new Model_User();
$user = $user->where('email', '=', Kohana::$_POST_ORIG['formorm']['email'])->where('id_user', '!=', $this->request->param('id'))->limit(1)->find();
if ($user->loaded()) {
Alert::set(Alert::ERROR, __('A user with the email you specified already exists'));
} else {
$form->save_object();
Alert::set(Alert::SUCCESS, __('Item updated') . '. ' . __('Please to see the changes delete the cache') . '<br><a class="btn btn-primary btn-mini ajax-load" href="' . Route::url('oc-panel', array('controller' => 'tools', 'action' => 'cache')) . '?force=1" title="' . __('Delete cache') . '">' . __('Delete cache') . '</a>');
$this->redirect(Route::get($this->_route_name)->uri(array('controller' => Request::current()->controller())));
}
} else {
Alert::set(Alert::ERROR, __('Invalid Email'));
}
} else {
Alert::set(Alert::ERROR, __('Check form for errors'));
}
}
return $this->render('oc-panel/pages/user/update', array('form' => $form));
}
开发者ID:ThomWensink,项目名称:common,代码行数:29,代码来源:user.php
示例7: set_values
public function set_values(array $data)
{
if (!Valid::url($data['next_url'])) {
$data['next_url'] = NULL;
}
$data['fields'] = array();
if (!empty($data['field']) and is_array($data['field'])) {
foreach ($data['field'] as $key => $values) {
foreach ($values as $index => $value) {
if ($index == 0) {
continue;
}
if ($key == 'source') {
$value = URL::title($value, '_');
}
$data['fields'][$index][$key] = $value;
}
}
$data['field'] = NULL;
}
$email_type_fields = array();
foreach ($data['fields'] as $field) {
$email_type_fields['key'][] = $field['id'];
$email_type_fields['value'][] = !empty($field['name']) ? $field['name'] : Inflector::humanize($field['id']);
}
$this->create_email_type($email_type_fields);
return parent::set_values($data);
}
开发者ID:ZerGabriel,项目名称:cms-1,代码行数:28,代码来源:sendmail.php
示例8: content
/**
* Render content.
*
* @return string
*/
public function content()
{
ob_start();
// Cover
if (Valid::url($this->track->cover)) {
echo HTML::image($this->track->cover, array('class' => 'cover img-responsive', 'alt' => __('Cover')));
}
// Time
if ($this->track->size_time) {
echo '<i class="fa fa-fw fa-clock-o"></i> ' . $this->track->size_time . '<br />';
}
// Listen count
if ($this->track->listen_count > 1) {
echo '<i class="fa fa-fw fa-play"></i> ' . ($this->track->listen_count == 1 ? __(':count play', array(':count' => $this->track->listen_count)) : __(':count plays', array(':count' => $this->track->listen_count))) . '<br />';
}
// Tags
if ($tags = $this->track->tags()) {
echo '<i class="fa fa-fw fa-music"></i> ' . implode(', ', $tags) . '<br />';
} elseif (!empty($this->track->music)) {
echo '<i class="fa fa-fw fa-music"></i> ' . $this->track->music . '<br />';
}
// Meta
echo '<footer class="meta text-muted">';
echo __('Added :date', array(':date' => HTML::time(Date::format(Date::DMY_SHORT, $this->track->created), $this->track->created)));
echo '</footer>';
return ob_get_clean();
}
开发者ID:anqh,项目名称:anqh,代码行数:32,代码来源:info.php
示例9: set_rss_url
public function set_rss_url($url)
{
if (!Valid::url($url)) {
return NULL;
}
return $url;
}
开发者ID:ZerGabriel,项目名称:cms-1,代码行数:7,代码来源:rss.php
示例10: action_index
/**
* @return void
*/
public function action_index()
{
$this->template->content->active = "options";
$session = Session::instance();
// Check for post
if ($this->request->method() === "POST") {
$bucket_name = trim($this->request->post('bucket_name'));
// Check for updates to the bucket name
if (Valid::not_empty($bucket_name) and strcmp($bucket_name, $this->bucket['name']) !== 0) {
$bucket_id = $this->bucket['id'];
$parameters = array('name' => $bucket_name, 'public' => (bool) $this->request->post('bucket_publish'));
//
if (($bucket = $this->bucket_service->modify_bucket($bucket_id, $parameters, $this->user)) != FALSE) {
$session->set('message', __("Bucket settings successfully saved"));
// Reload the settings page using the updated bucket name
$this->redirect($bucket['url'] . '/settings', 302);
} else {
$session->set('error', __("The bucket settings could not be updated"));
}
}
}
// Set the messages and/or error messages
$this->template->content->set('message', $session->get('message'))->set('error', $session->get('error'));
$this->settings_content = View::factory('pages/bucket/settings/display')->bind('bucket', $this->bucket)->bind('collaborators_view', $collaborators_view);
// Collaboraotors view
$collaborators_view = View::factory('/template/collaborators')->bind('fetch_url', $fetch_url)->bind('collaborator_list', $collaborators);
$fetch_url = $this->bucket_base_url . '/collaborators';
$collaborators = json_encode($this->bucket_service->get_collaborators($this->bucket['id']));
$session->delete('message');
$session->delete('error');
}
开发者ID:aliyubash23,项目名称:SwiftRiver,代码行数:34,代码来源:Settings.php
示例11: to_user
/**
* Send x copies of the registered item to a user.
*
* @param integer|Model_User $user
* @param integer $amount
* @param string $location
*
* @throws Item_Exception
*/
public function to_user($user, $origin = "app", $amount = 1, $location = 'inventory')
{
if (!Valid::digit($amount)) {
throw new Item_Exception('The supplied amount should be a number.');
}
if (Valid::digit($user)) {
$user = ORM::factory('User', $user);
} elseif (!is_a($user, 'Model_User')) {
throw new Item_Exception('The supplied user does not come from a model.');
}
if (!$user->loaded()) {
throw new Item_Exception('The supplied user does not exist.');
} else {
$user_item = ORM::factory('User_Item')->where('user_id', '=', $user->id)->where('item_id', '=', $this->_item->id)->where('location', '=', $location)->find();
$action = $amount > 0 ? '+' : '-';
if ($user_item->loaded()) {
// update item amount
$user_item->amount($action, $amount);
} elseif ($action == '+') {
$id = $this->_item->id;
// create new copy
$user_item = ORM::factory('User_Item')->values(array('user_id' => $user->id, 'item_id' => $id, 'location' => $location, 'amount' => $amount))->save();
}
return Journal::log('item.in.' . $origin, 'item', 'Player received :amount :item_name @ :origin', array(':amount' => $amount, ':item_name' => $user_item->item->name($amount, FALSE), ':origin' => str_replace('.', ' ', $origin)));
}
}
开发者ID:modulargaming,项目名称:item,代码行数:35,代码来源:Item.php
示例12: on_page_load
public function on_page_load()
{
$email_ctx_id = $this->get('email_id_ctx', 'email');
$email = $this->_ctx->get($email_ctx_id);
$referrer_page = Request::current()->referrer();
$next_page = $this->get('next_url', Request::current()->referrer());
if (!Valid::email($email)) {
Messages::errors(__('Use a valid e-mail address.'));
HTTP::redirect($referrer_page);
}
$user = ORM::factory('user', array('email' => $email));
if (!$user->loaded()) {
Messages::errors(__('No user found!'));
HTTP::redirect($referrer_page);
}
$reflink = ORM::factory('user_reflink')->generate($user, 'forgot', array('next_url' => URL::site($this->next_url, TRUE)));
if (!$reflink) {
Messages::errors(__('Reflink generate error'));
HTTP::redirect($referrer_page);
}
Observer::notify('admin_login_forgot_before', $user);
try {
Email_Type::get('user_request_password')->send(array('username' => $user->username, 'email' => $user->email, 'reflink' => Route::url('reflink', array('code' => $reflink)), 'code' => $reflink));
Messages::success(__('Email with reflink send to address set in your profile'));
} catch (Exception $e) {
Messages::error(__('Something went wrong'));
}
HTTP::redirect($next_page);
}
开发者ID:ZerGabriel,项目名称:cms-1,代码行数:29,代码来源:forgot.php
示例13: getVerifyResult
/**
* 获取校验结果
* @return type
*/
public static function getVerifyResult()
{
$context = new Context();
$typhoon = new Typhoon();
if ($typhoon->isValid()) {
$ssid = $typhoon->_ssid;
$name = $typhoon->_name;
$value = $context->get($name, '');
if ($value != '') {
if ($typhoon->_request_type == 1) {
$ret = Valid::sendVerifyRemoteRequest($ssid, $value, $typhoon->_diff_time);
} else {
$ret = Valid::sendVerifyLocalRequest($ssid, $value);
}
self::$_result = Valid::getResult();
self::$_code = Valid::getCode();
self::$_details = Valid::getDetails();
} else {
self::$_result = 0;
self::$_code = 'E_VALUEEMPTY_001';
self::$_details = '验证码不可以为空';
}
} else {
self::$_result = 0;
self::$_code = 'E_PARAM_001';
self::$_details = '重要参数传递错误';
}
return self::$_result === 1 ? TRUE : FALSE;
}
开发者ID:saintho,项目名称:phpdisk,代码行数:33,代码来源:Verify.php
示例14: isValid
public function isValid($Validation_data)
{
$errors = [];
foreach ($Validation_data as $name => $value) {
if (isset($_REQUEST[$name])) {
$exploded = explode(':', $value);
switch ($exploded[0]) {
case 'min':
$min = $exploded[1];
if (Valid::string()->length(3)->validate($_REQUEST[$name]) == false) {
$errors[] = "{$name} must be {$min} caracters long";
}
break;
case 'email':
if (Valid::email()->validate($_REQUEST[$name]) == false) {
$errors[] = $name . ' is not a valid email';
}
break;
case 'equalsTo':
$field = $exploded[1];
if (!Valid::equals($name)->validate($field)) {
$errors[] = $name . " must be equal to " . $field;
}
break;
}
}
}
return $errors;
}
开发者ID:rezof,项目名称:acme,代码行数:29,代码来源:Validator.php
示例15: action_pay
/**
* [action_form] generates the form to pay at paypal
*/
public function action_pay()
{
$this->auto_render = FALSE;
$order_id = $this->request->param('id');
$order = new Model_Order();
$order->where('id_order', '=', $order_id)->where('status', '=', Model_Order::STATUS_CREATED)->limit(1)->find();
if ($order->loaded()) {
// case when selling advert
if ($order->id_product == Model_Order::PRODUCT_AD_SELL) {
$paypal_account = $order->ad->paypal_account();
$currency = i18n::get_intl_currency_symbol();
if (isset($order->ad->cf_shipping) and Valid::numeric($order->ad->cf_shipping) and $order->ad->cf_shipping > 0) {
$order->amount = $order->amount + $order->ad->cf_shipping;
}
} else {
$paypal_account = core::config('payment.paypal_account');
$currency = core::config('payment.paypal_currency');
}
$paypal_url = Core::config('payment.sandbox') ? Paypal::url_sandbox_gateway : Paypal::url_gateway;
$paypal_data = array('order_id' => $order_id, 'amount' => number_format($order->amount, 2, '.', ''), 'site_name' => core::config('general.site_name'), 'site_url' => URL::base(TRUE), 'paypal_url' => $paypal_url, 'paypal_account' => $paypal_account, 'paypal_currency' => $currency, 'item_name' => $order->description);
$this->template = View::factory('paypal', $paypal_data);
$this->response->body($this->template->render());
} else {
Alert::set(Alert::INFO, __('Order could not be loaded'));
$this->redirect(Route::url('default'));
}
}
开发者ID:kotsios5,项目名称:openclassifieds2,代码行数:30,代码来源:paypal.php
示例16: action_index
public function action_index()
{
$code = $this->request->param('code');
if ($code === NULL) {
Model_Page_Front::not_found();
}
$reflink_model = ORM::factory('user_reflink', $code);
if (!$reflink_model->loaded()) {
Messages::errors(__('Reflink not found'));
$this->go_home();
}
$next_url = Arr::get($reflink_model->data, 'next_url');
try {
Database::instance()->begin();
Reflink::factory($reflink_model)->confirm();
$reflink_model->delete();
Database::instance()->commit();
} catch (Kohana_Exception $e) {
Database::instance()->rollback();
Messages::errors($e->getMessage());
}
if (Valid::url($next_url)) {
$this->go($next_url);
}
$this->go_home();
}
开发者ID:ZerGabriel,项目名称:cms-1,代码行数:26,代码来源:reflink.php
示例17: action_stats
public function action_stats()
{
$data = array();
$errors = array();
$filter = Session::instance()->get('statFilter', array());
if ($this->isPressed('btnFilter')) {
$filter['FIO'] = Arr::get($_POST, 'FIO');
$filter['dateFrom'] = Arr::get($_POST, 'dateFrom');
$filter['dateTo'] = Arr::get($_POST, 'dateTo');
Session::instance()->set('statFilter', $filter);
if ($filter['dateFrom'] != '' && !Valid::mydate($filter['dateFrom'])) {
$errors['dateFrom'] = 'Дата должна быть в формате dd.mm.yyyy';
}
if ($filter['dateTo'] != '' && !Valid::mydate($filter['dateTo'])) {
$errors['dateTo'] = 'Дата должна быть в формате dd.mm.yyyy';
}
}
$material_id = $this->request->param('id', NULL);
$material = ORM::factory('material', $material_id);
$data['materialName'] = $material->materialName;
$data['stats'] = $material->getStats($material_id, $filter);
$data['count'] = count($data['stats']);
$data['filter'] = $filter;
$data['errors'] = $errors;
$this->tpl->content = View::factory('materials/stats', $data);
}
开发者ID:reznikds,项目名称:Reznik,代码行数:26,代码来源:materials.php
示例18: action_create
public function action_create()
{
try {
if (!Valid::email(core::request('email'))) {
$this->_error(__('Invalid email'), 501);
} elseif (!is_numeric(core::request('id_product'))) {
$this->_error(__('Invalid product'), 501);
} else {
$product = new Model_Product(core::request('id_product'));
if ($product->loaded()) {
$user = Model_User::create_email(core::request('email'), core::request('name'));
$order = Model_Order::new_order($user, $product);
$order->confirm_payment(core::request('paymethod', 'API'), core::request('txn_id'), core::request('pay_date'), core::request('amount'), core::request('currency'), core::request('fee'));
//adding the notes
$order->notes = core::request('notes');
$order->save();
$this->rest_output(array('order' => self::get_order_array($order)));
} else {
$this->_error(__('Something went wrong'), 501);
}
}
} catch (Kohana_HTTP_Exception $khe) {
$this->_error($khe);
}
}
开发者ID:Ryanker,项目名称:open-eshop,代码行数:25,代码来源:order.php
示例19: set
/**
* Handles setting of columns
* Overriding this method to handle WKT Geometry value
*
* @param string $column Column name
* @param mixed $value Column value
* @throws Kohana_Exception
* @return ORM
*/
public function set($column, $value)
{
// Convert to WKT Point
if ($column == 'value' and is_array($value) and array_key_exists('lat', $value) and Valid::numeric($value['lat']) and array_key_exists('lon', $value) and Valid::numeric($value['lon'])) {
$value = strtr("POINT(lon lat)", $value);
}
return parent::set($column, $value);
}
开发者ID:kwameboame,项目名称:platform,代码行数:17,代码来源:Point.php
示例20: static_base
/**
* Returns LogReader static url.
*
* @return string
* @uses URL::base()
*/
public static function static_base()
{
if (Valid::url(static::$config->get_static_route())) {
return static::$config->get_static_route() . '/';
} else {
return URL::base(Request::current()) . static::$config->get_static_route() . '/';
}
}
开发者ID:siloor,项目名称:kohana-logreader,代码行数:14,代码来源:URL.php
注:本文中的Valid类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论