Subversion Repositories ALCASAR

Compare Revisions

Ignore whitespace Rev 2550 → Rev 2552

/alcasar.sh
28,8 → 28,8
# testing : connectivity tests, free space test and mageia version test
# init : Installation of RPM and scripts
# network : Network parameters
# ACC : ALCASAR Control Center installation
# CA : Certification Authority initialization
# ACC : ALCASAR Control Center installation
# CA : Certification Authority initialization
# time_server : NTPd configuration
# init_db : Initilization of radius database managed with MariaDB
# freeradius : FreeRadius initialisation
41,13 → 41,13
# nfsen : Configuration of Nfsen Netflow grapher
# dnsmasq : Name server configuration
# vnstat : little network stat daemon
# BL : Adaptation of Toulouse University BlackList : split into 3 BL (for Dnsmasq, for e2guardian and for Netfilter)
# BL : Adaptation of Toulouse University BlackList : split into 3 BL (for Dnsmasq, for e2guardian and for Netfilter)
# cron : Logs export + watchdog + connexion statistics
# fail2ban : Fail2ban IDS installation and configuration
# gammu_smsd : Autoregister addon via SMS (gammu-smsd)
# msec : Mandriva security package configuration
# letsencrypt : Let's Encrypt client
# post_install : Security, log rotation, etc.
# post_install : Security, log rotation, etc.
 
DEBUG_ALCASAR='off'; export DEBUG_ALCASAR # Debug mode = wait (hit key) after each function
DATE=`date '+%d %B %Y - %Hh%M'`
55,27 → 55,27
Lang=`echo $LANG|cut -c 1-2`
mode="install"
# ******* Files parameters - paramètres fichiers *********
DIR_INSTALL=`pwd` # current directory
DIR_INSTALL=`pwd` # current directory
DIR_CONF="$DIR_INSTALL/conf" # install directory (with conf files)
DIR_SCRIPTS="$DIR_INSTALL/scripts" # install directory (with script files)
DIR_BLACKLIST="$DIR_INSTALL/blacklist" # install directory (with blacklist files)
DIR_SAVE="/var/Save" # backup directory (traceability_log, user_db, security_log)
DIR_WEB="/var/www/html" # directory of Lighttpd
DIR_DG="/etc/e2guardian" # directory of E2Guardian
DIR_ACC="$DIR_WEB/acc" # directory of the 'ALCASAR Control Center'
DIR_BLACKLIST="$DIR_INSTALL/blacklist" # install directory (with blacklist files)
DIR_SAVE="/var/Save" # backup directory (traceability_log, user_db, security_log)
DIR_WEB="/var/www/html" # directory of Lighttpd
DIR_DG="/etc/e2guardian" # directory of E2Guardian
DIR_ACC="$DIR_WEB/acc" # directory of the 'ALCASAR Control Center'
DIR_DEST_BIN="/usr/local/bin" # directory of ALCASAR scripts
DIR_DEST_ETC="/usr/local/etc" # directory of ALCASAR conf files
DIR_DEST_SHARE="/usr/local/share" # directory of share files used by ALCASAR (dnsmasq for instance)
CONF_FILE="$DIR_DEST_ETC/alcasar.conf" # central ALCASAR conf file
CONF_FILE="$DIR_DEST_ETC/alcasar.conf" # central ALCASAR conf file
PASSWD_FILE="/root/ALCASAR-passwords.txt" # text file with the passwords and shared secrets
# ******* DBMS parameters - paramètres SGBD ********
DB_RADIUS="radius" # database name used by FreeRadius server
DB_USER="radius" # user name allows to request the users database
DB_GAMMU="gammu" # database name used by Gammu-smsd
DB_RADIUS="radius" # database name used by FreeRadius server
DB_USER="radius" # user name allows to request the users database
DB_GAMMU="gammu" # database name used by Gammu-smsd
# ******* Network parameters - paramètres réseau *******
HOSTNAME="alcasar" # default hostname
DOMAIN="localdomain" # default local domain
EXTIF=`/usr/sbin/ip route|grep default|head -n1|cut -d" " -f5` # EXTIF is connected to the ISP broadband modem/router (In France : Box-FAI)
HOSTNAME="alcasar" # default hostname
DOMAIN="localdomain" # default local domain
EXTIF=`/usr/sbin/ip route|grep default|head -n1|cut -d" " -f5` # EXTIF is connected to the ISP broadband modem/router (In France : Box-FAI)
INTIF=`/usr/sbin/ip link|grep '^[[:digit:]]:'|grep -v "lo\|$EXTIF\|tun0"|head -n1|cut -d" " -f2|tr -d ":"` # INTIF is connected to the consultation network
MTU="1500"
DEFAULT_PRIVATE_IP_MASK="192.168.182.1/24" # Default ALCASAR IP address
116,13 → 116,13
echo "-----------------------------------------------------------------------------"
}
 
