diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index fe205c7..a4f0225 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -57,4 +57,6 @@ jobs: tg_dir: environments/dev tg_command: 'apply' + - name: Copy build to s3 + run: aws s3 sync frontend/build s3://stumblefunk-www-dev/accreditation \ No newline at end of file diff --git a/.gitignore b/.gitignore index 8ea5772..c9592d4 100644 --- a/.gitignore +++ b/.gitignore @@ -2,6 +2,7 @@ *.tgz .*.sw? .idea +.env terragrunt.iml vendor .terraform diff --git a/frontend/public/config.js b/frontend/public/config.js new file mode 100644 index 0000000..72a1774 --- /dev/null +++ b/frontend/public/config.js @@ -0,0 +1,3 @@ +var config = { + apiUrl: "https://nf2c6o0vt2.execute-api.eu-west-1.amazonaws.com/dev" +} \ No newline at end of file diff --git a/frontend/public/index.html b/frontend/public/index.html index 65795c8..b52aa6e 100644 --- a/frontend/public/index.html +++ b/frontend/public/index.html @@ -4,6 +4,7 @@ + Stumblefunk - Accreditation diff --git a/frontend/src/AdminView.js b/frontend/src/AdminView.js index 1bf6a2e..66892d6 100644 --- a/frontend/src/AdminView.js +++ b/frontend/src/AdminView.js @@ -1,6 +1,5 @@ import React, { useState, useEffect } from 'react'; import { Link, useNavigate } from 'react-router-dom'; -import config from './config'; const AdminView = ({ groupCode, onUpdateLogin }) => { const [groups, setGroups] = useState([]); @@ -9,7 +8,7 @@ const AdminView = ({ groupCode, onUpdateLogin }) => { useEffect(() => { const fetchData = async () => { try { - const response = await fetch(`${config.apiUrl}/groups`, { + const response = await fetch(`${window.config.apiUrl}/groups`, { headers: { 'Authorization': groupCode, 'Content-Type': 'application/json', @@ -28,7 +27,7 @@ const AdminView = ({ groupCode, onUpdateLogin }) => { const handleNew = async () => { try { - const response = await fetch(`${config.apiUrl}/group`, { + const response = await fetch(`${window.config.apiUrl}/group`, { method: 'POST', headers: { 'Authorization': groupCode, @@ -51,7 +50,7 @@ const AdminView = ({ groupCode, onUpdateLogin }) => { const handleDelete = async (groupId) => { if (window.confirm('This will remove the group and any tickets that have been created by the group! Are you sure?')) { try { - const response = await fetch(`${config.apiUrl}/group?group_id=${groupId}`, { + const response = await fetch(`${window.config.apiUrl}/group?group_id=${groupId}`, { method: 'DELETE', headers: { 'Authorization': groupCode, diff --git a/frontend/src/GroupEdit.js b/frontend/src/GroupEdit.js index b528b85..f7089e7 100644 --- a/frontend/src/GroupEdit.js +++ b/frontend/src/GroupEdit.js @@ -1,7 +1,6 @@ import React, { useState, useEffect } from 'react'; import { useParams } from 'react-router-dom'; import { useNavigate } from 'react-router-dom'; -import config from './config'; const GroupEdit = (groupCode) => { const navigate = useNavigate(); @@ -19,7 +18,7 @@ const GroupEdit = (groupCode) => { useEffect(() => { const fetchData = async () => { try { - const response = await fetch(`${config.apiUrl}/group?group_id=${group_id}`, { + const response = await fetch(`${window.config.apiUrl}/group?group_id=${group_id}`, { headers: { 'Authorization': group_id, }, @@ -45,7 +44,7 @@ const GroupEdit = (groupCode) => { const handleSubmit = async (e) => { e.preventDefault(); try { - const response = await fetch(`${config.apiUrl}/group`, { + const response = await fetch(`${window.config.apiUrl}/group`, { method: 'PATCH', headers: { 'Authorization': groupCode.groupCode, diff --git a/frontend/src/ListTickets.js b/frontend/src/ListTickets.js index 36e7817..2c709ec 100644 --- a/frontend/src/ListTickets.js +++ b/frontend/src/ListTickets.js @@ -1,5 +1,4 @@ import React, { useState, useEffect } from 'react'; -import config from './config'; const ListTickets = ({ groupCode, ticketType }) => { const [groups, setGroups] = useState([]); @@ -10,7 +9,7 @@ const ListTickets = ({ groupCode, ticketType }) => { useEffect(() => { const fetchGroupsData = async () => { try { - const response = await fetch(`${config.apiUrl}/groups`, { + const response = await fetch(`${window.config.apiUrl}/groups`, { headers: { 'Authorization': groupCode, }, @@ -34,7 +33,7 @@ const ListTickets = ({ groupCode, ticketType }) => { const fetchDataForGroups = async () => { for (const group of groups) { try { - const ticketsResponse = await fetch(`${config.apiUrl}/tickets?group_id=${group.group_id}`, { + const ticketsResponse = await fetch(`${window.config.apiUrl}/tickets?group_id=${group.group_id}`, { headers: { 'Authorization': groupCode, }, diff --git a/frontend/src/Login.js b/frontend/src/Login.js index d76d440..8bd3421 100644 --- a/frontend/src/Login.js +++ b/frontend/src/Login.js @@ -1,5 +1,4 @@ import React, { useState, useEffect } from 'react'; -import config from './config'; import { useNavigate } from 'react-router-dom'; @@ -17,7 +16,7 @@ const Login = ({ onLogin }) => { const handleLoginApi = async () => { try { - const response = await fetch(`${config.apiUrl}/login`, { + const response = await fetch(`${window.config.apiUrl}/login`, { method: 'POST', headers: { 'Content-Type': 'application/json', diff --git a/frontend/src/TicketAdult.js b/frontend/src/TicketAdult.js index 918cec7..66bc7ad 100644 --- a/frontend/src/TicketAdult.js +++ b/frontend/src/TicketAdult.js @@ -1,6 +1,5 @@ import React, { useState } from 'react'; import { useNavigate } from 'react-router-dom'; -import config from './config'; const TicketAdult = ({ groupCode }) => { const navigate = useNavigate(); @@ -16,7 +15,7 @@ const TicketAdult = ({ groupCode }) => { event.preventDefault(); try { - const response = await fetch(`${config.apiUrl}/ticket`, { + const response = await fetch(`${window.config.apiUrl}/ticket`, { method: 'POST', headers: { 'Content-Type': 'application/json', diff --git a/frontend/src/TicketChild.js b/frontend/src/TicketChild.js index 2595d6b..7c11db8 100644 --- a/frontend/src/TicketChild.js +++ b/frontend/src/TicketChild.js @@ -1,6 +1,5 @@ import React, { useState, useEffect } from 'react'; import { useNavigate } from 'react-router-dom'; -import config from './config'; const TicketChild = ({ groupCode }) => { const navigate = useNavigate(); @@ -21,7 +20,7 @@ const TicketChild = ({ groupCode }) => { event.preventDefault(); try { - const response = await fetch(`${config.apiUrl}/ticket`, { + const response = await fetch(`${window.config.apiUrl}/ticket`, { method: 'POST', headers: { 'Content-Type': 'application/json', @@ -52,7 +51,7 @@ const TicketChild = ({ groupCode }) => { const fetchParentData = async () => { try { - const response = await fetch(`${config.apiUrl}/tickets?group_id=${groupCode}`, { + const response = await fetch(`${window.config.apiUrl}/tickets?group_id=${groupCode}`, { headers: { 'Authorization': groupCode, }, diff --git a/frontend/src/TicketVehicle.js b/frontend/src/TicketVehicle.js index a9d7c8a..78274fb 100644 --- a/frontend/src/TicketVehicle.js +++ b/frontend/src/TicketVehicle.js @@ -1,6 +1,5 @@ import React, { useState, useEffect } from 'react'; import { useNavigate } from 'react-router-dom'; -import config from './config'; const TicketVehicle = ({ groupCode }) => { const navigate = useNavigate(); @@ -19,7 +18,7 @@ const TicketVehicle = ({ groupCode }) => { event.preventDefault(); try { - const response = await fetch(`${config.apiUrl}/ticket`, { + const response = await fetch(`${window.config.apiUrl}/ticket`, { method: 'POST', headers: { 'Content-Type': 'application/json', @@ -50,7 +49,7 @@ const TicketVehicle = ({ groupCode }) => { const fetchDriverData = async () => { try { - const response = await fetch(`${config.apiUrl}/tickets?group_id=${groupCode}`, { + const response = await fetch(`${window.config.apiUrl}/tickets?group_id=${groupCode}`, { headers: { 'Authorization': groupCode, }, diff --git a/frontend/src/Totals.js b/frontend/src/Totals.js index 28da3a4..4750711 100644 --- a/frontend/src/Totals.js +++ b/frontend/src/Totals.js @@ -1,5 +1,4 @@ import React, { useState, useEffect } from 'react'; -import config from './config'; const Totals = ({ groupCode }) => { const [totalsData, setTotalsData] = useState({}); @@ -7,7 +6,7 @@ const Totals = ({ groupCode }) => { useEffect(() => { const fetchTotalsData = async () => { try { - const response = await fetch(`${config.apiUrl}/groups?`, { + const response = await fetch(`${window.config.apiUrl}/groups?`, { headers: { 'Authorization': groupCode, }, diff --git a/frontend/src/UserView.js b/frontend/src/UserView.js index 1e87ae7..b6c0c9b 100644 --- a/frontend/src/UserView.js +++ b/frontend/src/UserView.js @@ -1,6 +1,5 @@ import React, { useState, useEffect } from 'react'; import { Link } from 'react-router-dom'; -import config from './config'; const UserView = ({ groupCode }) => { const [groupInfo, setGroupInfo] = useState({ @@ -22,7 +21,7 @@ const UserView = ({ groupCode }) => { const fetchData = async () => { try { // Make API call to fetch ticket data - const ticketResponse = await fetch(`${config.apiUrl}/tickets?group_id=${groupCode}`, { + const ticketResponse = await fetch(`${window.config.apiUrl}/tickets?group_id=${groupCode}`, { headers: { 'Authorization': groupCode, }, @@ -31,7 +30,7 @@ const UserView = ({ groupCode }) => { setTickets(ticketData); // Make additional API call to fetch group info - const groupResponse = await fetch(`${config.apiUrl}/group?group_id=${groupCode}`, { + const groupResponse = await fetch(`${window.config.apiUrl}/group?group_id=${groupCode}`, { headers: { 'Authorization': groupCode, }, @@ -52,7 +51,7 @@ const UserView = ({ groupCode }) => { const handleRemoveTicket = async (ticketId) => { try { - const response = await fetch(`${config.apiUrl}/ticket?ticket_id=${ticketId}`, { + const response = await fetch(`$window.config.apiUrl}/ticket?ticket_id=${ticketId}`, { method: 'DELETE', headers: { 'Authorization': groupCode, diff --git a/frontend/src/config.js b/frontend/src/config.js index 0904fdc..91f6dce 100644 --- a/frontend/src/config.js +++ b/frontend/src/config.js @@ -1,5 +1,12 @@ -const config = { - apiUrl: 'https://nf2c6o0vt2.execute-api.eu-west-1.amazonaws.com/dev', - }; - - export default config; \ No newline at end of file +async function config() { + try { + const response = await fetch('config.json'); + const config = await response.json(); + return config; + } catch (error) { + console.error('Error fetching config:', error); + throw error; + } +} + +export default config; \ No newline at end of file diff --git a/frontend/src/index.js b/frontend/src/index.js index ce12270..24e480b 100644 --- a/frontend/src/index.js +++ b/frontend/src/index.js @@ -6,7 +6,7 @@ import 'bootstrap/dist/css/bootstrap.css'; import 'bootstrap/dist/js/bootstrap.bundle.min'; import 'font-awesome/css/font-awesome.min.css'; -import './index.css'; +import './index.css' const root = ReactDOM.createRoot(document.getElementById('root')); root.render( diff --git a/old/Dockerfile b/old/Dockerfile deleted file mode 100644 index 43b6680..0000000 --- a/old/Dockerfile +++ /dev/null @@ -1,6 +0,0 @@ -FROM php:7.2-apache - -RUN docker-php-ext-install pdo_mysql && apt-get update && apt-get install -y mysql-client && rm -rf /var/lib/apt - -COPY src/ /var/www/html/ - diff --git a/old/README.md b/old/README.md deleted file mode 100644 index a4c0ff0..0000000 --- a/old/README.md +++ /dev/null @@ -1,15 +0,0 @@ -# stumblefunk-accreditation - -### PHP application for managing ticket allocations - -##### We get allocated x tickets when we run a venue/stage at a festival, this app helps us mange our allocation and also collects the details for each ticketholder that we need - -* Docker container takes 4x evironment variables for MySQL config: `DB_HOST`, `DB_NAME`, `DB_USER` & `DB_PASS` - -* Admin login is via `DB_PASS` - -* Admin users can create 'groups', each group has a quota of adults/kids/vehicles assigned - Group has a unqiue access code generated - -* Admin users can see overall ticket consumption, and lists of allocated tickets and vehicle passes - -* When group user logs in with their details, they are able to assign contact details to each of their allocated tickets and vehicle passes \ No newline at end of file diff --git a/old/helm/.helmignore b/old/helm/.helmignore deleted file mode 100644 index 50af031..0000000 --- a/old/helm/.helmignore +++ /dev/null @@ -1,22 +0,0 @@ -# Patterns to ignore when building packages. -# This supports shell glob matching, relative path matching, and -# negation (prefixed with !). Only one pattern per line. -.DS_Store -# Common VCS dirs -.git/ -.gitignore -.bzr/ -.bzrignore -.hg/ -.hgignore -.svn/ -# Common backup files -*.swp -*.bak -*.tmp -*~ -# Various IDEs -.project -.idea/ -*.tmproj -.vscode/ diff --git a/old/helm/.sops.yaml b/old/helm/.sops.yaml deleted file mode 100644 index a30e51c..0000000 --- a/old/helm/.sops.yaml +++ /dev/null @@ -1,2 +0,0 @@ -creation_rules: - - pgp: 'C850D2D8D0CCAFC15B6DD4894D26191663D05BEE' diff --git a/old/helm/Chart.yaml b/old/helm/Chart.yaml deleted file mode 100644 index 7a52953..0000000 --- a/old/helm/Chart.yaml +++ /dev/null @@ -1,5 +0,0 @@ -apiVersion: v1 -appVersion: "1.0" -description: A Helm chart for Kubernetes -name: stumblefunk-accreditation -version: 0.1.0 diff --git a/old/helm/requirements.lock b/old/helm/requirements.lock deleted file mode 100644 index 01d40e1..0000000 --- a/old/helm/requirements.lock +++ /dev/null @@ -1,6 +0,0 @@ -dependencies: -- name: mysql - repository: https://kubernetes-charts.storage.googleapis.com - version: 0.11.0 -digest: sha256:a0b063d7f663ef6bf979a868d3b271e0a10dff88ae02e721dc5bf72f0accea4a -generated: 2019-02-14T12:35:25.906739673Z diff --git a/old/helm/requirements.yaml b/old/helm/requirements.yaml deleted file mode 100644 index a1a90f1..0000000 --- a/old/helm/requirements.yaml +++ /dev/null @@ -1,4 +0,0 @@ -dependencies: -- name: mysql - repository: https://kubernetes-charts.storage.googleapis.com - version: 0.11.0 diff --git a/old/helm/secrets.yaml b/old/helm/secrets.yaml deleted file mode 100644 index d068fb9..0000000 --- a/old/helm/secrets.yaml +++ /dev/null @@ -1,33 +0,0 @@ -env: - DB_HOST: ENC[AES256_GCM,data:w+JWVlIpNUJWh9+8+n8WNOD3IqokQmpYNgS8FKfWdw==,iv:rXlBOcSLa14vlgFzSUuBVR40if+wNZcKZaR3tO22DHU=,tag:7a8Mhs3tC93wLMpguceAwA==,type:str] - DB_NAME: ENC[AES256_GCM,data:fNmCvzq3i1ZBevY=,iv:2XSi2UkbxFwVQVeNWSv6kuz3FWWOdvkKOzp8mt9pqMU=,tag:Lh+9hU1aT75Trg+vfecPzA==,type:str] - DB_USER: ENC[AES256_GCM,data:5NJlgg==,iv:A+xhQCL5moLGqHz9tkhBWkkU2Unx1OIEhC01dHQ5bgI=,tag:BU2cRrlIGieBv7oeBszIBw==,type:str] - DB_PASS: ENC[AES256_GCM,data:R2UvJ885/w2knII=,iv:lvdRBNS4HGyhrcxXZ20afDNWaWHn9DxT2XiR72gJrFY=,tag:MNaPA5cXaQUmw/wVklohJQ==,type:str] -mysql: - mysqlRootPassword: ENC[AES256_GCM,data:1ub7/iVfdYxvi4k=,iv:aIQaCo/49gATE/sizS3uNeVhaa+f2UTxaeyDBLwkBQ0=,tag:Vr14Za+1A5Y+N5GZmeLX1g==,type:str] -sops: - kms: [] - gcp_kms: [] - lastmodified: '2019-02-14T13:14:55Z' - mac: ENC[AES256_GCM,data:e+nVCjE63PgxtyqoLV6dVwp0PaxJ9z5AKfo3ak715M5CxnfbESlLq50dm5hsmKO7FcqJ7E6tWtbLuIkLy1wo+K70cJGuse13/E2Ul/73NEtnAzG8g4Yp/TpP140vN5+k24yFHAoQZccFL1pXdhf8l+H4ewXH7hrQpeZOl5cM6IE=,iv:0x2nvTSEqv6Yr55MqWCsVn9LP0zJ8RxBILI+aJUIhiM=,tag:59l08IweSRkF3h5xlBGIdg==,type:str] - pgp: - - created_at: '2019-02-13T18:42:55Z' - enc: | - -----BEGIN PGP MESSAGE----- - - hQGMA2c8WqZTjOTFAQv8DuOCJguQVFpbXqpLt6fpJ1v/VKiX0x30fJw/W54unY48 - amDQC4MA90j1R/UjOYAUfeLxRs6Drj/Vy/L8Guxh0vqAhORfhJdJuuo3lsp6wLtF - S+JwbN9LlZq9XVWkXtoQ3YmaKglykaE12TKMM5qw+IEjW+fBTpZQi2wl6Akhd8ea - VwCFwLNY14/kVQ+H4hrMNQ1P9jKru6ubvZOB9e/n5HxZwAtluYsm83pgvzYuU97t - K/OYLputlkNKIy9/9/mTvpEuXqC4mC01oh+383l5CQi/vdWYs1iX/k+awsu+B9dF - 4bmN/mVoNQ1lj7Q8X70tZbkXP8aHuUCAnOVDCjvo+OrK+Z+KiQQ4NuNtC2sajDJG - TjlG/lCI+srdCPXEZ50YsrsXYPdwCXxG6IA4pHaTBtsX8hkmprtOxsqTHwHJRs+n - m1mbki4FfZC8bbZmntAnPaR8Qdll9FLa4+PzFMMQCcJEFk6U0mbzO1B+559JM2LU - B318hSQ/9Ha3nD5dY6UH0l4BtE/BkIjyoS6QQ71yFEe8vTW5zALq+X6rARTUJ0lz - th/ULA/R7WWMJehSteizNE2GuUfxhETu+Gil20wE2clq6+1e01yzM7KUexnwZ+et - 8Otex7pxM0/FtivGmjSL - =FnI3 - -----END PGP MESSAGE----- - fp: C850D2D8D0CCAFC15B6DD4894D26191663D05BEE - unencrypted_suffix: _unencrypted - version: 3.0.3 diff --git a/old/helm/templates/NOTES.txt b/old/helm/templates/NOTES.txt deleted file mode 100644 index b0ca449..0000000 --- a/old/helm/templates/NOTES.txt +++ /dev/null @@ -1,21 +0,0 @@ -1. Get the application URL by running these commands: -{{- if .Values.ingress.enabled }} -{{- range $host := .Values.ingress.hosts }} - {{- range $.Values.ingress.paths }} - http{{ if $.Values.ingress.tls }}s{{ end }}://{{ $host }}{{ . }} - {{- end }} -{{- end }} -{{- else if contains "NodePort" .Values.service.type }} - export NODE_PORT=$(kubectl get --namespace {{ .Release.Namespace }} -o jsonpath="{.spec.ports[0].nodePort}" services {{ include "stumblefunk-accreditation.fullname" . }}) - export NODE_IP=$(kubectl get nodes --namespace {{ .Release.Namespace }} -o jsonpath="{.items[0].status.addresses[0].address}") - echo http://$NODE_IP:$NODE_PORT -{{- else if contains "LoadBalancer" .Values.service.type }} - NOTE: It may take a few minutes for the LoadBalancer IP to be available. - You can watch the status of by running 'kubectl get svc -w {{ include "stumblefunk-accreditation.fullname" . }}' - export SERVICE_IP=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ include "stumblefunk-accreditation.fullname" . }} -o jsonpath='{.status.loadBalancer.ingress[0].ip}') - echo http://$SERVICE_IP:{{ .Values.service.port }} -{{- else if contains "ClusterIP" .Values.service.type }} - export POD_NAME=$(kubectl get pods --namespace {{ .Release.Namespace }} -l "app.kubernetes.io/name={{ include "stumblefunk-accreditation.name" . }},app.kubernetes.io/instance={{ .Release.Name }}" -o jsonpath="{.items[0].metadata.name}") - echo "Visit http://127.0.0.1:8080 to use your application" - kubectl port-forward $POD_NAME 8080:80 -{{- end }} diff --git a/old/helm/templates/_helpers.tpl b/old/helm/templates/_helpers.tpl deleted file mode 100644 index 9377765..0000000 --- a/old/helm/templates/_helpers.tpl +++ /dev/null @@ -1,32 +0,0 @@ -{{/* vim: set filetype=mustache: */}} -{{/* -Expand the name of the chart. -*/}} -{{- define "stumblefunk-accreditation.name" -}} -{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" -}} -{{- end -}} - -{{/* -Create a default fully qualified app name. -We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec). -If release name contains chart name it will be used as a full name. -*/}} -{{- define "stumblefunk-accreditation.fullname" -}} -{{- if .Values.fullnameOverride -}} -{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" -}} -{{- else -}} -{{- $name := default .Chart.Name .Values.nameOverride -}} -{{- if contains $name .Release.Name -}} -{{- .Release.Name | trunc 63 | trimSuffix "-" -}} -{{- else -}} -{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" -}} -{{- end -}} -{{- end -}} -{{- end -}} - -{{/* -Create chart name and version as used by the chart label. -*/}} -{{- define "stumblefunk-accreditation.chart" -}} -{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" -}} -{{- end -}} diff --git a/old/helm/templates/deployment.yaml b/old/helm/templates/deployment.yaml deleted file mode 100644 index 55df760..0000000 --- a/old/helm/templates/deployment.yaml +++ /dev/null @@ -1,72 +0,0 @@ -apiVersion: apps/v1 -kind: Deployment -metadata: - name: {{ include "stumblefunk-accreditation.fullname" . }} - labels: - app.kubernetes.io/name: {{ include "stumblefunk-accreditation.name" . }} - helm.sh/chart: {{ include "stumblefunk-accreditation.chart" . }} - app.kubernetes.io/instance: {{ .Release.Name }} - app.kubernetes.io/managed-by: {{ .Release.Service }} -spec: - replicas: {{ .Values.replicaCount }} - selector: - matchLabels: - app.kubernetes.io/name: {{ include "stumblefunk-accreditation.name" . }} - app.kubernetes.io/instance: {{ .Release.Name }} - template: - metadata: - labels: - app.kubernetes.io/name: {{ include "stumblefunk-accreditation.name" . }} - app.kubernetes.io/instance: {{ .Release.Name }} - spec: - containers: - - name: {{ .Chart.Name }} - image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}" - imagePullPolicy: {{ .Values.image.pullPolicy }} - env: - - name: DB_NAME - valueFrom: - secretKeyRef: - name: {{ include "stumblefunk-accreditation.fullname" . }}-db - key: DB_NAME - - name: DB_HOST - valueFrom: - secretKeyRef: - name: {{ include "stumblefunk-accreditation.fullname" . }}-db - key: DB_HOST - - name: DB_USER - valueFrom: - secretKeyRef: - name: {{ include "stumblefunk-accreditation.fullname" . }}-db - key: DB_USER - - name: DB_PASS - valueFrom: - secretKeyRef: - name: {{ include "stumblefunk-accreditation.fullname" . }}-db - key: DB_PASS - ports: - - name: http - containerPort: 80 - protocol: TCP - livenessProbe: - httpGet: - path: /health.php - port: http - readinessProbe: - httpGet: - path: /health.php - port: http - resources: - {{- toYaml .Values.resources | nindent 12 }} - {{- with .Values.nodeSelector }} - nodeSelector: - {{- toYaml . | nindent 8 }} - {{- end }} - {{- with .Values.affinity }} - affinity: - {{- toYaml . | nindent 8 }} - {{- end }} - {{- with .Values.tolerations }} - tolerations: - {{- toYaml . | nindent 8 }} - {{- end }} diff --git a/old/helm/templates/ingress.yaml b/old/helm/templates/ingress.yaml deleted file mode 100644 index 2a9a20c..0000000 --- a/old/helm/templates/ingress.yaml +++ /dev/null @@ -1,40 +0,0 @@ -{{- if .Values.ingress.enabled -}} -{{- $fullName := include "stumblefunk-accreditation.fullname" . -}} -{{- $ingressPaths := .Values.ingress.paths -}} -apiVersion: extensions/v1beta1 -kind: Ingress -metadata: - name: {{ $fullName }} - labels: - app.kubernetes.io/name: {{ include "stumblefunk-accreditation.name" . }} - helm.sh/chart: {{ include "stumblefunk-accreditation.chart" . }} - app.kubernetes.io/instance: {{ .Release.Name }} - app.kubernetes.io/managed-by: {{ .Release.Service }} - {{- with .Values.ingress.annotations }} - annotations: - {{- toYaml . | nindent 4 }} - {{- end }} -spec: -{{- if .Values.ingress.tls }} - tls: - {{- range .Values.ingress.tls }} - - hosts: - {{- range .hosts }} - - {{ . | quote }} - {{- end }} - secretName: {{ .secretName }} - {{- end }} -{{- end }} - rules: - {{- range .Values.ingress.hosts }} - - host: {{ . | quote }} - http: - paths: - {{- range $ingressPaths }} - - path: {{ . }} - backend: - serviceName: {{ $fullName }} - servicePort: http - {{- end }} - {{- end }} -{{- end }} diff --git a/old/helm/templates/secrets.yaml b/old/helm/templates/secrets.yaml deleted file mode 100644 index fbd8271..0000000 --- a/old/helm/templates/secrets.yaml +++ /dev/null @@ -1,15 +0,0 @@ -apiVersion: v1 -kind: Secret -metadata: - name: {{ include "stumblefunk-accreditation.fullname" . }}-db - labels: - app: {{ include "stumblefunk-accreditation.fullname" . }} - chart: "{{ .Chart.Name }}-{{ .Chart.Version }}" - release: "{{ .Release.Name }}" - heritage: "{{ .Release.Service }}" -type: Opaque -data: - DB_NAME: {{ .Values.env.DB_NAME | b64enc | quote }} - DB_HOST: {{ .Values.env.DB_HOST | b64enc | quote }} - DB_USER: {{ .Values.env.DB_USER | b64enc | quote }} - DB_PASS: {{ .Values.env.DB_PASS | b64enc | quote }} diff --git a/old/helm/templates/service.yaml b/old/helm/templates/service.yaml deleted file mode 100644 index c282e1f..0000000 --- a/old/helm/templates/service.yaml +++ /dev/null @@ -1,19 +0,0 @@ -apiVersion: v1 -kind: Service -metadata: - name: {{ include "stumblefunk-accreditation.fullname" . }} - labels: - app.kubernetes.io/name: {{ include "stumblefunk-accreditation.name" . }} - helm.sh/chart: {{ include "stumblefunk-accreditation.chart" . }} - app.kubernetes.io/instance: {{ .Release.Name }} - app.kubernetes.io/managed-by: {{ .Release.Service }} -spec: - type: {{ .Values.service.type }} - ports: - - port: {{ .Values.service.port }} - targetPort: http - protocol: TCP - name: http - selector: - app.kubernetes.io/name: {{ include "stumblefunk-accreditation.name" . }} - app.kubernetes.io/instance: {{ .Release.Name }} diff --git a/old/helm/templates/tests/test-connection.yaml b/old/helm/templates/tests/test-connection.yaml deleted file mode 100644 index d43b0f2..0000000 --- a/old/helm/templates/tests/test-connection.yaml +++ /dev/null @@ -1,18 +0,0 @@ -apiVersion: v1 -kind: Pod -metadata: - name: "{{ include "stumblefunk-accreditation.fullname" . }}-test-connection" - labels: - app.kubernetes.io/name: {{ include "stumblefunk-accreditation.name" . }} - helm.sh/chart: {{ include "stumblefunk-accreditation.chart" . }} - app.kubernetes.io/instance: {{ .Release.Name }} - app.kubernetes.io/managed-by: {{ .Release.Service }} - annotations: - "helm.sh/hook": test-success -spec: - containers: - - name: wget - image: busybox - command: ['wget'] - args: ['{{ include "stumblefunk-accreditation.fullname" . }}:{{ .Values.service.port }}'] - restartPolicy: Never diff --git a/old/helm/values.yaml b/old/helm/values.yaml deleted file mode 100644 index f57243f..0000000 --- a/old/helm/values.yaml +++ /dev/null @@ -1,43 +0,0 @@ -replicaCount: 1 - -image: - repository: stumblefunk-accreditation - tag: latest - pullPolicy: IfNotPresent - -nameOverride: "" -fullnameOverride: "" - -service: - type: ClusterIP - port: 80 - -mysql: - enabled: true - persistence: - enabled: true - storageClass: manual - subPath: stumblefunk-accreditation-mysql - mysqlDatabase: stumblefunk - configurationFiles: - mysql.cnf: |- - [mysqld] - skip-host-cache - skip-name-resolve - initializationFiles: - stumblefunk-groups.sql: |- - USE stumblefunk; CREATE TABLE groups (`id` INT NOT NULL AUTO_INCREMENT PRIMARY KEY, group_name varchar(255), kids int(5), adults int(5), vehicles int(5), last_action datetime, guid varchar(25))ENGINE=innodb; - stumblefunk-tickets.sql: |- - USE stumblefunk; CREATE TABLE tickets (`id` INT NOT NULL AUTO_INCREMENT PRIMARY KEY, guid varchar(25), ticket_type varchar(255), first_name varchar(255), last_name varchar(255), email varchar(255), mobile varchar(255), vehicle_reg varchar(255), vehicle_pass varchar(255), last_action datetime) ENGINE=innodb; - stumblefunk-sessions.sql: |- - USE stumblefunk; CREATE TABLE sessions (`id` varchar(32) NOT NULL, access int(10) unsigned, data text, PRIMARY KEY (id)); - -ingress: - enabled: true - annotations: - nginx.ingress.kubernetes.io/rewrite-target: / - paths: - - / - hosts: - - stumblefunk-accreditation.k8s.squiggle.org - tls: [] diff --git a/old/src/Medoo.php b/old/src/Medoo.php deleted file mode 100644 index 0213f1b..0000000 --- a/old/src/Medoo.php +++ /dev/null @@ -1,1547 +0,0 @@ -type = strtolower($options[ 'database_type' ]); - } - - if (isset($options[ 'prefix' ])) - { - $this->prefix = $options[ 'prefix' ]; - } - - if (isset($options[ 'option' ])) - { - $this->option = $options[ 'option' ]; - } - - if (isset($options[ 'logging' ]) && is_bool($options[ 'logging' ])) - { - $this->logging = $options[ 'logging' ]; - } - - if (isset($options[ 'command' ]) && is_array($options[ 'command' ])) - { - $commands = $options[ 'command' ]; - } - else - { - $commands = []; - } - - if (isset($options[ 'dsn' ])) - { - if (is_array($options[ 'dsn' ]) && isset($options[ 'dsn' ][ 'driver' ])) - { - $attr = $options[ 'dsn' ]; - } - else - { - return false; - } - } - else - { - if ( - isset($options[ 'port' ]) && - is_int($options[ 'port' ] * 1) - ) - { - $port = $options[ 'port' ]; - } - - $is_port = isset($port); - - switch ($this->type) - { - case 'mariadb': - case 'mysql': - $attr = [ - 'driver' => 'mysql', - 'dbname' => $options[ 'database_name' ] - ]; - - if (isset($options[ 'socket' ])) - { - $attr[ 'unix_socket' ] = $options[ 'socket' ]; - } - else - { - $attr[ 'host' ] = $options[ 'server' ]; - - if ($is_port) - { - $attr[ 'port' ] = $port; - } - } - - // Make MySQL using standard quoted identifier - $commands[] = 'SET SQL_MODE=ANSI_QUOTES'; - break; - - case 'pgsql': - $attr = [ - 'driver' => 'pgsql', - 'host' => $options[ 'server' ], - 'dbname' => $options[ 'database_name' ] - ]; - - if ($is_port) - { - $attr[ 'port' ] = $port; - } - - break; - - case 'sybase': - $attr = [ - 'driver' => 'dblib', - 'host' => $options[ 'server' ], - 'dbname' => $options[ 'database_name' ] - ]; - - if ($is_port) - { - $attr[ 'port' ] = $port; - } - - break; - - case 'oracle': - $attr = [ - 'driver' => 'oci', - 'dbname' => $options[ 'server' ] ? - '//' . $options[ 'server' ] . ($is_port ? ':' . $port : ':1521') . '/' . $options[ 'database_name' ] : - $options[ 'database_name' ] - ]; - - if (isset($options[ 'charset' ])) - { - $attr[ 'charset' ] = $options[ 'charset' ]; - } - - break; - - case 'mssql': - if (isset($options[ 'driver' ]) && $options[ 'driver' ] === 'dblib') - { - $attr = [ - 'driver' => 'dblib', - 'host' => $options[ 'server' ] . ($is_port ? ':' . $port : ''), - 'dbname' => $options[ 'database_name' ] - ]; - } - else - { - $attr = [ - 'driver' => 'sqlsrv', - 'Server' => $options[ 'server' ] . ($is_port ? ',' . $port : ''), - 'Database' => $options[ 'database_name' ] - ]; - } - - // Keep MSSQL QUOTED_IDENTIFIER is ON for standard quoting - $commands[] = 'SET QUOTED_IDENTIFIER ON'; - - // Make ANSI_NULLS is ON for NULL value - $commands[] = 'SET ANSI_NULLS ON'; - break; - - case 'sqlite': - $attr = [ - 'driver' => 'sqlite', - $options[ 'database_file' ] - ]; - - break; - } - } - - $driver = $attr[ 'driver' ]; - - unset($attr[ 'driver' ]); - - $stack = []; - - foreach ($attr as $key => $value) - { - $stack[] = is_int($key) ? $value : $key . '=' . $value; - } - - $dsn = $driver . ':' . implode($stack, ';'); - - if ( - in_array($this->type, ['mariadb', 'mysql', 'pgsql', 'sybase', 'mssql']) && - isset($options[ 'charset' ]) - ) - { - $commands[] = "SET NAMES '" . $options[ 'charset' ] . "'"; - } - - try { - $this->pdo = new PDO( - $dsn, - isset($options[ 'username' ]) ? $options[ 'username' ] : null, - isset($options[ 'password' ]) ? $options[ 'password' ] : null, - $this->option - ); - - foreach ($commands as $value) - { - $this->pdo->exec($value); - } - } - catch (PDOException $e) { - throw new PDOException($e->getMessage()); - } - } - - public function __call($name, $arguments) - { - $aggregation = ['avg', 'count', 'max', 'min', 'sum']; - - if (in_array($name, $aggregation)) - { - array_unshift($arguments, $name); - - return call_user_func_array([$this, 'aggregate'], $arguments); - } - } - - public function query($query, $map = []) - { - $raw = $this->raw($query, $map); - - $query = $this->buildRaw($raw, $map); - - return $this->exec($query, $map); - } - - public function exec($query, $map = []) - { - if ($this->debug_mode) - { - echo $this->generate($query, $map); - - $this->debug_mode = false; - - return false; - } - - if ($this->logging) - { - $this->logs[] = [$query, $map]; - } - else - { - $this->logs = [[$query, $map]]; - } - - $statement = $this->pdo->prepare($query); - - if ($statement) - { - foreach ($map as $key => $value) - { - $statement->bindValue($key, $value[ 0 ], $value[ 1 ]); - } - - $statement->execute(); - - $this->statement = $statement; - - return $statement; - } - - return false; - } - - protected function generate($query, $map) - { - $identifier = [ - 'mysql' => '`$1`', - 'mariadb' => '`$1`', - 'mssql' => '[$1]' - ]; - - $query = preg_replace( - '/"([a-zA-Z0-9_]+)"/i', - isset($identifier[ $this->type ]) ? $identifier[ $this->type ] : '"$1"', - $query - ); - - foreach ($map as $key => $value) - { - if ($value[ 1 ] === PDO::PARAM_STR) - { - $replace = $this->quote($value[ 0 ]); - } - elseif ($value[ 1 ] === PDO::PARAM_NULL) - { - $replace = 'NULL'; - } - elseif ($value[ 1 ] === PDO::PARAM_LOB) - { - $replace = '{LOB_DATA}'; - } - else - { - $replace = $value[ 0 ]; - } - - $query = str_replace($key, $replace, $query); - } - - return $query; - } - - public static function raw($string, $map = []) - { - $raw = new Raw(); - - $raw->map = $map; - $raw->value = $string; - - return $raw; - } - - protected function isRaw($object) - { - return $object instanceof Raw; - } - - protected function buildRaw($raw, &$map) - { - if (!$this->isRaw($raw)) - { - return false; - } - - $query = preg_replace_callback( - '/((FROM|TABLE|INTO|UPDATE)\s*)?\<([a-zA-Z0-9_\.]+)\>/i', - function ($matches) - { - if (!empty($matches[ 2 ])) - { - return $matches[ 2 ] . ' ' . $this->tableQuote($matches[ 3 ]); - } - - return $this->columnQuote($matches[ 3 ]); - }, - $raw->value); - - $raw_map = $raw->map; - - if (!empty($raw_map)) - { - foreach ($raw_map as $key => $value) - { - $raw_map[ $key ] = $this->typeMap($value, gettype($value)); - } - - $map = $raw_map; - } - - return $query; - } - - public function quote($string) - { - return $this->pdo->quote($string); - } - - protected function tableQuote($table) - { - return '"' . $this->prefix . $table . '"'; - } - - protected function mapKey() - { - return ':MeDoO_' . $this->guid++ . '_mEdOo'; - } - - protected function typeMap($value, $type) - { - $map = [ - 'NULL' => PDO::PARAM_NULL, - 'integer' => PDO::PARAM_INT, - 'double' => PDO::PARAM_STR, - 'boolean' => PDO::PARAM_BOOL, - 'string' => PDO::PARAM_STR, - 'object' => PDO::PARAM_STR, - 'resource' => PDO::PARAM_LOB - ]; - - if ($type === 'boolean') - { - $value = ($value ? '1' : '0'); - } - elseif ($type === 'NULL') - { - $value = null; - } - - return [$value, $map[ $type ]]; - } - - protected function columnQuote($string) - { - if (strpos($string, '.') !== false) - { - return '"' . $this->prefix . str_replace('.', '"."', $string) . '"'; - } - - return '"' . $string . '"'; - } - - protected function columnPush(&$columns, &$map) - { - if ($columns === '*') - { - return $columns; - } - - $stack = []; - - if (is_string($columns)) - { - $columns = [$columns]; - } - - foreach ($columns as $key => $value) - { - if (is_array($value)) - { - $stack[] = $this->columnPush($value, $map); - } - elseif (!is_int($key) && $raw = $this->buildRaw($value, $map)) - { - preg_match('/(?[a-zA-Z0-9_\.]+)(\s*\[(?(String|Bool|Int|Number))\])?/i', $key, $match); - - $stack[] = $raw . ' AS ' . $this->columnQuote( $match[ 'column' ] ); - } - elseif (is_int($key) && is_string($value)) - { - preg_match('/(?[a-zA-Z0-9_\.]+)(?:\s*\((?[a-zA-Z0-9_]+)\))?(?:\s*\[(?(?:String|Bool|Int|Number|Object|JSON))\])?/i', $value, $match); - - if (!empty($match[ 'alias' ])) - { - $stack[] = $this->columnQuote( $match[ 'column' ] ) . ' AS ' . $this->columnQuote( $match[ 'alias' ] ); - - $columns[ $key ] = $match[ 'alias' ]; - - if (!empty($match[ 'type' ])) - { - $columns[ $key ] .= ' [' . $match[ 'type' ] . ']'; - } - } - else - { - $stack[] = $this->columnQuote( $match[ 'column' ] ); - } - } - } - - return implode($stack, ','); - } - - protected function arrayQuote($array) - { - $stack = []; - - foreach ($array as $value) - { - $stack[] = is_int($value) ? $value : $this->pdo->quote($value); - } - - return implode($stack, ','); - } - - protected function innerConjunct($data, $map, $conjunctor, $outer_conjunctor) - { - $stack = []; - - foreach ($data as $value) - { - $stack[] = '(' . $this->dataImplode($value, $map, $conjunctor) . ')'; - } - - return implode($outer_conjunctor . ' ', $stack); - } - - protected function dataImplode($data, &$map, $conjunctor) - { - $stack = []; - - foreach ($data as $key => $value) - { - $type = gettype($value); - - if ( - $type === 'array' && - preg_match("/^(AND|OR)(\s+#.*)?$/", $key, $relation_match) - ) - { - $relationship = $relation_match[ 1 ]; - - $stack[] = $value !== array_keys(array_keys($value)) ? - '(' . $this->dataImplode($value, $map, ' ' . $relationship) . ')' : - '(' . $this->innerConjunct($value, $map, ' ' . $relationship, $conjunctor) . ')'; - - continue; - } - - $map_key = $this->mapKey(); - - if ( - is_int($key) && - preg_match('/([a-zA-Z0-9_\.]+)\[(?\>\=?|\<\=?|\!|\=)\]([a-zA-Z0-9_\.]+)/i', $value, $match) - ) - { - $stack[] = $this->columnQuote($match[ 1 ]) . ' ' . $match[ 'operator' ] . ' ' . $this->columnQuote($match[ 3 ]); - } - else - { - preg_match('/([a-zA-Z0-9_\.]+)(\[(?\>\=?|\<\=?|\!|\<\>|\>\<|\!?~|REGEXP)\])?/i', $key, $match); - $column = $this->columnQuote($match[ 1 ]); - - if (isset($match[ 'operator' ])) - { - $operator = $match[ 'operator' ]; - - if (in_array($operator, ['>', '>=', '<', '<='])) - { - $condition = $column . ' ' . $operator . ' '; - - if (is_numeric($value)) - { - $condition .= $map_key; - $map[ $map_key ] = [$value, PDO::PARAM_INT]; - } - elseif ($raw = $this->buildRaw($value, $map)) - { - $condition .= $raw; - } - else - { - $condition .= $map_key; - $map[ $map_key ] = [$value, PDO::PARAM_STR]; - } - - $stack[] = $condition; - } - elseif ($operator === '!') - { - switch ($type) - { - case 'NULL': - $stack[] = $column . ' IS NOT NULL'; - break; - - case 'array': - $placeholders = []; - - foreach ($value as $index => $item) - { - $placeholders[] = $map_key . $index . '_i'; - $map[ $map_key . $index . '_i' ] = $this->typeMap($item, gettype($item)); - } - - $stack[] = $column . ' NOT IN (' . implode(', ', $placeholders) . ')'; - break; - - case 'object': - if ($raw = $this->buildRaw($value, $map)) - { - $stack[] = $column . ' != ' . $raw; - } - break; - - case 'integer': - case 'double': - case 'boolean': - case 'string': - $stack[] = $column . ' != ' . $map_key; - $map[ $map_key ] = $this->typeMap($value, $type); - break; - } - } - elseif ($operator === '~' || $operator === '!~') - { - if ($type !== 'array') - { - $value = [ $value ]; - } - - $connector = ' OR '; - $data = array_values($value); - - if (is_array($data[ 0 ])) - { - if (isset($value[ 'AND' ]) || isset($value[ 'OR' ])) - { - $connector = ' ' . array_keys($value)[ 0 ] . ' '; - $value = $data[ 0 ]; - } - } - - $like_clauses = []; - - foreach ($value as $index => $item) - { - $item = strval($item); - - if (!preg_match('/(\[.+\]|_|%.+|.+%)/', $item)) - { - $item = '%' . $item . '%'; - } - - $like_clauses[] = $column . ($operator === '!~' ? ' NOT' : '') . ' LIKE ' . $map_key . 'L' . $index; - $map[ $map_key . 'L' . $index ] = [$item, PDO::PARAM_STR]; - } - - $stack[] = '(' . implode($connector, $like_clauses) . ')'; - } - elseif ($operator === '<>' || $operator === '><') - { - if ($type === 'array') - { - if ($operator === '><') - { - $column .= ' NOT'; - } - - $stack[] = '(' . $column . ' BETWEEN ' . $map_key . 'a AND ' . $map_key . 'b)'; - - $data_type = (is_numeric($value[ 0 ]) && is_numeric($value[ 1 ])) ? PDO::PARAM_INT : PDO::PARAM_STR; - - $map[ $map_key . 'a' ] = [$value[ 0 ], $data_type]; - $map[ $map_key . 'b' ] = [$value[ 1 ], $data_type]; - } - } - elseif ($operator === 'REGEXP') - { - $stack[] = $column . ' REGEXP ' . $map_key; - $map[ $map_key ] = [$value, PDO::PARAM_STR]; - } - } - else - { - switch ($type) - { - case 'NULL': - $stack[] = $column . ' IS NULL'; - break; - - case 'array': - $placeholders = []; - - foreach ($value as $index => $item) - { - $placeholders[] = $map_key . $index . '_i'; - $map[ $map_key . $index . '_i' ] = $this->typeMap($item, gettype($item)); - } - - $stack[] = $column . ' IN (' . implode(', ', $placeholders) . ')'; - break; - - case 'object': - if ($raw = $this->buildRaw($value, $map)) - { - $stack[] = $column . ' = ' . $raw; - } - break; - - case 'integer': - case 'double': - case 'boolean': - case 'string': - $stack[] = $column . ' = ' . $map_key; - $map[ $map_key ] = $this->typeMap($value, $type); - break; - } - } - } - } - - return implode($conjunctor . ' ', $stack); - } - - protected function whereClause($where, &$map) - { - $where_clause = ''; - - if (is_array($where)) - { - $where_keys = array_keys($where); - - $conditions = array_diff_key($where, array_flip( - ['GROUP', 'ORDER', 'HAVING', 'LIMIT', 'LIKE', 'MATCH'] - )); - - if (!empty($conditions)) - { - $where_clause = ' WHERE ' . $this->dataImplode($conditions, $map, ' AND'); - } - - if (isset($where[ 'MATCH' ])) - { - $MATCH = $where[ 'MATCH' ]; - - if (is_array($MATCH) && isset($MATCH[ 'columns' ], $MATCH[ 'keyword' ])) - { - $mode = ''; - - $mode_array = [ - 'natural' => 'IN NATURAL LANGUAGE MODE', - 'natural+query' => 'IN NATURAL LANGUAGE MODE WITH QUERY EXPANSION', - 'boolean' => 'IN BOOLEAN MODE', - 'query' => 'WITH QUERY EXPANSION' - ]; - - if (isset($MATCH[ 'mode' ], $mode_array[ $MATCH[ 'mode' ] ])) - { - $mode = ' ' . $mode_array[ $MATCH[ 'mode' ] ]; - } - - $columns = implode(array_map([$this, 'columnQuote'], $MATCH[ 'columns' ]), ', '); - $map_key = $this->mapKey(); - $map[ $map_key ] = [$MATCH[ 'keyword' ], PDO::PARAM_STR]; - - $where_clause .= ($where_clause !== '' ? ' AND ' : ' WHERE') . ' MATCH (' . $columns . ') AGAINST (' . $map_key . $mode . ')'; - } - } - - if (isset($where[ 'GROUP' ])) - { - $GROUP = $where[ 'GROUP' ]; - - if (is_array($GROUP)) - { - $stack = []; - - foreach ($GROUP as $column => $value) - { - $stack[] = $this->columnQuote($value); - } - - $where_clause .= ' GROUP BY ' . implode($stack, ','); - } - elseif ($raw = $this->buildRaw($GROUP, $map)) - { - $where_clause .= ' GROUP BY ' . $raw; - } - else - { - $where_clause .= ' GROUP BY ' . $this->columnQuote($GROUP); - } - - if (isset($where[ 'HAVING' ])) - { - if ($raw = $this->buildRaw($where[ 'HAVING' ], $map)) - { - $where_clause .= ' HAVING ' . $raw; - } - else - { - $where_clause .= ' HAVING ' . $this->dataImplode($where[ 'HAVING' ], $map, ' AND'); - } - } - } - - if (isset($where[ 'ORDER' ])) - { - $ORDER = $where[ 'ORDER' ]; - - if (is_array($ORDER)) - { - $stack = []; - - foreach ($ORDER as $column => $value) - { - if (is_array($value)) - { - $stack[] = 'FIELD(' . $this->columnQuote($column) . ', ' . $this->arrayQuote($value) . ')'; - } - elseif ($value === 'ASC' || $value === 'DESC') - { - $stack[] = $this->columnQuote($column) . ' ' . $value; - } - elseif (is_int($column)) - { - $stack[] = $this->columnQuote($value); - } - } - - $where_clause .= ' ORDER BY ' . implode($stack, ','); - } - elseif ($raw = $this->buildRaw($ORDER, $map)) - { - $where_clause .= ' ORDER BY ' . $raw; - } - else - { - $where_clause .= ' ORDER BY ' . $this->columnQuote($ORDER); - } - - if ( - isset($where[ 'LIMIT' ]) && - in_array($this->type, ['oracle', 'mssql']) - ) - { - $LIMIT = $where[ 'LIMIT' ]; - - if (is_numeric($LIMIT)) - { - $LIMIT = [0, $LIMIT]; - } - - if ( - is_array($LIMIT) && - is_numeric($LIMIT[ 0 ]) && - is_numeric($LIMIT[ 1 ]) - ) - { - $where_clause .= ' OFFSET ' . $LIMIT[ 0 ] . ' ROWS FETCH NEXT ' . $LIMIT[ 1 ] . ' ROWS ONLY'; - } - } - } - - if (isset($where[ 'LIMIT' ]) && !in_array($this->type, ['oracle', 'mssql'])) - { - $LIMIT = $where[ 'LIMIT' ]; - - if (is_numeric($LIMIT)) - { - $where_clause .= ' LIMIT ' . $LIMIT; - } - elseif ( - is_array($LIMIT) && - is_numeric($LIMIT[ 0 ]) && - is_numeric($LIMIT[ 1 ]) - ) - { - $where_clause .= ' LIMIT ' . $LIMIT[ 1 ] . ' OFFSET ' . $LIMIT[ 0 ]; - } - } - } - elseif ($raw = $this->buildRaw($where, $map)) - { - $where_clause .= ' ' . $raw; - } - - return $where_clause; - } - - protected function selectContext($table, &$map, $join, &$columns = null, $where = null, $column_fn = null) - { - preg_match('/(?[a-zA-Z0-9_]+)\s*\((?[a-zA-Z0-9_]+)\)/i', $table, $table_match); - - if (isset($table_match[ 'table' ], $table_match[ 'alias' ])) - { - $table = $this->tableQuote($table_match[ 'table' ]); - - $table_query = $table . ' AS ' . $this->tableQuote($table_match[ 'alias' ]); - } - else - { - $table = $this->tableQuote($table); - - $table_query = $table; - } - - $join_key = is_array($join) ? array_keys($join) : null; - - if ( - isset($join_key[ 0 ]) && - strpos($join_key[ 0 ], '[') === 0 - ) - { - $table_join = []; - - $join_array = [ - '>' => 'LEFT', - '<' => 'RIGHT', - '<>' => 'FULL', - '><' => 'INNER' - ]; - - foreach($join as $sub_table => $relation) - { - preg_match('/(\[(?\<\>?|\>\[a-zA-Z0-9_]+)\s?(\((?[a-zA-Z0-9_]+)\))?/', $sub_table, $match); - - if ($match[ 'join' ] !== '' && $match[ 'table' ] !== '') - { - if (is_string($relation)) - { - $relation = 'USING ("' . $relation . '")'; - } - - if (is_array($relation)) - { - // For ['column1', 'column2'] - if (isset($relation[ 0 ])) - { - $relation = 'USING ("' . implode($relation, '", "') . '")'; - } - else - { - $joins = []; - - foreach ($relation as $key => $value) - { - $joins[] = ( - strpos($key, '.') > 0 ? - // For ['tableB.column' => 'column'] - $this->columnQuote($key) : - - // For ['column1' => 'column2'] - $table . '."' . $key . '"' - ) . - ' = ' . - $this->tableQuote(isset($match[ 'alias' ]) ? $match[ 'alias' ] : $match[ 'table' ]) . '."' . $value . '"'; - } - - $relation = 'ON ' . implode($joins, ' AND '); - } - } - - $table_name = $this->tableQuote($match[ 'table' ]) . ' '; - - if (isset($match[ 'alias' ])) - { - $table_name .= 'AS ' . $this->tableQuote($match[ 'alias' ]) . ' '; - } - - $table_join[] = $join_array[ $match[ 'join' ] ] . ' JOIN ' . $table_name . $relation; - } - } - - $table_query .= ' ' . implode($table_join, ' '); - } - else - { - if (is_null($columns)) - { - if ( - !is_null($where) || - (is_array($join) && isset($column_fn)) - ) - { - $where = $join; - $columns = null; - } - else - { - $where = null; - $columns = $join; - } - } - else - { - $where = $columns; - $columns = $join; - } - } - - if (isset($column_fn)) - { - if ($column_fn === 1) - { - $column = '1'; - - if (is_null($where)) - { - $where = $columns; - } - } - else - { - if (empty($columns)) - { - $columns = '*'; - $where = $join; - } - - $column = $column_fn . '(' . $this->columnPush($columns, $map) . ')'; - } - } - else - { - $column = $this->columnPush($columns, $map); - } - - return 'SELECT ' . $column . ' FROM ' . $table_query . $this->whereClause($where, $map); - } - - protected function columnMap($columns, &$stack) - { - if ($columns === '*') - { - return $stack; - } - - foreach ($columns as $key => $value) - { - if (is_int($key)) - { - preg_match('/([a-zA-Z0-9_]+\.)?(?[a-zA-Z0-9_]+)(?:\s*\((?[a-zA-Z0-9_]+)\))?(?:\s*\[(?(?:String|Bool|Int|Number|Object|JSON))\])?/i', $value, $key_match); - - $column_key = !empty($key_match[ 'alias' ]) ? - $key_match[ 'alias' ] : - $key_match[ 'column' ]; - - if (isset($key_match[ 'type' ])) - { - $stack[ $value ] = [$column_key, $key_match[ 'type' ]]; - } - else - { - $stack[ $value ] = [$column_key, 'String']; - } - } - elseif ($this->isRaw($value)) - { - preg_match('/([a-zA-Z0-9_]+\.)?(?[a-zA-Z0-9_]+)(\s*\[(?(String|Bool|Int|Number))\])?/i', $key, $key_match); - - $column_key = $key_match[ 'column' ]; - - if (isset($key_match[ 'type' ])) - { - $stack[ $key ] = [$column_key, $key_match[ 'type' ]]; - } - else - { - $stack[ $key ] = [$column_key, 'String']; - } - } - elseif (!is_int($key) && is_array($value)) - { - $this->columnMap($value, $stack); - } - } - - return $stack; - } - - protected function dataMap($data, $columns, $column_map, &$stack) - { - foreach ($columns as $key => $value) - { - $isRaw = $this->isRaw($value); - - if (is_int($key) || $isRaw) - { - $map = $column_map[ $isRaw ? $key : $value ]; - - $column_key = $map[ 0 ]; - - if (isset($map[ 1 ])) - { - if ($isRaw && in_array($map[ 1 ], ['Object', 'JSON'])) - { - continue; - } - - switch ($map[ 1 ]) - { - case 'Number': - $stack[ $column_key ] = (double) $data[ $column_key ]; - break; - - case 'Int': - $stack[ $column_key ] = (int) $data[ $column_key ]; - break; - - case 'Bool': - $stack[ $column_key ] = (bool) $data[ $column_key ]; - break; - - case 'Object': - $stack[ $column_key ] = unserialize($data[ $column_key ]); - break; - - case 'JSON': - $stack[ $column_key ] = json_decode($data[ $column_key ], true); - break; - - case 'String': - $stack[ $column_key ] = $data[ $column_key ]; - break; - } - } - else - { - $stack[ $column_key ] = $data[ $column_key ]; - } - } - else - { - $current_stack = []; - - $this->dataMap($data, $value, $column_map, $current_stack); - - $stack[ $key ] = $current_stack; - } - } - } - - public function select($table, $join, $columns = null, $where = null) - { - $map = []; - $stack = []; - $column_map = []; - - $index = 0; - - $column = $where === null ? $join : $columns; - - $is_single = (is_string($column) && $column !== '*'); - - $query = $this->exec($this->selectContext($table, $map, $join, $columns, $where), $map); - - $this->columnMap($columns, $column_map); - - if (!$query) - { - return false; - } - - if ($columns === '*') - { - return $query->fetchAll(PDO::FETCH_ASSOC); - } - - if ($is_single) - { - return $query->fetchAll(PDO::FETCH_COLUMN); - } - - while ($data = $query->fetch(PDO::FETCH_ASSOC)) - { - $current_stack = []; - - $this->dataMap($data, $columns, $column_map, $current_stack); - - $stack[ $index ] = $current_stack; - - $index++; - } - - return $stack; - } - - public function insert($table, $datas) - { - $stack = []; - $columns = []; - $fields = []; - $map = []; - - if (!isset($datas[ 0 ])) - { - $datas = [$datas]; - } - - foreach ($datas as $data) - { - foreach ($data as $key => $value) - { - $columns[] = $key; - } - } - - $columns = array_unique($columns); - - foreach ($datas as $data) - { - $values = []; - - foreach ($columns as $key) - { - if ($raw = $this->buildRaw($data[ $key ], $map)) - { - $values[] = $raw; - continue; - } - - $map_key =$this->mapKey(); - - $values[] = $map_key; - - if (!isset($data[ $key ])) - { - $map[ $map_key ] = [null, PDO::PARAM_NULL]; - } - else - { - $value = $data[ $key ]; - - $type = gettype($value); - - switch ($type) - { - case 'array': - $map[ $map_key ] = [ - strpos($key, '[JSON]') === strlen($key) - 6 ? - json_encode($value) : - serialize($value), - PDO::PARAM_STR - ]; - break; - - case 'object': - $value = serialize($value); - - case 'NULL': - case 'resource': - case 'boolean': - case 'integer': - case 'double': - case 'string': - $map[ $map_key ] = $this->typeMap($value, $type); - break; - } - } - } - - $stack[] = '(' . implode($values, ', ') . ')'; - } - - foreach ($columns as $key) - { - $fields[] = $this->columnQuote(preg_replace("/(\s*\[JSON\]$)/i", '', $key)); - } - - return $this->exec('INSERT INTO ' . $this->tableQuote($table) . ' (' . implode(', ', $fields) . ') VALUES ' . implode(', ', $stack), $map); - } - - public function update($table, $data, $where = null) - { - $fields = []; - $map = []; - - foreach ($data as $key => $value) - { - $column = $this->columnQuote(preg_replace("/(\s*\[(JSON|\+|\-|\*|\/)\]$)/i", '', $key)); - - if ($raw = $this->buildRaw($value, $map)) - { - $fields[] = $column . ' = ' . $raw; - continue; - } - - $map_key = $this->mapKey(); - - preg_match('/(?[a-zA-Z0-9_]+)(\[(?\+|\-|\*|\/)\])?/i', $key, $match); - - if (isset($match[ 'operator' ])) - { - if (is_numeric($value)) - { - $fields[] = $column . ' = ' . $column . ' ' . $match[ 'operator' ] . ' ' . $value; - } - } - else - { - $fields[] = $column . ' = ' . $map_key; - - $type = gettype($value); - - switch ($type) - { - case 'array': - $map[ $map_key ] = [ - strpos($key, '[JSON]') === strlen($key) - 6 ? - json_encode($value) : - serialize($value), - PDO::PARAM_STR - ]; - break; - - case 'object': - $value = serialize($value); - - case 'NULL': - case 'resource': - case 'boolean': - case 'integer': - case 'double': - case 'string': - $map[ $map_key ] = $this->typeMap($value, $type); - break; - } - } - } - - return $this->exec('UPDATE ' . $this->tableQuote($table) . ' SET ' . implode(', ', $fields) . $this->whereClause($where, $map), $map); - } - - public function delete($table, $where) - { - $map = []; - - return $this->exec('DELETE FROM ' . $this->tableQuote($table) . $this->whereClause($where, $map), $map); - } - - public function replace($table, $columns, $where = null) - { - if (!is_array($columns) || empty($columns)) - { - return false; - } - - $map = []; - $stack = []; - - foreach ($columns as $column => $replacements) - { - if (is_array($replacements)) - { - foreach ($replacements as $old => $new) - { - $map_key = $this->mapKey(); - - $stack[] = $this->columnQuote($column) . ' = REPLACE(' . $this->columnQuote($column) . ', ' . $map_key . 'a, ' . $map_key . 'b)'; - - $map[ $map_key . 'a' ] = [$old, PDO::PARAM_STR]; - $map[ $map_key . 'b' ] = [$new, PDO::PARAM_STR]; - } - } - } - - if (!empty($stack)) - { - return $this->exec('UPDATE ' . $this->tableQuote($table) . ' SET ' . implode(', ', $stack) . $this->whereClause($where, $map), $map); - } - - return false; - } - - public function get($table, $join = null, $columns = null, $where = null) - { - $map = []; - $stack = []; - $column_map = []; - - if ($where === null) - { - $column = $join; - unset($columns[ 'LIMIT' ]); - } - else - { - $column = $columns; - unset($where[ 'LIMIT' ]); - } - - $is_single = (is_string($column) && $column !== '*'); - - $query = $this->exec($this->selectContext($table, $map, $join, $columns, $where) . ' LIMIT 1', $map); - - if ($query) - { - $data = $query->fetchAll(PDO::FETCH_ASSOC); - - if (isset($data[ 0 ])) - { - if ($column === '*') - { - return $data[ 0 ]; - } - - $this->columnMap($columns, $column_map); - - $this->dataMap($data[ 0 ], $columns, $column_map, $stack); - - if ($is_single) - { - return $stack[ $column_map[ $column ][ 0 ] ]; - } - - return $stack; - } - - return false; - } - - return false; - } - - public function has($table, $join, $where = null) - { - $map = []; - $column = null; - - $query = $this->exec('SELECT EXISTS(' . $this->selectContext($table, $map, $join, $column, $where, 1) . ')', $map); - - if ($query) - { - $result = $query->fetchColumn(); - - return $result === '1' || $result === true; - } - - return false; - } - - private function aggregate($type, $table, $join = null, $column = null, $where = null) - { - $map = []; - - $query = $this->exec($this->selectContext($table, $map, $join, $column, $where, strtoupper($type)), $map); - - if ($query) - { - $number = $query->fetchColumn(); - - return is_numeric($number) ? $number + 0 : $number; - } - - return false; - } - - public function action($actions) - { - if (is_callable($actions)) - { - $this->pdo->beginTransaction(); - - try { - $result = $actions($this); - - if ($result === false) - { - $this->pdo->rollBack(); - } - else - { - $this->pdo->commit(); - } - } - catch (Exception $e) { - $this->pdo->rollBack(); - - throw $e; - } - - return $result; - } - - return false; - } - - public function id() - { - $type = $this->type; - - if ($type === 'oracle') - { - return 0; - } - elseif ($type === 'mssql') - { - return $this->pdo->query('SELECT SCOPE_IDENTITY()')->fetchColumn(); - } - elseif ($type === 'pgsql') - { - return $this->pdo->query('SELECT LASTVAL()')->fetchColumn(); - } - - return $this->pdo->lastInsertId(); - } - - public function debug() - { - $this->debug_mode = true; - - return $this; - } - - public function error() - { - return $this->statement ? $this->statement->errorInfo() : null; - } - - public function last() - { - $log = end($this->logs); - - return $this->generate($log[ 0 ], $log[ 1 ]); - } - - public function log() - { - return array_map(function ($log) - { - return $this->generate($log[ 0 ], $log[ 1 ]); - }, - $this->logs - ); - } - - public function info() - { - $output = [ - 'server' => 'SERVER_INFO', - 'driver' => 'DRIVER_NAME', - 'client' => 'CLIENT_VERSION', - 'version' => 'SERVER_VERSION', - 'connection' => 'CONNECTION_STATUS' - ]; - - foreach ($output as $key => $value) - { - $output[ $key ] = @$this->pdo->getAttribute(constant('PDO::ATTR_' . $value)); - } - - return $output; - } -} -?> \ No newline at end of file diff --git a/old/src/add_adult.php b/old/src/add_adult.php deleted file mode 100644 index 40e5de0..0000000 --- a/old/src/add_adult.php +++ /dev/null @@ -1,62 +0,0 @@ -get("groups", [ - "guid", - "group_name", - "adults", - "kids", - "vehicles" -], [ - "guid" => $_GET[g] -]); - -?> - -
- -

