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


PHP isValid函数代码示例

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


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

示例1: isSubmitted

 /**
  * Checks whether the form builder is validated after validation.
  *
  * @access    private
  * @return    boolean
  *
  * @author Etienne de Longeaux <etienne.delongeaux@gmail.com>
  * @since 2012-09-11
  */
 private function isSubmitted()
 {
     if ($this->getName() == $this->_id_form) {
         if ($this->getTypeForm() == "zend") {
             $form_instance = $this->container->get('request')->query->get('form_instance');
             if ($form_instance) {
                 $instance = App_Tools_Post::get('form_instance');
                 if ($this->_session->_isValidInstance($instance)) {
                     // IMPORTANT :: permet d'éviter qu'une instance soit utilisé par un robot pour lancer x fois un même formulaire
                     $this->_session->_removeInstance($instance);
                     return true;
                 }
             }
             return false;
         } elseif ($this->getTypeForm() == "symfony") {
             $request = $this->container->get('request');
             if ($request->getMethod() == 'POST') {
                 // we apply the pre event bind request
                 $this->preEventBindRequest();
                 // we bind the form
                 $this->_form->bind($request);
                 if ($this->_form->isValid()) {
                     return true;
                 } else {
                     return false;
                 }
             }
             return false;
         }
     }
     return false;
 }
开发者ID:pigroupe,项目名称:SfynxCmfBundle,代码行数:41,代码来源:PiFormBuilderManager.php

示例2: updatePassword

 public function updatePassword()
 {
     if (!isset($this->clean->password) || !isValid($this->clean->password, 'password')) {
         $this->data['message'] = reset(array_values(formatErrors(602)));
     } else {
         // Check current password
         $current_password = isset($this->clean->current_password) ? $this->clean->current_password : null;
         $res = $this->user->read($this->user_id, 1, 1, 'email,password');
         if (!isset($res->password)) {
             $this->data['message'] = 'We could not verify your current password.';
         } elseif (verifyHash($current_password, $res->password) != $res->password) {
             $this->data['message'] = 'Your current password does not match what we have on record.';
         } else {
             $password = generateHash($this->clean->password);
             $user = $this->user->update($this->user_id, array('password' => $password));
             if (isset($user->password) && $user->password == $password) {
                 $this->data['success'] = true;
                 // Send email
                 $this->load->library('email');
                 $this->email->initialize();
                 $sent = $this->email->updatePassword($user->email);
             } else {
                 $this->data['message'] = 'Your password could not be updated at this time. Please try again.';
             }
         }
     }
     $this->renderJSON();
 }
开发者ID:iweave,项目名称:unmark,代码行数:28,代码来源:user.php

示例3: nextValidPass

function nextValidPass($pass)
{
    do {
        $pass = nextPass($pass);
    } while (!isValid($pass));
    return $pass;
}
开发者ID:earncef,项目名称:AdventOfCode,代码行数:7,代码来源:sol.php

示例4: getNext

function getNext($input)
{
    $next = $input;
    do {
        $next = increment($next);
        while (($validLen = strcspn($next, 'iol')) !== strlen($next)) {
            $next = increment(substr($next, 0, $validLen + 1)) . substr($next, $validLen + 1);
        }
    } while (!isValid($next));
    return $next;
}
开发者ID:ultramega,项目名称:adventofcode2015,代码行数:11,代码来源:part2.php

示例5: login

function login($account, $passwordhash)
{
    if (isValid($account, $passwordhash)) {
        session_reset();
        session_regenerate_id(true);
        $_SESSION["account"] = $account;
        $_SESSION["passwordhash"] = $passwordhash;
        return true;
    } else {
        return false;
    }
}
开发者ID:BlackTigers,项目名称:schoolnet-server,代码行数:12,代码来源:account.php

示例6: generatePassword

function generatePassword($password)
{
    $passwordLength = strlen($password);
    while (true) {
        $password++;
        if (strlen($password) > $passwordLength) {
            break;
        }
        if (isValid($password)) {
            return $password;
        }
    }
    return false;
}
开发者ID:bramstroker,项目名称:AdventOfCode,代码行数:14,代码来源:11.php

示例7: valid_link

function valid_link()
{
    $CI =& get_instance();
    $token = $CI->config->item('token');
    if (!validateSignature($token)) {
        exit('签名验证失败');
    }
    if (isValid()) {
        // 网址接入验证
        exit($_GET['echostr']);
    }
    if (!isset($GLOBALS['HTTP_RAW_POST_DATA'])) {
        exit('缺少数据');
    }
}
开发者ID:lnmpoo,项目名称:wechat_ci,代码行数:15,代码来源:common_helper.php

