Is it possible to show the voucher timer as a pop up small window?
-
Hi,
I am thinking, if it is possible to show the voucher timer, I mean the timer of on-use voucher? I wish to see my remaining time floating in a small pop-up box floating below-right corner. I hope it's possible and if so, my another problem is how will I am going to do that.
Any tutorial is very much appreciated.
Nubee
-
I managed to do this by editing captiveportal.inc and uploading a custom captiveportal-logout.php.
I don't like popups so this is a regular page after authentication, here's what it looks like:
-
Hi
I was struggling on the web searching for the above solution. Can anyone please share with me the coding for showing remaining minutes on a mannual logout page. I have a mannual logout which works perfectly when entering 10.10.10.1:8000/ on the browser during login sessions. Please I really want to implement that as my clients are really want to know how much time they have during their logout.
help help pliz
Thank you
-
@dpa:
I managed to do this by editing captiveportal.inc and uploading a custom captiveportal-logout.php.
Looks great, can you post the captiveportal.inc modifications and how to catch the timer in the logout page?
-
@dpa:
I managed to do this by editing captiveportal.inc and uploading a custom captiveportal-logout.php.
I don't like popups so this is a regular page after authentication, here's what it looks like:
can you please teach us how to do that?. pls!
-
This will be really very helpfull for all using the CP function. Thanks in Advance ! :)
-
Inquiring minds want to know ;D
-
Hi Guys, sorry for replying late. Been awhile I have not looked at pf. I applied this to previous versions of pf, but could still work on new ones.
First you need to check the "Enable logout popup window" in the CP settings. Then if you will take a look at captiveportal.inc there's a variable named $remaining_time. You can then create a custom logout.php and use this variable to display the remaining time.
Please take note the included 'captiveportal-vars.php' is a separate php file that contains my own constant variables(ie. $pagetitle). And the function secondsToWords() is probably not mine, I cannot remember if I made this or "borrowed" from someone else, credit goes to whoever made it. But this is not important as you can make your own datetime format.
You might need to edit also the captiveportal.inc to disable the popup logout html and include this custom captiveportal-logout.php. Look for the statement where it checks if "logoutwin_enable" is set.
Below is my captiveportal-logout.php.
Hope it helps. Cheers!
include_once('captiveportal-vars.php');
?>".$pagetitle."");?>
Login Successful! Thank you for using our service.
function secondsToWords($seconds)
{
$ret = "";/*** get the days **/
$days = intval(intval($seconds) / (360024));
if($days> 0)
{
$ret .= "$days days ";
}/*** get the hours ***/
$hours = (intval($seconds) / 3600) % 24;
if($hours > 0)
{
$ret .= "$hours hours ";
}/*** get the minutes ***/
$minutes = (intval($seconds) / 60) % 60;
if($minutes > 0)
{
$ret .= "$minutes minutes ";
}/*** get the seconds ***/
$seconds = intval($seconds) % 60;
if ($seconds > 0) {
$ret .= "$seconds seconds";
}return $ret;
}
?>Remaining Time:
-
Hi dpa & Thanks a lot for this information.
But please please could you show up also your captiveportal-vars.php ? It would be very interesting for the understanding of the code, especially for Newbies like me :)
Thanks for your efforts !
-
Hi Neobauer,
The include php file is simply a collection of variables that I used for the custom captive portal and other files. Below is the general format:
$var1='First variable';
$var2='Second variable';?>
-
Hi dpa,
does it mean that we don't have to include the 'captiveportal-vars.php to let this work ?You mentioned at the beginning that you don't like pop up windows.
May I know/see please how you valide the form in the login page ? meaning target windows ?And last question, can we see the css file just for testing ?
Thanks a lot !
-
Tell me if I have this wrong:
1. Create a script that echoes the "time_remaining" variable
2. Create a custom php/html page for the logout that shows the data from step #1 (Is this the code from above?)
3. Modify captiveportal.inc to disable popup and enable the custom page from step#2 -
1. Create a script that echoes the "time_remaining" variable
2. Create a custom php/html page for the logout that shows the data from step #1 (Is this the code from above?)Are not 1. and 2. the code from above ?
3. Modify captiveportal.inc to disable popup and enable the custom page from step#2
How please ?
A step by step guide will be really very helpful for All. Thanks !
And sorry for my too many questions. I'm not really experienced with PHP Coding. Thanks for understanding. -
I tried running the script but only got a bunch of empty variables showing, along with the little bit of html text. Uncertain as to what the constant variable php is for…?
-
Hi guys,
I'm sorry you're having a hard time figuring this out. And I can't easily remember the step by step procedure how I did it as I already moved to Unifi.
But I guess you can try these steps as a start:
1. Enable logout popup window.
2. Locate the default script for the logout and echo this variable $remaining_time anywhere in the script.See if that outputs the remaining time for that voucher. Post back the result here.
Kind regards,
-
I seem to have got it to work for the most part. I commented out the top part about /include_once('captiveportal-vars.php');/
Then I added a little html code to make the time remaining large (just for testing) and then uploaded to the captive portal "Logout page contents" at the very bottom.Still trying to get the "click to continue" to go to the url we want…
-
Thanks dpa! perpectly working!
1.enable logout popup window on cp
2.create php file, name it captiveportal-vars.php and paste this code inside
```$var1=$pagetitle;
$var2=$seconds;?>
then upload it on your cp file manager. 3.create a html or php file again and name it what ever you want and paste this code inside.
include_once('captiveportal-vars.php');
?>".$pagetitle."");?>
Login Successful! Thank you for using our service.
function secondsToWords($seconds)
{
$ret = "";/*** get the days **/
$days = intval(intval($seconds) / (360024));
if($days> 0)
{
$ret .= "$days days ";
}/*** get the hours ***/
$hours = (intval($seconds) / 3600) % 24;
if($hours > 0)
{
$ret .= "$hours hours ";
}/*** get the minutes ***/
$minutes = (intval($seconds) / 60) % 60;
if($minutes > 0)
{
$ret .= "$minutes minutes ";
}/*** get the seconds ***/
$seconds = intval($seconds) % 60;
if ($seconds > 0) {
$ret .= "$seconds seconds";
}return $ret;
}
?>Remaining Time:
then save and upload it on Logout page contents (buttom part of cp). again thank you dpa!
-
I seem to have got it to work for the most part. I commented out the top part about /include_once('captiveportal-vars.php');/
Then I added a little html code to make the time remaining large (just for testing) and then uploaded to the captive portal "Logout page contents" at the very bottom.Still trying to get the "click to continue" to go to the url we want…
try this instead of href="$redirurl"
[Click to continue](<?=$my_redirurl;?>)
-
Hi!
Glad it worked. But to clarify, this code below can be omitted and is not important.
include_once('captiveportal-vars.php');
?>The only part of this script that the above code is of use is this line:
".$pagetitle."");?>
which can be replaced with a basic html:
<title>Your own page title</title>
And yes probably newer versions of pf uses $my_redirurl instead of $redirurl
Kind regards,
-
Hi All,
Thanks for those updates. I will try it also during the day and provide feedback.
May I know which version of Pfsense you are using ? I'm on 2.1.5.