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

質問編集履歴

2

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

2018/06/18 09:54

投稿

amaguri
amaguri

スコア227

title CHANGED
@@ -1,1 +1,1 @@
1
- cakephp Componentエラー
1
+ セキュリティの関わる問題なので削除させていただきました。
body CHANGED
@@ -1,132 +1,1 @@
1
- 下記コードをためしたところ
2
- ヘッダーにコードの一部が表示され、
3
- さらに
4
- ようエラーが出てきましたが調べてみても何が悪いかわかりません
1
+ セキュリティ関わる問題ので削除させいただきました。
5
- 助けてください
6
-
7
- Error: Component class CommonComponent in UsersController was not found.
8
-
9
- Error: Create the class CommonComponent in file: app/controllers/components/common.php
10
-
11
- 長いので分割します
12
- ```ここに言語を入力
13
-
14
- <?php
15
- class CommonComponent extends Object {
16
-
17
- ///////////////////////////////////////////////////////////////////
18
- // 接続元IP取得
19
- ///////////////////////////////////////////////////////////////////
20
- function getAccessIp() {
21
- if (empty($_SERVER['HTTP_X_FORWARDED_FOR'])) {
22
- return $_SERVER['REMOTE_ADDR'];
23
- }
24
-
25
- $ips = explode(",", $_SERVER['HTTP_X_FORWARDED_FOR']);
26
- return trim(end($ips));
27
- }
28
-
29
- ///////////////////////////////////////////////////////////////////
30
- //監査ログ出力
31
- ///////////////////////////////////////////////////////////////////
32
- function QueryAuditLogWrite($user_id,$query){
33
- if ( DIR_AUDIT_LOG == "" ){ return 1; }
34
- if ( ! is_dir(DIR_AUDIT_LOG) ){ return 1; }
35
-
36
- //監査ログ
37
- $today = getdate();
38
- $audit_log_file=sprintf("%s/webhive_query.log",DIR_AUDIT_LOG);
39
- $ymdhms=sprintf("%04d/%02d/%02d %02d:%02d:%02d",
40
- $today['year'],$today['mon'],$today['mday'],
41
- $today['hours'],$today['minutes'],$today['seconds']);
42
-
43
- //改行置換
44
- $query2=ereg_replace("\t"," ",$query);
45
- $query2=ereg_replace("\r|\n","%n",$query2);
46
-
47
- // 接続元IP情報
48
- $access_ip = CommonComponent::getAccessIp();
49
-
50
- //監査ログ出力
51
- if ( !($fp=fopen($audit_log_file,"a")) ){ return 1; }
52
- fputs($fp,"$ymdhms\t$access_ip\t$user_id\t$query2\n");
53
- fclose($fp);
54
- return 0;
55
- }
56
-
57
-
58
- ///////////////////////////////////////////////////////////////////
59
- //ディレクトリ作成
60
- ///////////////////////////////////////////////////////////////////
61
- function MakeDirectory($u_userid, $u_id=""){
62
- $d1=DIR_REQUEST."/${u_userid}";
63
- if ( !is_dir($d1) ){
64
- if ( !mkdir($d1) ){ return 1; }
65
- }
66
-
67
- $d2=DIR_RESULT."/${u_userid}";
68
- if ( !is_dir($d2) ){
69
- if ( !mkdir($d2) ){ return 1; }
70
- }
71
-
72
- $d3=DIR_UPLOAD."/${u_userid}";
73
- if ( !is_dir($d3) ){
74
- if ( !mkdir($d3) ){ return 1; }
75
- }
76
-
77
- if ( $u_id != "" ){
78
- $d3=DIR_UPLOAD."/${u_userid}/$u_id";
79
- if ( !is_dir($d3) ){
80
- if ( !mkdir($d3) ){ return 1; }
81
- }
82
- }
83
- return 0;
84
- }
85
-
86
- ///////////////////////////////////////////////////////////////////
87
- //HiveQL結果ファイルの一覧を返す
88
- ///////////////////////////////////////////////////////////////////
89
- function GetResultFiles($fin_file) {
90
- $filnms="";
91
-
92
- if ( !file_exists($fin_file) ){ return ""; }
93
- if ( !($fp=fopen($fin_file,"r")) ){ return ""; }
94
- while(!feof($fp)){
95
- $w = fgets($fp,10240);
96
- $w=str_replace(array("\r\n","\n","\r"), '', $w);
97
- if ( !eregi("^OUT:",$w) ){ continue; }
98
- $arr=split('/',$w);
99
- if ( $filnms != "" ){ $filnms.=","; }
100
- $filnms.=end($arr);
101
- }
102
- fclose($fp);
103
-
104
- return $filnms;
105
- }
106
-
107
- ///////////////////////////////////////////////////////////////////
108
- //HiveQL結果ファイルの内容を返す
109
- ///////////////////////////////////////////////////////////////////
110
- function FileRead($csv_file,$dtype) {
111
- $datas=array();
112
- $line=0;
113
-
114
- if ( !($fp=fopen($csv_file,"r")) ){
115
- return $datas;
116
- }
117
- while(!feof($fp)){
118
- $w = fgets($fp, 1024);
119
- if ( $dtype == "csv" ){
120
- $w=mb_convert_encoding(rtrim($w),"UTF-8","SJIS-WIN");
121
- }else{
122
- $w=rtrim($w);
123
- }
124
- $datas[]=array("data"=>$w);
125
- $line++;
126
- if ( $line >= 1000 ){ break; }
127
- }
128
- fclose($fp);
129
- return $datas;
130
- }
131
-
132
- ```