示例8: modulus

function modulus($a, $b)
{
    $validated = isValid($a, $b);
    if ($validated === true) {
        if ($b === 0) {
            echo "DIVIDE-ERROR:\$b cannot be zero" . PHP_EOL;
        } else {
            $c = $a % $b;
            echo "Calculated Power Level = {$c}" . PHP_EOL;
            return $c;
        }
    } else {
        echo $validated;
    }
}
开发者ID:j-beere,项目名称:Codeup_Exercises,代码行数:15,代码来源:arithmetic.php

示例9: init

 public function init()
 {
     $reply_to = new Zend_Form_Element_Text('reply_to');
     $reply_to->setLabel('Reply To')->setAttribs(array('style' => 'width:550px !important;'))->setRequired(true)->addValidator('NotEmpty');
     $html_signature = new Zend_Form_Element_Text('html_signature');
     $html_signature->setLabel('Html Signature')->setAttribs(array('style' => 'width:550px !important;'))->setRequired(true)->addValidator('NotEmpty');
     $primary_phone = new Zend_Form_Element_Text('primary_phone');
     $primary_phone->setLabel('Primary Phone')->setAttribs(array('style' => 'width:250px !important;'))->setRequired(true)->addValidator(new Zend_Validate_Digits(isValid("+1234567890")));
     $cell_phone = new Zend_Form_Element_Text('cell_phone');
     $cell_phone->setLabel('Cell Phone')->setAttribs(array('style' => 'width:250px !important;'))->setRequired(true)->addValidator(new Zend_Validate_Digits(isValid("+1234567890")));
     $fax = new Zend_Form_Element_Text('fax');
     $fax->setLabel('Fax')->setAttribs(array('style' => 'width:250px !important;'))->setRequired(true)->addValidator('NotEmpty');
     $company = new Zend_Form_Element_Text('company');
     $company->setLabel('Company')->setAttribs(array('style' => 'width:550px !important;'))->setRequired(true)->addValidator('NotEmpty');
     $address = new Zend_Form_Element_Text('address');
     $address->setLabel('Address')->setAttribs(array('style' => 'width:550px !important;'))->setRequired(true)->addValidator('NotEmpty');
     $address2 = new Zend_Form_Element_Text('address2');
     $address2->setLabel('Address2')->setAttribs(array('style' => 'width:550px !important;'))->setRequired(true)->addValidator('NotEmpty');
     $city = new Zend_Form_Element_Text('city');
     $city->setLabel('City')->setAttribs(array('style' => 'width:250px !important;'))->setRequired(true)->addValidator('NotEmpty');
     $state = new Zend_Form_Element_Text('state');
     $state->setLabel('State')->setAttribs(array('style' => 'width:250px !important;'))->setRequired(true)->addValidator('NotEmpty');
     $zip = new Zend_Form_Element_Text('zip');
     $zip->setLabel('Zip')->setAttribs(array('style' => 'width:150px !important;'))->setRequired(true)->addValidator(new Zend_Validate_Digits(isValid("1234567890")));
     $email = new Zend_Form_Element_Text('email');
     $email->setLabel('Email')->setAttribs(array('style' => 'width:350px !important;'))->setRequired(true)->addValidator('EmailAddress', TRUE);
     $report_template_id = new Zend_Form_Element_Select('report_template_id');
     $report_template_id->setLabel('Report Template')->setRequired(true)->setMultiOptions(Jameen_ReportsTemplates::getMultiList());
     $followup_template_id = new Zend_Form_Element_Select('followup_template_id');
     $followup_template_id->setLabel('Followup Template')->setRequired(true)->setMultiOptions(Jameen_FollowupemailTemplates::getMultiList());
     $followup_enabled = new Zend_Form_Element_MultiCheckbox('followup_enabled');
     $followup_enabled->setLabel('Followup Enabled')->setRequired(true)->setAttribs(array('style' => 'width:53px !important;'))->addMultiOptions(array('checkedValue' => false));
     $sms_enabled = new Zend_Form_Element_MultiCheckbox('sms_enabled');
     $sms_enabled->setLabel('Sms Enabled')->setRequired(true)->setAttribs(array('style' => 'width:53px !important;'))->addMultiOptions(array('checkedValue' => false));
     $submit = new Zend_Form_Element_Submit('submit');
     $submit->setLabel('submit');
     $this->addElements(array($reply_to, $html_signature, $primary_phone, $cell_phone, $fax, $company, $address, $address2, $city, $state, $zip, $email, $report_template_id, $followup_template_id, $followup_enabled, $sms_enabled));
     /*
     $this->setElementDecorators(array(
        	array('ViewHelper'),
     	array('Label'),
     	array('Errors', array('class'=>'error')),
     )); 
     */
     $this->setElementDecorators(array('ViewHelper', array(array('wrapperField' => 'HtmlTag'), array('tag' => 'div', 'class' => 'controls cont')), array('Label', array('placement' => 'prepend', 'class' => 'control-label'))));
     $this->setAttribs(array('action' => ''));
 }
