Script help :(
-
could someone create me a script that would reset the captive portal in 0000hrs.
pseudo
If time >= 12:00AM cp_reboots endIf
objective:
since the captive portal is lacking of feature that would disconnects all users at exactly 00:00hrs, this script will help me to disconnect them at that specific time.
addendum:
captiveportal_configure()
what is that for?, is that the command to reboot/reset the CP?
thanks and more power
-cruzades -
Not the best idea to restart the captive portal - suggest you run a 'prune' of users at a specific time.
-
thank you so much for giving time at my noob queries :)
sir, may you enhance this code
$database = captiveportal_read_db(); $no_users = count($database); for ($i = 0; $i < $no_users; $i++) { if database(?) = expireuseraccount captiveportal_disconnect_client(database(userid)); endif } //do this every 0001hrs //cron
that is more likely I wanted to achieve.
thanks again.
another thing
//erase expired accounts
if (is_array($userdb)) {
$moddb = false;
for ($i = 0; $i < count($userdb); $i++) {
if ($userdb[$i]['expirationdate'] && (strtotime("-1 day") > strtotime($userdb[$i]['expirationdate']))) {
unset($userdb[$i]);
$moddb = true;
captiveportal_disconnect_client($userdb[$i]['userid']);
}
}
if ($moddb)
write_config();$userdb = &$config['captiveportal']['user'];
for ($i = 0; $i < count($userdb); $i++) {
if (($userdb[$i]['name'] == $_POST['auth_user']) && ($userdb[$i]['password'] == md5($_POST['auth_pass']))) {
$loginok = true;
break;
}
}
}notice the red line, is it possible to put that code?
-
@all php coders
please help me with this code, I want to run it at cron so that it would terminate logged-on clients if their accounts is expired at 00:00hrs
radius_database = /sr/local/etc/raddb/users //this is the record of all radius users cp_database = /var/db/captiveporta.db //this is the record of logged-on clients radius_user = count(radius_database) cp_users = count(cp_database) for i = 1 to len(radius_user) if radius_user[i][expiration] = today for ii = 1 to len(cp_users) if radius_user[i][username]=cp_users[ii][username] captiveportal_disconnect_client(cp_users[ii][userid] endif next ii endif next i close databases thanks and more power -cruzades[/i][/i]
-
Suggest you use the script provided in your other post
http://forum.pfsense.org/index.php/topic,27717.0.htmlThat script will achieve your requirements. You may need to just adjust the radius call to use your local radius user file (instead of radius service call)