/alcasar.sh |
---|
1462,8 → 1462,7 |
[ -e /etc/anacrontab.default ] || cp /etc/anacrontab /etc/anacrontab.default |
cat <<EOF >> /etc/anacrontab |
7 8 cron.MysqlDump nice /etc/cron.d/alcasar-mysql |
7 10 cron.logExport nice /etc/cron.d/alcasar-export_log |
7 15 cron.logClean nice /etc/cron.d/alcasar-clean_log |
7 10 cron.logExport nice /etc/cron.d/alcasar-archive |
7 20 cron.importClean nice /etc/cron.d/alcasar-clean_import |
EOF |
1574,7 → 1573,7 |
RunOnReceive = /usr/local/bin/alcasar-sms.sh --new_sms |
StatusFrequency = 30 |
LoopSleep = 2 |
;LoopSleep = 2 |
;ResetFrequency = 300 |
;HardResetFrequency = 120 |
1594,6 → 1593,11 |
$SED "10c u_db=\"$DB_USER\"" $DIR_DEST_BIN/alcasar-sms.sh |
$SED "11c p_db=\"$radiuspwd\"" $DIR_DEST_BIN/alcasar-sms.sh |
#Création de la règle udev pour les Huawei // idVendor: 12d1 |
cat << EOF > /etc/udev/rules.d/66-huawei.rules |
KERNEL=="ttyUSB0",ATTRS{idVendor}=="12d1",RUN+="/usr/local/bin/alcasar-sms.sh --mode" |
EOF |
} # END gammu_smsd() |
################################################################## |
/scripts/alcasar-sms.sh |
---|
1,7 → 1,7 |
#!/bin/bash |
######################################### |
####### VARIABLES ne pas toucher ######## |
nb_essais=3 |
nb_essais=2 |
time_account=1 |
time_ban=1 |
numero_alcasar=XXXXXXXXXX |
40,7 → 40,18 |
# Functions |
function mode_huawei() { |
couple=$(lsusb | grep -i huawei | cut -d ' ' -f6) |
vendor=$(echo $couple | cut -d ':' -f1) |
product=$(echo $couple | cut -d ':' -f2) |
echo "*********************" >> /srv/log.log |
echo $vendor >> /srv/log.log |
echo $product >> /srv/log.log |
/usr/sbin/usb_modeswitch -I -H -v 0x$vendor -p 0x$product -V 0x$vendor -P 0x$product -W -n >> /srv/log.log |
} |
function start_gammu() { |
#On truncate la table phones (informations signal / IMEI / batterie / sms recu et envoyé) |
sql_trunc_phones="connect gammu; TRUNCATE phones;" |
101,10 → 112,14 |
# On recupère le nombre de mots (resultat) |
nb=$(echo $result | wc -w) |
# On récypère le numéro de l'ID |
# On récupère le numéro de l'ID |
id=$(echo $result | cut -d ' ' -f1) |
numero=$(echo $result | cut -d ' ' -f2 | sed -e 's/+33/0/g') |
#numero=$(echo $result | cut -d ' ' -f2 | sed -e 's/+33/0/g'/) |
numero=$(echo $result | cut -d ' ' -f2) |
if [[ $numero =~ ^\+ ]] |
then |
# On vérifie que le numéro n'est pas Ban Perm |
sql_ban_perm="connect gammu; SELECT * FROM $sms_p WHERE SenderNumber=$numero" |
result_bp=$(mysql --user=$u_db --password=$p_db -B -se "$sql_ban_perm") |
278,7 → 293,9 |
echo "Le ban de $numero est encore valide" |
fi |
fi |
else |
echo "Numero non autorisé (ex: 36665)" |
fi |
# On supprime la ligne d'ID=$id dans inbox |
mysql --user=$u_db --password=$p_db -B -e "$sql_delete_inbox WHERE ID=$id;" |
done |
339,6 → 356,16 |
cat $config | grep logfile | cut -d ' ' -f3 |
exit 0 |
;; |
--connect) |
# Récupère la vitesse de co |
cat $config | grep connection | cut -d ' ' -f3 |
exit 0 |
;; |
--replace_connect) |
# Edition de la vitesse de co |
sed -i "3c connection = at$2" $config |
exit 0 |
;; |
--pin) |
# Récupère le code PIN (file de conf) |
cat $config | grep PIN | cut -d ' ' -f3 |
417,6 → 444,11 |
sed -i "7c numero_alcasar=$2" $script |
exit 0 |
;; |
--mode) |
# Mode huawei |
mode_huawei |
exit 0 |
;; |
*) |
# Default |
echo "$usage" |
/scripts/sbin/alcasar-uninstall.sh |
---|
220,8 → 220,10 |
sleep 1 |
#gammu-smsd |
echo -en "\n- gammu-smsd(1) :" |
rm -f /etc/gammu_smsd_conf |
echo -en "\n- gammu-smsd(3) :" |
[ -e /etc/gammu_smsd_conf ] && rm -f /etc/gammu_smsd_conf && echo -n "1, " |
[ -e /etc/udev/rules.d/66-huawei.rules ] && rm -f /etc/udev/rules.d/66-huawei.rules && echo -n "2, " |
[ -e /var/log/gammu-smsds ] && rm -rf /var/log/gammu-smsds && echo ,-n "3" |
echo -n "1" |
#nettoyage (on retire les services supprimés ou remplacés dans la nouvelle version) |
/web/acc/manager/htdocs/autoregistration.php |
---|
9,9 → 9,12 |
<body> |
<TABLE width="100%" border="0" cellspacing="0" cellpadding="0"> |
<? |
#Commandes |
$exec_com=exec("lsusb | grep -i huawei | cut -d ' ' -f6"); |
$exec_com2=exec("lsusb | grep -i d-link | cut -d ' ' -f7"); |
# Test présence de clé/modem |
$exec_com=exec("lsusb | grep -i 067b | cut -d ' ' -f6 | cut -d ' ' -f1"); |
$exec_com2=exec("lsusb | grep -i 12d1 | cut -d ' ' -f6 | cut -d ' ' -f1"); |
//$exec_com2=exec("lsusb | grep -i d-link | cut -d ' ' -f7"); |
$status_key="false"; |
$script="/usr/local/bin/alcasar-sms.sh"; |
38,9 → 41,9 |
$l_conf_actu = "Configuration actuelle"; |
$l_pin = "Code PIN"; |
$l_num_alcasar = "Le numero de téléphone de la clé 3G"; |
$l_ban_temp = "Nombre d'essais max avant le ban permanant"; |
$l_ban_temp = "Nombre d'essais avant le blocage"; |
$l_time_account = "Durée pour une session créée"; |
$l_time_perm = "Durée en jours d'un bloquage (ban)"; |
$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 périphérique"; |
56,6 → 59,7 |
$l_error_label_empty = "Le champ est vide"; |
$l_error_label_num = "Ce n'est pas un PIN valide"; |
$l_error_label_num2 = "Ce n'est pas un nombre"; |
$l_error_label_num3 = "Le format n'est pas correct: +xxxYYYYYYYYY (xxx: code pays / YYYYYYYYY: numéro de téléphone)"; |
$l_error_writefail = "Gammu semble ne pas parvenir à discuter avec la clé (port ttyUSB0)."; |
$l_error_timeoutfail = "Impossible de se connecter à la clé 3G. Timeout."; |
$l_error_simfail = "Un problème au niveau de la carte SIM a été détecté. Est elle présente?"; |
75,6 → 79,8 |
$l_service_status_img_ok="Démarré"; |
$l_service_status_img_ko="Arrété"; |
$l_conf_name="Configuration : "; |
$l_current_connect = "Connexion"; |
} |
else { |
101,6 → 107,8 |
$l_error_label_empty = "Field empty"; |
$l_error_label_num = "It's not a valid PIN password"; |
$l_error_label_num2 = "It's not a number"; |
$l_error_label_num3 = "The phone number is not good: +xxxYYYYYYYYY (xxx: code pays / YYYYYYYYY: numéro de téléphone)"; |
$l_error_writefail = "Gammu semble ne pas parvenir à discuter avec la clé (port ttyUSB0)."; |
$l_error_writefail = "Gammu can't listen the ttyUSB0 port."; |
$l_error_timeoutfail = "Timeout. Can not connect to modem."; |
$l_error_simfail = "An issue with your Sim card was detected. Is it in the key?"; |
119,6 → 127,9 |
$l_num_unlock="Erase"; |
$l_service_status_img_ok="Running"; |
$l_service_status_img_ko="Stopped"; |
$l_conf_name="Configuration : "; |
$l_current_connect = "Connection"; |
} |
echo " |
<tr> |
137,7 → 148,7 |
<br /><br /> |
<table border=1 width=100%> |
<tr> |
<td colspan=2><h3><?php echo $l_status_device ?></h3></td> |
<td colspan=3><h3><?php echo $l_status_device ?></h3></td> |
</tr> |
<tr> |
144,7 → 155,43 |
<?php |
if(!empty($exec_com) || !empty($exec_com2)) |
{ |
echo "<td>$l_key_enable</td>"; |
if(isset($_GET['config_submit'])){ |
switch ($_GET['config']) { |
case "at": |
exec("sudo $script --replace_connect "); |
break; |
case "9600": |
exec("sudo $script --replace_connect 9600"); |
break; |
case "19200": |
exec("sudo $script --replace_connect 19200"); |
break; |
case "115200": |
exec("sudo $script --replace_connect 115200"); |
break; |
} |
} |
$current_connect = exec("sudo $script --connect"); |
echo '<td width="50%">'.$l_key_enable.'</td>'; |
echo '<td width="20%">'.$l_current_connect.' : '.$current_connect.'</td>'; |
echo ' <form form="GET" action="./autoregistration.php"> |
<td align="right"> '.$l_conf_name.' |
<select name="config"> |
<option value="at">at</option> |
<option value="9600">at9600</option> |
<option value="19200">at19200</option> |
<option value="115200">at115200</option> |
</select> |
<input type="submit" name="config_submit"></submit> |
</td> |
</form> |
'; |
$status_key="true"; |
} |
else |
215,6 → 262,7 |
#Recuperation de la dernière ligne de TIMEOUT |
$current_last_timeout = exec("sudo $script --last_timeout"); |
# Test si le service est lancé |
if ($gammu_pid=="") |
{ |
$force_signal = "-"; |
297,7 → 345,7 |
} |
#Lancement et arret de gammu-smsd |
#Lancement et arret de gammu-smsd 3*7sec |
if(isset($_GET["start"])){ |
$gammu_1=exec("sudo $script --start"); |
sleep(7); |
346,7 → 394,7 |
$error_num_alcasar = ""; |
if($num !="") |
{ |
if(is_numeric($num)) |
if(preg_match('#^\+#',$num)) |
{ |
exec("sudo $script --replace_numero_alcasar $num"); |
header('Location: autoregistration.php'); |
353,7 → 401,7 |
} |
else |
{ |
$error_num_alcasar=$l_error_label_num2; |
$error_num_alcasar=$l_error_label_num3; |
} |
} |
else |
384,6 → 432,7 |
} |
} |
#Edition du nombre d'essais avant le ban perm |
if(isset($_GET["b_ban_temp"])){ |
$nb_ban_temp = $_GET["nb_essais"]; |
498,34 → 547,40 |
</tr> |
<tr> |
<td> $l_num_alcasar </td><td><input type=text name='num_alcasar' maxlength=\"10\"><font color=red><b>$error_num_alcasar</b></font></td> |
<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\"><font color=red><b>$error_pin</b></font></td> |
<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> |
<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 <font color=red><b>$error_time_account</b></font> |
<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><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'><font color=red><b>$error_nb_essais</b></font></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 <font color=red><b>$error_time_perm</b></font> |
<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><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> |
</tr> |
</table> |
</form>"; |
593,6 → 648,7 |
mysqli_close($con); |
} |
?> |
</html> |
/web/acc/manager/htdocs/user_edit.php |
---|
291,7 → 291,11 |
echo "<td><select name=$oper_name><option $selected[$op_eq] value=\":=\">:=</td><td><input type=text name=\"$name1\" value=\"$val\" size=20></td>"; |
break; |
case 'Expiration' : |
if($login == "sms" && $user_type == 'group'){ |
echo "<td><select name=$oper_name><option $selected[$op_eq] value=\":=\">:=</td><td><input type=text name=\"$name1\" value=\"$val\" size=20 disabled></td>"; |
} else { |
echo "<td><select name=$oper_name><option $selected[$op_eq] value=\":=\">:=</td><td><input type=text name=\"$name1\" value=\"$val\" size=20></td>"; |
} |
break; |
case 'Max-All-Session' : |
echo "<td><select name=$oper_name><option $selected[$op_eq] value=\":=\">:=</td><td><input type=text name=\"$name1\" value=\"$val\" size=20></td>"; |
/web/acc/manager/html/group_toolbar.html.php |
---|
9,8 → 9,25 |
<a href="group_admin.php?login=$Login"><font color="black"><b>$l_members</b></font></a></td> |
<td align=center bgcolor="#FFCC66"> |
<a href="user_edit.php?login=$Login&user_type=group"><font color="black"><b>$l_attributes</b></font></a></td> |
EOM; |
// Si le groupe selectionné est "sms" on désactive le lien de suppression. |
if(!($Login=="sms")) |
{ |
print <<<EOM |
<td align=center bgcolor="#FFCC66"> |
<a href="user_delete.php?login=$Login&user_type=group"><font color="black"><b>$l_remove</b></font></a></td> |
EOM; |
} |
else |
{ |
print <<<EOM |
<td align=center bgcolor="#FFCC66"> |
<font color="black"><b>$l_remove</b></font></td> |
EOM; |
} |
print <<<EOM |
</tr> |
EOM; |
?> |
/web/autoregistrationinfo.php |
---|
45,6 → 45,7 |
$l_num_expiration = "Expiration du bloquage"; |
$l_num_inconnu = "Le numero renseigné n'est dans la base de donnée"; |
$l_num_empty = "Le champ de recherche est vide."; |
$l_num_invalid = "Le format n'est pas correct: +xxxYYYYYYYYY (xxx: code pays / YYYYYYYYY: numéro de téléphone)"; |
$l_num_recherche = "Rechercher votre numéro:"; |
$l_recherche = "Rechercher"; |
53,6 → 54,7 |
$l_tuto_2 = "Le portail auquel vous essayez de vous connectez offre la possibilité de s'inscrire automatiquement, en envoyant votre mot de passe par SMS au numéro (prix d'un SMS, non surtaxé):"; |
$l_tuto_3 = "Votre SMS ne doit contenir qu'un seul mot."; |
$l_tuto_4 = "A la suite de votre inscription, vous pourrez retrouver votre numéro de téléphone dans le tableau ci-dessous, avec l'état et la date d'expiration de validité ou bloquage de ce dernier. Seul les 30 dernier numéros peuvent être affichés. Un champ de recherche est néanmoins disponible."; |
$l_help_s = "Pour la France: +3312234455"; |
} |
else { |
129,7 → 131,7 |
while($row = mysqli_fetch_array($result)) |
{ |
$start = substr($row['SenderNumber'], 0, 3); |
$start = substr($row['SenderNumber'], 0, 5); |
$end = substr($row['SenderNumber'], -3); |
echo " |
<tr> |
152,6 → 154,8 |
$num = mysqli_real_escape_string($con, $_POST['number']); |
echo "<tr>"; |
if($num!=""){ |
if(preg_match('#^\+#', $num) == 1) |
{ |
echo "<td><b>$num</b></td>"; |
$result = mysqli_query($con, "SELECT * FROM SMS_ban_perm WHERE SenderNumber='$num';"); |
$row = mysqli_fetch_array($result); |
170,6 → 174,9 |
echo " <td><b>" . $row['Expiration']. "</b></td>"; |
} |
} else { |
echo "<td colspan=\"3\"><b><font color=\"red\">$l_num_invalid</font></b></td>"; |
} |
} else { |
echo "<td colspan=\"3\"><b><font color=\"red\">$l_num_empty</font></b></td>"; |
} |
echo "</tr>"; |
185,6 → 192,9 |
<td><?php echo "$l_num_recherche"; ?> <input type="text" name="number" maxlength="10" size="10"> <input type="submit" value="<?php echo "$l_recherche" ?>"></td> |
</form> |
</tr> |
<tr> |
<td colspan=\"2\"><?php echo $l_help_s; ?></td> |
</tr> |
</table> |