开发者ID:nishant3001,项目名称:canopy,代码行数:47,代码来源:Accounts.php

示例10: index

    function index()
    {
        if (FW_CONFIGS == false) {
            $base_url = substr(__DIR__, 0, -19);
            $base_url = substr($base_url, strrpos($base_url, '/'), 20);
            $base_url .= '/';
            if ($this->input->isPost()) {
                //Validate form
                $this->load->helper("_config");
                $errors = isValid($this->input->getPostVariable());
                if (count($errors) == 0) {
                    $config = new Document($this->configPath, "all_config.inc.php");
                    $dbConfig = new Document($this->dbConfigPath, "db_config.inc.php");
                    $configString = $config->read();
                    $dbConfigString = $dbConfig->read();
                    foreach ($this->input->getPostVariable() as $field => $value) {
                        if (in_array($field, array("productTitle", "baseUrl", "productVersion", "mandrillKey", "productStage"))) {
                            $configString = str_replace("**" . $field . "**", $value, $configString);
                        } elseif ($field == "db_prefix" or $field == "DB_PREFIX") {
                            $dbConfigString = str_replace("**" . $field . "**", "_" . $value, $dbConfigString);
                        } else {
                            $dbConfigString = str_replace("**" . $field . "**", $value, $dbConfigString);
                        }
                    }
                    $config->write($configString);
                    $dbConfig->write($dbConfigString);
                    //Update config Framework
                    $fr = new Document(__DIR__ . '/../initialize', '_all_config.inc.php');
                    $fr->replace('
	define("FW_CONFIGS", false);', 'define("FW_CONFIGS", true);');
                    //Require the files again, since the settings are changed
                    include $this->configPath . '/all_config.inc.php';
                    include $this->dbConfigPath . '/db_config.inc.php';
                    //Load the view
                    $this->load->view("_config", array("form" => false));
                } else {
                    $this->load->view("_config", array("base_url" => $base_url, "form" => true, "errors" => $errors, "post" => $this->input->getPostVariable()));
                }
            } else {
                $this->load->view("_config", array("base_url" => $base_url, "form" => true));
            }
        } else {
            $fof = new FourOhFour("You are somewhere you should not be");
        }
    }
开发者ID:kliptonize,项目名称:Encode,代码行数:45,代码来源:_FirstTimeUse.php

示例11: update_recipes_request

function update_recipes_request()
{
    if (!empty($_POST["id"])) {
        $post_id = $_POST["id"];
        $post = get_post($post_id);
        $url = post_permalink($post_id);
        $ingredients = get_post_meta($post_id, 'RECIPE_META_ingredients', true);
        $nutrition_facts = process_request($ingredients);
        if (isValid($nutrition_facts)) {
            if (!add_post_meta($post_id, META_KEY, $nutrition_facts, true)) {
                update_post_meta($post_id, META_KEY, $nutrition_facts);
            }
            echo json_encode(array('ID' => $post->ID, 'post_title' => $post->post_title, 'url' => $url, 'success' => true, 'error' => false, 'message' => 'Update successful.'));
        } else {
            echo json_encode(array('ID' => $post->ID, 'post_title' => $post->post_title, 'url' => $url, 'success' => false, 'error' => true, 'message' => 'Update unsuccessful.'));
        }
    }
    die;
}
开发者ID:clintwine,项目名称:nutrition-facts-label,代码行数:19,代码来源:process.php

示例12: validate

function validate($options = array(), $data_types = array(), $required = array())
{
    $meets_reqs = true;
    $errors = array();
    //Check required fields
    if (!empty($required)) {
        foreach ($required as $column) {
            if (!isset($options[$column]) || $options[$column] == '') {
                $errors[$column] = ucwords(strtolower(str_replace('_', ' ', $column))) . ' is required.';
            }
        }
    }
    // Check data type requirements
    if (!empty($data_types)) {
        foreach ($data_types as $column => $type) {
            if (isset($options[$column]) && !isValid($options[$column], $type)) {
                $errors[$column] = ucwords(strtolower(str_replace('_', ' ', $column))) . ' is not valid.';
            }
        }
    }
    return !empty($errors) ? array(601 => $errors) : true;
}
开发者ID:iweave,项目名称:unmark,代码行数:22,代码来源:validation_helper.php

示例13: findStartFinish

function findStartFinish($start, $finish = null)
{
    $start = trim(urldecode($start));
    $start = isValid($start, 'date') === false && isValid($start, 'year') === false ? preg_replace('/\\b\\-\\b/', ' ', $start) : $start;
    $finish = trim(urldecode($finish));
    $finish = isValid($finish, 'date') === false && isValid($finish, 'year') === false ? preg_replace('/\\b\\-\\b/', ' ', $finish) : $finish;
    // check for single year
    if (isValid($start, 'year') === true && isValid($finish, 'year') !== true) {
        $finish = $start . '-12-31';
        $start = $start . '-01-01';
    } elseif (isValid($start, 'year') === true && isValid($finish, 'year') === true) {
        $finish = $finish > $start ? $finish - 1 . '-12-31' : $finish . '-12-31';
        $start = $start . '-01-01';
    } elseif (isValid($start, 'date') === true && isValid($finish, 'date') !== true) {
        $finish = $start;
    }
    /*print strtotime($start) . "<BR>";
      print date('Y-m-d', strtotime($start)) . "<BR>";
      print $finish . "<BR>";
      print strtotime($finish) . "<BR>";
      print date('Y-m-d', strtotime($finish)) . "<BR>";*/
    // Figure start/finish timestamps
    // If empty, assign to today
    $start = strtotime($start);
    $start = empty($start) ? strtotime('today') : $start;
    $finish = strtotime($finish);
    $finish = empty($finish) ? $start : $finish;
    //print date('Y-m-d', $start) . "<BR>";
    //print date('Y-m-d', $finish) . '<BR><br>';
    // Fix ordering if need be
    if ($start > $finish) {
        $s = $start;
        $finish = $start;
        $start = $s;
    }
    // Return
    return array('start' => date('Y-m-d', $start), 'finish' => date('Y-m-d', $finish));
}
开发者ID:iweave,项目名称:unmark,代码行数:38,代码来源:data_helper.php

示例14: create

 public function create($options = array())
 {
     if (!isValid($options['email'], 'email')) {
         return formatErrors(604);
     }
     if (!isValid($options['password'], 'password')) {
         return formatErrors(602);
     }
     // Make sure email does not exist already
     $total = $this->count("email = '" . $options['email'] . "'");
     if ($total > 0) {
         return formatErrors(603);
     }
     // If you made it this far, we need to add the record to the DB
     $options['password'] = generateHash($options['password']);
     $options['created_on'] = date("Y-m-d H:i:s");
     // Create user token
     do {
         $options['user_token'] = generateToken(30) . md5(time());
         $total = $this->count("user_token = '" . $options['user_token'] . "'");
         // If by some freak chance there is a collision
         // Report it
         if ($total > 0) {
             log_message('debug', 'User token collision detected on key of `' . $options['user_token'] . '`');
         }
     } while ($total > 0);
     // Add record
     $q = $this->db->insert_string('users', $options);
     $res = $this->db->query($q);
     // Check for errors
     $this->sendException();
     if ($res === true) {
         $user_id = $this->db->insert_id();
         return $this->read($user_id);
     } else {
         return formatErrors(500);
     }
 }
开发者ID:iweave,项目名称:unmark,代码行数:38,代码来源:users_model.php

示例15: increment

            return false;
        }
        if (!$has3Consecutive) {
            if (ord($char) - ord($prev) === 1) {
                $numConsecutive++;
                if ($numConsecutive >= 3) {
                    $has3Consecutive = true;
                }
            } else {
                $numConsecutive = 1;
            }
        }
        if ($numPairs < 2) {
            if ($char === $prev) {
                $numRepeats++;
                if ($numRepeats % 2 === 1) {
                    $numPairs++;
                }
            } else {
                $numRepeats = 0;
            }
        }
        $prev = $char;
    }
    return $has3Consecutive && $numPairs >= 2;
}
$output = increment($input);
while (!isValid($output)) {
    $output = increment($output);
}
echo 'Answer: ' . $output . PHP_EOL;
开发者ID:ultramega,项目名称:adventofcode2015,代码行数:31,代码来源:part1.php


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