Subversion Repositories ALCASAR

Compare Revisions

Ignore whitespace Rev 2549 → Rev 2550

/web/acc/manager/htdocs/autoregistration.php
1,23 → 1,6
<?php
# $Id$
 
# Test if 3G/4G key is plugged
$exec_com=exec("lsusb | grep -i 067b: | cut -d ' ' -f6"); // converter "USB to UART" PL2303 (several USB-serial cables, Wavecom GSM Modem)
$exec_com2=exec("lsusb | grep -i 12d1: | cut -d ' ' -f6"); // Huawei Technologies (E220/E230/E270/E870
$gammu_smsd_port=exec("cat /etc/gammu_smsd_conf| grep port | cut -d ' ' -f3"); // Gammu_smsd listen port
$model='';
if(!empty($exec_com) || !empty($exec_com2)){
$status_key="true";
if(!empty($exec_com)) $model='Wavecom';
if(!empty($exec_com2)) $model='Huawei';
exec("ls /dev/ttyUSB*",$openned_ports); // list of ports openned by the modem
}
else {
$status_key="false";
}
 
$script="/usr/local/bin/alcasar-sms.sh";
 
#Define
$gammu_puk = "";
$gammu_simfail = "";
30,7 → 13,39
$error_time_perm = "";
$error_num_alcasar = "";
$country_filter="";
$find_key="false";
$status_key="false";
$script="/usr/local/bin/alcasar-sms.sh";
 
# Test if a modem is plugged on serial-usb port
$open_port=exec("ls /dev/ttyUSB*",$openned_ports); // list of USB-Serial ports openned by a modem
if (!empty($open_port))
{
$find_key="true";
$vendor=exec("udevadm info -n $openned_ports[1] | grep 'MODEL=' | cut -d'=' -f2");
$model=exec("udevadm info -n $openned_ports[1] | grep 'MODEL_FROM_DATABASE=' | cut -d'=' -f2");
$gammu_smsd_port=exec("cat /etc/gammu_smsd_conf| grep port | cut -d ' ' -f3"); // Gammu_smsd listen port
while ( list(,$row) = each($openned_ports))
{
if ( "$row" == "$gammu_smsd_port" ) // is gammu listen on an openned port ?
{
$status_key="true";
}
}
}
$gammu_pid=exec("sudo $script --pidof");
if (( $status_key == "false") || ($find_key == "false"))
{ # close gammu if it's started
if ($gammu_pid!="")
{
echo "on ferme";
exec("sudo $script stop");
sleep(8);
header('Location: autoregistration.php');
exit();
}
}
 
