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


PHP sanitize_float函数代码示例

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


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

示例1: check

function check($input, $flags, $min = '', $max = '')
{
    $oldput = $input;
    if ($flags & UTF8) {
        $input = my_utf8_decode($input);
    }
    if ($flags & PARANOID) {
        $input = sanitize_paranoid_string($input, $min, $max);
    }
    if ($flags & INT) {
        $input = sanitize_int($input, $min, $max);
    }
    if ($flags & FLOAT) {
        $input = sanitize_float($input, $min, $max);
    }
    if ($flags & HTML) {
        $input = sanitize_html_string($input, $min, $max);
    }
    if ($flags & LDAP) {
        $input = sanitize_ldap_string($input, $min, $max);
    }
    if ($flags & SYSTEM) {
        $input = sanitize_system_string($input, $min, $max, TRUE);
    }
    if ($input != $oldput) {
        return FALSE;
    }
    return TRUE;
}
开发者ID:portokallidis,项目名称:Metamorphosis-Meducator,代码行数:29,代码来源:sanitize.php

示例2: ProcessCurrentResponses


//.........这里部分代码省略.........
                 }
             }
             $type = $qinfo['info']['type'];
             if ($relevant && $grelevant && $sqrelevant || !$LEM->surveyOptions['deletenonvalues']) {
                 if ($qinfo['info']['hidden'] && !isset($_POST[$sq])) {
                     $value = isset($_SESSION[$LEM->sessid][$sq]) ? $_SESSION[$LEM->sessid][$sq] : '';
                     // if always hidden, use the default value, if any
                 } else {
                     $value = isset($_POST[$sq]) ? $_POST[$sq] : '';
                 }
                 // Check for and adjust ',' and '.' in numbers
                 $isOnlyNum = isset($LEM->knownVars[$sq]['onlynum']) && $LEM->knownVars[$sq]['onlynum'] == '1';
                 if ($radixchange && $isOnlyNum) {
                     // Convert from comma back to decimal
                     // Also make sure to be able to convert numbers like 1.100,10
                     $value = preg_replace('|\\.|', '', $value);
                     $value = preg_replace('|\\,|', '.', $value);
                 } elseif (!$radixchange && $isOnlyNum) {
                     // Still have to remove all ',' introduced by the thousand separator
                     $value = preg_replace('|\\,|', '', $value);
                 }
                 switch ($type) {
                     case 'D':
                         //DATE
                         $value = trim($value);
                         if ($value != "" && $value != "INVALID") {
                             $aAttributes = $LEM->getQuestionAttributesForEM($LEM->sid, $qid, $_SESSION['LEMlang']);
                             if (!isset($aAttributes[$qid])) {
                                 $aAttributes[$qid] = array();
                             }
                             $aDateFormatData = getDateFormatDataForQID($aAttributes[$qid], $LEM->surveyOptions);
                             // We don't really validate date here : if date is invalid : return 1999-12-01 00:00
                             $oDateTimeConverter = new Date_Time_Converter(trim($value), $aDateFormatData['phpdate']);
                             $newValue = $oDateTimeConverter->convert("Y-m-d H:i");
                             $oDateTimeConverter = new Date_Time_Converter($newValue, "Y-m-d H:i");
                             if ($value == $oDateTimeConverter->convert($aDateFormatData['phpdate'])) {
                                 $value = $newValue;
                             } else {
                                 $value = "";
                                 // Or $value="INVALID" ? : dropdown is OK with this not default.
                             }
                         }
                         break;
                         #                            case 'N': //NUMERICAL QUESTION TYPE
                         #                            case 'K': //MULTIPLE NUMERICAL QUESTION
                         #                                if (trim($value)=="") {
                         #                                    $value = "";
                         #                                }
                         #                                else {
                         #                                    $value = sanitize_float($value);
                         #                                }
                         break;
                     case '|':
                         //File Upload
                         if (!preg_match('/_filecount$/', $sq)) {
                             $json = $value;
                             $phparray = json_decode(stripslashes($json));
                             // if the files have not been saved already,
                             // move the files from tmp to the files folder
                             $tmp = $LEM->surveyOptions['tempdir'] . 'upload' . DIRECTORY_SEPARATOR;
                             if (!is_null($phparray) && count($phparray) > 0) {
                                 // Move the (unmoved, temp) files from temp to files directory.
                                 // Check all possible file uploads
                                 for ($i = 0; $i < count($phparray); $i++) {
                                     if (file_exists($tmp . $phparray[$i]->filename)) {
                                         $sDestinationFileName = 'fu_' . randomChars(15);
                                         if (!is_dir($LEM->surveyOptions['target'])) {
                                             mkdir($LEM->surveyOptions['target'], 0777, true);
                                         }
                                         if (!rename($tmp . $phparray[$i]->filename, $LEM->surveyOptions['target'] . $sDestinationFileName)) {
                                             echo "Error moving file to target destination";
                                         }
                                         $phparray[$i]->filename = $sDestinationFileName;
                                     }
                                 }
                                 $value = ls_json_encode($phparray);
                                 // so that EM doesn't try to parse it.
                             }
                         }
                         break;
                 }
                 $_SESSION[$LEM->sessid][$sq] = $value;
                 $_update = array('type' => $type, 'value' => $value);
                 $updatedValues[$sq] = $_update;
                 $LEM->updatedValues[$sq] = $_update;
             } else {
                 // irrelevant, so database will be NULLed separately
                 // Must unset the value, rather than setting to '', so that EM can re-use the default value as needed.
                 unset($_SESSION[$LEM->sessid][$sq]);
                 $_update = array('type' => $type, 'value' => NULL);
                 $updatedValues[$sq] = $_update;
                 $LEM->updatedValues[$sq] = $_update;
             }
         }
     }
     if (isset($_POST['timerquestion'])) {
         $_SESSION[$LEM->sessid][$_POST['timerquestion']] = sanitize_float($_POST[$_POST['timerquestion']]);
     }
     return $updatedValues;
 }
