宝马娱乐在线112222 > 网络应用 > 通达OA公共代码 php常用检测函数

原标题:通达OA公共代码 php常用检测函数

浏览次数:167 时间:2019-10-01

日期比较如 2011-11-11  2011-12-12

check_type.php(使用类型检验函数)

 代码如下

复制代码 代码如下:

function compare_date( $DATE1, $DATE2 )
{
        $STR = strtok( $DATE1, "-" );
        $YEAR1 = $STR;
        $STR = strtok( "-" );
        $MON1 = $STR;
        $STR = strtok( "-" );
        $DAY1 = $STR;
        $STR = strtok( $DATE2, "-" );
        $YEAR2 = $STR;
        $STR = strtok( "-" );
        $MON2 = $STR;
        $STR = strtok( "-" );
        $DAY2 = $STR;
        if ( $YEAR2 < $YEAR1 )
        {
                return 1;
        }
        if ( $YEAR1 < $YEAR2 )
        {
                return -1;
        }
        if ( $MON2 < $MON1 )
        {
                return 1;
        }
        if ( $MON1 < $MON2 )
        {
                return -1;
        }
        if ( $DAY2 < $DAY1 )
        {
                return 1;
        }
        if ( $DAY1 < $DAY2 )
        {
                return -1;
        }
        return 0;
}

<?php
/*********************/
/* */
/* Version : 5.1.0 */
/* Author : RM */
/* Comment : 071223 */
/* */
/*********************/
function is_number( $str )
{
if ( substr( $str, 0, 1 ) == "-" )
{
$str = substr( $str, 1 );
}
$length = strlen( $str );
$i = 0;
for ( ; $i < $length; ++$i )
{
$ascii_value = ord( substr( $str, $i, 1 ) );
if ( 48 <= $ascii_value && $ascii_value <= 57 )
{
continue;
}
return FALSE;
}
if ( $str != "0" )
{
$str = intval( $str );
if ( $str == 0 )
{
return FALSE;
}
}
return TRUE;
}
function is_decimal( $str )
{
if ( substr( $str, 0, 1 ) == "-" )
{
$str = substr( $str, 1 );
}
$length = strlen( $str );
$i = 0;
for ( ; $i < $length; ++$i )
{
$ascii_value = ord( substr( $str, $i, 1 ) );
if ( 0 < $i && $ascii_value == 46 || 48 <= $ascii_value && $ascii_value <= 57 )
{
continue;
}
return FALSE;
}
return TRUE;
}
function is_money( $str )
{
$dot_pos = strpos( $str, "." );
if ( !$dot_pos )
{
return FALSE;
}
$str1 = substr( $str, 0, $dot_pos );
if ( 14 < strlen( $str1 ) )
{
return FALSE;
}
if ( !is_number( $str1 ) )
{
return FALSE;
}
$str2 = substr( $str, $dot_pos + 1, strlen( $str ) - $dot_pos );
if ( strlen( $str2 ) != 2 )
{
return FALSE;
}
if ( !is_number( $str2 ) )
{
return FALSE;
}
return TRUE;
}
function is_money_len( $str, $int_len, $dot_len )
{
$dot_pos = strpos( $str, "." );
if ( !$dot_pos )
{
return FALSE;
}
$str1 = substr( $str, 0, $dot_pos );
if ( $int_len < strlen( $str1 ) )
{
return FALSE;
}
if ( !is_number( $str1 ) )
{
return FALSE;
}
$str2 = substr( $str, $dot_pos + 1, strlen( $str ) - $dot_pos );
if ( strlen( $str2 ) != $dot_len )
{
return FALSE;
}
if ( !is_number( $str2 ) )
{
return FALSE;
}
return TRUE;
}
function is_date( $str )
{
$YEAR = "";
$MONTH = "";
$DAY = "";
$len = strlen( $str );
$offset = 0;
$i = strpos( $str, "-", $offset );
$YEAR = substr( $str, $offset, $i - $offset );
$offset = $i + 1;
if ( $len < $offset )
{
return FALSE;
}
if ( $i )
{
$i = strpos( $str, "-", $offset );
$MONTH = substr( $str, $offset, $i - $offset );
$offset = $i + 1;
if ( $len < $offset )
{
return FALSE;
}
if ( $i )
{
$DAY = substr( $str, $offset, $len - $offset );
}
}
if ( $YEAR == "" || $MONTH == "" || $DAY == "" )
{
return FALSE;
}
if ( !checkdate( intval( $MONTH ), intval( $DAY ), intval( $YEAR ) ) )
{
return FALSE;
}
return TRUE;
}
function is_time( $str )
{
$TEMP = "";
$HOUR = "";
$MIN = "";
$SEC = "";
$TEMP = strtok( $str, ":" );
$HOUR = $TEMP;
if ( $HOUR == "" || 24 <= $HOUR || $HOUR < 0 || !is_number( $HOUR ) )
{
return FALSE;
}
$TEMP = strtok( ":" );
$MIN = $TEMP;
if ( $MIN == "" || 60 <= $MIN || $MIN < 0 || !is_number( $MIN ) )
{
return FALSE;
}
$TEMP = strtok( ":" );
$SEC = $TEMP;
if ( $SEC == "" || 60 <= $SEC || $SEC < 0 || !is_number( $SEC ) )
{
return FALSE;
}
return TRUE;
}
function is_date_time( $DATE_TIME_STR )
{
if ( $DATE_TIME_STR == NULL || strlen( $DATE_TIME_STR ) == 0 )
{
return FALSE;
}
$DATE_TIME_ARRY = explode( " ", $DATE_TIME_STR );
if ( is_date( $DATE_TIME_ARRY[0] ) && is_time( $DATE_TIME_ARRY[1] ) )
{
return TRUE;
}
return FALSE;
}
?>