# Choice of language
$Language = 'en';
if(isset($_SERVER['HTTP_ACCEPT_LANGUAGE'])){
43,15 → 58,14
$l_pin = "Code PIN";
$l_num_alcasar = "Numero de téléphone du MODEM GSM";
$l_ban_temp = "Nombre d'essais avant le blocage";
$l_time_account = "Durée pour une session créée";
$l_time_account = "Durée de validité des comptes crées";
$l_time_perm = "Durée du blocage (en jours)";
$l_status_gammu = "Etat du service";
$l_start = "Démarrer";
$l_status_device = "Status de votre MODEM GSM (clé 2G/3G/4G)";
$l_key_diseable = "Aucun périphérique détecté";
$l_key_enable_1 = "Un MODEM GSM '<b>".$model."</b>' est connecté à la vitesse de ";
$l_key_enable_1 = "Un MODEM GSM '<b>".$vendor."(".$model.")</b>' est connecté à la vitesse de ";
$l_key_enable_2 = "Il a ouvert les ports suivants : ";
$l_key_enable_3 = "ALCASAR le gère actuellement sur le port : <b>".$gammu_smsd_port."</b>";
$l_force_signal = "Force du signal";
$l_imei_device = "IMEI du périphérique";
$l_sms_received = "Nombre de SMS reçu";
83,7 → 97,7
$l_service_status_img_ok="Démarré";
$l_service_status_img_ko="Arrété";
$l_connect_speed="Modifier la vitesse de connexion : ";
$l_connect_port="Modifier le port de connexion : ";
$l_connect_port="Port de connexion";
$l_tab_first = "premier";
$l_tab_last = "dernier";
$l_tab_next = "suivant";
109,15 → 123,14
$l_pin = "PIN password";
$l_num_alcasar = "Phone number of the GSM MODEM";
$l_ban_temp = "Max number of try before a permanent ban";
$l_time_account = "Time for a new session";
$l_time_account = "Validity period of new account";
$l_time_perm = "Duration of a ban (for example, after X try)";
$l_status_gammu = "Service status";
$l_start = "Start";
$l_status_device = "Status of your GSM MODEM (2G/3G/4G key)";
$l_key_diseable = "No device detected";
$l_key_enable_1 = "A GSM MODEM '<b>".$model."</b>' is connected at the speed of ";
$l_key_enable_1 = "A GSM MODEM '<b>".$vendor."(".$model.")</b>' is connected at the speed of ";
$l_key_enable_2 = "It has openned the following ports : ";
$l_key_enable_3 = "ALCASAR manage it actually on port : <b>".$gammu_smsd_port."</b>";
$l_force_signal = "Signal strength";
$l_imei_device = "Device IMEI";
$l_sms_received = "Number of SMS received";
149,7 → 162,7
$l_service_status_img_ok="Running";
$l_service_status_img_ko="Stopped";
$l_connect_speed="Modify the connection speed : ";
$l_connect_port="Modify the connection port : ";
$l_connect_port="Connection port";
$l_tab_first = "first";
$l_tab_last = "last";
$l_tab_next = "next";
226,7 → 239,7
"sSearch": "<?php echo $l_tab_search; ?>"
}
});
$(".showhide-div_country").slideUp("slow");
$(".showhide-div_country").slideUp("slow");
$(".showhide-div_ban").slideUp("slow");
$(".showhide-div_country_plus").slideUp("slow");
$(".showhide-but_country").on("click", function(){
252,21 → 265,20
<td><img src=\"/images/pix.gif\" width=\"1\" height=\"2\"></td>
</tr>
</TABLE>
<br />
<br>
<input type='checkbox' checked='checked' name='autoRefreshCheckboxes' >".$l_autorefresh."
";
?>
<center>
<br /><br />
<br>
<form form="GET" action="./autoregistration.php">
<table border=1 width=100%>
<tr>
<td colspan=2><h3><center><?php echo $l_status_device ?></center></h3></td>
</tr>
 
<tr>
<?php
if($status_key=="true")
if($find_key=="true")
{
if(isset($_GET['config_submit'])){
switch ($_GET['speed']) {
284,34 → 296,25
break;
}
}
$current_connect = exec("sudo $script --connect");
echo '<td width="50%">'.$l_key_enable_1."<b>".str_replace("at","",$current_connect).' Bauds</b>';
echo ' <td align="right"> '.$l_connect_speed.'
<select name="speed">
<option value="at"></option>
<option value="9600">9600 Bauds</option>
<option value="19200">19200 Bauds</option>
<option value="115200">115200 Bauds</option>
</select>
<input type="submit" name="config_submit">
</td></tr>';
echo '<tr><td width="50%">'.$l_key_enable_2.'<b>';
while ( list(,$row) = each($openned_ports))
{
echo $row." ";
}
echo '</b><br>'.$l_key_enable_3.'</td>';
echo ' <td align="right"> '.$l_connect_port.'
<select name="port">';
$current_speed = exec("sudo $script --connect");
echo ' <td width="50%">'.$l_key_enable_1."<b>".str_replace("at","",$current_speed).' Bauds</b>';
echo '<br>'.$l_key_enable_2.'<b>';
reset ($openned_ports);
while ( list(,$row) = each($openned_ports))
{
echo '<option value="'.$row.'">'.$row.'</option>';
echo $row." ";
}
echo ' </select>
<input type="submit" name="config_submit">
</td>';
echo '</b></td>';
echo '
<td align="right"> '.$l_connect_speed.'
<select name="speed">
<option value="at"></option>
<option value="9600">9600 Bauds</option>
<option value="19200">19200 Bauds</option>
<option value="115200">115200 Bauds</option>
</select>
<input type="submit" name="config_submit">
</td>';
}
else
{
322,25 → 325,11
</table>
</form>
</center>
<br /><br />
 
<br>
<?php
 
#Test if gammu is started
$gammu_pid=exec("sudo $script --pidof");
if ($status_key=="false")
if ($find_key=="true")
{
if ($gammu_pid!="")
{
exec("sudo $script stop");
sleep(8);
header('Location: autoregistration.php');
exit();
}
}
 
if ($status_key=="true")
{
#Nom du fichier de log lorsque gammu est démarré
#$file_log = "gammu-smsd.log";
 
348,13 → 337,13
$current_pin = exec("sudo $script --pin");
#Recuperation du nombre de try avant le ban perm
$current_try_ban = exec("sudo $script --try_ban");
$current_try_ban = exec("sudo $script --try_ban");
 
#Recuperation de la durée d'une session créée
$current_time_account = exec("sudo $script --time_account");
$current_time_account = exec("sudo $script --time_account");
 
#Recuperation de la durée dun ban perm (après flood)
$current_time_perm = exec("sudo $script --time_perm");
$current_time_perm = exec("sudo $script --time_perm");
 
#Detection neméro de tel
$current_num_alcasar = exec("sudo $script --numero_alcasar");
384,7 → 373,7
$imei_device = "-";
$sms_received = "-";
 
$gammu="<td><img src=\"/images/state_error.gif\" width=\"15\" height=\"15\" alt=\"".$l_service_status_img_ko."\"></td><td>$l_gammu_off</td>";
$gammu="<td><img src=\"/images/state_error.gif\" width=\"15\" height=\"15\" alt=\"".$l_service_status_img_ko."\"></td><td>$l_gammu_off</td>";
$gammu_status_on="";
$gammu_status_off="disabled";
 
392,7 → 381,7
{
if(($current_last_secu > $current_last_start) && ($current_last_secu < $current_last_stop))
{
$gammu_simsecu="<tr><td colspan=7><font color=red>$l_error_simsecu_l</font></td></tr>";
$gammu_simsecu="<tr><td colspan=7><font color=red>$l_error_simsecu_l</font></td></tr>";
}
}
} else {
417,17 → 406,11
 
}
 
 
 
 
 
$gammu="<td><img src=\"/images/state_ok.gif\" width=\"15\" height=\"15\" alt=\"".$l_service_status_img_ok."\"></td><td>$l_gammu_on</td>";
$gammu="<td><img src=\"/images/state_ok.gif\" width=\"15\" height=\"15\" alt=\"".$l_service_status_img_ok."\"></td><td>$l_gammu_on</td>";
if($current_last_timeout!=""){
if(($current_last_timeout > $current_last_start) && ($current_last_timeout > $current_last_stop))
{
$gammu_timeout="<tr><td colspan=7><font color=red>$l_error_timeoutfail</font></td></tr>";
$gammu_timeout="<tr><td colspan=7><font color=red>$l_error_timeoutfail</font></td></tr>";
}
}
442,7 → 425,7
if($current_last_write!=""){
if(($current_last_write > $current_last_start) && ($current_last_write > $current_last_stop))
{
$gammu_writeerror="<tr><td colspan=7><font color=red>$l_error_writefail</font></td></tr>";
$gammu_writeerror="<tr><td colspan=7><font color=red>$l_error_writefail</font></td></tr>";
}
}
462,7 → 445,6
if(isset($_GET["start"])){
$gammu_1=exec("sudo $script --start");
sleep(7);
if($current_last_secu!="")
{
if(($current_last_secu > $current_last_start) && ($current_last_secu > $current_last_stop))
470,7 → 452,6
exec("sudo $script --stop");
}
}
sleep(7);
if($current_last_secu!="")
{
479,7 → 460,6
exec("sudo $script --stop");
}
}
sleep(7);
if($current_last_secu!="")
{
488,9 → 468,6
exec("sudo $script --stop");
}
}
header('Location: autoregistration.php');
exit();
}
540,7 → 517,7
}
else
{
$error_pin=$l_error_label_num;
$error_pin=$l_error_label_num;
}
}
else
664,7 → 641,7
}
 
