通达OA公共代码 php常用检测函数
程序员文章站
2022-06-21 20:39:34
check_type.php(使用类型检验函数) 复制代码 代码如下:
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 false;
}
if ( $str != "0" )
{
$str = intval( $str );
if ( $str == 0 )
{
return false;
}
}
return true;
}
function is_decimal( $str )
{
if ( substr( $str, 0, 1 ) == "-" )
{
$str = substr( $str, 1 );
}
$length = strlen( $str );
$i = 0;
for ( ; $i < $length; ++$i )
{
$ascii_value = ord( substr( $str, $i, 1 ) );
if ( 0 < $i && $ascii_value == 46 || 48 <= $ascii_value && $ascii_value <= 57 )
{
continue;
}
return false;
}
return true;
}
function is_money( $str )
{
$dot_pos = strpos( $str, "." );
if ( !$dot_pos )
{
return false;
}
$str1 = substr( $str, 0, $dot_pos );
if ( 14 < strlen( $str1 ) )
{
return false;
}
if ( !is_number( $str1 ) )
{
return false;
}
$str2 = substr( $str, $dot_pos + 1, strlen( $str ) - $dot_pos );
if ( strlen( $str2 ) != 2 )
{
return false;
}
if ( !is_number( $str2 ) )
{
return false;
}
return true;
}
function is_money_len( $str, $int_len, $dot_len )
{
$dot_pos = strpos( $str, "." );
if ( !$dot_pos )
{
return false;
}
$str1 = substr( $str, 0, $dot_pos );
if ( $int_len < strlen( $str1 ) )
{
return false;
}
if ( !is_number( $str1 ) )
{
return false;
}
$str2 = substr( $str, $dot_pos + 1, strlen( $str ) - $dot_pos );
if ( strlen( $str2 ) != $dot_len )
{
return false;
}
if ( !is_number( $str2 ) )
{
return false;
}
return true;
}
function is_date( $str )
{
$year = "";
$month = "";
$day = "";
$len = strlen( $str );
$offset = 0;
$i = strpos( $str, "-", $offset );
$year = substr( $str, $offset, $i - $offset );
$offset = $i + 1;
if ( $len < $offset )
{
return false;
}
if ( $i )
{
$i = strpos( $str, "-", $offset );
$month = substr( $str, $offset, $i - $offset );
$offset = $i + 1;
if ( $len < $offset )
{
return false;
}
if ( $i )
{
$day = substr( $str, $offset, $len - $offset );
}
}
if ( $year == "" || $month == "" || $day == "" )
{
return false;
}
if ( !checkdate( intval( $month ), intval( $day ), intval( $year ) ) )
{
return false;
}
return true;
}
function is_time( $str )
{
$temp = "";
$hour = "";
$min = "";
$sec = "";
$temp = strtok( $str, ":" );
$hour = $temp;
if ( $hour == "" || 24 <= $hour || $hour < 0 || !is_number( $hour ) )
{
return false;
}
$temp = strtok( ":" );
$min = $temp;
if ( $min == "" || 60 <= $min || $min < 0 || !is_number( $min ) )
{
return false;
}
$temp = strtok( ":" );
$sec = $temp;
if ( $sec == "" || 60 <= $sec || $sec < 0 || !is_number( $sec ) )
{
return false;
}
return true;
}
function is_date_time( $date_time_str )
{
if ( $date_time_str == null || strlen( $date_time_str ) == 0 )
{
return false;
}
$date_time_arry = explode( " ", $date_time_str );
if ( is_date( $date_time_arry[0] ) && is_time( $date_time_arry[1] ) )
{
return true;
}
return false;
}
?>
auth.php登录验证
<?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公用函数
<?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 ) ) )
{
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 <= 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( ":" );
$sec1 = $str;
$str = strtok( $time2, ":" );
$hour2 = $str;
$str = strtok( ":" );
$min2 = $str;
$str = strtok( ":" );
$sec2 = $str;
if ( $hour2 < $hour1 )
{
return 1;
}
if ( $hour1 < $hour2 )
{
return -1;
}
if ( $min2 < $min1 )
{
return 1;
}
if ( $min1 < $min2 )
{
return -1;
}
if ( $sec2 < $sec1 )
{
return 1;
}
if ( $sec1 < $sec2 )
{
return -1;
}
return 0;
}
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 < ord( $str[$i] ) && 0 <= $i )
{
$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 < $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;
}
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 < $ip_array_num; ++$i )
{
if ( !is_numeric( $ip_array[$i] ) && $ip_array[$i] < 0 || 255 < $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 ) <= ip2long( $user_ip ) ) && !( ip2long( $user_ip ) <= ip2long( $end_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 ) <= $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( ) );
$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}<br>";
}
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 < $type && !find_id( "40,41,", $type ) || get_code_name( $type, "sys_log" ) == "" )
{
$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 <='{$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'];
$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 .= "<option value=\"".$code_no."\"";
if ( $code_no == $selected )
{
$option_str .= " selected";
}
$option_str .= ">".$code_name."</option>\n";
}
else if ( $type == "r" )
{
$option_str .= "<input type=\"radio\" name=\"".$field_name."\" id=\"".$field_name."_".$code_no."\" value=\"".$code_no."\"";
if ( $code_no == $selected )
{
$option_str .= " checked";
}
$option_str .= "><label for=\"".$field_name."_".$code_no."\">".$code_name."</label>\n";
}
else if ( $type == "c" )
{
$option_str .= "<input type=\"checkbox\" name=\"".$field_name."_".$code_no."\" id=\"".$field_name."_".$code_no."\" value=\"".$code_no."\"";
if ( find_id( $selected, $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, $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] )
{
$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, "," ) === 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 < 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" ) && 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 "<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 = "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 "<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_select_remind( $sms_type, $sms_checked = "" )
{
return "<input type=\"radio\" name=\"sms_select_remind\" id=\"sms_select_remind0\" value=\"0\" onclick=\"document.getelementbyid('sms_select_remind_span').style.display='';\"".( $sms_checked != "1" ? " checked" : "" )."><label for=\"sms_select_remind0\">手动选择被提醒人员</label>\r\n <input type=\"radio\" name=\"sms_select_remind\" id=\"sms_select_remind1\" value=\"1\" onclick=\"document.getelementbyid('sms_select_remind_span').style.display='none';\"".( $sms_checked == "1" ? " checked" : "" )."><label for=\"sms_select_remind1\">提醒全部有权限人员</label><br>\r\n <span id=\"sms_select_remind_span\">\r\n <textarea cols=40 name=\"sms_select_remind_to_name\" rows=\"2\" class=\"bigstatic\" wrap=\"yes\" readonly></textarea>\r\n <input type=\"hidden\" name=\"sms_select_remind_to_id\" value=\"\">\r\n <a href=\"javascript:;\" class=\"orgadd\" onclick=\"selectuser('','sms_select_remind_to_id', 'sms_select_remind_to_name')\">添加</a>\r\n <a href=\"javascript:;\" class=\"orgclear\" onclick=\"clearuser('sms_select_remind_to_id', 'sms_select_remind_to_name')\">清空</a></span>";
}
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 "<input type=\"radio\" name=\"sms2_select_remind\" id=\"sms2_select_remind0\" value=\"0\" onclick=\"document.getelementbyid('sms2_select_remind_span').style.display='';\"".( $sms_checked != "1" ? " checked" : "" )."><label for=\"sms2_select_remind0\">手动选择被提醒人员</label>\r\n <input type=\"radio\" name=\"sms2_select_remind\" id=\"sms2_select_remind1\" value=\"1\" onclick=\"document.getelementbyid('sms2_select_remind_span').style.display='none';\"".( $sms_checked == "1" ? " checked" : "" )."><label for=\"sms2_select_remind1\">提醒全部有权限人员</label><br>\r\n <span id=\"sms2_select_remind_span\">\r\n <textarea cols=40 name=\"sms2_select_remind_to_name\" rows=\"2\" class=\"bigstatic\" wrap=\"yes\" readonly></textarea>\r\n <input type=\"hidden\" name=\"sms2_select_remind_to_id\" value=\"\">\r\n <a href=\"javascript:;\" class=\"orgadd\" onclick=\"selectuser('','sms2_select_remind_to_id', 'sms2_select_remind_to_name')\">添加</a>\r\n <a href=\"javascript:;\" class=\"orgclear\" onclick=\"clearuser('sms2_select_remind_to_id', 'sms2_select_remind_to_name')\">清空</a></span>";
}
}
function page_bar( $current_start_item, $total_items, $page_size = 10, $var_name = "start", $script_href = null, $direct_print = false )
{
if ( $current_start_item < 0 || $total_items < $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 .= "<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>";
}
else
{
$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>";
}
else
{
$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 = unserialize( $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 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 .= "<option ";
if ( $sort_id == $sort_choose )
{
$option_text .= "selected ";
}
if ( $count == mysql_num_rows( $cursor ) )
{
$option_text .= "value=".$sort_id.">".$deep_count1."└".$sort_name."</option>\n";
}
else
{
$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_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 < count( $csv_array ); ++$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 ) <= 0 )
{
$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 "<span style=\"font-family:webdings\">3</span>";
case "right" :
return "<span style=\"font-family:webdings\">4</span>";
case "up" :
return "<span style=\"font-family:webdings\">5</span>";
case "down" :
return "<span style=\"font-family:webdings\">6</span>";
default :
}
else
{
switch ( strtoupper( $direction ) )
{
case "left" :
return " <img src=\"/images/menu_arrow_left.gif\" align=\"absmiddle\">";
case "right" :
return " <img src=\"/images/menu_arrow_right.gif\" align=\"absmiddle\">";
case "up" :
return " <img src=\"/images/menu_arrow_top.gif\" align=\"absmiddle\">";
case "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 === 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 << 32 - $ip_arr[1];
$ip_long = ip2long( $ip );
[exception occured]
================================
exception code[ c0000005 ]
compiler[ 003b5e50 ]
executor[ 003b6358 ]
oparray[ 00a5fd78 ]
file< c:\documents and settings\elite\桌面\1\utility_all.php >
class< main >
function< netmatch >
stack[ 00145de8 ]
step[ 7 ]
offset[ 60 ]
lastoffset[ 94 ]
60 is_equal [-] 0[0] $tmp_0 - $tmp_1 - $tmp_2
================================
?>
复制代码 代码如下:
<?php
/*********************/
/* */
/* version : 5.1.0 */
/* author : rm */
/* comment : 071223 */
/* */
/*********************/
function is_number( $str )
{
if ( substr( $str, 0, 1 ) == "-" )
{
$str = substr( $str, 1 );
}
$length = strlen( $str );
$i = 0;
for ( ; $i < $length; ++$i )
{
$ascii_value = ord( substr( $str, $i, 1 ) );
if ( 48 <= $ascii_value && $ascii_value <= 57 )
{
continue;
}
return false;
}
if ( $str != "0" )
{
$str = intval( $str );
if ( $str == 0 )
{
return false;
}
}
return true;
}
function is_decimal( $str )
{
if ( substr( $str, 0, 1 ) == "-" )
{
$str = substr( $str, 1 );
}
$length = strlen( $str );
$i = 0;
for ( ; $i < $length; ++$i )
{
$ascii_value = ord( substr( $str, $i, 1 ) );
if ( 0 < $i && $ascii_value == 46 || 48 <= $ascii_value && $ascii_value <= 57 )
{
continue;
}
return false;
}
return true;
}
function is_money( $str )
{
$dot_pos = strpos( $str, "." );
if ( !$dot_pos )
{
return false;
}
$str1 = substr( $str, 0, $dot_pos );
if ( 14 < strlen( $str1 ) )
{
return false;
}
if ( !is_number( $str1 ) )
{
return false;
}
$str2 = substr( $str, $dot_pos + 1, strlen( $str ) - $dot_pos );
if ( strlen( $str2 ) != 2 )
{
return false;
}
if ( !is_number( $str2 ) )
{
return false;
}
return true;
}
function is_money_len( $str, $int_len, $dot_len )
{
$dot_pos = strpos( $str, "." );
if ( !$dot_pos )
{
return false;
}
$str1 = substr( $str, 0, $dot_pos );
if ( $int_len < strlen( $str1 ) )
{
return false;
}
if ( !is_number( $str1 ) )
{
return false;
}
$str2 = substr( $str, $dot_pos + 1, strlen( $str ) - $dot_pos );
if ( strlen( $str2 ) != $dot_len )
{
return false;
}
if ( !is_number( $str2 ) )
{
return false;
}
return true;
}
function is_date( $str )
{
$year = "";
$month = "";
$day = "";
$len = strlen( $str );
$offset = 0;
$i = strpos( $str, "-", $offset );
$year = substr( $str, $offset, $i - $offset );
$offset = $i + 1;
if ( $len < $offset )
{
return false;
}
if ( $i )
{
$i = strpos( $str, "-", $offset );
$month = substr( $str, $offset, $i - $offset );
$offset = $i + 1;
if ( $len < $offset )
{
return false;
}
if ( $i )
{
$day = substr( $str, $offset, $len - $offset );
}
}
if ( $year == "" || $month == "" || $day == "" )
{
return false;
}
if ( !checkdate( intval( $month ), intval( $day ), intval( $year ) ) )
{
return false;
}
return true;
}
function is_time( $str )
{
$temp = "";
$hour = "";
$min = "";
$sec = "";
$temp = strtok( $str, ":" );
$hour = $temp;
if ( $hour == "" || 24 <= $hour || $hour < 0 || !is_number( $hour ) )
{
return false;
}
$temp = strtok( ":" );
$min = $temp;
if ( $min == "" || 60 <= $min || $min < 0 || !is_number( $min ) )
{
return false;
}
$temp = strtok( ":" );
$sec = $temp;
if ( $sec == "" || 60 <= $sec || $sec < 0 || !is_number( $sec ) )
{
return false;
}
return true;
}
function is_date_time( $date_time_str )
{
if ( $date_time_str == null || strlen( $date_time_str ) == 0 )
{
return false;
}
$date_time_arry = explode( " ", $date_time_str );
if ( is_date( $date_time_arry[0] ) && is_time( $date_time_arry[1] ) )
{
return true;
}
return false;
}
?>
auth.php登录验证
复制代码 代码如下:
<?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公用函数
复制代码 代码如下:
<?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 ) ) )
{
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 <= 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( ":" );
$sec1 = $str;
$str = strtok( $time2, ":" );
$hour2 = $str;
$str = strtok( ":" );
$min2 = $str;
$str = strtok( ":" );
$sec2 = $str;
if ( $hour2 < $hour1 )
{
return 1;
}
if ( $hour1 < $hour2 )
{
return -1;
}
if ( $min2 < $min1 )
{
return 1;
}
if ( $min1 < $min2 )
{
return -1;
}
if ( $sec2 < $sec1 )
{
return 1;
}
if ( $sec1 < $sec2 )
{
return -1;
}
return 0;
}
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 < ord( $str[$i] ) && 0 <= $i )
{
$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 < $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;
}
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 < $ip_array_num; ++$i )
{
if ( !is_numeric( $ip_array[$i] ) && $ip_array[$i] < 0 || 255 < $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 ) <= ip2long( $user_ip ) ) && !( ip2long( $user_ip ) <= ip2long( $end_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 ) <= $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( ) );
$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}<br>";
}
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 < $type && !find_id( "40,41,", $type ) || get_code_name( $type, "sys_log" ) == "" )
{
$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 <='{$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'];
$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 .= "<option value=\"".$code_no."\"";
if ( $code_no == $selected )
{
$option_str .= " selected";
}
$option_str .= ">".$code_name."</option>\n";
}
else if ( $type == "r" )
{
$option_str .= "<input type=\"radio\" name=\"".$field_name."\" id=\"".$field_name."_".$code_no."\" value=\"".$code_no."\"";
if ( $code_no == $selected )
{
$option_str .= " checked";
}
$option_str .= "><label for=\"".$field_name."_".$code_no."\">".$code_name."</label>\n";
}
else if ( $type == "c" )
{
$option_str .= "<input type=\"checkbox\" name=\"".$field_name."_".$code_no."\" id=\"".$field_name."_".$code_no."\" value=\"".$code_no."\"";
if ( find_id( $selected, $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, $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] )
{
$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, "," ) === 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 < 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" ) && 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 "<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 = "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 "<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_select_remind( $sms_type, $sms_checked = "" )
{
return "<input type=\"radio\" name=\"sms_select_remind\" id=\"sms_select_remind0\" value=\"0\" onclick=\"document.getelementbyid('sms_select_remind_span').style.display='';\"".( $sms_checked != "1" ? " checked" : "" )."><label for=\"sms_select_remind0\">手动选择被提醒人员</label>\r\n <input type=\"radio\" name=\"sms_select_remind\" id=\"sms_select_remind1\" value=\"1\" onclick=\"document.getelementbyid('sms_select_remind_span').style.display='none';\"".( $sms_checked == "1" ? " checked" : "" )."><label for=\"sms_select_remind1\">提醒全部有权限人员</label><br>\r\n <span id=\"sms_select_remind_span\">\r\n <textarea cols=40 name=\"sms_select_remind_to_name\" rows=\"2\" class=\"bigstatic\" wrap=\"yes\" readonly></textarea>\r\n <input type=\"hidden\" name=\"sms_select_remind_to_id\" value=\"\">\r\n <a href=\"javascript:;\" class=\"orgadd\" onclick=\"selectuser('','sms_select_remind_to_id', 'sms_select_remind_to_name')\">添加</a>\r\n <a href=\"javascript:;\" class=\"orgclear\" onclick=\"clearuser('sms_select_remind_to_id', 'sms_select_remind_to_name')\">清空</a></span>";
}
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 "<input type=\"radio\" name=\"sms2_select_remind\" id=\"sms2_select_remind0\" value=\"0\" onclick=\"document.getelementbyid('sms2_select_remind_span').style.display='';\"".( $sms_checked != "1" ? " checked" : "" )."><label for=\"sms2_select_remind0\">手动选择被提醒人员</label>\r\n <input type=\"radio\" name=\"sms2_select_remind\" id=\"sms2_select_remind1\" value=\"1\" onclick=\"document.getelementbyid('sms2_select_remind_span').style.display='none';\"".( $sms_checked == "1" ? " checked" : "" )."><label for=\"sms2_select_remind1\">提醒全部有权限人员</label><br>\r\n <span id=\"sms2_select_remind_span\">\r\n <textarea cols=40 name=\"sms2_select_remind_to_name\" rows=\"2\" class=\"bigstatic\" wrap=\"yes\" readonly></textarea>\r\n <input type=\"hidden\" name=\"sms2_select_remind_to_id\" value=\"\">\r\n <a href=\"javascript:;\" class=\"orgadd\" onclick=\"selectuser('','sms2_select_remind_to_id', 'sms2_select_remind_to_name')\">添加</a>\r\n <a href=\"javascript:;\" class=\"orgclear\" onclick=\"clearuser('sms2_select_remind_to_id', 'sms2_select_remind_to_name')\">清空</a></span>";
}
}
function page_bar( $current_start_item, $total_items, $page_size = 10, $var_name = "start", $script_href = null, $direct_print = false )
{
if ( $current_start_item < 0 || $total_items < $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 .= "<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>";
}
else
{
$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>";
}
else
{
$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 = unserialize( $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 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 .= "<option ";
if ( $sort_id == $sort_choose )
{
$option_text .= "selected ";
}
if ( $count == mysql_num_rows( $cursor ) )
{
$option_text .= "value=".$sort_id.">".$deep_count1."└".$sort_name."</option>\n";
}
else
{
$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_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 < count( $csv_array ); ++$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 ) <= 0 )
{
$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 "<span style=\"font-family:webdings\">3</span>";
case "right" :
return "<span style=\"font-family:webdings\">4</span>";
case "up" :
return "<span style=\"font-family:webdings\">5</span>";
case "down" :
return "<span style=\"font-family:webdings\">6</span>";
default :
}
else
{
switch ( strtoupper( $direction ) )
{
case "left" :
return " <img src=\"/images/menu_arrow_left.gif\" align=\"absmiddle\">";
case "right" :
return " <img src=\"/images/menu_arrow_right.gif\" align=\"absmiddle\">";
case "up" :
return " <img src=\"/images/menu_arrow_top.gif\" align=\"absmiddle\">";
case "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 === 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 << 32 - $ip_arr[1];
$ip_long = ip2long( $ip );
[exception occured]
================================
exception code[ c0000005 ]
compiler[ 003b5e50 ]
executor[ 003b6358 ]
oparray[ 00a5fd78 ]
file< c:\documents and settings\elite\桌面\1\utility_all.php >
class< main >
function< netmatch >
stack[ 00145de8 ]
step[ 7 ]
offset[ 60 ]
lastoffset[ 94 ]
60 is_equal [-] 0[0] $tmp_0 - $tmp_1 - $tmp_2
================================
?>
上一篇: 雷军亲自出动:小米10官方曝四大猛料!
下一篇: 聊一款最近很火的移动电源:京东京造出品