Issues (93)

Security Analysis    not enabled

This project does not seem to handle request data directly as such no vulnerable execution paths were found.

  Cross-Site Scripting
Cross-Site Scripting enables an attacker to inject code into the response of a web-request that is viewed by other users. It can for example be used to bypass access controls, or even to take over other users' accounts.
  File Exposure
File Exposure allows an attacker to gain access to local files that he should not be able to access. These files can for example include database credentials, or other configuration files.
  File Manipulation
File Manipulation enables an attacker to write custom data to files. This potentially leads to injection of arbitrary code on the server.
  Object Injection
Object Injection enables an attacker to inject an object into PHP code, and can lead to arbitrary code execution, file exposure, or file manipulation attacks.
  Code Injection
Code Injection enables an attacker to execute arbitrary code on the server.
  Response Splitting
Response Splitting can be used to send arbitrary responses.
  File Inclusion
File Inclusion enables an attacker to inject custom files into PHP's file loading mechanism, either explicitly passed to include, or for example via PHP's auto-loading mechanism.
  Command Injection
Command Injection enables an attacker to inject a shell command that is execute with the privileges of the web-server. This can be used to expose sensitive data, or gain access of your server.
  SQL Injection
SQL Injection enables an attacker to execute arbitrary SQL code on your database server gaining access to user data, or manipulating user data.
  XPath Injection
XPath Injection enables an attacker to modify the parts of XML document that are read. If that XML document is for example used for authentication, this can lead to further vulnerabilities similar to SQL Injection.
  LDAP Injection
LDAP Injection enables an attacker to inject LDAP statements potentially granting permission to run unauthorized queries, or modify content inside the LDAP tree.
  Header Injection
  Other Vulnerability
This category comprises other attack vectors such as manipulating the PHP runtime, loading custom extensions, freezing the runtime, or similar.
  Regex Injection
Regex Injection enables an attacker to execute arbitrary code in your PHP process.
  XML Injection
XML Injection enables an attacker to read files on your local filesystem including configuration files, or can be abused to freeze your web-server process.
  Variable Injection
Variable Injection enables an attacker to overwrite program variables with custom data, and can lead to further vulnerabilities.
Unfortunately, the security analysis is currently not available for your project. If you are a non-commercial open-source project, please contact support to gain access.

application/controllers/Form.php (2 issues)

Upgrade to new PHP Analysis Engine

These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more

1
<?php
2
/* コンタクトフォーム
3
 * 
4
 */
5
6
/**
7
 * @property CI_Email $email
8
 * @property CI_Session $session
9
 * @property CI_Form_validation $form_validation
10
 * @property CI_Input $input
11
 * @property CI_Output $output
12
 */