if(isset($_GET["b_country_enable"])){
exec("sudo $script --change_country_ena_all");
exec("sudo $script --change_country_ena_all");
exec("sudo $script --change_country_filter all");
header('Location: autoregistration.php');
exit();
675,47 → 652,31
header('Location: autoregistration.php');
exit();
}
 
 
#Si une clé 3g est plugué
echo "<form action=\"autoregistration.php\" methode=\"GET\">
<table border=1>
<tr>
<td colspan=4><b>$l_status_gammu</b></td>
<td><b><center>$l_force_signal</center></b></td>
<td><b><center>$l_imei_device</center></b></td>
<td><b><center>$l_sms_received</center></b></td>
<td colspan=3><b>$l_conf</b></td>
<td><b>$l_conf_actu</b></td>
</tr>
<tr>
$gammu
<td><button type=\"submit\" name=\"start\" $gammu_status_on>$l_start</button></td>
<td><button type=\"submit\" name=\"stop\" $gammu_status_off>$l_stop</button></td>
<td><center>$force_signal</center></td>
<td><center>$imei_device</center></td>
<td><center>$sms_received</center></td>
<td> $l_connect_port </td><td><select name=\"port\">'";
reset ($openned_ports);
while ( list(,$row) = each($openned_ports))
{
echo '<option value="'.$row.'">'.$row.'</option>';
echo $row." ";
}
echo "</select></td>
<td><button type=\"submit\" name=\"b_num_alcasar\" $gammu_status_on>$l_edit</button></td>
<td><center><font color=\"green\">$gammu_smsd_port</font></center></td>
</tr>
$gammu_puk
$gammu_simfail
$gammu_simsecu
$gammu_timeout
$gammu_writeerror
</table>
<br /><br />
<table border=1>
<tr>
<td colspan=3><b>$l_conf</b></td>
<td><b>$l_conf_actu</b></td>
</tr>
<tr>
<td> $l_num_alcasar </td><td><input type=text name='num_alcasar' maxlength=\"20\"></td>
<td><button type=\"submit\" name=\"b_num_alcasar\" $gammu_status_on>$l_edit</button></td>
<td><center><font color=\"green\">$current_num_alcasar</font></center></td>
</tr>
<tr><td colspan=\"4\"><font color=red><b>$error_num_alcasar</b></font></td></tr>
<tr>
<td> $l_pin </td><td><input type=text name='pin' maxlength=\"8\"></td>
<td><button type=\"submit\" name=\"b_pin\" $gammu_status_on>$l_edit</button></td>
722,30 → 683,48
<td><center><font color=\"green\">$current_pin</font></center></td>
</tr>
<tr><td colspan=\"4\"><font color=red><b>$error_pin</b></font></td></tr>
<tr>
<td> $l_time_account </td><td><input type=text name='time_account'> $l_days </td>
<td><button type=\"submit\" name=\"b_time_account\" $gammu_status_on>$l_edit</button></td>
<td><button type=\"submit\" name=\"b_time_account\" $gammu_status_on>$l_edit</button></td>
<td><center><font color=\"blue\">$current_time_account</font></center></td>
</tr>
<tr><td colspan=\"4\"><font color=red><b>$error_time_account</b></font></td></tr>
<tr>
<td> $l_ban_temp </td><td><input type=text name='nb_essais'></td>
<td><button type=\"submit\" name=\"b_ban_temp\" $gammu_status_on>$l_edit</button></td>
<td> $l_ban_temp </td><td><input type=text name='nb_essais'></td>
<td><button type=\"submit\" name=\"b_ban_temp\" $gammu_status_on>$l_edit</button></td>
<td><center><font color=\"orange\">$current_try_ban</font></center></td>
</tr>
<tr><td colspan=\"4\"><font color=red><b>$error_nb_essais</b></font></td></tr>
<tr>
<td>$l_time_perm</td><td><input type=text name='time_perm'> $l_days</td>
<td><button type=\"submit\" name=\"b_time_perm\" $gammu_status_on>$l_edit</button></td>
<td><button type=\"submit\" name=\"b_time_perm\" $gammu_status_on>$l_edit</button></td>
<td><center><font color=\"orange\">$current_time_perm</font></center></td>
</tr>
<tr><td colspan=\"4\"><font color=red><b>$error_time_perm</b></font></td></tr>
</table>
<br>
<table border=1>
<tr>
<td colspan=4><b>$l_status_gammu</b></td>
<td><b><center>$l_force_signal</center></b></td>
<td><b><center>$l_imei_device</center></b></td>
<td><b><center>$l_sms_received</center></b></td>
</tr>
<tr>
$gammu
<td><button type=\"submit\" name=\"start\" $gammu_status_on>$l_start</button></td>
<td><button type=\"submit\" name=\"stop\" $gammu_status_off>$l_stop</button></td>
<td><center>$force_signal</center></td>
<td><center>$imei_device</center></td>
<td><center>$sms_received</center></td>
</tr>
$gammu_puk
$gammu_simfail
$gammu_simsecu
$gammu_timeout
$gammu_writeerror
</table>
</form>";
 
require('/etc/freeradius-web/config.php');