##################################################################
## Function "testing" ##
## - Test of Mageia version ##
## - Test of ALCASAR version (if already installed) ##
## - Test of free space on /var (>10G) ##
## - Test of Internet access ##
##################################################################
########################################################
## Function "testing" ##
## - Test Mageia version ##
## - Test ALCASAR version (if already installed) ##
## - Test free space on /var (>10G) ##
## - Test Internet access ##
########################################################
testing ()
{
# Test of Mageia version
359,11 → 359,11
echo ". : ok"
} # end of testing ()
 
##################################################################
## Function "init" ##
## - Création du fichier "/root/ALCASAR_parametres.tx ##
## - Installation et modification des scripts du portail ##
##################################################################
#######################################################################
## Function "init" ##
## - Creation of ALCASAR conf file "/usr/local/etc/alcasar.conf ##
## - Creation of random password for GRUB, mariadb (admin and user) ##
#######################################################################
init ()
{
if [ "$mode" != "update" ]
437,14 → 437,14
chmod o-rwx $CONF_FILE
} # End of init ()
 
##################################################################
## Function "network" ##
## - Définition du plan d'adressage du réseau de consultation ##
## - Nommage DNS du système ##
## - Configuration de l'interface INTIF (réseau de consultation)##
## - Modification du fichier /etc/hosts ##
## - Renseignement des fichiers hosts.allow et hosts.deny ##
##################################################################
#########################################################
## Function "network" ##
## - Define the several network address ##
## - Define the DNS naming ##
## - INTIF parameters (consultation network) ##
## - Write "/etc/hosts" file ##
## - write "hosts.allow" & "hosts.deny" files ##
#########################################################
network ()
{
header_install
531,12 → 531,11
PUBLIC_NETMASK=`/bin/ipcalc -m $PUBLIC_IP_MASK | cut -d"=" -f2`
PUBLIC_PREFIX=`/bin/ipcalc -p $PUBLIC_IP $PUBLIC_NETMASK|cut -d"=" -f2`
PUBLIC_NETWORK=`/bin/ipcalc -n $PUBLIC_IP/$PUBLIC_PREFIX|cut -d"=" -f2`
# Wrtie the conf file
# Write network parameters in the conf file
echo "EXTIF=$EXTIF" >> $CONF_FILE
echo "INTIF=$INTIF" >> $CONF_FILE
######## Récupération des interfaces du ou des réseaux de consultation supplémentaires #################
INTERFACES=`/usr/sbin/ip link|grep '^[[:digit:]]:'|grep -v "^lo\|$EXTIF\|tun0"|cut -d " " -f2|tr -d ":"`
 
for i in $INTERFACES
do
SUB=`echo ${i:0:2}`
546,7 → 545,6
then LANIF=$i
fi
done
 
if [ -n "$WIFIF" ]
then echo "WIFIF=$WIFIF" >> $CONF_FILE
elif [ -n "$LANIF" ]
553,8 → 551,7
then echo "LANIF=$LANIF" >> $CONF_FILE
fi
#########################################################################################################
 
IP_SETTING=`grep BOOTPROTO /etc/sysconfig/network-scripts/ifcfg-$EXTIF|cut -d"=" -f2` # IP setting (static or dynamic)
IP_SETTING=`grep BOOTPROTO /etc/sysconfig/network-scripts/ifcfg-$EXTIF|cut -d"=" -f2` # test static or dynamic
if [ $IP_SETTING == "dhcp" ]
then
echo "PUBLIC_IP=dhcp" >> $CONF_FILE
580,13 → 577,13
NETWORKING=yes
FORWARD_IPV4=true
EOF
# /etc/hosts config
# write "/etc/hosts"
[ -e /etc/hosts.default ] || cp /etc/hosts /etc/hosts.default
cat <<EOF > /etc/hosts
127.0.0.1 localhost
$PRIVATE_IP $HOSTNAME.$DOMAIN $HOSTNAME
EOF
# EXTIF (Internet) config
# write EXTIF (Internet) config
[ -e /etc/sysconfig/network-scripts/default-ifcfg-$EXTIF ] || cp /etc/sysconfig/network-scripts/ifcfg-$EXTIF /etc/sysconfig/network-scripts/default-ifcfg-$EXTIF
if [ $IP_SETTING == "dhcp" ]
then
626,7 → 623,7
MTU=$MTU
EOF
fi
# Config INTIF (consultation LAN) in normal mode
# write INTIF (consultation LAN) in normal mode
cat <<EOF > /etc/sysconfig/network-scripts/ifcfg-$INTIF
DEVICE=$INTIF
BOOTPROTO=static
639,7 → 636,7
USERCTL=no
EOF
cp -f /etc/sysconfig/network-scripts/ifcfg-$INTIF /etc/sysconfig/network-scripts/default-ifcfg-$INTIF
# Config of INTIF in bypass mode (see "alcasar-bypass.sh")
# write INTIF in bypass mode (see "alcasar-bypass.sh")
cat <<EOF > /etc/sysconfig/network-scripts/bypass-ifcfg-$INTIF
DEVICE=$INTIF
BOOTPROTO=static
683,7 → 680,7
EOF
fi
#########################################################################################################
# Renseignement des fichiers hosts.allow et hosts.deny
# write hosts.allow & hosts.deny
[ -e /etc/hosts.allow.default ] || cp /etc/hosts.allow /etc/hosts.allow.default
cat <<EOF > /etc/hosts.allow
ALL: LOCAL, 127.0.0.1, localhost, $PRIVATE_IP
711,13 → 708,13
# the script "$DIR_DEST_BIN/alcasar-iptables.sh" is launched at the end in order to allow update via ssh
} # End of network ()
 