Adult Ticket

- - -
- -
-
- - -
-
- - -
-
- -
-
- - -
-
- - -
-
- -
-
- Back -
-
- -
-
- - -
- - - - diff --git a/old/src/add_adult_do.php b/old/src/add_adult_do.php deleted file mode 100644 index 85132cf..0000000 --- a/old/src/add_adult_do.php +++ /dev/null @@ -1,50 +0,0 @@ -count("tickets", [ - "guid" => $_SESSION[user], - "ticket_type" => "a" -]); - -// get group data -$g = $database->get("groups", [ - "guid", - "group_name", - "adults", - "kids", - "vehicles" -], [ - "guid" => $_SESSION[user] -]); - - - -if ($count < $g[adults]) { - - // Add record - $database->insert("tickets", [ - "first_name" => ucfirst($_POST[first_name]), - "last_name" => ucfirst($_POST[last_name]), - "mobile" => $_POST[mobile], - "email" => $_POST[email], - "ticket_type" => "a", - "last_action" => date("Y-m-d H:i:s"), - "guid" => $_SESSION[user] - ]); - - // Update activity timer - $database->update("groups", [ - "last_action" => date("Y-m-d H:i:s"), - ], [ - "guid" => $_SESSION[user] - ]); - -} - -// Back to main screen -header("Location: tickets.php"); - -?> - diff --git a/old/src/add_group_do.php b/old/src/add_group_do.php deleted file mode 100644 index 7af1fdd..0000000 --- a/old/src/add_group_do.php +++ /dev/null @@ -1,23 +0,0 @@ -insert("groups", [ - "kids" => "0", - "adults" => "0", - "vehicles" => "0", - "guid" => uniqid() -]); - -$id = $database->id(); - -$g = $database->get("groups", [ - "guid" - ], [ - "id" => $id -]); - -header("Location: edit_group.php?guid=$g[guid]"); - -?> - diff --git a/old/src/add_kids.php b/old/src/add_kids.php deleted file mode 100644 index b4d4dcb..0000000 --- a/old/src/add_kids.php +++ /dev/null @@ -1,58 +0,0 @@ -get("groups", [ - "guid", - "group_name", - "adults", - "kids", - "vehicles" -], [ - "guid" => $_GET[g] -]); - -?> - -
- -

