Subversion Repositories ALCASAR

Rev

Rev 2178 | Rev 2817 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log

Rev 2178 Rev 2463
Line 126... Line 126...
126
	exec ("sudo /usr/local/bin/alcasar-file-clean.sh");  # Clean & sort conf files. Add uamallowed domains to the dns-blackhole conf
126
	exec ("sudo /usr/local/bin/alcasar-file-clean.sh");  # Clean & sort conf files. Add uamallowed domains to the dns-blackhole conf
127
	sleep (1); # be sure that dnsmasq-blackhole is restarted before killing tun0 ! 
127
	sleep (1); # be sure that dnsmasq-blackhole is restarted before killing tun0 ! 
128
	exec ("sudo /usr/bin/systemctl restart chilli");
128
	exec ("sudo /usr/bin/systemctl restart chilli");
129
	break;
129
	break;
130
	case 'new_ip' :
130
	case 'new_ip' :
131
	if (trim($_POST['add_ip']) != "") 
131
		$ipAddr = trim($_POST['add_ip']);
-
 
132
		if (!preg_match('/^([0-9]{1,3}\.){3}([0-9]{1,3})$/', $ipAddr)) {
-
 
133
			echo '<span style="color: red;">'.'Invalid IP address'.'</span>'; // TODO : need to translate
132
		{
134
		} else if (!empty($ipAddr)) {
133
		$tab=file(IP_ALLOWED_LIST);
135
			$tab=file(IP_ALLOWED_LIST);
134
		$insert = true;
136
			$insert = true;
135
		if ($tab) // file isn't empty
137
			if ($tab) { // file isn't empty
136
			{
-
 
137
			foreach ($tab as $line) // test if domain address doesn't already exist
138
				foreach ($tab as $line) { // test if domain address doesn't already exist
138
				{
-
 
139
				$ip=explode("\"", $line);
139
					$ip = explode('"', $line);
140
				if (strcmp(trim($_POST['add_ip']),$ip[1]) == 0)
140
					if (strcmp($ipAddr, $ip[1]) === 0) {
141
			       		{
-
 
142
					$insert = false;
141
						$insert = false;
143
					break;
142
						break;
144
					}
143
					}
145
				}
144
				}
146
			}
145
			}
147
		if ($insert == true) 
146
			if ($insert === true)  {
148
			{
-
 
149
			$line ="\nuamallowed=\"" . trim($_POST['add_ip']) ."\" #" . trim($_POST['add_ip_comment']);
147
				$line = "\nuamallowed=\"" . $ipAddr .'" #' . trim($_POST['add_ip_comment']);
150
			$pointeur=fopen(IP_ALLOWED_LIST,"a");
148
				$pointeur = fopen(IP_ALLOWED_LIST, 'a');
151
			fwrite ($pointeur, $line);
149
				fwrite($pointeur, $line);
152
			fclose ($pointeur);
150
				fclose($pointeur);
153
			exec ("sudo /usr/local/bin/alcasar-file-clean.sh");  # Clean & sort conf files. Add uamallowed domains to the dns-blackhole conf
151
				exec('sudo /usr/local/bin/alcasar-file-clean.sh');  # Clean & sort conf files. Add uamallowed domains to the dns-blackhole conf
154
			exec ("sudo /usr/bin/systemctl restart chilli");
152
				exec('sudo /usr/bin/systemctl restart chilli');
155
			}
153
			}
156
		}
154
		}
157
	break;
155
	break;
158
	case 'change_ip' :
156
	case 'change_ip' :
159
	$tab=file(IP_ALLOWED_LIST);
157
	$tab=file(IP_ALLOWED_LIST);