質問編集履歴

2

セキュリティの関わる問題なので削除させていただきました。

2018/06/18 09:54

投稿

amaguri
amaguri

スコア227

test CHANGED
@@ -1 +1 @@
1
- cakephp Componentエラー
1
+ セキュリティの関わる問題なので削除させていただきました。
test CHANGED
@@ -1,263 +1 @@
1
- 下記コードをためしたところ
2
-
3
- ヘッダーにコードの一部が表示され、
4
-
5
- さらに
6
-
7
- ようエラーが出てきましたが調べてみても何が悪いかわかりません
1
+ セキュリティ関わる問題ので削除させいただきました。
8
-
9
- 助けてください
10
-
11
-
12
-
13
- Error: Component class CommonComponent in UsersController was not found.
14
-
15
-
16
-
17
- Error: Create the class CommonComponent in file: app/controllers/components/common.php
18
-
19
-
20
-
21
- 長いので分割します
22
-
23
- ```ここに言語を入力
24
-
25
-
26
-
27
- <?php
28
-
29
- class CommonComponent extends Object {
30
-
31
-
32
-
33
- ///////////////////////////////////////////////////////////////////
34
-
35
- // 接続元IP取得
36
-
37
- ///////////////////////////////////////////////////////////////////
38
-
39
- function getAccessIp() {
40
-
41
- if (empty($_SERVER['HTTP_X_FORWARDED_FOR'])) {
42
-
43
- return $_SERVER['REMOTE_ADDR'];
44
-
45
- }
46
-
47
-
48
-
49
- $ips = explode(",", $_SERVER['HTTP_X_FORWARDED_FOR']);
50
-
51
- return trim(end($ips));
52
-
53
- }
54
-
55
-
56
-
57
- ///////////////////////////////////////////////////////////////////
58
-
59
- //監査ログ出力
60
-
61
- ///////////////////////////////////////////////////////////////////
62
-
63
- function QueryAuditLogWrite($user_id,$query){
64
-
65
- if ( DIR_AUDIT_LOG == "" ){ return 1; }
66
-
67
- if ( ! is_dir(DIR_AUDIT_LOG) ){ return 1; }
68
-
69
-
70
-
71
- //監査ログ
72
-
73
- $today = getdate();
74
-
75
- $audit_log_file=sprintf("%s/webhive_query.log",DIR_AUDIT_LOG);
76
-
77
- $ymdhms=sprintf("%04d/%02d/%02d %02d:%02d:%02d",
78
-
79
- $today['year'],$today['mon'],$today['mday'],
80
-
81
- $today['hours'],$today['minutes'],$today['seconds']);
82
-
83
-
84
-
85
- //改行置換
86
-
87
- $query2=ereg_replace("\t"," ",$query);
88
-
89
- $query2=ereg_replace("\r|\n","%n",$query2);
90
-
91
-
92
-
93
- // 接続元IP情報
94
-
95
- $access_ip = CommonComponent::getAccessIp();
96
-
97
-
98
-
99
- //監査ログ出力
100
-
101
- if ( !($fp=fopen($audit_log_file,"a")) ){ return 1; }
102
-
103
- fputs($fp,"$ymdhms\t$access_ip\t$user_id\t$query2\n");
104
-
105
- fclose($fp);
106
-
107
- return 0;
108
-
109
- }
110
-
111
-
112
-
113
-
114
-
115
- ///////////////////////////////////////////////////////////////////
116
-
117
- //ディレクトリ作成
118
-
119
- ///////////////////////////////////////////////////////////////////
120
-
121
- function MakeDirectory($u_userid, $u_id=""){
122
-
123
- $d1=DIR_REQUEST."/${u_userid}";
124
-
125
- if ( !is_dir($d1) ){
126
-
127
- if ( !mkdir($d1) ){ return 1; }
128
-
129
- }
130
-
131
-
132
-
133
- $d2=DIR_RESULT."/${u_userid}";
134
-
135
- if ( !is_dir($d2) ){
136
-
137
- if ( !mkdir($d2) ){ return 1; }
138
-
139
- }
140
-
141
-
142
-
143
- $d3=DIR_UPLOAD."/${u_userid}";
144
-
145
- if ( !is_dir($d3) ){
146
-
147
- if ( !mkdir($d3) ){ return 1; }
148
-
149
- }
150
-
151
-
152
-
153
- if ( $u_id != "" ){
154
-
155
- $d3=DIR_UPLOAD."/${u_userid}/$u_id";
156
-
157
- if ( !is_dir($d3) ){
158
-
159
- if ( !mkdir($d3) ){ return 1; }
160
-
161
- }
162
-
163
- }
164
-
165
- return 0;
166
-
167
- }
168
-
169
-
170
-
171
- ///////////////////////////////////////////////////////////////////
172
-
173
- //HiveQL結果ファイルの一覧を返す
174
-
175
- ///////////////////////////////////////////////////////////////////
176
-
177
- function GetResultFiles($fin_file) {
178
-
179
- $filnms="";
180
-
181
-
182
-
183
- if ( !file_exists($fin_file) ){ return ""; }
184
-
185
- if ( !($fp=fopen($fin_file,"r")) ){ return ""; }
186
-
187
- while(!feof($fp)){
188
-
189
- $w = fgets($fp,10240);
190
-
191
- $w=str_replace(array("\r\n","\n","\r"), '', $w);
192
-
193
- if ( !eregi("^OUT:",$w) ){ continue; }
194
-
195
- $arr=split('/',$w);
196
-
197
- if ( $filnms != "" ){ $filnms.=","; }
198
-
199
- $filnms.=end($arr);
200
-
201
- }
202
-
203
- fclose($fp);
204
-
205
-
206
-
207
- return $filnms;
208
-
209
- }
210
-
211
-
212
-
213
- ///////////////////////////////////////////////////////////////////
214
-
215
- //HiveQL結果ファイルの内容を返す
216
-
217
- ///////////////////////////////////////////////////////////////////
218
-
219
- function FileRead($csv_file,$dtype) {
220
-
221
- $datas=array();
222
-
223
- $line=0;
224
-
225
-
226
-
227
- if ( !($fp=fopen($csv_file,"r")) ){
228
-
229
- return $datas;
230
-
231
- }
232
-
233
- while(!feof($fp)){
234
-
235
- $w = fgets($fp, 1024);
236
-
237
- if ( $dtype == "csv" ){
238
-
239
- $w=mb_convert_encoding(rtrim($w),"UTF-8","SJIS-WIN");
240
-
241
- }else{
242
-
243
- $w=rtrim($w);
244
-
245
- }
246
-
247
- $datas[]=array("data"=>$w);
248
-
249
- $line++;
250
-
251
- if ( $line >= 1000 ){ break; }
252
-
253
- }
254
-
255
- fclose($fp);
256
-
257
- return $datas;
258
-
259
- }
260
-
261
-
262
-
263
- ```