##################################################################
## Function "ACC" ##
## - installation of then ALCASAR Control Center (ACC) ) ##
## - configuration of the web server (Lighttpd) ##
## - creation of the first ACC admin account ##
## - secure the access ##
##################################################################
###################################################
## Function "ACC" ##
## - copy ALCASAR Control Center (ACC) files ##
## - configuration of the web server (Lighttpd) ##
## - creation of the first ACC admin account ##
## - secure the ACC access ##
###################################################
ACC ()
{
[ -d $DIR_WEB ] && rm -rf $DIR_WEB
796,7 → 793,7
/usr/bin/systemctl start lighttpd
/usr/bin/systemctl start php-fpm
 
# Définition du premier compte lié au profil 'admin'
# Creation of the first account (in 'admin' profile)
if [ "$mode" = "install" ]
then
header_install
818,10 → 815,10
chmod 664 /var/Save/security/acc_access.log
} # End of ACC ()
 
##########################################################################
## Fonction "CA" ##
## - Creating the CA and the server certificate (lighttpd) ##
##########################################################################
##################################################################
## Fonction "CA" ##
## - Creating the CA and the server certificate (lighttpd) ##
##################################################################
CA ()
{
$DIR_DEST_BIN/alcasar-CA.sh
830,10 → 827,10
chmod -R 750 /etc/pki
} # End of CA ()
 
##################################################################
## Function "time_server" ##
## - Configuring NTP server ##
##################################################################
#############################################################
## Function "time_server" ##
## - Configuring NTP server ##
#############################################################
time_server ()
{
# Set the Internet time server
1026,7 → 1023,7
} # End freeradius ()
 
#############################################################################
## Function "chilli" ##
## Function "chilli" ##
## - Creation of the conf file and init file (systemd) for coova-chilli ##
## - Adapt the authentication web page (intercept.php) ##
#############################################################################
1339,7 → 1336,7
 
################################################################################
## Function "tinyproxy" ##
## - Set the parameters of tinyproxy (proxy between filterde users and havp) ##
## - Set the parameters of tinyproxy (proxy between filtered users and havp) ##
################################################################################
tinyproxy ()
{
1492,10 → 1489,10
rm -rf /tmp/SURFmap*
} # End of nfsen ()
 
##################################################
## Function "vnstat" ##
## - Initialization of Vnstat and vnstat phpFE ##
##################################################
###########################################################
## Function "vnstat" ##
## - Initialization of Vnstat and vnstat phpFrontEnd ##
###########################################################
vnstat ()
{
[ -e /etc/vnstat.conf.default ] || cp /etc/vnstat.conf /etc/vnstat.conf.default
1507,7 → 1504,7
} # End of vnstat
 
################################################################
## Function "dnsmasq" ##
## Function "dnsmasq" ##
## - creation of the conf files of the 4 intances of dnsmasq ##
################################################################
dnsmasq ()
1616,9 → 1613,14
done
} # End dnsmasq
 