开发者ID:GuillaumeSmaha,项目名称:LimeSurvey,代码行数:101,代码来源:em_manager_helper.php

示例3: sanitize

function sanitize($input, $type, $default = null, $more = null)
{
    #
    # if we get a null in, always return a null
    #
    if ($type == 'isset') {
        return isset($input);
    }
    if (!isset($input)) {
        return $default;
    }
    switch ($type) {
        case 'str':
            return sanitize_string($input, false);
        case 'str_multi':
            return sanitize_string($input, true);
        case 'int32':
            return sanitize_int32($input);
        case 'int64':
            return sanitize_int64($input);
        case 'float':
            return sanitize_float($input);
        case 'html':
            # this needs to do class_exists('lib_filter')
            die("not implemented");
        case 'bool':
            return $input ? true : false;
        case 'rx':
            if (preg_match($more, $input)) {
                return $input;
            }
            return $default;
        case 'in':
            foreach ($more as $match) {
                if ($input === $match) {
                    return $input;
                }
            }
            return $default;
    }
    die("Unknown data conversion type: {$type}");
}
开发者ID:jacques,项目名称:flamework,代码行数:42,代码来源:lib_sanitize.php

示例4: ProcessCurrentResponses

 /**
  * Cleanse the $_POSTed data and update $_SESSION variables accordingly
  */
 static function ProcessCurrentResponses()
 {
     $LEM =& LimeExpressionManager::singleton();
     if (!isset($LEM->currentQset)) {
         return array();
     }
     $updatedValues = array();
     $radixchange = $LEM->surveyOptions['radix'] == ',' ? true : false;
     foreach ($LEM->currentQset as $qinfo) {
         $relevant = false;
         $qid = $qinfo['info']['qid'];
         $gseq = $qinfo['info']['gseq'];
         $relevant = isset($_POST['relevance' . $qid]) ? $_POST['relevance' . $qid] == 1 : false;
         $grelevant = isset($_POST['relevanceG' . $gseq]) ? $_POST['relevanceG' . $gseq] == 1 : false;
         $_SESSION[$LEM->sessid]['relevanceStatus'][$qid] = $relevant;
         $_SESSION[$LEM->sessid]['relevanceStatus']['G' . $gseq] = $grelevant;
         foreach (explode('|', $qinfo['sgqa']) as $sq) {
             $sqrelevant = true;
             if (isset($LEM->subQrelInfo[$qid][$sq]['rowdivid'])) {
                 $rowdivid = $LEM->subQrelInfo[$qid][$sq]['rowdivid'];
                 if ($rowdivid != '' && isset($_POST['relevance' . $rowdivid])) {
                     $sqrelevant = $_POST['relevance' . $rowdivid] == 1;
                     $_SESSION[$LEM->sessid]['relevanceStatus'][$rowdivid] = $sqrelevant;
                 }
             }
             $type = $qinfo['info']['type'];
             if ($relevant && $grelevant && $sqrelevant) {
                 if ($qinfo['info']['hidden'] && !isset($_POST[$sq])) {
                     $value = isset($_SESSION[$LEM->sessid][$sq]) ? $_SESSION[$LEM->sessid][$sq] : '';
                     // if always hidden, use the default value, if any
                 } else {
                     $value = isset($_POST[$sq]) ? $_POST[$sq] : '';
                 }
                 if ($radixchange && isset($LEM->knownVars[$sq]['onlynum']) && $LEM->knownVars[$sq]['onlynum'] == '1') {
                     // convert from comma back to decimal
                     $value = implode('.', explode(',', $value));
                 }
                 switch ($type) {
                     case 'D':
                         //DATE
                         if (trim($value) == "") {
                             $value = "";
                         } else {
                             $dateformatdatat = getDateFormatData($LEM->surveyOptions['surveyls_dateformat']);
                             $datetimeobj = new Date_Time_Converter($value, $dateformatdatat['phpdate']);
                             $value = $datetimeobj->convert("Y-m-d");
                         }
                         break;
                     case 'N':
                         //NUMERICAL QUESTION TYPE
                     //NUMERICAL QUESTION TYPE
                     case 'K':
                         //MULTIPLE NUMERICAL QUESTION
                         if (trim($value) == "") {
                             $value = "";
                         } else {
                             $value = sanitize_float($value);
                         }
                         break;
                     case '|':
                         //File Upload
                         if (!preg_match('/_filecount$/', $sq)) {
                             $json = $value;
                             $phparray = json_decode(stripslashes($json));
                             // if the files have not been saved already,
                             // move the files from tmp to the files folder
                             $tmp = $LEM->surveyOptions['tempdir'] . 'upload' . DIRECTORY_SEPARATOR;
                             if (!is_null($phparray) && count($phparray) > 0) {
                                 // Move the (unmoved, temp) files from temp to files directory.
                                 // Check all possible file uploads
                                 for ($i = 0; $i < count($phparray); $i++) {
                                     if (file_exists($tmp . $phparray[$i]->filename)) {
                                         $sDestinationFileName = 'fu_' . randomChars(15);
                                         if (!is_dir($LEM->surveyOptions['target'])) {
                                             mkdir($LEM->surveyOptions['target'], 0777, true);
                                         }
                                         if (!rename($tmp . $phparray[$i]->filename, $LEM->surveyOptions['target'] . $sDestinationFileName)) {
                                             echo "Error moving file to target destination";
                                         }
                                         $phparray[$i]->filename = $sDestinationFileName;
                                     }
                                 }
                                 $value = ls_json_encode($phparray);
                                 // so that EM doesn't try to parse it.
                             }
                         }
                         break;
                 }
                 $_SESSION[$LEM->sessid][$sq] = $value;
                 $_update = array('type' => $type, 'value' => $value);
                 $updatedValues[$sq] = $_update;
                 $LEM->updatedValues[$sq] = $_update;
             } else {
                 // irrelevant, so database will be NULLed separately
                 // Must unset the value, rather than setting to '', so that EM can re-use the default value as needed.
                 unset($_SESSION[$LEM->sessid][$sq]);
                 $_update = array('type' => $type, 'value' => NULL);
//.........这里部分代码省略.........
开发者ID:rawaludin,项目名称:LimeSurvey,代码行数:101,代码来源:em_manager_helper.php

示例5: sanitize

function sanitize($input, $flags, $min = '', $max = '')
{
    if ($flags & UTF8) {
        $input = my_utf8_decode($input);
    }
    if ($flags & PARANOID) {
        $input = sanitize_paranoid_string($input, $min, $max);
    }
    if ($flags & INT) {
        $input = sanitize_int($input, $min, $max);
    }
    if ($flags & FLOAT) {
        $input = sanitize_float($input, $min, $max);
    }
    if ($flags & HTML) {
        $input = sanitize_html_string($input, $min, $max);
    }
    if ($flags & SQL) {
        $input = sanitize_sql_string($input, $min, $max);
    }
    if ($flags & LDAP) {
        $input = sanitize_ldap_string($input, $min, $max);
    }
    if ($flags & SYSTEM) {
        $input = sanitize_system_string($input, $min, $max);
    }
    return $input;
}
开发者ID:killich,项目名称:JustFrame,代码行数:28,代码来源:sanitize_fu.php


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