Kids Ticket

-
- -
-
- - -
-
- - -
-
- -
-
- - -
-
- - -
-
- -
-
- Back -
-
- -
-
- - -
- - - - diff --git a/old/src/add_kids_do.php b/old/src/add_kids_do.php deleted file mode 100644 index c5d17d7..0000000 --- a/old/src/add_kids_do.php +++ /dev/null @@ -1,50 +0,0 @@ -count("tickets", [ - "guid" => $_SESSION[user], - "ticket_type" => "k" -]); - -// get group data -$g = $database->get("groups", [ - "guid", - "group_name", - "adults", - "kids", - "vehicles" -], [ - "guid" => $_SESSION[user] -]); - - - -if ($count < $g[kids]) { - - // Add record - $database->insert("tickets", [ - "first_name" => ucfirst($_POST[first_name]), - "last_name" => ucfirst($_POST[last_name]), - "mobile" => $_POST[mobile], - "email" => $_POST[email], - "ticket_type" => "k", - "last_action" => date("Y-m-d H:i:s"), - "guid" => $_SESSION[user] - ]); - - // Update activity timer - $database->update("groups", [ - "last_action" => date("Y-m-d H:i:s"), - ], [ - "guid" => $_SESSION[user] - ]); - -} - -// Back to main screen -header("Location:tickets.php?g=$_SESSION[user]"); - -?> - diff --git a/old/src/add_vehicle.php b/old/src/add_vehicle.php deleted file mode 100644 index c88a441..0000000 --- a/old/src/add_vehicle.php +++ /dev/null @@ -1,74 +0,0 @@ -get("groups", [ - "guid", - "group_name", - "adults", - "kids", - "vehicles" -], [ - "guid" => $_GET[g] -]); - -?> - -
- -