#######################################################
## Function "BL" ##
#######################################################
##########################################################
## Function "BL" ##
## - copy Toulouse BL ##
## - adapt this BL to ALCASAR architecture ##
## - domain names for dnsmasq-bl & dnasmasq-wl ##
## - URLs for E²guardian ##
## - IPs for NetFilter ##
##########################################################
BL ()
{
# copy the Toulouse university BL in order to be adapted to ALCASAR architecture (alcasar-bl.sh -adapt)
1675,9 → 1677,10
$DIR_DEST_BIN/alcasar-bl.sh --cat_choice
} # End BL()
 
##########################################################
## Function "cron" ##
##########################################################
#######################################################
## Function "cron" ##
## - write all cron & anacron files ##
#######################################################
cron ()
{
# Modif du fichier 'crontab' pour passer les cron à minuit au lieu de 04h00
1764,11 → 1767,11
rm -f /var/spool/cron/*
} # End cron()
 
##################################################################
## Fonction "Fail2Ban" ##
##- Modification de la configuration de fail2ban ##
##- Sécurisation DDOS, SSH-Brute-Force, Intercept.php ... ##
##################################################################
######################################################################
## Fonction "Fail2Ban" ##
##- Adapt conf file to ALCASAR ##
##- Secure items : DDOS, SSH-Brute-Force, Intercept.php Brute-Force ##
######################################################################
fail2ban()
{
/usr/bin/sh $DIR_CONF/fail2ban.sh
1785,11 → 1788,11
$SED '/After=*/c After=syslog.target network.target lighttpd.service' /usr/lib/systemd/system/fail2ban.service
} # End fail2ban()
 
