Skip to content

Commit

Permalink
Clean up code and fix PHP scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
Carlgo11 committed Aug 3, 2020
1 parent e3cae4c commit e600d3c
Show file tree
Hide file tree
Showing 50 changed files with 656 additions and 441 deletions.
4 changes: 4 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
.git
.github
.idea
vendor
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
img/bg.*
Gemfile.lock
composer.lock
_api/composer.lock
vendor/
.bundle
_site
Expand Down
67 changes: 67 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
FROM alpine

###
# Jekyll
###

# Install Jekyll dependencies
RUN apk add --no-cache build-base libxml2-dev libxslt-dev ruby-full ruby-dev gcc linux-headers

# Copy Jekyll files
RUN adduser -D -u 1000 -h /tmp/www www
COPY --chown=www:www jekyll /tmp/jekyll
WORKDIR /tmp/jekyll

USER www

# Install gems
RUN bundle config build.nokogiri --use-system-libraries
RUN bundle config set path 'vendor/bundle'
RUN bundle install

# Build site
RUN bundle exec jekyll build

USER root
RUN mv _site /opt/www/

# Remove Jekyll dependencies
RUN apk del build-base libxml2-dev libxslt-dev ruby-full ruby-dev gcc linux-headers

###
# PHP
###

# Install PHP dependencies
RUN apk add --no-cache php-fpm php-curl php-json php-session composer

# Set up PHP-FPM
COPY php-install.sh /
RUN chmod +x /php-install.sh; /bin/sh /php-install.sh; rm /php-install.sh

# Copy PHP files
COPY ./php /opt/php
WORKDIR /opt/php

# Install libraries
RUN composer install --no-dev

RUN apk del composer

###
# Nginx
###

# Install Nginx
RUN apk add --no-cache nginx

# Copy Nginx virtual server config
COPY ./nginx.conf /etc/nginx/conf.d/default.conf

# Bug fixes
RUN mkdir /run/nginx
RUN sed -i 's/cgi.fix_pathinfo= 0/cgi.fix_pathinfo=1/g' /etc/php7/php.ini
ONBUILD RUN chown www:www /opt/www/ -R

EXPOSE 80
CMD php-fpm7 && nginx; tail -F /var/log/nginx/error.log
6 changes: 0 additions & 6 deletions Gemfile

This file was deleted.

26 changes: 24 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,28 @@
# Unify Guest Portal
# UniFi Guest Portal

## Usage

```BASH
docker run -p 80:80 carlgo11/guest-portal
```

Optionally, add some background images:

```BASH
docker run -p 80:80 -v $(pwd)/bg.webp:/opt/www/img/bg.webp -v $(pwd)/bg.jpg:/opt/www/img/bg.jpg carlgo11/guest-portal
```

## Environment variables

|Name|Default|Description|Example|
|----|-------|-----------|-------|
|UNIFI_USER| |UniFi Hotspot username|api
|UNIFI_PASSWORD| |UniFi Hotspot password|password
|UNIFI_URL| |UniFi Controller IP/URL & port|https://192.168.1.2:8443
|UNIFI_SITE|default|UniFi Site|default
|UNIFI_VERSION| |Controller version|5.13.32

## License

This work is licensed under the Creative Commons Attribution 4.0 International License.
To view a copy of this license, visit [LICENSE](LICENSE).
To view a copy of this license, visit [LICENSE](LICENSE).
44 changes: 0 additions & 44 deletions _api/submit.php

This file was deleted.

3 changes: 3 additions & 0 deletions jekyll/Gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
source 'https://rubygems.org'

gem 'jekyll'
16 changes: 8 additions & 8 deletions _config.yml → jekyll/_config.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
theme: null
exclude:
- vendor/bundle
- vendor/cache
- .bundle
- .gitignore
- composer.json
- Gemfile
theme: null
exclude:
- vendor/bundle
- vendor/cache
- .bundle
- .gitignore
- composer.json
- Gemfile
- README.md
20 changes: 10 additions & 10 deletions _includes/approval.html → jekyll/_includes/approval.html
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
<!-- Awaiting approval -->
<div id="approval" class="view">
<div class="spinner">
<div class="spinner-grow spinner-grow-lg text-success" role="status">
<span class="sr-only">Loading...</span>
</div>
</div>
<div class="btn-back noselect"><i class="fas fa-chevron-left "></i> Back</div>
<h2 class="noselect">Waiting for
approval...</h2>
<!-- Awaiting approval -->
<div id="approval" class="view">
<div class="spinner">
<div class="spinner-grow spinner-grow-lg text-success" role="status">
<span class="sr-only">Loading...</span>
</div>
</div>
<div class="btn-back noselect"><i class="fas fa-chevron-left "></i> Back</div>
<h2 class="noselect">Waiting for
approval...</h2>
</div>
14 changes: 7 additions & 7 deletions _includes/error.html → jekyll/_includes/error.html
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<!-- Error -->
<div id="error" class="view">
<div class="btn-back noselect"><i class="fas fa-chevron-left "></i> Back</div>
<div id="error-container">
<h1><i class="far fa-frown text-danger noselect"></i></h1>
<h2 id="error-msg">Error:</h2>
</div>
<!-- Error -->
<div id="error" class="view">
<div class="btn-back noselect"><i class="fas fa-chevron-left "></i> Back</div>
<div id="error-container">
<h1><i class="far fa-frown text-danger noselect"></i></h1>
<h2 id="error-msg">Error:</h2>
</div>
</div>
36 changes: 18 additions & 18 deletions _includes/form.html → jekyll/_includes/form.html
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
<!-- Form -->
<div id="form" class="view">
<form method="POST" action="/submit.php">
<h1 class="title noselect">Guest Wifi</h1>
<div class="input-group">
<input class="form-control" type="text" placeholder="Enter your login code" pattern="^\d{5}(?:-)?\d{5}$"
autocomplete="one-time-code" autofocus="" autocapitalize="off" spellcheck="false" inputmode="numeric"
required="" id="otp" maxlength="11" name="code">