Vehicle Pass

-
- -
-
- - -
-
- - -
-
- -
-
- - - -
-
- - -
-
- -
-
- - -
-
- - -
-
- -
-
- Back -
-
- -
-
- - -
- - - - diff --git a/old/src/add_vehicle_do.php b/old/src/add_vehicle_do.php deleted file mode 100644 index 534580f..0000000 --- a/old/src/add_vehicle_do.php +++ /dev/null @@ -1,52 +0,0 @@ -count("tickets", [ - "guid" => $_SESSION[user], - "ticket_type" => "v" -]); - -// get group data -$g = $database->get("groups", [ - "guid", - "group_name", - "adults", - "kids", - "vehicles" -], [ - "guid" => $_SESSION[user] -]); - - - -if ($count < $g[vehicles]) { - - // Add record - $database->insert("tickets", [ - "first_name" => ucfirst($_POST[first_name]), - "last_name" => ucfirst($_POST[last_name]), - "mobile" => $_POST[mobile], - "email" => $_POST[email], - "vehicle_pass" => $_POST[vehicle_pass], - "vehicle_reg" => strtoupper($_POST[vehicle_reg]), - "ticket_type" => "v", - "last_action" => date("Y-m-d H:i:s"), - "guid" => $_SESSION[user] - ]); - - // Update activity timer - $database->update("groups", [ - "last_action" => date("Y-m-d H:i:s"), - ], [ - "guid" => $_SESSION[user] - ]); - -} - -// Back to main screen -header("Location:tickets.php?g=$_SESSION[user]"); - -?> - diff --git a/old/src/artist-info/index.php b/old/src/artist-info/index.php deleted file mode 100644 index 6dc9f1c..0000000 --- a/old/src/artist-info/index.php +++ /dev/null @@ -1,5 +0,0 @@ - diff --git a/old/src/backup.php b/old/src/backup.php deleted file mode 100644 index c641465..0000000 --- a/old/src/backup.php +++ /dev/null @@ -1,16 +0,0 @@ - diff --git a/old/src/classes/database.class.php b/old/src/classes/database.class.php deleted file mode 100644 index 7276a80..0000000 --- a/old/src/classes/database.class.php +++ /dev/null @@ -1,105 +0,0 @@ -host . ';dbname=' . $this->dbname; - // Set options - $options = array( - PDO::ATTR_PERSISTENT => true, - PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION - ); - // Create a new PDO instanace - try{ - $this->dbh = new PDO($dsn, $this->user, $this->pass, $options); - } - // Catch any errors - catch(PDOException $e){ - $this->error = $e->getMessage(); - } - } - - public function query($query){ - $this->stmt = $this->dbh->prepare($query); - } - public function bind($param, $value, $type = null){ - if (is_null($type)) { - switch (true) { - case is_int($value): - $type = PDO::PARAM_INT; - break; - case is_bool($value): - $type = PDO::PARAM_BOOL; - break; - case is_null($value): - $type = PDO::PARAM_NULL; - break; - default: - $type = PDO::PARAM_STR; - } - } - $this->stmt->bindValue($param, $value, $type); - } - public function execute(){ - return $this->stmt->execute(); - } - - public function resultset(){ - $this->execute(); - return $this->stmt->fetchAll(PDO::FETCH_ASSOC); - } - - public function single(){ - $this->execute(); - return $this->stmt->fetch(PDO::FETCH_ASSOC); - } - - public function rowCount(){ - return $this->stmt->rowCount(); - } - - public function lastInsertId(){ - return $this->dbh->lastInsertId(); - } - - public function beginTransaction(){ - return $this->dbh->beginTransaction(); - } - - public function endTransaction(){ - return $this->dbh->commit(); - } - - public function cancelTransaction(){ - return $this->dbh->rollBack(); - } - - public function debugDumpParams(){ - return $this->stmt->debugDumpParams(); - } - - public function close(){ - $this->dbh = null; - } - } -?> diff --git a/old/src/classes/mysql.sessions.php b/old/src/classes/mysql.sessions.php deleted file mode 100644 index 94cd50f..0000000 --- a/old/src/classes/mysql.sessions.php +++ /dev/null @@ -1,132 +0,0 @@ -db = new Database; - - // Set handler to overide SESSION - session_set_save_handler( - array($this, "_open"), - array($this, "_close"), - array($this, "_read"), - array($this, "_write"), - array($this, "_destroy"), - array($this, "_gc") - ); - - // Start the session - session_start(); - } - public function _open(){ - // If successful - if($this->db){ - // Return True - return true; - } - // Return False - return false; - } - public function _close(){ - // Close the database connection - // If successful - if($this->db->close()){ - // Return True - return true; - } - // Return False - return false; - } - public function _read($id){ - // Set query - $this->db->query('SELECT data FROM sessions WHERE id = :id'); - // Bind the Id - $this->db->bind(':id', $id); - // Attempt execution - // If successful - if($this->db->execute()){ - // Save returned row - $row = $this->db->single(); - // Return the data - if (is_null($row['data'])) { - return ''; - } - return $row['data']; - } - } - public function _write($id, $data){ - // Create time stamp - $access = time(); - // Set query - $this->db->query('REPLACE INTO sessions VALUES (:id, :access, :data)'); - // Bind data - $this->db->bind(':id', $id); - $this->db->bind(':access', $access); - $this->db->bind(':data', $data); - // Attempt Execution - // If successful - if($this->db->execute()){ - // Return True - return true; - } - // Return False - return false; - } - public function _destroy($id){ - // Set query - $this->db->query('DELETE FROM sessions WHERE id = :id'); - // Bind data - $this->db->bind(':id', $id); - // Attempt execution - // If successful - if($this->db->execute()){ - // Return True - return true; - } - // Return False - return false; - } - public function _gc($max){ - // Calculate what is to be deemed old - $old = time() - $max; - // Set query - $this->db->query('DELETE FROM sessions WHERE access < :old'); - // Bind data - $this->db->bind(':old', $old); - // Attempt execution - if($this->db->execute()){ - // Return True - return true; - } - // Return False - return false; - } -} -?> diff --git a/old/src/config.php b/old/src/config.php deleted file mode 100644 index c84bdde..0000000 --- a/old/src/config.php +++ /dev/null @@ -1,33 +0,0 @@ - 'mysql', - 'database_name' => getenv('DB_NAME'), - 'server' => getenv('DB_HOST'), - 'username' => getenv('DB_USER'), - 'password' => getenv('DB_PASS'), -]); - - -?> diff --git a/old/src/delete_group_do.php b/old/src/delete_group_do.php deleted file mode 100644 index 529a5cc..0000000 --- a/old/src/delete_group_do.php +++ /dev/null @@ -1,16 +0,0 @@ -delete("tickets", [ - "guid" => $_GET[guid] -]); - -$database->delete("groups", [ - "guid" => $_GET[guid] -]); - -header("Location: groups.php"); - -?> - diff --git a/old/src/edit_group.php b/old/src/edit_group.php deleted file mode 100644 index ba8a6e7..0000000 --- a/old/src/edit_group.php +++ /dev/null @@ -1,96 +0,0 @@ -get("groups", [ - "guid", - "group_name", - "adults", - "kids", - "vehicles" -], [ - "guid" => $_GET[guid] -]); - -?> - -
-