##################################################################
## Fonction "gammu_smsd" ##
## - Creation de la base de donnée Gammu ##
## - Creation du fichier de config: gammu_smsd_conf ##
##################################################################
#########################################################
## Fonction "gammu_smsd" ##
## - Creating of SMS management database ##
## - Write the gammu a gammu_smsd conf files ##
#########################################################
gammu_smsd()
{
# Create 'gammu' databse
1798,18 → 1801,20
# Add a gammu database structure
mysql -u$DB_USER -p$radiuspwd $DB_GAMMU < $DIR_CONF/empty-gammu-smsd-db.sql
 
# Config file for the daemon
# Config file for the gammu_smsd daemon & gammu (ttyUSB0 as default com port)
cat << EOF > /etc/gammurc
[gammu]
device = /dev/ttyUSB0
connection = at115200
EOF
 
cat << EOF > /etc/gammu_smsd_conf
[gammu]
port = /dev/ttyUSB0
connection = at115200
 
;########################################################
 
[smsd]
 
PIN = 1234
 
logfile = /var/log/gammu-smsd/gammu-smsd.log
logformat = textall
debuglevel = 0
1834,7 → 1839,7
CheckBattery = 0
EOF
 
chmod 755 /etc/gammu_smsd_conf
chmod 755 /etc/gammu_smsd_conf /etc/gammurc
 
# Log folder for gammu-smsd
[ -e /var/log/gammu-smsd ] || mkdir /var/log/gammu-smsd
1844,21 → 1849,23
$SED "s/^u_db=\".*/u_db=\"$DB_USER\"/g" $DIR_DEST_BIN/alcasar-sms.sh
$SED "s/^p_db=\".*/p_db=\"$radiuspwd\"/g" $DIR_DEST_BIN/alcasar-sms.sh
 
# Udev rule for Huawei GSM MODEM (idVendor: 12d1) --> run "modeswitch" to switch from "mass_storage" mode to "ttyUSB" (modem) mode
# normally not needed now since modeswitch is managed by udev (see RPM)
# Udev rule for Modeswitch (switch from "mass_storage" mode to "ttyUSB" modem) needed with some Huawei MODEM (idVendor: 12d1)
# normally not needed now since modeswitch is managed by udev (see Mageia RPM)
#cat << EOF > /lib/udev/rules.d/66-huawei.rules
#KERNEL=="ttyUSB0",ATTRS{idVendor}=="12d1",RUN+="$DIR_DEST_BIN/alcasar-sms.sh --mode"
#EOF
 
# Udev rule for fixing the enumeration of ttyUSB port on some MODEM (when they switch randomly the order of their ports at boot time)
# example : http://hintshop.ludvig.co.nz/show/persistent-names-usb-serial-devices/
 
} # End gammu_smsd()
 
 
##################################################################
## Fonction "msec" ##
## - Apply the "fileserver" security level ##
## - remove the "system request" for rebboting ##
## - Fix several file permissions ##
##################################################################
############################################################
## Fonction "msec" ##
## - Apply the "fileserver" security level ##
## - remove the "system request" for rebboting ##
## - Fix several file permissions ##
############################################################
msec()
{
 
1890,9 → 1897,9
 
 
##################################################################
## Fonction "letsencrypt" ##
## - Install Let's Encrypt client ##
## - Prepare Let's Encrypt ALCASAR configuration file ##
## Fonction "letsencrypt" ##
## - Install Let's Encrypt client ##
## - Prepare Let's Encrypt ALCASAR configuration file ##
##################################################################
letsencrypt()
{
1940,13 → 1947,13
} # END letsencrypt()
 
##################################################################
## Fonction "post_install" ##
## - Modifying banners (locals et ssh) & prompts ##
## - SSH config ##
## - sudoers config & files security ##
## - log rotate & ANSSI security parameters ##
## - Apply former conf in case of an update ##
##########################################################
## Fonction "post_install" ##
## - Modifying banners (locals et ssh) & prompts ##
## - SSH config ##
## - sudoers config & files security ##
## - log rotate & ANSSI security parameters ##
## - Apply former conf in case of an update ##
##################################################################
post_install()
{
# change the SSH banner
2145,9 → 2152,9
reboot
} # End post_install ()
 
#################################
# Main Install loop #
#################################
#####################################################################################
# Main Install loop #
#####################################################################################
dir_exec=`dirname "$0"`
if [ $dir_exec != "." ]
then
/web/acc/manager/htdocs/autoregistration.php
2,6 → 2,7
# $Id$
 
#Define
$gammu_wrong_port = "";
$gammu_puk = "";
$gammu_simfail = "";
$gammu_simsecu = "";
14,7 → 15,7
$error_num_alcasar = "";
$country_filter="";
$find_key="false";
$status_key="false";
$listen_on_right_port="false";
$script="/usr/local/bin/alcasar-sms.sh";
 
# Test if a modem is plugged on serial-usb port
22,19 → 23,19
if (!empty($open_port))
{
$find_key="true";
$vendor=exec("udevadm info -n $openned_ports[1] | grep 'MODEL=' | cut -d'=' -f2");
$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
$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";
$listen_on_right_port="true";
}
}
}
$gammu_pid=exec("sudo $script --pidof");
if (( $status_key == "false") || ($find_key == "false"))
if ($find_key == "false")
{ # close gammu if it's started
if ($gammu_pid!="")
{
55,8 → 56,10
$l_title = "Auto enregistrement (SMS)";
$l_conf = "Configuration";
$l_conf_actu = "Configuration actuelle";
$l_pin = "Code PIN";
$l_num_alcasar = "Numero de téléphone du MODEM GSM";
$l_speed = "Vitesse de connexion au MODEM";
$l_connect_port="Port de connexion au MODEM";
$l_pin = "Code PIN de la carte SIM";
$l_num_alcasar = "Numero de téléphone de la carte SIM";
$l_ban_temp = "Nombre d'essais avant le blocage";
$l_time_account = "Durée de validité des comptes crées";
$l_time_perm = "Durée du blocage (en jours)";
64,7 → 67,7
$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>".$vendor."(".$model.")</b>' est connecté à la vitesse de ";
$l_key_enable_1 = "Un MODEM GSM '<b>".$vendor."(".$model.")</b>' est connecté.";
$l_key_enable_2 = "Il a ouvert les ports suivants : ";
$l_force_signal = "Force du signal";
$l_imei_device = "IMEI du périphérique";
73,6 → 76,7
$l_gammu_on="Le service est démarré";
$l_gammu_off="Le service est arrêté";
$l_edit = "Modifier";
$l_error_wrong_port = "Le port d'écoute ($gammu_smsd_port) n'existe pas";
$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";
97,7 → 101,6
$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="Port de connexion";
$l_tab_first = "premier";
$l_tab_last = "dernier";
$l_tab_next = "suivant";
120,8 → 123,10
$l_title = "Auto registration (SMS)";
$l_conf = "Configuration";
$l_conf_actu = "Current configuration";
$l_pin = "PIN password";
$l_num_alcasar = "Phone number of the GSM MODEM";
$l_speed = "Connection speed to the MODEM";
$l_connect_port="Connection port to the MODEM";
$l_pin = "PIN password of the SIM card";
$l_num_alcasar = "Phone number of the SIM card";
$l_ban_temp = "Max number of try before a permanent ban";
$l_time_account = "Validity period of new account";
$l_time_perm = "Duration of a ban (for example, after X try)";
129,7 → 134,7
$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>".$vendor."(".$model.")</b>' is connected at the speed of ";
$l_key_enable_1 = "A GSM MODEM '<b>".$vendor."(".$model.")</b>' is connected.";
$l_key_enable_2 = "It has openned the following ports : ";
$l_force_signal = "Signal strength";
$l_imei_device = "Device IMEI";
138,6 → 143,7
$l_gammu_on="The service is running";
$l_gammu_off="The service is down";
$l_edit = "Modify";
$l_error_wrong_port = "The listening port ($gammu_smsd_port) doesn't exist";
$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";
162,7 → 168,6
$l_service_status_img_ok="Running";
$l_service_status_img_ko="Stopped";
$l_connect_speed="Modify the connection speed : ";
$l_connect_port="Connection port";
$l_tab_first = "first";
$l_tab_last = "last";
$l_tab_next = "next";
239,7 → 244,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(){
271,7 → 276,7
?>
<center>
<br>
<form form="GET" action="./autoregistration.php">
<form method="post" action="./autoregistration.php">
<table border=1 width=100%>
<tr>
<td colspan=2><h3><center><?php echo $l_status_device ?></center></h3></td>
280,168 → 285,7
<?php
if($find_key=="true")
{
if(isset($_GET['config_submit'])){
switch ($_GET['speed']) {
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_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 $row." ";
}
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
{
echo "<td>$l_key_diseable</td>";
}
?>
</tr>
</table>
</form>
</center>
<br>
<?php
 
if ($find_key=="true")
{
#Nom du fichier de log lorsque gammu est démarré
#$file_log = "gammu-smsd.log";
 
#Recuperation du code PIN actuel
$current_pin = exec("sudo $script --pin");
#Recuperation du nombre de try avant le ban perm
$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");
 
#Recuperation de la durée dun ban perm (après flood)
$current_time_perm = exec("sudo $script --time_perm");
 
#Detection neméro de tel
$current_num_alcasar = exec("sudo $script --numero_alcasar");
#Detection problème avec la SIM
$current_simfail = exec("sudo $script --last_nosim");
 
#Recuperation de la dernière ligne de START
$current_last_start = exec("sudo $script --last_start");
 
#Recuperarion de la dernière ligne de STOP
$current_last_stop = exec("sudo $script --last_stop");
 
#Recuperation de la dernière ligne de SECURITYERROR
$current_last_secu = exec("sudo $script --last_secu");
 
#Recuperation de la dernière ligne de DEVICEWRITEERROR
$current_last_write = exec("sudo $script --last_writeerror");
 
#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 = "-";
$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_status_on="";
$gammu_status_off="disabled";
 
if($current_last_secu!="")
{
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>";
}
}
} else {
# Recuperation de la force du signal et IMEI et nombre de sms reçu
$val_force_signal = exec("sudo $script --signal_device");
$imei_device = exec("sudo $script --imei_device");
$sms_received = exec("sudo $script --sms_received");
 
if ($val_force_signal < 21) {
$force_signal = "<img src=\"/images/signal_0.png\"> -- ".$val_force_signal." %";
} elseif ($val_force_signal < 41) {
$force_signal = "<img src=\"/images/signal_20.png\"> -- ".$val_force_signal." %";
 
} elseif ($val_force_signal < 61) {
$force_signal = "<img src=\"/images/signal_40.png\"> -- ".$val_force_signal." %";
 
} elseif ($val_force_signal < 81) {
$force_signal = "<img src=\"/images/signal_60.png\"> -- ".$val_force_signal." %";
 
} elseif ($val_force_signal < 101) {
$force_signal = "<img src=\"/images/signal_80.png\"> -- ".$val_force_signal." %";
 
}
 
$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>";
}
}
if($current_last_secu!="")
{
if(($current_last_secu > $current_last_start) && ($current_last_secu > $current_last_stop))
{
exec("sudo $script --stop");
}
}
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>";
}
}
if($current_simfail!="")
{
if(($current_simfail > $current_last_start) && ($current_simfail > $current_last_stop))
{
$gammu_simfail="<tr><td colspan=7><font color=red>$l_error_simfail</font></td></tr>";
}
}
$gammu_status_on="disabled";
$gammu_status_off="";
}
 
 
#Lancement et arret de gammu-smsd 3*7sec
# Start / stop of gammu-smsd (3*7sec) --> to be improve with systemd unit (see tarball in contrib/init folder)
if(isset($_GET["start"])){
$gammu_1=exec("sudo $script --start");
sleep(7);
471,7 → 315,6
header('Location: autoregistration.php');
exit();
}
 
