teratail header banner
teratail header banner
質問するログイン新規登録

質問編集履歴

3

修正

2021/07/08 08:33

投稿

AKIRAF
AKIRAF

スコア1

title CHANGED
File without changes
body CHANGED
@@ -10,10 +10,106 @@
10
10
 
11
11
  これから何をしたらいいのか?わかりません
12
12
 
13
+ ```
13
- 242  if(! in_array($entry['name'], $_temp)){
14
+ <?php if(! defined('SWPA_PLUGIN_PREFIX')) return;
15
+ /**
16
+ * Class SwpaPlugin
17
+ * Static class
18
+ */
19
+ class SwpaPlugin
20
+ {
21
+ public static function createWpMenu()
22
+ {
23
+ if (current_user_can('administrator') && function_exists('add_menu_page'))
24
+ {
25
+ $reqCap = 'activate_plugins';
26
+ add_menu_page('Secure WP', 'Secure WP', $reqCap, SWPA_PLUGIN_PREFIX, array(get_class(),'pageMain'), SwpaUtil::imageUrl('logo-small.png'));
27
+ add_submenu_page(SWPA_PLUGIN_PREFIX, 'Dashboard', __('Dashboard'), $reqCap, SWPA_PLUGIN_PREFIX, array(get_class(),'pageMain'));
28
+ add_submenu_page(SWPA_PLUGIN_PREFIX, 'Database', __('Database'), $reqCap, SWPA_PLUGIN_PREFIX.'database', array(get_class(),'pageDatabase'));
29
+ add_submenu_page(SWPA_PLUGIN_PREFIX, 'Scanner', __('Scanner'), $reqCap, SWPA_PLUGIN_PREFIX.'scanner', array(get_class(),'pageScanner'));
30
+ add_submenu_page(SWPA_PLUGIN_PREFIX, 'Live traffic', __('Live traffic'), $reqCap, SWPA_PLUGIN_PREFIX.'live_traffic', array(get_class(),'pageLiveTraffic'));
31
+ add_submenu_page(SWPA_PLUGIN_PREFIX, 'Blog', __('Blog'), $reqCap, SWPA_PLUGIN_PREFIX.'blog', array(get_class(),'pageBlog'));
32
+ add_submenu_page(SWPA_PLUGIN_PREFIX, 'Settings', __('Settings'), $reqCap, SWPA_PLUGIN_PREFIX.'settings', array(get_class(),'pageSettings'));
33
+ add_submenu_page(SWPA_PLUGIN_PREFIX, 'About', __('About'), $reqCap, SWPA_PLUGIN_PREFIX.'about', array(get_class(),'pageAbout'));
34
+ }
35
+ }
14
36
 
37
+ public static function pageMain() { SwpaUtil::includePage('dashboard.php'); }
38
+ public static function pageDatabase() { SwpaUtil::includePage('database.php'); }
39
+ public static function pageScanner() { SwpaUtil::includePage('scanner.php'); }
40
+ public static function pageLiveTraffic() { SwpaUtil::includePage('live_traffic.php'); }
41
+ public static function pageBlog() { SwpaUtil::includePage('blog.php'); }
42
+ public static function pageSettings() { SwpaUtil::includePage('settings.php'); }
43
+ public static function pageAbout() { SwpaUtil::includePage('about.php'); }
44
+
45
+ public static function loadResources()
46
+ {
47
+ if(SwpaUtil::canLoad()){
48
+ wp_enqueue_style('wsd-styles-base', SwpaUtil::cssUrl('styles.base.css'));
49
+ wp_enqueue_style('wsd-styles-alerts', SwpaUtil::cssUrl('styles.alerts.css'));
50
+ wp_enqueue_style('wsd-styles-general', SwpaUtil::cssUrl('styles.general.css'));
51
+ wp_enqueue_style('wsd-styles-status', SwpaUtil::cssUrl('styles.status.css'));
52
+ wp_enqueue_script('wsdplugin-js-util', SwpaUtil::jsUrl('wsd-util.js'), array('jquery'));
53
+ }
54
+ }
55
+
56
+
57
+ /**
58
+ * Common method to add an alert to database.
59
+ * @static
60
+ * @param string $actionName The name of the action of the alert
61
+ * @param int $type Can only be one of the following: SWPA_PLUGIN_ALERT_TYPE_OVERWRITE | SWPA_PLUGIN_ALERT_TYPE_STACK. Defaults to SWPA_PLUGIN_ALERT_TYPE_OVERWRITE
62
+ * @param int $severity Can only have one of the following values: 0 1 2 3. Defaults to 0.
63
+ * @param string $title
64
+ * @param string $description
65
+ * @param string $solution
66
+ * @return bool
67
+ */
68
+ public static function alert($actionName, $type = 0, $severity = 0, $title = '', $description = '', $solution = '') {
69
+ global $wpdb;
70
+
71
+ $table = self::getTableName();
72
+
73
+ if($type == SWPA_PLUGIN_ALERT_TYPE_STACK)
74
+ {
75
+ //#! Check the max number of stacked alerts to keep and remove the exceeding ones
76
+ $afsDate = $wpdb->get_var("SELECT alertFirstSeen FROM $table WHERE alertActionName = '$actionName' ORDER BY `alertDate`;");
77
+ if(empty($afsDate)){ $afsDate = "CURRENT_TIMESTAMP()";}
78
+ else { $afsDate = "'".$afsDate."'"; }
79
+ $result = $wpdb->get_var("SELECT COUNT(alertId) FROM $table WHERE alertActionName = '$actionName';");
80
+ if($result >= SWPA_PLUGIN_ALERT_STACK_MAX_KEEP){
81
+ // remove older entries to make room for the new ones
82
+ $query = "DELETE FROM $table ORDER BY alertDate ASC LIMIT ".($result - (SWPA_PLUGIN_ALERT_STACK_MAX_KEEP - 1));
83
+ $wpdb->query($query);
84
+ }
85
+
86
+ //Add the new entry
87
+ $query = $wpdb->prepare(
88
+ "INSERT INTO $table
89
+ (`alertType`,
90
+ `alertSeverity`,
91
+ `alertActionName`,
92
+ `alertTitle`,
93
+ `alertDescription`,
94
+ `alertSolution`,
15
- ```ここに言語名を入力
95
+ `alertDate`,
96
+ `alertFirstSeen`)
16
- ソースコード
97
+ VALUES
98
+ (%d,
99
+ %d,
100
+ '%s',
101
+ '%s',
102
+ '%s',
103
+ '%s',
104
+ CURRENT_TIMESTAMP(),
105
+ $afsDate
106
+ );"
107
+ ,$type, $severity, $actionName, $title, $description, $solution);
108
+ }
109
+ elseif($type == SWPA_PLUGIN_ALERT_TYPE_OVERWRITE)
110
+ {
111
+ //#! Find the record by actionName and update fields
112
+ $result = $wpdb->get_var("SELECT alertId FROM $table WHERE
17
113
  ```
18
114
 
19
115
  ### 試したこと

2

修正

2021/07/08 08:33

投稿

AKIRAF
AKIRAF

スコア1

title CHANGED
File without changes
body CHANGED
@@ -3,7 +3,7 @@
3
3
 
4
4
  ### 発生している問題・エラーメッセージ
5
5
 
6
- ```Notice: Trying to access array offset on value of type int in /home/fujitaseikotsuin/www/roppongimidtown-seikotsuin.com/wp-content/plugins/secure-wordpress/res/inc/SwpaPlugin.php on line 242
6
+ Notice: Trying to access array offset on value of type int in /home/fujitaseikotsuin/www/roppongimidtown-seikotsuin.com/wp-content/plugins/secure-wordpress/res/inc/SwpaPlugin.php on line 242
7
7
 
8
8
  HPが表示されなくなりデバックしたらこの表示です。
9
9
  それで調べたら以下までは進みました。

1

補足説明です

2021/07/08 08:06

投稿

AKIRAF
AKIRAF

スコア1

title CHANGED
File without changes
body CHANGED
@@ -5,8 +5,11 @@
5
5
 
6
6
  ```Notice: Trying to access array offset on value of type int in /home/fujitaseikotsuin/www/roppongimidtown-seikotsuin.com/wp-content/plugins/secure-wordpress/res/inc/SwpaPlugin.php on line 242
7
7
 
8
+ HPが表示されなくなりデバックしたらこの表示です。
8
- ```
9
+ それで調べたら以下までは進みました。
9
10
 
11
+ これから何をしたらいいのか?わかりません
12
+
10
13
  242  if(! in_array($entry['name'], $_temp)){
11
14
 
12
15
  ```ここに言語名を入力