Edit Group

-

Access Code:

-
-
- - - -
-
-
- - -
-
- - -
-
- - -
-
-
-
- Back -
-
- -
-
- - -
- - - - diff --git a/old/src/edit_group_do.php b/old/src/edit_group_do.php deleted file mode 100644 index 67b0c9f..0000000 --- a/old/src/edit_group_do.php +++ /dev/null @@ -1,17 +0,0 @@ -update("groups", [ - "group_name" => $_POST[group_name], - "kids" => $_POST[kids], - "adults" => $_POST[adults], - "vehicles" => $_POST[vehicles], -], [ - "guid" => $_POST[guid] -]); - -header("Location:groups.php"); - -?> - diff --git a/old/src/group_login_do.php b/old/src/group_login_do.php deleted file mode 100644 index b54ddac..0000000 --- a/old/src/group_login_do.php +++ /dev/null @@ -1,9 +0,0 @@ - - diff --git a/old/src/groups.php b/old/src/groups.php deleted file mode 100644 index 5ac7675..0000000 --- a/old/src/groups.php +++ /dev/null @@ -1,75 +0,0 @@ - - -
-

Group Management

-

Add New Group

-
- - - - - - - - - - -select("groups", [ - "guid", - "group_name", - "adults", - "kids", - "vehicles" -], [ - "ORDER" => ["group_name"] -]); - -foreach($groups as $g) -{ - $adults = $database->count("tickets", [ - "guid" => $g[guid], - "ticket_type" => "a" - ]); - $kids = $database->count("tickets", [ - "guid" => $g[guid], - "ticket_type" => "k" - ]); - $vehicles = $database->count("tickets", [ - "guid" => $g[guid], - "ticket_type" => "v" - ]); - - echo " "; - echo " "; - - if ($adults == $g["adults"]) $pillColor = "badge-success"; - elseif ($adults == 0) $pillColor = "badge-secondary"; - else $pillColor = "badge-primary"; - echo " "; - - if ($kids == $g["kids"]) $pillColor = "badge-success"; - elseif ($kids == 0) $pillColor = "badge-secondary"; - else $pillColor = "badge-primary"; - echo " "; - - if ($vehicles == $g["vehicles"]) $pillColor = "badge-success"; - elseif ($vehicles == 0) $pillColor = "badge-secondary"; - else $pillColor = "badge-primary"; - echo " "; - - echo " "; - echo " "; -} -?> - - - -
CollectiveAdultsKidsVehiclesAction
" . $g["group_name"] . "$adults / " . $g["adults"] . "$kids / " . $g["kids"] . "$vehicles / " . $g["vehicles"] . " Edit"; - echo " Delete"; - echo " Login
- - - - diff --git a/old/src/health.php b/old/src/health.php deleted file mode 100644 index 9145504..0000000 --- a/old/src/health.php +++ /dev/null @@ -1,5 +0,0 @@ - diff --git a/old/src/img/SF-small.png b/old/src/img/SF-small.png deleted file mode 100644 index 9e21fcd..0000000 Binary files a/old/src/img/SF-small.png and /dev/null differ diff --git a/old/src/inc/footer.php b/old/src/inc/footer.php deleted file mode 100755 index b31de24..0000000 --- a/old/src/inc/footer.php +++ /dev/null @@ -1,4 +0,0 @@ - - - - diff --git a/old/src/inc/header.php b/old/src/inc/header.php deleted file mode 100755 index 4892a05..0000000 --- a/old/src/inc/header.php +++ /dev/null @@ -1,47 +0,0 @@ - - - - - Stumblefunk - - - - - - - - - - - - -

