Rumah > Artikel > pembangunan bahagian belakang > 通达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 .= "