Home > php教程 > php手册 > 通达OA公共代码 php常用检测函数

通达OA公共代码 php常用检测函数

WBOY
Release: 2016-06-06 20:39:23
Original
1033 people have browsed it

从通达OA公共代码扒下的php常用检测函数代码,学习php的朋友可以参考下。

check_type.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 {
$ascii_value = ord( substr( $str, $i, 1 ) );
if ( 48 {
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 {
$ascii_value = ord( substr( $str, $i, 1 ) );
if ( 0 {
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 {
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 {
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 {
return FALSE;
}
if ( $i )
{
$i = strpos( $str, "-", $offset );
$MONTH = substr( $str, $offset, $i - $offset );
$offset = $i + 1;
if ( $len {
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 {
return FALSE;
}
$TEMP = strtok( ":" );
$MIN = $TEMP;
if ( $MIN == "" || 60 {
return FALSE;
}
$TEMP = strtok( ":" );
$SEC = $TEMP;
if ( $SEC == "" || 60 {
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;
}
?>

auth.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( );
}
?>

utility_all公用函数
代码如下:
/*********************/
/* */
/* Version : 5.1.0 */
/* Author : RM */
/* Comment : 071223 */
/* */
/*********************/
function format_date( $STRING1 )
{
$STRING1 = str_replace( "-0", "-", $STRING1 );
$STR = strtok( $STRING1, "-" );
$STRING2 = $STR."年";
$STR = strtok( "-" );
$STRING2 .= $STR."月";
$STR = strtok( " " );
$STRING2 .= $STR."日";
return $STRING2;
}
function format_date_short1( $STRING1 )
{
$STRING1 = str_replace( "-0", "-", $STRING1 );
$STR = strtok( $STRING1, "-" );
$STRING2 = $STR."年";
$STR = strtok( "-" );
$STRING2 .= $STR."月";
return $STRING2;
}
function format_date_short2( $STRING1 )
{
$STRING1 = str_replace( "-0", "-", $STRING1 );
$STR = strtok( $STRING1, "-" );
$STR = strtok( "-" );
$STRING2 .= $STR."月";
$STR = strtok( " " );
$STRING2 .= $STR."日";
return $STRING2;
}
function format_date_short3( $STRING1 )
{
$STRING1 = str_replace( "-0", "-", $STRING1 );
$STR = strtok( $STRING1, "-" );
$STRING2 .= $STR."年";
return $STRING2;
}
function format_date_number( $STRING1 )
{
$STRING1 = str_replace( "-0", "-", $STRING1 );
$STR = strtok( $STRING1, "-" );
$STRING2 = $STR;
$STR = strtok( "-" );
$STRING2 .= strlen( $STR ) == 1 ? "0".$STR : $STR;
$STR = strtok( " " );
$STRING2 .= strlen( $STR ) == 1 ? "0".$STR : $STR;
return $STRING2;
}
function get_week( $STRING )
{
switch ( date( "w", strtotime( $STRING ) ) )
{
case 0 :
return "日";
case 1 :
return "一";
case 2 :
return "二";
case 3 :
return "三";
case 4 :
return "四";
case 5 :
return "五";
case 6 :
return "六";
}
}
function format_money( $STR )
{
if ( $STR == "" )
{
return "";
}
if ( $STR == ".00" )
{
return "0.00";
}
$TOK = strtok( $STR, "." );
if ( strcmp( $STR, $TOK ) == "0" )
{
$STR .= ".00";
}
else
{
$TOK = strtok( "." );
$I = 1;
for ( ; $I {
$STR .= "0";
}
}
if ( substr( $STR, 0, 1 ) == "." )
{
$STR = "0".$STR;
}
return $STR;
}
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 {
return 1;
}
if ( $YEAR1 {
return -1;
}
if ( $MON2 {
return 1;
}
if ( $MON1 {
return -1;
}
if ( $DAY2 {
return 1;
}
if ( $DAY1 {
return -1;
}
return 0;
}
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 {
return 1;
}
if ( $HOUR1 {
return -1;
}
if ( $MIN2 {
return 1;
}
if ( $MIN1 {
return -1;
}
if ( $SEC2 {
return 1;
}
if ( $SEC1 {
return -1;
}
return 0;
}
function compare_date_time( $DATE_TIME1, $DATE_TIME2 )
{
if ( $DATE_TIME1 == NULL || strlen( $DATE_TIME1 ) == 0 || $DATE_TIME2 == NULL || strlen( $DATE_TIME2 ) == 0 )
{
return -1;
}
$DATE_TIME1_ARRY = explode( " ", $DATE_TIME1 );
$DATE_TIME2_ARRY = explode( " ", $DATE_TIME2 );
if ( compare_date( $DATE_TIME1_ARRY[0], $DATE_TIME2_ARRY[0] ) == 1 )
{
return 1;
}
if ( compare_date( $DATE_TIME1_ARRY[0], $DATE_TIME2_ARRY[0] ) == 0 )
{
if ( compare_time( $DATE_TIME1_ARRY[1], $DATE_TIME2_ARRY[1] ) == 1 )
{
return 1;
}
if ( compare_time( $DATE_TIME1_ARRY[1], $DATE_TIME2_ARRY[1] ) == 0 )
{
return 0;
}
return -1;
}
return -1;
}
function is_chinese( &$str, $location )
{
$ch = TRUE;
$i = $location;
while ( 160 {
$ch = !$ch;
--$i;
}
if ( $i != $location )
{
$f_str = $ch ? 1 : -1;
return $f_str;
}
$f_str = FALSE;
return $f_str;
}
function csubstr( &$str, $start = 0, $long = 0, $ltor = TRUE, $cn_len = 2 )
{
if ( $long == 0 )
{
$long = strlen( $str );
}
if ( !$ltor )
{
$str = cstrrev( $str );
}
if ( $cn_len == 1 )
{
$i = 0;
$fs = 0;
for ( ; $i {
$i += ord( $str[$fs] ) }
$i = 0;
$fe = $fs;
for ( ; $i {
$i += ord( $str[$fe] ) }
$long = $fe - $fs;
}
else
{
$fs = is_chinese( &$str, $start ) == 1 ? $start - 1 : $start;
$fe = $long + $start - 1;
$end = is_chinese( &$str, $fe ) == -1 ? $fe - 1 : $fe;
$long = $end - $fs + 1;
}
$f_str = substr( $str, $fs, $long );
if ( !$ltor )
{
$f_str = cstrrev( $f_str );
}
return $f_str;
}
function is_ip( $IP )
{
$IP_ARRAY = explode( ".", $IP );
$IP_ARRAY_NUM = sizeof( $IP_ARRAY );
if ( $IP_ARRAY_NUM != 4 )
{
return FALSE;
}
$I = 0;
for ( ; $I {
if ( !is_numeric( $IP_ARRAY[$I] ) && $IP_ARRAY[$I] {
return FALSE;
}
if ( !( $I == 3 ) && !( $IP_ARRAY[$I] == 255 ) )
{
continue;
}
return FALSE;
}
return TRUE;
}
function check_ip( $USER_IP, $TYPE, $USER_ID )
{
global $connection;
$query = "SELECT PARA_VALUE from SYS_PARA where PARA_NAME='IP_UNLIMITED_USER'";
$cursor = exequery( $connection, $query );
if ( $ROW = mysql_fetch_array( $cursor ) )
{
$IP_UNLIMITED_USER = $ROW['PARA_VALUE'];
}
if ( find_id( $IP_UNLIMITED_USER, $USER_ID ) )
{
return TRUE;
}
$query = "select * from IP_RULE where TYPE='".$TYPE."'";
$cursor = exequery( $connection, $query );
$RULE_COUNT = 0;
$FLAG = 0;
while ( $ROW = mysql_fetch_array( $cursor ) )
{
++$RULE_COUNT;
$BEGIN_IP = $ROW['BEGIN_IP'];
$END_IP = $ROW['END_IP'];
if ( !( ip2long( $BEGIN_IP ) {
continue;
}
$FLAG = 1;
break;
}
if ( $RULE_COUNT == 0 || $FLAG == 1 )
{
return TRUE;
}
return FALSE;
}
function maskstr( $STR, $FIRST, $LAST )
{
if ( is_numeric( $FIRST ) )
{
}
if ( !is_numeric( $LAST ) )
{
return;
}
if ( strlen( $STR ) {
return $STR;
}
$RETURN_STR = substr( $STR, 0, $FIRST );
$I = 0;
for ( ; $I {
$RETURN_STR .= "*";
}
$RETURN_STR .= substr( $STR, 0 - $LAST );
return $RETURN_STR;
}
function add_log( $TYPE, $REMARK, $OPERATOR )
{
global $connection;
$CUR_TIME = date( "Y-m-d H:i:s", time( ) );
$USER_IP = get_client_ip( );
if ( $TYPE == 1 )
{
$query = "update USER set LAST_VISIT_IP='".$USER_IP."' where USER_ID='{$OPERATOR}'";
exequery( $connection, $query );
}
else
{
if ( $TYPE == 3 || $TYPE == 4 || $TYPE == 5 )
{
include_once( "inc/itask/itask.php" );
global $DEPT_PARENT;
if ( $TYPE == 3 || $TYPE == 4 )
{
$result = itask( array(
"LOG_".$TYPE." ".$REMARK.",".$DEPT_PARENT
) );
}
$query = "SELECT DEPT_ID,DEPT_NAME from DEPARTMENT where DEPT_ID='".$REMARK."'";
$cursor = exequery( $connection, $query );
if ( $ROW = mysql_fetch_array( $cursor ) )
{
$DEPT_ID = $ROW['DEPT_ID'];
$DEPT_NAME = $ROW['DEPT_NAME'];
}
$REMARK = "{$DEPT_NAME},DEPT_ID={$DEPT_ID},DEPT_PARENT={$DEPT_PARENT}";
if ( $result === FALSE )
{
message( "错误", itask_last_error( ) );
button_back( );
exit( );
}
}
else if ( $TYPE == 6 || $TYPE == 7 || $TYPE == 8 || $TYPE == 11 )
{
include_once( "inc/itask/itask.php" );
global $DEPT_ID;
global $NOT_LOGIN;
if ( $TYPE == 6 || $TYPE == 7 )
{
$result = itask( array(
"LOG_".$TYPE." ".$REMARK.",".$DEPT_ID.",".$NOT_LOGIN
) );
}
$query = "SELECT USER_ID,USER_NAME,DEPT_ID from USER where find_in_set(USER_ID,'".$REMARK."')";
$cursor = exequery( $connection, $query );
$REMARK = "";
while ( $ROW = mysql_fetch_array( $cursor ) )
{
$USER_ID = $ROW['USER_ID'];
$USER_NAME = $ROW['USER_NAME'];
$DEPT_ID = $ROW['DEPT_ID'];
$query = "SELECT DEPT_NAME from DEPARTMENT where DEPT_ID='".$DEPT_ID."'";
$cursor1 = exequery( $connection, $query );
if ( $ROW = mysql_fetch_array( $cursor1 ) )
{
$DEPT_NAME = $ROW['DEPT_NAME'];
}
$REMARK .= "[".$DEPT_NAME."]{$USER_NAME},USER_ID={$USER_ID}
";
}
if ( $result === FALSE )
{
message( "错误", itask_last_error( ) );
button_back( );
exit( );
}
}
}
$REMARK = str_replace( "'", "\\'", $REMARK );
$REMARK = str_replace( "\\\\'", "\\'", $REMARK );
$query = "insert into SYS_LOG (USER_ID,TIME,IP,TYPE,REMARK) values ('".$OPERATOR."','{$CUR_TIME}','{$USER_IP}','{$TYPE}','{$REMARK}')";
exequery( $connection, $query );
if ( 21 {
$query1 = "INSERT INTO `SYS_CODE` ( `CODE_NO` , `CODE_NAME` , `CODE_ORDER` , `PARENT_NO` , `CODE_FLAG` ) VALUES ('".$TYPE."', '未知类型', '99', 'SYS_LOG', '1');";
exequery( $connection, $query1 );
}
return $query;
}
function affair_sms( )
{
include_once( "inc/utility_sms1.php" );
global $connection;
global $LOGIN_USER_ID;
$CUR_DATE = date( "Y-m-d", time( ) );
$CUR_TIME = date( "Y-m-d H:i:s", time( ) );
$query = "SELECT * from AFFAIR where USER_ID='".$LOGIN_USER_ID."' and BEGIN_TIME $cursor = exequery( $connection, $query );
while ( $ROW = mysql_fetch_array( $cursor ) )
{
$AFF_ID = $ROW['AFF_ID'];
$USER_ID = $ROW['USER_ID'];
$TYPE = $ROW['TYPE'];
$REMIND_DATE = $ROW['REMIND_DATE'];
$REMIND_TIME = $ROW['REMIND_TIME'];
$CONTENT = $ROW['CONTENT'];
$SEND_TIME = date( "Y-m-d", time( ) )." ".$REMIND_TIME;
$SMS_CONTENT = "日常事务提醒:".csubstr( &$CONTENT, 0, 100 );
$FLAG = 0;
if ( $TYPE == "2" )
{
$FLAG = 1;
}
else if ( $TYPE == "3" && date( "w", time( ) ) == $REMIND_DATE )
{
$FLAG = 1;
}
else if ( $TYPE == "4" && date( "j", time( ) ) == $REMIND_DATE )
{
$FLAG = 1;
}
else if ( $TYPE == "5" )
{
$REMIND_ARR = explode( "-", $REMIND_DATE );
$REMIND_DATE_MON = $REMIND_ARR[0];
$REMIND_DATE_DAY = $REMIND_ARR[1];
if ( date( "n", time( ) ) == $REMIND_DATE_MON && date( "j", time( ) ) == $REMIND_DATE_DAY )
{
$FLAG = 1;
}
}
if ( $FLAG == 1 )
{
send_sms( $SEND_TIME, $LOGIN_USER_ID, $LOGIN_USER_ID, 5, $SMS_CONTENT, "1:calendar/affair/note.php?AFF_ID=".$AFF_ID );
$query = "update AFFAIR set LAST_REMIND='".$CUR_DATE."' where AFF_ID='{$AFF_ID}'";
exequery( $connection, $query );
}
}
}
function get_code_name( $CODE_NO, $PARENT_NO )
{
if ( $CODE_NO == "" || $PARENT_NO == "" )
{
return "";
}
global $connection;
$query = "SELECT CODE_NAME from SYS_CODE where PARENT_NO='".$PARENT_NO."' and find_in_set(CODE_NO,'{$CODE_NO}')";
$cursor = exequery( $connection, $query );
while ( $ROW = mysql_fetch_array( $cursor ) )
{
$CODE_NAME .= $ROW['CODE_NAME'].",";
}
return substr( $CODE_NAME, 0, -2 );
}
function code_list( $PARENT_NO, $SELECTED = "", $TYPE = "D", $FIELD_NAME = "" )
{
if ( $PARENT_NO == "" )
{
return;
}
global $connection;
$query = "select CODE_NO,CODE_NAME from SYS_CODE where PARENT_NO='".$PARENT_NO."' order by CODE_ORDER";
$cursor = exequery( $connection, $query );
while ( $ROW = mysql_fetch_array( $cursor ) )
{
$CODE_NO = $ROW['CODE_NO'];
$CODE_NAME = $ROW['CODE_NAME'];
if ( $TYPE == "D" )
{
$OPTION_STR .= "\n";
}
else if ( $TYPE == "R" )
{
$OPTION_STR .= "if ( $CODE_NO == $SELECTED )
{
$OPTION_STR .= " checked";
}
$OPTION_STR .= ">\n";
}
else if ( $TYPE == "C" )
{
$OPTION_STR .= "if ( find_id( $SELECTED, $CODE_NO ) )
{
$OPTION_STR .= " checked";
}
$OPTION_STR .= ">\n";
}
}
return $OPTION_STR;
}
function get_code_array( $PARENT_NO, $REVERSE = FALSE )
{
$CODE_ARRAY = array( );
if ( $PARENT_NO == "" )
{
return $CODE_ARRAY;
}
global $connection;
$query = "select CODE_NO,CODE_NAME from SYS_CODE where PARENT_NO='".$PARENT_NO."' order by CODE_ORDER";
$cursor = exequery( $connection, $query );
while ( $ROW = mysql_fetch_array( $cursor ) )
{
$CODE_NO = $ROW['CODE_NO'];
$CODE_NAME = $ROW['CODE_NAME'];
if ( !$REVERSE )
{
$CODE_ARRAY[$CODE_NO] = $CODE_NAME;
}
else
{
$CODE_ARRAY[$CODE_NAME] = $CODE_NO;
}
}
return $CODE_ARRAY;
}
function sms_type_url( $SMS_TYPE, $CONTENT )
{
switch ( $SMS_TYPE )
{
case "0" :
$URL = "/general/sms/receive/";
return $URL;
case "1" :
$URL = "/general/notify/show/";
return $URL;
case "2" :
$URL = "/general/email/inbox/?BOX_ID=0";
return $URL;
case "3" :
$URL = "/general/netmeeting/";
return $URL;
case "4" :
$URL = "/general/salary/report/";
return $URL;
case "5" :
$URL = "/general/calendar/";
return $URL;
case "6" :
if ( strstr( $CONTENT, "提交" ) && strstr( $CONTENT, "申请" ) && strstr( $CONTENT, "请批示" ) )
{
$URL = "/general/attendance/manage/";
return $URL;
}
$URL = "/general/attendance/personal/";
return $URL;
case "7" :
$URL = "/general/workflow/list";
return $URL;
case "8" :
$URL = "/general/meeting/manage/";
return $URL;
case "9" :
if ( strstr( $CONTENT, "提交" ) )
{
if ( strstr( $CONTENT, "申请" ) )
{
}
}
if ( strstr( $CONTENT, "请批示" ) || strstr( $CONTENT, "部门领导" ) && strstr( $CONTENT, "批准了" ) )
{
$URL = "/general/vehicle/checkup/";
return $URL;
}
if ( strstr( $CONTENT, "部门审批" ) )
{
$URL = "/general/vehicle/dept_manage/";
return $URL;
}
$URL = "/general/vehicle/";
return $URL;
case "10" :
$URL = "/general/mobile_sms/";
return $URL;
case "11" :
$URL = "/general/vote/show/";
return $URL;
case "12" :
$URL = "/general/work_plan/show/";
return $URL;
case "13" :
$URL = "/general/diary/";
return $URL;
case "14" :
$URL = "/general/news/show/";
return $URL;
case "15" :
$URL = "/general/score/submit/";
return $URL;
case "16" :
$URL = "/general/file_folder/index1.php";
return $URL;
case "17" :
$URL = "/general/netdisk";
return $URL;
case "18" :
$URL = "/general/bbs";
return $URL;
case "20" :
$URL = "/general/file_folder?FILE_SORT=2&SORT_ID=0";
return $URL;
case "30" :
$URL = "/general/training/manage/show";
return $URL;
case "31" :
if ( strstr( $CONTENT, "批准了" ) || strstr( $CONTENT, "未批准" ) || strstr( $CONTENT, "撤销了" ) )
{
$URL = "/general/training/train/apply/";
return $URL;
}
$URL = "/general/training/manage/apply_manage/";
return $URL;
case "32" :
$URL = "/general/training/train/survey/";
return $URL;
case "33" :
$URL = "/general/training/train/information/";
return $URL;
case "34" :
$URL = "/general/training/train/assessment/";
return $URL;
case "35" :
$URL = "/general/hrms/manage/";
}
return $URL;
}
function avatar_size( $AVATAR )
{
global $ROOT_PATH;
global $connection;
global $AVATAR_WIDTH;
global $AVATAR_HEIGHT;
$FILENAME = $ROOT_PATH."images/avatar/".$AVATAR.".gif";
if ( !$AVATAR_WIDTH && !$AVATAR_HEIGHT )
{
$query = "SELECT AVATAR_WIDTH,AVATAR_HEIGHT from INTERFACE";
$cursor = exequery( $connection, $query );
if ( $ROW = mysql_fetch_array( $cursor ) )
{
$AVATAR_WIDTH = $ROW['AVATAR_WIDTH'];
$AVATAR_HEIGHT = $ROW['AVATAR_HEIGHT'];
}
}
$IMG_ATTR = @getimagesize( $FILENAME );
if ( $AVATAR_WIDTH {
$IMG_ATTR[0] = $AVATAR_WIDTH;
}
if ( $AVATAR_HEIGHT {
$IMG_ATTR[1] = $AVATAR_HEIGHT;
}
if ( $IMG_ATTR[0] {
$IMG_ATTR[0] = 15;
}
if ( $IMG_ATTR[1] {
$IMG_ATTR[1] = 15;
}
return "width=\"".$IMG_ATTR['0']."\" height=\"{$IMG_ATTR['1']}\"";
}
function format_cvs( $STR )
{
$STR = str_replace( "\"", "", $STR );
$STR = str_replace( "\n", "", $STR );
$STR = str_replace( "\r", "", $STR );
$STR = str_replace( "'", "\\'", $STR );
if ( strpos( $STR, "," ) === FALSE )
{
return $STR;
}
$STR = "\"".$STR."\"";
return $STR;
}
function keyed_str( $TXT, $ENCRYPT_KEY )
{
$ENCRYPT_KEY = md5( $ENCRYPT_KEY );
$CTR = 0;
$TMP = "";
$I = 0;
for ( ; $I {
if ( $CTR == strlen( $ENCRYPT_KEY ) )
{
$CTR = 0;
}
$TMP .= substr( $TXT, $I, 1 ) ^ substr( $ENCRYPT_KEY, $CTR, 1 );
++$CTR;
}
return $TMP;
}
function encrypt_str( $TXT, $KEY )
{
srand( ( double )microtime( ) * 1000000 );
$ENCRYPT_KEY = md5( rand( 0, 32000 ) );
$CTR = 0;
$TMP = "";
$I = 0;
for ( ; $I {
if ( $CTR == strlen( $ENCRYPT_KEY ) )
{
$CTR = 0;
}
$TMP .= substr( $ENCRYPT_KEY, $CTR, 1 ).( substr( $TXT, $I, 1 ) ^ substr( $ENCRYPT_KEY, $CTR, 1 ) );
++$CTR;
}
return keyed_str( $TMP, $KEY );
}
function decrypt_str( $TXT, $KEY )
{
$TXT = keyed_str( $TXT, $KEY );
$TMP = "";
$I = 0;
for ( ; $I {
$MD5 = substr( $TXT, $I, 1 );
++$I;
$TMP .= substr( $TXT, $I, 1 ) ^ $MD5;
}
return $TMP;
}
function get_client_ip( )
{
if ( getenv( "REMOTE_ADDR" ) && strcasecmp( getenv( "REMOTE_ADDR" ), "unknown" ) )
{
$onlineip = getenv( "REMOTE_ADDR" );
return $onlineip;
}
if ( isset( $_SERVER['REMOTE_ADDR'] ) && $_SERVER['REMOTE_ADDR'] && strcasecmp( $_SERVER['REMOTE_ADDR'], "unknown" ) )
{
$onlineip = $_SERVER['REMOTE_ADDR'];
return $onlineip;
}
if ( getenv( "HTTP_CLIENT_IP" ) && strcasecmp( getenv( "HTTP_CLIENT_IP" ), "unknown" ) )
{
$onlineip = getenv( "HTTP_CLIENT_IP" );
return $onlineip;
}
if ( getenv( "HTTP_X_FORWARDED_FOR" ) && strcasecmp( getenv( "HTTP_X_FORWARDED_FOR" ), "unknown" ) )
{
$onlineip = getenv( "HTTP_X_FORWARDED_FOR" );
}
return $onlineip;
}
function dept_long_name( $DEPT_ID )
{
global $SYS_DEPARTMENT;
include_once( "inc/department.php" );
if ( is_array( $SYS_DEPARTMENT ) )
{
}
if ( !array_key_exists( $DEPT_ID, $SYS_DEPARTMENT ) )
{
include_once( "inc/utility_org.php" );
cache_department( );
include( "inc/department.php" );
}
return $SYS_DEPARTMENT[$DEPT_ID]['DEPT_LONG_NAME'];
}
function sms_remind( $SMS_TYPE, $SMS_CHECKED = "" )
{
global $connection;
global $LOGIN_USER_ID;
$query = "select * from SYS_PARA where PARA_NAME='SMS_REMIND'";
$cursor = exequery( $connection, $query );
if ( $ROW = mysql_fetch_array( $cursor ) )
{
$PARA_VALUE = $ROW['PARA_VALUE'];
}
$REMIND_ARRAY = explode( "|", $PARA_VALUE );
$SMS_REMIND = $REMIND_ARRAY[0];
$SMS2_REMIND = $REMIND_ARRAY[1];
$SMS3_REMIND = $REMIND_ARRAY[2];
if ( find_id( $SMS3_REMIND, $SMS_TYPE ) )
{
echo "if ( $SMS_CHECKED == "1" || find_id( $SMS_REMIND, $SMS_TYPE ) )
{
echo " checked";
}
echo "> ";
}
$query = "select * from SMS2_PRIV";
$cursor = exequery( $connection, $query );
if ( $ROW = mysql_fetch_array( $cursor ) )
{
$TYPE_PRIV = $ROW['TYPE_PRIV'];
$SMS2_REMIND_PRIV = $ROW['SMS2_REMIND_PRIV'];
}
if ( find_id( $TYPE_PRIV, $SMS_TYPE ) && find_id( $SMS2_REMIND_PRIV, $LOGIN_USER_ID ) )
{
echo "if ( find_id( $SMS2_REMIND, $SMS_TYPE ) )
{
echo " checked";
}
echo ">";
}
}
function sms_select_remind( $SMS_TYPE, $SMS_CHECKED = "" )
{
return "\r\n
\r\n \r\n \r\n \r\n 添加\r\n 清空";
}
function sms2_select_remind( $SMS_TYPE, $SMS_CHECKED = "" )
{
global $connection;
global $LOGIN_USER_ID;
$query = "select * from SMS2_PRIV";
$cursor = exequery( $connection, $query );
if ( $ROW = mysql_fetch_array( $cursor ) )
{
$TYPE_PRIV = $ROW['TYPE_PRIV'];
$SMS2_REMIND_PRIV = $ROW['SMS2_REMIND_PRIV'];
}
if ( find_id( $TYPE_PRIV, $SMS_TYPE ) && find_id( $SMS2_REMIND_PRIV, $LOGIN_USER_ID ) )
{
return "\r\n
\r\n \r\n \r\n \r\n 添加\r\n 清空";
}
}
function page_bar( $current_start_item, $total_items, $page_size = 10, $var_name = "start", $script_href = NULL, $direct_print = FALSE )
{
if ( $current_start_item {
$current_start_item = 0;
}
if ( $script_href == NULL )
{
$script_href = $_SERVER['PHP_SELF'];
}
if ( $_SERVER['QUERY_STRING'] != "" )
{
$script_href .= "?".$_SERVER['QUERY_STRING'];
}
$script_href = preg_replace( "/^(.+)(\\?|&)TOTAL_ITEMS=[^&]+&?(.*)\$/i", "\$1\$2\$3", $script_href );
$script_href = preg_replace( "/^(.+)(\\?|&)PAGE_SIZE=[^&]+&?(.*)\$/i", "\$1\$2\$3", $script_href );
$script_href = preg_replace( "/^(.+)(\\?|&)".$var_name."=[^&]+&?(.*)\$/i", "\$1\$2\$3", $script_href );
if ( substr( $script_href, -1 ) == "&" || substr( $script_href, -1 ) == "?" )
{
$script_href = substr( $script_href, 0, -1 );
}
$hyphen = strstr( $script_href, "?" ) === FALSE ? "?" : "&";
$num_pages = ceil( $total_items / $page_size );
$cur_page = floor( $current_start_item / $page_size ) + 1;
$result_str .= "<script>function goto_page(){var page_no=parseInt(document.getElementById('page_no').value);if(isNaN(page_no)||page_no<1||page_no>".$num_pages."){alert(\"页数必须为1-".$num_pages."\");return;}window.location=\"".$script_href.$hyphen.$var_name."=\"+(page_no-1)*".$page_size."+\"&TOTAL_ITEMS=".$total_items."&PAGE_SIZE=".$page_size."\";} function input_page_no(){if(event.keyCode==13) goto_page();if(event.keyCode<47||event.keyCode>57) event.returnValue=false;}</script>";
$result_str .= "
\n第".$cur_page."/".$num_pages."页";
if ( $cur_page {
$result_str .= "\r\n ";
}
else
{
$result_str .= "\r\n ";
}
if ( $num_pages {
$result_str .= "\r\n ";
}
else
{
$result_str .= "\r\n ";
}
$result_str .= "转到 第 ";
if ( $direct_print )
{
echo $result_str;
}
return $result_str;
}
function get_page_size( $MODULE, $DEFAULT_SIZE = 10 )
{
$PARA_ARRAY = get_sys_para( "PAGE_BAR_SIZE" );
$PAGE_SIZE_ARRAY = unserialize( $PARA_ARRAY['PAGE_BAR_SIZE'] );
$PAGE_SIZE = intval( $PAGE_SIZE_ARRAY[$MODULE] );
$PAGE_SIZE = 0 return $PAGE_SIZE;
}
function send_mail( $FROM, $TO, $SUBJECT, $BODY, $SMTP_SERVER, $SMTP_USER, $SMTP_PASS, $SMTP_AUTH = TRUE, $FROM_NAME = "通达科技", $REPLY_TO = "", $CC = "", $BCC = "", $ATTACHMENT = "", $IS_HTML = TRUE, $SMTP_PORT = 25, $SMTPSecure = "" )
{
global $ATTACH_PATH2;
include_once( "inc/phpmailer/class.phpmailer.php" );
include_once( "inc/utility_file.php" );
$mail = new PHPMailer( );
$mail->SetLanguage( "zh" );
$mail->IsSMTP( );
$mail->Host = $SMTP_SERVER;
$mail->Port = $SMTP_PORT;
$mail->SMTPAuth = $SMTP_AUTH;
$mail->SMTPSecure = $SMTPSecure;
$mail->Username = $SMTP_USER;
$mail->Password = $SMTP_PASS;
$mail->From = $FROM;
$mail->FromName = $FROM_NAME;
$mail->AddReplyTo( $FROM, $FROM_NAME );
$mail->WordWrap = 50;
$mail->IsHTML( $IS_HTML );
$mail->Subject = $SUBJECT;
$mail->Body = $BODY;
$mail->AltBody = strip_tags( $BODY );
$TOK = strtok( $TO, "," );
while ( $TOK != "" )
{
$mail->AddAddress( $TOK );
$TOK = strtok( "," );
}
$TOK = strtok( $CC, "," );
while ( $TOK != "" )
{
$mail->AddCC( $TOK );
$TOK = strtok( "," );
}
$TOK = strtok( $BCC, "," );
while ( $TOK != "" )
{
$mail->AddBCC( $TOK );
$TOK = strtok( "," );
}
$TOK = strtok( $ATTACHMENT, "*" );
while ( $TOK != "" )
{
$FILENAME = substr( $TOK, strrpos( $TOK, "/" ) + 1 );
if ( strtolower( substr( $TOK, 0, strlen( $ATTACH_PATH2 ) + strlen( attach_sub_dir( ) ) ) ) == strtolower( $ATTACH_PATH2 ).attach_sub_dir( ) )
{
$FILENAME = substr( $FILENAME, strpos( $FILENAME, "." ) + 1 );
}
$mail->AddAttachment( $TOK, $FILENAME );
$TOK = strtok( "*" );
}
if ( $mail->Send( ) )
{
return TRUE;
}
return $mail->ErrorInfo;
}
function send_email( $LOGIN_USER_ID, $FORM_EMAIL, $TO_EMAIL_STR, $EMAIL_CONTENT, $MAIL_TITLE )
{
global $connection;
global $LOGIN_USER_NAME;
$query = "SELECT * from WEBMAIL where EMAIL='".$FORM_EMAIL."' and USER_ID='{$LOGIN_USER_ID}'";
$cursor = exequery( $connection, $query );
if ( $ROW = mysql_fetch_array( $cursor ) )
{
$POP_SERVER = $ROW['POP_SERVER'];
$SMTP_SERVER = $ROW['SMTP_SERVER'];
$LOGIN_TYPE = $ROW['LOGIN_TYPE'];
$SMTP_PASS = $ROW['SMTP_PASS'];
$SMTP_PORT = $ROW['SMTP_PORT'];
$SMTP_SSL = $ROW['SMTP_SSL'] == "1" ? "ssl" : "";
$EMAIL_PASS = $ROW['EMAIL_PASS'];
$EMAIL_PASS = decrypt_str( $EMAIL_PASS, "webmail" );
}
return send_mail( $FORM_EMAIL, $TO_EMAIL_STR, $MAIL_TITLE, $EMAIL_CONTENT, $SMTP_SERVER, $FORM_EMAIL, $EMAIL_PASS, TRUE, $LOGIN_USER_NAME, "", "", "", "", TRUE, $SMTP_PORT, $SMTP_SSL );
}
function unescape( $str )
{
$str = rawurldecode( $str );
preg_match_all( "/(?:%u.{4})|.{4};|\\d+;|.+/U", $str, $r );
$ar = $r[0];
foreach ( $ar as $k => $v )
{
if ( substr( $v, 0, 2 ) == "%u" )
{
$ar[$k] = iconv( "UCS-2", ini_get( "default_charset" ), pack( "H4", substr( $v, -4 ) ) );
}
else if ( substr( $v, 0, 3 ) == "" )
{
$ar[$k] = iconv( "UCS-2", ini_get( "default_charset" ), pack( "H4", substr( $v, 3, -1 ) ) );
}
else if ( substr( $v, 0, 2 ) == "" )
{
$ar[$k] = iconv( "UCS-2", ini_get( "default_charset" ), pack( "n", substr( $v, 2, -1 ) ) );
}
}
return str_replace( "\\\\", "\\", join( "", $ar ) );
}
function flow_sort_tree( $SORT_ID, $SORT_CHOOSE )
{
include_once( "inc/utility_org.php" );
global $connection;
global $DEEP_COUNT;
global $LOGIN_USER_PRIV;
global $LOGIN_DEPT_ID;
global $LOGIN_USER_PRIV_OTHER;
$query = "SELECT * from FLOW_SORT where SORT_PARENT=".$SORT_ID." order by SORT_NO";
$cursor = exequery( $connection, $query );
$OPTION_TEXT = "";
$DEEP_COUNT1 = $DEEP_COUNT;
$DEEP_COUNT .= "│";
$COUNT = 0;
while ( $ROW = mysql_fetch_array( $cursor ) )
{
++$COUNT;
$SORT_ID = $ROW['SORT_ID'];
$SORT_NAME = $ROW['SORT_NAME'];
$SORT_PARENT = $ROW['SORT_PARENT'];
$HAVE_CHILD = $ROW['HAVE_CHILD'];
$DEPT_ID = $ROW['DEPT_ID'];
if ( $LOGIN_USER_PRIV != 1 && !find_id( $LOGIN_USER_PRIV_OTHER, 1 ) || $DEPT_ID != $LOGIN_DEPT_ID && $DEPT_ID != 0 && !is_dept_parent( $LOGIN_DEPT_ID, $DEPT_ID ) )
{
}
else
{
$SORT_NAME = htmlspecialchars( $SORT_NAME );
if ( $COUNT == mysql_num_rows( $cursor ) )
{
$DEEP_COUNT = substr( $DEEP_COUNT, 0, -2 )." ";
}
if ( $HAVE_CHILD == 1 )
{
$OPTION_TEXT_CHILD = flow_sort_tree( $SORT_ID, $SORT_CHOOSE );
}
$OPTION_TEXT .= "\n";
}
else
{
$OPTION_TEXT .= "value=".$SORT_ID.">".$DEEP_COUNT1."├".$SORT_NAME."\n";
}
if ( !( $HAVE_CHILD != 0 ) && !( $OPTION_TEXT_CHILD != "" ) )
{
$OPTION_TEXT .= $OPTION_TEXT_CHILD;
}
}
}
$DEEP_COUNT = $DEEP_COUNT1;
return $OPTION_TEXT;
}
function check_priv( $PRIV_STR )
{
global $LOGIN_DEPT_ID;
global $LOGIN_USER_PRIV;
global $LOGIN_USER_ID;
$PRIV_ARRAY = explode( "|", $PRIV_STR );
if ( $PRIV_ARRAY[0] == "ALL_DEPT" || find_id( $PRIV_ARRAY[0], $LOGIN_DEPT_ID ) || find_id( $PRIV_ARRAY[1], $LOGIN_USER_PRIV ) || find_id( $PRIV_ARRAY[2], $LOGIN_USER_ID ) )
{
return TRUE;
}
return FALSE;
}
function CSV2Array( $content, $title = array( ), $delimiter = ",", $enclosure = "\"", $optional = 1 )
{
$content = trim( $content );
$content = str_replace( "\r", "", $content );
$csv_array = array( );
$expr_line = "/\\n(?=(?:[^".$enclosure."]*".$enclosure."[^".$enclosure."]*".$enclosure.")*(?![^".$enclosure."]*".$enclosure."))/";
$expr_field = "/".$delimiter."(?=(?:[^".$enclosure."]*".$enclosure."[^".$enclosure."]*".$enclosure.")*(?![^".$enclosure."]*".$enclosure."))/";
$lines = preg_split( $expr_line, trim( $content ) );
foreach ( $lines as $line )
{
$fields = preg_split( $expr_field, trim( $line ) );
$csv_array[] = preg_replace( array( "/\"(.*)\"\$/s", "/\"\"/s" ), array( "\$1", "\"" ), $fields );
}
if ( !is_array( $title ) && count( $title ) == 0 || count( $csv_array ) == 0 )
{
return $csv_array;
}
$field_map = array( );
while ( list( $key, $value ) = each( &$title ) )
{
if ( ( $index = array_search( $key, $csv_array[0] ) ) !== FALSE )
{
$field_map[$value] = $index;
}
}
$lines = array( );
$i = 1;
for ( ; $i {
$line = array( );
reset( &$field_map );
while ( list( $key, $value ) = each( &$field_map ) )
{
$line[$key] = $csv_array[$i][$value];
}
$lines[] = $line;
}
return $lines;
}
function add_sys_para( $PARA_ARRAY )
{
global $connection;
while ( list( $PARA_NAME, $PARA_VALUE ) = each( &$PARA_ARRAY ) )
{
$query = "SELECT * from SYS_PARA where PARA_NAME='".$PARA_NAME."'";
$cursor = exequery( $connection, $query );
if ( mysql_num_rows( $cursor ) {
$query = "insert into SYS_PARA (PARA_NAME, PARA_VALUE) values('".$PARA_NAME."', '{$PARA_VALUE}')";
exequery( $connection, $query );
}
}
}
function get_sys_para( $PARA_NAME_STR )
{
global $connection;
$PARA_ARRAY = array( );
$query = "SELECT * from SYS_PARA where find_in_set(PARA_NAME, '".$PARA_NAME_STR."')";
$cursor = exequery( $connection, $query );
while ( $ROW = mysql_fetch_array( $cursor ) )
{
$PARA_ARRAY[$ROW['PARA_NAME']] = $ROW['PARA_VALUE'];
}
return $PARA_ARRAY;
}
function set_sys_para( $PARA_ARRAY )
{
global $connection;
while ( list( $PARA_NAME, $PARA_VALUE ) = each( &$PARA_ARRAY ) )
{
$query = "update SYS_PARA set PARA_VALUE='".$PARA_VALUE."' where PARA_NAME='{$PARA_NAME}'";
exequery( $connection, $query );
}
}
function menu_arrow( $DIRECTION = "DOWN" )
{
if ( stristr( $_SERVER['HTTP_USER_AGENT'], "MSIE" ) )
{
switch ( strtoupper( $DIRECTION ) )
{
case "LEFT" :
return "3";
case "RIGHT" :
return "4";
case "UP" :
return "5";
case "DOWN" :
return "6";
default :
}
else
{
switch ( strtoupper( $DIRECTION ) )
{
case "LEFT" :
return " 通达OA公共代码 php常用检测函数";
case "RIGHT" :
return " 通达OA公共代码 php常用检测函数";
case "UP" :
return " 通达OA公共代码 php常用检测函数";
case "DOWN" :
return " 通达OA公共代码 php常用检测函数";
}
}
}
}
function netMatch( $network, $ip )
{
$network = trim( $network );
$ip = trim( $ip );
$d = strpos( $network, "-" );
if ( $d === FALSE )
{
$ip_arr = explode( "/", $network );
if ( !preg_match( "@\\d*\\.\\d*\\.\\d*\\.\\d*@", $ip_arr[0], $matches ) )
{
$ip_arr[0] .= ".0";
}
$network_long = ip2long( $ip_arr[0] );
$x = ip2long( $ip_arr[1] );
$mask = long2ip( $x ) == $ip_arr[1] ? $x : -1 $ip_long = ip2long( $ip );
[exception occured]
================================
Exception code[ C0000005 ]
Compiler[ 003B5E50 ]
Executor[ 003B6358 ]
OpArray[ 00A5FD78 ]
File
Class
Function
Stack[ 00145DE8 ]
Step[ 7 ]
Offset[ 60 ]
LastOffset[ 94 ]
60 IS_EQUAL [-] 0[0] $Tmp_0 - $Tmp_1 - $Tmp_2
================================
?>
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template