<span class="input-group-btn">
<button type="submit" class="btn btn-success ">Connect <i class="fas fa-chevron-right"></i></button>
</span>
</div>

<div class="separator noselect">or</div>
<button type="button" class="btn btn-danger form-control" id="manual"><i class="fas fa-comment"></i> Manual
approval</button>
</form>
<!-- Form -->
<div id="form" class="view">
<form method="POST" action="/api/submit.php">
<h1 class="title noselect">Guest Wifi</h1>
<div class="input-group">
<input class="form-control" type="text" placeholder="Enter your login code" pattern="^\d{5}(?:-)?\d{5}$"
autocomplete="one-time-code" autofocus="" autocapitalize="off" spellcheck="false" inputmode="numeric"
required="" id="otp" maxlength="11" name="code">

<span class="input-group-btn">
<button type="submit" class="btn btn-success ">Connect <i class="fas fa-chevron-right"></i></button>
</span>
</div>

<div class="separator noselect">or</div>
<button type="button" class="btn btn-danger form-control" id="manual"><i class="fas fa-comment"></i> Manual
approval</button>
</form>
</div>
16 changes: 8 additions & 8 deletions _includes/loading.html → jekyll/_includes/loading.html
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<!-- Loading -->
<div id="loading" class="view">
<h1>Communicating with network...</h1>
<div>
<div class="spinner-grow text-success" role="status">
<span class="sr-only">Loading...</span>
</div>
</div>
<!-- Loading -->
<div id="loading" class="view">
<h1>Communicating with network...</h1>
<div>
<div class="spinner-grow text-success" role="status">
<span class="sr-only">Loading...</span>
</div>
</div>
</div>
6 changes: 3 additions & 3 deletions _includes/success.html → jekyll/_includes/success.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<!-- Success -->
<div id="success" class="view">
<h1>Welcome! 😄</h1>
<!-- Success -->
<div id="success" class="view">
<h1>Welcome! 😄</h1>
</div>
50 changes: 25 additions & 25 deletions _layouts/default.html → jekyll/_layouts/default.html
Original file line number Diff line number Diff line change
@@ -1,26 +1,26 @@
<html lang="en-us">

<head>
<meta name="viewport" content="width=device-width initial-scale=1">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Guest WiFi</title>
<link rel="icon" href="/img/favicon.svg" type="image/x-icon" />
<link rel="icon" href="/img/favicon.png" type="image/png" />
<link rel="apple-touch-icon" href="/img/apple-touch-icon.png" sizes="256x256" />
<link rel="stylesheet" href="/css/bootstrap.min.css" />
<link rel="stylesheet" href="/css/main.css" />
<link rel="stylesheet" href="/css/all.min.css" />
</head>

<body>
<div class="container">
{{ content }}
</div>
<script src="/js/jquery.min.js"></script>
<script src="/js/jquery-ui.min.js"></script>
<script src="/js/modenizr-webp.min.js"></script>
{% if page.name == 'index.html' %}<script src="/js/main.js"></script>{% endif %}
{% if page.name == 'admin.html' %}<script src="/js/admin.js"></script>{% endif %}
</body>

<html lang="en-us">

<head>
<meta name="viewport" content="width=device-width initial-scale=1">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Guest WiFi</title>
<link rel="icon" href="/img/favicon.svg" type="image/x-icon" />
<link rel="icon" href="/img/favicon.png" type="image/png" />
<link rel="apple-touch-icon" href="/img/apple-touch-icon.png" sizes="256x256" />
<link rel="stylesheet" href="/css/bootstrap.min.css" />
<link rel="stylesheet" href="/css/main.css" />
<link rel="stylesheet" href="/css/all.min.css" />
</head>

<body>
<div class="container">
{{ content }}
</div>
<script src="/js/jquery.min.js"></script>
<script src="/js/jquery-ui.min.js"></script>
<script src="/js/modenizr-webp.min.js"></script>
{% if page.name == 'index.html' %}<script src="/js/main.js"></script>{% endif %}
{% if page.name == 'admin.html' %}<script src="/js/admin.js"></script>{% endif %}
</body>

</html>
File renamed without changes.
File renamed without changes.
File renamed without changes.
Loading

0 comments on commit e600d3c

Please sign in to comment.