if(isset($_GET["stop"])){
exec("sudo $script --stop");
sleep(8);
478,9 → 321,28
header('Location: autoregistration.php');
exit();
}
 
 
#Edition du NUMERO de telephone
# Set the speed connexion to MODEM
if(isset($_GET['b_speed'])){
echo "speed = ".$speed;
switch ($_GET['speed']) {
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;
}
//header('Location: autoregistration.php');
//exit();
}
# Set the SIM phone number
if(isset($_GET["b_num_alcasar"])){
$num = $_GET["num_alcasar"];
$error_num_alcasar = "";
503,7 → 365,7
}
}
#Edition du code PIN
# Set the SIM card PIN number
if(isset($_GET["b_pin"])){
$pin = $_GET["pin"];
$error_pin = "";
517,7 → 379,7
}
else
{
$error_pin=$l_error_label_num;
$error_pin=$l_error_label_num;
}
}
else
525,9 → 387,8
$error_pin=$l_error_label_empty;
}
}
#Edition du nombre d'essais avant le ban perm
 
# Set the number of tries before ban
if(isset($_GET["b_ban_temp"])){
$nb_ban_temp = $_GET["nb_essais"];
$error_nb_essais = "";
550,8 → 411,7
}
}
 
 
#Edition de la durée pour un compte créé
# Set the session timeout for each new account
if(isset($_GET["b_time_account"])){
$time_account = $_GET["time_account"];
$error_time_account = "";
574,7 → 434,7
}
}
 
