首页 > 作文

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

更新时间:2023-04-06 11:00:17 阅读: 评论:0

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


复制代码 代码如下:

<?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 fal;

}

if ( $str != “0” )

{

$str = intval( $str );

if ( $str == 0 )

{

return fal;

}

}

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 fal;

}

return true;

}

function is_money( $str )

{

$dot_pos = strpos( $str, “.” );

if ( !$dot_pos )

{

return fal;

}

$str1 = substr( $str, 0, $dot_pos );

if ( 14 < strlen( $str1 ) )

{

return fal;

}

if ( !is_number( $str1 ) )

{

return fal;

}

$str2 = substr( $str, $dot_pos + 1, strlen( $str ) – $dot_pos );

if ( strlen( $str2 ) != 2 )

{

return fal;

}

if ( !is_number( $str2 ) )

{

return fal;

}

return true;

}

function is_money_len( $str, $int_len, $dot_len )

{

$dot_pos = strpos( $str, “.” );

if ( !$dot_pos )

{

return fal;

}

$str1 = substr( $str, 0, $dot_pos );

if ( $int_len < strlen( $str1 ) )

{

return fal;

}

if ( !is_number( $str1 ) )

{

return fal;

}

$str2 = substr( $str, $dot_pos + 1, strlen( $str ) – $dot_pos );

if ( strlen( $str2 ) != $dot_len )

{

return fal;

}

if ( !is_number( $str2 ) )

{

return fal;

}

return true;

}

function is_date( $str )

{

$year = “”;

$month = “”;

$day = “”;

$len = strlen( $str );

$offt = 0;

$i = strpos( $str, “-“, $offt );

$year = substr( $str, $offt, $i – $offt );

$offt = $i + 1;

if ( $len < $offt )

{

return fal;

}

if ( $i )

{

$i = strpos( $str, “-“, $offt );

$month = substr( $str, $offt, $i – $offt );

$offt = $i + 1;

if ( $len < $offt )

{

return fal;

}

if ( $i )

{

$day = substr( $str, $offt, $len – $offt );

}

}

if ( $year == “” || $month == “” || $day == “” )

{

return fal;

}

if ( !checkdate( intval( $month ), intval( $day ), intval( $year ) ) )

{

return fal;

}

return true;

}

function is_time( $str )

{

$temp = “”;

$hour = “”;

$min = “”;

$c = “”;

$temp = strtok( $str, “:” );

$hour = $temp;

if ( $hour == “” || 24 <= $hour || $hour < 0 || !is_number( $hour ) )

{

return fal;

}

$temp = strtok( “:” );

$min = $temp;

if ( $min == “” || 60 <= $min || $min < 0 || !is_number( $min ) )

{

return fal;

}

$temp = strtok( “:” );

$c = $temp;

if ( $c == “” || 60 <= $c || $c < 0 || !is_number( $c ) )

{

return fal;

}

return true;

}

function is_date_time( $date_time_str )

{

if ( $date_time_str == null || strlen( $date_time_str ) == 0 )

{

return fal;

}

$date_time_arry = explode( ” “, $date_time_str );

if ( is_date( $date_time_arry[0] ) && is_time( $date_time_arry[1] ) )

{

return true;

}

return fal;

}

?>

auth.php登录验证


复制代码 代码如下:

<?php

/*********************/

/* */

/* version : 5.1.0 */

/* author : rm */

/* comment : 071223 */

/* */

/*********************/

if ( $ur_id == “” || $password == “” )

{

echo “201#|#用户名或密码为空”;

exit( );

}

if ( $ur_id != “officetask” )

{

echo “205#|#用户名错误”;

exit( );

}

include_once( “../inc/conn.php” );

include_once( “../inc/utility.php” );

ob_end_clean( );

$query = “lect * from ext_ur where ur_id='”.$ur_id.”‘”;

$cursor = exequery( $connection, $query );

if ( $row = mysql_fetch_array( $cursor ) )

{

$pwd = $row[‘password’];

$u_flag = $row[‘u_flag’];

$auth_module = $row[‘auth_module’];

$postfix = $row[‘postfix’];

if ( md5( $pwd ) != $password )

{

echo “203#|#密码错误”;

exit( );

}

if ( $u_flag == “0” )

{

echo “204#|#帐号已停用”;

exit( );

}

}