13
class Form extends CI_Controller {
14
15
	public function __construct()
16
	{
17
# 親クラスのコンストラクタを呼び出します。コントローラにコンストラクタを
18
# 記述する場合は、忘れずに記述してください。
19
		parent::__construct();
20
21
# 必要なヘルパーをロードします。
22
		$this->load->helper(['form', 'url']);
23
		
24
# セッションクラスをロードすることで、セッションを開始します。
25
		$this->load->library('session');
26
27
# 出力クラスのset_header()メソッドでHTTPヘッダのContent-Typeヘッダを指定
28
# します。
29
		$this->output->set_header('Content-Type: text/html; charset=UTF-8');
30
31
# バリデーション(検証)クラスをロードします。
32
		$this->load->library('form_validation');
33
34
		//$this->output->enable_profiler(TRUE);
35
	}
36
37
	private function _set_validation()
38
	{
39
# バリデーションの設定をします。
40
		$this->form_validation->set_error_delimiters('<div class="error">', '</div>');
41
		$this->form_validation->set_rules('name', '名前', 'trim|required|max_length[20]');
42
		$this->form_validation->set_rules('email', 'メールアドレス', 'trim|required|valid_email');
43
		$this->form_validation->set_rules('comment', 'コメント', 'required|max_length[200]');
44
	}
45
46
	public function index()
47
	{
48
# 入力ページ(form)のビューをロードし表示します。
49
		$this->load->view('form');
50
	}
51
52
	public function confirm()
53
	{
54
# 検証ルールを設定します。
55
		$this->_set_validation();
56
57
# バリデーション(検証)クラスのrun()メソッドを呼び出し、送信されたデータの検証
58
# を行います。検証OKなら、確認ページ(form_confirm)を表示します。
59
		if ($this->form_validation->run() == TRUE)
0 ignored issues
show
Coding Style Best Practice introduced by
It seems like you are loosely comparing two booleans. Considering using the strict comparison === instead.

When comparing two booleans, it is generally considered safer to use the strict comparison operator.

Loading history...
60
		{
61
			$this->load->view('form_confirm');
62
		}
63
# 検証でエラーの場合、入力ページ(form)を表示します。
64
		else
65
		{
66
			$this->load->view('form');
67
		}
68
	}
69
70
	public function send()
71
	{
72
# 検証ルールを設定します。
73
		$this->_set_validation();
74
75
# 送信されたデータの検証を行い、検証OKなら、メールを送信します。
76
		if ($this->form_validation->run() == TRUE)
0 ignored issues
show
Coding Style Best Practice introduced by
It seems like you are loosely comparing two booleans. Considering using the strict comparison === instead.

When comparing two booleans, it is generally considered safer to use the strict comparison operator.

Loading history...
77
		{
78
# メールの内容を設定します。
79
			$mail = [];
80
			$mail['from_name'] = $this->input->post('name');
81
			$mail['from']      = $this->input->post('email');
82
			$mail['to']        = '[email protected]';
83
			$mail['subject']   = 'コンタクトフォーム';
84
			$mail['body']      = $this->input->post('comment');
85
86
# _sendmail()メソッドを呼び出しメールの送信処理を行います。
87
# メールの送信に成功したら、完了ページ(form_end)を表示します。
88
			if ($this->_sendmail($mail))
89
			{
90
# 完了ページ(form_end)を表示し、セッションを破棄します。
91
				$this->load->view('form_end');
92
				$this->session->sess_destroy();
93
			}
94
# メールの送信に失敗した場合、エラーを表示します。
95
			else
96
			{
97
				echo 'メール送信エラー';
98
			}
99
		}
100
# 検証でエラーの場合、入力ページ(form)を表示します。
101
		else
102
		{
103
			$this->load->view('form');
104
		}
105
	}
106
107
	private function _sendmail($mail)
108
	{
109
# Emailクラスをロードします。
110
		$this->load->library('email');
111
		$config = [];
112
# メールの送信方法を指定します。ここでは、mail()関数を使います。
113
		$config['protocol'] = 'mail';
114
# 日本語ではワードラップ機能は使えませんのでオフにします。
115
		$config['wordwrap'] = FALSE;
116
# $configでEmailクラスを初期化します。
117
		$this->email->initialize($config);
118
119
# メールの内容を変数に代入します。
120
		$from_name = $mail['from_name'];
121
		$from      = $mail['from'];
122
		$to        = $mail['to'];
123
		$subject   = $mail['subject'];
124
		$body      = $mail['body'];
125
126
# 差出人、あて先、件名、本文をEmailクラスに設定します。
127
		$this->email->from($from, $from_name);
128
		$this->email->to($to);
129
		$this->email->subject($subject);
130
		$this->email->message($body);
131
132
# Emailクラスのsend()メソッドで、実際にメールを送信します。
133
# メールの送信が成功した場合はTRUEを、失敗した場合はFALSEを返します。
134
		if ($this->email->send())
135
		{
136
			return TRUE;
137
		}
138
		else
139
		{
140
//			echo $this->email->print_debugger();
141
			return FALSE;
142
		}
143
	}
144
145
}
146