#Edition de la durée d'un ban perm (après flood)
# Set the ban timeout
if(isset($_GET["b_time_perm"])){
$time_perm = $_GET["time_perm"];
$error_time_perm = "";
596,8 → 456,8
$error_time_perm=$l_error_label_empty;
}
}
 
# Suppression d'un numero bloqué
# removing a banned phone number
if(isset($_GET['num_select'])){
$numero=$_GET['num_select'];
 
605,7 → 465,6
if (!empty($add_mac)) {
exec("sudo /usr/sbin/chilli_query logout ".escapeshellarg($add_mac));
}
 
exec("sudo $script --unlock_num $numero");
header('Location: autoregistration.php');
exit();
619,7 → 478,6
header('Location: autoregistration.php');
exit();
}
 
if(isset($_GET['b_france_enable'])){
exec("sudo $script --change_country_dis_all");
exec("sudo $script --change_country France");
627,7 → 485,6
header('Location: autoregistration.php');
exit();
}
 
if(isset($_GET['b_ue_enable'])){
exec("sudo $script --change_country_dis_all");
$array_ue = array("Allemagne","Autriche","Belgique","Bulgarie","Chypre","Croatie","Danemark","Espagne","Estonie","Finlande","France","Grece","Hongrie","Irlande","Italie","Lettonie","Lituanie","Luxembourg","Malte","Pays-Bas"," Pologne","Portugal","Republique Tcheque","Roumanie","Angleterre","Slovaquie","Slovenie","Suede");
639,21 → 496,159
header('Location: autoregistration.php');
exit();
}
 
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();
}
 
if(isset($_GET["b_country_disable"])){
exec("sudo $script --change_country_dis_all");
header('Location: autoregistration.php');
exit();
}
 
echo ' <td>'.$l_key_enable_1;
echo '<br>'.$l_key_enable_2.'<b>';
reset ($openned_ports);
while ( list(,$row) = each($openned_ports))
{
echo $row." ";
}
echo '</b></td>';
}
else
{
echo "<td>$l_key_diseable</td>";
}
?>
</tr>
</table>
</form>
</center>
<br>
<?php
 