格式:12.00 -13.11

auth.php登录验证

 代码如下

复制代码 代码如下:

function compare_time( $TIME1, $TIME2 )
{
        $STR = strtok( $TIME1, ":" );
        $HOUR1 = $STR;
        $STR = strtok( ":" );
        $MIN1 = $STR;
        $STR = strtok( ":" );
        $SEC1 = $STR;
        $STR = strtok( $TIME2, ":" );
        $HOUR2 = $STR;
        $STR = strtok( ":" );
        $MIN2 = $STR;
        $STR = strtok( ":" );
        $SEC2 = $STR;
        if ( $HOUR2 < $HOUR1 )
        {
                return 1;
        }
        if ( $HOUR1 < $HOUR2 )
        {
                return -1;
        }
        if ( $MIN2 < $MIN1 )
        {
                return 1;
        }
        if ( $MIN1 < $MIN2 )
        {
                return -1;
        }
        if ( $SEC2 < $SEC1 )
        {
                return 1;
        }
        if ( $SEC1 < $SEC2 )
        {
                return -1;
        }
        return 0;
}

<?php
/*********************/
/* */
/* Version : 5.1.0 */
/* Author : RM */
/* Comment : 071223 */
/* */
/*********************/
if ( $USER_ID == "" || $PASSWORD == "" )
{
echo "201#|#用户名或密码为空";
exit( );
}
if ( $USER_ID != "OfficeTask" )
{
echo "205#|#用户名错误";
exit( );
}
include_once( "../inc/conn.php" );
include_once( "../inc/utility.php" );
ob_end_clean( );
$query = "select * from EXT_USER where USER_ID='".$USER_ID."'";
$cursor = exequery( $connection, $query );
if ( $ROW = mysql_fetch_array( $cursor ) )
{
$PWD = $ROW['PASSWORD'];
$USE_FLAG = $ROW['USE_FLAG'];
$AUTH_MODULE = $ROW['AUTH_MODULE'];
$POSTFIX = $ROW['POSTFIX'];
if ( md5( $PWD ) != $PASSWORD )
{
echo "203#|#密码错误";
exit( );
}
if ( $USE_FLAG == "0" )
{
echo "204#|#帐号已停用";
exit( );
}
}
else
{
echo "202#|#".$USER_ID;
exit( );
}
?>

本文由宝马娱乐在线112222发布于网络应用,转载请注明出处:通达OA公共代码 php常用检测函数

关键词:

上一篇:php中英数字混排的字符串分割代码【宝马娱乐在

下一篇:没有了