1

コード追加

2018/06/18 09:54

投稿

amaguri
amaguri

スコア227

test CHANGED
File without changes
test CHANGED
@@ -15,3 +15,249 @@
15
15
 
16
16
 
17
17
  Error: Create the class CommonComponent in file: app/controllers/components/common.php
18
+
19
+
20
+
21
+ 長いので分割します
22
+
23
+ ```ここに言語を入力
24
+
25
+
26
+
27
+ <?php
28
+
29
+ class CommonComponent extends Object {
30
+
31
+
32
+
33
+ ///////////////////////////////////////////////////////////////////
34
+
35
+ // 接続元IP取得
36
+
37
+ ///////////////////////////////////////////////////////////////////
38
+
39
+ function getAccessIp() {
40
+
41
+ if (empty($_SERVER['HTTP_X_FORWARDED_FOR'])) {
42
+
43
+ return $_SERVER['REMOTE_ADDR'];
44
+
45
+ }
46
+
47
+
48
+
49
+ $ips = explode(",", $_SERVER['HTTP_X_FORWARDED_FOR']);
50
+
51
+ return trim(end($ips));
52
+
53
+ }
54
+
55
+
56
+
57
+ ///////////////////////////////////////////////////////////////////
58
+
59
+ //監査ログ出力
60
+
61
+ ///////////////////////////////////////////////////////////////////
62
+
63
+ function QueryAuditLogWrite($user_id,$query){
64
+
65
+ if ( DIR_AUDIT_LOG == "" ){ return 1; }
66
+
67
+ if ( ! is_dir(DIR_AUDIT_LOG) ){ return 1; }
68
+
69
+
70
+
71
+ //監査ログ
72
+
73
+ $today = getdate();
74
+
75
+ $audit_log_file=sprintf("%s/webhive_query.log",DIR_AUDIT_LOG);
76
+
77
+ $ymdhms=sprintf("%04d/%02d/%02d %02d:%02d:%02d",
78
+
79
+ $today['year'],$today['mon'],$today['mday'],
80
+
81
+ $today['hours'],$today['minutes'],$today['seconds']);
82
+
83
+
84
+
85
+ //改行置換
86
+
87
+ $query2=ereg_replace("\t"," ",$query);
88
+
89
+ $query2=ereg_replace("\r|\n","%n",$query2);
90
+
91
+
92
+
93
+ // 接続元IP情報
94
+
95
+ $access_ip = CommonComponent::getAccessIp();
96
+
97
+
98
+
99
+ //監査ログ出力
100
+
101
+ if ( !($fp=fopen($audit_log_file,"a")) ){ return 1; }
102
+
103
+ fputs($fp,"$ymdhms\t$access_ip\t$user_id\t$query2\n");
104
+
105
+ fclose($fp);
106
+
107
+ return 0;
108
+
109
+ }
110
+
111
+
112
+
113
+
114
+
115
+ ///////////////////////////////////////////////////////////////////
116
+
117
+ //ディレクトリ作成
118
+
119
+ ///////////////////////////////////////////////////////////////////
120
+
121
+ function MakeDirectory($u_userid, $u_id=""){
122
+
123
+ $d1=DIR_REQUEST."/${u_userid}";
124
+
125
+ if ( !is_dir($d1) ){
126
+
127
+ if ( !mkdir($d1) ){ return 1; }
128
+
129
+ }
130
+
131
+
132
+
133
+ $d2=DIR_RESULT."/${u_userid}";
134
+
135
+ if ( !is_dir($d2) ){
136
+
137
+ if ( !mkdir($d2) ){ return 1; }
138
+
139
+ }
140
+
141
+
142
+
143
+ $d3=DIR_UPLOAD."/${u_userid}";
144
+
145
+ if ( !is_dir($d3) ){
146
+
147
+ if ( !mkdir($d3) ){ return 1; }
148
+
149
+ }
150
+
151
+
152
+
153
+ if ( $u_id != "" ){
154
+
155
+ $d3=DIR_UPLOAD."/${u_userid}/$u_id";
156
+
157
+ if ( !is_dir($d3) ){
158
+
159
+ if ( !mkdir($d3) ){ return 1; }
160
+
161
+ }
162
+
163
+ }
164
+
165
+ return 0;
166
+
167
+ }
168
+
169
+
170
+
171
+ ///////////////////////////////////////////////////////////////////
172
+
173
+ //HiveQL結果ファイルの一覧を返す
174
+
175
+ ///////////////////////////////////////////////////////////////////
176
+
177
+ function GetResultFiles($fin_file) {
178
+
179
+ $filnms="";
180
+
181
+
182
+
183
+ if ( !file_exists($fin_file) ){ return ""; }
184
+
185
+ if ( !($fp=fopen($fin_file,"r")) ){ return ""; }
186
+
187
+ while(!feof($fp)){
188
+
189
+ $w = fgets($fp,10240);
190
+
191
+ $w=str_replace(array("\r\n","\n","\r"), '', $w);
192
+
193
+ if ( !eregi("^OUT:",$w) ){ continue; }
194
+
195
+ $arr=split('/',$w);
196
+
197
+ if ( $filnms != "" ){ $filnms.=","; }
198
+
199
+ $filnms.=end($arr);
200
+
201
+ }
202
+
203
+ fclose($fp);
204
+
205
+
206
+
207
+ return $filnms;
208
+
209
+ }
210
+
211
+
212
+
213
+ ///////////////////////////////////////////////////////////////////
214
+
215
+ //HiveQL結果ファイルの内容を返す
216
+
217
+ ///////////////////////////////////////////////////////////////////
218
+
219
+ function FileRead($csv_file,$dtype) {
220
+
221
+ $datas=array();
222
+
223
+ $line=0;
224
+
225
+
226
+
227
+ if ( !($fp=fopen($csv_file,"r")) ){
228
+
229
+ return $datas;
230
+
231
+ }
232
+
233
+ while(!feof($fp)){
234
+
235
+ $w = fgets($fp, 1024);
236
+
237
+ if ( $dtype == "csv" ){
238
+
239
+ $w=mb_convert_encoding(rtrim($w),"UTF-8","SJIS-WIN");
240
+
241
+ }else{
242
+
243
+ $w=rtrim($w);
244
+
245
+ }
246
+
247
+ $datas[]=array("data"=>$w);
248
+
249
+ $line++;
250
+
251
+ if ( $line >= 1000 ){ break; }
252
+
253
+ }
254
+
255
+ fclose($fp);
256
+
257
+ return $datas;
258
+
259
+ }
260
+
261
+
262
+
263
+ ```