Upcoming Maintenance Alert:

The UBNT Community will be upgraded at 5pm MDT on April 25th. During this time the community forums will be set to read-only status.

Learn more

×
Reply
Highlighted
Regular Member
Posts: 320
Registered: ‎05-09-2012
Kudos: 102
Solutions: 6
Accepted Solution

Simple External Portal in PHP

Hey all,

 

I've put together a simple package for an external portal server written in PHP.  The package by itself (when the unifi IP, username and password are changed) will authorize a user for 12 hours.

 

PLEASE NOTE: You WILL NEEDto change the unifi IP, the unifi Username and unifi Password, in order for the script to function.  It will not function AS IS. 

 

Modify the script at your own will.  Of course I can help along the way but only to a certain extent.  We all need to practice some integrity in our own work Man Wink.

Attachment

Accepted Solutions
Ubiquiti Employee
Posts: 10,991
Registered: ‎02-10-2014
Kudos: 3239
Solutions: 877
Contributions: 17

Re: Simple External Portal in PHP


klinutzu wrote:

GOT THE ANSWER!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

 

external portal doesn't work in controller 4.2.0, therefore you must revert to 3.2.5...

 

thanks matt for this answer....


For clarification, it's the portal talking back to the controller that doesn't work in 4.2.0.  They're already working on the bug fix and that should be expected in the coming weeks.


Many Questions are Answered in the KnowledgeBase
Don't forget to kudo helpful posts and mark threads as solved
Forum Rules

View solution in original post


All Replies
Emerging Member
Posts: 63
Registered: ‎01-10-2013
Kudos: 5

Re: Simple External Portal in PHP

how hard would it be to add the ability to add user sign up to this code? 

Get real-time information about customers. Track new / return visits, identify peak visit times and create a customer mailing list.

Seamless software integration with the UniFi Cloud Controller for guest authentication and customer analytics (no flashing required) Check it out
Deleted Account
Posts: 0

Re: Simple External Portal in PHP

with some php skills pretty easy.

 

u need it urgently? i look what i can write up the next days.

 

cheers

Emerging Member
Posts: 63
Registered: ‎01-10-2013
Kudos: 5

Re: Simple External Portal in PHP

Something ive needed for ages... I have my own database and hosting just cant put the two and two together. Would be a massive help. 

 

 

Get real-time information about customers. Track new / return visits, identify peak visit times and create a customer mailing list.

Seamless software integration with the UniFi Cloud Controller for guest authentication and customer analytics (no flashing required) Check it out
Emerging Member
Posts: 45
Registered: ‎05-18-2012
Kudos: 5

Re: Simple External Portal in PHP

me too, i've been waiting for somebody to share code that can be modify to create my own portal ( with looks and identity), in doesn't matter if it is unifi portal or an external portal. thanks

Emerging Member
Posts: 54
Registered: ‎03-17-2013
Kudos: 1
Solutions: 1

Re: Simple External Portal in PHP


JMichieli wrote:

Hey all,

 

I've put together a simple package for an external portal server written in PHP.  The package by itself (when the unifi IP, username and password are changed) will authorize a user for 12 hours.

 

PLEASE NOTE: You WILL NEEDto change the unifi IP, the unifi Username and unifi Password, in order for the script to function.  It will not function AS IS. 

 

Modify the script at your own will.  Of course I can help along the way but only to a certain extent.  We all need to practice some integrity in our own work Man Wink.


Can i use the url that you have created with curl and use it in another file like .exe file on windows ?

Regular Member
Posts: 320
Registered: ‎05-09-2012
Kudos: 102
Solutions: 6

Re: Simple External Portal in PHP

[ Edited ]

n3m0 wrote:

Can i use the url that you have created with curl and use it in another file like .exe file on windows ?

 

Sure, why not?  It is a simple http request that is being sent.  You can use this in any application / programming language that has the capability of sending http requests.

Emerging Member
Posts: 40
Registered: ‎02-19-2012
Kudos: 2

Re: Simple External Portal in PHP

[ Edited ]

I used your simple php code and for some reason host refused connection...My controller is at https://ec2-xxxxxxxxxxx.compute-1.amazonaws.com:8443/

 

Everything else works as it should just wondering why the host refuses connection....any ideas?

 

I made sure I changed the user name and password  ip address to reflect my own controllers information. 

 

I look forward to any ideas to resolve this issue I am experiencing

Regular Member
Posts: 320
Registered: ‎05-09-2012
Kudos: 102
Solutions: 6