1

コード追加

2018/06/18 09:54

投稿

amaguri
amaguri

スコア227

title CHANGED
File without changes
body CHANGED
@@ -6,4 +6,127 @@
6
6
 
7
7
  Error: Component class CommonComponent in UsersController was not found.
8
8
 
9
- Error: Create the class CommonComponent in file: app/controllers/components/common.php
9
+ Error: Create the class CommonComponent in file: app/controllers/components/common.php
10
+
11
+ 長いので分割します
12
+ ```ここに言語を入力
13
+
14
+ <?php
15
+ class CommonComponent extends Object {
16
+
17
+ ///////////////////////////////////////////////////////////////////
18
+ // 接続元IP取得
19
+ ///////////////////////////////////////////////////////////////////
20
+ function getAccessIp() {
21
+ if (empty($_SERVER['HTTP_X_FORWARDED_FOR'])) {
22
+ return $_SERVER['REMOTE_ADDR'];
23
+ }
24
+
25
+ $ips = explode(",", $_SERVER['HTTP_X_FORWARDED_FOR']);
26
+ return trim(end($ips));
27
+ }
28
+
29
+ ///////////////////////////////////////////////////////////////////
30
+ //監査ログ出力
31
+ ///////////////////////////////////////////////////////////////////
32
+ function QueryAuditLogWrite($user_id,$query){
33
+ if ( DIR_AUDIT_LOG == "" ){ return 1; }
34
+ if ( ! is_dir(DIR_AUDIT_LOG) ){ return 1; }
35
+
36
+ //監査ログ
37
+ $today = getdate();
38
+ $audit_log_file=sprintf("%s/webhive_query.log",DIR_AUDIT_LOG);
39
+ $ymdhms=sprintf("%04d/%02d/%02d %02d:%02d:%02d",
40
+ $today['year'],$today['mon'],$today['mday'],
41
+ $today['hours'],$today['minutes'],$today['seconds']);
42
+
43
+ //改行置換
44
+ $query2=ereg_replace("\t"," ",$query);
45
+ $query2=ereg_replace("\r|\n","%n",$query2);
46
+
47
+ // 接続元IP情報
48
+ $access_ip = CommonComponent::getAccessIp();
49
+
50
+ //監査ログ出力
51
+ if ( !($fp=fopen($audit_log_file,"a")) ){ return 1; }
52
+ fputs($fp,"$ymdhms\t$access_ip\t$user_id\t$query2\n");
53
+ fclose($fp);
54
+ return 0;
55
+ }
56
+
57
+
58
+ ///////////////////////////////////////////////////////////////////
59
+ //ディレクトリ作成
60
+ ///////////////////////////////////////////////////////////////////
61
+ function MakeDirectory($u_userid, $u_id=""){
62
+ $d1=DIR_REQUEST."/${u_userid}";
63
+ if ( !is_dir($d1) ){
64
+ if ( !mkdir($d1) ){ return 1; }
65
+ }
66
+
67
+ $d2=DIR_RESULT."/${u_userid}";
68
+ if ( !is_dir($d2) ){
69
+ if ( !mkdir($d2) ){ return 1; }
70
+ }
71
+
72
+ $d3=DIR_UPLOAD."/${u_userid}";
73
+ if ( !is_dir($d3) ){
74
+ if ( !mkdir($d3) ){ return 1; }
75
+ }
76
+
77
+ if ( $u_id != "" ){
78
+ $d3=DIR_UPLOAD."/${u_userid}/$u_id";
79
+ if ( !is_dir($d3) ){
80
+ if ( !mkdir($d3) ){ return 1; }
81
+ }
82
+ }
83
+ return 0;
84
+ }
85
+
86
+ ///////////////////////////////////////////////////////////////////
87
+ //HiveQL結果ファイルの一覧を返す
88
+ ///////////////////////////////////////////////////////////////////
89
+ function GetResultFiles($fin_file) {
90
+ $filnms="";
91
+
92
+ if ( !file_exists($fin_file) ){ return ""; }
93
+ if ( !($fp=fopen($fin_file,"r")) ){ return ""; }
94
+ while(!feof($fp)){
95
+ $w = fgets($fp,10240);
96
+ $w=str_replace(array("\r\n","\n","\r"), '', $w);
97
+ if ( !eregi("^OUT:",$w) ){ continue; }
98
+ $arr=split('/',$w);
99
+ if ( $filnms != "" ){ $filnms.=","; }
100
+ $filnms.=end($arr);
101
+ }
102
+ fclose($fp);
103
+
104
+ return $filnms;
105
+ }
106
+
107
+ ///////////////////////////////////////////////////////////////////
108
+ //HiveQL結果ファイルの内容を返す
109
+ ///////////////////////////////////////////////////////////////////
110
+ function FileRead($csv_file,$dtype) {
111
+ $datas=array();
112
+ $line=0;
113
+
114
+ if ( !($fp=fopen($csv_file,"r")) ){
115
+ return $datas;
116
+ }
117
+ while(!feof($fp)){
118
+ $w = fgets($fp, 1024);
119
+ if ( $dtype == "csv" ){
120
+ $w=mb_convert_encoding(rtrim($w),"UTF-8","SJIS-WIN");
121
+ }else{
122
+ $w=rtrim($w);
123
+ }
124
+ $datas[]=array("data"=>$w);
125
+ $line++;
126
+ if ( $line >= 1000 ){ break; }
127
+ }
128
+ fclose($fp);
129
+ return $datas;
130
+ }
131
+
132
+ ```