| Line 93... |
Line 93... |
| 93 |
mysql --user=$u_db --password=$p_db -B -se "$sql_remove_gp"
|
93 |
mysql --user=$u_db --password=$p_db -B -se "$sql_remove_gp"
|
| 94 |
|
94 |
|
| 95 |
# Suppression du compte dans Radcheck
|
95 |
# Suppression du compte dans Radcheck
|
| 96 |
sql_remove_compte="connect radius; DELETE FROM $rad WHERE username='$1';"
|
96 |
sql_remove_compte="connect radius; DELETE FROM $rad WHERE username='$1';"
|
| 97 |
mysql --user=$u_db --password=$p_db -B -se "$sql_remove_compte"
|
97 |
mysql --user=$u_db --password=$p_db -B -se "$sql_remove_compte"
|
| - |
|
98 |
} # end function unlock
|
| - |
|
99 |
|
| - |
|
100 |
function supp_acc_rad() {
|
| - |
|
101 |
# Suppression du compte dans Radcheck
|
| - |
|
102 |
sql_del_compte="connect radius; DELETE FROM $rad WHERE username='$1';"
|
| - |
|
103 |
mysql --user=$u_db --password=$p_db -B -se "$sql_del_compte"
|
| - |
|
104 |
} # end function supp_acc_rad()
|
| - |
|
105 |
|
| - |
|
106 |
function add_acc_rad() {
|
| - |
|
107 |
# Ajout table RadCheck : creation du compte
|
| - |
|
108 |
sql_add_pass="connect radius; INSERT INTO $rad (username,attribute,op,value) VALUES ('$1','Crypt-Password',':=','$2');"
|
| - |
|
109 |
sql_add_expe="connect radius; INSERT INTO $rad (username,attribute,op,value) VALUES ('$1','Expiration',':=','$3');"
|
| 98 |
|
110 |
|
| - |
|
111 |
mysql --user=$u_db --password=$p_db -B -se "$sql_add_pass"
|
| - |
|
112 |
mysql --user=$u_db --password=$p_db -B -se "$sql_add_expe"
|
| - |
|
113 |
|
| - |
|
114 |
# Ajout au groupe sms
|
| - |
|
115 |
sql_add_gp="connect radius; INSERT INTO $radgp (username,groupname) VALUES ('$1','sms');"
|
| - |
|
116 |
mysql --user=$u_db --password=$p_db -B -se "$sql_add_gp"
|
| - |
|
117 |
} # end function add_acc_rad()
|
| 99 |
|
118 |
|
| - |
|
119 |
function supp_num_temp() {
|
| - |
|
120 |
# Suppression du numéro dans table SMS_ban_temp
|
| - |
|
121 |
sql_remove_ban_temp="connect gammu; DELETE FROM $sms_t"
|
| - |
|
122 |
mysql --user=$u_db --password=$p_db -B -se "$sql_remove_ban_temp WHERE SenderNumber=$1;"
|
| - |
|
123 |
} # end function supp_num_temp()
|
| 100 |
|
124 |
|
| - |
|
125 |
function add_num_perm() {
|
| - |
|
126 |
# Ajout du numero table SMS_ban_perm, 0 : creation du compte
|
| - |
|
127 |
sql_add_ban_perm="connect gammu; INSERT INTO $sms_p (SenderNumber,Perm,Expiration) VALUES ('$1',0,'$2');"
|
| - |
|
128 |
mysql --user=$u_db --password=$p_db -B -se "$sql_add_ban_perm"
|
| 101 |
} # end function unlock
|
129 |
} # end function add_num_perm()
|
| - |
|
130 |
|
| - |
|
131 |
function supp_num_perm() {
|
| - |
|
132 |
#Suppression du numero dans la table SMS_ban_perm
|
| - |
|
133 |
sql_remove_ban_perm="connect gammu; DELETE FROM $sms_p"
|
| - |
|
134 |
mysql --user=$u_db --password=$p_db -B -se "$sql_remove_ban_perm WHERE SenderNumber=$1;"
|
| - |
|
135 |
} # end function add_num_perm()
|
| 102 |
|
136 |
|
| 103 |
function new_sms() {
|
137 |
function new_sms() {
|
| 104 |
# Check Inbox table, manage Ban temp and perm, create account
|
138 |
# Check Inbox table, manage Ban temp and perm, create account
|
| 105 |
export salt='$1$passwd$'
|
139 |
export salt='$1$passwd$'
|
| 106 |
|
140 |
|
| Line 113... |
Line 147... |
| 113 |
nb=$(echo $result | wc -w)
|
147 |
nb=$(echo $result | wc -w)
|
| 114 |
|
148 |
|
| 115 |
# On récupère le numéro de l'ID
|
149 |
# On récupère le numéro de l'ID
|
| 116 |
id=$(echo $result | cut -d ' ' -f1)
|
150 |
id=$(echo $result | cut -d ' ' -f1)
|
| 117 |
|
151 |
|
| 118 |
#numero=$(echo $result | cut -d ' ' -f2 | sed -e 's/+33/0/g'/)
|
- |
|
| 119 |
numero=$(echo $result | cut -d ' ' -f2)
|
152 |
numero=$(echo $result | cut -d ' ' -f2)
|
| 120 |
|
153 |
|
| 121 |
if [[ $numero =~ ^\+ ]]
|
154 |
if [[ $numero =~ ^\+ ]]
|
| 122 |
then
|
155 |
then
|
| - |
|
156 |
|
| - |
|
157 |
numero=$(echo $numero | cut -d '+' -f2)
|
| - |
|
158 |
|
| 123 |
# On vérifie que le numéro n'est pas Ban Perm
|
159 |
# On vérifie que le numéro n'est pas Ban Perm
|
| 124 |
sql_ban_perm="connect gammu; SELECT * FROM $sms_p WHERE SenderNumber=$numero"
|
160 |
sql_ban_perm="connect gammu; SELECT * FROM $sms_p WHERE SenderNumber=$numero"
|
| 125 |
result_bp=$(mysql --user=$u_db --password=$p_db -B -se "$sql_ban_perm")
|
161 |
result_bp=$(mysql --user=$u_db --password=$p_db -B -se "$sql_ban_perm")
|
| 126 |
|
162 |
|
| 127 |
if test -z "$result_bp"
|
163 |
if test -z "$result_bp"
|
| Line 139... |
Line 175... |
| 139 |
pass_salt=$(perl -e'print crypt($ARGV[0],$ARGV[1])' $pass $salt)
|
175 |
pass_salt=$(perl -e'print crypt($ARGV[0],$ARGV[1])' $pass $salt)
|
| 140 |
|
176 |
|
| 141 |
export LC_TIME="en_US.UTF-8"
|
177 |
export LC_TIME="en_US.UTF-8"
|
| 142 |
expir=$(date '+%d %B %Y' -d "$time_account days")
|
178 |
expir=$(date '+%d %B %Y' -d "$time_account days")
|
| 143 |
|
179 |
|
| 144 |
# Suppression du compte dans Radcheck
|
180 |
supp_acc_rad "$numero"
|
| 145 |
sql_del_compte="connect radius; DELETE FROM $rad WHERE username='$numero';"
|
- |
|
| 146 |
mysql --user=$u_db --password=$p_db -B -se "$sql_del_compte"
|
- |
|
| 147 |
|
- |
|
| 148 |
# Ajout table RadCheck : creation du compte
|
181 |
add_acc_rad "$numero" "$pass_salt" "$expir"
|
| 149 |
sql_add_pass="connect radius; INSERT INTO $rad (username,attribute,op,value) VALUES ('$numero','Crypt-Password',':=','$pass_salt');"
|
- |
|
| 150 |
sql_add_expe="connect radius; INSERT INTO $rad (username,attribute,op,value) VALUES ('$numero','Expiration',':=','$expir');"
|
- |
|
| 151 |
|
- |
|
| 152 |
mysql --user=$u_db --password=$p_db -B -se "$sql_add_pass"
|
- |
|
| 153 |
mysql --user=$u_db --password=$p_db -B -se "$sql_add_expe"
|
- |
|
| 154 |
|
- |
|
| 155 |
# Ajout au groupe sms
|
182 |
supp_num_temp "$numero"
|
| 156 |
sql_add_gp="connect radius; INSERT INTO $radgp (username,groupname) VALUES ('$numero','sms');"
|
- |
|
| 157 |
mysql --user=$u_db --password=$p_db -B -se "$sql_add_gp"
|
- |
|
| 158 |
|
- |
|
| 159 |
# Suppression du numéro dans table SMS_ban_temp
|
183 |
add_num_perm "$numero" "$expir"
|
| 160 |
sql_remove_ban_temp="connect gammu; DELETE FROM $sms_t"
|
- |
|
| 161 |
mysql --user=$u_db --password=$p_db -B -se "$sql_remove_ban_temp WHERE SenderNumber=$numero;"
|
- |
|
| 162 |
|
- |
|
| 163 |
# Ajout du numero table SMS_ban_perm, 0 : creation du compte
|
- |
|
| 164 |
sql_add_ban_perm="connect gammu; INSERT INTO $sms_p (SenderNumber,Perm,Expiration) VALUES ('$numero',0,'$expir');"
|
- |
|
| 165 |
mysql --user=$u_db --password=$p_db -B -se "$sql_add_ban_perm"
|
- |
|
| 166 |
|
184 |
|
| 167 |
else
|
185 |
else
|
| 168 |
# Autrement, le mot de passe est trop grand ( > un mot )
|
186 |
# Autrement, le mot de passe est trop grand ( > un mot )
|
| 169 |
# On incrémente d'un 1 dans la table des bans temp
|
187 |
# On incrémente d'un 1 dans la table des bans temp
|
| 170 |
sql_add_temp="connect gammu; INSERT INTO $sms_t(SenderNumber) VALUES ('$numero');"
|
188 |
sql_add_temp="connect gammu; INSERT INTO $sms_t(SenderNumber) VALUES ('$numero');"
|
| Line 176... |
Line 194... |
| 176 |
r_select_temp=$(mysql --user=$u_db --password=$p_db -B -se "$sql_select_temp")
|
194 |
r_select_temp=$(mysql --user=$u_db --password=$p_db -B -se "$sql_select_temp")
|
| 177 |
nb_ban_t=$(echo $r_select_temp| wc -w)
|
195 |
nb_ban_t=$(echo $r_select_temp| wc -w)
|
| 178 |
|
196 |
|
| 179 |
if [ $nb_ban_t -ge $nb_essais ]
|
197 |
if [ $nb_ban_t -ge $nb_essais ]
|
| 180 |
then
|
198 |
then
|
| 181 |
# Suppression du numéro dans table SMS_ban_temp
|
199 |
supp_num_temp "$numero"
|
| 182 |
sql_remove_ban_temp="connect gammu; DELETE FROM $sms_t"
|
- |
|
| 183 |
mysql --user=$u_db --password=$p_db -B -se "$sql_remove_ban_temp WHERE SenderNumber=$numero;"
|
- |
|
| 184 |
|
200 |
|
| 185 |
export LC_TIME="en_US.UTF-8"
|
201 |
export LC_TIME="en_US.UTF-8"
|
| 186 |
expir_f=$(date '+%d %B %Y' -d "$time_ban days")
|
202 |
expir_f=$(date '+%d %B %Y' -d "$time_ban days")
|
| 187 |
|
203 |
|
| 188 |
# Ajout du numero table SMS_ban_perm, 1 : flood
|
204 |
# Ajout du numero table SMS_ban_perm, 1 : flood
|
| Line 226... |
Line 242... |
| 226 |
pass_salt=$(perl -e'print crypt($ARGV[0],$ARGV[1])' $pass $salt)
|
242 |
pass_salt=$(perl -e'print crypt($ARGV[0],$ARGV[1])' $pass $salt)
|
| 227 |
|
243 |
|
| 228 |
export LC_TIME="en_US.UTF-8"
|
244 |
export LC_TIME="en_US.UTF-8"
|
| 229 |
expir=$(date '+%d %B %Y' -d "$time_account days")
|
245 |
expir=$(date '+%d %B %Y' -d "$time_account days")
|
| 230 |
|
246 |
|
| 231 |
# Suppression du compte dans Radcheck
|
- |
|
| 232 |
sql_del_compte="connect radius; DELETE FROM $rad WHERE username='$numero';"
|
- |
|
| 233 |
mysql --user=$u_db --password=$p_db -B -se "$sql_del_compte"
|
- |
|
| 234 |
|
- |
|
| 235 |
# Creation du compte
|
- |
|
| 236 |
sql_add_pass="connect radius; INSERT INTO $rad (username,attribute,op,value) VALUES ('$numero','Crypt-Password',':=','$pass_salt');"
|
- |
|
| 237 |
sql_add_expe="connect radius; INSERT INTO $rad (username,attribute,op,value) VALUES ('$numero','Expiration',':=','$expir');"
|
- |
|
| 238 |
|
- |
|
| 239 |
mysql --user=$u_db --password=$p_db -B -se "$sql_add_pass"
|
- |
|
| 240 |
mysql --user=$u_db --password=$p_db -B -se "$sql_add_expe"
|
- |
|
| 241 |
|
- |
|
| 242 |
# Ajout au groupe sms
|
- |
|
| 243 |
sql_add_gp="connect radius; INSERT INTO $radgp (username,groupname) VALUES ('$numero','sms');"
|
- |
|
| 244 |
mysql --user=$u_db --password=$p_db -B -se "$sql_add_gp"
|
- |
|
| 245 |
|
- |
|
| 246 |
|
247 |
|
| 247 |
# Suppression du numéro dans table SMS_ban_temp
|
248 |
supp_acc_rad "$numero"
|
| 248 |
sql_remove_ban_temp="connect gammu; DELETE FROM $sms_t"
|
249 |
add_acc_rad "$numero" "$pass_salt" "$expir"
|
| 249 |
mysql --user=$u_db --password=$p_db -B -se "$sql_remove_ban_temp WHERE SenderNumber=$numero;"
|
- |
|
| 250 |
|
- |
|
| 251 |
#Suppression du numero dans la table SMS_ban_perm
|
250 |
supp_num_temp "$numero"
|
| 252 |
sql_remove_ban_perm="connect gammu; DELETE FROM $sms_p"
|
251 |
supp_num_perm "$numero"
|
| 253 |
mysql --user=$u_db --password=$p_db -B -se "$sql_remove_ban_perm WHERE SenderNumber=$numero;"
|
- |
|
| 254 |
|
- |
|
| 255 |
# Ajout du numero table SMS_ban_perm, 0 : creation du compte
|
252 |
add_num_perm "$numero" "$expir"
|
| 256 |
sql_add_ban_perm="connect gammu; INSERT INTO $sms_p (SenderNumber,Perm,Expiration) VALUES ('$numero',0,'$expir');"
|
- |
|
| 257 |
mysql --user=$u_db --password=$p_db -B -se "$sql_add_ban_perm"
|
- |
|
| 258 |
|
253 |
|
| 259 |
else
|
254 |
else
|
| 260 |
# Autrement, le mot de passe est trop grand ( > un mot )
|
255 |
# Autrement, le mot de passe est trop grand ( > un mot )
|
| 261 |
# On incrémente d'un 1 dans la table des bans temp
|
256 |
# On incrémente d'un 1 dans la table des bans temp
|
| 262 |
sql_add_temp="connect gammu; INSERT INTO $sms_t(SenderNumber) VALUES ('$numero');"
|
257 |
sql_add_temp="connect gammu; INSERT INTO $sms_t(SenderNumber) VALUES ('$numero');"
|
| Line 270... |
Line 265... |
| 270 |
nb_ban_t=$(echo $r_select_temp| wc -w)
|
265 |
nb_ban_t=$(echo $r_select_temp| wc -w)
|
| 271 |
|
266 |
|
| 272 |
if [ $nb_ban_t -ge $nb_essais ]
|
267 |
if [ $nb_ban_t -ge $nb_essais ]
|
| 273 |
then
|
268 |
then
|
| 274 |
|
269 |
|
| 275 |
echo "Trop de ban temporaire"
|
270 |
supp_num_perm "$numero"
|
| 276 |
|
- |
|
| 277 |
#Suppression du numero dans la table SMS_ban_perm
|
271 |
supp_num_temp "$numero"
|
| 278 |
sql_remove_ban_perm="connect gammu; DELETE FROM $sms_p"
|
- |
|
| 279 |
mysql --user=$u_db --password=$p_db -B -se "$sql_remove_ban_perm WHERE SenderNumber=$numero;"
|
- |
|
| 280 |
|
- |
|
| 281 |
# Suppression du numéro dans table SMS_ban_temp
|
- |
|
| 282 |
sql_remove_ban_temp="connect gammu; DELETE FROM $sms_t"
|
- |
|
| 283 |
mysql --user=$u_db --password=$p_db -B -se "$sql_remove_ban_temp WHERE SenderNumber=$numero;"
|
- |
|
| 284 |
|
272 |
|
| 285 |
export LC_TIME="en_US.UTF-8"
|
273 |
export LC_TIME="en_US.UTF-8"
|
| 286 |
expir_f=$(date '+%d %B %Y' -d "$time_ban days")
|
274 |
expir_f=$(date '+%d %B %Y' -d "$time_ban days")
|
| 287 |
|
275 |
|
| 288 |
# Ajout du numero table SMS_ban_perm, 1 : flood
|
276 |
# Ajout du numero table SMS_ban_perm, 1 : flood
|
| Line 349... |
Line 337... |
| 349 |
--last_puk)
|
337 |
--last_puk)
|
| 350 |
# Récupère la dernière ligne où PUK est présent (error)
|
338 |
# Récupère la dernière ligne où PUK est présent (error)
|
| 351 |
cat $logfile | grep -n "UNKNOWN" | cut -d ':' -f1 | tail -n 1
|
339 |
cat $logfile | grep -n "UNKNOWN" | cut -d ':' -f1 | tail -n 1
|
| 352 |
exit 0
|
340 |
exit 0
|
| 353 |
;;
|
341 |
;;
|
| 354 |
--log)
|
342 |
#--log)
|
| 355 |
# Récupère le nom du fichier de log
|
343 |
# # Récupère le nom du fichier de log
|
| 356 |
cat $config | grep logfile | cut -d ' ' -f3
|
344 |
# cat $config | grep logfile | cut -d ' ' -f3
|
| 357 |
exit 0
|
345 |
# exit 0
|
| 358 |
;;
|
346 |
# ;;
|
| 359 |
--connect)
|
347 |
--connect)
|
| 360 |
# Récupère la vitesse de co
|
348 |
# Récupère la vitesse de co
|
| 361 |
cat $config | grep connection | cut -d ' ' -f3
|
349 |
cat $config | grep connection | cut -d ' ' -f3
|
| 362 |
exit 0
|
350 |
exit 0
|
| 363 |
;;
|
351 |
;;
|