el

{

echo “202#|#”.$ur_id;

exit( );

}

?>

utility_all公用函数


复制代码 代码如下:

<?php

/*********************/

/* */

/* 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 ) ) )

{

ca 0 :

return “日”;

ca 1 :

return “一”;

ca 2 :

return “二”;

ca 3 :

return “三”;

ca 4 :

return “四”;

ca 5 :

return “五”;

ca 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”;

}

el

{

$tok = strtok( “.” );

$i = 1;

for ( ; $i <= 2 – strlen( $tok ); ++$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 < $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;

}

function compare_time( $time1, $time2 )

{

$str = strtok( $time1, “:” );

$hour1 = $str;

$str = strtok( “:” );

$min1 = $str;

$str = strtok( “:” );

$c1 = $str;

$str = strtok( $time2, “:” );

$hour2 = $str;

$str = strtok( “:” );

$min2 = $str;

$str = strtok( “:” );

$c2 = $str;

if ( $hour2 < $hour1 )

{

return 1;

}

if ( $hour1 < $hour2 )

{

return -1;

}

if ( $min2 < $min1 )

{

return 1;

}

if ( $min1 < $min2 )

{

return -1;

}

if ( $c2 < $c1 )

{

return 1;

}

if ( $c1 < $c2 )

{

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], $d海拔最高的盆地ate_time2_arry[1] ) == 0 )

{

return 0;

}

return -1;

}

return -1;

}

function is_chine( &$str, $location )

{

$ch = true;

$i = $location;

while ( 160 < ord( $str[$i] ) && 0 <= $i )

{

$ch = !$ch;

–$i;

}

if ( $i != $location )

{

$f_str = $ch ? 1 : -1;

return $f_str;

}

$f_str = fal;

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 < $start; ++$fs )

{

$i += ord( $str[$fs] ) <= 160 ? 1 : 0.5;

}

$i = 0;

$fe = $fs;

for ( ; $i < $long; ++$fe )

{

$i += ord( $str[$fe] ) <= 160 ? 1 : 0.5;

}

$long = $fe – $fs;

}

el

{

$fs = is_chine( &$str, $start ) == 1 ? $start – 1 : $start;

$fe = $long + $start – 1;

$end = is_chine( &$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 fal;

}

$i = 0;

for ( ; $i < $ip_array_num; ++$i )

{

if ( !is_numeric( $ip_array[$i] ) && $ip_array[$i] < 0 || 255 < $ip_array[$i] )

{

return fal;

}

if ( !( $i == 3 ) && !( $ip_array[$i] == 255 ) )

{

continue;

}

return fal;

}

return true;

}

function check_ip( $ur_ip, $type, $ur_id )

{

global $connection;

$query = “lect para_value from sys_para where para_name=’ip_unlimited_ur'”;

$cursor = exequery( $connection, $query );

if ( $row = mysql_fetch_array( $cursor ) )

{

$ip_unlimited_ur = $row[‘para_value’];

}

if ( find_id( $ip_unlimited_ur, $ur_id ) )

{

return true;

}

$query = “lect * 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 ) <= ip2long( $ur_ip ) ) && !( ip2long( $ur_ip ) <= ip2long( $end_ip ) ) )

{

continue;

}

$flag = 1;

break;

}

if ( $rule_count == 0 || $flag == 1 )

{

return true;

}

return fal;

}

function maskstr( $str, $first, $last )

{

if ( is_numeric( $first ) )

{

}

if ( !is_numeric( $last ) )

{

return;

}

if ( strlen( $str ) <= $first + $last )

{

return $str;

}

$return_str = substr( $str, 0, $first );

$i = 0;

for ( ; $i < strlen( substr( $str, $first, 0 – $last ) ); ++$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( ) );

$ur_ip = get_client_ip( );

if ( $type == 1 )

{

$query = “update ur t last_visit_ip='”.$ur_ip.”‘ where ur_id='{$operator}'”;

exequery( $connection, $query );

}

el

{

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 = “lect 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 === fal )

{

message( “错误”, itask_last_error( ) );

button_back( );

exit( );

}

}

el 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 = “lect ur_id,ur_name,dept_id from ur where find_in_t(ur_id,'”.$remark.”‘)”;

$cursor = exequery( $connection, $query );

$remark = “”;

while ( $row = mysql_fetch_array( $cursor ) )

{

$ur_id = $row[‘ur_id’];

$ur_name = $row[‘ur_name’];

$dept_id = $row[‘dept_id’];

$query = “lect 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.”]{$ur_name},ur_id={$ur_id}<br>”;

}

if ( $result === fal )

{

message( “错误”, itask_last_error( ) );

button_back( );

exit( );

}

}

}

$remark = str_replace( “‘”, “\\'”, $remark );

$remark = str_replace( “\\\\'”, “\\'”, $remark );

$query = “inrt into sys_log (ur_id,time,ip,type,remark) values (‘”.$operator.”‘,'{$cur_time}’,'{$ur_ip}’,'{$type}’,'{$remark}’)”;

exequery( $connection, $query );

if ( 21 < $type && !find_id( “40,41,”, $type ) || get_code_name( $type, “sys_log” ) == “” )

{

$query1 = “inrt 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_ur_id;

$cur_date = date( “y-m-d”, time( ) );

$cur_time = date( “y-m-d h:i:s”, time( ) );

$query = “lect * from affair where ur_id='”.$login_ur_id.”‘ and begin_time <='{$cur_time}’ and (last_remind<‘{$cur_date}’ or last_remind=’0000-00-00′)”;

$cursor = exequery( $connection, $query );

while ( $row = mysql_fetch_array( $cursor ) )

{

$aff_id = $row[‘aff_id’];

$ur_id = $row[‘ur_id’];

$type = $row[‘type’];

$remind_date = $row[‘remind_date’];

$remind_time = $row[‘remind_time’];

$content = $row[‘content’];

$nd_time = date( “y-m-d”, time( ) ).” “.$remind_time;

$sms_content = “日常事务提醒:”.csubstr( &$content, 0, 100 );

$flag = 0;

if ( $type == “2” )

{

$flag = 1;

}

el if ( $type == “3” && date( “w”, time( ) ) == $remind_date )

{

$flag = 1;

}

el if ( $type == “4” && date( “j”, time( ) ) == $remind_date )

{

$flag = 1;

}

el 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 )

{

nd_sms( $nd_time, $login_ur_id, $login_ur_id, 5, $sms_content, “1:calendar/affair/note.php?aff_id=”.$aff_id );

$query = “update affair t 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 = “lect code_name from sys_code where parent_no='”.$parent_no.”‘ and find_in_t(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, $lected = “”, $type = “d”, $field_name = “” )

{

if ( $parent_no == “” )

{

return;

}

global $connection;

$query = “lect 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 .= “<option value=\””.$code_no.”\””;

if ( $code_no == $lected )

{

$option_str .= ” lected”;

}

$option_str .= “>”.$code_name.”</option>\n”;

}

el if ( $type == “r” )

{

$option_str .= “<input type=\”radio\” name=\””.$field_name.”\” id=\””.$field_name.”_”.$code_no.”\” value=\””.$code_no.”\””;

if ( $code_no == $lected )

{

$option_str .= ” checked”;

}

$option_str .= “><label for=\””.$field_name.”_”.$code_no.”\”>”.$code_name.”</label>\n”;

}

el if ( $type == “c” )

{

$option_str .= “<input type=\”checkbox\” name=\””.$field_name.”_”.$code_no.”\” id=\””.$field_name.”_”.$code_no.”\” value=\””.$code_no.”\””;

if ( find_id( $lected, $code_no ) )

{

$option_str .= ” checked”;

}

$option_str .= “><label for=\””.$field_name.”_”.$code_no.”\”>”.$code_name.”</label>\n”;

}

}

return $option_str;

}

function get_code_array( $parent_no, $rever = fal )

{

$code_array = array( );

if ( $parent_no == “” )

{

return $code_array;

}

global $connection;

$query = “lect 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 ( !$rever )

{

$code_array[$code_no] = $code_name;

}

el

{

$code_array[$code_name] = $code_no;

}

}

return $code_array;

}

function sms_type_url( $sms_type, $content )

{

switch ( $sms_type )

{

ca “0” :

$url = “/general/sms/receive/”;

return $url;

ca “1” :

$url = “/general/notify/show/”;

return $url;

ca “2” :

$url = “/general/email/inbox/?box_id=0”;

return $url;

ca “3” :

$url = “/general/netmeeting/”;

return $url;

ca “4” :

$url = “/general/salary/report/”;

return $url;

ca “5” :

$url = “/general/calendar/”;

return $url;

ca “6” :

if ( strstr( $content, “提交” ) && strstr( $content, “申请” ) && strstr( $content, “请批示” ) )

{

$url = “/general/attendance/manage/”;

return $url;

}

$url = “/general/attendance/personal/”;

return $url;

ca “7” :

$url = “/general/workflow/list”;

return $url;

ca “8” :

$url = “/general/meeting/manage/”;

return $url;

ca “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;

ca “10” :

$url = “/general/mobile_sms/”;

return $url;

ca “11” :

$url = “/general/vote/show/”;

return $url;

ca “12” :

$url = “/general/work_plan/show/”;

return $url;

ca “13” :

$url = “/general/diary/”;

return $url;

ca “14” :

$url = “/general/news/show/”;

return $url;

ca “15” :

$url = “/general/score/submit/”;

return $url;

ca “16” :

$url = “/general/file_folder/index1.php”;

return $url;

ca “17” :

$url = “/general/netdisk”;

return $url;

ca “18” :

$url = “/general/bbs”;

return $url;

ca “20” :

$url = “/general/file_folder?file_sort=2&sort_id=0”;

return $url;

ca “30” :

$url = “/general/training/manage/show”;

return $url;

ca “31” :

if ( strstr( $content, “批准了” ) || strstr( $content, “未批准” ) || strstr( $content, “撤销了” ) )

{

$url = “/general/training/train/apply/”;

return $url;

}

$url = “/general/training/manage/apply_manage/”;

return $url;

ca “32” :

$url = “/general/training/train/survey/”;

return $url;

ca “33” :

$url = “/general/training/train/information/”;

return $url;

ca “34” :

$url = “/general/training/train/asssment/”;

return $url;

ca “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 = “lect 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] )

{

$img_attr[0] = $avatar_width;

}

if ( $avatar_height < $img_attr[1] )

{

$img_attr[1] = $avatar_height;

}

if ( $img_attr[0] < 15 )

{

$img_attr[0] = 15;

}

if ( $img_attr[1] < 15 )

{

$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, “,” ) === fal )

{

return $str;

}

$str = “\””.$str.”\””;

return $str;

}

function keyed_str( $txt, $encrypt_key )

{

$encrypt_key = md5( $encrypt_key );

$ctr = 0;

$tmp = “”;

$i = 0;

for ( ; $i < strlen( $txt ); ++$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 < strlen( $txt ); ++$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 < strlen( $txt ); ++$i )

{

$md5 = substr( $txt, $i, 1 );

++$i;

$tmp .= substr( $txt, $i, 1 ) ^ $md5;

}

return $tmp;

}

function get_client_ip( )

{

if ( getenv( “remote_addr” ) && strcacmp( getenv( “remote_addr” ), “unknown” ) )

{

$onlineip = getenv( “remote_addr” );

return $onlineip;

}

if ( ist( $_rver[‘remote_addr’] ) && $_rver[‘remote_addr’] && strcacmp( $_rver[‘remote_addr’], “unknown” ) )

{

$onlineip = $_rver[‘remote_addr’];

return $onlineip;

}

if ( getenv( “http_client_ip” ) && strcacmp( getenv( “http_client_ip” ), “unknown” ) )

{

$onlineip = getenv( “http_client_ip” );

return $onlineip;

}

if ( getenv( “http_x_forwarded_for” ) && strcacmp( 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_ur_id;

$query = “lect * 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 “<input type=\”checkbox\” name=\”sms_remind\” id=\”sms_remind\””;

if ( $sms_checked == “1” || find_id( $sms_remind, $sms_type ) )

{

echo ” checked”;

}

echo “><label for=\”sms_remind\”>使用内部短信提醒</label>“;

}

$query = “lect * 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_ur_id ) )

{

echo “<input type=\”checkbox\” name=\”sms2_remind\” id=\”sms2_remind\””;

if ( find_id( $sms2_remind, $sms_type ) )

{

echo ” checked”;

}

echo “><label for=\”sms2_remind\”>使用手机短信提醒</label>”;

}

}

function sms_lect_remind( $sms_type, $sms_checked = “” )

{

return “<input type=\”radio\” name=\”sms_lect_remind\” id=\”sms_lect_remind0\” value=\”0\” onclick=\”document.getelementbyid(‘sms_lect_remind_span’).style.display=”;\””.( $sms_checked != “1” ? ” checked” : “” ).”><label for=\”sms_lect_remind0\”>手动选择被提醒人员</label>\r\n <input type=\”radio\” name=\”sms_lect_remind\” id=\”sms_lect_remind1\” value=\”1\” onclick=\”document.getelementbyid(‘sms_lect_remind_span’).style.display=’none’;\””.( $sms_checked == “1” ? ” checked” : “” ).”><label for=\”sms_lect_remind1\”>提醒全部有权限人员</label><br>\r\n <span id=\”sms_lect_remind_span\”>\r\n <textarea cols=40 name=\”sms_lect_remind_to_name\” rows=\”2\” class=\”bigstatic\” wrap=\”yes\” readonly></textarea>\r\n <input type=\”hidden\” name=\”sms_lect_remind_to_id\” value=\”\”>\r\n <a href=\”javascript:;\” class=\”orgadd\” onclick=\”lectur(”,’sms_lect_remind_to_id’, ‘sms_lect_remind_to_name’)\”>添加</a>\r\n <a href=\”javascript:;\” class=\”orgclear\” onclick=\”clearur(‘sms_lect_remind_to_id’, ‘sms_lect_remind_to_name’)\”>清空</a></span>”;

}

function sms2_lect_remind( $sms_type, $sms_checked = “” )

{

global $connection;

global $login_ur_id;

$query = “lect * 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_ur_id ) )

{

return “<input type=\”radio\” name=\”sms2_lect_remind\” id=\”sms2_lect_remind0\” value=\”0\” onclick=\”document.getelementbyid(‘sms2_lect_remind_span’).style.display=”;\””.( $sms_checked != “1” ? ” checked” : “” ).”><label for=\”sms2_lect_remind0\”>手动选择被提醒人员</label>\r\n <input type=\”radio\” name=\”sms2_lect_remind\” id=\”sms2_lect_remind1\” value=\”1\” onclick=\”document.getelementbyid(‘sms2_lect_remind_span’).style.display=’none’;\””.( $sms_checked == “1” ? ” checked” : “” ).”><label for=\”sms2_lect_remind1\”>提醒全部有权限人员</label><br>\r\n <span id=\”sms2_lect_remind_span\”>\r\n <textarea cols=40 name=\”sms2_lect_remind_to_name\” rows=\”2\” class=\”bigstatic\” wrap=\”yes\” readonly></textarea>\r\n <input type=\”hidden\” name=\”sms2_lect_remind_to_id\” value=\”\”>\r\n <a href=\”javascript:;\” class=\”orgadd\” onclick=\”lectur(”,’sms2_lect_remind_to_id’, ‘sms2_lect_remind_to_name’)\”>添加</a>\r\n <a href=\”javascript:;\” class=\”orgclear\” onclick=\”clearur(‘sms2_lect_remind_to_id’, ‘sms2_lect_remind_to_name’)\”>清空</a></span>”;

}

}

function page_bar( $current_start_item, $total_items, $page_size = 10, $var_name = “start”, $script_href = null, $direct_print = fal )

{

if ( $current_start_item < 0 || $total_items < $current_start_item )

{

$current_start_item = 0;

}

if ( $script_href == null )

{

$script_href = $_rver[‘php_lf’];

}

if ( $_rver[‘query_string’] != “” )

{

$script_href .= “?”.$_rver[‘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, “?” ) === fal ? “?” : “&”;

$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=parint(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=fal;}</script>”;

$result_str .= “<div id=\”pagearea\” class=\”pagearea\”>\n第<span id=\”pagenumber\” class=\”pagenumber\”>”.$cur_page.”/”.$num_pages.”</span>页”;

if ( $cur_page <= 1 )

{

$result_str .= “<a href=\”javascript:;\” id=\”pagefirst\” class=\”pagefirstdisable\” title=\”首页\”></a>\r\n <a href=\”javascript:;\” id=\”pageprevious\” class=\”pagepreviousdisable\” title=\”上一页\”></a>”;

}

el

{

$result_str .= “<a href=\””.$script_href.$hyphen.$var_name.”=0&total_items=”.$total_items.”&page_size=”.$page_size.”\” id=\”pagefirst\” class=\”pagefirst\” title=\”首页\”></a>\r\n <a href=\””.$script_href.$hyphen.$var_name.”=”.( $current_start_item – $page_size ).”&total_items=”.$total_items.”&page_size=”.$page_size.”\” id=\”pageprevious\” class=\”pageprevious\” title=\”上一页\”></a>”;

}

if ( $num_pages <= $cur_page )

{

$result_str .= “<a href=\”javascript:;\” id=\”pagenext\” class=\”pagenextdisable\” title=\”下一页\”></a>\r\n <a href=\”javascript:;\” id=\”pagelast\” class=\”pagelastdisable\” title=\”末页\”></a>”;

}

el

{

$result_str .= “<a href=\””.$script_href.$hyphen.$var_name.”=”.( $current_start_item + $page_size ).”&total_items=”.$total_items.”&page_size=”.$page_size.”\” id=\”pagenext\” class=\”pagenext\” title=\”下一页\”></a>\r\n <a href=\””.$script_href.$hyphen.$var_name.”=”.( 0 < $total_items % $page_size ? $total_items – $total_items % $page_size : $total_items – $page_size ).”&total_items=”.$total_items.”&page_size=”.$page_size.”\” id=\”pagelast\” class=\”pagelast\” title=\”末页\”></a>”;

}

$result_str .= “转到 第 <input type=\”text\” size=\”3\” class=\”smallinput\” name=\”page_no\” id=\”page_no\” onkeypress=\”input_page_no()\” style=’text-align:center;’> 页 <a href=\”javascript:goto_page();\” id=\”pagegoto\” class=\”pagegoto\” title=\”转到\”></a>”;

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 = unrialize( $para_array[‘page_bar_size’] );

$page_size = intval( $page_size_array[$module] );

$page_size = 0 < $page_size ? $page_size : $default_size;

return $page_size;

}

function nd_mail( $from, $to, $subject, $body, $smtp_rver, $smtp_ur, $smtp_pass, $smtp_auth = true, $from_name = “通达科技”, $reply_to = “”, $cc = “”, $bcc = “”, $attachment = “”, $is_html = true, $smtp_port = 25, $smtpcure = “” )

{

global $attach_path2;

include_once( “inc/phpmailer/class.phpmailer.php” );

include_once( “inc/utility_file.php” );

$mail = new phpmailer( );

$mail->tlanguage( “zh” );

$mail->issmtp( );

$mail->host = $smtp_rver;

$mail->port = $smtp_port;

$mail->smtpauth = $smtp_auth;

$mail->smtpcure = $smtpcure;

$mail->urname = $smtp_ur;

$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->nd( ) )

{

return true;

}

return $mail->errorinfo;

}

function nd_email( $login_ur_id, $form_email, $to_email_str, $email_content, $mail_title )

{

global $connection;

global $login_ur_name;

$query = “lect * from webmail where email='”.$form_email.”‘ and ur_id='{$login_ur_id}'”;

$cursor = exequery( $connection, $query );

if ( $row = mysql_fetch_array( $cursor ) )

{

$pop_rver = $row[‘pop_rver’];

$smtp_rver = $row[‘smtp_rver’];

$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 nd_mail( $form_email, $to_email_str, $mail_title, $email_content, $smtp_rver, $form_email, $email_pass, true, $login_ur_name, “”, “”, “”, “”, true, $smtp_port, $smtp_ssl );

}

function unescape( $str )

{

$str = rawurldecode( $str );

preg_match_all( “/(?:%u.{4})|&#x.{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_chart” ), pack( “h4”, substr( $v, -4 ) ) );

}

el if ( substr( $v, 0, 3 ) == “&#x” )

{

$ar[$k] = iconv( “ucs-2”, ini_get( “default_chart” ), pack( “h4”, substr( $v, 3, -1 ) ) );

}

el if ( substr( $v, 0, 2 ) == “&#” )

{

$ar[$k] = iconv( “ucs-2”, ini_get( “default_chart” ), pack( “n”, substr( $v, 2, -1 ) ) );

}

}

return str_replace( “\\\\”, “\\”, join( “”, $ar ) );

}

function flow_sort_tree( $sort_id, $sort_choo )

{

include_once( “inc/utility_org.php” );

global $connection;

global $deep_count;

global $login_ur_priv;

global $login_dept_id;

global $login_ur_priv_other;

$query = “lect * 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_ur_priv != 1 && !find_id( $login_ur_priv_other, 1 ) || $dept_id != $login_dept_id && $dept_id != 0 && !is_dept_parent( $login_dept_id, $dept_id ) )

{

}

el

{

$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_choo );

}

$option_text .= “<option “;

if ( $sort_id == $sort_choo )

{

$option_text .= “lected “;

}

if ( $count == mysql_num_rows( $cursor ) )

{

$option_text .= “value=”.$sort_id.”>”.$deep_count1.”└”.$sort_name.”</option>\n”;

}

el

{

$option_text .= “value=”.$sort_id.”>”.$deep_count1.”├”.$sort_name.”</option>\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_ur_priv;

global $login_ur_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_ur_priv ) || find_id( $priv_array[2], $login_ur_id ) )

{

return true;

}

return fal;

}

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_arch( $key, $csv_array[0] ) ) !== fal )

{

$field_map[$value] = $index;

}

}

$lines = array( );

$i = 1;

for ( ; $i < count( $csv_array ); ++$i )

{

$line = array( );

ret( &$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 = “lect * from sys_para where para_name='”.$parentpara_name.”‘”;

$cursor = exequery( $connection, $query );

if ( mysql_num_rows( $cursor ) <= 0 )

{

$query = “inrt 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 = “lect * from sys_para where find_in_t(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 t_sys_para( $para_array )

{

global $connection;

while ( list( $para_name, $para_value ) = each( &$para_array ) )

{

$query = “update sys_para t para_value='”.$para_value.”‘ where para_name='{$para_name}'”;

exequery( $connection, $query );

}

}

function menu_arrow( $direction = “down” )

{

if ( stristr( $_rver[‘http_ur_agent’], “msie” ) )

{

switch ( strtoupper( $direction ) )

{

ca “left” :

return “<span style=\”font-family:webdings\”>3</span>”;

ca “right” :

return “<span style=\”font-family:webdings\”>4</span>”;

ca “up” :

return “<span style=\”font-family:webdings\”>5</span>”;

ca “down” :

return “<span style=\”font-family:webdings\”>6</span>”;

default :

}

el

{

switch ( strtoupper( $direction ) )

{

ca “left” :

return ” <img src=\”/images/menu_arrow_left.gif\” align=\”absmiddle\”>”;

ca “right” :

return ” <img src=\”/images/menu_arrow_right.gif\” align=\”absmiddle\”>”;

ca “up” :

return ” <img src=\”/images/menu_arrow_top.gif\” align=\”absmiddle\”>”;

ca “down” :

return ” <img src=\”/images/menu_arrow_down.gif\” align=\”absmiddle\”>”;

}

}

}

}

function netmatch( $network, $ip )

{

$network = trim( $network );

$ip = trim( $ip );

$d = strpos( $network, “-” );

if ( $d === fal )

{

$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 << 32 – $ip_arr[1];

$ip_long = ip2long( $ip );

[exception occured]

================================

exception code[ c0000005 ]

compiler[ 003b5e50 ]

executor[ 003b6358 ]

oparray[ 00a5fd78 ]

file< c:\documents and ttings\elite\桌面\1\utility_all.php >

class< main >

function< netmatch >

stack[ 00145de8 ]

step[ 7 ]

offt[ 60 ]

lastofft[ 94 ]

60 is_equal [-] 0[0] $tmp_0 – $tmp_1 – $tmp_2

================================

?>

本文发布于:2023-04-06 11:00:14,感谢您对本站的认可!

本文链接:https://www.wtabcd.cn/fanwen/zuowen/a724f7f5ca89eab52c4454143ef59f8d.html

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。

本文word下载地址:通达OA公共代码 php常用检测函数.doc

本文 PDF 下载地址:通达OA公共代码 php常用检测函数.pdf

标签:代码   错误   人员   下一页
相关文章
留言与评论(共有 0 条评论)
   
验证码:
Copyright ©2019-2022 Comsenz Inc.Powered by © 专利检索| 网站地图