if ($find_key=="true")
{
#Nom du fichier de log lorsque gammu est démarré
#$file_log = "gammu-smsd.log";
 
#Recuperation de la vitesse de connexion
$current_speed = exec("sudo $script --connect");
 
#Recuperation du code PIN actuel
$current_pin = exec("sudo $script --pin");
echo "<form action=\"autoregistration.php\" methode=\"GET\">
#Recuperation du nombre de try avant le ban perm
$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");
 
#Recuperation de la durée dun ban perm (après flood)
$current_time_perm = exec("sudo $script --time_perm");
 
#Detection neméro de tel
$current_num_alcasar = exec("sudo $script --numero_alcasar");
#Detection problème avec la SIM
$current_simfail = exec("sudo $script --last_nosim");
 
#Recuperation de la dernière ligne de START
$current_last_start = exec("sudo $script --last_start");
 
#Recuperarion de la dernière ligne de STOP
$current_last_stop = exec("sudo $script --last_stop");
 
#Recuperation de la dernière ligne de SECURITYERROR
$current_last_secu = exec("sudo $script --last_secu");
 
#Recuperation de la dernière ligne de DEVICEWRITEERROR
$current_last_write = exec("sudo $script --last_writeerror");
 
#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 = "-";
$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_status_on="";
$gammu_status_off="disabled";
 
if($current_last_secu!="")
{
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>";
}
}
} else {
# Recuperation de la force du signal et IMEI et nombre de sms reçu
$val_force_signal = exec("sudo $script --signal_device");
$imei_device = exec("sudo $script --imei_device");
$sms_received = exec("sudo $script --sms_received");
 
if ($val_force_signal < 21) {
$force_signal = "<img src=\"/images/signal_0.png\"> -- ".$val_force_signal." %";
} elseif ($val_force_signal < 41) {
$force_signal = "<img src=\"/images/signal_20.png\"> -- ".$val_force_signal." %";
 
} elseif ($val_force_signal < 61) {
$force_signal = "<img src=\"/images/signal_40.png\"> -- ".$val_force_signal." %";
 
} elseif ($val_force_signal < 81) {
$force_signal = "<img src=\"/images/signal_60.png\"> -- ".$val_force_signal." %";
 
} elseif ($val_force_signal < 101) {
$force_signal = "<img src=\"/images/signal_80.png\"> -- ".$val_force_signal." %";
 
}
$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 ($listen_on_right_port != "true"){
$gammu_wrong_port="<tr><td colspan=7><font color=red>$l_error_wrong_port</font></td></tr>";
}
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>";
}
}
if($current_last_secu!="")
{
if(($current_last_secu > $current_last_start) && ($current_last_secu > $current_last_stop))
{
exec("sudo $script --stop");
}
}
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>";
}
}
if($current_simfail!="")
{
if(($current_simfail > $current_last_start) && ($current_simfail > $current_last_stop))
{
$gammu_simfail="<tr><td colspan=7><font color=red>$l_error_simfail</font></td></tr>";
}
}
$gammu_status_on="disabled";
$gammu_status_off="";
}
 
echo "<form action=\"autoregistration.php\" method=\"post\">
<table border=1>
<tr>
<td colspan=3><b>$l_conf</b></td>
660,6 → 655,16
<td><b>$l_conf_actu</b></td>
</tr>
<tr>
<td> $l_speed </td><td>
<select name=\"speed\">
<option value=\"at\">Auto</option>
<option value=\"'9600\">9600 Bauds</option>
<option value=\"19200\">19200 Bauds</option>
<option value=\"'115200\">115200 Bauds</option>
</select>
<td><button type=\"submit\" name=\"b_speed\">$l_edit</button></td>
<td><center><font color=\"green\">".str_replace("at","",$current_speed)." Bauds</font></center></td>
<tr>
<td> $l_connect_port </td><td><select name=\"port\">'";
reset ($openned_ports);
while ( list(,$row) = each($openned_ports))
668,7 → 673,7
echo $row." ";
}
echo "</select></td>
<td><button type=\"submit\" name=\"b_num_alcasar\" $gammu_status_on>$l_edit</button></td>
<td><button type=\"submit\" name=\"b_port\" $gammu_status_on>$l_edit</button></td>
<td><center><font color=\"green\">$gammu_smsd_port</font></center></td>
</tr>
<tr>
685,19 → 690,19
<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>
707,17 → 712,18
<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><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=\"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_wrong_port
$gammu_puk
$gammu_simfail
$gammu_simsecu
773,7 → 779,7
<td colspan="3" align="center"><strong><?php echo $l_country_filter; ?></strong><font size="3" color="red"><?php echo $country_filter; ?></font></td>
</tr>
<tr>
<form action="autoregistration.php" methode="POST">
<form action="autoregistration.php" method="post">
<td align="center" width=33%><button type="submit" name="b_france_enable"><?php echo "$l_country_france_ena" ?></button></td>
<td align="center" width=34%><button type="submit" name="b_ue_enable"><?php echo "$l_country_ue_ena" ?></button></td>
<td align="center" width=33%><button type="submit" name="b_country_enable"><?php echo "$l_country_all_ena" ?></button></td>
799,7 → 805,7
{
echo "
<tr>
<form action=\"autoregistration.php\" methode=\"POST\">
<form action=\"autoregistration.php\" method=\"post\">
<td>
<input type=\"hidden\" name=\"country_select\" value=\"" .$row['name']."\">
".$row['name']."
851,7 → 857,7
{
echo "
<tr>
<form action=\"autoregistration.php\" methode=\"POST\">
<form action=\"autoregistration.php\" method=\"post\">
<td>
<input type=\"hidden\" name=\"num_select\" value=\"" .$row['SenderNumber']."\">
".$row['SenderNumber']."