Re: Simple External Portal in PHP

[ Edited ]

If your external portal server is located on a different IP than that of your controller, please ensure that both your controller's IP and the external portal IP are located in the Allowed Subnets boxes within Settings -> Guest Control.

 

To add a single IP to the allowed subnets, add the shorthand subnet mask /32 to the end of the IP.  For example, an IP of 192.168.1.13 would become 192.168.1.13/32 in the allowed subnets boxes.

Emerging Member
Posts: 40
Registered: ‎02-19-2012
Kudos: 2

Re: Simple External Portal in PHP

Thank you very much for the reply however I did already have the cloud controllers IP address in the allowed subnet. Let me know if there is any other information you need or would like me to verify

 

again I appreciate the reply!!

Regular Member
Posts: 320
Registered: ‎05-09-2012
Kudos: 102
Solutions: 6

Re: Simple External Portal in PHP

If your host is refusing the connection it means that the server you are using to host the external portal on is not accepting the connection on the port you are redirecting to (which is port 80). If you do have a web server setup on port 80 on your external portal server, ensure that any firewalls between the portal server and the internet allow incoming connections on port 80 to that server.
Emerging Member
Posts: 40
Registered: ‎02-19-2012
Kudos: 2

Re: Simple External Portal in PHP

Thanks!!

 

I looked into the webserver and you were correct that port 80 was not allowed so I opened this port. I had it closed before because my unifi controller is at port 8443 which was open on the webserver. However the same result. The connect button comes up, I click connect then it looks like its trying to do somehting then after about a minute goes back to the connect page.

 

 

Emerging Member
Posts: 40
Registered: ‎02-19-2012
Kudos: 2

Re: Simple External Portal in PHP

I was going through your simple code and re-read the requirements of having curl enabled...can you tell me how to confirm I have this enabled?

 

Thanks!!

Regular Member
Posts: 320
Registered: ‎05-09-2012
Kudos: 102
Solutions: 6

Re: Simple External Portal in PHP

Create a new php file and use php_info(); to see your PHP configuration:

 

<?php
php_info();
?>

 Open the new page in a web browser and it will tell you all modules that you have enabled (along with the rest of the configuration).  Just do a search for curl, if it doesn't show up, it's not enabled.

Emerging Member
Posts: 40
Registered: ‎02-19-2012
Kudos: 2

Re: Simple External Portal in PHP

ok Curl is enabled however still not authorizing... any other things to try? I would be more then happy to provide any access or code requested in a PM

 

Thanks!!

Emerging Member
Posts: 40
Registered: ‎02-19-2012
Kudos: 2

Re: Simple External Portal in PHP

I made it a step closer...I am able to get to google.com however it does not show authorized in the controller. If I try to leave google.com it won't go....just stays on google the search doesn't function either so I am not truley on the Internet...getting thereMan Happy

Emerging Member
Posts: 56
Registered: ‎01-28-2013
Kudos: 22

Re: Simple External Portal in PHP

Will this need much updating to support v3 controller (hosted in cloud) when it is no longer beta?

New Member
Posts: 35
Registered: ‎07-23-2012
Kudos: 1

Re: Simple External Portal in PHP

Has anyone had any luck getting this to work for Apple products?  In my tests, they get stuck in the captive portal login.

Established Member
Posts: 2,482
Registered: ‎01-05-2010
Kudos: 224
Solutions: 2

Re: Simple External Portal in PHP

Is there anyway just add username and password without having simple check mark agreeing to the terms of service?

New Member
Posts: 15
Registered: ‎03-19-2014

Re: Simple External Portal in PHP

Hi there!

Such a great work you've done!

Congratulations and thanks a lot for helping us!

Have some questions for you:

 

What IP address should I use for curl?

Let me try to explain a little better:

First, I'm not using PHP curl. Instead, I'm using shell_exec() executing the native curl of my OS hosting the external portal. Indeed, I'm trying this http://www.ubnt.com/downloads/unifi/2.2.0/portal_sample.zip

When I start the UniFi controler in my Windows machine, a web browser opens with the IP https://192.168.150.72

However, the UniFi itself is using a static IP 192.168.150.91

Then, If I set this IP address 192.168.150.91 in my shell script (guest_authorize.sh), nothing happens. However, if I use 192.168.150.72 then the user is authorized and navigation occurs normaly.

What should I do then? Is there a way to use the real IP of the UniFi?

Thanks a lot for any help.

You guys rock!

Reply