请选择 进入手机版 | 继续访问电脑版
风雨十年,感恩同行

[原创] 通达OA2017二次开发破解实例中应用到的PHP检测函数(从全源代码中提取)

[复制链接]
发表于 2018-12-18 06:10:53 | 显示全部楼层 |阅读模式
  1. check_type.php(使用类型检验函数)

  2. 复制代码 代码如下:

  3. <?php
  4. /*********************/
  5. /* */
  6. /* Version : 5.1.0 */
  7. /* Author : RM */
  8. /* Comment : 071223 */
  9. /* */
  10. /*********************/
  11. function is_number( $str )
  12. {
  13. if ( substr( $str, 0, 1 ) == "-" )
  14. {
  15. $str = substr( $str, 1 );
  16. }
  17. $length = strlen( $str );
  18. $i = 0;
  19. for ( ; $i < $length; ++$i )
  20. {
  21. $ascii_value = ord( substr( $str, $i, 1 ) );
  22. if ( 48 <= $ascii_value && $ascii_value <= 57 )
  23. {
  24. continue;
  25. }
  26. return false;
  27. }
  28. if ( $str != "0" )
  29. {
  30. $str = intval( $str );
  31. if ( $str == 0 )
  32. {
  33. return FALSE;
  34. }
  35. }
  36. return TRUE;
  37. }
  38. function is_decimal( $str )
  39. {
  40. if ( substr( $str, 0, 1 ) == "-" )
  41. {
  42. $str = substr( $str, 1 );
  43. }
  44. $length = strlen( $str );
  45. $i = 0;
  46. for ( ; $i < $length; ++$i )
  47. {
  48. $ascii_value = ord( substr( $str, $i, 1 ) );
  49. if ( 0 < $i && $ascii_value == 46 || 48 <= $ascii_value && $ascii_value <= 57 )
  50. {
  51. continue;
  52. }
  53. return FALSE;
  54. }
  55. return TRUE;
  56. }
  57. function is_money( $str )
  58. {
  59. $dot_pos = strpos( $str, "." );
  60. if ( !$dot_pos )
  61. {
  62. return FALSE;
  63. }
  64. $str1 = substr( $str, 0, $dot_pos );
  65. if ( 14 < strlen( $str1 ) )
  66. {
  67. return FALSE;
  68. }
  69. if ( !is_number( $str1 ) )
  70. {
  71. return FALSE;
  72. }
  73. $str2 = substr( $str, $dot_pos + 1, strlen( $str ) - $dot_pos );
  74. if ( strlen( $str2 ) != 2 )
  75. {
  76. return FALSE;
  77. }
  78. if ( !is_number( $str2 ) )
  79. {
  80. return FALSE;
  81. }
  82. return TRUE;
  83. }
  84. function is_money_len( $str, $int_len, $dot_len )
  85. {
  86. $dot_pos = strpos( $str, "." );
  87. if ( !$dot_pos )
  88. {
  89. return FALSE;
  90. }
  91. $str1 = substr( $str, 0, $dot_pos );
  92. if ( $int_len < strlen( $str1 ) )
  93. {
  94. return FALSE;
  95. }
  96. if ( !is_number( $str1 ) )
  97. {
  98. return FALSE;
  99. }
  100. $str2 = substr( $str, $dot_pos + 1, strlen( $str ) - $dot_pos );
  101. if ( strlen( $str2 ) != $dot_len )
  102. {
  103. return FALSE;
  104. }
  105. if ( !is_number( $str2 ) )
  106. {
  107. return FALSE;
  108. }
  109. return TRUE;
  110. }
  111. function is_date( $str )
  112. {
  113. $YEAR = "";
  114. $MONTH = "";
  115. $DAY = "";
  116. $len = strlen( $str );
  117. $offset = 0;
  118. $i = strpos( $str, "-", $offset );
  119. $YEAR = substr( $str, $offset, $i - $offset );
  120. $offset = $i + 1;
  121. if ( $len < $offset )
  122. {
  123. return FALSE;
  124. }
  125. if ( $i )
  126. {
  127. $i = strpos( $str, "-", $offset );
  128. $MONTH = substr( $str, $offset, $i - $offset );
  129. $offset = $i + 1;
  130. if ( $len < $offset )
  131. {
  132. return FALSE;
  133. }
  134. if ( $i )
  135. {
  136. $DAY = substr( $str, $offset, $len - $offset );
  137. }
  138. }
  139. if ( $YEAR == "" || $MONTH == "" || $DAY == "" )
  140. {
  141. return FALSE;
  142. }
  143. if ( !checkdate( intval( $MONTH ), intval( $DAY ), intval( $YEAR ) ) )
  144. {
  145. return FALSE;
  146. }
  147. return TRUE;
  148. }
  149. function is_time( $str )
  150. {
  151. $TEMP = "";
  152. $HOUR = "";
  153. $MIN = "";
  154. $SEC = "";
  155. $TEMP = strtok( $str, ":" );
  156. $HOUR = $TEMP;
  157. if ( $HOUR == "" || 24 <= $HOUR || $HOUR < 0 || !is_number( $HOUR ) )
  158. {
  159. return FALSE;
  160. }
  161. $TEMP = strtok( ":" );
  162. $MIN = $TEMP;
  163. if ( $MIN == "" || 60 <= $MIN || $MIN < 0 || !is_number( $MIN ) )
  164. {
  165. return FALSE;
  166. }
  167. $TEMP = strtok( ":" );
  168. $SEC = $TEMP;
  169. if ( $SEC == "" || 60 <= $SEC || $SEC < 0 || !is_number( $SEC ) )
  170. {
  171. return FALSE;
  172. }
  173. return TRUE;
  174. }
  175. function is_date_time( $DATE_TIME_STR )
  176. {
  177. if ( $DATE_TIME_STR == null || strlen( $DATE_TIME_STR ) == 0 )
  178. {
  179. return FALSE;
  180. }
  181. $DATE_TIME_ARRY = explode( " ", $DATE_TIME_STR );
  182. if ( is_date( $DATE_TIME_ARRY[0] ) && is_time( $DATE_TIME_ARRY[1] ) )
  183. {
  184. return TRUE;
  185. }
  186. return FALSE;
  187. }
  188. ?>

  189. auth.php登录验证

  190. 复制代码 代码如下:

  191. <?php
  192. /*********************/
  193. /* */
  194. /* Version : 5.1.0 */
  195. /* Author : RM */
  196. /* Comment : 071223 */
  197. /* */
  198. /*********************/
  199. if ( $USER_ID == "" || $PASSWORD == "" )
  200. {
  201. echo "201#|#用户名或密码为空";
  202. exit( );
  203. }
  204. if ( $USER_ID != "officeTask" )
  205. {
  206. echo "205#|#用户名错误";
  207. exit( );
  208. }
  209. include_once( "../inc/conn.php" );
  210. include_once( "../inc/utility.php" );
  211. ob_end_clean( );
  212. $query = "select * from EXT_USER where USER_ID='".$USER_ID."'";
  213. $cursor = exequery( $connection, $query );
  214. if ( $ROW = mysql_fetch_array( $cursor ) )
  215. {
  216. $PWD = $ROW['PASSWORD'];
  217. $USE_FLAG = $ROW['USE_FLAG'];
  218. $AUTH_MODULE = $ROW['AUTH_MODULE'];
  219. $POSTFIX = $ROW['POSTFIX'];
  220. if ( md5( $PWD ) != $PASSWORD )
  221. {
  222. echo "203#|#密码错误";
  223. exit( );
  224. }
  225. if ( $USE_FLAG == "0" )
  226. {
  227. echo "204#|#帐号已停用";
  228. exit( );
  229. }
  230. }
  231. else
  232. {
  233. echo "202#|#".$USER_ID;
  234. exit( );
  235. }
  236. ?>

  237. utility_all公用函数

  238. 复制代码 代码如下:

  239. <?php
  240. /*********************/
  241. /* */
  242. /* Version : 5.1.0 */
  243. /* Author : RM */
  244. /* Comment : 071223 */
  245. /* */
  246. /*********************/
  247. function format_date( $STRING1 )
  248. {
  249. $STRING1 = str_replace( "-0", "-", $STRING1 );
  250. $STR = strtok( $STRING1, "-" );
  251. $STRING2 = $STR."年";
  252. $STR = strtok( "-" );
  253. $STRING2 .= $STR."月";
  254. $STR = strtok( " " );
  255. $STRING2 .= $STR."日";
  256. return $STRING2;
  257. }
  258. function format_date_short1( $STRING1 )
  259. {
  260. $STRING1 = str_replace( "-0", "-", $STRING1 );
  261. $STR = strtok( $STRING1, "-" );
  262. $STRING2 = $STR."年";
  263. $STR = strtok( "-" );
  264. $STRING2 .= $STR."月";
  265. return $STRING2;
  266. }
  267. function format_date_short2( $STRING1 )
  268. {
  269. $STRING1 = str_replace( "-0", "-", $STRING1 );
  270. $STR = strtok( $STRING1, "-" );
  271. $STR = strtok( "-" );
  272. $STRING2 .= $STR."月";
  273. $STR = strtok( " " );
  274. $STRING2 .= $STR."日";
  275. return $STRING2;
  276. }
  277. function format_date_short3( $STRING1 )
  278. {
  279. $STRING1 = str_replace( "-0", "-", $STRING1 );
  280. $STR = strtok( $STRING1, "-" );
  281. $STRING2 .= $STR."年";
  282. return $STRING2;
  283. }
  284. function format_date_number( $STRING1 )
  285. {
  286. $STRING1 = str_replace( "-0", "-", $STRING1 );
  287. $STR = strtok( $STRING1, "-" );
  288. $STRING2 = $STR;
  289. $STR = strtok( "-" );
  290. $STRING2 .= strlen( $STR ) == 1 ? "0".$STR : $STR;
  291. $STR = strtok( " " );
  292. $STRING2 .= strlen( $STR ) == 1 ? "0".$STR : $STR;
  293. return $STRING2;
  294. }
  295. function get_week( $STRING )
  296. {
  297. switch ( date( "w", strtotime( $STRING ) ) )
  298. {
  299. case 0 :
  300. return "日";
  301. case 1 :
  302. return "一";
  303. case 2 :
  304. return "二";
  305. case 3 :
  306. return "三";
  307. case 4 :
  308. return "四";
  309. case 5 :
  310. return "五";
  311. case 6 :
  312. return "六";
  313. }
  314. }
  315. function format_money( $STR )
  316. {
  317. if ( $STR == "" )
  318. {
  319. return "";
  320. }
  321. if ( $STR == ".00" )
  322. {
  323. return "0.00";
  324. }
  325. $TOK = strtok( $STR, "." );
  326. if ( strcmp( $STR, $TOK ) == "0" )
  327. {
  328. $STR .= ".00";
  329. }
  330. else
  331. {
  332. $TOK = strtok( "." );
  333. $I = 1;
  334. for ( ; $I <= 2 - strlen( $TOK ); ++$I )
  335. {
  336. $STR .= "0";
  337. }
  338. }
  339. if ( substr( $STR, 0, 1 ) == "." )
  340. {
  341. $STR = "0".$STR;
  342. }
  343. return $STR;
  344. }
  345. function compare_date( $DATE1, $DATE2 )
  346. {
  347. $STR = strtok( $DATE1, "-" );
  348. $YEAR1 = $STR;
  349. $STR = strtok( "-" );
  350. $MON1 = $STR;
  351. $STR = strtok( "-" );
  352. $DAY1 = $STR;
  353. $STR = strtok( $DATE2, "-" );
  354. $YEAR2 = $STR;
  355. $STR = strtok( "-" );
  356. $MON2 = $STR;
  357. $STR = strtok( "-" );
  358. $DAY2 = $STR;
  359. if ( $YEAR2 < $YEAR1 )
  360. {
  361. return 1;
  362. }
  363. if ( $YEAR1 < $YEAR2 )
  364. {
  365. return -1;
  366. }
  367. if ( $MON2 < $MON1 )
  368. {
  369. return 1;
  370. }
  371. if ( $MON1 < $MON2 )
  372. {
  373. return -1;
  374. }
  375. if ( $DAY2 < $DAY1 )
  376. {
  377. return 1;
  378. }
  379. if ( $DAY1 < $DAY2 )
  380. {
  381. return -1;
  382. }
  383. return 0;
  384. }
  385. function compare_time( $TIME1, $TIME2 )
  386. {
  387. $STR = strtok( $TIME1, ":" );
  388. $HOUR1 = $STR;
  389. $STR = strtok( ":" );
  390. $MIN1 = $STR;
  391. $STR = strtok( ":" );
  392. $SEC1 = $STR;
  393. $STR = strtok( $TIME2, ":" );
  394. $HOUR2 = $STR;
  395. $STR = strtok( ":" );
  396. $MIN2 = $STR;
  397. $STR = strtok( ":" );
  398. $SEC2 = $STR;
  399. if ( $HOUR2 < $HOUR1 )
  400. {
  401. return 1;
  402. }
  403. if ( $HOUR1 < $HOUR2 )
  404. {
  405. return -1;
  406. }
  407. if ( $MIN2 < $MIN1 )
  408. {
  409. return 1;
  410. }
  411. if ( $MIN1 < $MIN2 )
  412. {
  413. return -1;
  414. }
  415. if ( $SEC2 < $SEC1 )
  416. {
  417. return 1;
  418. }
  419. if ( $SEC1 < $SEC2 )
  420. {
  421. return -1;
  422. }
  423. return 0;
  424. }
  425. function compare_date_time( $DATE_TIME1, $DATE_TIME2 )
  426. {
  427. if ( $DATE_TIME1 == NULL || strlen( $DATE_TIME1 ) == 0 || $DATE_TIME2 == NULL || strlen( $DATE_TIME2 ) == 0 )
  428. {
  429. return -1;
  430. }
  431. $DATE_TIME1_ARRY = explode( " ", $DATE_TIME1 );
  432. $DATE_TIME2_ARRY = explode( " ", $DATE_TIME2 );
  433. if ( compare_date( $DATE_TIME1_ARRY[0], $DATE_TIME2_ARRY[0] ) == 1 )
  434. {
  435. return 1;
  436. }
  437. if ( compare_date( $DATE_TIME1_ARRY[0], $DATE_TIME2_ARRY[0] ) == 0 )
  438. {
  439. if ( compare_time( $DATE_TIME1_ARRY[1], $DATE_TIME2_ARRY[1] ) == 1 )
  440. {
  441. return 1;
  442. }
  443. if ( compare_time( $DATE_TIME1_ARRY[1], $DATE_TIME2_ARRY[1] ) == 0 )
  444. {
  445. return 0;
  446. }
  447. return -1;
  448. }
  449. return -1;
  450. }
  451. function is_chinese( &$str, $location )
  452. {
  453. $ch = TRUE;
  454. $i = $location;
  455. while ( 160 < ord( $str[$i] ) && 0 <= $i )
  456. {
  457. $ch = !$ch;
  458. --$i;
  459. }
  460. if ( $i != $location )
  461. {
  462. $f_str = $ch ? 1 : -1;
  463. return $f_str;
  464. }
  465. $f_str = FALSE;
  466. return $f_str;
  467. }
  468. function csubstr( &$str, $start = 0, $long = 0, $ltor = TRUE, $cn_len = 2 )
  469. {
  470. if ( $long == 0 )
  471. {
  472. $long = strlen( $str );
  473. }
  474. if ( !$ltor )
  475. {
  476. $str = cstrrev( $str );
  477. }
  478. if ( $cn_len == 1 )
  479. {
  480. $i = 0;
  481. $fs = 0;
  482. for ( ; $i < $start; ++$fs )
  483. {
  484. $i += ord( $str[$fs] ) <= 160 ? 1 : 0.5;
  485. }
  486. $i = 0;
  487. $fe = $fs;
  488. for ( ; $i < $long; ++$fe )
  489. {
  490. $i += ord( $str[$fe] ) <= 160 ? 1 : 0.5;
  491. }
  492. $long = $fe - $fs;
  493. }
  494. else
  495. {
  496. $fs = is_chinese( &$str, $start ) == 1 ? $start - 1 : $start;
  497. $fe = $long + $start - 1;
  498. $end = is_chinese( &$str, $fe ) == -1 ? $fe - 1 : $fe;
  499. $long = $end - $fs + 1;
  500. }
  501. $f_str = substr( $str, $fs, $long );
  502. if ( !$ltor )
  503. {
  504. $f_str = cstrrev( $f_str );
  505. }
  506. return $f_str;
  507. }
  508. function is_ip( $IP )
  509. {
  510. $IP_ARRAY = explode( ".", $IP );
  511. $IP_ARRAY_NUM = sizeof( $IP_ARRAY );
  512. if ( $IP_ARRAY_NUM != 4 )
  513. {
  514. return FALSE;
  515. }
  516. $I = 0;
  517. for ( ; $I < $IP_ARRAY_NUM; ++$I )
  518. {
  519. if ( !is_numeric( $IP_ARRAY[$I] ) && $IP_ARRAY[$I] < 0 || 255 < $IP_ARRAY[$I] )
  520. {
  521. return FALSE;
  522. }
  523. if ( !( $I == 3 ) && !( $IP_ARRAY[$I] == 255 ) )
  524. {
  525. continue;
  526. }
  527. return FALSE;
  528. }
  529. return TRUE;
  530. }
  531. function check_ip( $USER_IP, $TYPE, $USER_ID )
  532. {
  533. global $connection;
  534. $query = "SELECT PARA_VALUE from SYS_PARA where PARA_NAME='IP_UNLIMITED_USER'";
  535. $cursor = exequery( $connection, $query );
  536. if ( $ROW = mysql_fetch_array( $cursor ) )
  537. {
  538. $IP_UNLIMITED_USER = $ROW['PARA_VALUE'];
  539. }
  540. if ( find_id( $IP_UNLIMITED_USER, $USER_ID ) )
  541. {
  542. return TRUE;
  543. }
  544. $query = "select * from IP_RULE where TYPE='".$TYPE."'";
  545. $cursor = exequery( $connection, $query );
  546. $RULE_COUNT = 0;
  547. $FLAG = 0;
  548. while ( $ROW = mysql_fetch_array( $cursor ) )
  549. {
  550. ++$RULE_COUNT;
  551. $BEGIN_IP = $ROW['BEGIN_IP'];
  552. $END_IP = $ROW['END_IP'];
  553. if ( !( ip2long( $BEGIN_IP ) <= ip2long( $USER_IP ) ) && !( ip2long( $USER_IP ) <= ip2long( $END_IP ) ) )
  554. {
  555. continue;
  556. }
  557. $FLAG = 1;
  558. break;
  559. }
  560. if ( $RULE_COUNT == 0 || $FLAG == 1 )
  561. {
  562. return TRUE;
  563. }
  564. return FALSE;
  565. }
  566. function maskstr( $STR, $FIRST, $LAST )
  567. {
  568. if ( is_numeric( $FIRST ) )
  569. {
  570. }
  571. if ( !is_numeric( $LAST ) )
  572. {
  573. return;
  574. }
  575. if ( strlen( $STR ) <= $FIRST + $LAST )
  576. {
  577. return $STR;
  578. }
  579. $RETURN_STR = substr( $STR, 0, $FIRST );
  580. $I = 0;
  581. for ( ; $I < strlen( substr( $STR, $FIRST, 0 - $LAST ) ); ++$I )
  582. {
  583. $RETURN_STR .= "*";
  584. }
  585. $RETURN_STR .= substr( $STR, 0 - $LAST );
  586. return $RETURN_STR;
  587. }
  588. function add_log( $TYPE, $REMARK, $OPERATOR )
  589. {
  590. global $connection;
  591. $CUR_TIME = date( "Y-m-d H:i:s", time( ) );
  592. $USER_IP = get_client_ip( );
  593. if ( $TYPE == 1 )
  594. {
  595. $query = "update USER set LAST_VISIT_IP='".$USER_IP."' where USER_ID='{$OPERATOR}'";
  596. exequery( $connection, $query );
  597. }
  598. else
  599. {
  600. if ( $TYPE == 3 || $TYPE == 4 || $TYPE == 5 )
  601. {
  602. include_once( "inc/itask/itask.php" );
  603. global $DEPT_PARENT;
  604. if ( $TYPE == 3 || $TYPE == 4 )
  605. {
  606. $result = itask( array(
  607. "LOG_".$TYPE." ".$REMARK.",".$DEPT_PARENT
  608. ) );
  609. }
  610. $query = "SELECT DEPT_ID,DEPT_NAME from DEPARTMENT where DEPT_ID='".$REMARK."'";
  611. $cursor = exequery( $connection, $query );
  612. if ( $ROW = mysql_fetch_array( $cursor ) )
  613. {
  614. $DEPT_ID = $ROW['DEPT_ID'];
  615. $DEPT_NAME = $ROW['DEPT_NAME'];
  616. }
  617. $REMARK = "{$DEPT_NAME},DEPT_ID={$DEPT_ID},DEPT_PARENT={$DEPT_PARENT}";
  618. if ( $result === FALSE )
  619. {
  620. message( "错误", itask_last_error( ) );
  621. button_back( );
  622. exit( );
  623. }
  624. }
  625. else if ( $TYPE == 6 || $TYPE == 7 || $TYPE == 8 || $TYPE == 11 )
  626. {
  627. include_once( "inc/itask/itask.php" );
  628. global $DEPT_ID;
  629. global $NOT_LOGIN;
  630. if ( $TYPE == 6 || $TYPE == 7 )
  631. {
  632. $result = itask( array(
  633. "LOG_".$TYPE." ".$REMARK.",".$DEPT_ID.",".$NOT_LOGIN
  634. ) );
  635. }
  636. $query = "SELECT USER_ID,USER_NAME,DEPT_ID from USER where find_in_set(USER_ID,'".$REMARK."')";
  637. $cursor = exequery( $connection, $query );
  638. $REMARK = "";
  639. while ( $ROW = mysql_fetch_array( $cursor ) )
  640. {
  641. $USER_ID = $ROW['USER_ID'];
  642. $USER_NAME = $ROW['USER_NAME'];
  643. $DEPT_ID = $ROW['DEPT_ID'];
  644. $query = "SELECT DEPT_NAME from DEPARTMENT where DEPT_ID='".$DEPT_ID."'";
  645. $cursor1 = exequery( $connection, $query );
  646. if ( $ROW = mysql_fetch_array( $cursor1 ) )
  647. {
  648. $DEPT_NAME = $ROW['DEPT_NAME'];
  649. }
  650. $REMARK .= "[".$DEPT_NAME."]{$USER_NAME},USER_ID={$USER_ID}<br>";
  651. }
  652. if ( $result === FALSE )
  653. {
  654. message( "错误", itask_last_error( ) );
  655. button_back( );
  656. exit( );
  657. }
  658. }
  659. }
  660. $REMARK = str_replace( "'", "\\'", $REMARK );
  661. $REMARK = str_replace( "\\\\'", "\\'", $REMARK );
  662. $query = "insert into SYS_LOG (USER_ID,TIME,IP,TYPE,REMARK) values ('".$OPERATOR."','{$CUR_TIME}','{$USER_IP}','{$TYPE}','{$REMARK}')";
  663. exequery( $connection, $query );
  664. if ( 21 < $TYPE && !find_id( "40,41,", $TYPE ) || get_code_name( $TYPE, "SYS_LOG" ) == "" )
  665. {
  666. $query1 = "INSERT INTO `SYS_CODE` ( `CODE_NO` , `CODE_NAME` , `CODE_ORDER` , `PARENT_NO` , `CODE_FLAG` ) VALUES ('".$TYPE."', '未知类型', '99', 'SYS_LOG', '1');";
  667. exequery( $connection, $query1 );
  668. }
  669. return $query;
  670. }
  671. function affair_sms( )
  672. {
  673. include_once( "inc/utility_sms1.php" );
  674. global $connection;
  675. global $LOGIN_USER_ID;
  676. $CUR_DATE = date( "Y-m-d", time( ) );
  677. $CUR_TIME = date( "Y-m-d H:i:s", time( ) );
  678. $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')";
  679. $cursor = exequery( $connection, $query );
  680. while ( $ROW = mysql_fetch_array( $cursor ) )
  681. {
  682. $AFF_ID = $ROW['AFF_ID'];
  683. $USER_ID = $ROW['USER_ID'];
  684. $TYPE = $ROW['TYPE'];
  685. $REMIND_DATE = $ROW['REMIND_DATE'];
  686. $REMIND_TIME = $ROW['REMIND_TIME'];
  687. $CONTENT = $ROW['CONTENT'];
  688. $SEND_TIME = date( "Y-m-d", time( ) )." ".$REMIND_TIME;
  689. $SMS_CONTENT = "日常事务提醒:".csubstr( &$CONTENT, 0, 100 );
  690. $FLAG = 0;
  691. if ( $TYPE == "2" )
  692. {
  693. $FLAG = 1;
  694. }
  695. else if ( $TYPE == "3" && date( "w", time( ) ) == $REMIND_DATE )
  696. {
  697. $FLAG = 1;
  698. }
  699. else if ( $TYPE == "4" && date( "j", time( ) ) == $REMIND_DATE )
  700. {
  701. $FLAG = 1;
  702. }
  703. else if ( $TYPE == "5" )
  704. {
  705. $REMIND_ARR = explode( "-", $REMIND_DATE );
  706. $REMIND_DATE_MON = $REMIND_ARR[0];
  707. $REMIND_DATE_DAY = $REMIND_ARR[1];
  708. if ( date( "n", time( ) ) == $REMIND_DATE_MON && date( "j", time( ) ) == $REMIND_DATE_DAY )
  709. {
  710. $FLAG = 1;
  711. }
  712. }
  713. if ( $FLAG == 1 )
  714. {
  715. send_sms( $SEND_TIME, $LOGIN_USER_ID, $LOGIN_USER_ID, 5, $SMS_CONTENT, "1:calendar/affair/note.php?AFF_ID=".$AFF_ID );
  716. $query = "update AFFAIR set LAST_REMIND='".$CUR_DATE."' where AFF_ID='{$AFF_ID}'";
  717. exequery( $connection, $query );
  718. }
  719. }
  720. }
  721. function get_code_name( $CODE_NO, $PARENT_NO )
  722. {
  723. if ( $CODE_NO == "" || $PARENT_NO == "" )
  724. {
  725. return "";
  726. }
  727. global $connection;
  728. $query = "SELECT CODE_NAME from SYS_CODE where PARENT_NO='".$PARENT_NO."' and find_in_set(CODE_NO,'{$CODE_NO}')";
  729. $cursor = exequery( $connection, $query );
  730. while ( $ROW = mysql_fetch_array( $cursor ) )
  731. {
  732. $CODE_NAME .= $ROW['CODE_NAME'].",";
  733. }
  734. return substr( $CODE_NAME, 0, -2 );
  735. }
  736. function code_list( $PARENT_NO, $SELECTED = "", $TYPE = "D", $FIELD_NAME = "" )
  737. {
  738. if ( $PARENT_NO == "" )
  739. {
  740. return;
  741. }
  742. global $connection;
  743. $query = "select CODE_NO,CODE_NAME from SYS_CODE where PARENT_NO='".$PARENT_NO."' order by CODE_ORDER";
  744. $cursor = exequery( $connection, $query );
  745. while ( $ROW = mysql_fetch_array( $cursor ) )
  746. {
  747. $CODE_NO = $ROW['CODE_NO'];
  748. $CODE_NAME = $ROW['CODE_NAME'];
  749. if ( $TYPE == "D" )
  750. {
  751. $OPTION_STR .= "<option value="".$CODE_NO.""";
  752. if ( $CODE_NO == $SELECTED )
  753. {
  754. $OPTION_STR .= " selected";
  755. }
  756. $OPTION_STR .= ">".$CODE_NAME."</option>\n";
  757. }
  758. else if ( $TYPE == "R" )
  759. {
  760. $OPTION_STR .= "<input type="radio" name="".$FIELD_NAME."" id="".$FIELD_NAME."_".$CODE_NO."" value="".$CODE_NO.""";
  761. if ( $CODE_NO == $SELECTED )
  762. {
  763. $OPTION_STR .= " checked";
  764. }
  765. $OPTION_STR .= "><label for="".$FIELD_NAME."_".$CODE_NO."">".$CODE_NAME."</label>\n";
  766. }
  767. else if ( $TYPE == "C" )
  768. {
  769. $OPTION_STR .= "<input type="checkbox" name="".$FIELD_NAME."_".$CODE_NO."" id="".$FIELD_NAME."_".$CODE_NO."" value="".$CODE_NO.""";
  770. if ( find_id( $SELECTED, $CODE_NO ) )
  771. {
  772. $OPTION_STR .= " checked";
  773. }
  774. $OPTION_STR .= "><label for="".$FIELD_NAME."_".$CODE_NO."">".$CODE_NAME."</label>\n";
  775. }
  776. }
  777. return $OPTION_STR;
  778. }
  779. function get_code_array( $PARENT_NO, $REVERSE = FALSE )
  780. {
  781. $CODE_ARRAY = array( );
  782. if ( $PARENT_NO == "" )
  783. {
  784. return $CODE_ARRAY;
  785. }
  786. global $connection;
  787. $query = "select CODE_NO,CODE_NAME from SYS_CODE where PARENT_NO='".$PARENT_NO."' order by CODE_ORDER";
  788. $cursor = exequery( $connection, $query );
  789. while ( $ROW = mysql_fetch_array( $cursor ) )
  790. {
  791. $CODE_NO = $ROW['CODE_NO'];
  792. $CODE_NAME = $ROW['CODE_NAME'];
  793. if ( !$REVERSE )
  794. {
  795. $CODE_ARRAY[$CODE_NO] = $CODE_NAME;
  796. }
  797. else
  798. {
  799. $CODE_ARRAY[$CODE_NAME] = $CODE_NO;
  800. }
  801. }
  802. return $CODE_ARRAY;
  803. }
  804. function sms_type_url( $SMS_TYPE, $CONTENT )
  805. {
  806. switch ( $SMS_TYPE )
  807. {
  808. case "0" :
  809. $URL = "/general/sms/receive/";
  810. return $URL;
  811. case "1" :
  812. $URL = "/general/notify/show/";
  813. return $URL;
  814. case "2" :
  815. $URL = "/general/email/inbox/?BOX_ID=0";
  816. return $URL;
  817. case "3" :
  818. $URL = "/general/netmeeting/";
  819. return $URL;
  820. case "4" :
  821. $URL = "/general/salary/report/";
  822. return $URL;
  823. case "5" :
  824. $URL = "/general/calendar/";
  825. return $URL;
  826. case "6" :
  827. if ( strstr( $CONTENT, "提交" ) && strstr( $CONTENT, "申请" ) && strstr( $CONTENT, "请批示" ) )
  828. {
  829. $URL = "/general/attendance/manage/";
  830. return $URL;
  831. }
  832. $URL = "/general/attendance/personal/";
  833. return $URL;
  834. case "7" :
  835. $URL = "/general/workflow/list";
  836. return $URL;
  837. case "8" :
  838. $URL = "/general/meeting/manage/";
  839. return $URL;
  840. case "9" :
  841. if ( strstr( $CONTENT, "提交" ) )
  842. {
  843. if ( strstr( $CONTENT, "申请" ) )
  844. {
  845. }
  846. }
  847. if ( strstr( $CONTENT, "请批示" ) || strstr( $CONTENT, "部门领导" ) && strstr( $CONTENT, "批准了" ) )
  848. {
  849. $URL = "/general/vehicle/checkup/";
  850. return $URL;
  851. }
  852. if ( strstr( $CONTENT, "部门审批" ) )
  853. {
  854. $URL = "/general/vehicle/dept_manage/";
  855. return $URL;
  856. }
  857. $URL = "/general/vehicle/";
  858. return $URL;
  859. case "10" :
  860. $URL = "/general/mobile_sms/";
  861. return $URL;
  862. case "11" :
  863. $URL = "/general/vote/show/";
  864. return $URL;
  865. case "12" :
  866. $URL = "/general/work_plan/show/";
  867. return $URL;
  868. case "13" :
  869. $URL = "/general/diary/";
  870. return $URL;
  871. case "14" :
  872. $URL = "/general/news/show/";
  873. return $URL;
  874. case "15" :
  875. $URL = "/general/score/submit/";
  876. return $URL;
  877. case "16" :
  878. $URL = "/general/file_folder/index1.php";
  879. return $URL;
  880. case "17" :
  881. $URL = "/general/netdisk";
  882. return $URL;
  883. case "18" :
  884. $URL = "/general/bbs";
  885. return $URL;
  886. case "20" :
  887. $URL = "/general/file_folder?FILE_SORT=2&SORT_ID=0";
  888. return $URL;
  889. case "30" :
  890. $URL = "/general/training/manage/show";
  891. return $URL;
  892. case "31" :
  893. if ( strstr( $CONTENT, "批准了" ) || strstr( $CONTENT, "未批准" ) || strstr( $CONTENT, "撤销了" ) )
  894. {
  895. $URL = "/general/training/train/apply/";
  896. return $URL;
  897. }
  898. $URL = "/general/training/manage/apply_manage/";
  899. return $URL;
  900. case "32" :
  901. $URL = "/general/training/train/survey/";
  902. return $URL;
  903. case "33" :
  904. $URL = "/general/training/train/information/";
  905. return $URL;
  906. case "34" :
  907. $URL = "/general/training/train/assessment/";
  908. return $URL;
  909. case "35" :
  910. $URL = "/general/hrms/manage/";
  911. }
  912. return $URL;
  913. }
  914. function avatar_size( $AVATAR )
  915. {
  916. global $ROOT_PATH;
  917. global $connection;
  918. global $AVATAR_WIDTH;
  919. global $AVATAR_HEIGHT;
  920. $FILENAME = $ROOT_PATH."images/avatar/".$AVATAR.".gif";
  921. if ( !$AVATAR_WIDTH && !$AVATAR_HEIGHT )
  922. {
  923. $query = "SELECT AVATAR_WIDTH,AVATAR_HEIGHT from INTERFACE";
  924. $cursor = exequery( $connection, $query );
  925. if ( $ROW = mysql_fetch_array( $cursor ) )
  926. {
  927. $AVATAR_WIDTH = $ROW['AVATAR_WIDTH'];
  928. $AVATAR_HEIGHT = $ROW['AVATAR_HEIGHT'];
  929. }
  930. }
  931. $IMG_ATTR = @getimagesize( $FILENAME );
  932. if ( $AVATAR_WIDTH < $IMG_ATTR[0] )
  933. {
  934. $IMG_ATTR[0] = $AVATAR_WIDTH;
  935. }
  936. if ( $AVATAR_HEIGHT < $IMG_ATTR[1] )
  937. {
  938. $IMG_ATTR[1] = $AVATAR_HEIGHT;
  939. }
  940. if ( $IMG_ATTR[0] < 15 )
  941. {
  942. $IMG_ATTR[0] = 15;
  943. }
  944. if ( $IMG_ATTR[1] < 15 )
  945. {
  946. $IMG_ATTR[1] = 15;
  947. }
  948. return "width="".$IMG_ATTR['0']."" height="{$IMG_ATTR['1']}"";
  949. }
  950. function format_cvs( $STR )
  951. {
  952. $STR = str_replace( """, "", $STR );
  953. $STR = str_replace( "\n", "", $STR );
  954. $STR = str_replace( "\r", "", $STR );
  955. $STR = str_replace( "'", "\\'", $STR );
  956. if ( strpos( $STR, "," ) === FALSE )
  957. {
  958. return $STR;
  959. }
  960. $STR = """.$STR.""";
  961. return $STR;
  962. }
  963. function keyed_str( $TXT, $ENCRYPT_KEY )
  964. {
  965. $ENCRYPT_KEY = md5( $ENCRYPT_KEY );
  966. $CTR = 0;
  967. $TMP = "";
  968. $I = 0;
  969. for ( ; $I < strlen( $TXT ); ++$I )
  970. {
  971. if ( $CTR == strlen( $ENCRYPT_KEY ) )
  972. {
  973. $CTR = 0;
  974. }
  975. $TMP .= substr( $TXT, $I, 1 ) ^ substr( $ENCRYPT_KEY, $CTR, 1 );
  976. ++$CTR;
  977. }
  978. return $TMP;
  979. }
  980. function encrypt_str( $TXT, $KEY )
  981. {
  982. srand( ( double )microtime( ) * 1000000 );
  983. $ENCRYPT_KEY = md5( rand( 0, 32000 ) );
  984. $CTR = 0;
  985. $TMP = "";
  986. $I = 0;
  987. for ( ; $I < strlen( $TXT ); ++$I )
  988. {
  989. if ( $CTR == strlen( $ENCRYPT_KEY ) )
  990. {
  991. $CTR = 0;
  992. }
  993. $TMP .= substr( $ENCRYPT_KEY, $CTR, 1 ).( substr( $TXT, $I, 1 ) ^ substr( $ENCRYPT_KEY, $CTR, 1 ) );
  994. ++$CTR;
  995. }
  996. return keyed_str( $TMP, $KEY );
  997. }
  998. function decrypt_str( $TXT, $KEY )
  999. {
  1000. $TXT = keyed_str( $TXT, $KEY );
  1001. $TMP = "";
  1002. $I = 0;
  1003. for ( ; $I < strlen( $TXT ); ++$I )
  1004. {
  1005. $MD5 = substr( $TXT, $I, 1 );
  1006. ++$I;
  1007. $TMP .= substr( $TXT, $I, 1 ) ^ $MD5;
  1008. }
  1009. return $TMP;
  1010. }
  1011. function get_client_ip( )
  1012. {
  1013. if ( getenv( "REMOTE_ADDR" ) && strcasecmp( getenv( "REMOTE_ADDR" ), "unknown" ) )
  1014. {
  1015. $onlineip = getenv( "REMOTE_ADDR" );
  1016. return $onlineip;
  1017. }
  1018. if ( isset( $_SERVER['REMOTE_ADDR'] ) && $_SERVER['REMOTE_ADDR'] && strcasecmp( $_SERVER['REMOTE_ADDR'], "unknown" ) )
  1019. {
  1020. $onlineip = $_SERVER['REMOTE_ADDR'];
  1021. return $onlineip;
  1022. }
  1023. if ( getenv( "HTTP_CLIENT_IP" ) && strcasecmp( getenv( "HTTP_CLIENT_IP" ), "unknown" ) )
  1024. {
  1025. $onlineip = getenv( "HTTP_CLIENT_IP" );
  1026. return $onlineip;
  1027. }
  1028. if ( getenv( "HTTP_X_FORWARDED_FOR" ) && strcasecmp( getenv( "HTTP_X_FORWARDED_FOR" ), "unknown" ) )
  1029. {
  1030. $onlineip = getenv( "HTTP_X_FORWARDED_FOR" );
  1031. }
  1032. return $onlineip;
  1033. }
  1034. function dept_long_name( $DEPT_ID )
  1035. {
  1036. global $SYS_DEPARTMENT;
  1037. include_once( "inc/department.php" );
  1038. if ( is_array( $SYS_DEPARTMENT ) )
  1039. {
  1040. }
  1041. if ( !array_key_exists( $DEPT_ID, $SYS_DEPARTMENT ) )
  1042. {
  1043. include_once( "inc/utility_org.php" );
  1044. cache_department( );
  1045. include( "inc/department.php" );
  1046. }
  1047. return $SYS_DEPARTMENT[$DEPT_ID]['DEPT_LONG_NAME'];
  1048. }
  1049. function sms_remind( $SMS_TYPE, $SMS_CHECKED = "" )
  1050. {
  1051. global $connection;
  1052. global $LOGIN_USER_ID;
  1053. $query = "select * from SYS_PARA where PARA_NAME='SMS_REMIND'";
  1054. $cursor = exequery( $connection, $query );
  1055. if ( $ROW = mysql_fetch_array( $cursor ) )
  1056. {
  1057. $PARA_VALUE = $ROW['PARA_VALUE'];
  1058. }
  1059. $REMIND_ARRAY = explode( "|", $PARA_VALUE );
  1060. $SMS_REMIND = $REMIND_ARRAY[0];
  1061. $SMS2_REMIND = $REMIND_ARRAY[1];
  1062. $SMS3_REMIND = $REMIND_ARRAY[2];
  1063. if ( find_id( $SMS3_REMIND, $SMS_TYPE ) )
  1064. {
  1065. echo "<input type="checkbox" name="SMS_REMIND" id="SMS_REMIND"";
  1066. if ( $SMS_CHECKED == "1" || find_id( $SMS_REMIND, $SMS_TYPE ) )
  1067. {
  1068. echo " checked";
  1069. }
  1070. echo "><label for="SMS_REMIND">使用内部短信提醒</label>  ";
  1071. }
  1072. $query = "select * from SMS2_PRIV";
  1073. $cursor = exequery( $connection, $query );
  1074. if ( $ROW = mysql_fetch_array( $cursor ) )
  1075. {
  1076. $TYPE_PRIV = $ROW['TYPE_PRIV'];
  1077. $SMS2_REMIND_PRIV = $ROW['SMS2_REMIND_PRIV'];
  1078. }
  1079. if ( find_id( $TYPE_PRIV, $SMS_TYPE ) && find_id( $SMS2_REMIND_PRIV, $LOGIN_USER_ID ) )
  1080. {
  1081. echo "<input type="checkbox" name="SMS2_REMIND" id="SMS2_REMIND"";
  1082. if ( find_id( $SMS2_REMIND, $SMS_TYPE ) )
  1083. {
  1084. echo " checked";
  1085. }
  1086. echo "><label for="SMS2_REMIND">使用手机短信提醒</label>";
  1087. }
  1088. }
  1089. function sms_select_remind( $SMS_TYPE, $SMS_CHECKED = "" )
  1090. {
  1091. 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>";
  1092. }
  1093. function sms2_select_remind( $SMS_TYPE, $SMS_CHECKED = "" )
  1094. {
  1095. global $connection;
  1096. global $LOGIN_USER_ID;
  1097. $query = "select * from SMS2_PRIV";
  1098. $cursor = exequery( $connection, $query );
  1099. if ( $ROW = mysql_fetch_array( $cursor ) )
  1100. {
  1101. $TYPE_PRIV = $ROW['TYPE_PRIV'];
  1102. $SMS2_REMIND_PRIV = $ROW['SMS2_REMIND_PRIV'];
  1103. }
  1104. if ( find_id( $TYPE_PRIV, $SMS_TYPE ) && find_id( $SMS2_REMIND_PRIV, $LOGIN_USER_ID ) )
  1105. {
  1106. 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>";
  1107. }
  1108. }
  1109. function page_bar( $current_start_item, $total_items, $page_size = 10, $var_name = "start", $script_href = NULL, $direct_print = FALSE )
  1110. {
  1111. if ( $current_start_item < 0 || $total_items < $current_start_item )
  1112. {
  1113. $current_start_item = 0;
  1114. }
  1115. if ( $script_href == NULL )
  1116. {
  1117. $script_href = $_SERVER['PHP_SELF'];
  1118. }
  1119. if ( $_SERVER['QUERY_STRING'] != "" )
  1120. {
  1121. $script_href .= "?".$_SERVER['QUERY_STRING'];
  1122. }
  1123. $script_href = preg_replace( "/^(.+)(\\?|&)TOTAL_ITEMS=[^&]+&?(.*)\$/i", "\$1\$2\$3", $script_href );
  1124. $script_href = preg_replace( "/^(.+)(\\?|&)PAGE_SIZE=[^&]+&?(.*)\$/i", "\$1\$2\$3", $script_href );
  1125. $script_href = preg_replace( "/^(.+)(\\?|&)".$var_name."=[^&]+&?(.*)\$/i", "\$1\$2\$3", $script_href );
  1126. if ( substr( $script_href, -1 ) == "&" || substr( $script_href, -1 ) == "?" )
  1127. {
  1128. $script_href = substr( $script_href, 0, -1 );
  1129. }
  1130. $hyphen = strstr( $script_href, "?" ) === FALSE ? "?" : "&";
  1131. $num_pages = ceil( $total_items / $page_size );
  1132. $cur_page = floor( $current_start_item / $page_size ) + 1;
  1133. $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>";
  1134. $result_str .= "<div id="pageArea" class="pageArea">\n第<span id="pageNumber" class="pageNumber">".$cur_page."/".$num_pages."</span>页";
  1135. if ( $cur_page <= 1 )
  1136. {
  1137. $result_str .= "<a href="javascript:;" id="pageFirst" class="pageFirstDisable" title="首页"></a>\r\n <a href="javascript:;" id="pagePrevious" class="pagePreviousDisable" title="上一页"></a>";
  1138. }
  1139. else
  1140. {
  1141. $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>";
  1142. }
  1143. if ( $num_pages <= $cur_page )
  1144. {
  1145. $result_str .= "<a href="javascript:;" id="pageNext" class="pageNextDisable" title="下一页"></a>\r\n <a href="javascript:;" id="pageLast" class="pageLastDisable" title="末页"></a>";
  1146. }
  1147. else
  1148. {
  1149. $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>";
  1150. }
  1151. $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>";
  1152. if ( $direct_print )
  1153. {
  1154. echo $result_str;
  1155. }
  1156. return $result_str;
  1157. }
  1158. function get_page_size( $MODULE, $DEFAULT_SIZE = 10 )
  1159. {
  1160. $PARA_ARRAY = get_sys_para( "PAGE_BAR_SIZE" );
  1161. $PAGE_SIZE_ARRAY = unserialize( $PARA_ARRAY['PAGE_BAR_SIZE'] );
  1162. $PAGE_SIZE = intval( $PAGE_SIZE_ARRAY[$MODULE] );
  1163. $PAGE_SIZE = 0 < $PAGE_SIZE ? $PAGE_SIZE : $DEFAULT_SIZE;
  1164. return $PAGE_SIZE;
  1165. }
  1166. 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 = "" )
  1167. {
  1168. global $ATTACH_PATH2;
  1169. include_once( "inc/phpmailer/class.phpmailer.php" );
  1170. include_once( "inc/utility_file.php" );
  1171. $mail = new PHPMailer( );
  1172. $mail->SetLanguage( "zh" );
  1173. $mail->IsSMTP( );
  1174. $mail->Host = $SMTP_SERVER;
  1175. $mail->Port = $SMTP_PORT;
  1176. $mail->SMTPAuth = $SMTP_AUTH;
  1177. $mail->SMTPSecure = $SMTPSecure;
  1178. $mail->Username = $SMTP_USER;
  1179. $mail->Password = $SMTP_PASS;
  1180. $mail->From = $FROM;
  1181. $mail->FromName = $FROM_NAME;
  1182. $mail->AddReplyTo( $FROM, $FROM_NAME );
  1183. $mail->WordWrap = 50;
  1184. $mail->IsHTML( $IS_HTML );
  1185. $mail->Subject = $SUBJECT;
  1186. $mail->Body = $BODY;
  1187. $mail->AltBody = strip_tags( $BODY );
  1188. $TOK = strtok( $TO, "," );
  1189. while ( $TOK != "" )
  1190. {
  1191. $mail->AddAddress( $TOK );
  1192. $TOK = strtok( "," );
  1193. }
  1194. $TOK = strtok( $CC, "," );
  1195. while ( $TOK != "" )
  1196. {
  1197. $mail->AddCC( $TOK );
  1198. $TOK = strtok( "," );
  1199. }
  1200. $TOK = strtok( $BCC, "," );
  1201. while ( $TOK != "" )
  1202. {
  1203. $mail->AddBCC( $TOK );
  1204. $TOK = strtok( "," );
  1205. }
  1206. $TOK = strtok( $ATTACHMENT, "*" );
  1207. while ( $TOK != "" )
  1208. {
  1209. $FILENAME = substr( $TOK, strrpos( $TOK, "/" ) + 1 );
  1210. if ( strtolower( substr( $TOK, 0, strlen( $ATTACH_PATH2 ) + strlen( attach_sub_dir( ) ) ) ) == strtolower( $ATTACH_PATH2 ).attach_sub_dir( ) )
  1211. {
  1212. $FILENAME = substr( $FILENAME, strpos( $FILENAME, "." ) + 1 );
  1213. }
  1214. $mail->AddAttachment( $TOK, $FILENAME );
  1215. $TOK = strtok( "*" );
  1216. }
  1217. if ( $mail->Send( ) )
  1218. {
  1219. return TRUE;
  1220. }
  1221. return $mail->ErrorInfo;
  1222. }
  1223. function send_email( $LOGIN_USER_ID, $FORM_EMAIL, $TO_EMAIL_STR, $EMAIL_CONTENT, $MAIL_TITLE )
  1224. {
  1225. global $connection;
  1226. global $LOGIN_USER_NAME;
  1227. $query = "SELECT * from WEBMAIL where EMAIL='".$FORM_EMAIL."' and USER_ID='{$LOGIN_USER_ID}'";
  1228. $cursor = exequery( $connection, $query );
  1229. if ( $ROW = mysql_fetch_array( $cursor ) )
  1230. {
  1231. $POP_SERVER = $ROW['POP_SERVER'];
  1232. $SMTP_SERVER = $ROW['SMTP_SERVER'];
  1233. $LOGIN_TYPE = $ROW['LOGIN_TYPE'];
  1234. $SMTP_PASS = $ROW['SMTP_PASS'];
  1235. $SMTP_PORT = $ROW['SMTP_PORT'];
  1236. $SMTP_SSL = $ROW['SMTP_SSL'] == "1" ? "ssl" : "";
  1237. $EMAIL_PASS = $ROW['EMAIL_PASS'];
  1238. $EMAIL_PASS = decrypt_str( $EMAIL_PASS, "webmail" );
  1239. }
  1240. 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 );
  1241. }
  1242. function unescape( $str )
  1243. {
  1244. $str = rawurldecode( $str );
  1245. preg_match_all( "/(?:%u.{4})|&#x.{4};|&#\\d+;|.+/U", $str, $r );
  1246. $ar = $r[0];
  1247. foreach ( $ar as $k => $v )
  1248. {
  1249. if ( substr( $v, 0, 2 ) == "%u" )
  1250. {
  1251. $ar[$k] = iconv( "UCS-2", ini_get( "default_charset" ), pack( "H4", substr( $v, -4 ) ) );
  1252. }
  1253. else if ( substr( $v, 0, 3 ) == "&#x" )
  1254. {
  1255. $ar[$k] = iconv( "UCS-2", ini_get( "default_charset" ), pack( "H4", substr( $v, 3, -1 ) ) );
  1256. }
  1257. else if ( substr( $v, 0, 2 ) == "&#" )
  1258. {
  1259. $ar[$k] = iconv( "UCS-2", ini_get( "default_charset" ), pack( "n", substr( $v, 2, -1 ) ) );
  1260. }
  1261. }
  1262. return str_replace( "\\\", "\", join( "", $ar ) );
  1263. }
  1264. function flow_sort_tree( $SORT_ID, $SORT_CHOOSE )
  1265. {
  1266. include_once( "inc/utility_org.php" );
  1267. global $connection;
  1268. global $DEEP_COUNT;
  1269. global $LOGIN_USER_PRIV;
  1270. global $LOGIN_DEPT_ID;
  1271. global $LOGIN_USER_PRIV_OTHER;
  1272. $query = "SELECT * from FLOW_SORT where SORT_PARENT=".$SORT_ID." order by SORT_NO";
  1273. $cursor = exequery( $connection, $query );
  1274. $OPTION_TEXT = "";
  1275. $DEEP_COUNT1 = $DEEP_COUNT;
  1276. $DEEP_COUNT .= "│";
  1277. $COUNT = 0;
  1278. while ( $ROW = mysql_fetch_array( $cursor ) )
  1279. {
  1280. ++$COUNT;
  1281. $SORT_ID = $ROW['SORT_ID'];
  1282. $SORT_NAME = $ROW['SORT_NAME'];
  1283. $SORT_PARENT = $ROW['SORT_PARENT'];
  1284. $HAVE_CHILD = $ROW['HAVE_CHILD'];
  1285. $DEPT_ID = $ROW['DEPT_ID'];
  1286. 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 ) )
  1287. {
  1288. }
  1289. else
  1290. {
  1291. $SORT_NAME = htmlspecialchars( $SORT_NAME );
  1292. if ( $COUNT == mysql_num_rows( $cursor ) )
  1293. {
  1294. $DEEP_COUNT = substr( $DEEP_COUNT, 0, -2 )." ";
  1295. }
  1296. if ( $HAVE_CHILD == 1 )
  1297. {
  1298. $OPTION_TEXT_CHILD = flow_sort_tree( $SORT_ID, $SORT_CHOOSE );
  1299. }
  1300. $OPTION_TEXT .= "<option ";
  1301. if ( $SORT_ID == $SORT_CHOOSE )
  1302. {
  1303. $OPTION_TEXT .= "selected ";
  1304. }
  1305. if ( $COUNT == mysql_num_rows( $cursor ) )
  1306. {
  1307. $OPTION_TEXT .= "value=".$SORT_ID.">".$DEEP_COUNT1."└".$SORT_NAME."</option>\n";
  1308. }
  1309. else
  1310. {
  1311. $OPTION_TEXT .= "value=".$SORT_ID.">".$DEEP_COUNT1."├".$SORT_NAME."</option>\n";
  1312. }
  1313. if ( !( $HAVE_CHILD != 0 ) && !( $OPTION_TEXT_CHILD != "" ) )
  1314. {
  1315. $OPTION_TEXT .= $OPTION_TEXT_CHILD;
  1316. }
  1317. }
  1318. }
  1319. $DEEP_COUNT = $DEEP_COUNT1;
  1320. return $OPTION_TEXT;
  1321. }
  1322. function check_priv( $PRIV_STR )
  1323. {
  1324. global $LOGIN_DEPT_ID;
  1325. global $LOGIN_USER_PRIV;
  1326. global $LOGIN_USER_ID;
  1327. $PRIV_ARRAY = explode( "|", $PRIV_STR );
  1328. 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 ) )
  1329. {
  1330. return TRUE;
  1331. }
  1332. return FALSE;
  1333. }
  1334. function CSV2Array( $content, $title = array( ), $delimiter = ",", $enclosure = """, $optional = 1 )
  1335. {
  1336. $content = trim( $content );
  1337. $content = str_replace( "\r", "", $content );
  1338. $csv_array = array( );
  1339. $expr_line = "/\\n(?=(?:[^".$enclosure."]*".$enclosure."[^".$enclosure."]*".$enclosure.")*(?![^".$enclosure."]*".$enclosure."))/";
  1340. $expr_field = "/".$delimiter."(?=(?:[^".$enclosure."]*".$enclosure."[^".$enclosure."]*".$enclosure.")*(?![^".$enclosure."]*".$enclosure."))/";
  1341. $lines = preg_split( $expr_line, trim( $content ) );
  1342. foreach ( $lines as $line )
  1343. {
  1344. $fields = preg_split( $expr_field, trim( $line ) );
  1345. $csv_array[] = preg_replace( array( "/"(.*)"\$/s", "/""/s" ), array( "\$1", """ ), $fields );
  1346. }
  1347. if ( !is_array( $title ) && count( $title ) == 0 || count( $csv_array ) == 0 )
  1348. {
  1349. return $csv_array;
  1350. }
  1351. $field_map = array( );
  1352. while ( list( $key, $value ) = each( &$title ) )
  1353. {
  1354. if ( ( $index = array_search( $key, $csv_array[0] ) ) !== FALSE )
  1355. {
  1356. $field_map[$value] = $index;
  1357. }
  1358. }
  1359. $lines = array( );
  1360. $i = 1;
  1361. for ( ; $i < count( $csv_array ); ++$i )
  1362. {
  1363. $line = array( );
  1364. reset( &$field_map );
  1365. while ( list( $key, $value ) = each( &$field_map ) )
  1366. {
  1367. $line[$key] = $csv_array[$i][$value];
  1368. }
  1369. $lines[] = $line;
  1370. }
  1371. return $lines;
  1372. }
  1373. function add_sys_para( $PARA_ARRAY )
  1374. {
  1375. global $connection;
  1376. while ( list( $PARA_NAME, $PARA_VALUE ) = each( &$PARA_ARRAY ) )
  1377. {
  1378. $query = "SELECT * from SYS_PARA where PARA_NAME='".$PARA_NAME."'";
  1379. $cursor = exequery( $connection, $query );
  1380. if ( mysql_num_rows( $cursor ) <= 0 )
  1381. {
  1382. $query = "insert into SYS_PARA (PARA_NAME, PARA_VALUE) values('".$PARA_NAME."', '{$PARA_VALUE}')";
  1383. exequery( $connection, $query );
  1384. }
  1385. }
  1386. }
  1387. function get_sys_para( $PARA_NAME_STR )
  1388. {
  1389. global $connection;
  1390. $PARA_ARRAY = array( );
  1391. $query = "SELECT * from SYS_PARA where find_in_set(PARA_NAME, '".$PARA_NAME_STR."')";
  1392. $cursor = exequery( $connection, $query );
  1393. while ( $ROW = mysql_fetch_array( $cursor ) )
  1394. {
  1395. $PARA_ARRAY[$ROW['PARA_NAME']] = $ROW['PARA_VALUE'];
  1396. }
  1397. return $PARA_ARRAY;
  1398. }
  1399. function set_sys_para( $PARA_ARRAY )
  1400. {
  1401. global $connection;
  1402. while ( list( $PARA_NAME, $PARA_VALUE ) = each( &$PARA_ARRAY ) )
  1403. {
  1404. $query = "update SYS_PARA set PARA_VALUE='".$PARA_VALUE."' where PARA_NAME='{$PARA_NAME}'";
  1405. exequery( $connection, $query );
  1406. }
  1407. }
  1408. function menu_arrow( $DIRECTION = "DOWN" )
  1409. {
  1410. if ( stristr( $_SERVER['HTTP_USER_AGENT'], "MSIE" ) )
  1411. {
  1412. switch ( strtoupper( $DIRECTION ) )
  1413. {
  1414. case "LEFT" :
  1415. return "<span style="font-family:Webdings">3</span>";
  1416. case "RIGHT" :
  1417. return "<span style="font-family:Webdings">4</span>";
  1418. case "UP" :
  1419. return "<span style="font-family:Webdings">5</span>";
  1420. case "DOWN" :
  1421. return "<span style="font-family:Webdings">6</span>";
  1422. default :
  1423. }
  1424. else
  1425. {
  1426. switch ( strtoupper( $DIRECTION ) )
  1427. {
  1428. case "LEFT" :
  1429. return " <img src="/images/menu_arrow_left.gif" align="absMiddle">";
  1430. case "RIGHT" :
  1431. return " <img src="/images/menu_arrow_right.gif" align="absMiddle">";
  1432. case "UP" :
  1433. return " <img src="/images/menu_arrow_top.gif" align="absMiddle">";
  1434. case "DOWN" :
  1435. return " <img src="/images/menu_arrow_down.gif" align="absMiddle">";
  1436. }
  1437. }
  1438. }
  1439. }
  1440. function netMatch( $network, $ip )
  1441. {
  1442. $network = trim( $network );
  1443. $ip = trim( $ip );
  1444. $d = strpos( $network, "-" );
  1445. if ( $d === FALSE )
  1446. {
  1447. $ip_arr = explode( "/", $network );
  1448. if ( !preg_match( "@\\d*\\.\\d*\\.\\d*\\.\\d*@", $ip_arr[0], $matches ) )
  1449. {
  1450. $ip_arr[0] .= ".0";
  1451. }
  1452. $network_long = ip2long( $ip_arr[0] );
  1453. $x = ip2long( $ip_arr[1] );
  1454. $mask = long2ip( $x ) == $ip_arr[1] ? $x : -1 << 32 - $ip_arr[1];
  1455. $ip_long = ip2long( $ip );
  1456. [exception occured]
  1457. ================================
  1458. Exception code[ C0000005 ]
  1459. Compiler[ 003B5E50 ]
  1460. Executor[ 003B6358 ]
  1461. OpArray[ 00A5FD78 ]
  1462. File< C:\Documents and Settings\elite\桌面\1\utility_all.php >
  1463. Class< main >
  1464. Function< netMatch >
  1465. Stack[ 00145DE8 ]
  1466. Step[ 7 ]
  1467. Offset[ 60 ]
  1468. LastOffset[ 94 ]
  1469. 60 IS_EQUAL [-] 0[0] $Tmp_0 - $Tmp_1 - $Tmp_2
  1470. ================================
  1471. ?>
复制代码



您需要登录后才可以回帖 登录 | 用户注册

本版积分规则

帖子推荐:
客服咨询

QQ:592439202

服务时间 9:00-22:00

金蝶用友易助管家婆深度服务
 
QQ在线咨询
售前咨询热线
592439202
售后服务热线
243998158
快速回复 返回顶部 返回列表