check.ctrl.php 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. <?php
  2. /**
  3. * [WeEngine System] Copyright (c) 2014 WE7.CC
  4. * WeEngine is NOT a free software, it under the license terms, visited http://www.we7.cc/ for more details.
  5. */
  6. defined('IN_IA') or exit('Access Denied');
  7. load()->model('system');
  8. if ($do == 'check_table') {
  9. $wrong_tables = array();
  10. $table_pre = $_W['config']['db']['tablepre'] . '_%';
  11. $tables = pdo_fetchall("SHOW TABLE STATUS LIKE '{$table_pre}'", array(), 'Name');
  12. foreach ($tables as $table_name => $table_info) {
  13. if (!empty($table_info['Engine']) && !in_array($table_info['Engine'], array('MyISAM', 'InnoDB'))) {
  14. unset($tables[$table_name]);
  15. }
  16. }
  17. $tables_str = implode('`,`', array_keys($tables));
  18. $check_result = pdo_fetchall("CHECK TABLE `" . $tables_str . '`');
  19. foreach ($check_result as $check_info) {
  20. if ($check_info['Msg_text'] != 'OK' && $check_info['Msg_type'] != 'warning') {
  21. $wrong_tables[$check_info['Table']] = $check_info;
  22. }
  23. }
  24. iajax(0, $wrong_tables);
  25. }
  26. if ($do == 'check_fpm') {
  27. $result = fastcgi_finish_request();
  28. if (is_error($result)) {
  29. iajax($result['errno'], $result['message']);
  30. }
  31. exit();
  32. }
  33. if ($do == 'check_auth_accounts') {
  34. $accounts = pdo_getall('account', array(
  35. 'isconnect' => 1,
  36. 'isdeleted' => 0,
  37. 'type' => array(ACCOUNT_TYPE_OFFCIAL_AUTH, ACCOUNT_TYPE_APP_AUTH, ACCOUNT_TYPE_XZAPP_AUTH)
  38. ));
  39. $failed_accounts = array();
  40. if (!empty($accounts)) {
  41. foreach ($accounts as $account) {
  42. $uni_account = WeAccount::createByUniacid($account['uniacid']);
  43. $token = $uni_account->getAccessToken();
  44. if (is_error($token)) {
  45. $failed_accounts[] = array(
  46. 'name' => $uni_account->account['name'],
  47. 'acid' => $uni_account->account['acid'],
  48. 'uniacid' => $uni_account->account['uniacid'],
  49. 'type' => $uni_account->account['type'],
  50. 'error' => $token['message'],
  51. );
  52. }
  53. }
  54. }
  55. if (empty($failed_accounts)) {
  56. iajax(0, 'success');
  57. } else {
  58. iajax(-1, $failed_accounts);
  59. }
  60. }
  61. $system_check_items = system_check_items();
  62. if (version_compare(PHP_VERSION, '7.0.0', '>=')) {
  63. unset($system_check_items['mcrypt']);
  64. }
  65. foreach ($system_check_items as $check_item_name => &$check_item) {
  66. $check_item['check_result'] = $check_item['operate']($check_item_name);
  67. }
  68. $check_num = count($system_check_items);
  69. $check_wrong_num = 0;
  70. foreach ($system_check_items as $check_key => $check_val) {
  71. if ($check_val['check_result'] === false) {
  72. $check_wrong_num += 1;
  73. }
  74. }
  75. cache_write(cache_system_key('system_check'), array('check_items' => $system_check_items, 'check_num' => $check_num, 'check_wrong_num' => $check_wrong_num));
  76. template('system/check');