- diff --git a/old/src/inc/index.css b/old/src/inc/index.css deleted file mode 100644 index d7f7722..0000000 --- a/old/src/inc/index.css +++ /dev/null @@ -1,47 +0,0 @@ -body { - padding-top: 40px; - padding-bottom: 40px; - background-color: #343a40; -} - -.form-signin { - max-width: 330px; - padding: 15px; - margin: 0 auto; -} - -.form-signin .form-signin-heading, - -.form-signin .checkbox { - margin-bottom: 10px; -} - -.form-signin .checkbox { - font-weight: normal; -} - -.form-signin .form-control { - position: relative; - height: auto; - -webkit-box-sizing: border-box; - box-sizing: border-box; - padding: 10px; - font-size: 16px; -} - -.form-signin .form-control:focus { - z-index: 2; -} - -.form-signin input[type="email"] { - margin-bottom: -1px; - border-bottom-right-radius: 0; - border-bottom-left-radius: 0; -} - -.form-signin input[type="password"] { - margin-bottom: 10px; - border-top-left-radius: 0; - border-top-right-radius: 0; -} - diff --git a/old/src/index.php b/old/src/index.php deleted file mode 100644 index b056667..0000000 --- a/old/src/index.php +++ /dev/null @@ -1,38 +0,0 @@ - - - - - Stumblefunk - - - - - - - - - - - -

- -
- - - diff --git a/old/src/index_do.php b/old/src/index_do.php deleted file mode 100644 index b5ad6b1..0000000 --- a/old/src/index_do.php +++ /dev/null @@ -1,38 +0,0 @@ -count("groups", [ - "guid" => $_POST[guid] -]); - -if ($count==1) { - - $_SESSION[user] = $_POST[guid]; - - $database->update("groups", [ - "last_action" => date("Y-m-d H:i:s"), - ], [ - "guid" => $_POST[guid] - ]); - - header("Location:tickets.php"); - -} - -else { - header("Location: /?e=1"); -} - -?> - diff --git a/old/src/list_tickets.php b/old/src/list_tickets.php deleted file mode 100644 index 8fe4dd8..0000000 --- a/old/src/list_tickets.php +++ /dev/null @@ -1,76 +0,0 @@ - - -
-

List of tickets

-
- - - - - - - - - - - -select("groups", [ - "guid", - "group_name", - "adults", - "kids", - "vehicles" -], [ - "ORDER" => ["group_name"] -]); - -foreach($groups as $g) -{ - $tickets = $database->select("tickets", [ - "guid", - "first_name", - "last_name", - "ticket_type", - "mobile", - "email" - ], [ - "guid" => $g[guid], - "ORDER" => ["first_name"] - ]); - - foreach($tickets as $t) - { - if ($t[ticket_type]=='a') $type='Adult'; - if ($t[ticket_type]=='k') $type='Child'; - if ($t[ticket_type]=='v') continue; - echo " "; - echo " "; - echo " "; - echo " "; - echo " "; - echo " "; - echo " "; - } -} -?> - - - -
CollectiveNameTypeEmailMobile
$g[group_name]$t[first_name] $t[last_name]$type$t[email]$t[mobile]
-
- - - - - diff --git a/old/src/list_vehicles.php b/old/src/list_vehicles.php deleted file mode 100644 index 10a1513..0000000 --- a/old/src/list_vehicles.php +++ /dev/null @@ -1,76 +0,0 @@ - - -
-

List of vehicles

-
- - - - - - - - - - - -select("groups", [ - "guid", - "group_name", - "adults", - "kids", - "vehicles" -], [ - "ORDER" => ["group_name"] -]); - -foreach($groups as $g) -{ - $tickets = $database->select("tickets", [ - "guid", - "first_name", - "last_name", - "ticket_type", - "mobile", - "vehicle_pass", - "vehicle_reg", - "email" - ], [ - "guid" => $g[guid], - "ORDER" => ["first_name"] - ]); - - foreach($tickets as $t) - { - if ($t[ticket_type]!='v') continue; - echo " "; - echo " "; - echo " "; - echo " "; - echo " "; - echo " "; - echo " "; - } -} -?> - - - -
CollectiveNameMobileRegistrationPass Type
$g[group_name]$t[first_name] $t[last_name]$t[mobile]$t[vehicle_reg]$t[vehicle_pass]
-
- - - - - diff --git a/old/src/logout.php b/old/src/logout.php deleted file mode 100644 index 48e5680..0000000 --- a/old/src/logout.php +++ /dev/null @@ -1,12 +0,0 @@ - - diff --git a/old/src/remove_ticket.php b/old/src/remove_ticket.php deleted file mode 100644 index 96b195e..0000000 --- a/old/src/remove_ticket.php +++ /dev/null @@ -1,22 +0,0 @@ -delete("tickets", [ - "guid" => $_SESSION[user], - "id" => $_GET[id] -]); - -// Update activity timer - $database->update("groups", [ - "last_action" => date("Y-m-d H:i:s"), -], [ - "guid" => $_SESSION[user] -]); - -// Back to main screen -header("Location: tickets.php"); - -?> - diff --git a/old/src/sql/groups.sql b/old/src/sql/groups.sql deleted file mode 100644 index b83aa12..0000000 --- a/old/src/sql/groups.sql +++ /dev/null @@ -1,10 +0,0 @@ -CREATE TABLE groups ( -`id` INT NOT NULL AUTO_INCREMENT PRIMARY KEY, -group_name varchar(255) , -kids int(5), -adults int(5), -vehicles int(5), -last_action datetime, -guid varchar(25) -)ENGINE=innodb; - diff --git a/old/src/sql/tickets.sql b/old/src/sql/tickets.sql deleted file mode 100644 index f6e1dbf..0000000 --- a/old/src/sql/tickets.sql +++ /dev/null @@ -1,13 +0,0 @@ -CREATE TABLE tickets ( -`id` INT NOT NULL AUTO_INCREMENT PRIMARY KEY, -guid varchar(25) , -ticket_type varchar(255) , -first_name varchar(255) , -last_name varchar(255) , -email varchar(255) , -mobile varchar(255) , -vehicle_reg varchar(255) , -vehicle_pass varchar(255) , -last_action datetime -)ENGINE=innodb; - diff --git a/old/src/tickets.php b/old/src/tickets.php deleted file mode 100644 index f0f297f..0000000 --- a/old/src/tickets.php +++ /dev/null @@ -1,106 +0,0 @@ -get("groups", [ - "guid", - "group_name", - "adults", - "kids", - "vehicles" -], [ - "guid" => $_SESSION[user] -]); - -$adults = $database->select("tickets", [ - "id", - "first_name", - "last_name" -], [ - "ticket_type" => "a", - "guid" => $_SESSION[user], - "ORDER" => ["first_name"] -]); - -$kids = $database->select("tickets", [ - "id", - "first_name", - "last_name" -], [ - "ticket_type" => "k", - "guid" => $_SESSION[user], - "ORDER" => ["first_name"] -]); - -$vehicles = $database->select("tickets", [ - "id", - "vehicle_reg" -], [ - "ticket_type" => "v", - "guid" => $_SESSION[user], - "ORDER" => ["vehicle_reg"] -]); - -?> - -
-

- Ticket Management

-

Hi there! We've allocated you some tickets, please assign them to people so the we can get you on the correct guest lists...

- - -
-
-
-
Adults ( of )
-
-

-
"; -if (sizeof($adults) < $g[adults] ) - echo "
Add"; -?> -

-
-
-
-
-
-
-
Kids ( of )
-
-

-
"; -if (sizeof($kids) < $g[kids] ) - echo "
Add"; -?> -

-
-
-
-
-
-
Vehicles ( of )
-
-

-$v[vehicle_reg]
"; -if (sizeof($vehicles) < $g[vehicles] ) - echo "
Add"; -?> -

-
-
-
-
- - - -
- - - diff --git a/old/src/totals.php b/old/src/totals.php deleted file mode 100644 index 0e87fa1..0000000 --- a/old/src/totals.php +++ /dev/null @@ -1,67 +0,0 @@ -count("tickets", [ - "ticket_type" => "a" -]); -$kids_used = $database->count("tickets", [ - "ticket_type" => "k" -]); -$vehicles_used = $database->count("tickets", [ - "ticket_type" => "v" -]); - -$groups = $database->select("groups", [ - "adults", - "kids", - "vehicles" -]); - - -$adults_max = 0; -$kids_max = 0; -$vehicles_max = 0; - -foreach($groups as $g) -{ - $adults_max += $g[adults]; - $kids_max += $g[kids]; - $vehicles_max += $g[vehicles]; -} - -?> - -
-

Ticket totals

-
-
-
-
-
Adults
-
-

of

-
-
-
-
-
-
Kids
-
-

of

-
-
-
-
-
-
Vehicles
-
-

of

-
-
-
-
-
- - - diff --git a/terraform/s3.tf b/terraform/s3.tf index 2a4fa94..4e77ee5 100644 --- a/terraform/s3.tf +++ b/terraform/s3.tf @@ -42,4 +42,12 @@ resource "aws_s3_object" "this" { source = "${path.module}/public_html/${each.value}" etag = filemd5("${path.module}/public_html/${each.value}") content_type = lookup(local.mime_types, regex("\\.[^.]+$", each.value), null) +} + + +resource "aws_s3_object" "env" { + bucket = aws_s3_bucket.www.bucket + key = "accreditation/config.js.env" + content = "var config = { apiUrl: '${aws_api_gateway_deployment.this.invoke_url}' }" + content_type = "application/javascript" } \ No newline at end of file