diff --git a/.gitignore b/.gitignore
deleted file mode 100644
index 8d8c018..0000000
--- a/.gitignore
+++ /dev/null
@@ -1,7 +0,0 @@
-# Tmp
-/tmp/*
-
-# Misc
-/.vscode/
-/env/frx_workspace.code-workspace
-/docs/planning/
\ No newline at end of file
diff --git a/README.md b/README.md
index 184b6f5..bf5c5e7 100644
--- a/README.md
+++ b/README.md
@@ -1,4 +1,4 @@
-# FruxePi OPEN-PROTOTYPE v0.3-BETA
+# FruxePi OPEN-PROTOTYPE v0.5-BETA
A browser-based dashboard to monitor and automate indoor agriculture using the Raspberry Pi.

@@ -85,7 +85,7 @@ Run `sudo bash install.sh` to quickly install the application as well as Docker,

-#### Manual Installation
+#### Developers Installation
Besides the Docker installation, the FruxePi can also be manually installed and configured by following these [instructions](https://docs.fruxe.co/#/install?id=manual-installation-1). Good luck!
---
@@ -132,7 +132,7 @@ This project was built with the assistance of the following libraries and tools:
## Version
-### frx-pi-v0.3-BETA
+### frx-pi-v0.5-BETA
We use [SemVer](http://semver.org/) for versioning. For the versions available, see the [tags on this repository](https://github.com/fruxefarms/FruxePi/tags).
---
diff --git a/app/.htaccess b/app/.htaccess
deleted file mode 100644
index f725fc9..0000000
--- a/app/.htaccess
+++ /dev/null
@@ -1,4 +0,0 @@
-RewriteEngine on
-RewriteCond %{REQUEST_FILENAME} !-f
-RewriteCond %{REQUEST_FILENAME} !-d
-RewriteRule .* index.php?/$0 [PT,L]
\ No newline at end of file
diff --git a/app/actions/fruxepi.py b/app/actions/fruxepi.py
deleted file mode 100755
index cdce2d0..0000000
--- a/app/actions/fruxepi.py
+++ /dev/null
@@ -1,701 +0,0 @@
-#!/usr/bin/env python
-
-#FruxePi - CLI
-
-import os
-import sys
-import Adafruit_DHT as dht
-import RPi.GPIO as GPIO
-from datetime import datetime, date
-import time
-import pymysql
-import subprocess
-from time import strftime
-
-# Script Arguments
-action = None
-action_option = None
-action_GPIO = None
-action_interval = None
-
-
-# Database Credentials
-host = "db"
-user="frxpi"
-password="password"
-database="frx_db"
-
-
-# Script Argument Checker
-if len(sys.argv) == 6:
- action = sys.argv[1]
- action_option = sys.argv[2]
- action_GPIO = sys.argv[3]
- action_interval = sys.argv[4]
- relay_type = sys.argv[5]
-elif len(sys.argv) == 5:
- action = sys.argv[1]
- action_option = sys.argv[2]
- action_GPIO = sys.argv[3]
- action_interval = sys.argv[4]
-elif len(sys.argv) == 4:
- action = sys.argv[1]
- action_option = sys.argv[2]
- action_GPIO = sys.argv[3]
-elif len(sys.argv) == 3:
- action = sys.argv[1]
- action_option = sys.argv[2]
-
-
-# CLI Menu Function
-def CLI_menu():
- # Climate
- if action == "climate":
- # Return Temperature
- if action_option == "-t" and action_GPIO is not None:
- fetchTemperature(action_GPIO)
- # Return Raw Temperature
- elif action_option == "-tr" and action_GPIO is not None:
- fetchRawTemperature(action_GPIO)
- # Return Humidity
- elif action_option == "-h" and action_GPIO is not None:
- fetchHumidity(action_GPIO)
- # Return Raw Humidity
- elif action_option == "-hr" and action_GPIO is not None:
- fetchRawHumidity(action_GPIO)
- # Diagnostics
- elif action_option == "-d" and action_GPIO is not None:
- diagnosticsClimate(action_GPIO)
- else:
- print("Invalid Command!")
-
- # Lights
- elif action == "lights":
- # Lights ON
- if action_option == "-ON" and action_GPIO is not None:
- lightsON(action_GPIO, action_interval)
- # Lights OFF
- elif action_option == "-OFF" and action_GPIO is not None:
- lightsOFF(action_GPIO, action_interval)
- # Light Relay State
- elif action_option == "-s" and action_GPIO is not None:
- print(getRelayGPIOState(action_GPIO, action_interval))
- # Diagnostics
- elif action_option == "-d" and action_GPIO is not None:
- relayDiagnostics(action_GPIO, True)
- else:
- print("Invalid Command!")
-
- # Fan
- elif action == "fan":
- # Fan ON
- if action_option == "-ON" and action_GPIO is not None:
- fanON(action_GPIO, action_interval)
- # Fan OFF
- elif action_option == "-OFF" and action_GPIO is not None:
- fanOFF(action_GPIO, action_interval)
- # Fan Relay State
- elif action_option == "-s" and action_GPIO is not None:
- print(getRelayGPIOState(action_GPIO, action_interval))
- # Run Fan Program
- elif action_option == "-RUN" and action_GPIO is not None and action_interval is not None and relay_type is not None:
- fanProgram(action_GPIO, action_interval, relay_type)
- # Diagnostics
- elif action_option == "-d" and action_GPIO is not None:
- relayDiagnostics(action_GPIO, True)
- else:
- print("Invalid Command!")
-
- # Pump
- elif action == "pump":
- # Pump ON
- if action_option == "-ON" and action_GPIO is not None:
- pumpON(action_GPIO, action_interval)
- # Pump OFF
- elif action_option == "-OFF" and action_GPIO is not None:
- pumpOFF(action_GPIO, action_interval)
- # Pump Relay State
- elif action_option == "-s" and action_GPIO is not None:
- print(getRelayGPIOState(action_GPIO, action_interval))
- # Run Pump Program
- elif action_option == "-RUN" and action_GPIO is not None and action_interval is not None and relay_type is not None:
- pumpProgram(action_GPIO, action_interval, relay_type)
- # Diagnostics
- elif action_option == "-d" and action_GPIO is not None:
- relayDiagnostics(action_GPIO, True)
- else:
- print("Invalid Command!")
-
- # Moisture
- elif action == "moisture":
- # Get Moisture
- if action_option == "-m" and action_GPIO is not None:
- fetchMoisture(action_GPIO)
- # Pump Moisture Raw
- elif action_option == "-mr" and action_GPIO is not None:
- fetchRawMoisture(action_GPIO)
- # Moisture State
- elif action_option == "-s" and action_GPIO is not None:
- getGPIOState(action_GPIO)
- # Diagnostics
- elif action_option == "-d" and action_GPIO is not None:
- diagnosticsMoisture(action_GPIO)
- else:
- print("Invalid Command!")
-
- # Heater
- elif action == "heater":
- # Heater ON
- if action_option == "-ON" and action_GPIO is not None:
- heaterON(action_GPIO)
- # Heater OFF
- elif action_option == "-OFF" and action_GPIO is not None:
- heaterOFF(action_GPIO)
- # Heater Relay State
- elif action_option == "-s" and action_GPIO is not None:
- print(getGPIOState(action_GPIO))
- # Run Heater Program
- elif action_option == "-RUN" and action_GPIO is not None and action_interval is not None:
- heaterProgram(action_GPIO, action_interval)
- # Diagnostics
- elif action_option == "-d" and action_GPIO is not None:
- relayDiagnostics(action_GPIO)
- else:
- print("Invalid Command!")
-
- # Fetch Grow Data
- elif action == "update":
- # Update grow data
- if action_option == "-growdata":
- growData = getGrowData()
- growDataUpdate(growData)
- # Update chart
- elif action_option == "-chart":
- update_chart()
- else:
- print("Invalid Command!")
-
- # Maintenance
- elif action == "maint":
- # Cleanup old data from database
- if action_option == "-cleanup":
- deleteOldGrowData()
- else:
- print("Invalid Command!")
-
- # Camera
- elif action == "camera":
- # Capture Photo
- if action_option == "-capture":
- capturePhoto("candid")
- elif action_option == "-crop":
- capturePhoto("crop")
- # Diagnostics
- elif action_option == "-d":
- cameraDiagnostics()
- else:
- print("Invalid Command!")
-
- else:
- print("Invalid Command!")
-
-# Fetch Moisture
-def fetchMoisture(gpioPIN):
- try:
- # Set our GPIO numbering to BCM
- GPIO.setmode(GPIO.BCM)
- # Set the GPIO pin to an input
- GPIO.setup(int(gpioPIN), GPIO.IN)
- # Get Data
- status = GPIO.input(int(gpioPIN))
-
- if status is not None:
-
- if status == 0:
- print("Soil Dry")
- elif status == 1:
- print("Soil Moist")
-
- else:
- print('Failed to get reading. Try again!')
-
- except:
- print('Sensor Error!')
-
-# Fetch Moisture Raw
-def fetchRawMoisture(gpioPIN):
- try:
- # Set our GPIO numbering to BCM
- GPIO.setmode(GPIO.BCM)
-
- # Set the GPIO pin to an input
- GPIO.setup(int(gpioPIN), GPIO.IN)
-
- # Get Data
- status = GPIO.input(int(gpioPIN))
-
- if status is not None:
- print(status)
- else:
- print('Failed to get reading. Try again!')
-
- except:
- print('Sensor Error!')
-
-def diagnosticsMoisture(gpioPIN):
-
- try:
- # Set our GPIO numbering to BCM
- GPIO.setmode(GPIO.BCM)
-
- # Set the GPIO pin to an input
- GPIO.setup(int(gpioPIN), GPIO.IN)
-
- # Get Data
- status = GPIO.input(int(gpioPIN))
-
- if status == 0 or status == 1:
- print("All good - Moisture Sensor Operational!")
- else:
- print("Sensor Error!" + str(status))
-
- except:
- print("Sensor Error! Script")
-
-# Fetch Temperature
-def fetchTemperature(gpioPIN):
- try:
- humidity,temperature = dht.read_retry(dht.DHT22, int(gpioPIN))
-
- if temperature is not None:
- data_output = str(round(temperature, 2)) + "*C"
- print(data_output)
- return data_output
- else:
- print('Failed to get reading. Try again!')
- except:
- print("Sensor Error!")
-
-# Fetch Raw Temperature
-def fetchRawTemperature(gpioPIN):
- try:
- humidity,temperature = dht.read_retry(dht.DHT22, int(gpioPIN))
-
- if temperature is not None:
- data_output = round(temperature, 2)
- print(data_output)
- return data_output
- else:
- print('Failed to get reading. Try again!')
- except:
- print("Sensor Error!")
-
-# Fetch Humidity
-def fetchHumidity(gpioPIN):
- try:
- humidity,temperature = dht.read_retry(dht.DHT22, int(gpioPIN))
-
- if humidity is not None and humidity <= 100:
- data_output = str(round(humidity, 2)) + "%"
- print(data_output)
- return data_output
- else:
- print('Failed to get reading. Try again!')
- except:
- print("Sensor Error!")
-
-# Fetch Raw Humidity
-def fetchRawHumidity(gpioPIN):
- try:
- humidity,temperature = dht.read_retry(dht.DHT22, int(gpioPIN))
-
- if humidity is not None and humidity <= 100:
- data_output = round(humidity, 2)
- print(data_output)
- return data_output
- else:
- print('Failed to get reading. Try again!')
- except:
- print("Sensor Error!")
-
-
-def diagnosticsClimate(gpioPIN):
-
- try:
- humidity,temperature = dht.read_retry(dht.DHT22, int(gpioPIN))
-
- raw_temp = int(temperature)
- raw_humidity = int(humidity)
-
- if str(raw_temp).isdigit() == True and str(raw_humidity).isdigit() == True:
- print("All good - Climate Sensor Operational!")
- else:
- print("Sensor Error!")
-
- except:
- print("Sensor Error!")
-
-
-# Fan ON
-def fanON(gpioPIN, reverseRelay):
- print("Fan ON")
- if reverseRelay:
- os.system("gpio -g mode " + str(gpioPIN) + " out")
- os.system("gpio -g write " + str(gpioPIN) + " 0")
- else:
- os.system("gpio -g mode " + str(gpioPIN) + " out")
- os.system("gpio -g write " + str(gpioPIN) + " 1")
-
-# Fan OFF
-def fanOFF(gpioPIN, reverseRelay):
- print("Fan OFF")
- if reverseRelay:
- os.system("gpio -g mode " + str(gpioPIN) + " out")
- os.system("gpio -g write " + str(gpioPIN) + " 1")
- else:
- os.system("gpio -g mode " + str(gpioPIN) + " out")
- os.system("gpio -g write " + str(gpioPIN) + " 0")
-
-# Fetch fan threshold DB data
-def fetchFanThresholdDBData():
-
- # SQL query
- sql = "SELECT * FROM fan_schedule"
-
- # Connect to the database
- connection = pymysql.connect(host, user, password, database, charset='utf8mb4', cursorclass=pymysql.cursors.DictCursor)
-
- try:
- with connection.cursor() as cursor:
- # Fetch DB Query
- cursor.execute(sql)
- result = cursor.fetchall()
- finally:
- connection.close()
-
- # Output data
- data = {}
- data['temp'] = result[0]['fan_temp_threshold']
- data['humid'] = result[0]['fan_humid_threshold']
-
- return data
-
-
-# Check thresholds
-def checkThresholds(curTemperature, curHumidity):
-
- # get temperature Thresholds
- threshold_data = fetchFanThresholdDBData()
-
- # if curTemp or curHumidity exceed threshold
- if curTemperature > float(threshold_data['temp']) or curHumidity > float(threshold_data['humid']):
- return True
- else:
- return False
-
-
-
-# Fan run program
-def fanProgram(gpioPIN, timeInterval, reverseRelay):
-
- grow_room = getGrowData()
-
- if checkThresholds(float(grow_room['temperature']), float(grow_room['humidity'])):
- fanON(gpioPIN, reverseRelay)
- time.sleep(int(timeInterval))
- fanOFF(gpioPIN, reverseRelay)
-
-
-
-# Heater ON
-def heaterON(gpioPIN):
- print("Heater ON")
- os.system("gpio -g mode " + str(gpioPIN) + " out")
- os.system("gpio -g write " + str(gpioPIN) + " 1")
-
-# Heater OFF
-def heaterOFF(gpioPIN):
- print("Heater OFF")
- os.system("gpio -g mode " + str(gpioPIN) + " out")
- os.system("gpio -g write " + str(gpioPIN) + " 0")
-
-# Heater run program
-def heaterProgram(gpioPIN, timeInterval):
- heaterON(gpioPIN)
- time.sleep(int(timeInterval))
- heaterOFF(gpioPIN)
-
-# Lights ON
-def lightsON(gpioPIN, reverseRelay):
- print("Lights ON")
- if reverseRelay:
- os.system("gpio -g mode " + str(gpioPIN) + " out")
- os.system("gpio -g write " + str(gpioPIN) + " 0")
- else:
- os.system("gpio -g mode " + str(gpioPIN) + " out")
- os.system("gpio -g write " + str(gpioPIN) + " 1")
-
-# Lights OFF
-def lightsOFF(gpioPIN, reverseRelay):
- print("Lights OFF")
- if reverseRelay:
- os.system("gpio -g mode " + str(gpioPIN) + " out")
- os.system("gpio -g write " + str(gpioPIN) + " 1")
- else:
- os.system("gpio -g mode " + str(gpioPIN) + " out")
- os.system("gpio -g write " + str(gpioPIN) + " 0")
-
-# Pump ON
-def pumpON(gpioPIN, reverseRelay):
- print("Pump ON")
- if reverseRelay:
- os.system("gpio -g mode " + str(gpioPIN) + " out")
- os.system("gpio -g write " + str(gpioPIN) + " 0")
- else:
- os.system("gpio -g mode " + str(gpioPIN) + " out")
- os.system("gpio -g write " + str(gpioPIN) + " 1")
-
-# Pummp OFF
-def pumpOFF(gpioPIN, reverseRelay):
- print("Pump OFF")
- if reverseRelay:
- os.system("gpio -g mode " + str(gpioPIN) + " out")
- os.system("gpio -g write " + str(gpioPIN) + " 1")
- else:
- os.system("gpio -g mode " + str(gpioPIN) + " out")
- os.system("gpio -g write " + str(gpioPIN) + " 0")
-
-# Pump run program
-def pumpProgram(gpioPIN, timeInterval, reverseRelay):
- pumpON(gpioPIN, reverseRelay)
- time.sleep(int(timeInterval))
- pumpOFF(gpioPIN, reverseRelay)
-
-# Get GPIO state
-def getGPIOState(gpioPIN):
- state = os.popen("gpio -g read " + str(gpioPIN)).read()
-
- return state
-
-
-# Get Relay GPIO state
-def getRelayGPIOState(gpioPIN, reverseRelay):
- state = os.popen("gpio -g read " + str(gpioPIN)).read()
-
- if reverseRelay:
- if str(state[0]) == "1":
- return 0
- elif str(state[0]) == "0":
- return 1
- else:
- return state[0]
-
-# Relay diagnostics
-def relayDiagnostics(gpioPIN, reverseRelay):
- # Get GPIO status
- state = getGPIOState(int(gpioPIN))
-
- if reverseRelay == True:
- if str(state[0]) == "1":
- print("Relay State: 0")
- elif str(state[0]) == "0":
- print("Relay State: 1")
- else:
- print("Relay State: " + state)
-
-
-
-# Get list all sensor GPIO pins stored in DB
-def fetchSensorGPIO():
-
- # SQL query
- sql = "SELECT * FROM technical ORDER BY id ASC"
-
- # Connect to the database
- connection = pymysql.connect(host, user, password, database, charset='utf8mb4', cursorclass=pymysql.cursors.DictCursor)
-
- try:
- with connection.cursor() as cursor:
- # Fetch DB Query
- cursor.execute(sql)
- result = cursor.fetchall()
- finally:
- connection.close()
-
- # Format GPIO data for export
- data = {}
- data['climate_GPIO'] = result[0]['gpio_pin']
- data['moisture_GPIO'] = result[1]['gpio_pin']
- data['light_GPIO'] = result[2]['gpio_pin']
- data['fan_GPIO'] = result[3]['gpio_pin']
- data['pump_GPIO'] = result[4]['gpio_pin']
-
- return data
-
-def getGrowData():
-
- GPIO = fetchSensorGPIO()
-
- data = {}
- data['timestamp'] = strftime("%Y-%m-%d %H:%M:%S")
- data['temperature'] = fetchRawTemperature(GPIO['climate_GPIO'])
- data['humidity'] = fetchRawHumidity(GPIO['climate_GPIO'])
- data['light_status'] = getGPIOState(GPIO['light_GPIO'])
- data['moisture_status'] = getGPIOState(GPIO['moisture_GPIO'])
- data['fan_status'] = getGPIOState(GPIO['fan_GPIO'])
- data['pump_status'] = getGPIOState(GPIO['pump_GPIO'])
-
- print(data)
- return data
-
-def growDataUpdate(data):
-
- dbData = [data['timestamp'], data['temperature'], data['humidity'], data['light_status'], data['moisture_status'], data['fan_status'], data['pump_status']]
-
- db = pymysql.connect(host, user, password, database)
- cursor = db.cursor()
-
- try:
- cursor.execute("INSERT INTO grow_data (date_time, temperature, humidity, light_status, moisture_status, fan_status, pump_status) VALUES(%s, %s, %s, %s, %s, %s, %s)", dbData)
- db.commit()
- print("Grow Data Updated!")
- except:
- print("Database Error!")
- db.rollback()
- db.close()
-
-
-def deleteOldGrowData():
-
- # SQL query
- sql = "DELETE FROM grow_data WHERE date_time < CURDATE()"
-
- # Connect to the database
- connection = pymysql.connect(host, user, password, database, charset='utf8mb4', cursorclass=pymysql.cursors.DictCursor)
-
- try:
- with connection.cursor() as cursor:
- # Fetch DB Query
- cursor.execute(sql)
- connection.commit()
- print("Old Grow Data Deleted")
- except:
- print("Database deletion error. Delete not complete!")
- finally:
- connection.close()
-
-
-def takePhoto(imgPath, imgName):
- # Filepath
- filePath = str(imgPath) + str(imgName)
-
- # Take Photo
- os.system("raspistill -w 1920 -h 1720 -o " + filePath)
-
- return imgName
-
-
-def capturePhoto(usage):
-
- try:
-
- if usage == "crop":
- # Image Details
- imgName = "crop_bg.jpg"
- imgPath = "/var/www/html/assets/img/"
-
- # Filepath
- filePath = imgPath + imgName
-
- # Take photo
- os.system("raspistill -w 800 -h 600 -o " + filePath)
-
- elif usage == "candid":
- # Image Details
- timestamp = "{:%Y%m%d%H%M}".format(datetime.now())
- imgName = "FruxePi_capture_" + str(timestamp) + ".jpg"
- imgPath = "/var/www/html/assets/tmp/"
-
- # Take photo
- print(takePhoto(imgPath, imgName))
-
- else:
- # Image Details
- imgName = "crop_bg.jpg"
- imgPath = "/var/www/html/assets/img/"
-
- # Filepath
- filePath = imgPath + imgName
-
- # Take photo
- os.system("raspistill -w 800 -h 600 -o " + filePath)
-
- except:
- print("Camera Error!")
-
-
-def cameraDiagnostics():
- status = os.popen('vcgencmd get_camera').read()
- print(status)
-
-
-# Chart
-# Fetch from sql based on string
-def fetchData(sql):
-
- # Connect to the database
- connection = pymysql.connect(host,user,password,database,charset='utf8mb4',cursorclass=pymysql.cursors.DictCursor)
- try:
- with connection.cursor() as cursor:
- # Read a single record
- cursor.execute(sql)
- result = cursor.fetchone()
- return result
- finally:
- connection.close()
-
-
-# update chart history function
-def update_history(data):
-
- # Connect to the database
- connection = pymysql.connect(host,user,password,database,charset='utf8mb4',cursorclass=pymysql.cursors.DictCursor)
-
- try:
- with connection.cursor() as cursor:
- # Create a new record
- sql = "INSERT INTO climate_history (date_time, temperature, humidity) VALUES (%s, %s, %s)"
- cursor.execute(sql, (data['date_time'], round(data['temperature']), round(data['humidity'])))
-
- connection.commit()
- print("Success!")
- finally:
- connection.close()
-
-
-def fetch_history():
-
- tempQueryString = "SELECT AVG(temperature) as temperature, AVG(humidity) as humidity, date_time FROM grow_data WHERE date_time >= now() - interval 1 hour"
- tempData = fetchData(tempQueryString)
-
- return tempData
-
-
-# Update Chart
-def update_chart():
-
- try:
- # fetch chart data
- hourlyData = fetch_history()
-
- #update chart
- update_history(hourlyData)
-
- print("Chart Updated!")
- except Exception as e:
- print("Chart Update Error!")
- print(e)
-
-
-# RUN
-CLI_menu()
\ No newline at end of file
diff --git a/app/application/.htaccess b/app/application/.htaccess
deleted file mode 100755
index 6c63ed4..0000000
--- a/app/application/.htaccess
+++ /dev/null
@@ -1,6 +0,0 @@
-
- Require all denied
-
-
- Deny from all
-
\ No newline at end of file
diff --git a/app/application/cache/index.html b/app/application/cache/index.html
deleted file mode 100755
index b702fbc..0000000
--- a/app/application/cache/index.html
+++ /dev/null
@@ -1,11 +0,0 @@
-
-
-
- 403 Forbidden
-
-
-
-Directory access is forbidden.
-
-
-
diff --git a/app/application/config/autoload.php b/app/application/config/autoload.php
deleted file mode 100755
index 79bbaa2..0000000
--- a/app/application/config/autoload.php
+++ /dev/null
@@ -1,135 +0,0 @@
- 'ua');
-*/
-$autoload['libraries'] = array('database', 'email', 'session');
-
-/*
-| -------------------------------------------------------------------
-| Auto-load Drivers
-| -------------------------------------------------------------------
-| These classes are located in system/libraries/ or in your
-| application/libraries/ directory, but are also placed inside their
-| own subdirectory and they extend the CI_Driver_Library class. They
-| offer multiple interchangeable driver options.
-|
-| Prototype:
-|
-| $autoload['drivers'] = array('cache');
-|
-| You can also supply an alternative property name to be assigned in
-| the controller:
-|
-| $autoload['drivers'] = array('cache' => 'cch');
-|
-*/
-$autoload['drivers'] = array();
-
-/*
-| -------------------------------------------------------------------
-| Auto-load Helper Files
-| -------------------------------------------------------------------
-| Prototype:
-|
-| $autoload['helper'] = array('url', 'file');
-*/
-$autoload['helper'] = array('form', 'url', 'utility');
-
-/*
-| -------------------------------------------------------------------
-| Auto-load Config files
-| -------------------------------------------------------------------
-| Prototype:
-|
-| $autoload['config'] = array('config1', 'config2');
-|
-| NOTE: This item is intended for use ONLY if you have created custom
-| config files. Otherwise, leave it blank.
-|
-*/
-$autoload['config'] = array();
-
-/*
-| -------------------------------------------------------------------
-| Auto-load Language files
-| -------------------------------------------------------------------
-| Prototype:
-|
-| $autoload['language'] = array('lang1', 'lang2');
-|
-| NOTE: Do not include the "_lang" part of your file. For example
-| "codeigniter_lang.php" would be referenced as array('codeigniter');
-|
-*/
-$autoload['language'] = array();
-
-/*
-| -------------------------------------------------------------------
-| Auto-load Models
-| -------------------------------------------------------------------
-| Prototype:
-|
-| $autoload['model'] = array('first_model', 'second_model');
-|
-| You can also supply an alternative model name to be assigned
-| in the controller:
-|
-| $autoload['model'] = array('first_model' => 'first');
-*/
-$autoload['model'] = array();
diff --git a/app/application/config/config.php b/app/application/config/config.php
deleted file mode 100755
index 29a7a8a..0000000
--- a/app/application/config/config.php
+++ /dev/null
@@ -1,523 +0,0 @@
-]+$/i
-|
-| DO NOT CHANGE THIS UNLESS YOU FULLY UNDERSTAND THE REPERCUSSIONS!!
-|
-*/
-$config['permitted_uri_chars'] = 'a-z 0-9~%.:_\-';
-
-/*
-|--------------------------------------------------------------------------
-| Enable Query Strings
-|--------------------------------------------------------------------------
-|
-| By default CodeIgniter uses search-engine friendly segment based URLs:
-| example.com/who/what/where/
-|
-| You can optionally enable standard query string based URLs:
-| example.com?who=me&what=something&where=here
-|
-| Options are: TRUE or FALSE (boolean)
-|
-| The other items let you set the query string 'words' that will
-| invoke your controllers and its functions:
-| example.com/index.php?c=controller&m=function
-|
-| Please note that some of the helpers won't work as expected when
-| this feature is enabled, since CodeIgniter is designed primarily to
-| use segment based URLs.
-|
-*/
-$config['enable_query_strings'] = FALSE;
-$config['controller_trigger'] = 'c';
-$config['function_trigger'] = 'm';
-$config['directory_trigger'] = 'd';
-
-/*
-|--------------------------------------------------------------------------
-| Allow $_GET array
-|--------------------------------------------------------------------------
-|
-| By default CodeIgniter enables access to the $_GET array. If for some
-| reason you would like to disable it, set 'allow_get_array' to FALSE.
-|
-| WARNING: This feature is DEPRECATED and currently available only
-| for backwards compatibility purposes!
-|
-*/
-$config['allow_get_array'] = TRUE;
-
-/*
-|--------------------------------------------------------------------------
-| Error Logging Threshold
-|--------------------------------------------------------------------------
-|
-| You can enable error logging by setting a threshold over zero. The
-| threshold determines what gets logged. Threshold options are:
-|
-| 0 = Disables logging, Error logging TURNED OFF
-| 1 = Error Messages (including PHP errors)
-| 2 = Debug Messages
-| 3 = Informational Messages
-| 4 = All Messages
-|
-| You can also pass an array with threshold levels to show individual error types
-|
-| array(2) = Debug Messages, without Error Messages
-|
-| For a live site you'll usually only enable Errors (1) to be logged otherwise
-| your log files will fill up very fast.
-|
-*/
-$config['log_threshold'] = 0;
-
-/*
-|--------------------------------------------------------------------------
-| Error Logging Directory Path
-|--------------------------------------------------------------------------
-|
-| Leave this BLANK unless you would like to set something other than the default
-| application/logs/ directory. Use a full server path with trailing slash.
-|
-*/
-$config['log_path'] = '';
-
-/*
-|--------------------------------------------------------------------------
-| Log File Extension
-|--------------------------------------------------------------------------
-|
-| The default filename extension for log files. The default 'php' allows for
-| protecting the log files via basic scripting, when they are to be stored
-| under a publicly accessible directory.
-|
-| Note: Leaving it blank will default to 'php'.
-|
-*/
-$config['log_file_extension'] = '';
-
-/*
-|--------------------------------------------------------------------------
-| Log File Permissions
-|--------------------------------------------------------------------------
-|
-| The file system permissions to be applied on newly created log files.
-|
-| IMPORTANT: This MUST be an integer (no quotes) and you MUST use octal
-| integer notation (i.e. 0700, 0644, etc.)
-*/
-$config['log_file_permissions'] = 0644;
-
-/*
-|--------------------------------------------------------------------------
-| Date Format for Logs
-|--------------------------------------------------------------------------
-|
-| Each item that is logged has an associated date. You can use PHP date
-| codes to set your own date formatting
-|
-*/
-$config['log_date_format'] = 'Y-m-d H:i:s';
-
-/*
-|--------------------------------------------------------------------------
-| Error Views Directory Path
-|--------------------------------------------------------------------------
-|
-| Leave this BLANK unless you would like to set something other than the default
-| application/views/errors/ directory. Use a full server path with trailing slash.
-|
-*/
-$config['error_views_path'] = '';
-
-/*
-|--------------------------------------------------------------------------
-| Cache Directory Path
-|--------------------------------------------------------------------------
-|
-| Leave this BLANK unless you would like to set something other than the default
-| application/cache/ directory. Use a full server path with trailing slash.
-|
-*/
-$config['cache_path'] = '';
-
-/*
-|--------------------------------------------------------------------------
-| Cache Include Query String
-|--------------------------------------------------------------------------
-|
-| Whether to take the URL query string into consideration when generating
-| output cache files. Valid options are:
-|
-| FALSE = Disabled
-| TRUE = Enabled, take all query parameters into account.
-| Please be aware that this may result in numerous cache
-| files generated for the same page over and over again.
-| array('q') = Enabled, but only take into account the specified list
-| of query parameters.
-|
-*/
-$config['cache_query_string'] = FALSE;
-
-/*
-|--------------------------------------------------------------------------
-| Encryption Key
-|--------------------------------------------------------------------------
-|
-| If you use the Encryption class, you must set an encryption key.
-| See the user guide for more info.
-|
-| https://codeigniter.com/user_guide/libraries/encryption.html
-|
-*/
-$config['encryption_key'] = '';
-
-/*
-|--------------------------------------------------------------------------
-| Session Variables
-|--------------------------------------------------------------------------
-|
-| 'sess_driver'
-|
-| The storage driver to use: files, database, redis, memcached
-|
-| 'sess_cookie_name'
-|
-| The session cookie name, must contain only [0-9a-z_-] characters
-|
-| 'sess_expiration'
-|
-| The number of SECONDS you want the session to last.
-| Setting to 0 (zero) means expire when the browser is closed.
-|
-| 'sess_save_path'
-|
-| The location to save sessions to, driver dependent.
-|
-| For the 'files' driver, it's a path to a writable directory.
-| WARNING: Only absolute paths are supported!
-|
-| For the 'database' driver, it's a table name.
-| Please read up the manual for the format with other session drivers.
-|
-| IMPORTANT: You are REQUIRED to set a valid save path!
-|
-| 'sess_match_ip'
-|
-| Whether to match the user's IP address when reading the session data.
-|
-| WARNING: If you're using the database driver, don't forget to update
-| your session table's PRIMARY KEY when changing this setting.
-|
-| 'sess_time_to_update'
-|
-| How many seconds between CI regenerating the session ID.
-|
-| 'sess_regenerate_destroy'
-|
-| Whether to destroy session data associated with the old session ID
-| when auto-regenerating the session ID. When set to FALSE, the data
-| will be later deleted by the garbage collector.
-|
-| Other session cookie settings are shared with the rest of the application,
-| except for 'cookie_prefix' and 'cookie_httponly', which are ignored here.
-|
-*/
-$config['sess_driver'] = 'files';
-$config['sess_cookie_name'] = 'ci_session';
-$config['sess_expiration'] = 7200;
-$config['sess_save_path'] = sys_get_temp_dir();
-$config['sess_match_ip'] = FALSE;
-$config['sess_time_to_update'] = 300;
-$config['sess_regenerate_destroy'] = FALSE;
-
-/*
-|--------------------------------------------------------------------------
-| Cookie Related Variables
-|--------------------------------------------------------------------------
-|
-| 'cookie_prefix' = Set a cookie name prefix if you need to avoid collisions
-| 'cookie_domain' = Set to .your-domain.com for site-wide cookies
-| 'cookie_path' = Typically will be a forward slash
-| 'cookie_secure' = Cookie will only be set if a secure HTTPS connection exists.
-| 'cookie_httponly' = Cookie will only be accessible via HTTP(S) (no javascript)
-|
-| Note: These settings (with the exception of 'cookie_prefix' and
-| 'cookie_httponly') will also affect sessions.
-|
-*/
-$config['cookie_prefix'] = '';
-$config['cookie_domain'] = '';
-$config['cookie_path'] = '/';
-$config['cookie_secure'] = FALSE;
-$config['cookie_httponly'] = FALSE;
-
-/*
-|--------------------------------------------------------------------------
-| Standardize newlines
-|--------------------------------------------------------------------------
-|
-| Determines whether to standardize newline characters in input data,
-| meaning to replace \r\n, \r, \n occurrences with the PHP_EOL value.
-|
-| WARNING: This feature is DEPRECATED and currently available only
-| for backwards compatibility purposes!
-|
-*/
-$config['standardize_newlines'] = FALSE;
-
-/*
-|--------------------------------------------------------------------------
-| Global XSS Filtering
-|--------------------------------------------------------------------------
-|
-| Determines whether the XSS filter is always active when GET, POST or
-| COOKIE data is encountered
-|
-| WARNING: This feature is DEPRECATED and currently available only
-| for backwards compatibility purposes!
-|
-*/
-$config['global_xss_filtering'] = FALSE;
-
-/*
-|--------------------------------------------------------------------------
-| Cross Site Request Forgery
-|--------------------------------------------------------------------------
-| Enables a CSRF cookie token to be set. When set to TRUE, token will be
-| checked on a submitted form. If you are accepting user data, it is strongly
-| recommended CSRF protection be enabled.
-|
-| 'csrf_token_name' = The token name
-| 'csrf_cookie_name' = The cookie name
-| 'csrf_expire' = The number in seconds the token should expire.
-| 'csrf_regenerate' = Regenerate token on every submission
-| 'csrf_exclude_uris' = Array of URIs which ignore CSRF checks
-*/
-$config['csrf_protection'] = FALSE;
-$config['csrf_token_name'] = 'csrf_test_name';
-$config['csrf_cookie_name'] = 'csrf_cookie_name';
-$config['csrf_expire'] = 7200;
-$config['csrf_regenerate'] = TRUE;
-$config['csrf_exclude_uris'] = array();
-
-/*
-|--------------------------------------------------------------------------
-| Output Compression
-|--------------------------------------------------------------------------
-|
-| Enables Gzip output compression for faster page loads. When enabled,
-| the output class will test whether your server supports Gzip.
-| Even if it does, however, not all browsers support compression
-| so enable only if you are reasonably sure your visitors can handle it.
-|
-| Only used if zlib.output_compression is turned off in your php.ini.
-| Please do not use it together with httpd-level output compression.
-|
-| VERY IMPORTANT: If you are getting a blank page when compression is enabled it
-| means you are prematurely outputting something to your browser. It could
-| even be a line of whitespace at the end of one of your scripts. For
-| compression to work, nothing can be sent before the output buffer is called
-| by the output class. Do not 'echo' any values with compression enabled.
-|
-*/
-$config['compress_output'] = FALSE;
-
-/*
-|--------------------------------------------------------------------------
-| Master Time Reference
-|--------------------------------------------------------------------------
-|
-| Options are 'local' or any PHP supported timezone. This preference tells
-| the system whether to use your server's local time as the master 'now'
-| reference, or convert it to the configured one timezone. See the 'date
-| helper' page of the user guide for information regarding date handling.
-|
-*/
-$config['time_reference'] = 'local';
-
-/*
-|--------------------------------------------------------------------------
-| Rewrite PHP Short Tags
-|--------------------------------------------------------------------------
-|
-| If your PHP installation does not have short tag support enabled CI
-| can rewrite the tags on-the-fly, enabling you to utilize that syntax
-| in your view files. Options are TRUE or FALSE (boolean)
-|
-| Note: You need to have eval() enabled for this to work.
-|
-*/
-$config['rewrite_short_tags'] = FALSE;
-
-/*
-|--------------------------------------------------------------------------
-| Reverse Proxy IPs
-|--------------------------------------------------------------------------
-|
-| If your server is behind a reverse proxy, you must whitelist the proxy
-| IP addresses from which CodeIgniter should trust headers such as
-| HTTP_X_FORWARDED_FOR and HTTP_CLIENT_IP in order to properly identify
-| the visitor's IP address.
-|
-| You can use both an array or a comma-separated list of proxy addresses,
-| as well as specifying whole subnets. Here are a few examples:
-|
-| Comma-separated: '10.0.1.200,192.168.5.0/24'
-| Array: array('10.0.1.200', '192.168.5.0/24')
-*/
-$config['proxy_ips'] = '';
diff --git a/app/application/config/constants.php b/app/application/config/constants.php
deleted file mode 100755
index 18d3b4b..0000000
--- a/app/application/config/constants.php
+++ /dev/null
@@ -1,85 +0,0 @@
-db->last_query() and profiling of DB queries.
-| When you run a query, with this setting set to TRUE (default),
-| CodeIgniter will store the SQL statement for debugging purposes.
-| However, this may cause high memory usage, especially if you run
-| a lot of SQL queries ... disable this to avoid that problem.
-|
-| The $active_group variable lets you choose which connection group to
-| make active. By default there is only one group (the 'default' group).
-|
-| The $query_builder variables lets you determine whether or not to load
-| the query builder class.
-*/
-$active_group = 'default';
-$query_builder = TRUE;
-
-$db['default'] = array(
- 'dsn' => '',
- 'hostname' => 'db',
- 'username' => 'frxpi',
- 'password' => 'password',
- 'database' => 'frx_db',
- 'dbdriver' => 'mysqli',
- 'dbprefix' => '',
- 'pconnect' => FALSE,
- 'db_debug' => (ENVIRONMENT !== 'production'),
- 'cache_on' => FALSE,
- 'cachedir' => '',
- 'char_set' => 'utf8',
- 'dbcollat' => 'utf8_general_ci',
- 'swap_pre' => '',
- 'encrypt' => FALSE,
- 'compress' => FALSE,
- 'stricton' => FALSE,
- 'failover' => array(),
- 'save_queries' => TRUE
-);
diff --git a/app/application/config/doctypes.php b/app/application/config/doctypes.php
deleted file mode 100755
index 59a7991..0000000
--- a/app/application/config/doctypes.php
+++ /dev/null
@@ -1,24 +0,0 @@
- '',
- 'xhtml1-strict' => '',
- 'xhtml1-trans' => '',
- 'xhtml1-frame' => '',
- 'xhtml-basic11' => '',
- 'html5' => '',
- 'html4-strict' => '',
- 'html4-trans' => '',
- 'html4-frame' => '',
- 'mathml1' => '',
- 'mathml2' => '',
- 'svg10' => '',
- 'svg11' => '',
- 'svg11-basic' => '',
- 'svg11-tiny' => '',
- 'xhtml-math-svg-xh' => '',
- 'xhtml-math-svg-sh' => '',
- 'xhtml-rdfa-1' => '',
- 'xhtml-rdfa-2' => ''
-);
diff --git a/app/application/config/foreign_chars.php b/app/application/config/foreign_chars.php
deleted file mode 100755
index 995f483..0000000
--- a/app/application/config/foreign_chars.php
+++ /dev/null
@@ -1,103 +0,0 @@
- 'ae',
- '/ö|œ/' => 'oe',
- '/ü/' => 'ue',
- '/Ä/' => 'Ae',
- '/Ü/' => 'Ue',
- '/Ö/' => 'Oe',
- '/À|Á|Â|Ã|Ä|Å|Ǻ|Ā|Ă|Ą|Ǎ|Α|Ά|Ả|Ạ|Ầ|Ẫ|Ẩ|Ậ|Ằ|Ắ|Ẵ|Ẳ|Ặ|А/' => 'A',
- '/à|á|â|ã|å|ǻ|ā|ă|ą|ǎ|ª|α|ά|ả|ạ|ầ|ấ|ẫ|ẩ|ậ|ằ|ắ|ẵ|ẳ|ặ|а/' => 'a',
- '/Б/' => 'B',
- '/б/' => 'b',
- '/Ç|Ć|Ĉ|Ċ|Č/' => 'C',
- '/ç|ć|ĉ|ċ|č/' => 'c',
- '/Д/' => 'D',
- '/д/' => 'd',
- '/Ð|Ď|Đ|Δ/' => 'Dj',
- '/ð|ď|đ|δ/' => 'dj',
- '/È|É|Ê|Ë|Ē|Ĕ|Ė|Ę|Ě|Ε|Έ|Ẽ|Ẻ|Ẹ|Ề|Ế|Ễ|Ể|Ệ|Е|Э/' => 'E',
- '/è|é|ê|ë|ē|ĕ|ė|ę|ě|έ|ε|ẽ|ẻ|ẹ|ề|ế|ễ|ể|ệ|е|э/' => 'e',
- '/Ф/' => 'F',
- '/ф/' => 'f',
- '/Ĝ|Ğ|Ġ|Ģ|Γ|Г|Ґ/' => 'G',
- '/ĝ|ğ|ġ|ģ|γ|г|ґ/' => 'g',
- '/Ĥ|Ħ/' => 'H',
- '/ĥ|ħ/' => 'h',
- '/Ì|Í|Î|Ï|Ĩ|Ī|Ĭ|Ǐ|Į|İ|Η|Ή|Ί|Ι|Ϊ|Ỉ|Ị|И|Ы/' => 'I',
- '/ì|í|î|ï|ĩ|ī|ĭ|ǐ|į|ı|η|ή|ί|ι|ϊ|ỉ|ị|и|ы|ї/' => 'i',
- '/Ĵ/' => 'J',
- '/ĵ/' => 'j',
- '/Ķ|Κ|К/' => 'K',
- '/ķ|κ|к/' => 'k',
- '/Ĺ|Ļ|Ľ|Ŀ|Ł|Λ|Л/' => 'L',
- '/ĺ|ļ|ľ|ŀ|ł|λ|л/' => 'l',
- '/М/' => 'M',
- '/м/' => 'm',
- '/Ñ|Ń|Ņ|Ň|Ν|Н/' => 'N',
- '/ñ|ń|ņ|ň|ʼn|ν|н/' => 'n',
- '/Ò|Ó|Ô|Õ|Ō|Ŏ|Ǒ|Ő|Ơ|Ø|Ǿ|Ο|Ό|Ω|Ώ|Ỏ|Ọ|Ồ|Ố|Ỗ|Ổ|Ộ|Ờ|Ớ|Ỡ|Ở|Ợ|О/' => 'O',
- '/ò|ó|ô|õ|ō|ŏ|ǒ|ő|ơ|ø|ǿ|º|ο|ό|ω|ώ|ỏ|ọ|ồ|ố|ỗ|ổ|ộ|ờ|ớ|ỡ|ở|ợ|о/' => 'o',
- '/П/' => 'P',
- '/п/' => 'p',
- '/Ŕ|Ŗ|Ř|Ρ|Р/' => 'R',
- '/ŕ|ŗ|ř|ρ|р/' => 'r',
- '/Ś|Ŝ|Ş|Ș|Š|Σ|С/' => 'S',
- '/ś|ŝ|ş|ș|š|ſ|σ|ς|с/' => 's',
- '/Ț|Ţ|Ť|Ŧ|τ|Т/' => 'T',
- '/ț|ţ|ť|ŧ|т/' => 't',
- '/Þ|þ/' => 'th',
- '/Ù|Ú|Û|Ũ|Ū|Ŭ|Ů|Ű|Ų|Ư|Ǔ|Ǖ|Ǘ|Ǚ|Ǜ|Ũ|Ủ|Ụ|Ừ|Ứ|Ữ|Ử|Ự|У/' => 'U',
- '/ù|ú|û|ũ|ū|ŭ|ů|ű|ų|ư|ǔ|ǖ|ǘ|ǚ|ǜ|υ|ύ|ϋ|ủ|ụ|ừ|ứ|ữ|ử|ự|у/' => 'u',
- '/Ƴ|Ɏ|Ỵ|Ẏ|Ӳ|Ӯ|Ў|Ý|Ÿ|Ŷ|Υ|Ύ|Ϋ|Ỳ|Ỹ|Ỷ|Ỵ|Й/' => 'Y',
- '/ẙ|ʏ|ƴ|ɏ|ỵ|ẏ|ӳ|ӯ|ў|ý|ÿ|ŷ|ỳ|ỹ|ỷ|ỵ|й/' => 'y',
- '/В/' => 'V',
- '/в/' => 'v',
- '/Ŵ/' => 'W',
- '/ŵ/' => 'w',
- '/Ź|Ż|Ž|Ζ|З/' => 'Z',
- '/ź|ż|ž|ζ|з/' => 'z',
- '/Æ|Ǽ/' => 'AE',
- '/ß/' => 'ss',
- '/IJ/' => 'IJ',
- '/ij/' => 'ij',
- '/Œ/' => 'OE',
- '/ƒ/' => 'f',
- '/ξ/' => 'ks',
- '/π/' => 'p',
- '/β/' => 'v',
- '/μ/' => 'm',
- '/ψ/' => 'ps',
- '/Ё/' => 'Yo',
- '/ё/' => 'yo',
- '/Є/' => 'Ye',
- '/є/' => 'ye',
- '/Ї/' => 'Yi',
- '/Ж/' => 'Zh',
- '/ж/' => 'zh',
- '/Х/' => 'Kh',
- '/х/' => 'kh',
- '/Ц/' => 'Ts',
- '/ц/' => 'ts',
- '/Ч/' => 'Ch',
- '/ч/' => 'ch',
- '/Ш/' => 'Sh',
- '/ш/' => 'sh',
- '/Щ/' => 'Shch',
- '/щ/' => 'shch',
- '/Ъ|ъ|Ь|ь/' => '',
- '/Ю/' => 'Yu',
- '/ю/' => 'yu',
- '/Я/' => 'Ya',
- '/я/' => 'ya'
-);
diff --git a/app/application/config/hooks.php b/app/application/config/hooks.php
deleted file mode 100755
index a8f38a5..0000000
--- a/app/application/config/hooks.php
+++ /dev/null
@@ -1,13 +0,0 @@
-
-
-
- 403 Forbidden
-
-
-
-Directory access is forbidden.
-
-
-
diff --git a/app/application/config/ion_auth.php b/app/application/config/ion_auth.php
deleted file mode 100755
index 73f3f66..0000000
--- a/app/application/config/ion_auth.php
+++ /dev/null
@@ -1,197 +0,0 @@
-ion_auth->is_max_login_attempts_exceeded().
- | The controller should check this function and act
- | appropriately. If this variable set to 0, there is no maximum.
- */
-$config['site_title'] = "Example.com"; // Site Title, example.com
-$config['admin_email'] = "admin@example.com"; // Admin Email, admin@example.com
-$config['default_group'] = 'members'; // Default group, use name
-$config['admin_group'] = 'admin'; // Default administrators group, use name
-$config['identity'] = 'email'; // You can use any unique column in your table as identity column. The values in this column, alongside password, will be used for login purposes
-$config['min_password_length'] = 8; // Minimum Required Length of Password
-$config['max_password_length'] = 20; // Maximum Allowed Length of Password
-$config['email_activation'] = FALSE; // Email Activation for registration
-$config['manual_activation'] = FALSE; // Manual Activation for registration
-$config['remember_users'] = TRUE; // Allow users to be remembered and enable auto-login
-$config['user_expire'] = 0; // How long to remember the user (seconds). Set to zero for no expiration
-$config['user_extend_on_login'] = FALSE; // Extend the users cookies every time they auto-login
-$config['track_login_attempts'] = TRUE; // Track the number of failed login attempts for each user or ip.
-$config['track_login_ip_address'] = TRUE; // Track login attempts by IP Address, if FALSE will track based on identity. (Default: TRUE)
-$config['maximum_login_attempts'] = 3; // The maximum number of failed login attempts.
-$config['lockout_time'] = 600; /* The number of seconds to lockout an account due to exceeded attempts
- You should not use a value below 60 (1 minute) */
-$config['forgot_password_expiration'] = 0; // The number of seconds after which a forgot password request will expire. If set to 0, forgot password requests will not expire.
-$config['recheck_timer'] = 0; /* The number of seconds after which the session is checked again against database to see if the user still exists and is active.
- Leave 0 if you don't want session recheck. if you really think you need to recheck the session against database, we would
- recommend a higher value, as this would affect performance */
-
-/*
- | -------------------------------------------------------------------------
- | Cookie options.
- | -------------------------------------------------------------------------
- | remember_cookie_name Default: remember_code
- | identity_cookie_name Default: identity
- */
-$config['remember_cookie_name'] = 'remember_code';
-$config['identity_cookie_name'] = 'identity';
-
-/*
- | -------------------------------------------------------------------------
- | Email options.
- | -------------------------------------------------------------------------
- | email_config:
- | 'file' = Use the default CI config or use from a config file
- | array = Manually set your email config settings
- */
-$config['use_ci_email'] = FALSE; // Send Email using the builtin CI email class, if false it will return the code and the identity
-$config['email_config'] = array(
- 'mailtype' => 'html',
-);
-
-/*
- | -------------------------------------------------------------------------
- | Email templates.
- | -------------------------------------------------------------------------
- | Folder where email templates are stored.
- | Default: auth/
- */
-$config['email_templates'] = 'auth/email/';
-
-/*
- | -------------------------------------------------------------------------
- | Activate Account Email Template
- | -------------------------------------------------------------------------
- | Default: activate.tpl.php
- */
-$config['email_activate'] = 'activate.tpl.php';
-
-/*
- | -------------------------------------------------------------------------
- | Forgot Password Email Template
- | -------------------------------------------------------------------------
- | Default: forgot_password.tpl.php
- */
-$config['email_forgot_password'] = 'forgot_password.tpl.php';
-
-/*
- | -------------------------------------------------------------------------
- | Forgot Password Complete Email Template
- | -------------------------------------------------------------------------
- | Default: new_password.tpl.php
- */
-$config['email_forgot_password_complete'] = 'new_password.tpl.php';
-
-/*
- | -------------------------------------------------------------------------
- | Salt options
- | -------------------------------------------------------------------------
- | salt_length Default: 22
- |
- | store_salt: Should the salt be stored in the database?
- | This will change your password encryption algorithm,
- | default password, 'password', changes to
- | fbaa5e216d163a02ae630ab1a43372635dd374c0 with default salt.
- */
-$config['salt_length'] = 22;
-$config['store_salt'] = FALSE;
-
-/*
- | -------------------------------------------------------------------------
- | Message Delimiters.
- | -------------------------------------------------------------------------
- */
-$config['delimiters_source'] = 'config'; // "config" = use the settings defined here, "form_validation" = use the settings defined in CI's form validation library
-$config['message_start_delimiter'] = ''; // Message start delimiter
-$config['message_end_delimiter'] = '
'; // Message end delimiter
-$config['error_start_delimiter'] = ''; // Error message start delimiter
-$config['error_end_delimiter'] = '
'; // Error message end delimiter
diff --git a/app/application/config/memcached.php b/app/application/config/memcached.php
deleted file mode 100755
index 5c23b39..0000000
--- a/app/application/config/memcached.php
+++ /dev/null
@@ -1,19 +0,0 @@
- array(
- 'hostname' => '127.0.0.1',
- 'port' => '11211',
- 'weight' => '1',
- ),
-);
diff --git a/app/application/config/migration.php b/app/application/config/migration.php
deleted file mode 100755
index 4b585a6..0000000
--- a/app/application/config/migration.php
+++ /dev/null
@@ -1,84 +0,0 @@
-migration->current() this is the version that schema will
-| be upgraded / downgraded to.
-|
-*/
-$config['migration_version'] = 0;
-
-/*
-|--------------------------------------------------------------------------
-| Migrations Path
-|--------------------------------------------------------------------------
-|
-| Path to your migrations folder.
-| Typically, it will be within your application path.
-| Also, writing permission is required within the migrations path.
-|
-*/
-$config['migration_path'] = APPPATH.'migrations/';
diff --git a/app/application/config/mimes.php b/app/application/config/mimes.php
deleted file mode 100755
index 0ec9db0..0000000
--- a/app/application/config/mimes.php
+++ /dev/null
@@ -1,184 +0,0 @@
- array('application/mac-binhex40', 'application/mac-binhex', 'application/x-binhex40', 'application/x-mac-binhex40'),
- 'cpt' => 'application/mac-compactpro',
- 'csv' => array('text/x-comma-separated-values', 'text/comma-separated-values', 'application/octet-stream', 'application/vnd.ms-excel', 'application/x-csv', 'text/x-csv', 'text/csv', 'application/csv', 'application/excel', 'application/vnd.msexcel', 'text/plain'),
- 'bin' => array('application/macbinary', 'application/mac-binary', 'application/octet-stream', 'application/x-binary', 'application/x-macbinary'),
- 'dms' => 'application/octet-stream',
- 'lha' => 'application/octet-stream',
- 'lzh' => 'application/octet-stream',
- 'exe' => array('application/octet-stream', 'application/x-msdownload'),
- 'class' => 'application/octet-stream',
- 'psd' => array('application/x-photoshop', 'image/vnd.adobe.photoshop'),
- 'so' => 'application/octet-stream',
- 'sea' => 'application/octet-stream',
- 'dll' => 'application/octet-stream',
- 'oda' => 'application/oda',
- 'pdf' => array('application/pdf', 'application/force-download', 'application/x-download', 'binary/octet-stream'),
- 'ai' => array('application/pdf', 'application/postscript'),
- 'eps' => 'application/postscript',
- 'ps' => 'application/postscript',
- 'smi' => 'application/smil',
- 'smil' => 'application/smil',
- 'mif' => 'application/vnd.mif',
- 'xls' => array('application/vnd.ms-excel', 'application/msexcel', 'application/x-msexcel', 'application/x-ms-excel', 'application/x-excel', 'application/x-dos_ms_excel', 'application/xls', 'application/x-xls', 'application/excel', 'application/download', 'application/vnd.ms-office', 'application/msword'),
- 'ppt' => array('application/powerpoint', 'application/vnd.ms-powerpoint', 'application/vnd.ms-office', 'application/msword'),
- 'pptx' => array('application/vnd.openxmlformats-officedocument.presentationml.presentation', 'application/x-zip', 'application/zip'),
- 'wbxml' => 'application/wbxml',
- 'wmlc' => 'application/wmlc',
- 'dcr' => 'application/x-director',
- 'dir' => 'application/x-director',
- 'dxr' => 'application/x-director',
- 'dvi' => 'application/x-dvi',
- 'gtar' => 'application/x-gtar',
- 'gz' => 'application/x-gzip',
- 'gzip' => 'application/x-gzip',
- 'php' => array('application/x-httpd-php', 'application/php', 'application/x-php', 'text/php', 'text/x-php', 'application/x-httpd-php-source'),
- 'php4' => 'application/x-httpd-php',
- 'php3' => 'application/x-httpd-php',
- 'phtml' => 'application/x-httpd-php',
- 'phps' => 'application/x-httpd-php-source',
- 'js' => array('application/x-javascript', 'text/plain'),
- 'swf' => 'application/x-shockwave-flash',
- 'sit' => 'application/x-stuffit',
- 'tar' => 'application/x-tar',
- 'tgz' => array('application/x-tar', 'application/x-gzip-compressed'),
- 'z' => 'application/x-compress',
- 'xhtml' => 'application/xhtml+xml',
- 'xht' => 'application/xhtml+xml',
- 'zip' => array('application/x-zip', 'application/zip', 'application/x-zip-compressed', 'application/s-compressed', 'multipart/x-zip'),
- 'rar' => array('application/x-rar', 'application/rar', 'application/x-rar-compressed'),
- 'mid' => 'audio/midi',
- 'midi' => 'audio/midi',
- 'mpga' => 'audio/mpeg',
- 'mp2' => 'audio/mpeg',
- 'mp3' => array('audio/mpeg', 'audio/mpg', 'audio/mpeg3', 'audio/mp3'),
- 'aif' => array('audio/x-aiff', 'audio/aiff'),
- 'aiff' => array('audio/x-aiff', 'audio/aiff'),
- 'aifc' => 'audio/x-aiff',
- 'ram' => 'audio/x-pn-realaudio',
- 'rm' => 'audio/x-pn-realaudio',
- 'rpm' => 'audio/x-pn-realaudio-plugin',
- 'ra' => 'audio/x-realaudio',
- 'rv' => 'video/vnd.rn-realvideo',
- 'wav' => array('audio/x-wav', 'audio/wave', 'audio/wav'),
- 'bmp' => array('image/bmp', 'image/x-bmp', 'image/x-bitmap', 'image/x-xbitmap', 'image/x-win-bitmap', 'image/x-windows-bmp', 'image/ms-bmp', 'image/x-ms-bmp', 'application/bmp', 'application/x-bmp', 'application/x-win-bitmap'),
- 'gif' => 'image/gif',
- 'jpeg' => array('image/jpeg', 'image/pjpeg'),
- 'jpg' => array('image/jpeg', 'image/pjpeg'),
- 'jpe' => array('image/jpeg', 'image/pjpeg'),
- 'jp2' => array('image/jp2', 'video/mj2', 'image/jpx', 'image/jpm'),
- 'j2k' => array('image/jp2', 'video/mj2', 'image/jpx', 'image/jpm'),
- 'jpf' => array('image/jp2', 'video/mj2', 'image/jpx', 'image/jpm'),
- 'jpg2' => array('image/jp2', 'video/mj2', 'image/jpx', 'image/jpm'),
- 'jpx' => array('image/jp2', 'video/mj2', 'image/jpx', 'image/jpm'),
- 'jpm' => array('image/jp2', 'video/mj2', 'image/jpx', 'image/jpm'),
- 'mj2' => array('image/jp2', 'video/mj2', 'image/jpx', 'image/jpm'),
- 'mjp2' => array('image/jp2', 'video/mj2', 'image/jpx', 'image/jpm'),
- 'png' => array('image/png', 'image/x-png'),
- 'tiff' => 'image/tiff',
- 'tif' => 'image/tiff',
- 'css' => array('text/css', 'text/plain'),
- 'html' => array('text/html', 'text/plain'),
- 'htm' => array('text/html', 'text/plain'),
- 'shtml' => array('text/html', 'text/plain'),
- 'txt' => 'text/plain',
- 'text' => 'text/plain',
- 'log' => array('text/plain', 'text/x-log'),
- 'rtx' => 'text/richtext',
- 'rtf' => 'text/rtf',
- 'xml' => array('application/xml', 'text/xml', 'text/plain'),
- 'xsl' => array('application/xml', 'text/xsl', 'text/xml'),
- 'mpeg' => 'video/mpeg',
- 'mpg' => 'video/mpeg',
- 'mpe' => 'video/mpeg',
- 'qt' => 'video/quicktime',
- 'mov' => 'video/quicktime',
- 'avi' => array('video/x-msvideo', 'video/msvideo', 'video/avi', 'application/x-troff-msvideo'),
- 'movie' => 'video/x-sgi-movie',
- 'doc' => array('application/msword', 'application/vnd.ms-office'),
- 'docx' => array('application/vnd.openxmlformats-officedocument.wordprocessingml.document', 'application/zip', 'application/msword', 'application/x-zip'),
- 'dot' => array('application/msword', 'application/vnd.ms-office'),
- 'dotx' => array('application/vnd.openxmlformats-officedocument.wordprocessingml.document', 'application/zip', 'application/msword'),
- 'xlsx' => array('application/vnd.openxmlformats-officedocument.spreadsheetml.sheet', 'application/zip', 'application/vnd.ms-excel', 'application/msword', 'application/x-zip'),
- 'word' => array('application/msword', 'application/octet-stream'),
- 'xl' => 'application/excel',
- 'eml' => 'message/rfc822',
- 'json' => array('application/json', 'text/json'),
- 'pem' => array('application/x-x509-user-cert', 'application/x-pem-file', 'application/octet-stream'),
- 'p10' => array('application/x-pkcs10', 'application/pkcs10'),
- 'p12' => 'application/x-pkcs12',
- 'p7a' => 'application/x-pkcs7-signature',
- 'p7c' => array('application/pkcs7-mime', 'application/x-pkcs7-mime'),
- 'p7m' => array('application/pkcs7-mime', 'application/x-pkcs7-mime'),
- 'p7r' => 'application/x-pkcs7-certreqresp',
- 'p7s' => 'application/pkcs7-signature',
- 'crt' => array('application/x-x509-ca-cert', 'application/x-x509-user-cert', 'application/pkix-cert'),
- 'crl' => array('application/pkix-crl', 'application/pkcs-crl'),
- 'der' => 'application/x-x509-ca-cert',
- 'kdb' => 'application/octet-stream',
- 'pgp' => 'application/pgp',
- 'gpg' => 'application/gpg-keys',
- 'sst' => 'application/octet-stream',
- 'csr' => 'application/octet-stream',
- 'rsa' => 'application/x-pkcs7',
- 'cer' => array('application/pkix-cert', 'application/x-x509-ca-cert'),
- '3g2' => 'video/3gpp2',
- '3gp' => array('video/3gp', 'video/3gpp'),
- 'mp4' => 'video/mp4',
- 'm4a' => 'audio/x-m4a',
- 'f4v' => array('video/mp4', 'video/x-f4v'),
- 'flv' => 'video/x-flv',
- 'webm' => 'video/webm',
- 'aac' => 'audio/x-acc',
- 'm4u' => 'application/vnd.mpegurl',
- 'm3u' => 'text/plain',
- 'xspf' => 'application/xspf+xml',
- 'vlc' => 'application/videolan',
- 'wmv' => array('video/x-ms-wmv', 'video/x-ms-asf'),
- 'au' => 'audio/x-au',
- 'ac3' => 'audio/ac3',
- 'flac' => 'audio/x-flac',
- 'ogg' => array('audio/ogg', 'video/ogg', 'application/ogg'),
- 'kmz' => array('application/vnd.google-earth.kmz', 'application/zip', 'application/x-zip'),
- 'kml' => array('application/vnd.google-earth.kml+xml', 'application/xml', 'text/xml'),
- 'ics' => 'text/calendar',
- 'ical' => 'text/calendar',
- 'zsh' => 'text/x-scriptzsh',
- '7z' => array('application/x-7z-compressed', 'application/x-compressed', 'application/x-zip-compressed', 'application/zip', 'multipart/x-zip'),
- '7zip' => array('application/x-7z-compressed', 'application/x-compressed', 'application/x-zip-compressed', 'application/zip', 'multipart/x-zip'),
- 'cdr' => array('application/cdr', 'application/coreldraw', 'application/x-cdr', 'application/x-coreldraw', 'image/cdr', 'image/x-cdr', 'zz-application/zz-winassoc-cdr'),
- 'wma' => array('audio/x-ms-wma', 'video/x-ms-asf'),
- 'jar' => array('application/java-archive', 'application/x-java-application', 'application/x-jar', 'application/x-compressed'),
- 'svg' => array('image/svg+xml', 'application/xml', 'text/xml'),
- 'vcf' => 'text/x-vcard',
- 'srt' => array('text/srt', 'text/plain'),
- 'vtt' => array('text/vtt', 'text/plain'),
- 'ico' => array('image/x-icon', 'image/x-ico', 'image/vnd.microsoft.icon'),
- 'odc' => 'application/vnd.oasis.opendocument.chart',
- 'otc' => 'application/vnd.oasis.opendocument.chart-template',
- 'odf' => 'application/vnd.oasis.opendocument.formula',
- 'otf' => 'application/vnd.oasis.opendocument.formula-template',
- 'odg' => 'application/vnd.oasis.opendocument.graphics',
- 'otg' => 'application/vnd.oasis.opendocument.graphics-template',
- 'odi' => 'application/vnd.oasis.opendocument.image',
- 'oti' => 'application/vnd.oasis.opendocument.image-template',
- 'odp' => 'application/vnd.oasis.opendocument.presentation',
- 'otp' => 'application/vnd.oasis.opendocument.presentation-template',
- 'ods' => 'application/vnd.oasis.opendocument.spreadsheet',
- 'ots' => 'application/vnd.oasis.opendocument.spreadsheet-template',
- 'odt' => 'application/vnd.oasis.opendocument.text',
- 'odm' => 'application/vnd.oasis.opendocument.text-master',
- 'ott' => 'application/vnd.oasis.opendocument.text-template',
- 'oth' => 'application/vnd.oasis.opendocument.text-web'
-);
diff --git a/app/application/config/profiler.php b/app/application/config/profiler.php
deleted file mode 100755
index 3db22e3..0000000
--- a/app/application/config/profiler.php
+++ /dev/null
@@ -1,14 +0,0 @@
- my_controller/index
-| my-controller/my-method -> my_controller/my_method
-*/
-$route['default_controller'] = 'dashboard';
-$route['404_override'] = '';
-$route['translate_uri_dashes'] = FALSE;
-
-// Auth
-$route['login'] = 'auth/login';
-$route['logout'] = 'auth/logout';
-
-// Users
-$route['users'] = 'auth/index';
-$route['user/edit/(:num)'] = 'auth/edit_user/$1';
-$route['user/delete/(:num)'] = 'auth/delete_user/$1';
-$route['reset'] = 'dashboard/reset';
-
-// Dashboard
-$route['dashboard'] = 'dashboard/index';
-$route['dashboard/settings'] = 'dashboard/editGrowRoomSettings';
-
-// Crop
-$route['crop'] = 'crop/index';
-$route['crop/new'] = 'crop/createCrop';
-$route['crop/edit/(:any)'] = 'crop/editCrop/$1';
-$route['crop/delete/(:any)'] = 'crop/deleteCrop/$1';
-
-// Crop Activity
-$route['crop/activity/new'] = 'crop/addCropActivityEntry';
-$route['crop/activity/edit/(:any)'] = 'crop/editCropActivityEntry/$1';
-$route['crop/activity/delete/(:any)'] = 'crop/deleteCropActivityEntry/$1';
-
-// Technical
-$route['technical'] = 'sensors/index';
-
-// Climate
-$route['technical/climate'] = 'sensors/climateSettings';
-$route['technical/climate/enable'] = 'sensors/enableClimateSensor';
-$route['technical/climate/disable'] = 'sensors/disableClimateSensor';
-$route['technical/climate/edit/GPIO'] = 'sensors/editClimateGPIO';
-$route['technical/climate/edit/format'] = 'sensors/editTemperatureFormat';
-$route['technical/climate/diagnostics'] = 'sensors/climateDiagnostics';
-
-// Lights
-$route['technical/lights'] = 'sensors/lightSettings';
-$route['technical/lights/ON'] = 'sensors/lightsON';
-$route['technical/lights/OFF'] = 'sensors/lightsOFF';
-$route['technical/lights/enable'] = 'sensors/enableLights';
-$route['technical/lights/disable'] = 'sensors/disableLights';
-$route['technical/lights/edit/settings'] = 'sensors/editLightsSettings';
-$route['technical/lights/edit/schedule'] = 'sensors/editLightSchedule';
-$route['technical/lights/diagnostics'] = 'sensors/lightsDiagnostics';
-
-// Fans
-$route['technical/fans'] = 'sensors/fanSettings';
-$route['technical/fans/ON'] = 'sensors/fanON';
-$route['technical/fans/OFF'] = 'sensors/fanOFF';
-$route['technical/fans/enable'] = 'sensors/enableFan';
-$route['technical/fans/disable'] = 'sensors/disableFan';
-$route['technical/fans/edit/settings'] = 'sensors/editFanSettings';
-$route['technical/fans/edit/schedule'] = 'sensors/editFanSchedule';
-$route['technical/fans/diagnostics'] = 'sensors/fanDiagnostics';
-
-// Heater
-$route['technical/heater'] = 'sensors/heaterSettings';
-$route['technical/heater/ON'] = 'sensors/heaterON';
-$route['technical/heater/OFF'] = 'sensors/heaterOFF';
-$route['technical/heater/enable'] = 'sensors/heaterFan';
-$route['technical/heater/disable'] = 'sensors/heaterFan';
-$route['technical/heater/edit/GPIO'] = 'sensors/editHeaterGPIO';
-$route['technical/heater/edit/schedule'] = 'sensors/editHeaterSchedule';
-$route['technical/heater/diagnostics'] = 'sensors/heaterDiagnostics';
-
-// Camera
-$route['technical/camera'] = 'sensors/cameraSettings';
-$route['technical/camera/enable'] = 'sensors/enableCamera';
-$route['technical/camera/disable'] = 'sensors/disableCamera';
-$route['technical/camera/capture'] = 'sensors/capturePhoto';
-$route['technical/camera/diagnostics'] = 'sensors/cameraDiagnostics';
-
-// Pump
-$route['technical/pump'] = 'sensors/pumpSettings';
-$route['technical/pump/ON'] = 'sensors/pumpON';
-$route['technical/pump/OFF'] = 'sensors/pumpOFF';
-$route['technical/pump/enable'] = 'sensors/enablePump';
-$route['technical/pump/disable'] = 'sensors/disablePump';
-$route['technical/pump/edit/settings'] = 'sensors/editPumpSettings';
-$route['technical/pump/edit/schedule'] = 'sensors/editPumpSchedule';
-$route['technical/pump/diagnostics'] = 'sensors/pumpDiagnostics';
-
-// Moisture Probe
-$route['technical/moisture'] = 'sensors/moistureSettings';
-$route['technical/moisture/enable'] = 'sensors/enableMoistureSensor';
-$route['technical/moisture/disable'] = 'sensors/disableMoistureSensor';
-$route['technical/moisture/edit/GPIO'] = 'sensors/editMoistureGPIO';
-$route['technical/moisture/diagnostics'] = 'sensors/moistureDiagnostics';
-
diff --git a/app/application/config/smileys.php b/app/application/config/smileys.php
deleted file mode 100755
index abf9a89..0000000
--- a/app/application/config/smileys.php
+++ /dev/null
@@ -1,64 +0,0 @@
- array('grin.gif', '19', '19', 'grin'),
- ':lol:' => array('lol.gif', '19', '19', 'LOL'),
- ':cheese:' => array('cheese.gif', '19', '19', 'cheese'),
- ':)' => array('smile.gif', '19', '19', 'smile'),
- ';-)' => array('wink.gif', '19', '19', 'wink'),
- ';)' => array('wink.gif', '19', '19', 'wink'),
- ':smirk:' => array('smirk.gif', '19', '19', 'smirk'),
- ':roll:' => array('rolleyes.gif', '19', '19', 'rolleyes'),
- ':-S' => array('confused.gif', '19', '19', 'confused'),
- ':wow:' => array('surprise.gif', '19', '19', 'surprised'),
- ':bug:' => array('bigsurprise.gif', '19', '19', 'big surprise'),
- ':-P' => array('tongue_laugh.gif', '19', '19', 'tongue laugh'),
- '%-P' => array('tongue_rolleye.gif', '19', '19', 'tongue rolleye'),
- ';-P' => array('tongue_wink.gif', '19', '19', 'tongue wink'),
- ':P' => array('raspberry.gif', '19', '19', 'raspberry'),
- ':blank:' => array('blank.gif', '19', '19', 'blank stare'),
- ':long:' => array('longface.gif', '19', '19', 'long face'),
- ':ohh:' => array('ohh.gif', '19', '19', 'ohh'),
- ':grrr:' => array('grrr.gif', '19', '19', 'grrr'),
- ':gulp:' => array('gulp.gif', '19', '19', 'gulp'),
- '8-/' => array('ohoh.gif', '19', '19', 'oh oh'),
- ':down:' => array('downer.gif', '19', '19', 'downer'),
- ':red:' => array('embarrassed.gif', '19', '19', 'red face'),
- ':sick:' => array('sick.gif', '19', '19', 'sick'),
- ':shut:' => array('shuteye.gif', '19', '19', 'shut eye'),
- ':-/' => array('hmm.gif', '19', '19', 'hmmm'),
- '>:(' => array('mad.gif', '19', '19', 'mad'),
- ':mad:' => array('mad.gif', '19', '19', 'mad'),
- '>:-(' => array('angry.gif', '19', '19', 'angry'),
- ':angry:' => array('angry.gif', '19', '19', 'angry'),
- ':zip:' => array('zip.gif', '19', '19', 'zipper'),
- ':kiss:' => array('kiss.gif', '19', '19', 'kiss'),
- ':ahhh:' => array('shock.gif', '19', '19', 'shock'),
- ':coolsmile:' => array('shade_smile.gif', '19', '19', 'cool smile'),
- ':coolsmirk:' => array('shade_smirk.gif', '19', '19', 'cool smirk'),
- ':coolgrin:' => array('shade_grin.gif', '19', '19', 'cool grin'),
- ':coolhmm:' => array('shade_hmm.gif', '19', '19', 'cool hmm'),
- ':coolmad:' => array('shade_mad.gif', '19', '19', 'cool mad'),
- ':coolcheese:' => array('shade_cheese.gif', '19', '19', 'cool cheese'),
- ':vampire:' => array('vampire.gif', '19', '19', 'vampire'),
- ':snake:' => array('snake.gif', '19', '19', 'snake'),
- ':exclaim:' => array('exclaim.gif', '19', '19', 'exclaim'),
- ':question:' => array('question.gif', '19', '19', 'question')
-
-);
diff --git a/app/application/config/user_agents.php b/app/application/config/user_agents.php
deleted file mode 100755
index b6c8563..0000000
--- a/app/application/config/user_agents.php
+++ /dev/null
@@ -1,214 +0,0 @@
- 'Windows 10',
- 'windows nt 6.3' => 'Windows 8.1',
- 'windows nt 6.2' => 'Windows 8',
- 'windows nt 6.1' => 'Windows 7',
- 'windows nt 6.0' => 'Windows Vista',
- 'windows nt 5.2' => 'Windows 2003',
- 'windows nt 5.1' => 'Windows XP',
- 'windows nt 5.0' => 'Windows 2000',
- 'windows nt 4.0' => 'Windows NT 4.0',
- 'winnt4.0' => 'Windows NT 4.0',
- 'winnt 4.0' => 'Windows NT',
- 'winnt' => 'Windows NT',
- 'windows 98' => 'Windows 98',
- 'win98' => 'Windows 98',
- 'windows 95' => 'Windows 95',
- 'win95' => 'Windows 95',
- 'windows phone' => 'Windows Phone',
- 'windows' => 'Unknown Windows OS',
- 'android' => 'Android',
- 'blackberry' => 'BlackBerry',
- 'iphone' => 'iOS',
- 'ipad' => 'iOS',
- 'ipod' => 'iOS',
- 'os x' => 'Mac OS X',
- 'ppc mac' => 'Power PC Mac',
- 'freebsd' => 'FreeBSD',
- 'ppc' => 'Macintosh',
- 'linux' => 'Linux',
- 'debian' => 'Debian',
- 'sunos' => 'Sun Solaris',
- 'beos' => 'BeOS',
- 'apachebench' => 'ApacheBench',
- 'aix' => 'AIX',
- 'irix' => 'Irix',
- 'osf' => 'DEC OSF',
- 'hp-ux' => 'HP-UX',
- 'netbsd' => 'NetBSD',
- 'bsdi' => 'BSDi',
- 'openbsd' => 'OpenBSD',
- 'gnu' => 'GNU/Linux',
- 'unix' => 'Unknown Unix OS',
- 'symbian' => 'Symbian OS'
-);
-
-
-// The order of this array should NOT be changed. Many browsers return
-// multiple browser types so we want to identify the sub-type first.
-$browsers = array(
- 'OPR' => 'Opera',
- 'Flock' => 'Flock',
- 'Edge' => 'Edge',
- 'Chrome' => 'Chrome',
- // Opera 10+ always reports Opera/9.80 and appends Version/ to the user agent string
- 'Opera.*?Version' => 'Opera',
- 'Opera' => 'Opera',
- 'MSIE' => 'Internet Explorer',
- 'Internet Explorer' => 'Internet Explorer',
- 'Trident.* rv' => 'Internet Explorer',
- 'Shiira' => 'Shiira',
- 'Firefox' => 'Firefox',
- 'Chimera' => 'Chimera',
- 'Phoenix' => 'Phoenix',
- 'Firebird' => 'Firebird',
- 'Camino' => 'Camino',
- 'Netscape' => 'Netscape',
- 'OmniWeb' => 'OmniWeb',
- 'Safari' => 'Safari',
- 'Mozilla' => 'Mozilla',
- 'Konqueror' => 'Konqueror',
- 'icab' => 'iCab',
- 'Lynx' => 'Lynx',
- 'Links' => 'Links',
- 'hotjava' => 'HotJava',
- 'amaya' => 'Amaya',
- 'IBrowse' => 'IBrowse',
- 'Maxthon' => 'Maxthon',
- 'Ubuntu' => 'Ubuntu Web Browser'
-);
-
-$mobiles = array(
- // legacy array, old values commented out
- 'mobileexplorer' => 'Mobile Explorer',
-// 'openwave' => 'Open Wave',
-// 'opera mini' => 'Opera Mini',
-// 'operamini' => 'Opera Mini',
-// 'elaine' => 'Palm',
- 'palmsource' => 'Palm',
-// 'digital paths' => 'Palm',
-// 'avantgo' => 'Avantgo',
-// 'xiino' => 'Xiino',
- 'palmscape' => 'Palmscape',
-// 'nokia' => 'Nokia',
-// 'ericsson' => 'Ericsson',
-// 'blackberry' => 'BlackBerry',
-// 'motorola' => 'Motorola'
-
- // Phones and Manufacturers
- 'motorola' => 'Motorola',
- 'nokia' => 'Nokia',
- 'palm' => 'Palm',
- 'iphone' => 'Apple iPhone',
- 'ipad' => 'iPad',
- 'ipod' => 'Apple iPod Touch',
- 'sony' => 'Sony Ericsson',
- 'ericsson' => 'Sony Ericsson',
- 'blackberry' => 'BlackBerry',
- 'cocoon' => 'O2 Cocoon',
- 'blazer' => 'Treo',
- 'lg' => 'LG',
- 'amoi' => 'Amoi',
- 'xda' => 'XDA',
- 'mda' => 'MDA',
- 'vario' => 'Vario',
- 'htc' => 'HTC',
- 'samsung' => 'Samsung',
- 'sharp' => 'Sharp',
- 'sie-' => 'Siemens',
- 'alcatel' => 'Alcatel',
- 'benq' => 'BenQ',
- 'ipaq' => 'HP iPaq',
- 'mot-' => 'Motorola',
- 'playstation portable' => 'PlayStation Portable',
- 'playstation 3' => 'PlayStation 3',
- 'playstation vita' => 'PlayStation Vita',
- 'hiptop' => 'Danger Hiptop',
- 'nec-' => 'NEC',
- 'panasonic' => 'Panasonic',
- 'philips' => 'Philips',
- 'sagem' => 'Sagem',
- 'sanyo' => 'Sanyo',
- 'spv' => 'SPV',
- 'zte' => 'ZTE',
- 'sendo' => 'Sendo',
- 'nintendo dsi' => 'Nintendo DSi',
- 'nintendo ds' => 'Nintendo DS',
- 'nintendo 3ds' => 'Nintendo 3DS',
- 'wii' => 'Nintendo Wii',
- 'open web' => 'Open Web',
- 'openweb' => 'OpenWeb',
-
- // Operating Systems
- 'android' => 'Android',
- 'symbian' => 'Symbian',
- 'SymbianOS' => 'SymbianOS',
- 'elaine' => 'Palm',
- 'series60' => 'Symbian S60',
- 'windows ce' => 'Windows CE',
-
- // Browsers
- 'obigo' => 'Obigo',
- 'netfront' => 'Netfront Browser',
- 'openwave' => 'Openwave Browser',
- 'mobilexplorer' => 'Mobile Explorer',
- 'operamini' => 'Opera Mini',
- 'opera mini' => 'Opera Mini',
- 'opera mobi' => 'Opera Mobile',
- 'fennec' => 'Firefox Mobile',
-
- // Other
- 'digital paths' => 'Digital Paths',
- 'avantgo' => 'AvantGo',
- 'xiino' => 'Xiino',
- 'novarra' => 'Novarra Transcoder',
- 'vodafone' => 'Vodafone',
- 'docomo' => 'NTT DoCoMo',
- 'o2' => 'O2',
-
- // Fallback
- 'mobile' => 'Generic Mobile',
- 'wireless' => 'Generic Mobile',
- 'j2me' => 'Generic Mobile',
- 'midp' => 'Generic Mobile',
- 'cldc' => 'Generic Mobile',
- 'up.link' => 'Generic Mobile',
- 'up.browser' => 'Generic Mobile',
- 'smartphone' => 'Generic Mobile',
- 'cellphone' => 'Generic Mobile'
-);
-
-// There are hundreds of bots but these are the most common.
-$robots = array(
- 'googlebot' => 'Googlebot',
- 'msnbot' => 'MSNBot',
- 'baiduspider' => 'Baiduspider',
- 'bingbot' => 'Bing',
- 'slurp' => 'Inktomi Slurp',
- 'yahoo' => 'Yahoo',
- 'ask jeeves' => 'Ask Jeeves',
- 'fastcrawler' => 'FastCrawler',
- 'infoseek' => 'InfoSeek Robot 1.0',
- 'lycos' => 'Lycos',
- 'yandex' => 'YandexBot',
- 'mediapartners-google' => 'MediaPartners Google',
- 'CRAZYWEBCRAWLER' => 'Crazy Webcrawler',
- 'adsbot-google' => 'AdsBot Google',
- 'feedfetcher-google' => 'Feedfetcher Google',
- 'curious george' => 'Curious George',
- 'ia_archiver' => 'Alexa Crawler',
- 'MJ12bot' => 'Majestic-12',
- 'Uptimebot' => 'Uptimebot'
-);
diff --git a/app/application/controllers/Auth.php b/app/application/controllers/Auth.php
deleted file mode 100755
index 18e2f1c..0000000
--- a/app/application/controllers/Auth.php
+++ /dev/null
@@ -1,864 +0,0 @@
-load->database();
- $this->load->library(array('ion_auth', 'form_validation'));
- $this->load->helper(array('url', 'language'));
- $this->load->model('Dashboard_model');
-
- $this->form_validation->set_error_delimiters($this->config->item('error_start_delimiter', 'ion_auth'), $this->config->item('error_end_delimiter', 'ion_auth'));
-
- $this->lang->load('auth');
- }
-
- /**
- * Redirect if needed, otherwise display the user list
- */
- public function index()
- {
-
- if (!$this->ion_auth->logged_in())
- {
- // redirect them to the login page
- redirect('/login', 'refresh');
- }
- else if (!$this->ion_auth->is_admin()) // remove this elseif if you want to enable this for non-admins
- {
- // redirect them to the home page because they must be an administrator to view this
- return show_error('You must be an administrator to view this page.');
- }
- else
- {
- // set the flash data error message if there is one
- $this->data['message'] = (validation_errors()) ? validation_errors() : $this->session->flashdata('message');
-
- //list the users
- $this->data['users'] = $this->ion_auth->users()->result();
- foreach ($this->data['users'] as $k => $user)
- {
- $this->data['users'][$k]->groups = $this->ion_auth->get_users_groups($user->id)->result();
- }
- $this->data['user_info'] = $this->Dashboard_model->get_user_info();
-
- $this->_render_page('user/view_users', $this->data);
- }
- }
-
- /**
- * Log the user in
- */
- public function login()
- {
- $this->data['title'] = $this->lang->line('login_heading');
-
- // validate form input
- $this->form_validation->set_rules('identity', str_replace(':', '', $this->lang->line('login_identity_label')), 'required');
- $this->form_validation->set_rules('password', str_replace(':', '', $this->lang->line('login_password_label')), 'required');
-
- if ($this->form_validation->run() === TRUE)
- {
- // check to see if the user is logging in
- // check for "remember me"
- $remember = (bool)$this->input->post('remember');
-
- if ($this->ion_auth->login($this->input->post('identity'), $this->input->post('password'), $remember))
- {
- //if the login is successful
- //redirect them back to the home page
- $this->session->set_flashdata('message', $this->ion_auth->messages());
- redirect('/', 'refresh');
- }
- else
- {
- // if the login was un-successful
- // redirect them back to the login page
- $this->session->set_flashdata('message', $this->ion_auth->errors());
- redirect('/login', 'refresh'); // use redirects instead of loading views for compatibility with MY_Controller libraries
- }
- }
- else
- {
- // the user is not logging in so display the login page
- // set the flash data error message if there is one
- $this->data['message'] = (validation_errors()) ? validation_errors() : $this->session->flashdata('message');
-
- $this->data['identity'] = array('name' => 'identity',
- 'id' => 'identity',
- 'type' => 'text',
- 'value' => $this->form_validation->set_value('identity'),
- );
- $this->data['password'] = array('name' => 'password',
- 'id' => 'password',
- 'type' => 'password',
- );
-
- $this->_render_page('auth' . DIRECTORY_SEPARATOR . 'login', $this->data);
- }
- }
-
- /**
- * Log the user out
- */
- public function logout()
- {
- $this->data['title'] = "Logout";
-
- // log the user out
- $logout = $this->ion_auth->logout();
-
- // redirect them to the login page
- $this->session->set_flashdata('message', $this->ion_auth->messages());
- redirect('/login', 'refresh');
- }
-
- /**
- * Change password
- */
- public function change_password()
- {
- $this->form_validation->set_rules('old', $this->lang->line('change_password_validation_old_password_label'), 'required');
- $this->form_validation->set_rules('new', $this->lang->line('change_password_validation_new_password_label'), 'required|min_length[' . $this->config->item('min_password_length', 'ion_auth') . ']|max_length[' . $this->config->item('max_password_length', 'ion_auth') . ']|matches[new_confirm]');
- $this->form_validation->set_rules('new_confirm', $this->lang->line('change_password_validation_new_password_confirm_label'), 'required');
-
- if (!$this->ion_auth->logged_in())
- {
- redirect('/login', 'refresh');
- }
-
- $user = $this->ion_auth->user()->row();
-
- if ($this->form_validation->run() === FALSE)
- {
- // display the form
- // set the flash data error message if there is one
- $this->data['message'] = (validation_errors()) ? validation_errors() : $this->session->flashdata('message');
-
- $this->data['min_password_length'] = $this->config->item('min_password_length', 'ion_auth');
- $this->data['old_password'] = array(
- 'name' => 'old',
- 'id' => 'old',
- 'type' => 'password',
- );
- $this->data['new_password'] = array(
- 'name' => 'new',
- 'id' => 'new',
- 'type' => 'password',
- 'pattern' => '^.{' . $this->data['min_password_length'] . '}.*$',
- );
- $this->data['new_password_confirm'] = array(
- 'name' => 'new_confirm',
- 'id' => 'new_confirm',
- 'type' => 'password',
- 'pattern' => '^.{' . $this->data['min_password_length'] . '}.*$',
- );
- $this->data['user_id'] = array(
- 'name' => 'user_id',
- 'id' => 'user_id',
- 'type' => 'hidden',
- 'value' => $user->id,
- );
-
- // render
- $this->_render_page('auth' . DIRECTORY_SEPARATOR . 'change_password', $this->data);
- }
- else
- {
- $identity = $this->session->userdata('identity');
-
- $change = $this->ion_auth->change_password($identity, $this->input->post('old'), $this->input->post('new'));
-
- if ($change)
- {
- //if the password was successfully changed
- $this->session->set_flashdata('message', $this->ion_auth->messages());
- $this->logout();
- }
- else
- {
- $this->session->set_flashdata('message', $this->ion_auth->errors());
- redirect('auth/change_password', 'refresh');
- }
- }
- }
-
- /**
- * Forgot password
- */
- public function forgot_password()
- {
- // setting validation rules by checking whether identity is username or email
- if ($this->config->item('identity', 'ion_auth') != 'email')
- {
- $this->form_validation->set_rules('identity', $this->lang->line('forgot_password_identity_label'), 'required');
- }
- else
- {
- $this->form_validation->set_rules('identity', $this->lang->line('forgot_password_validation_email_label'), 'required|valid_email');
- }
-
-
- if ($this->form_validation->run() === FALSE)
- {
- $this->data['type'] = $this->config->item('identity', 'ion_auth');
- // setup the input
- $this->data['identity'] = array('name' => 'identity',
- 'id' => 'identity',
- );
-
- if ($this->config->item('identity', 'ion_auth') != 'email')
- {
- $this->data['identity_label'] = $this->lang->line('forgot_password_identity_label');
- }
- else
- {
- $this->data['identity_label'] = $this->lang->line('forgot_password_email_identity_label');
- }
-
- // set any errors and display the form
- $this->data['message'] = (validation_errors()) ? validation_errors() : $this->session->flashdata('message');
- $this->_render_page('auth' . DIRECTORY_SEPARATOR . 'forgot_password', $this->data);
- }
- else
- {
- $identity_column = $this->config->item('identity', 'ion_auth');
- $identity = $this->ion_auth->where($identity_column, $this->input->post('identity'))->users()->row();
-
- if (empty($identity))
- {
-
- if ($this->config->item('identity', 'ion_auth') != 'email')
- {
- $this->ion_auth->set_error('forgot_password_identity_not_found');
- }
- else
- {
- $this->ion_auth->set_error('forgot_password_email_not_found');
- }
-
- $this->session->set_flashdata('message', $this->ion_auth->errors());
- redirect("auth/forgot_password", 'refresh');
- }
-
- // run the forgotten password method to email an activation code to the user
- $forgotten = $this->ion_auth->forgotten_password($identity->{$this->config->item('identity', 'ion_auth')});
-
- if ($forgotten)
- {
- // if there were no errors
- $this->session->set_flashdata('message', $this->ion_auth->messages());
- redirect("/login", 'refresh'); //we should display a confirmation page here instead of the login page
- }
- else
- {
- $this->session->set_flashdata('message', $this->ion_auth->errors());
- redirect("auth/forgot_password", 'refresh');
- }
- }
- }
-
- /**
- * Reset password - final step for forgotten password
- *
- * @param string|null $code The reset code
- */
- public function reset_password($code = NULL)
- {
- if (!$code)
- {
- show_404();
- }
-
- $user = $this->ion_auth->forgotten_password_check($code);
-
- if ($user)
- {
- // if the code is valid then display the password reset form
-
- $this->form_validation->set_rules('new', $this->lang->line('reset_password_validation_new_password_label'), 'required|min_length[' . $this->config->item('min_password_length', 'ion_auth') . ']|max_length[' . $this->config->item('max_password_length', 'ion_auth') . ']|matches[new_confirm]');
- $this->form_validation->set_rules('new_confirm', $this->lang->line('reset_password_validation_new_password_confirm_label'), 'required');
-
- if ($this->form_validation->run() === FALSE)
- {
- // display the form
-
- // set the flash data error message if there is one
- $this->data['message'] = (validation_errors()) ? validation_errors() : $this->session->flashdata('message');
-
- $this->data['min_password_length'] = $this->config->item('min_password_length', 'ion_auth');
- $this->data['new_password'] = array(
- 'name' => 'new',
- 'id' => 'new',
- 'type' => 'password',
- 'pattern' => '^.{' . $this->data['min_password_length'] . '}.*$',
- );
- $this->data['new_password_confirm'] = array(
- 'name' => 'new_confirm',
- 'id' => 'new_confirm',
- 'type' => 'password',
- 'pattern' => '^.{' . $this->data['min_password_length'] . '}.*$',
- );
- $this->data['user_id'] = array(
- 'name' => 'user_id',
- 'id' => 'user_id',
- 'type' => 'hidden',
- 'value' => $user->id,
- );
- $this->data['csrf'] = $this->_get_csrf_nonce();
- $this->data['code'] = $code;
-
- // render
- $this->_render_page('auth' . DIRECTORY_SEPARATOR . 'reset_password', $this->data);
- }
- else
- {
- // do we have a valid request?
- if ($this->_valid_csrf_nonce() === FALSE || $user->id != $this->input->post('user_id'))
- {
-
- // something fishy might be up
- $this->ion_auth->clear_forgotten_password_code($code);
-
- show_error($this->lang->line('error_csrf'));
-
- }
- else
- {
- // finally change the password
- $identity = $user->{$this->config->item('identity', 'ion_auth')};
-
- $change = $this->ion_auth->reset_password($identity, $this->input->post('new'));
-
- if ($change)
- {
- // if the password was successfully changed
- $this->session->set_flashdata('message', $this->ion_auth->messages());
- redirect("/login", 'refresh');
- }
- else
- {
- $this->session->set_flashdata('message', $this->ion_auth->errors());
- redirect('auth/reset_password/' . $code, 'refresh');
- }
- }
- }
- }
- else
- {
- // if the code is invalid then send them back to the forgot password page
- $this->session->set_flashdata('message', $this->ion_auth->errors());
- redirect("auth/forgot_password", 'refresh');
- }
- }
-
- /**
- * Activate the user
- *
- * @param int $id The user ID
- * @param string|bool $code The activation code
- */
- public function activate($id, $code = FALSE)
- {
- if ($code !== FALSE)
- {
- $activation = $this->ion_auth->activate($id, $code);
- }
- else if ($this->ion_auth->is_admin())
- {
- $activation = $this->ion_auth->activate($id);
- }
-
- if ($activation)
- {
- // redirect them to the auth page
- $this->session->set_flashdata('message', $this->ion_auth->messages());
- redirect("auth", 'refresh');
- }
- else
- {
- // redirect them to the forgot password page
- $this->session->set_flashdata('message', $this->ion_auth->errors());
- redirect("auth/forgot_password", 'refresh');
- }
- }
-
- /**
- * Deactivate the user
- *
- * @param int|string|null $id The user ID
- */
- public function deactivate($id = NULL)
- {
- if (!$this->ion_auth->logged_in() || !$this->ion_auth->is_admin())
- {
- // redirect them to the home page because they must be an administrator to view this
- return show_error('You must be an administrator to view this page.');
- }
-
- $id = (int)$id;
-
- $this->load->library('form_validation');
- $this->form_validation->set_rules('confirm', $this->lang->line('deactivate_validation_confirm_label'), 'required');
- $this->form_validation->set_rules('id', $this->lang->line('deactivate_validation_user_id_label'), 'required|alpha_numeric');
-
- if ($this->form_validation->run() === FALSE)
- {
- // insert csrf check
- $this->data['csrf'] = $this->_get_csrf_nonce();
- $this->data['user'] = $this->ion_auth->user($id)->row();
-
- $this->_render_page('auth' . DIRECTORY_SEPARATOR . 'deactivate_user', $this->data);
- }
- else
- {
- // do we really want to deactivate?
- if ($this->input->post('confirm') == 'yes')
- {
- // do we have a valid request?
- if ($this->_valid_csrf_nonce() === FALSE || $id != $this->input->post('id'))
- {
- return show_error($this->lang->line('error_csrf'));
- }
-
- // do we have the right userlevel?
- if ($this->ion_auth->logged_in() && $this->ion_auth->is_admin())
- {
- $this->ion_auth->deactivate($id);
- }
- }
-
- // redirect them back to the auth page
- redirect('auth', 'refresh');
- }
- }
-
- /**
- * Create a new user
- */
- public function create_user()
- {
- $this->data['title'] = $this->lang->line('create_user_heading');
-
- if (!$this->ion_auth->logged_in() || !$this->ion_auth->is_admin())
- {
- redirect('auth', 'refresh');
- }
-
- $tables = $this->config->item('tables', 'ion_auth');
- $identity_column = $this->config->item('identity', 'ion_auth');
- $this->data['identity_column'] = $identity_column;
-
- // validate form input
- $this->form_validation->set_rules('first_name', $this->lang->line('create_user_validation_fname_label'), 'trim|required');
- $this->form_validation->set_rules('last_name', $this->lang->line('create_user_validation_lname_label'), 'trim|required');
- if ($identity_column !== 'email')
- {
- $this->form_validation->set_rules('identity', $this->lang->line('create_user_validation_identity_label'), 'trim|required|is_unique[' . $tables['users'] . '.' . $identity_column . ']');
- $this->form_validation->set_rules('email', $this->lang->line('create_user_validation_email_label'), 'trim|required|valid_email');
- }
- else
- {
- $this->form_validation->set_rules('email', $this->lang->line('create_user_validation_email_label'), 'trim|required|valid_email|is_unique[' . $tables['users'] . '.email]');
- }
- $this->form_validation->set_rules('password', $this->lang->line('create_user_validation_password_label'), 'required|min_length[' . $this->config->item('min_password_length', 'ion_auth') . ']|max_length[' . $this->config->item('max_password_length', 'ion_auth') . ']|matches[password_confirm]');
- $this->form_validation->set_rules('password_confirm', $this->lang->line('create_user_validation_password_confirm_label'), 'required');
-
- if ($this->form_validation->run() === TRUE)
- {
- $email = strtolower($this->input->post('email'));
- $identity = ($identity_column === 'email') ? $email : $this->input->post('identity');
- $password = $this->input->post('password');
-
- $additional_data = array(
- 'first_name' => $this->input->post('first_name'),
- 'last_name' => $this->input->post('last_name'),
- );
- }
- if ($this->form_validation->run() === TRUE && $this->ion_auth->register($identity, $password, $email, $additional_data))
- {
- // check to see if we are creating the user
- // redirect them back to the admin page
- $this->session->set_flashdata('message', $this->ion_auth->messages());
- redirect("auth", 'refresh');
- }
- else
- {
- // display the create user form
- // set the flash data error message if there is one
- $this->data['message'] = (validation_errors() ? validation_errors() : ($this->ion_auth->errors() ? $this->ion_auth->errors() : $this->session->flashdata('message')));
-
- $this->data['first_name'] = array(
- 'name' => 'first_name',
- 'id' => 'first_name',
- 'type' => 'text',
- 'value' => $this->form_validation->set_value('first_name'),
- );
- $this->data['last_name'] = array(
- 'name' => 'last_name',
- 'id' => 'last_name',
- 'type' => 'text',
- 'value' => $this->form_validation->set_value('last_name'),
- );
- $this->data['identity'] = array(
- 'name' => 'identity',
- 'id' => 'identity',
- 'type' => 'text',
- 'value' => $this->form_validation->set_value('identity'),
- );
- $this->data['email'] = array(
- 'name' => 'email',
- 'id' => 'email',
- 'type' => 'text',
- 'value' => $this->form_validation->set_value('email'),
- );
- $this->data['password'] = array(
- 'name' => 'password',
- 'id' => 'password',
- 'type' => 'password',
- 'value' => $this->form_validation->set_value('password'),
- );
- $this->data['password_confirm'] = array(
- 'name' => 'password_confirm',
- 'id' => 'password_confirm',
- 'type' => 'password',
- 'value' => $this->form_validation->set_value('password_confirm'),
- );
- $this->data['user_info'] = $this->Dashboard_model->get_user_info();
-
- $this->_render_page('user/create_user', $this->data);
- }
- }
- /**
- * Redirect a user checking if is admin
- */
- public function redirectUser(){
- if ($this->ion_auth->is_admin()){
- redirect('auth', 'refresh');
- }
- redirect('/', 'refresh');
- }
-
- /**
- * Edit a user
- *
- * @param int|string $id
- */
- public function edit_user($id)
- {
- $this->data['title'] = $this->lang->line('edit_user_heading');
-
- if (!$this->ion_auth->logged_in() || (!$this->ion_auth->is_admin() && !($this->ion_auth->user()->row()->id == $id)))
- {
- redirect('auth', 'refresh');
- }
-
- $user = $this->ion_auth->user($id)->row();
- $groups = $this->ion_auth->groups()->result_array();
- $currentGroups = $this->ion_auth->get_users_groups($id)->result();
-
- // validate form input
- $this->form_validation->set_rules('first_name', $this->lang->line('edit_user_validation_fname_label'), 'trim|required');
- $this->form_validation->set_rules('last_name', $this->lang->line('edit_user_validation_lname_label'), 'trim|required');
-
- if (isset($_POST) && !empty($_POST))
- {
- // do we have a valid request?
- if ($this->_valid_csrf_nonce() === FALSE || $id != $this->input->post('id'))
- {
- show_error($this->lang->line('error_csrf'));
- }
-
- // update the password if it was posted
- if ($this->input->post('password'))
- {
- $this->form_validation->set_rules('password', $this->lang->line('edit_user_validation_password_label'), 'required|min_length[' . $this->config->item('min_password_length', 'ion_auth') . ']|max_length[' . $this->config->item('max_password_length', 'ion_auth') . ']|matches[password_confirm]');
- $this->form_validation->set_rules('password_confirm', $this->lang->line('edit_user_validation_password_confirm_label'), 'required');
- }
-
- if ($this->form_validation->run() === TRUE)
- {
- $data = array(
- 'first_name' => $this->input->post('first_name'),
- 'last_name' => $this->input->post('last_name'),
- );
-
- // update the password if it was posted
- if ($this->input->post('password'))
- {
- $data['password'] = $this->input->post('password');
- }
-
- // Only allow updating groups if user is admin
- if ($this->ion_auth->is_admin())
- {
- // Update the groups user belongs to
- $groupData = $this->input->post('groups');
-
- if (isset($groupData) && !empty($groupData))
- {
-
- $this->ion_auth->remove_from_group('', $id);
-
- foreach ($groupData as $grp)
- {
- $this->ion_auth->add_to_group($grp, $id);
- }
-
- }
- }
-
- // check to see if we are updating the user
- if ($this->ion_auth->update($user->id, $data))
- {
- // redirect them back to the admin page if admin, or to the base url if non admin
- $this->session->set_flashdata('message', $this->ion_auth->messages());
- $this->redirectUser();
-
- }
- else
- {
- // redirect them back to the admin page if admin, or to the base url if non admin
- $this->session->set_flashdata('message', $this->ion_auth->errors());
- $this->redirectUser();
-
- }
-
- }
- }
-
- // display the edit user form
- $this->data['csrf'] = $this->_get_csrf_nonce();
-
- // set the flash data error message if there is one
- $this->data['message'] = (validation_errors() ? validation_errors() : ($this->ion_auth->errors() ? $this->ion_auth->errors() : $this->session->flashdata('message')));
-
- // pass the user to the view
- $this->data['user'] = $user;
- $this->data['groups'] = $groups;
- $this->data['currentGroups'] = $currentGroups;
-
- $this->data['first_name'] = array(
- 'name' => 'first_name',
- 'id' => 'first_name',
- 'type' => 'text',
- 'value' => $this->form_validation->set_value('first_name', $user->first_name),
- );
- $this->data['last_name'] = array(
- 'name' => 'last_name',
- 'id' => 'last_name',
- 'type' => 'text',
- 'value' => $this->form_validation->set_value('last_name', $user->last_name),
- );
- $this->data['password'] = array(
- 'name' => 'password',
- 'id' => 'password',
- 'type' => 'password'
- );
- $this->data['password_confirm'] = array(
- 'name' => 'password_confirm',
- 'id' => 'password_confirm',
- 'type' => 'password'
- );
-
- // Page Meta
- $this->data['title'] = 'Edit User';
-
- // Data Fetch
- $this->data['user_info'] = $this->Dashboard_model->get_user_info();
-
- $this->_render_page('user/edit_user', $this->data);
- }
-
- /**
- * Create a new group
- */
- public function create_group()
- {
- $this->data['title'] = $this->lang->line('create_group_title');
-
- if (!$this->ion_auth->logged_in() || !$this->ion_auth->is_admin())
- {
- redirect('auth', 'refresh');
- }
-
- // validate form input
- $this->form_validation->set_rules('group_name', $this->lang->line('create_group_validation_name_label'), 'trim|required|alpha_dash');
-
- if ($this->form_validation->run() === TRUE)
- {
- $new_group_id = $this->ion_auth->create_group($this->input->post('group_name'), $this->input->post('description'));
- if ($new_group_id)
- {
- // check to see if we are creating the group
- // redirect them back to the admin page
- $this->session->set_flashdata('message', $this->ion_auth->messages());
- redirect("auth", 'refresh');
- }
- }
- else
- {
- // display the create group form
- // set the flash data error message if there is one
- $this->data['message'] = (validation_errors() ? validation_errors() : ($this->ion_auth->errors() ? $this->ion_auth->errors() : $this->session->flashdata('message')));
-
- $this->data['group_name'] = array(
- 'name' => 'group_name',
- 'id' => 'group_name',
- 'type' => 'text',
- 'value' => $this->form_validation->set_value('group_name'),
- );
- $this->data['description'] = array(
- 'name' => 'description',
- 'id' => 'description',
- 'type' => 'text',
- 'value' => $this->form_validation->set_value('description'),
- );
-
- $this->_render_page('auth' . DIRECTORY_SEPARATOR . 'create_group', $this->data);
- }
- }
-
- /**
- * Edit a group
- *
- * @param int|string $id
- */
- public function edit_group($id)
- {
- // bail if no group id given
- if (!$id || empty($id))
- {
- redirect('auth', 'refresh');
- }
-
- $this->data['title'] = $this->lang->line('edit_group_title');
-
- if (!$this->ion_auth->logged_in() || !$this->ion_auth->is_admin())
- {
- redirect('auth', 'refresh');
- }
-
- $group = $this->ion_auth->group($id)->row();
-
- // validate form input
- $this->form_validation->set_rules('group_name', $this->lang->line('edit_group_validation_name_label'), 'required|alpha_dash');
-
- if (isset($_POST) && !empty($_POST))
- {
- if ($this->form_validation->run() === TRUE)
- {
- $group_update = $this->ion_auth->update_group($id, $_POST['group_name'], $_POST['group_description']);
-
- if ($group_update)
- {
- $this->session->set_flashdata('message', $this->lang->line('edit_group_saved'));
- }
- else
- {
- $this->session->set_flashdata('message', $this->ion_auth->errors());
- }
- redirect("auth", 'refresh');
- }
- }
-
- // set the flash data error message if there is one
- $this->data['message'] = (validation_errors() ? validation_errors() : ($this->ion_auth->errors() ? $this->ion_auth->errors() : $this->session->flashdata('message')));
-
- // pass the user to the view
- $this->data['group'] = $group;
-
- $readonly = $this->config->item('admin_group', 'ion_auth') === $group->name ? 'readonly' : '';
-
- $this->data['group_name'] = array(
- 'name' => 'group_name',
- 'id' => 'group_name',
- 'type' => 'text',
- 'value' => $this->form_validation->set_value('group_name', $group->name),
- $readonly => $readonly,
- );
- $this->data['group_description'] = array(
- 'name' => 'group_description',
- 'id' => 'group_description',
- 'type' => 'text',
- 'value' => $this->form_validation->set_value('group_description', $group->description),
- );
-
- $this->_render_page('auth' . DIRECTORY_SEPARATOR . 'edit_group', $this->data);
- }
-
- /**
- * @return array A CSRF key-value pair
- */
- public function _get_csrf_nonce()
- {
- $this->load->helper('string');
- $key = random_string('alnum', 8);
- $value = random_string('alnum', 20);
- $this->session->set_flashdata('csrfkey', $key);
- $this->session->set_flashdata('csrfvalue', $value);
-
- return array($key => $value);
- }
-
- /**
- * @return bool Whether the posted CSRF token matches
- */
- public function _valid_csrf_nonce(){
- $csrfkey = $this->input->post($this->session->flashdata('csrfkey'));
- if ($csrfkey && $csrfkey === $this->session->flashdata('csrfvalue')){
- return TRUE;
- }
- return FALSE;
- }
-
- /**
- * @param string $view
- * @param array|null $data
- * @param bool $returnhtml
- *
- * @return mixed
- */
- public function _render_page($view, $data = NULL, $returnhtml = FALSE)//I think this makes more sense
- {
-
- $this->viewdata = (empty($data)) ? $this->data : $data;
-
- $view_html = $this->load->view($view, $this->viewdata, $returnhtml);
-
- // This will return html on 3rd argument being true
- if ($returnhtml)
- {
- return $view_html;
- }
- }
-
- // Delete user
- public function delete_user($id)
- {
- if ($this->ion_auth->is_admin()) {
- $this->ion_auth->delete_user($id);
- }
-
- redirect("/users");
- }
-
- // Reset Admin Default
- public function reset()
- {
-
- // Reset admin account to default
- // $this->ion_auth->reset_Admin();
-
- redirect("/login");
-
- }
-
-}
diff --git a/app/application/controllers/Crop.php b/app/application/controllers/Crop.php
deleted file mode 100755
index 3818828..0000000
--- a/app/application/controllers/Crop.php
+++ /dev/null
@@ -1,253 +0,0 @@
-load->library('ion_auth');
- $this->load->helper('form');
- $this->load->library('form_validation');
- $this->load->model('Dashboard_model');
- $this->load->model('Crop_model');
- $this->load->model('Lights_model');
- $this->load->model('Fan_model');
- $this->load->model('Pump_model');
- $this->load->model('Climate_model');
- $this->load->model('Camera_model');
- $this->load->model('Moisture_model');
- }
-
- /**
- * Crop - Index
- * Main page for adding, editing and viewing crops.
- *
- * @url /crop
- */
- public function index()
- {
- // Redirect if user not logged in, otherwise display the page.
- if ($this->ion_auth->logged_in())
- {
- // Page Meta
- $data['title'] = 'Crop';
-
- // Data Fetch
- $data['user_info'] = $this->Dashboard_model->get_user_info();
- $data['crops'] = $this->Crop_model->getAllCropsInfo();
- $data['sensor_state'] = $this->Dashboard_model->get_sensor_activation_state();
-
- // Page View
- $this->load->view('crop/index', $data);
-
- } else {
- // Redirect to login.
- redirect('/login');
- }
- }
-
-
- /**
- * Crop - Create Crop
- * Create a new crop.
- *
- * @url /crop/new
- */
- public function createCrop()
- {
- // Redirect if user not logged in, otherwise display the page.
- if ($this->ion_auth->logged_in())
- {
- // Form validation rules
- $this->form_validation->set_rules('nickname', 'Nickname', 'required');
- $this->form_validation->set_rules('plant_qty', 'Plant Quantity', 'required');
- $this->form_validation->set_rules('plant_type', 'Plant Type', 'required');
- $this->form_validation->set_rules('crop_start', 'Crop Start', 'required');
- $this->form_validation->set_rules('crop_end', 'Crop End', 'required');
-
- if ($this->form_validation->run() == FALSE)
- {
- // Page Meta
- $data['title'] = 'Create Crop';
-
- // Data Fetch
- $data['user_info'] = $this->Dashboard_model->get_user_info();
-
- // Page View
- $this->load->view('crop/new_crop', $data);
- }
- else
- {
- $this->Crop_model->setupCrop();
- redirect('/crop');
- }
-
- } else {
- // Redirect to login.
- redirect('/login');
- }
- }
-
- /**
- * Crop - Edit Crop
- * Edit an existing crop and modify its parameters.
- *
- * @url /crop/edit/
- *
- * @param string $cropID - A string which is the unique crop identifier.
- */
- public function editCrop($cropID)
- {
- // Redirect if user not logged in, otherwise display the page.
- if ($this->ion_auth->logged_in())
- {
- // Form validation rules
- $this->form_validation->set_rules('nickname', 'Nickname', 'required');
- $this->form_validation->set_rules('plant_qty', 'Plant Quantity', 'required');
- $this->form_validation->set_rules('plant_type', 'Plant Type', 'required');
- $this->form_validation->set_rules('crop_start', 'Crop Start', 'required');
- $this->form_validation->set_rules('crop_end', 'Crop End', 'required');
-
- if ($this->form_validation->run() == FALSE)
- {
- // Page Meta
- $data['title'] = 'Edit Crop';
-
- // Data Fetch
- $data['user_info'] = $this->Dashboard_model->get_user_info();
- $data['crop_info'] = $this->Crop_model->cropInfo($cropID);
-
- // Page View
- $this->load->view('crop/edit_crop', $data);
- }
- else
- {
- $this->Crop_model->editCrop($cropID);
- redirect('/crop');
- }
-
- } else {
- // Redirect to login.
- redirect('/login');
- }
- }
-
- /**
- * Crop - Delete Crop
- * Delete an existing crop.
- *
- * @url /crop/delete/
- *
- * @param string $cropID - A string which is the unique crop identifier.
- */
- public function deleteCrop($cropID)
- {
- // Redirect if user not logged in, otherwise display the page.
- if ($this->ion_auth->logged_in())
- {
- // Delete crop based on cropID
- $this->Crop_model->deleteCrop($cropID);
-
- // Redirect to original page
- redirect($_SERVER['HTTP_REFERER']);
-
- } else {
- // Redirect to login.
- redirect('/login');
- }
- }
-
- /**
- * Crop - Add Crop Journal Entry
- * Add a new crop journal entry to the database.
- *
- * @url /crop/activity/new
- */
- public function addCropActivityEntry()
- {
- // Redirect if user not logged in, otherwise display the page.
- if ($this->ion_auth->logged_in())
- {
- // Add record to database
- $this->Crop_model->addActivityEntry();
-
- // Redirect to dashboard
- redirect('/dashboard');
-
- } else {
- // Redirect to login.
- redirect('/login');
- }
- }
-
- /**
- * Crop - Edit Crop Journal Entry
- * Edit a crop journal entry.
- *
- * @url /crop/activity/edit/
- *
- * @param integer $id - An integer which is the unique crop journal entry identifier.
- */
- public function editCropActivityEntry($id)
- {
- // Redirect if user not logged in, otherwise display the page.
- if ($this->ion_auth->logged_in())
- {
-
- if ($this->input->server('REQUEST_METHOD') != 'POST')
- {
- // Page Meta
- $data['title'] = 'Edit Activity';
-
- // Data Fetch
- $data['user_info'] = $this->Dashboard_model->get_user_info();
- $data['activity'] = $this->Crop_model->getCropActivityEntry($id);
-
- // Page View
- $this->load->view('crop/edit_crop_activity', $data);
- }
- else
- {
- // Update record in database
- $this->Crop_model->editActivityEntry($id);
- redirect('/dashboard');
- }
-
- } else {
- // Redirect to login.
- redirect('/login');
- }
- }
-
- /**
- * Crop - Delete Crop Journal Entry
- * Delete a crop journal entry.
- *
- * @url /crop/activity/delete/
- *
- * @param integer $id - An integer which is the unique crop journal entry identifier.
- */
- public function deleteCropActivityEntry($id)
- {
- // Redirect if user not logged in, otherwise display the page.
- if ($this->ion_auth->logged_in())
- {
- // Add record to database
- $this->Crop_model->deleteActivityEntry($id);
-
- // Redirect to original page
- redirect($_SERVER['HTTP_REFERER']);
-
- } else {
- // Redirect to login.
- redirect('/login');
- }
- }
-
-}
-
diff --git a/app/application/controllers/Dashboard.php b/app/application/controllers/Dashboard.php
deleted file mode 100755
index 30690a5..0000000
--- a/app/application/controllers/Dashboard.php
+++ /dev/null
@@ -1,131 +0,0 @@
-load->library('ion_auth');
- $this->load->helper('form');
- $this->load->library('form_validation');
- $this->load->model('Dashboard_model');
- $this->load->model('Crop_model');
- $this->load->model('Lights_model');
- $this->load->model('Fan_model');
- $this->load->model('Pump_model');
- $this->load->model('Climate_model');
- $this->load->model('Camera_model');
- $this->load->model('Moisture_model');
- $this->load->model('Scheduler_model');
- $this->load->helper('utility');
- }
-
- /**
- * Dashboard - Index
- * The main page of the FruxePi app. From here, all things are possible!
- *
- * @url /dashboard
- */
- public function index()
- {
- // Redirect if user not logged in, otherwise display the page.
- if ($this->ion_auth->logged_in())
- {
- // Page Meta
- $data['title'] = 'Dashboard';
-
- // Data Fetch
- $data['user_info'] = $this->Dashboard_model->get_user_info();
- $data['grow_data'] = $this->Dashboard_model->get_latest_grow_data();
- $data['crops'] = $this->Crop_model->getAllCropsInfo();
- $data['crop_activity'] = $this->Crop_model->get_cropActivity();
-
- $data['temperature_chart'] = $this->Dashboard_model->get_temperature_chart_data();
- $data['temperature_format'] = $this->Climate_model->getTemperatureFormat();
- $data['humidity_chart'] = $this->Dashboard_model->get_humidity_chart_data();
- $data['chart_legend'] = $this->Dashboard_model->get_chart_legend();
-
- $data['pump_schedule'] = $this->Pump_model->getPumpSchedule();
- $data['fan_schedule'] = $this->Fan_model->getFanSchedule();
- $data['fan_status'] = $this->Fan_model->getFanStatus();
- $data['lights_ON'] = $this->Lights_model->getLightTimerON();
- $data['lights_OFF'] = $this->Lights_model->getLightTimerOFF();
- $data['lights_status'] = $this->Lights_model->getLightsStatus();
- $data['climate_threshold'] = $this->Climate_model->getClimateThreshold();
-
- $data['sensor_state'] = $this->Dashboard_model->get_sensor_activation_state();
- $data['cropThresholds'] = $this->Dashboard_model->get_cropThresholds();
- $data['cropConditions'] = $this->Dashboard_model->get_cropConditions();
- $data['soil_status'] = $this->Moisture_model->readMoistureSensor();
-
- // Page View
- $this->load->view('dashboard/index', $data);
-
- } else {
- // Redirect to login.
- redirect('/login');
- }
- }
-
- public function editGrowRoomSettings()
- {
- // Redirect if user not logged in, otherwise display the page.
- if ($this->ion_auth->logged_in())
- {
- // Set climate threshold
- $this->Climate_model->setClimateThreshold();
-
- // Change lighting schedule in DB
- $lightsON = $this->Lights_model->setLightTimerON();
- $lightsOFF = $this->Lights_model->setLightTimerOFF();
-
- // Edit lighting CRON
- $this->Scheduler_model->editLightsCRON($lightsON, $lightsOFF);
-
- // Set Fan schedule
- $this->Fan_model->setFanSchedule();
-
- // Set Pump schedule
- $this->Pump_model->setPumpSchedule();
-
- redirect($_SERVER['HTTP_REFERER']);
-
- } else {
- // Redirect to login.
- redirect('/login');
- }
- }
-
- // Capture current photo
- public function latestPhoto()
- {
- // Redirect if user not logged in, otherwise display the page.
- if ($this->ion_auth->logged_in())
- {
- $filename = $this->Camera_model->takePhoto();
-
- redirect(asset_url() . "tmp/". $filename);
-
- } else {
- // Redirect to login.
- redirect('/login');
- }
- }
-
- // Reset Admin Default
- public function reset()
- {
- // Page View
- $this->load->view('auth/reset');
-
- }
-
- }
-?>
diff --git a/app/application/controllers/Media.php b/app/application/controllers/Media.php
deleted file mode 100644
index ac4476b..0000000
--- a/app/application/controllers/Media.php
+++ /dev/null
@@ -1,27 +0,0 @@
-load->library('ion_auth');
- $this->load->helper(array('form', 'url'));
- $this->load->library('form_validation');
- $this->load->model('Media_model');
-
- }
-
- // Upload Image
- public function upload_image()
- {
- $this->Media_model->uploadMedia();
- }
-
-}
-
diff --git a/app/application/controllers/Sensors.php b/app/application/controllers/Sensors.php
deleted file mode 100755
index 57e6253..0000000
--- a/app/application/controllers/Sensors.php
+++ /dev/null
@@ -1,1005 +0,0 @@
-load->library('ion_auth');
- $this->load->helper('form');
- $this->load->library('form_validation');
- $this->load->model('Dashboard_model');
- $this->load->model('Moisture_model');
- $this->load->model('Pump_model');
- $this->load->model('Lights_model');
- $this->load->model('Fan_model');
- $this->load->model('Climate_model');
- $this->load->model('Camera_model');
- $this->load->model('Scheduler_model');
- }
-
- /**
- * Sensors - Index
- * Main page for all sensor settings
- *
- * @url /technical
- */
- public function index()
- {
- // Redirect if user not logged in, otherwise display the page.
- if ($this->ion_auth->logged_in())
- {
- // Page Meta
- $data['title'] = 'Technical';
-
- // Data Fetch
- $data['user_info'] = $this->Dashboard_model->get_user_info();
-
- // Page View
- $this->load->view('technical/index', $data);
-
- } else {
- // Redirect to login.
- redirect('/login');
- }
- }
-
- /**
- * Climate Settings
- * Set and modify the DHT22 temperature probe settings.
- *
- * Functions:
- * - Enable\Disable DHT22 temperatur /humidity sensor
- * - Set/Modify the moisture GPIO pin
- * - Sensor dignostics
- *
- * @url /technical/climate
- */
- public function climateSettings()
- {
- // Redirect if user not logged in, otherwise display the page.
- if ($this->ion_auth->logged_in())
- {
- // Page Meta
- $data['title'] = 'Climate Settings';
-
- // Data Fetch
- $data['user_info'] = $this->Dashboard_model->get_user_info();
- $data['GPIO'] = $this->Climate_model->getGPIO();
- $data['activation_state'] = $this->Climate_model->climateActivationState();
- $data['temperature_format'] = $this->Climate_model->getTemperatureFormat();
-
- // Page View
- $this->load->view('technical/climate', $data);
-
- } else {
- // Redirect to login.
- redirect('/login');
- }
- }
-
- // Edit Climate GPIO
- public function editClimateGPIO()
- {
- // Redirect if user not logged in, otherwise display the page.
- if ($this->ion_auth->logged_in())
- {
- $this->Climate_model->setGPIO();
-
- redirect($_SERVER['HTTP_REFERER']);
-
- } else {
- // Redirect to login.
- redirect('/login');
- }
- }
-
- // Set Temperature Format
- public function editTemperatureFormat()
- {
- // Redirect if user not logged in, otherwise display the page.
- if ($this->ion_auth->logged_in())
- {
- $this->Climate_model->setTemperatureFormat();
-
- redirect($_SERVER['HTTP_REFERER']);
-
- } else {
- // Redirect to login.
- redirect('/login');
- }
- }
-
- // Enable Climate Sensor
- public function enableClimateSensor()
- {
- // Redirect if user not logged in, otherwise display the page.
- if ($this->ion_auth->logged_in())
- {
- $this->Climate_model->enableClimateSensor();
-
- redirect($_SERVER['HTTP_REFERER']);
-
- } else {
- // Redirect to login.
- redirect('/login');
- }
- }
-
- // Disable Climate Sensor
- public function disableClimateSensor()
- {
- // Redirect if user not logged in, otherwise display the page.
- if ($this->ion_auth->logged_in())
- {
- $this->Climate_model->disableClimateSensor();
-
- redirect($_SERVER['HTTP_REFERER']);
-
- } else {
- // Redirect to login.
- redirect('/login');
- }
- }
-
- // Climate Diagnostics
- public function climateDiagnostics()
- {
- // Redirect if user not logged in, otherwise display the page.
- if ($this->ion_auth->logged_in())
- {
- $diagnostic_callback = $this->Climate_model->climateDiagnostics();
- print_r($diagnostic_callback);
-
- } else {
- // Redirect to login.
- redirect('/login');
- }
- }
-
- /**
- * Light Settings
- * Set and modify the light settings.
- *
- * Functions:
- * - Enable\Disable lights relay
- * - Set/Modify the relay GPIO pin
- * - Relay dignostics
- *
- * @url /technical/lights
- */
- public function lightSettings()
- {
- // Redirect if user not logged in, otherwise display the page.
- if ($this->ion_auth->logged_in())
- {
- // Page Meta
- $data['title'] = 'Light Settings';
-
- // Data Fetch
- $data['user_info'] = $this->Dashboard_model->get_user_info();
- $data['GPIO'] = $this->Lights_model->getGPIO();
- $data['relay_type'] = $this->Lights_model->getRelayType();
- $data['activation_state'] = $this->Lights_model->lightsActivationState();
- $data['lights_status'] = $this->Lights_model->getLightsStatus();
- $data['lights_ON'] = $this->Lights_model->getLightTimerON();
- $data['lights_OFF'] = $this->Lights_model->getLightTimerOFF();
-
- // Page View
- $this->load->view('technical/lights', $data);
-
- } else {
- // Redirect to login.
- redirect('/login');
- }
- }
-
- // Edit Lights Settings
- public function editLightsSettings()
- {
- // Redirect if user not logged in, otherwise display the page.
- if ($this->ion_auth->logged_in())
- {
- $this->Lights_model->setGPIO();
- $this->Lights_model->setRelayType();
-
- redirect($_SERVER['HTTP_REFERER']);
-
- } else {
- // Redirect to login.
- redirect('/login');
- }
- }
-
- // Enable Lights
- public function enableLights()
- {
- // Redirect if user not logged in, otherwise display the page.
- if ($this->ion_auth->logged_in())
- {
- // Enable Lights
- $this->Lights_model->enableLights();
-
- // Edit CRON
- $this->Scheduler_model->enableCRON("lights");
-
- redirect($_SERVER['HTTP_REFERER']);
-
- } else {
- // Redirect to login.
- redirect('/login');
- }
- }
-
- // Disable Lights
- public function disableLights()
- {
- // Redirect if user not logged in, otherwise display the page.
- if ($this->ion_auth->logged_in())
- {
- // Disable Lights
- $this->Lights_model->disableLights();
-
- // Edit CRON
- $this->Scheduler_model->disableCRON("lights");
-
- redirect($_SERVER['HTTP_REFERER']);
-
- } else {
- // Redirect to login.
- redirect('/login');
- }
- }
-
- // Edit Lighting Schedule
- public function editLightSchedule()
- {
- // Redirect if user not logged in, otherwise display the page.
- if ($this->ion_auth->logged_in())
- {
- // Change lighting schedule in DB
- $lightsON = $this->Lights_model->setLightTimerON();
- $lightsOFF = $this->Lights_model->setLightTimerOFF();
-
- // Relay Type
- $relayType = $this->Lights_model->getRelayType();
-
- // Edit CRON
- $this->Scheduler_model->editLightsCRON($lightsON, $lightsOFF, $relayType);
-
- redirect($_SERVER['HTTP_REFERER']);
-
- } else {
- // Redirect to login.
- redirect('/login');
- }
- }
-
- // Light Diagnostics
- public function lightsDiagnostics()
- {
- // Redirect if user not logged in, otherwise display the page.
- if ($this->ion_auth->logged_in())
- {
- $diagnostic_callback = $this->Lights_model->lightsDiagnostics();
- print_r($diagnostic_callback);
-
- } else {
- // Redirect to login.
- redirect('/login');
- }
- }
-
- // Lights ON
- public function lightsON()
- {
- // Redirect if user not logged in, otherwise display the page.
- if ($this->ion_auth->logged_in())
- {
- $this->Lights_model->lightsON();
-
- redirect($_SERVER['HTTP_REFERER']);
-
- } else {
- // Redirect to login.
- redirect('/login');
- }
- }
-
- // Lights OFF
- public function lightsOFF()
- {
- // Redirect if user not logged in, otherwise display the page.
- if ($this->ion_auth->logged_in())
- {
- $this->Lights_model->lightsOFF();
-
- redirect($_SERVER['HTTP_REFERER']);
-
- } else {
- // Redirect to login.
- redirect('/login');
- }
- }
-
- /**
- * Fan Settings
- * Set and modify the fan settings.
- *
- * Functions:
- * - Enable\Disable fan relay
- * - Set/Modify the relay GPIO pin
- * - Relay dignostics
- *
- * @url /technical/fans
- */
- public function fanSettings()
- {
- // Redirect if user not logged in, otherwise display the page.
- if ($this->ion_auth->logged_in())
- {
- // Page Meta
- $data['title'] = 'Fan Settings';
-
- // Data Fetch
- $data['user_info'] = $this->Dashboard_model->get_user_info();
- $data['GPIO'] = $this->Fan_model->getGPIO();
- $data['relay_type'] = $this->Fan_model->getRelayType();
- $data['activation_state'] = $this->Fan_model->fanActivationState();
- $data['fan_schedule'] = $this->Fan_model->getFanSchedule();
- $data['fan_status'] = $this->Fan_model->getFanStatus();
- $data['temperature_format'] = $this->Climate_model->getTemperatureFormat();
-
- // Page View
- $this->load->view('technical/fans', $data);
-
- } else {
- // Redirect to login.
- redirect('/login');
- }
- }
-
- // Edit Fan Settings
- public function editFanSettings()
- {
- // Redirect if user not logged in, otherwise display the page.
- if ($this->ion_auth->logged_in())
- {
- $this->Fan_model->setGPIO();
- $this->Fan_model->setRelayType();
-
- redirect($_SERVER['HTTP_REFERER']);
-
- } else {
- // Redirect to login.
- redirect('/login');
- }
- }
-
- // Edit Fan Schedule
- public function editFanSchedule()
- {
- // Redirect if user not logged in, otherwise display the page.
- if ($this->ion_auth->logged_in())
- {
- $fan_duration = $this->Fan_model->setFanSchedule();
-
- // Relay Type
- $relayType = $this->Fan_model->getRelayType();
-
- // Edit CRON
- $this->Scheduler_model->editFanCRON($fan_duration, $relayType);
-
- redirect($_SERVER['HTTP_REFERER']);
-
- } else {
- // Redirect to login.
- redirect('/login');
- }
- }
-
- // Enable Fans
- public function enableFan()
- {
- // Redirect if user not logged in, otherwise display the page.
- if ($this->ion_auth->logged_in())
- {
- // Enable Fans
- $this->Fan_model->enableFans();
-
- // Enable CRON
- $this->Scheduler_model->enableCRON("fan");
-
- redirect($_SERVER['HTTP_REFERER']);
-
- } else {
- // Redirect to login.
- redirect('/login');
- }
- }
-
- // Disable Fans
- public function disableFan()
- {
- // Redirect if user not logged in, otherwise display the page.
- if ($this->ion_auth->logged_in())
- {
- // Disable fans
- $this->Fan_model->disableFans();
-
- // Disable CRON
- $this->Scheduler_model->disableCRON("fan");
-
- redirect($_SERVER['HTTP_REFERER']);
-
- } else {
- // Redirect to login.
- redirect('/login');
- }
- }
-
- // Fan Diagnostics
- public function fanDiagnostics()
- {
- // Redirect if user not logged in, otherwise display the page.
- if ($this->ion_auth->logged_in())
- {
- $diagnostic_callback = $this->Fan_model->fanDiagnostics();
- print_r($diagnostic_callback);
-
- } else {
- // Redirect to login.
- redirect('/login');
- }
- }
-
- // Fan ON
- public function fanON()
- {
- // Redirect if user not logged in, otherwise display the page.
- if ($this->ion_auth->logged_in())
- {
- $this->Fan_model->fanON();
-
- redirect($_SERVER['HTTP_REFERER']);
-
- } else {
- // Redirect to login.
- redirect('/login');
- }
- }
-
- // Fan OFF
- public function fanOFF()
- {
- // Redirect if user not logged in, otherwise display the page.
- if ($this->ion_auth->logged_in())
- {
- $this->Fan_model->fanOFF();
-
- redirect($_SERVER['HTTP_REFERER']);
-
- } else {
- // Redirect to login.
- redirect('/login');
- }
- }
-
- /**
- * Camera Settings
- * Set and modify the camera settings.
- *
- * Functions:
- * - Enable\Disable camera module
- * - Set photo capture interval
- * - Take photo
- * - Camera dignostics
- *
- * @url /technical/camera
- */
- public function cameraSettings()
- {
- // Redirect if user not logged in, otherwise display the page.
- if ($this->ion_auth->logged_in())
- {
- // Page Meta
- $data['title'] = 'Camera Settings';
-
- // Data Fetch
- $data['user_info'] = $this->Dashboard_model->get_user_info();
- $data['activation_state'] = $this->Camera_model->cameraActivationState();
-
- // Page View
- $this->load->view('technical/camera', $data);
-
- } else {
- // Redirect to login.
- redirect('/login');
- }
- }
-
- // Enable Camera
- public function enableCamera()
- {
- // Redirect if user not logged in, otherwise display the page.
- if ($this->ion_auth->logged_in())
- {
- // Enablle Camera
- $this->Camera_model->enableCamera();
-
- // Enable CRON
- $this->Scheduler_model->enableCRON("camera");
-
- redirect($_SERVER['HTTP_REFERER']);
-
- } else {
- // Redirect to login.
- redirect('/login');
- }
- }
-
- // Disable Camera
- public function disableCamera()
- {
- // Redirect if user not logged in, otherwise display the page.
- if ($this->ion_auth->logged_in())
- {
- // Disable Camera
- $this->Camera_model->disableCamera();
-
- // Disable CRON
- $this->Scheduler_model->disableCRON("camera");
-
- redirect($_SERVER['HTTP_REFERER']);
-
- } else {
- // Redirect to login.
- redirect('/login');
- }
- }
-
- // Capture photo
- public function capturePhoto()
- {
- // Redirect if user not logged in, otherwise display the page.
- if ($this->ion_auth->logged_in())
- {
- $filename = $this->Camera_model->takePhoto();
-
- echo $filename;
-
- } else {
- // Redirect to login.
- redirect('/login');
- }
- }
-
- // Camera Diagnostics
- public function cameraDiagnostics()
- {
- // Redirect if user not logged in, otherwise display the page.
- if ($this->ion_auth->logged_in())
- {
- $diagnostic_callback = $this->Camera_model->cameraDiagnostics();
- print_r($diagnostic_callback);
-
- } else {
- // Redirect to login.
- redirect('/login');
- }
- }
-
- /**
- * Pump Settings
- * Set and modify the water pump settings.
- *
- * Functions:
- * - Enable\Disable water pump relay
- * - Set/Modify the water pump relay GPIO pin
- * - Relay dignostics
- *
- * @url /technical/pump
- */
- public function pumpSettings()
- {
- // Redirect if user not logged in, otherwise display the page.
- if ($this->ion_auth->logged_in())
- {
- // Page Meta
- $data['title'] = 'Pump Settings';
-
- // Data Fetch
- $data['user_info'] = $this->Dashboard_model->get_user_info();
- $data['GPIO'] = $this->Pump_model->getGPIO();
- $data['relay_type'] = $this->Pump_model->getRelayType();
- $data['activation_state'] = $this->Pump_model->pumpActivationState();
- $data['pump_schedule'] = $this->Pump_model->getPumpSchedule();
- $data['pump_status'] = $this->Pump_model->getPumpStatus();
-
- // Page View
- $this->load->view('technical/pump', $data);
-
- } else {
- // Redirect to login.
- redirect('/login');
- }
- }
-
- // Edit Moisture Settings
- public function editPumpSettings()
- {
- // Redirect if user not logged in, otherwise display the page.
- if ($this->ion_auth->logged_in())
- {
- $this->Pump_model->setGPIO();
- $this->Pump_model->setRelayType();
-
- redirect($_SERVER['HTTP_REFERER']);
-
- } else {
- // Redirect to login.
- redirect('/login');
- }
- }
-
- // Edit Pump Schedule
- public function editPumpSchedule()
- {
- // Redirect if user not logged in, otherwise display the page.
- if ($this->ion_auth->logged_in())
- {
- $this->Pump_model->setPumpSchedule();
-
- redirect($_SERVER['HTTP_REFERER']);
-
- } else {
- // Redirect to login.
- redirect('/login');
- }
- }
-
- // Enable Pump
- public function enablePump()
- {
- // Redirect if user not logged in, otherwise display the page.
- if ($this->ion_auth->logged_in())
- {
- // Enable Pump
- $this->Pump_model->enablePump();
-
- // Edit CRON
- $this->Scheduler_model->enableCRON("pump");
-
- redirect($_SERVER['HTTP_REFERER']);
-
- } else {
- // Redirect to login.
- redirect('/login');
- }
- }
-
- // Disable Pump
- public function disablePump()
- {
- // Redirect if user not logged in, otherwise display the page.
- if ($this->ion_auth->logged_in())
- {
- // Disable Pump
- $this->Pump_model->disablePump();
-
- // Edit CRON
- $this->Scheduler_model->disableCRON("pump");
-
- redirect($_SERVER['HTTP_REFERER']);
-
- } else {
- // Redirect to login.
- redirect('/login');
- }
- }
-
- // Pump Diagnostics
- public function pumpDiagnostics()
- {
- // Redirect if user not logged in, otherwise display the page.
- if ($this->ion_auth->logged_in())
- {
- $diagnostic_callback = $this->Pump_model->pumpDiagnostics();
- print_r($diagnostic_callback);
-
- } else {
- // Redirect to login.
- redirect('/login');
- }
- }
-
- // Pump ON
- public function pumpON()
- {
- // Redirect if user not logged in, otherwise display the page.
- if ($this->ion_auth->logged_in())
- {
- $this->Pump_model->pumpON();
-
- redirect($_SERVER['HTTP_REFERER']);
-
- } else {
- // Redirect to login.
- redirect('/login');
- }
- }
-
- // Pump OFF
- public function pumpOFF()
- {
- // Redirect if user not logged in, otherwise display the page.
- if ($this->ion_auth->logged_in())
- {
- $this->Pump_model->pumpOFF();
-
- redirect($_SERVER['HTTP_REFERER']);
-
- } else {
- // Redirect to login.
- redirect('/login');
- }
- }
-
- /**
- * Moisture Probe Settings
- * Set and modify the moisture probe settings.
- *
- * Functions:
- * - Enable\Disable moisture probe
- * - Set/Modify the moisture probe GPIO pin
- * - Moisture probe dignostics
- *
- * @url /technical/moisture
- */
- public function moistureSettings()
- {
- // Redirect if user not logged in, otherwise display the page.
- if ($this->ion_auth->logged_in())
- {
- // Page Meta
- $data['title'] = 'Moisture Probe Settings';
-
- // Data Fetch
- $data['user_info'] = $this->Dashboard_model->get_user_info();
- $data['GPIO'] = $this->Moisture_model->getGPIO();
- $data['activation_state'] = $this->Moisture_model->moistureActivationState();
-
- // Page View
- $this->load->view('technical/moisture', $data);
-
- } else {
- // Redirect to login.
- redirect('/login');
- }
- }
-
- // Edit Moisture GPIO
- public function editMoistureGPIO()
- {
- // Redirect if user not logged in, otherwise display the page.
- if ($this->ion_auth->logged_in())
- {
- $this->Moisture_model->setGPIO();
-
- redirect($_SERVER['HTTP_REFERER']);
-
- } else {
- // Redirect to login.
- redirect('/login');
- }
- }
-
- // Enable Moisture Sensor
- public function enableMoistureSensor()
- {
- // Redirect if user not logged in, otherwise display the page.
- if ($this->ion_auth->logged_in())
- {
- $this->Moisture_model->enableMoistureSensor();
-
- redirect($_SERVER['HTTP_REFERER']);
-
- } else {
- // Redirect to login.
- redirect('/login');
- }
- }
-
- // Disable Moisture Sensor
- public function disableMoistureSensor()
- {
- // Redirect if user not logged in, otherwise display the page.
- if ($this->ion_auth->logged_in())
- {
- $this->Moisture_model->disableMoistureSensor();
-
- redirect($_SERVER['HTTP_REFERER']);
-
- } else {
- // Redirect to login.
- redirect('/login');
- }
- }
-
- // Moisture Probe Diagnostics
- public function moistureDiagnostics()
- {
- // Redirect if user not logged in, otherwise display the page.
- if ($this->ion_auth->logged_in())
- {
- $diagnostic_callback = $this->Moisture_model->moistureDiagnostics();
- print_r($diagnostic_callback);
-
- } else {
- // Redirect to login.
- redirect('/login');
- }
- }
-
- /**
- * Heater Settings
- * Set and modify the heater settings.
- *
- * Functions:
- * - Enable\Disable heater relay
- * - Set/Modify the heater GPIO pin
- * - Relay dignostics
- *
- * @url /technical/heater
- */
- public function heaterSettings()
- {
- // Redirect if user not logged in, otherwise display the page.
- if ($this->ion_auth->logged_in())
- {
- // Page Meta
- $data['title'] = 'Heater Settings';
-
- // Data Fetch
- $data['user_info'] = $this->Dashboard_model->get_user_info();
- $data['GPIO'] = $this->Fan_model->getGPIO();
- $data['activation_state'] = $this->Fan_model->fanActivationState();
- $data['fan_schedule'] = $this->Fan_model->getFanSchedule();
- $data['fan_status'] = $this->Fan_model->getFanStatus();
- $data['temperature_format'] = $this->Climate_model->getTemperatureFormat();
-
- // Page View
- $this->load->view('technical/heater', $data);
-
- } else {
- // Redirect to login.
- redirect('/login');
- }
- }
-
- // Edit Heater GPIO
- public function editHeaterGPIO()
- {
- // Redirect if user not logged in, otherwise display the page.
- if ($this->ion_auth->logged_in())
- {
- $this->Fan_model->setGPIO();
-
- redirect($_SERVER['HTTP_REFERER']);
-
- } else {
- // Redirect to login.
- redirect('/login');
- }
- }
-
- // Edit Heater Schedule
- public function editHeaterSchedule()
- {
- // Redirect if user not logged in, otherwise display the page.
- if ($this->ion_auth->logged_in())
- {
- $this->Fan_model->setFanSchedule();
-
- redirect($_SERVER['HTTP_REFERER']);
-
- } else {
- // Redirect to login.
- redirect('/login');
- }
- }
-
- // Enable Heater
- public function enableHeater()
- {
- // Redirect if user not logged in, otherwise display the page.
- if ($this->ion_auth->logged_in())
- {
- // Enable Fans
- $this->Fan_model->enableFans();
-
- // Enable CRON
- $this->Scheduler_model->enableCRON("fan");
-
- redirect($_SERVER['HTTP_REFERER']);
-
- } else {
- // Redirect to login.
- redirect('/login');
- }
- }
-
- // Disable Heater
- public function disableHeater()
- {
- // Redirect if user not logged in, otherwise display the page.
- if ($this->ion_auth->logged_in())
- {
- // Disable fans
- $this->Fan_model->disableFans();
-
- // Disable CRON
- $this->Scheduler_model->disableCRON("fan");
-
- redirect($_SERVER['HTTP_REFERER']);
-
- } else {
- // Redirect to login.
- redirect('/login');
- }
- }
-
- // Heater Diagnostics
- public function heaterDiagnostics()
- {
- // Redirect if user not logged in, otherwise display the page.
- if ($this->ion_auth->logged_in())
- {
- $diagnostic_callback = $this->Fan_model->fanDiagnostics();
- print_r($diagnostic_callback);
-
- } else {
- // Redirect to login.
- redirect('/login');
- }
- }
-
- // Heater ON
- public function heaterON()
- {
- // Redirect if user not logged in, otherwise display the page.
- if ($this->ion_auth->logged_in())
- {
- $this->Fan_model->fanON();
-
- redirect($_SERVER['HTTP_REFERER']);
-
- } else {
- // Redirect to login.
- redirect('/login');
- }
- }
-
- // Heater OFF
- public function heaterOFF()
- {
- // Redirect if user not logged in, otherwise display the page.
- if ($this->ion_auth->logged_in())
- {
- $this->Fan_model->fanOFF();
-
- redirect($_SERVER['HTTP_REFERER']);
-
- } else {
- // Redirect to login.
- redirect('/login');
- }
- }
-
-}
-
diff --git a/app/application/controllers/index.html b/app/application/controllers/index.html
deleted file mode 100755
index b702fbc..0000000
--- a/app/application/controllers/index.html
+++ /dev/null
@@ -1,11 +0,0 @@
-
-
-
- 403 Forbidden
-
-
-
-Directory access is forbidden.
-
-
-
diff --git a/app/application/core/index.html b/app/application/core/index.html
deleted file mode 100755
index b702fbc..0000000
--- a/app/application/core/index.html
+++ /dev/null
@@ -1,11 +0,0 @@
-
-
-
- 403 Forbidden
-
-
-
-Directory access is forbidden.
-
-
-
diff --git a/app/application/helpers/index.html b/app/application/helpers/index.html
deleted file mode 100755
index b702fbc..0000000
--- a/app/application/helpers/index.html
+++ /dev/null
@@ -1,11 +0,0 @@
-
-
-
- 403 Forbidden
-
-
-
-Directory access is forbidden.
-
-
-
diff --git a/app/application/helpers/utility_helper.php b/app/application/helpers/utility_helper.php
deleted file mode 100755
index 2e69ebc..0000000
--- a/app/application/helpers/utility_helper.php
+++ /dev/null
@@ -1,46 +0,0 @@
- 'year',
- 30 * 24 * 60 * 60 => 'month',
- 24 * 60 * 60 => 'day',
- 60 * 60 => 'hour',
- 60 => 'minute',
- 1 => 'second'
- );
-
- foreach( $condition as $secs => $str )
- {
- $d = $estimate_time / $secs;
-
- if( $d >= 1 )
- {
- $r = round( $d );
- return 'about ' . $r . ' ' . $str . ( $r > 1 ? 's' : '' ) . ' ago';
- }
- }
-}
-
-function celsiusToFahrenheit($degrees) {
- return round((float)$degrees * 1.8 + 32, 2);
-}
-
-function fahrenheitToCelsius($degrees)
-{
- return round(((float)$degrees - 32) / 1.8, 2);
-}
-
-?>
diff --git a/app/application/hooks/index.html b/app/application/hooks/index.html
deleted file mode 100755
index b702fbc..0000000
--- a/app/application/hooks/index.html
+++ /dev/null
@@ -1,11 +0,0 @@
-
-
-
- 403 Forbidden
-
-
-
-Directory access is forbidden.
-
-
-
diff --git a/app/application/index.html b/app/application/index.html
deleted file mode 100755
index b702fbc..0000000
--- a/app/application/index.html
+++ /dev/null
@@ -1,11 +0,0 @@
-
-
-
- 403 Forbidden
-
-
-
-Directory access is forbidden.
-
-
-
diff --git a/app/application/language/english/auth_lang.php b/app/application/language/english/auth_lang.php
deleted file mode 100755
index 8b26ad3..0000000
--- a/app/application/language/english/auth_lang.php
+++ /dev/null
@@ -1,145 +0,0 @@
-
-
-
- 403 Forbidden
-
-
-
-Directory access is forbidden.
-
-
-
diff --git a/app/application/language/english/ion_auth_lang.php b/app/application/language/english/ion_auth_lang.php
deleted file mode 100755
index 06f8e2a..0000000
--- a/app/application/language/english/ion_auth_lang.php
+++ /dev/null
@@ -1,79 +0,0 @@
-
-
-
- 403 Forbidden
-
-
-
-Directory access is forbidden.
-
-
-
diff --git a/app/application/libraries/Bcrypt.php b/app/application/libraries/Bcrypt.php
deleted file mode 100755
index c2ea95a..0000000
--- a/app/application/libraries/Bcrypt.php
+++ /dev/null
@@ -1,231 +0,0 @@
- 7, 'salt_prefix' => '$2y$'))
- {
-
- if (CRYPT_BLOWFISH != 1)
- {
- throw new Exception("bcrypt not supported in this installation. See http://php.net/crypt");
- }
-
- $this->rounds = $params['rounds'];
- $this->salt_prefix = $params['salt_prefix'];
- }
-
- /**
- * @param string $input
- *
- * @return bool|string
- */
- public function hash($input)
- {
- $hash = crypt($input, $this->getSalt());
-
- if (strlen($hash) > 13)
- {
- return $hash;
- }
-
- return FALSE;
- }
-
- /**
- * @param string $input
- * @param string $existingHash
- *
- * @return bool
- */
- public function verify($input, $existingHash)
- {
- $hash = crypt($input, $existingHash);
- return $this->hashEquals($existingHash, $hash);
- }
-
- /**
- * Polyfill for hash_equals()
- * Code mainly taken from hash_equals() compat function of CodeIgniter 3
- *
- * @param string $known_string
- * @param string $user_string
- *
- * @return bool
- */
- private function hashEquals($known_string, $user_string)
- {
- // For CI3 or PHP >= 5.6
- if (function_exists('hash_equals'))
- {
- return hash_equals($known_string, $user_string);
- }
-
- // For CI2 with PHP < 5.6
- // Code from CI3 https://github.com/bcit-ci/CodeIgniter/blob/develop/system/core/compat/hash.php
- if (!is_string($known_string))
- {
- trigger_error('hash_equals(): Expected known_string to be a string, ' . strtolower(gettype($known_string)) . ' given', E_USER_WARNING);
- return FALSE;
- }
- else if (!is_string($user_string))
- {
- trigger_error('hash_equals(): Expected user_string to be a string, ' . strtolower(gettype($user_string)) . ' given', E_USER_WARNING);
- return FALSE;
- }
- else if (($length = strlen($known_string)) !== strlen($user_string))
- {
- return FALSE;
- }
-
- $diff = 0;
- for ($i = 0; $i < $length; $i++)
- {
- $diff |= ord($known_string[$i]) ^ ord($user_string[$i]);
- }
-
- return ($diff === 0);
- }
-
- /**
- * @return string
- */
- private function getSalt()
- {
- $salt = sprintf($this->salt_prefix . '%02d$', $this->rounds);
-
- $bytes = $this->getRandomBytes(16);
-
- $salt .= $this->encodeBytes($bytes);
-
- return $salt;
- }
-
- /**
- * @param $count
- *
- * @return string
- */
- private function getRandomBytes($count)
- {
- $bytes = '';
-
- if (function_exists('openssl_random_pseudo_bytes') &&
- (strtoupper(substr(PHP_OS, 0, 3)) !== 'WIN'))
- {
- // OpenSSL slow on Win
- $bytes = openssl_random_pseudo_bytes($count);
- }
-
- if ($bytes === '' && @is_readable('/dev/urandom') &&
- ($hRand = @fopen('/dev/urandom', 'rb')) !== FALSE)
- {
- $bytes = fread($hRand, $count);
- fclose($hRand);
- }
-
- if (strlen($bytes) < $count)
- {
- $bytes = '';
-
- if ($this->randomState === NULL)
- {
- $this->randomState = microtime();
- if (function_exists('getmypid'))
- {
- $this->randomState .= getmypid();
- }
- }
-
- for ($i = 0; $i < $count; $i += 16)
- {
- $this->randomState = md5(microtime() . $this->randomState);
-
- if (PHP_VERSION >= '5')
- {
- $bytes .= md5($this->randomState, TRUE);
- }
- else
- {
- $bytes .= pack('H*', md5($this->randomState));
- }
- }
-
- $bytes = substr($bytes, 0, $count);
- }
-
- return $bytes;
- }
-
- /**
- * @param string $input
- *
- * @return string
- */
- private function encodeBytes($input)
- {
- // The following is code from the PHP Password Hashing Framework
- $itoa64 = './ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
-
- $output = '';
- $i = 0;
- do
- {
- $c1 = ord($input[$i++]);
- $output .= $itoa64[$c1 >> 2];
- $c1 = ($c1 & 0x03) << 4;
- if ($i >= 16)
- {
- $output .= $itoa64[$c1];
- break;
- }
-
- $c2 = ord($input[$i++]);
- $c1 |= $c2 >> 4;
- $output .= $itoa64[$c1];
- $c1 = ($c2 & 0x0f) << 2;
-
- $c2 = ord($input[$i++]);
- $c1 |= $c2 >> 6;
- $output .= $itoa64[$c1];
- $output .= $itoa64[$c2 & 0x3f];
- } while (1);
-
- return $output;
- }
-}
diff --git a/app/application/libraries/Ion_auth.php b/app/application/libraries/Ion_auth.php
deleted file mode 100755
index 2e585fb..0000000
--- a/app/application/libraries/Ion_auth.php
+++ /dev/null
@@ -1,551 +0,0 @@
-config->load('ion_auth', TRUE);
- $this->load->library(array('email'));
- $this->lang->load('ion_auth');
- $this->load->helper(array('cookie', 'language','url'));
-
- $this->load->library('session');
-
- $this->load->model('ion_auth_model');
-
- $this->_cache_user_in_group =& $this->ion_auth_model->_cache_user_in_group;
-
- $email_config = $this->config->item('email_config', 'ion_auth');
-
- if ($this->config->item('use_ci_email', 'ion_auth') && isset($email_config) && is_array($email_config))
- {
- $this->email->initialize($email_config);
- }
-
- $this->ion_auth_model->trigger_events('library_constructor');
- }
-
- /**
- * __call
- *
- * Acts as a simple way to call model methods without loads of stupid alias'
- *
- * @param string $method
- * @param array $arguments
- *
- * @return mixed
- * @throws Exception
- */
- public function __call($method, $arguments)
- {
- if (!method_exists( $this->ion_auth_model, $method) )
- {
- throw new Exception('Undefined method Ion_auth::' . $method . '() called');
- }
- if($method == 'create_user')
- {
- return call_user_func_array(array($this, 'register'), $arguments);
- }
- if($method=='update_user')
- {
- return call_user_func_array(array($this, 'update'), $arguments);
- }
- return call_user_func_array( array($this->ion_auth_model, $method), $arguments);
- }
-
- /**
- * __get
- *
- * Enables the use of CI super-global without having to define an extra variable.
- *
- * I can't remember where I first saw this, so thank you if you are the original author. -Militis
- *
- * @param string $var
- *
- * @return mixed
- */
- public function __get($var)
- {
- return get_instance()->$var;
- }
-
- /**
- * Forgotten password feature
- *
- * @param string $identity
- *
- * @return array|bool
- * @author Mathew
- */
- public function forgotten_password($identity)
- {
- if ($this->ion_auth_model->forgotten_password($identity))
- {
- // Get user information
- $identifier = $this->ion_auth_model->identity_column; // use model identity column, so it can be overridden in a controller
- $user = $this->where($identifier, $identity)->where('active', 1)->users()->row();
-
- if ($user)
- {
- $data = array(
- 'identity' => $user->{$this->config->item('identity', 'ion_auth')},
- 'forgotten_password_code' => $user->forgotten_password_code
- );
-
- if (!$this->config->item('use_ci_email', 'ion_auth'))
- {
- $this->set_message('forgot_password_successful');
- return $data;
- }
- else
- {
- $message = $this->load->view($this->config->item('email_templates', 'ion_auth') . $this->config->item('email_forgot_password', 'ion_auth'), $data, TRUE);
- $this->email->clear();
- $this->email->from($this->config->item('admin_email', 'ion_auth'), $this->config->item('site_title', 'ion_auth'));
- $this->email->to($user->email);
- $this->email->subject($this->config->item('site_title', 'ion_auth') . ' - ' . $this->lang->line('email_forgotten_password_subject'));
- $this->email->message($message);
-
- if ($this->email->send())
- {
- $this->set_message('forgot_password_successful');
- return TRUE;
- }
- else
- {
- $this->set_error('forgot_password_unsuccessful');
- return FALSE;
- }
- }
- }
- else
- {
- $this->set_error('forgot_password_unsuccessful');
- return FALSE;
- }
- }
- else
- {
- $this->set_error('forgot_password_unsuccessful');
- return FALSE;
- }
- }
-
- /**
- * forgotten_password_complete
- *
- * @param string $code
- *
- * @return array|bool
- * @author Mathew
- */
- public function forgotten_password_complete($code)
- {
- $this->ion_auth_model->trigger_events('pre_password_change');
-
- $identity = $this->config->item('identity', 'ion_auth');
- $profile = $this->where('forgotten_password_code', $code)->users()->row(); // pass the code to profile
-
- if (!$profile)
- {
- $this->ion_auth_model->trigger_events(array('post_password_change', 'password_change_unsuccessful'));
- $this->set_error('password_change_unsuccessful');
- return FALSE;
- }
-
- $new_password = $this->ion_auth_model->forgotten_password_complete($code, $profile->salt);
-
- if ($new_password)
- {
- $data = array(
- 'identity' => $profile->{$identity},
- 'new_password' => $new_password
- );
- if(!$this->config->item('use_ci_email', 'ion_auth'))
- {
- $this->set_message('password_change_successful');
- $this->ion_auth_model->trigger_events(array('post_password_change', 'password_change_successful'));
- return $data;
- }
- else
- {
- $message = $this->load->view($this->config->item('email_templates', 'ion_auth').$this->config->item('email_forgot_password_complete', 'ion_auth'), $data, true);
-
- $this->email->clear();
- $this->email->from($this->config->item('admin_email', 'ion_auth'), $this->config->item('site_title', 'ion_auth'));
- $this->email->to($profile->email);
- $this->email->subject($this->config->item('site_title', 'ion_auth') . ' - ' . $this->lang->line('email_new_password_subject'));
- $this->email->message($message);
-
- if ($this->email->send())
- {
- $this->set_message('password_change_successful');
- $this->ion_auth_model->trigger_events(array('post_password_change', 'password_change_successful'));
- return TRUE;
- }
- else
- {
- $this->set_error('password_change_unsuccessful');
- $this->ion_auth_model->trigger_events(array('post_password_change', 'password_change_unsuccessful'));
- return FALSE;
- }
-
- }
- }
-
- $this->ion_auth_model->trigger_events(array('post_password_change', 'password_change_unsuccessful'));
- return FALSE;
- }
-
- /**
- * forgotten_password_check
- *
- * @param string $code
- *
- * @return object|bool
- * @author Michael
- */
- public function forgotten_password_check($code)
- {
- $profile = $this->where('forgotten_password_code', $code)->users()->row(); // pass the code to profile
-
- if (!is_object($profile))
- {
- $this->set_error('password_change_unsuccessful');
- return FALSE;
- }
- else
- {
- if ($this->config->item('forgot_password_expiration', 'ion_auth') > 0)
- {
- //Make sure it isn't expired
- $expiration = $this->config->item('forgot_password_expiration', 'ion_auth');
- if (time() - $profile->forgotten_password_time > $expiration)
- {
- //it has expired
- $this->ion_auth_model->clear_forgotten_password_code($code);
- $this->set_error('password_change_unsuccessful');
- return FALSE;
- }
- }
- return $profile;
- }
- }
-
- /**
- * register
- *
- * @param string $identity
- * @param string $password
- * @param string $email
- * @param array $additional_data
- * @param array $group_ids
- *
- * @return int|array|bool The new user's ID if e-mail activation is disabled or Ion-Auth e-mail activation was
- * completed; or an array of activation details if CI e-mail validation is enabled; or FALSE
- * if the operation failed.
- * @author Mathew
- */
- public function register($identity, $password, $email, $additional_data = array(), $group_ids = array())
- {
- $this->ion_auth_model->trigger_events('pre_account_creation');
-
- $email_activation = $this->config->item('email_activation', 'ion_auth');
-
- $id = $this->ion_auth_model->register($identity, $password, $email, $additional_data, $group_ids);
-
- if (!$email_activation)
- {
- if ($id !== FALSE)
- {
- $this->set_message('account_creation_successful');
- $this->ion_auth_model->trigger_events(array('post_account_creation', 'post_account_creation_successful'));
- return $id;
- }
- else
- {
- $this->set_error('account_creation_unsuccessful');
- $this->ion_auth_model->trigger_events(array('post_account_creation', 'post_account_creation_unsuccessful'));
- return FALSE;
- }
- }
- else
- {
- if (!$id)
- {
- $this->set_error('account_creation_unsuccessful');
- return FALSE;
- }
-
- // deactivate so the user much follow the activation flow
- $deactivate = $this->ion_auth_model->deactivate($id);
-
- // the deactivate method call adds a message, here we need to clear that
- $this->ion_auth_model->clear_messages();
-
-
- if (!$deactivate)
- {
- $this->set_error('deactivate_unsuccessful');
- $this->ion_auth_model->trigger_events(array('post_account_creation', 'post_account_creation_unsuccessful'));
- return FALSE;
- }
-
- $activation_code = $this->ion_auth_model->activation_code;
- $identity = $this->config->item('identity', 'ion_auth');
- $user = $this->ion_auth_model->user($id)->row();
-
- $data = array(
- 'identity' => $user->{$identity},
- 'id' => $user->id,
- 'email' => $email,
- 'activation' => $activation_code,
- );
- if(!$this->config->item('use_ci_email', 'ion_auth'))
- {
- $this->ion_auth_model->trigger_events(array('post_account_creation', 'post_account_creation_successful', 'activation_email_successful'));
- $this->set_message('activation_email_successful');
- return $data;
- }
- else
- {
- $message = $this->load->view($this->config->item('email_templates', 'ion_auth').$this->config->item('email_activate', 'ion_auth'), $data, true);
-
- $this->email->clear();
- $this->email->from($this->config->item('admin_email', 'ion_auth'), $this->config->item('site_title', 'ion_auth'));
- $this->email->to($email);
- $this->email->subject($this->config->item('site_title', 'ion_auth') . ' - ' . $this->lang->line('email_activation_subject'));
- $this->email->message($message);
-
- if ($this->email->send() === TRUE)
- {
- $this->ion_auth_model->trigger_events(array('post_account_creation', 'post_account_creation_successful', 'activation_email_successful'));
- $this->set_message('activation_email_successful');
- return $id;
- }
-
- }
-
- $this->ion_auth_model->trigger_events(array('post_account_creation', 'post_account_creation_unsuccessful', 'activation_email_unsuccessful'));
- $this->set_error('activation_email_unsuccessful');
- return FALSE;
- }
- }
-
- /**
- * Logout
- *
- * @return true
- * @author Mathew
- **/
- public function logout()
- {
- $this->ion_auth_model->trigger_events('logout');
-
- $identity = $this->config->item('identity', 'ion_auth');
-
- if (substr(CI_VERSION, 0, 1) == '2')
- {
- $this->session->unset_userdata(array($identity => '', 'id' => '', 'user_id' => ''));
- }
- else
- {
- $this->session->unset_userdata(array($identity, 'id', 'user_id'));
- }
-
- // delete the remember me cookies if they exist
- if (get_cookie($this->config->item('identity_cookie_name', 'ion_auth')))
- {
- delete_cookie($this->config->item('identity_cookie_name', 'ion_auth'));
- }
- if (get_cookie($this->config->item('remember_cookie_name', 'ion_auth')))
- {
- delete_cookie($this->config->item('remember_cookie_name', 'ion_auth'));
- }
-
- // Destroy the session
- $this->session->sess_destroy();
-
- //Recreate the session
- if (substr(CI_VERSION, 0, 1) == '2')
- {
- $this->session->sess_create();
- }
- else
- {
- if (version_compare(PHP_VERSION, '7.0.0') >= 0)
- {
- session_start();
- }
- $this->session->sess_regenerate(TRUE);
- }
-
- $this->set_message('logout_successful');
- return TRUE;
- }
-
- /**
- * Auto logs-in the user if they are remembered
- * @return bool Whether the user is logged in
- * @author Mathew
- **/
- public function logged_in()
- {
- $this->ion_auth_model->trigger_events('logged_in');
-
- $recheck = $this->ion_auth_model->recheck_session();
-
- // auto-login the user if they are remembered
- if (!$recheck && get_cookie($this->config->item('identity_cookie_name', 'ion_auth')) && get_cookie($this->config->item('remember_cookie_name', 'ion_auth')))
- {
- $recheck = $this->ion_auth_model->login_remembered_user();
- }
-
- return $recheck;
- }
-
- /**
- * @return int|null The user's ID from the session user data or NULL if not found
- * @author jrmadsen67
- **/
- public function get_user_id()
- {
- $user_id = $this->session->userdata('user_id');
- if (!empty($user_id))
- {
- return $user_id;
- }
- return NULL;
- }
-
- /**
- * @param int|string|bool $id
- *
- * @return bool Whether the user is an administrator
- * @author Ben Edmunds
- */
- public function is_admin($id = FALSE)
- {
- $this->ion_auth_model->trigger_events('is_admin');
-
- $admin_group = $this->config->item('admin_group', 'ion_auth');
-
- return $this->in_group($admin_group, $id);
- }
-
- /**
- * @param int|string|array $check_group group(s) to check
- * @param int|string|bool $id user id
- * @param bool $check_all check if all groups is present, or any of the groups
- *
- * @return bool Whether the/all user(s) with the given ID(s) is/are in the given group
- * @author Phil Sturgeon
- **/
- public function in_group($check_group, $id = FALSE, $check_all = FALSE)
- {
- $this->ion_auth_model->trigger_events('in_group');
-
- $id || $id = $this->session->userdata('user_id');
-
- if (!is_array($check_group))
- {
- $check_group = array($check_group);
- }
-
- if (isset($this->_cache_user_in_group[$id]))
- {
- $groups_array = $this->_cache_user_in_group[$id];
- }
- else
- {
- $users_groups = $this->ion_auth_model->get_users_groups($id)->result();
- $groups_array = array();
- foreach ($users_groups as $group)
- {
- $groups_array[$group->id] = $group->name;
- }
- $this->_cache_user_in_group[$id] = $groups_array;
- }
- foreach ($check_group as $key => $value)
- {
- $groups = (is_numeric($value)) ? array_keys($groups_array) : $groups_array;
-
- /**
- * if !all (default), in_array
- * if all, !in_array
- */
- if (in_array($value, $groups) xor $check_all)
- {
- /**
- * if !all (default), true
- * if all, false
- */
- return !$check_all;
- }
- }
-
- /**
- * if !all (default), false
- * if all, true
- */
- return $check_all;
- }
-
-}
diff --git a/app/application/libraries/index.html b/app/application/libraries/index.html
deleted file mode 100755
index b702fbc..0000000
--- a/app/application/libraries/index.html
+++ /dev/null
@@ -1,11 +0,0 @@
-
-
-
- 403 Forbidden
-
-
-
-Directory access is forbidden.
-
-
-
diff --git a/app/application/logs/index.html b/app/application/logs/index.html
deleted file mode 100755
index b702fbc..0000000
--- a/app/application/logs/index.html
+++ /dev/null
@@ -1,11 +0,0 @@
-
-
-
- 403 Forbidden
-
-
-
-Directory access is forbidden.
-
-
-
diff --git a/app/application/models/Camera_model.php b/app/application/models/Camera_model.php
deleted file mode 100755
index 0bfb363..0000000
--- a/app/application/models/Camera_model.php
+++ /dev/null
@@ -1,110 +0,0 @@
-load->database();
- $this->load->helper(array('form', 'url'));
- $this->load->library('ion_auth');
- }
-
-
- /**
- * Enable Camera
- * Enables the camera module.
- * @return void
- */
- public function enableCamera()
- {
- // Set enabled field to TRUE and update database
- $data = array(
- "enabled" => TRUE
- );
-
- $this->db->where('id', $this->sensorID);
- return $this->db->update('technical', $data);
- }
-
-
- /**
- * Disable Camera
- * Disables the camera module.
- * @return void
- */
- public function disableCamera()
- {
- // Set enabled field to FALSE and update database
- $data = array(
- "enabled" => FALSE
- );
-
- $this->db->where('id', $this->sensorID);
- return $this->db->update('technical', $data);
-
- }
-
-
- /**
- * Take Photo
- * Capture photo and save to photos.
- * @return void
- */
- public function takePhoto()
- {
- // String to execute photo capture command
- $photo_command = "sudo /var/www/html/actions/fruxepi.py camera -capture";
-
- // Run capture photo command
- $filename = shell_exec($photo_command);
-
- return $filename;
-
- }
-
- /**
- * Get Camera Activation State
- * Get the activation state of the camera.
- * @return boolean
- */
- public function cameraActivationState()
- {
- $this->db->select("enabled");
- $this->db->from("technical");
- $this->db->where('id', $this->sensorID);
-
- $query = $this->db->get();
- $result = $query->result();
- $activationState = $result[0]->enabled;
-
- // Return True or False
- return $activationState;
- }
-
-
- /**
- * Camera Diagnostics
- * A diagnostics function to determine the Camera module's operability.
- * @return boolean
- */
- public function cameraDiagnostics()
- {
-
- // Command string
- $command_string = "sudo /var/www/html/actions/fruxepi.py camera -d ";
-
- // Execute command
- $command_callback = shell_exec($command_string);
-
- return $command_callback;
- }
-
- }
-
diff --git a/app/application/models/Climate_model.php b/app/application/models/Climate_model.php
deleted file mode 100755
index 009bee4..0000000
--- a/app/application/models/Climate_model.php
+++ /dev/null
@@ -1,263 +0,0 @@
-load->database();
- $this->load->helper(array('form', 'url'));
- $this->load->library('ion_auth');
- }
-
-
- /**
- * Get Temperature
- * Get the latest temperature reading from the database as an unformatted float.
- * @return float
- */
- public function getTemperature()
- {
- $this->db->select("temperature");
- $this->db->from("grow_data");
- $this->db->order_by("id","DESC");
- $this->db->limit(1);
-
- $query = $this->db->get();
- $temperature = $query->result()[0]->temperature;
-
- return $temperature;
- }
-
-
- /**
- * Get Humidity
- * Get the latest humidity reading from the database as an unformatted float.
- * @return float
- */
- public function getHumidity()
- {
- $this->db->select("humidity");
- $this->db->from("grow_data");
- $this->db->order_by("id","DESC");
- $this->db->limit(1);
-
- $query = $this->db->get();
- $humidity = $query->result()[0]->humidity;
-
- return $humidity;
- }
-
- /**
- * Set Climate Sensor GPIO Pin
- * Set the GPIO Pin associated with the climate sensor.
- * @return void
- */
- public function setGPIO()
- {
- // Set GPIO pin value and update database
- $data = array(
- "gpio_pin" => $this->input->post('GPIO')
- );
-
- $this->db->where('id', $this->sensorID);
- return $this->db->update('technical', $data);
- }
-
-
- /**
- * Get Climate Sensor GPIO Pin
- * Return the GPIO Pin associated with the climate sensor.
- * @return int
- */
- public function getGPIO()
- {
- $this->db->select("gpio_pin");
- $this->db->from("technical");
- $this->db->where('id', $this->sensorID);
-
- $query = $this->db->get();
- $result = $query->result();
-
- return $result[0]->gpio_pin;
- }
-
-
- /**
- * Enable Climate Sensor
- * Enable the climate sensor module.
- * @return void
- */
- public function enableClimateSensor()
- {
- // Set enabled field to TRUE and update database
- $data = array(
- "enabled" => TRUE
- );
-
- $this->db->where('id', $this->sensorID);
- return $this->db->update('technical', $data);
- }
-
-
- /**
- * Disable Climate Sensor
- * Disable the climate sensor module.
- * @return void
- */
- public function disableClimateSensor()
- {
- // Set enabled field to FALSE and update database
- $data = array(
- "enabled" => FALSE
- );
-
- $this->db->where('id', $this->sensorID);
-
- return $this->db->update('technical', $data);
- }
-
- /**
- * Get Climate Sensor Activation State
- * Get the activation state of the moisture probe.
- * @return boolean
- */
- public function climateActivationState()
- {
- $this->db->select("enabled");
- $this->db->from("technical");
- $this->db->where('id', $this->sensorID);
-
- $query = $this->db->get();
- $result = $query->result();
- $activationState = $result[0]->enabled;
-
- // Return True or False
- return $activationState;
- }
-
-
- /**
- * Read Climate Sensor
- * Return the immediate temperature and humidity from the climate sensor.
- * @return int
- */
- public function readClimateSensor()
- {
- // Command string
- $command_string = "";
-
- // Execute command
- exec($command_string, $climate_callback);
-
- return $climate_callback;
- }
-
- /**
- * Get Climate Threshold
- * Get climate threshold temperature and humidity
- * @return array
- */
- public function getClimateThreshold()
- {
- $this->db->select("*");
- $this->db->from("climate_threshold");
- $this->db->where('id', 1);
-
- $query = $this->db->get();
- $result = $query->result_array();
-
- return $result[0];
- }
-
- /**
- * Set Climate Threshold
- * set climate threshold temperature and humidity
- * @return void
- */
- public function setClimateThreshold()
- {
- $tempFormat = $this->Climate_model->getTemperatureFormat();
-
- if ($tempFormat == "F") {
- $data = array(
- "temp_MIN" => fahrenheitToCelsius($this->input->post('temperatureLOW')),
- "temp_MAX" => fahrenheitToCelsius($this->input->post('temperatureHIGH')),
- "humid_MIN" => $this->input->post('humidityLOW'),
- "humid_MAX" => $this->input->post('humidityHIGH')
- );
- } else {
- $data = array(
- "temp_MIN" => $this->input->post('temperatureLOW'),
- "temp_MAX" => $this->input->post('temperatureHIGH'),
- "humid_MIN" => $this->input->post('humidityLOW'),
- "humid_MAX" => $this->input->post('humidityHIGH')
- );
- }
-
- $this->db->where('id', 1);
- return $this->db->update('climate_threshold', $data);
- }
-
-
- /**
- * Climate Sensor Diagnostics
- * A diagnostics function to determine the climate sensor's operability.
- * @return boolean
- */
- public function climateDiagnostics()
- {
- // GPIO pin
- $gpioPIN = $this->Climate_model->getGPIO();
-
- // Command string
- $command_string = "sudo /var/www/html/actions/fruxepi.py climate -d " . $gpioPIN;
-
- // Execute command
- $command_callback = shell_exec($command_string);
-
- return $command_callback;
- }
-
- /**
- * Get Climate Temperature Format
- * Return the desired temperature format.
- * @return string
- */
- public function getTemperatureFormat()
- {
- $this->db->select("format");
- $this->db->from("climate_settings");
- $this->db->where('id', $this->sensorID);
-
- $query = $this->db->get();
- $result = $query->result();
-
- return $result[0]->format;
- }
-
-
- /**
- * Set Temperature Format
- * Set the desired temperature format (Celsius or Fahrenheit).
- * @return void
- */
- public function setTemperatureFormat()
- {
- // Set format value and update database
- $data = array(
- "format" => $this->input->post('tempFormat')
- );
-
- $this->db->where('id', $this->sensorID);
- return $this->db->update('climate_settings', $data);
- }
-
- }
-
diff --git a/app/application/models/Crop_model.php b/app/application/models/Crop_model.php
deleted file mode 100755
index c775b82..0000000
--- a/app/application/models/Crop_model.php
+++ /dev/null
@@ -1,292 +0,0 @@
-load->database();
- $this->load->helper(array('form', 'url'));
- $this->load->library('ion_auth');
- }
-
-
- /**
- * Generate CropID
- * Generate a unique string to identify each crop.
- * @return String
- */
- public function generateCropID()
- {
- $length = 5;
- $cropID = "";
- $characters = array_merge(range('A','Z'), range('0','9'));
- $max = count($characters) - 1;
-
- for ($i = 0; $i < $length; $i++) {
- $rand = mt_rand(0, $max);
- $cropID .= $characters[$rand];
- }
-
- return "FRX-CR0" . $cropID;
- }
-
-
- /**
- * Get Crop Info
- * Returns an array of basic information on the crop.
- * @return Array
- */
- public function cropInfo($cropID)
- {
- $crop_info = $this->Crop_model->getCrop($cropID);
- $crop_progress = $this->Crop_model->getCropProgress($cropID);
-
- $data = array(
- "cropID" => $crop_info['cropID'],
- "nickname" => $crop_info['nickname'],
- "plant_qty" => $crop_info['plant_qty'],
- "plant_type" => $crop_info['plant_type'],
- "crop_start" => $crop_info['crop_start'],
- "crop_end" => $crop_info['crop_end'],
- "total_growdays" => $crop_progress['daysTotal'],
- "growdays_complete" => $crop_progress['daysComplete'],
- "growdays_remaining" => $crop_progress['daysLeft'],
- "crop_progress" => $crop_progress['progress'],
- "crop_thumbnail" => $crop_info['crop_thumbnail'],
- );
-
- return $data;
- }
-
- /**
- * Get All Crop Info
- * Returns an array of basic information on the crop.
- * @return Array
- */
- public function getAllCropsInfo()
- {
- $output = array();
- $crops = $this->Crop_model->getCrops();
-
- foreach($crops as $crop) {
- $crop_data = $this->Crop_model->cropInfo($crop['cropID']);
- array_push($output, $crop_data);
- }
-
- return $output;
-
- }
-
- /**
- * Get Crop By cropID
- * Get crop by cropID.
- * @return Array
- */
- public function getCrop($cropID)
- {
- $this->db->select("*");
- $this->db->from("crops");
- $this->db->where('cropID', $cropID);
-
- $query = $this->db->get();
-
- return $query->result_array()[0];
- }
-
- /**
- * Get All Crops
- * Returns an array of crops.
- * @return Array
- */
- public function getCrops()
- {
- $this->db->select("*");
- $this->db->from("crops");
-
- $query = $this->db->get();
-
- return $query->result_array();
- }
-
-
- /**
- * Setup Crop
- * Create a new crop.
- * @return void
- */
- public function setupCrop()
- {
- $data = array(
- "cropID" => $this->Crop_model->generateCropID(),
- "nickname" => $this->input->post('nickname'),
- "plant_qty" => $this->input->post('plant_qty'),
- "plant_type" => $this->input->post('plant_type'),
- "crop_start" => $this->input->post('crop_start'),
- "crop_end" => $this->input->post('crop_end'),
- "crop_thumbnail" => $this->input->post('crop_thumbnail'),
- "date_created" => date("d-m-Y H:i:s"),
- "date_modified" => date("d-m-Y H:i:s")
- );
-
- return $this->db->insert('crops', $data);
- }
-
-
- /**
- * Edit Crop
- * Edit crop
- * @return True
- */
- public function editCrop($cropID)
- {
- $data = array(
- "nickname" => $this->input->post('nickname'),
- "plant_qty" => $this->input->post('plant_qty'),
- "plant_type" => $this->input->post('plant_type'),
- "crop_start" => $this->input->post('crop_start'),
- "crop_end" => $this->input->post('crop_end'),
- "crop_thumbnail" => $this->input->post('crop_thumbnail'),
- "date_modified" => date("d-m-Y H:i:s")
- );
-
- $this->db->where('cropID', $cropID);
- return $this->db->update('crops', $data);
- }
-
-
- /**
- * Delete Crop
- * Delete crop from the database.
- * @return True
- */
- public function deleteCrop($cropID)
- {
- $this->db->where('cropID', $cropID);
-
- return $this->db->delete('crops');
- }
-
- /**
- * Get Crop Activity Entries
- * Return all crop journal entries for specific crop.
- * @return True
- */
- public function get_cropActivity()
- {
- $this->db->select("*");
- $this->db->from("activity");
- $this->db->order_by('id', 'desc');
-
- $query = $this->db->get();
-
- return $query->result_array();
- }
-
- /**
- * Get Single Crop Activity Entry
- * Add a new crop activity entry to the database.
- * @return True
- */
- public function getCropActivityEntry($id)
- {
- $this->db->select("*");
- $this->db->from("activity");
- $this->db->where('id', $id);
-
- $query = $this->db->get();
-
- return $query->result_array()[0];
- }
-
- /**
- * Add Crop Journal Entry
- * Add a new crop journal entry to the database.
- * @return True
- */
- public function addActivityEntry()
- {
- // Journal Entry fields for database update
- $data = array(
- "cropID" => $this->input->post('crop'),
- "date_time" => date("Y-m-d H:i:s"),
- "activity_type" => $this->input->post('activity_type'),
- "msg" => $this->input->post('msg')
- );
-
- return $this->db->insert('activity', $data);
- }
-
-
- /**
- * Delete Crop Activity Entry
- * Delete a Crop Journal entry from the database.
- * @return True
- */
- public function deleteActivityEntry($id)
- {
- $this->db->where('id', $id);
-
- return $this->db->delete('activity');
- }
-
-
- /**
- * Edit Crop Activity Entry
- * Edit a Crop Journal Entry.
- * @return True
- */
- public function editActivityEntry($id)
- {
- // Journal Entry fields for database update
- $data = array(
- "msg" => $this->input->post('msg')
- );
-
- $this->db->where('id', $id);
- return $this->db->update('activity', $data);
- }
-
-
- // Current Crop Stage
- public function getCropProgress($cropID)
- {
- $query = $this->db->get_where('crops', array('cropID' => $cropID));
- $cropData = $query->row_array();
-
- $curDay = new DateTime();
- $cropStart = new DateTime($cropData['crop_start']);
- $cropEnd = new DateTime($cropData['crop_end']);
-
- $daysTotal = $cropStart->diff($cropEnd)->format("%a");
- $daysComplete = $curDay->diff($cropStart)->format("%a");
- $daysLeft = $curDay->diff($cropEnd)->format("%a");
-
- if ($daysTotal <= $daysComplete) {
-
- $extraDays = $daysComplete - $daysTotal;
-
- $data['daysTotal'] = $daysTotal;
- $data['daysComplete'] = $daysComplete;
- $data['daysLeft'] = "+" . $extraDays;
- $data['progress'] = 100;
-
- return $data;
-
- } else {
-
- $data['daysTotal'] = $daysTotal;
- $data['daysComplete'] = $daysComplete;
- $data['daysLeft'] = $daysLeft;
- $data['progress'] = round(($daysComplete / $daysTotal) * 100);
-
- return $data;
- }
-
- }
-
- }
-
diff --git a/app/application/models/Dashboard_model.php b/app/application/models/Dashboard_model.php
deleted file mode 100755
index f7cea89..0000000
--- a/app/application/models/Dashboard_model.php
+++ /dev/null
@@ -1,295 +0,0 @@
-load->database();
- $this->load->helper(array('form', 'url', 'utility'));
- $this->load->library('ion_auth');
- $this->load->model('Climate_model');
- $this->load->model('Lights_model');
- }
-
- // Get User Info
- public function get_user_info()
- {
- // Get user ID for current user logged in
- $user = $this->ion_auth->user()->row();
- $id = $user->id;
-
- // Fetch user record from the database
- $this->db->select('*');
- $this->db->from('users');
- $this->db->where(array('users.id' => $id));
-
- // Return the result as array
- $query = $this->db->get();
- return $query->result();
- }
-
- // Get latest grow data
- public function get_latest_grow_data()
- {
- $this->db->select("*");
- $this->db->from("grow_data");
- $this->db->order_by("id","DESC");
- $this->db->limit(1);
-
- $query = $this->db->get();
- $grow_data = $query->result_array()[0];
- $lights_data = $this->Lights_model->getLightStatusMessage();
-
- $data = array(
- "id" => $grow_data["id"],
- "date_time" => $grow_data["date_time"],
- "temperature" => $grow_data["temperature"],
- "humidity" => $grow_data["humidity"],
- "light_status" => $grow_data["light_status"],
- "light_status_message" => $lights_data["status"],
- "light_hours" => $lights_data["lightHours"],
- "moisture_status" => $grow_data["moisture_status"],
- "fan_status" => $grow_data["fan_status"],
- "pump_status" => $grow_data["pump_status"],
- );
-
- return $data;
- }
-
- // Get latest grow data
- public function get_sensor_activation_state()
- {
- // Fetch sensor state
- $data = array(
- "climate_state" => $this->Climate_model->climateActivationState(),
- "camera_state" => $this->Camera_model->cameraActivationState(),
- "fan_state" => $this->Fan_model->fanActivationState(),
- "lights_state" => $this->Lights_model->lightsActivationState(),
- "moisture_state" => $this->Moisture_model->moistureActivationState(),
- "pump_state" => $this->Pump_model->pumpActivationState()
- );
-
- return $data;
- }
-
- // Get 24-hr temperature chart data
- public function get_temperature_chart_data()
- {
- $tempFormat = $this->Climate_model->getTemperatureFormat();
-
- $this->db->select("*");
- $this->db->from("climate_history");
- $this->db->order_by("id","DESC");
- $this->db->limit(24);
-
- $query = $this->db->get();
- $results = $query->result_array();
-
- $output = "";
- $count = 1;
- foreach($results as $result) {
- if ($count == count($results)) {
- if ($tempFormat == "F") {
- $output .= celsiusToFahrenheit($result["temperature"]);
- } else {
- $output .= $result["temperature"];
- }
- } else {
- if ($tempFormat == "F") {
- $output .= celsiusToFahrenheit($result["temperature"]) . ", ";
- } else {
- $output .= $result["temperature"] . ", ";
- }
- }
- $count++;
- }
-
- return $output;
- }
-
- // Get 24-hr humidity chart data
- public function get_humidity_chart_data()
- {
- $this->db->select("*");
- $this->db->from("climate_history");
- $this->db->order_by("id","DESC");
- $this->db->limit(24);
-
- $query = $this->db->get();
- $results = $query->result_array();
-
- $output = "";
- $count = 1;
- foreach($results as $result) {
- if ($count == count($results)) {
- $output .= $result["humidity"];
- } else {
- $output .= $result["humidity"] . ", ";
- }
- $count++;
- }
-
- return $output;
- }
-
- // Get chart legend
- public function get_chart_legend()
- {
- $this->db->select("*");
- $this->db->from("climate_history");
- $this->db->order_by("id","DESC");
- $this->db->limit(24);
-
- $query = $this->db->get();
- $results = $query->result_array();
-
- $output = "";
- $count = 1;
- foreach($results as $result) {
- if ($count == count($results)) {
- $output .= "\"" . date_format(date_create($result["date_time"]), "M d H:i") . "\"";
- } else {
- $output .= "\"" . date_format(date_create($result["date_time"]), "M d H:i") . "\"" . ", ";
- }
- $count++;
- }
-
- return $output;
- }
-
- // Get daily High temperature
- public function get_temperature_dailyHIGH()
- {
- $this->db->select_max('temperature');
- $this->db->from("grow_data");
- $this->db->where('date_format(date_time,"d-m-Y H:i")', 'CURDATE()', FALSE);
- $query = $this->db->get();
-
- return $query->result();
- }
-
- // Get daily Low temperature
- public function get_temperature_dailyLOW()
- {
- $this->db->select_min('temperature');
- $this->db->from("grow_data");
- $this->db->where('date_format(date_time,"d-m-Y H:i")', 'CURDATE()', FALSE);
- $query = $this->db->get();
-
- return $query->result();
- }
-
- // Get daily High humidity
- public function get_humidity_dailyHIGH()
- {
- $this->db->select_max('humidity');
- $this->db->from("grow_data");
- $this->db->where('date_format(date_time,"d-m-Y H:i)', 'CURDATE()', FALSE);
- $query = $this->db->get();
-
- return $query->result();
- }
-
- // Get daily Low humidity
- public function get_humidity_dailyLOW()
- {
- $this->db->select_min('humidity');
- $this->db->from("grow_data");
- $this->db->where('date_format(date_time,"d-m-Y H:i:s")', 'CURDATE()', FALSE);
- $query = $this->db->get();
-
- return $query->result();
- }
-
- // Current Crop Threshold
- public function get_cropThresholds()
- {
- // Prepare Data
- $climate_threshold = $this->Climate_model->getClimateThreshold();
-
- $data = array();
- $curTemp = $this->Climate_model->getTemperature();
- $tempHigh = $climate_threshold['temp_MAX'];
- $tempLow = $climate_threshold['temp_MIN'];
-
- $curHumid = $this->Climate_model->getHumidity();
- $humidHigh = $climate_threshold['humid_MAX'];
- $humidLow = $climate_threshold['humid_MIN'];
-
- // Check Temperature Range
- if (($curTemp >= $tempLow) && ($curTemp <= $tempHigh))
- {
- $data['temperature'] = 'Y';
- } else {
-
- if ($curTemp <= $tempLow) {
- $data['temperature'] = 'N';
- $data['tempStatus'] = 'L';
- } elseif($curTemp >= $tempHigh) {
- $data['temperature'] = 'N';
- $data['tempStatus'] = 'H';
- }
- }
-
- // Check Humidity Range
- if (($curHumid >= $humidLow) && ($curHumid <= $humidHigh))
- {
- $data['humidity'] = 'Y';
- } else {
- if ($curHumid <= $humidLow) {
- $data['humidity'] = 'N';
- $data['humidStatus'] = 'L';
- } elseif($curHumid >= $humidHigh) {
- $data['humidity'] = 'N';
- $data['humidStatus'] = 'H';
- }
- }
-
- return $data;
-
- }
-
- // Current Crop Conditions
- public function get_cropConditions()
- {
-
- $sql = "SELECT * FROM grow_data WHERE DATE(date_time) = CURDATE() ORDER BY date_time DESC";
- $query = $this->db->query($sql);
- $tempData = $query->result_array();
-
- // Grow Room Thresholds
- $climate_threshold = $this->Climate_model->getClimateThreshold();
- $tempHigh = $climate_threshold['temp_MAX'];
- $tempLow = $climate_threshold['temp_MIN'];
- $humidHigh = $climate_threshold['humid_MAX'];
- $humidLow = $climate_threshold['humid_MIN'];
-
- // Loop through tempData
- $total_records = sizeof($tempData);
- $positive_records = 0;
-
- foreach ($tempData as $item) {
- $temp = $item['temperature'];
- $humid = $item['humidity'];
- if (($temp >= $tempLow) && ($temp <= $tempHigh) && ($humid >= $humidLow) && ($humid <= $humidHigh)) {
- $positive_records++;
- }
- }
-
- // Calculate Ratio check for zero division
- if ($positive_records != 0 && $total_records != 0) {
- $cropConditions = round(($positive_records / $total_records) * 100);
- return $cropConditions;
- } else {
- return $cropConditions = 0;
- }
-
- }
-
- }
-
-?>
\ No newline at end of file
diff --git a/app/application/models/Fan_model.php b/app/application/models/Fan_model.php
deleted file mode 100755
index 63ec07f..0000000
--- a/app/application/models/Fan_model.php
+++ /dev/null
@@ -1,280 +0,0 @@
-load->database();
- $this->load->helper(array('form', 'url', 'utility'));
- $this->load->model('Climate_model');
- $this->load->library('ion_auth');
- }
-
-
- /**
- * Turn Fan ON
- * Turn the fan funcion on.
- * @return void
- */
- public function fanON()
- {
- // GPIO pin
- $gpioPIN = $this->Fan_model->getGPIO();
-
- // Relay Type
- $relayType = $this->Fan_model->getRelayType();
-
- // Command string
- $command_string = "sudo /var/www/html/actions/fruxepi.py fan -ON " . $gpioPIN . " " . $relayType;
-
- // Execute command
- exec($command_string);
- }
-
-
- /**
- * Turn Fan OFF
- * Turn the fan funcion off.
- * @return void
- */
- public function fanOFF()
- {
- // GPIO pin
- $gpioPIN = $this->Fan_model->getGPIO();
-
- // Relay Type
- $relayType = $this->Fan_model->getRelayType();
-
- // Command string
- $command_string = "sudo /var/www/html/actions/fruxepi.py fan -OFF " . $gpioPIN . " " . $relayType;
-
- // Execute command
- exec($command_string);
- }
-
-
- /**
- * Set Fan GPIO Pin
- * Set the GPIO Pin associated with the fan.
- * @return void
- */
- public function setGPIO()
- {
- // Set GPIO pin value and update database
- $data = array(
- "gpio_pin" => $this->input->post('GPIO')
- );
-
- $this->db->where('id', $this->sensorID);
- return $this->db->update('technical', $data);
- }
-
-
- /**
- * Get Fan GPIO Pin
- * Return the GPIO Pin associated with the climate sensor.
- * @return int
- */
- public function getGPIO()
- {
- $this->db->select("gpio_pin");
- $this->db->from("technical");
- $this->db->where('id', $this->sensorID);
-
- $query = $this->db->get();
- $result = $query->result();
-
- return $result[0]->gpio_pin;
- }
-
- /**
- * Set Fan Schedule
- * Set the fan schedule
- * @return void
- */
- public function setFanSchedule()
- {
- // Set fan program values and update database
-
- $tempFormat = $this->Climate_model->getTemperatureFormat();
-
- if ($tempFormat == "F") {
- $data = array(
- "fan_temp_threshold" => fahrenheitToCelsius($this->input->post('fan_temp_threshold')),
- "fan_humid_threshold" => $this->input->post('fan_humid_threshold'),
- "fan_duration" => $this->input->post('fan_duration')
- );
- } else {
- $data = array(
- "fan_temp_threshold" => $this->input->post('fan_temp_threshold'),
- "fan_humid_threshold" => $this->input->post('fan_humid_threshold'),
- "fan_duration" => $this->input->post('fan_duration')
- );
- }
-
- $this->db->where("process_id", "fan");
- $this->db->update("fan_schedule", $data);
-
- return $this->input->post('fan_duration');
- }
-
- /**
- * Get Fan Schedule
- * Set the fan schedule
- * @return void
- */
- public function getFanSchedule()
- {
- $this->db->select("*");
- $this->db->from("fan_schedule");
- $this->db->where('process_id', "fan");
-
- $query = $this->db->get();
- return $query->result();
- }
-
- /**
- * Get Fan Activation State
- * Get the activation state of the moisture probe.
- * @return boolean
- */
- public function fanActivationState()
- {
- $this->db->select("enabled");
- $this->db->from("technical");
- $this->db->where('id', $this->sensorID);
-
- $query = $this->db->get();
- $result = $query->result();
- $activationState = $result[0]->enabled;
-
- // Return True or False
- return $activationState;
- }
-
-
- /**
- * Enable Fan
- * Enable the fan module.
- * @return void
- */
- public function enableFans()
- {
- // Set enabled field to TRUE and update database
- $data = array(
- "enabled" => TRUE
- );
-
- $this->db->where('id', $this->sensorID);
- return $this->db->update('technical', $data);
- }
-
-
- /**
- * Disable Fan
- * Diable the fan module.
- * @return void
- */
- public function disableFans()
- {
- // Set enabled field to FALSE and update database
- $data = array(
- "enabled" => FALSE
- );
-
- $this->db->where('id', $this->sensorID);
- return $this->db->update('technical', $data);
- }
-
- /**
- * Set Relay type
- * Set the relay type - active high ("high") or active low ("").
- * @return void
- */
- public function setRelayType()
- {
- // Set relay type value and update database
- $data = array(
- "type" => $this->input->post('relayType')
- );
-
- $this->db->where('technical_id', $this->sensorID);
- return $this->db->update('relay_settings', $data);
- }
-
-
- /**
- * Get Fan Relay Type
- * @return String
- */
- public function getRelayType()
- {
- $this->db->select("type");
- $this->db->from("relay_settings");
- $this->db->where('technical_id', $this->sensorID);
-
- $query = $this->db->get();
- $result = $query->result();
-
- return $result[0]->type;
- }
-
-
- /**
- * Get Fan Status
- * Return a boolean if the fan is running (True) or not running (False).
- * @return boolean
- */
- public function getFanStatus()
- {
- // GPIO pin
- $gpioPIN = $this->Fan_model->getGPIO();
-
- // Relay Type
- $relayType = $this->Fan_model->getRelayType();
-
- // Command string
- $command_string = "sudo /var/www/html/actions/fruxepi.py fan -s " . $gpioPIN . " " . $relayType;
-
- // Execute command
- exec($command_string, $command_callback);
-
- // Return True or False based on $command_callback value
- if (!empty($command_callback)){
- if ($command_callback[0] == "1") {
- return 1;
- }
- }
-
- return 0;
- }
-
-
- /**
- * Fan Diagnostics
- * A diagnostics function to determine the fan's health and operability.
- * @return string
- */
- public function fanDiagnostics()
- {
- // GPIO pin
- $gpioPIN = $this->Fan_model->getGPIO();
-
- // Command string
- $command_string = "sudo /var/www/html/actions/fruxepi.py fan -d " . $gpioPIN;
-
- // Execute command
- $command_callback = shell_exec($command_string);
-
- return $command_callback;
- }
-
- }
-
diff --git a/app/application/models/Heater_model.php b/app/application/models/Heater_model.php
deleted file mode 100644
index d3b808a..0000000
--- a/app/application/models/Heater_model.php
+++ /dev/null
@@ -1,194 +0,0 @@
-load->database();
- $this->load->helper(array('form', 'url', 'utility'));
- $this->load->model('Climate_model');
- $this->load->library('ion_auth');
- }
-
-
- /**
- * Turn Heater ON
- * Turn the heater function on.
- * @return void
- */
- public function heaterON()
- {
- // GPIO pin
- $gpioPIN = $this->Heater_model->getGPIO();
-
- // Command string
- $command_string = "sudo /var/www/html/actions/fruxepi.py heater -ON " . $gpioPIN;
-
- // Execute command
- exec($command_string);
- }
-
-
- /**
- * Turn Heater OFF
- * Turn the heater function off.
- * @return void
- */
- public function heaterOFF()
- {
- // GPIO pin
- $gpioPIN = $this->Heater_model->getGPIO();
-
- // Command string
- $command_string = "sudo /var/www/html/actions/fruxepi.py heater -OFF " . $gpioPIN;
-
- // Execute command
- exec($command_string);
- }
-
-
- /**
- * Set Heater GPIO Pin
- * Set the GPIO Pin associated with the heater.
- * @return void
- */
- public function setGPIO()
- {
- // Set GPIO pin value and update database
- $data = array(
- "gpio_pin" => $this->input->post('GPIO')
- );
-
- $this->db->where('id', $this->sensorID);
- return $this->db->update('technical', $data);
- }
-
-
- /**
- * Get Heater GPIO Pin
- * Return the GPIO Pin associated with the heater relay.
- * @return int
- */
- public function getGPIO()
- {
- $this->db->select("gpio_pin");
- $this->db->from("technical");
- $this->db->where('id', $this->sensorID);
-
- $query = $this->db->get();
- $result = $query->result();
-
- return $result[0]->gpio_pin;
- }
-
-
-
- /**
- * Get Fan Activation State
- * Get the activation state of the heater relay.
- * @return boolean
- */
- public function heaterActivationState()
- {
- $this->db->select("enabled");
- $this->db->from("technical");
- $this->db->where('id', $this->sensorID);
-
- $query = $this->db->get();
- $result = $query->result();
- $activationState = $result[0]->enabled;
-
- // Return True or False
- return $activationState;
- }
-
-
- /**
- * Enable Heater
- * Enable the heater module.
- * @return void
- */
- public function enableHeater()
- {
- // Set enabled field to TRUE and update database
- $data = array(
- "enabled" => TRUE
- );
-
- $this->db->where('id', $this->sensorID);
- return $this->db->update('technical', $data);
- }
-
-
- /**
- * Disable Heater
- * Diable the heater module.
- * @return void
- */
- public function disableHeater()
- {
- // Set enabled field to FALSE and update database
- $data = array(
- "enabled" => FALSE
- );
-
- $this->db->where('id', $this->sensorID);
- return $this->db->update('technical', $data);
- }
-
-
- /**
- * Get Heater Status
- * Return a boolean if the heater is running (True) or not running (False).
- * @return boolean
- */
- public function getHeaterStatus()
- {
- // GPIO pin
- $gpioPIN = $this->Heater_model->getGPIO();
-
- // Command string
- $command_string = "sudo /var/www/html/actions/fruxepi.py heater -s " . $gpioPIN;
-
- // Execute command
- exec($command_string, $command_callback);
-
- // Return True or False based on $command_callback value
- if (!empty($command_callback)){
- if ($command_callback[0] == "1") {
- return 1;
- }
- }
-
- return 0;
- }
-
-
- /**
- * Heater Diagnostics
- * A diagnostics function to determine the heater's health and operability.
- * @return string
- */
- public function heaterDiagnostics()
- {
- // GPIO pin
- $gpioPIN = $this->Heater_model->getGPIO();
-
- // Command string
- $command_string = "sudo /var/www/html/actions/fruxepi.py heater -d " . $gpioPIN;
-
- // Execute command
- $command_callback = shell_exec($command_string);
-
- return $command_callback;
- }
-
- }
-
diff --git a/app/application/models/Ion_auth_model.php b/app/application/models/Ion_auth_model.php
deleted file mode 100755
index c43acfd..0000000
--- a/app/application/models/Ion_auth_model.php
+++ /dev/null
@@ -1,2682 +0,0 @@
-config->load('ion_auth', TRUE);
- $this->load->helper('cookie');
- $this->load->helper('date');
- $this->lang->load('ion_auth');
-
- // initialize the database
- $this->db = $this->load->database($this->config->item('database_group_name', 'ion_auth'), TRUE, TRUE);
-
- // initialize db tables data
- $this->tables = $this->config->item('tables', 'ion_auth');
-
- // initialize data
- $this->identity_column = $this->config->item('identity', 'ion_auth');
- $this->store_salt = $this->config->item('store_salt', 'ion_auth');
- $this->salt_length = $this->config->item('salt_length', 'ion_auth');
- $this->join = $this->config->item('join', 'ion_auth');
-
- // initialize hash method options (Bcrypt)
- $this->hash_method = $this->config->item('hash_method', 'ion_auth');
- $this->default_rounds = $this->config->item('default_rounds', 'ion_auth');
- $this->random_rounds = $this->config->item('random_rounds', 'ion_auth');
- $this->min_rounds = $this->config->item('min_rounds', 'ion_auth');
- $this->max_rounds = $this->config->item('max_rounds', 'ion_auth');
-
- // initialize messages and error
- $this->messages = array();
- $this->errors = array();
- $delimiters_source = $this->config->item('delimiters_source', 'ion_auth');
-
- // load the error delimeters either from the config file or use what's been supplied to form validation
- if ($delimiters_source === 'form_validation')
- {
- // load in delimiters from form_validation
- // to keep this simple we'll load the value using reflection since these properties are protected
- $this->load->library('form_validation');
- $form_validation_class = new ReflectionClass("CI_Form_validation");
-
- $error_prefix = $form_validation_class->getProperty("_error_prefix");
- $error_prefix->setAccessible(TRUE);
- $this->error_start_delimiter = $error_prefix->getValue($this->form_validation);
- $this->message_start_delimiter = $this->error_start_delimiter;
-
- $error_suffix = $form_validation_class->getProperty("_error_suffix");
- $error_suffix->setAccessible(TRUE);
- $this->error_end_delimiter = $error_suffix->getValue($this->form_validation);
- $this->message_end_delimiter = $this->error_end_delimiter;
- }
- else
- {
- // use delimiters from config
- $this->message_start_delimiter = $this->config->item('message_start_delimiter', 'ion_auth');
- $this->message_end_delimiter = $this->config->item('message_end_delimiter', 'ion_auth');
- $this->error_start_delimiter = $this->config->item('error_start_delimiter', 'ion_auth');
- $this->error_end_delimiter = $this->config->item('error_end_delimiter', 'ion_auth');
- }
-
- // initialize our hooks object
- $this->_ion_hooks = new stdClass;
-
- // load the bcrypt class if needed
- if ($this->hash_method == 'bcrypt')
- {
- if ($this->random_rounds)
- {
- $rand = rand($this->min_rounds,$this->max_rounds);
- $params = array('rounds' => $rand);
- }
- else
- {
- $params = array('rounds' => $this->default_rounds);
- }
-
- $params['salt_prefix'] = $this->config->item('salt_prefix', 'ion_auth');
- $this->load->library('bcrypt',$params);
- }
-
- $this->trigger_events('model_constructor');
- }
-
- /**
- * Hashes the password to be stored in the database.
- *
- * @param string $password
- * @param bool $salt
- * @param bool $use_sha1_override
- *
- * @return false|string
- * @author Mathew
- */
- public function hash_password($password, $salt = FALSE, $use_sha1_override = FALSE)
- {
- if (empty($password))
- {
- return FALSE;
- }
-
- // bcrypt
- if ($use_sha1_override === FALSE && $this->hash_method == 'bcrypt')
- {
- return $this->bcrypt->hash($password);
- }
-
-
- if ($this->store_salt && $salt)
- {
- return sha1($password . $salt);
- }
- else
- {
- $salt = $this->salt();
- return $salt . substr(sha1($salt . $password), 0, -$this->salt_length);
- }
- }
-
- /**
- * This function takes a password and validates it
- * against an entry in the users table.
- *
- * @param string|int $id
- * @param string $password
- * @param bool $use_sha1_override
- *
- * @return bool
- * @author Mathew
- */
- public function hash_password_db($id, $password, $use_sha1_override = FALSE)
- {
- if (empty($id) || empty($password))
- {
- return FALSE;
- }
-
- $this->trigger_events('extra_where');
-
- $query = $this->db->select('password, salt')
- ->where('id', $id)
- ->limit(1)
- ->order_by('id', 'desc')
- ->get($this->tables['users']);
-
- $hash_password_db = $query->row();
-
- if ($query->num_rows() !== 1)
- {
- return FALSE;
- }
-
- // bcrypt
- if ($use_sha1_override === FALSE && $this->hash_method == 'bcrypt')
- {
- if ($this->bcrypt->verify($password,$hash_password_db->password))
- {
- return TRUE;
- }
-
- return FALSE;
- }
-
- // sha1
- if ($this->store_salt)
- {
- $db_password = sha1($password . $hash_password_db->salt);
- }
- else
- {
- $salt = substr($hash_password_db->password, 0, $this->salt_length);
-
- $db_password = $salt . substr(sha1($salt . $password), 0, -$this->salt_length);
- }
-
- if($db_password == $hash_password_db->password)
- {
- return TRUE;
- }
- else
- {
- return FALSE;
- }
- }
-
- /**
- * Generates a random salt value for forgotten passwords or any other keys. Uses SHA1.
- *
- * @param string $password
- *
- * @return false|string
- * @author Mathew
- */
- public function hash_code($password)
- {
- return $this->hash_password($password, FALSE, TRUE);
- }
-
- /**
- * Generates a random salt value.
- *
- * Salt generation code taken from https://github.com/ircmaxell/password_compat/blob/master/lib/password.php
- *
- * @return bool|string
- * @author Anthony Ferrera
- */
- public function salt()
- {
- $raw_salt_len = 16;
-
- $buffer = '';
- $buffer_valid = FALSE;
-
- if (function_exists('random_bytes'))
- {
- $buffer = random_bytes($raw_salt_len);
- if ($buffer)
- {
- $buffer_valid = TRUE;
- }
- }
-
- if (!$buffer_valid && function_exists('mcrypt_create_iv') && !defined('PHALANGER'))
- {
- $buffer = mcrypt_create_iv($raw_salt_len, MCRYPT_DEV_URANDOM);
- if ($buffer)
- {
- $buffer_valid = TRUE;
- }
- }
-
- if (!$buffer_valid && function_exists('openssl_random_pseudo_bytes'))
- {
- $buffer = openssl_random_pseudo_bytes($raw_salt_len);
- if ($buffer)
- {
- $buffer_valid = TRUE;
- }
- }
-
- if (!$buffer_valid && @is_readable('/dev/urandom'))
- {
- $f = fopen('/dev/urandom', 'r');
- $read = strlen($buffer);
- while ($read < $raw_salt_len)
- {
- $buffer .= fread($f, $raw_salt_len - $read);
- $read = strlen($buffer);
- }
- fclose($f);
- if ($read >= $raw_salt_len)
- {
- $buffer_valid = TRUE;
- }
- }
-
- if (!$buffer_valid || strlen($buffer) < $raw_salt_len)
- {
- $bl = strlen($buffer);
- for ($i = 0; $i < $raw_salt_len; $i++)
- {
- if ($i < $bl)
- {
- $buffer[$i] = $buffer[$i] ^ chr(mt_rand(0, 255));
- }
- else
- {
- $buffer .= chr(mt_rand(0, 255));
- }
- }
- }
-
- $salt = $buffer;
-
- // encode string with the Base64 variant used by crypt
- $base64_digits = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';
- $bcrypt64_digits = './ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
- $base64_string = base64_encode($salt);
- $salt = strtr(rtrim($base64_string, '='), $base64_digits, $bcrypt64_digits);
-
- $salt = substr($salt, 0, $this->salt_length);
-
- return $salt;
- }
-
- /**
- * Validates and removes activation code.
- *
- * @param int|string $id
- * @param bool $code
- *
- * @return bool
- * @author Mathew
- */
- public function activate($id, $code = FALSE)
- {
- $this->trigger_events('pre_activate');
-
- if ($code !== FALSE)
- {
- $query = $this->db->select($this->identity_column)
- ->where('activation_code', $code)
- ->where('id', $id)
- ->limit(1)
- ->order_by('id', 'desc')
- ->get($this->tables['users']);
-
- $query->row();
-
- if ($query->num_rows() !== 1)
- {
- $this->trigger_events(array('post_activate', 'post_activate_unsuccessful'));
- $this->set_error('activate_unsuccessful');
- return FALSE;
- }
-
- $data = array(
- 'activation_code' => NULL,
- 'active' => 1
- );
-
- $this->trigger_events('extra_where');
- $this->db->update($this->tables['users'], $data, array('id' => $id));
- }
- else
- {
- $data = array(
- 'activation_code' => NULL,
- 'active' => 1
- );
-
- $this->trigger_events('extra_where');
- $this->db->update($this->tables['users'], $data, array('id' => $id));
- }
-
- $return = $this->db->affected_rows() == 1;
- if ($return)
- {
- $this->trigger_events(array('post_activate', 'post_activate_successful'));
- $this->set_message('activate_successful');
- }
- else
- {
- $this->trigger_events(array('post_activate', 'post_activate_unsuccessful'));
- $this->set_error('activate_unsuccessful');
- }
-
- return $return;
- }
-
-
- /**
- * Updates a users row with an activation code.
- *
- * @param int|string|null $id
- *
- * @return bool
- * @author Mathew
- */
- public function deactivate($id = NULL)
- {
- $this->trigger_events('deactivate');
-
- if (!isset($id))
- {
- $this->set_error('deactivate_unsuccessful');
- return FALSE;
- }
- else if ($this->ion_auth->logged_in() && $this->user()->row()->id == $id)
- {
- $this->set_error('deactivate_current_user_unsuccessful');
- return FALSE;
- }
-
- $activation_code = sha1(md5(microtime()));
- $this->activation_code = $activation_code;
-
- $data = array(
- 'activation_code' => $activation_code,
- 'active' => 0
- );
-
- $this->trigger_events('extra_where');
- $this->db->update($this->tables['users'], $data, array('id' => $id));
-
- $return = $this->db->affected_rows() == 1;
- if ($return)
- {
- $this->set_message('deactivate_successful');
- }
- else
- {
- $this->set_error('deactivate_unsuccessful');
- }
-
- return $return;
- }
-
- /**
- * Finds the user with the given forgotten password code and clears the forgotten password fields
- *
- * @param string $code
- *
- * @return bool Success
- */
- public function clear_forgotten_password_code($code) {
-
- if (empty($code))
- {
- return FALSE;
- }
-
- $this->db->where('forgotten_password_code', $code);
-
- if ($this->db->count_all_results($this->tables['users']) > 0)
- {
- $data = array(
- 'forgotten_password_code' => NULL,
- 'forgotten_password_time' => NULL
- );
-
- $this->db->update($this->tables['users'], $data, array('forgotten_password_code' => $code));
-
- return TRUE;
- }
-
- return FALSE;
- }
-
- /**
- * Reset password
- *
- * @param string $identity
- * @param string $new
- *
- * @return bool
- * @author Mathew
- */
- public function reset_password($identity, $new) {
- $this->trigger_events('pre_change_password');
-
- if (!$this->identity_check($identity)) {
- $this->trigger_events(array('post_change_password', 'post_change_password_unsuccessful'));
- return FALSE;
- }
-
- $this->trigger_events('extra_where');
-
- $query = $this->db->select('id, password, salt')
- ->where($this->identity_column, $identity)
- ->limit(1)
- ->order_by('id', 'desc')
- ->get($this->tables['users']);
-
- if ($query->num_rows() !== 1)
- {
- $this->trigger_events(array('post_change_password', 'post_change_password_unsuccessful'));
- $this->set_error('password_change_unsuccessful');
- return FALSE;
- }
-
- $result = $query->row();
-
- $new = $this->hash_password($new, $result->salt);
-
- // store the new password and reset the remember code so all remembered instances have to re-login
- // also clear the forgotten password code
- $data = array(
- 'password' => $new,
- 'remember_code' => NULL,
- 'forgotten_password_code' => NULL,
- 'forgotten_password_time' => NULL,
- );
-
- $this->trigger_events('extra_where');
- $this->db->update($this->tables['users'], $data, array($this->identity_column => $identity));
-
- $return = $this->db->affected_rows() == 1;
- if ($return)
- {
- $this->trigger_events(array('post_change_password', 'post_change_password_successful'));
- $this->set_message('password_change_successful');
- }
- else
- {
- $this->trigger_events(array('post_change_password', 'post_change_password_unsuccessful'));
- $this->set_error('password_change_unsuccessful');
- }
-
- return $return;
- }
-
- /**
- * Change password
- *
- * @param string $identity
- * @param string $old
- * @param string $new
- *
- * @return bool
- * @author Mathew
- */
- public function change_password($identity, $old, $new)
- {
- $this->trigger_events('pre_change_password');
-
- $this->trigger_events('extra_where');
-
- $query = $this->db->select('id, password, salt')
- ->where($this->identity_column, $identity)
- ->limit(1)
- ->order_by('id', 'desc')
- ->get($this->tables['users']);
-
- if ($query->num_rows() !== 1)
- {
- $this->trigger_events(array('post_change_password', 'post_change_password_unsuccessful'));
- $this->set_error('password_change_unsuccessful');
- return FALSE;
- }
-
- $user = $query->row();
-
- $old_password_matches = $this->hash_password_db($user->id, $old);
-
- if ($old_password_matches === TRUE)
- {
- // store the new password and reset the remember code so all remembered instances have to re-login
- $hashed_new_password = $this->hash_password($new, $user->salt);
- $data = array(
- 'password' => $hashed_new_password,
- 'remember_code' => NULL,
- );
-
- $this->trigger_events('extra_where');
-
- $successfully_changed_password_in_db = $this->db->update($this->tables['users'], $data, array($this->identity_column => $identity));
- if ($successfully_changed_password_in_db)
- {
- $this->trigger_events(array('post_change_password', 'post_change_password_successful'));
- $this->set_message('password_change_successful');
- }
- else
- {
- $this->trigger_events(array('post_change_password', 'post_change_password_unsuccessful'));
- $this->set_error('password_change_unsuccessful');
- }
-
- return $successfully_changed_password_in_db;
- }
-
- $this->set_error('password_change_unsuccessful');
- return FALSE;
- }
-
- /**
- * Checks username
- *
- * @param string $username
- *
- * @return bool
- * @author Mathew
- */
- public function username_check($username = '')
- {
- $this->trigger_events('username_check');
-
- if (empty($username))
- {
- return FALSE;
- }
-
- $this->trigger_events('extra_where');
-
- return $this->db->where('username', $username)
- ->limit(1)
- ->count_all_results($this->tables['users']) > 0;
- }
-
- /**
- * Checks email
- *
- * @param string $email
- *
- * @return bool
- * @author Mathew
- */
- public function email_check($email = '')
- {
- $this->trigger_events('email_check');
-
- if (empty($email))
- {
- return FALSE;
- }
-
- $this->trigger_events('extra_where');
-
- return $this->db->where('email', $email)
- ->limit(1)
- ->count_all_results($this->tables['users']) > 0;
- }
-
- /**
- * Identity check
- *
- * @return bool
- * @author Mathew
- */
- public function identity_check($identity = '')
- {
- $this->trigger_events('identity_check');
-
- if (empty($identity))
- {
- return FALSE;
- }
-
- return $this->db->where($this->identity_column, $identity)
- ->limit(1)
- ->count_all_results($this->tables['users']) > 0;
- }
-
- /**
- * Insert a forgotten password key.
- *
- * @param string $identity
- *
- * @return bool
- * @author Mathew
- * @updated Ryan
- */
- public function forgotten_password($identity)
- {
- if (empty($identity))
- {
- $this->trigger_events(array('post_forgotten_password', 'post_forgotten_password_unsuccessful'));
- return FALSE;
- }
-
- // All some more randomness
- $activation_code_part = "";
- if (function_exists("openssl_random_pseudo_bytes"))
- {
- $activation_code_part = openssl_random_pseudo_bytes(128);
- }
-
- for ($i = 0; $i < 1024; $i++)
- {
- $activation_code_part = sha1($activation_code_part . mt_rand() . microtime());
- }
-
- $key = $this->hash_code($activation_code_part . $identity);
-
- // If enable query strings is set, then we need to replace any unsafe characters so that the code can still work
- if ($key != '' && $this->config->item('permitted_uri_chars') != '' && $this->config->item('enable_query_strings') == FALSE)
- {
- // preg_quote() in PHP 5.3 escapes -, so the str_replace() and addition of - to preg_quote() is to maintain backwards
- // compatibility as many are unaware of how characters in the permitted_uri_chars will be parsed as a regex pattern
- if (!preg_match("|^[" . str_replace(array('\\-', '\-'), '-', preg_quote($this->config->item('permitted_uri_chars'), '-')) . "]+$|i", $key))
- {
- $key = preg_replace("/[^" . $this->config->item('permitted_uri_chars') . "]+/i", "-", $key);
- }
- }
-
- // Limit to 40 characters since that's how our DB field is setup
- $this->forgotten_password_code = substr($key, 0, 40);
-
- $this->trigger_events('extra_where');
-
- $update = array(
- 'forgotten_password_code' => $key,
- 'forgotten_password_time' => time()
- );
-
- $this->db->update($this->tables['users'], $update, array($this->identity_column => $identity));
-
- $return = $this->db->affected_rows() == 1;
-
- if ($return)
- {
- $this->trigger_events(array('post_forgotten_password', 'post_forgotten_password_successful'));
- }
- else
- {
- $this->trigger_events(array('post_forgotten_password', 'post_forgotten_password_unsuccessful'));
- }
-
- return $return;
- }
-
- /**
- * Forgotten Password Complete
- *
- * @param string $code
- * @param bool $salt
- *
- * @return string
- * @author Mathew
- */
- public function forgotten_password_complete($code, $salt = FALSE)
- {
- $this->trigger_events('pre_forgotten_password_complete');
-
- if (empty($code))
- {
- $this->trigger_events(array('post_forgotten_password_complete', 'post_forgotten_password_complete_unsuccessful'));
- return FALSE;
- }
-
- $profile = $this->where('forgotten_password_code', $code)->users()->row(); //pass the code to profile
-
- if ($profile)
- {
-
- if ($this->config->item('forgot_password_expiration', 'ion_auth') > 0)
- {
- //Make sure it isn't expired
- $expiration = $this->config->item('forgot_password_expiration', 'ion_auth');
- if (time() - $profile->forgotten_password_time > $expiration)
- {
- //it has expired
- $this->set_error('forgot_password_expired');
- $this->trigger_events(array('post_forgotten_password_complete', 'post_forgotten_password_complete_unsuccessful'));
- return FALSE;
- }
- }
-
- $password = $this->salt();
-
- $data = array(
- 'password' => $this->hash_password($password, $salt),
- 'forgotten_password_code' => NULL,
- 'active' => 1,
- );
-
- $this->db->update($this->tables['users'], $data, array('forgotten_password_code' => $code));
-
- $this->trigger_events(array('post_forgotten_password_complete', 'post_forgotten_password_complete_successful'));
- return $password;
- }
-
- $this->trigger_events(array('post_forgotten_password_complete', 'post_forgotten_password_complete_unsuccessful'));
- return FALSE;
- }
-
- /**
- * Register
- *
- * @param string $identity
- * @param string $password
- * @param string $email
- * @param array $additional_data
- * @param array $groups
- *
- * @return bool
- * @author Mathew
- */
- public function register($identity, $password, $email, $additional_data = array(), $groups = array())
- {
- $this->trigger_events('pre_register');
-
- $manual_activation = $this->config->item('manual_activation', 'ion_auth');
-
- if ($this->identity_check($identity))
- {
- $this->set_error('account_creation_duplicate_identity');
- return FALSE;
- }
- else if (!$this->config->item('default_group', 'ion_auth') && empty($groups))
- {
- $this->set_error('account_creation_missing_default_group');
- return FALSE;
- }
-
- // check if the default set in config exists in database
- $query = $this->db->get_where($this->tables['groups'], array('name' => $this->config->item('default_group', 'ion_auth')), 1)->row();
- if (!isset($query->id) && empty($groups))
- {
- $this->set_error('account_creation_invalid_default_group');
- return FALSE;
- }
-
- // capture default group details
- $default_group = $query;
-
- // IP Address
- $ip_address = $this->_prepare_ip($this->input->ip_address());
- $salt = $this->store_salt ? $this->salt() : FALSE;
- $password = $this->hash_password($password, $salt);
-
- // Users table.
- $data = array(
- $this->identity_column => $identity,
- 'username' => $identity,
- 'password' => $password,
- 'email' => $email,
- 'ip_address' => $ip_address,
- 'created_on' => time(),
- 'active' => ($manual_activation === FALSE ? 1 : 0)
- );
-
- if ($this->store_salt)
- {
- $data['salt'] = $salt;
- }
-
- // filter out any data passed that doesnt have a matching column in the users table
- // and merge the set user data and the additional data
- $user_data = array_merge($this->_filter_data($this->tables['users'], $additional_data), $data);
-
- $this->trigger_events('extra_set');
-
- $this->db->insert($this->tables['users'], $user_data);
-
- $id = $this->db->insert_id($this->tables['users'] . '_id_seq');
-
- // add in groups array if it doesn't exists and stop adding into default group if default group ids are set
- if (isset($default_group->id) && empty($groups))
- {
- $groups[] = $default_group->id;
- }
-
- if (!empty($groups))
- {
- // add to groups
- foreach ($groups as $group)
- {
- $this->add_to_group($group, $id);
- }
- }
-
- $this->trigger_events('post_register');
-
- return (isset($id)) ? $id : FALSE;
- }
-
- /**
- * login
- *
- * @param string $identity
- * @param string $password
- * @param bool $remember
- *
- * @return bool
- * @author Mathew
- */
- public function login($identity, $password, $remember=FALSE)
- {
- $this->trigger_events('pre_login');
-
- if (empty($identity) || empty($password))
- {
- $this->set_error('login_unsuccessful');
- return FALSE;
- }
-
- $this->trigger_events('extra_where');
-
- $query = $this->db->select($this->identity_column . ', email, id, password, active, last_login')
- ->where($this->identity_column, $identity)
- ->limit(1)
- ->order_by('id', 'desc')
- ->get($this->tables['users']);
-
- if ($this->is_max_login_attempts_exceeded($identity))
- {
- // Hash something anyway, just to take up time
- $this->hash_password($password);
-
- $this->trigger_events('post_login_unsuccessful');
- $this->set_error('login_timeout');
-
- return FALSE;
- }
-
- if ($query->num_rows() === 1)
- {
- $user = $query->row();
-
- $password = $this->hash_password_db($user->id, $password);
-
- if ($password === TRUE)
- {
- if ($user->active == 0)
- {
- $this->trigger_events('post_login_unsuccessful');
- $this->set_error('login_unsuccessful_not_active');
-
- return FALSE;
- }
-
- $this->set_session($user);
-
- $this->update_last_login($user->id);
-
- $this->clear_login_attempts($identity);
-
- if ($remember && $this->config->item('remember_users', 'ion_auth'))
- {
- $this->remember_user($user->id);
- }
-
- // Regenerate the session (for security purpose: to avoid session fixation)
- $this->_regenerate_session();
-
- $this->trigger_events(array('post_login', 'post_login_successful'));
- $this->set_message('login_successful');
-
- return TRUE;
- }
- }
-
- // Hash something anyway, just to take up time
- $this->hash_password($password);
-
- $this->increase_login_attempts($identity);
-
- $this->trigger_events('post_login_unsuccessful');
- $this->set_error('login_unsuccessful');
-
- return FALSE;
- }
-
- /**
- * Verifies if the session should be rechecked according to the configuration item recheck_timer. If it does, then
- * it will check if the user is still active
- * @return bool
- */
- public function recheck_session()
- {
- $recheck = (NULL !== $this->config->item('recheck_timer', 'ion_auth')) ? $this->config->item('recheck_timer', 'ion_auth') : 0;
-
- if ($recheck !== 0)
- {
- $last_login = $this->session->userdata('last_check');
- if ($last_login + $recheck < time())
- {
- $query = $this->db->select('id')
- ->where(array($this->identity_column => $this->session->userdata('identity'), 'active' => '1'))
- ->limit(1)
- ->order_by('id', 'desc')
- ->get($this->tables['users']);
- if ($query->num_rows() === 1)
- {
- $this->session->set_userdata('last_check', time());
- }
- else
- {
- $this->trigger_events('logout');
-
- $identity = $this->config->item('identity', 'ion_auth');
-
- if (substr(CI_VERSION, 0, 1) == '2')
- {
- $this->session->unset_userdata(array($identity => '', 'id' => '', 'user_id' => ''));
- }
- else
- {
- $this->session->unset_userdata(array($identity, 'id', 'user_id'));
- }
- return FALSE;
- }
- }
- }
-
- return (bool)$this->session->userdata('identity');
- }
-
- /**
- * is_max_login_attempts_exceeded
- * Based on code from Tank Auth, by Ilya Konyukhov (https://github.com/ilkon/Tank-Auth)
- *
- * @param string $identity user's identity
- * @param string|null $ip_address IP address
- * Only used if track_login_ip_address is set to TRUE.
- * If NULL (default value), the current IP address is used.
- * Use get_last_attempt_ip($identity) to retrieve a user's last IP
- *
- * @return boolean
- */
- public function is_max_login_attempts_exceeded($identity, $ip_address = NULL)
- {
- if ($this->config->item('track_login_attempts', 'ion_auth'))
- {
- $max_attempts = $this->config->item('maximum_login_attempts', 'ion_auth');
- if ($max_attempts > 0)
- {
- $attempts = $this->get_attempts_num($identity, $ip_address);
- return $attempts >= $max_attempts;
- }
- }
- return FALSE;
- }
-
- /**
- * Get number of login attempts for the given IP-address or identity
- * Based on code from Tank Auth, by Ilya Konyukhov (https://github.com/ilkon/Tank-Auth)
- *
- * @param string $identity User's identity
- * @param string|null $ip_address IP address
- * Only used if track_login_ip_address is set to TRUE.
- * If NULL (default value), the current IP address is used.
- * Use get_last_attempt_ip($identity) to retrieve a user's last IP
- *
- * @return int
- */
- public function get_attempts_num($identity, $ip_address = NULL)
- {
- if ($this->config->item('track_login_attempts', 'ion_auth'))
- {
- $this->db->select('1', FALSE);
- $this->db->where('login', $identity);
- if ($this->config->item('track_login_ip_address', 'ion_auth'))
- {
- if (!isset($ip_address))
- {
- $ip_address = $this->_prepare_ip($this->input->ip_address());
- }
- $this->db->where('ip_address', $ip_address);
- }
- $this->db->where('time >', time() - $this->config->item('lockout_time', 'ion_auth'), FALSE);
- $qres = $this->db->get($this->tables['login_attempts']);
- return $qres->num_rows();
- }
- return 0;
- }
-
- /**
- * @deprecated This function is now only a wrapper for is_max_login_attempts_exceeded() since it only retrieve
- * attempts within the given period.
- *
- * @param string $identity User's identity
- * @param string|null $ip_address IP address
- * Only used if track_login_ip_address is set to TRUE.
- * If NULL (default value), the current IP address is used.
- * Use get_last_attempt_ip($identity) to retrieve a user's last IP
- *
- * @return boolean Whether an account is locked due to excessive login attempts within a given period
- */
- public function is_time_locked_out($identity, $ip_address = NULL)
- {
- return $this->is_max_login_attempts_exceeded($identity, $ip_address);
- }
-
- /**
- * @deprecated This function is now only a wrapper for is_max_login_attempts_exceeded() since it only retrieve
- * attempts within the given period.
- *
- * @param string $identity User's identity
- * @param string|null $ip_address IP address
- * Only used if track_login_ip_address is set to TRUE.
- * If NULL (default value), the current IP address is used.
- * Use get_last_attempt_ip($identity) to retrieve a user's last IP
- *
- * @return int The time of the last login attempt for a given IP-address or identity
- */
- public function get_last_attempt_time($identity, $ip_address = NULL)
- {
- if ($this->config->item('track_login_attempts', 'ion_auth'))
- {
- $this->db->select('time');
- $this->db->where('login', $identity);
- if ($this->config->item('track_login_ip_address', 'ion_auth'))
- {
- if (!isset($ip_address))
- {
- $ip_address = $this->_prepare_ip($this->input->ip_address());
- }
- $this->db->where('ip_address', $ip_address);
- }
- $this->db->order_by('id', 'desc');
- $qres = $this->db->get($this->tables['login_attempts'], 1);
-
- if ($qres->num_rows() > 0)
- {
- return $qres->row()->time;
- }
- }
-
- return 0;
- }
-
- /**
- * Get the IP address of the last time a login attempt occured from given identity
- *
- * @param string $identity User's identity
- *
- * @return string
- */
- public function get_last_attempt_ip($identity)
- {
- if ($this->config->item('track_login_attempts', 'ion_auth') && $this->config->item('track_login_ip_address', 'ion_auth'))
- {
- $this->db->select('ip_address');
- $this->db->where('login', $identity);
- $this->db->order_by('id', 'desc');
- $qres = $this->db->get($this->tables['login_attempts'], 1);
-
- if ($qres->num_rows() > 0)
- {
- return $qres->row()->ip_address;
- }
- }
-
- return '';
- }
-
- /**
- * Based on code from Tank Auth, by Ilya Konyukhov (https://github.com/ilkon/Tank-Auth)
- *
- * Note: the current IP address will be used if track_login_ip_address config value is TRUE
- *
- * @param string $identity User's identity
- *
- * @return bool
- */
- public function increase_login_attempts($identity)
- {
- if ($this->config->item('track_login_attempts', 'ion_auth'))
- {
- $data = array('ip_address' => '', 'login' => $identity, 'time' => time());
- if ($this->config->item('track_login_ip_address', 'ion_auth'))
- {
- $data['ip_address'] = $this->_prepare_ip($this->input->ip_address());
- }
- return $this->db->insert($this->tables['login_attempts'], $data);
- }
- return FALSE;
- }
-
- /**
- * clear_login_attempts
- * Based on code from Tank Auth, by Ilya Konyukhov (https://github.com/ilkon/Tank-Auth)
- *
- * @param string $identity User's identity
- * @param int $old_attempts_expire_period In seconds, any attempts older than this value will be removed.
- * It is used for regularly purging the attempts table.
- * (for security reason, minimum value is lockout_time config value)
- * @param string|null $ip_address IP address
- * Only used if track_login_ip_address is set to TRUE.
- * If NULL (default value), the current IP address is used.
- * Use get_last_attempt_ip($identity) to retrieve a user's last IP
- *
- * @return bool
- */
- public function clear_login_attempts($identity, $old_attempts_expire_period = 86400, $ip_address = NULL)
- {
- if ($this->config->item('track_login_attempts', 'ion_auth'))
- {
- // Make sure $old_attempts_expire_period is at least equals to lockout_time
- $old_attempts_expire_period = max($old_attempts_expire_period, $this->config->item('lockout_time', 'ion_auth'));
-
- $this->db->where('login', $identity);
- if ($this->config->item('track_login_ip_address', 'ion_auth'))
- {
- if (!isset($ip_address))
- {
- $ip_address = $this->_prepare_ip($this->input->ip_address());
- }
- $this->db->where('ip_address', $ip_address);
- }
- // Purge obsolete login attempts
- $this->db->or_where('time <', time() - $old_attempts_expire_period, FALSE);
-
- return $this->db->delete($this->tables['login_attempts']);
- }
- return FALSE;
- }
-
- /**
- * @param int $limit
- *
- * @return static
- */
- public function limit($limit)
- {
- $this->trigger_events('limit');
- $this->_ion_limit = $limit;
-
- return $this;
- }
-
- /**
- * @param int $offset
- *
- * @return static
- */
- public function offset($offset)
- {
- $this->trigger_events('offset');
- $this->_ion_offset = $offset;
-
- return $this;
- }
-
- /**
- * @param array|string $where
- * @param null|string $value
- *
- * @return static
- */
- public function where($where, $value = NULL)
- {
- $this->trigger_events('where');
-
- if (!is_array($where))
- {
- $where = array($where => $value);
- }
-
- array_push($this->_ion_where, $where);
-
- return $this;
- }
-
- /**
- * @param string $like
- * @param string|null $value
- * @param string $position
- *
- * @return static
- */
- public function like($like, $value = NULL, $position = 'both')
- {
- $this->trigger_events('like');
-
- array_push($this->_ion_like, array(
- 'like' => $like,
- 'value' => $value,
- 'position' => $position
- ));
-
- return $this;
- }
-
- /**
- * @param array|string $select
- *
- * @return static
- */
- public function select($select)
- {
- $this->trigger_events('select');
-
- $this->_ion_select[] = $select;
-
- return $this;
- }
-
- /**
- * @param string $by
- * @param string $order
- *
- * @return static
- */
- public function order_by($by, $order='desc')
- {
- $this->trigger_events('order_by');
-
- $this->_ion_order_by = $by;
- $this->_ion_order = $order;
-
- return $this;
- }
-
- /**
- * @return object|mixed
- */
- public function row()
- {
- $this->trigger_events('row');
-
- $row = $this->response->row();
-
- return $row;
- }
-
- /**
- * @return array|mixed
- */
- public function row_array()
- {
- $this->trigger_events(array('row', 'row_array'));
-
- $row = $this->response->row_array();
-
- return $row;
- }
-
- /**
- * @return mixed
- */
- public function result()
- {
- $this->trigger_events('result');
-
- $result = $this->response->result();
-
- return $result;
- }
-
- /**
- * @return array|mixed
- */
- public function result_array()
- {
- $this->trigger_events(array('result', 'result_array'));
-
- $result = $this->response->result_array();
-
- return $result;
- }
-
- /**
- * @return int
- */
- public function num_rows()
- {
- $this->trigger_events(array('num_rows'));
-
- $result = $this->response->num_rows();
-
- return $result;
- }
-
- /**
- * users
- *
- * @param array|null $groups
- *
- * @return static
- * @author Ben Edmunds
- */
- public function users($groups = NULL)
- {
- $this->trigger_events('users');
-
- if (isset($this->_ion_select) && !empty($this->_ion_select))
- {
- foreach ($this->_ion_select as $select)
- {
- $this->db->select($select);
- }
-
- $this->_ion_select = array();
- }
- else
- {
- // default selects
- $this->db->select(array(
- $this->tables['users'].'.*',
- $this->tables['users'].'.id as id',
- $this->tables['users'].'.id as user_id'
- ));
- }
-
- // filter by group id(s) if passed
- if (isset($groups))
- {
- // build an array if only one group was passed
- if (!is_array($groups))
- {
- $groups = Array($groups);
- }
-
- // join and then run a where_in against the group ids
- if (isset($groups) && !empty($groups))
- {
- $this->db->distinct();
- $this->db->join(
- $this->tables['users_groups'],
- $this->tables['users_groups'].'.'.$this->join['users'].'='.$this->tables['users'].'.id',
- 'inner'
- );
- }
-
- // verify if group name or group id was used and create and put elements in different arrays
- $group_ids = array();
- $group_names = array();
- foreach($groups as $group)
- {
- if(is_numeric($group)) $group_ids[] = $group;
- else $group_names[] = $group;
- }
- $or_where_in = (!empty($group_ids) && !empty($group_names)) ? 'or_where_in' : 'where_in';
- // if group name was used we do one more join with groups
- if(!empty($group_names))
- {
- $this->db->join($this->tables['groups'], $this->tables['users_groups'] . '.' . $this->join['groups'] . ' = ' . $this->tables['groups'] . '.id', 'inner');
- $this->db->where_in($this->tables['groups'] . '.name', $group_names);
- }
- if(!empty($group_ids))
- {
- $this->db->{$or_where_in}($this->tables['users_groups'].'.'.$this->join['groups'], $group_ids);
- }
- }
-
- $this->trigger_events('extra_where');
-
- // run each where that was passed
- if (isset($this->_ion_where) && !empty($this->_ion_where))
- {
- foreach ($this->_ion_where as $where)
- {
- $this->db->where($where);
- }
-
- $this->_ion_where = array();
- }
-
- if (isset($this->_ion_like) && !empty($this->_ion_like))
- {
- foreach ($this->_ion_like as $like)
- {
- $this->db->or_like($like['like'], $like['value'], $like['position']);
- }
-
- $this->_ion_like = array();
- }
-
- if (isset($this->_ion_limit) && isset($this->_ion_offset))
- {
- $this->db->limit($this->_ion_limit, $this->_ion_offset);
-
- $this->_ion_limit = NULL;
- $this->_ion_offset = NULL;
- }
- else if (isset($this->_ion_limit))
- {
- $this->db->limit($this->_ion_limit);
-
- $this->_ion_limit = NULL;
- }
-
- // set the order
- if (isset($this->_ion_order_by) && isset($this->_ion_order))
- {
- $this->db->order_by($this->_ion_order_by, $this->_ion_order);
-
- $this->_ion_order = NULL;
- $this->_ion_order_by = NULL;
- }
-
- $this->response = $this->db->get($this->tables['users']);
-
- return $this;
- }
-
- /**
- * user
- *
- * @param int|string|null $id
- *
- * @return static
- * @author Ben Edmunds
- */
- public function user($id = NULL)
- {
- $this->trigger_events('user');
-
- // if no id was passed use the current users id
- $id = isset($id) ? $id : $this->session->userdata('user_id');
-
- $this->limit(1);
- $this->order_by($this->tables['users'].'.id', 'desc');
- $this->where($this->tables['users'].'.id', $id);
-
- $this->users();
-
- return $this;
- }
-
- /**
- * get_users_groups
- *
- * @param int|string|bool $id
- *
- * @return CI_DB_result
- * @author Ben Edmunds
- */
- public function get_users_groups($id = FALSE)
- {
- $this->trigger_events('get_users_group');
-
- // if no id was passed use the current users id
- $id || $id = $this->session->userdata('user_id');
-
- return $this->db->select($this->tables['users_groups'].'.'.$this->join['groups'].' as id, '.$this->tables['groups'].'.name, '.$this->tables['groups'].'.description')
- ->where($this->tables['users_groups'].'.'.$this->join['users'], $id)
- ->join($this->tables['groups'], $this->tables['users_groups'].'.'.$this->join['groups'].'='.$this->tables['groups'].'.id')
- ->get($this->tables['users_groups']);
- }
-
- /**
- * add_to_group
- *
- * @param array|int|float|string $group_ids
- * @param bool|int|float|string $user_id
- *
- * @return int
- * @author Ben Edmunds
- */
- public function add_to_group($group_ids, $user_id = FALSE)
- {
- $this->trigger_events('add_to_group');
-
- // if no id was passed use the current users id
- $user_id || $user_id = $this->session->userdata('user_id');
-
- if(!is_array($group_ids))
- {
- $group_ids = array($group_ids);
- }
-
- $return = 0;
-
- // Then insert each into the database
- foreach ($group_ids as $group_id)
- {
- // Cast to float to support bigint data type
- if ($this->db->insert(
- $this->tables['users_groups'],
- array(
- $this->join['groups'] => (float)$group_id,
- $this->join['users'] => (float)$user_id
- )
- )
- )
- {
- if (isset($this->_cache_groups[$group_id]))
- {
- $group_name = $this->_cache_groups[$group_id];
- }
- else
- {
- $group = $this->group($group_id)->result();
- $group_name = $group[0]->name;
- $this->_cache_groups[$group_id] = $group_name;
- }
- $this->_cache_user_in_group[$user_id][$group_id] = $group_name;
-
- // Return the number of groups added
- $return++;
- }
- }
-
- return $return;
- }
-
- /**
- * remove_from_group
- *
- * @param array|int|float|string|bool $group_ids
- * @param int|float|string|bool $user_id
- *
- * @return bool
- * @author Ben Edmunds
- */
- public function remove_from_group($group_ids = FALSE, $user_id = FALSE)
- {
- $this->trigger_events('remove_from_group');
-
- // user id is required
- if (empty($user_id))
- {
- return FALSE;
- }
-
- // if group id(s) are passed remove user from the group(s)
- if (!empty($group_ids))
- {
- if (!is_array($group_ids))
- {
- $group_ids = array($group_ids);
- }
-
- foreach ($group_ids as $group_id)
- {
- // Cast to float to support bigint data type
- $this->db->delete(
- $this->tables['users_groups'],
- array($this->join['groups'] => (float)$group_id, $this->join['users'] => (float)$user_id)
- );
- if (isset($this->_cache_user_in_group[$user_id]) && isset($this->_cache_user_in_group[$user_id][$group_id]))
- {
- unset($this->_cache_user_in_group[$user_id][$group_id]);
- }
- }
-
- $return = TRUE;
- }
- // otherwise remove user from all groups
- else
- {
- // Cast to float to support bigint data type
- if ($return = $this->db->delete($this->tables['users_groups'], array($this->join['users'] => (float)$user_id)))
- {
- $this->_cache_user_in_group[$user_id] = array();
- }
- }
- return $return;
- }
-
- /**
- * groups
- *
- * @return static
- * @author Ben Edmunds
- */
- public function groups()
- {
- $this->trigger_events('groups');
-
- // run each where that was passed
- if (isset($this->_ion_where) && !empty($this->_ion_where))
- {
- foreach ($this->_ion_where as $where)
- {
- $this->db->where($where);
- }
- $this->_ion_where = array();
- }
-
- if (isset($this->_ion_limit) && isset($this->_ion_offset))
- {
- $this->db->limit($this->_ion_limit, $this->_ion_offset);
-
- $this->_ion_limit = NULL;
- $this->_ion_offset = NULL;
- }
- else if (isset($this->_ion_limit))
- {
- $this->db->limit($this->_ion_limit);
-
- $this->_ion_limit = NULL;
- }
-
- // set the order
- if (isset($this->_ion_order_by) && isset($this->_ion_order))
- {
- $this->db->order_by($this->_ion_order_by, $this->_ion_order);
- }
-
- $this->response = $this->db->get($this->tables['groups']);
-
- return $this;
- }
-
- /**
- * group
- *
- * @param int|string|null $id
- *
- * @return static
- * @author Ben Edmunds
- */
- public function group($id = NULL)
- {
- $this->trigger_events('group');
-
- if (isset($id))
- {
- $this->where($this->tables['groups'].'.id', $id);
- }
-
- $this->limit(1);
- $this->order_by('id', 'desc');
-
- return $this->groups();
- }
-
- /**
- * update
- *
- * @param int|string $id
- * @param array $data
- *
- * @return bool
- * @author Phil Sturgeon
- */
- public function update($id, array $data)
- {
- $this->trigger_events('pre_update_user');
-
- $user = $this->user($id)->row();
-
- $this->db->trans_begin();
-
- if (array_key_exists($this->identity_column, $data) && $this->identity_check($data[$this->identity_column]) && $user->{$this->identity_column} !== $data[$this->identity_column])
- {
- $this->db->trans_rollback();
- $this->set_error('account_creation_duplicate_identity');
-
- $this->trigger_events(array('post_update_user', 'post_update_user_unsuccessful'));
- $this->set_error('update_unsuccessful');
-
- return FALSE;
- }
-
- // Filter the data passed
- $data = $this->_filter_data($this->tables['users'], $data);
-
- if (array_key_exists($this->identity_column, $data) || array_key_exists('password', $data) || array_key_exists('email', $data))
- {
- if (array_key_exists('password', $data))
- {
- if( ! empty($data['password']))
- {
- $data['password'] = $this->hash_password($data['password'], $user->salt);
- }
- else
- {
- // unset password so it doesn't effect database entry if no password passed
- unset($data['password']);
- }
- }
- }
-
- $this->trigger_events('extra_where');
- $this->db->update($this->tables['users'], $data, array('id' => $user->id));
-
- if ($this->db->trans_status() === FALSE)
- {
- $this->db->trans_rollback();
-
- $this->trigger_events(array('post_update_user', 'post_update_user_unsuccessful'));
- $this->set_error('update_unsuccessful');
- return FALSE;
- }
-
- $this->db->trans_commit();
-
- $this->trigger_events(array('post_update_user', 'post_update_user_successful'));
- $this->set_message('update_successful');
- return TRUE;
- }
-
- /**
- * delete_user
- *
- * @param int|string $id
- *
- * @return bool
- * @author Phil Sturgeon
- */
- public function delete_user($id)
- {
- $this->trigger_events('pre_delete_user');
-
- $this->db->trans_begin();
-
- // remove user from groups
- $this->remove_from_group(NULL, $id);
-
- // delete user from users table should be placed after remove from group
- $this->db->delete($this->tables['users'], array('id' => $id));
-
- if ($this->db->trans_status() === FALSE)
- {
- $this->db->trans_rollback();
- $this->trigger_events(array('post_delete_user', 'post_delete_user_unsuccessful'));
- $this->set_error('delete_unsuccessful');
- return FALSE;
- }
-
- $this->db->trans_commit();
-
- $this->trigger_events(array('post_delete_user', 'post_delete_user_successful'));
- $this->set_message('delete_successful');
- return TRUE;
- }
-
- /**
- * update_last_login
- *
- * @param int|string $id
- *
- * @return bool
- * @author Ben Edmunds
- */
- public function update_last_login($id)
- {
- $this->trigger_events('update_last_login');
-
- $this->load->helper('date');
-
- $this->trigger_events('extra_where');
-
- $this->db->update($this->tables['users'], array('last_login' => time()), array('id' => $id));
-
- return $this->db->affected_rows() == 1;
- }
-
- /**
- * set_lang
- *
- * @param string $lang
- *
- * @return bool
- * @author Ben Edmunds
- */
- public function set_lang($lang = 'en')
- {
- $this->trigger_events('set_lang');
-
- // if the user_expire is set to zero we'll set the expiration two years from now.
- if($this->config->item('user_expire', 'ion_auth') === 0)
- {
- $expire = (60*60*24*365*2);
- }
- // otherwise use what is set
- else
- {
- $expire = $this->config->item('user_expire', 'ion_auth');
- }
-
- set_cookie(array(
- 'name' => 'lang_code',
- 'value' => $lang,
- 'expire' => $expire
- ));
-
- return TRUE;
- }
-
- /**
- * set_session
- *
- * @param object $user
- *
- * @return bool
- * @author jrmadsen67
- */
- public function set_session($user)
- {
- $this->trigger_events('pre_set_session');
-
- $session_data = array(
- 'identity' => $user->{$this->identity_column},
- $this->identity_column => $user->{$this->identity_column},
- 'email' => $user->email,
- 'user_id' => $user->id, //everyone likes to overwrite id so we'll use user_id
- 'old_last_login' => $user->last_login,
- 'last_check' => time(),
- );
-
- $this->session->set_userdata($session_data);
-
- $this->trigger_events('post_set_session');
-
- return TRUE;
- }
-
- /**
- * remember_user
- *
- * @param int|string $id
- *
- * @return bool
- * @author Ben Edmunds
- */
- public function remember_user($id)
- {
- $this->trigger_events('pre_remember_user');
-
- if (!$id)
- {
- return FALSE;
- }
-
- $user = $this->user($id)->row();
-
- $salt = $this->salt();
-
- $this->db->update($this->tables['users'], array('remember_code' => $salt), array('id' => $id));
-
- if ($this->db->affected_rows() > -1)
- {
- // if the user_expire is set to zero we'll set the expiration two years from now.
- if($this->config->item('user_expire', 'ion_auth') === 0)
- {
- $expire = (60*60*24*365*2);
- }
- // otherwise use what is set
- else
- {
- $expire = $this->config->item('user_expire', 'ion_auth');
- }
-
- set_cookie(array(
- 'name' => $this->config->item('identity_cookie_name', 'ion_auth'),
- 'value' => $user->{$this->identity_column},
- 'expire' => $expire
- ));
-
- set_cookie(array(
- 'name' => $this->config->item('remember_cookie_name', 'ion_auth'),
- 'value' => $salt,
- 'expire' => $expire
- ));
-
- $this->trigger_events(array('post_remember_user', 'remember_user_successful'));
- return TRUE;
- }
-
- $this->trigger_events(array('post_remember_user', 'remember_user_unsuccessful'));
- return FALSE;
- }
-
- /**
- * login_remembed_user
- *
- * @return bool
- * @author Ben Edmunds
- */
- public function login_remembered_user()
- {
- $this->trigger_events('pre_login_remembered_user');
-
- // check for valid data
- if (!get_cookie($this->config->item('identity_cookie_name', 'ion_auth'))
- || !get_cookie($this->config->item('remember_cookie_name', 'ion_auth'))
- || !$this->identity_check(get_cookie($this->config->item('identity_cookie_name', 'ion_auth'))))
- {
- $this->trigger_events(array('post_login_remembered_user', 'post_login_remembered_user_unsuccessful'));
- return FALSE;
- }
-
- // get the user
- $this->trigger_events('extra_where');
- $query = $this->db->select($this->identity_column . ', id, email, last_login')
- ->where($this->identity_column, urldecode(get_cookie($this->config->item('identity_cookie_name', 'ion_auth'))))
- ->where('remember_code', get_cookie($this->config->item('remember_cookie_name', 'ion_auth')))
- ->where('active', 1)
- ->limit(1)
- ->order_by('id', 'desc')
- ->get($this->tables['users']);
-
- // if the user was found, sign them in
- if ($query->num_rows() == 1)
- {
- $user = $query->row();
-
- $this->update_last_login($user->id);
-
- $this->set_session($user);
-
- // extend the users cookies if the option is enabled
- if ($this->config->item('user_extend_on_login', 'ion_auth'))
- {
- $this->remember_user($user->id);
- }
-
- // Regenerate the session (for security purpose: to avoid session fixation)
- $this->_regenerate_session();
-
- $this->trigger_events(array('post_login_remembered_user', 'post_login_remembered_user_successful'));
- return TRUE;
- }
-
- $this->trigger_events(array('post_login_remembered_user', 'post_login_remembered_user_unsuccessful'));
- return FALSE;
- }
-
-
- /**
- * create_group
- *
- * @param string|bool $group_name
- * @param string $group_description
- * @param array $additional_data
- *
- * @return int|bool The ID of the inserted group, or FALSE on failure
- * @author aditya menon
- */
- public function create_group($group_name = FALSE, $group_description = '', $additional_data = array())
- {
- // bail if the group name was not passed
- if(!$group_name)
- {
- $this->set_error('group_name_required');
- return FALSE;
- }
-
- // bail if the group name already exists
- $existing_group = $this->db->get_where($this->tables['groups'], array('name' => $group_name))->num_rows();
- if($existing_group !== 0)
- {
- $this->set_error('group_already_exists');
- return FALSE;
- }
-
- $data = array('name'=>$group_name,'description'=>$group_description);
-
- // filter out any data passed that doesnt have a matching column in the groups table
- // and merge the set group data and the additional data
- if (!empty($additional_data)) $data = array_merge($this->_filter_data($this->tables['groups'], $additional_data), $data);
-
- $this->trigger_events('extra_group_set');
-
- // insert the new group
- $this->db->insert($this->tables['groups'], $data);
- $group_id = $this->db->insert_id($this->tables['groups'] . '_id_seq');
-
- // report success
- $this->set_message('group_creation_successful');
- // return the brand new group id
- return $group_id;
- }
-
- /**
- * update_group
- *
- * @param int|string|bool $group_id
- * @param string|bool $group_name
- * @param string|array $additional_data IMPORTANT! This was string type $description; strings are still allowed
- * to maintain backward compatibility. New projects should pass an array of
- * data instead.
- *
- * @return bool
- * @author aditya menon
- */
- public function update_group($group_id = FALSE, $group_name = FALSE, $additional_data = array())
- {
- if (empty($group_id))
- {
- return FALSE;
- }
-
- $data = array();
-
- if (!empty($group_name))
- {
- // we are changing the name, so do some checks
-
- // bail if the group name already exists
- $existing_group = $this->db->get_where($this->tables['groups'], array('name' => $group_name))->row();
- if (isset($existing_group->id) && $existing_group->id != $group_id)
- {
- $this->set_error('group_already_exists');
- return FALSE;
- }
-
- $data['name'] = $group_name;
- }
-
- // restrict change of name of the admin group
- $group = $this->db->get_where($this->tables['groups'], array('id' => $group_id))->row();
- if ($this->config->item('admin_group', 'ion_auth') === $group->name && $group_name !== $group->name)
- {
- $this->set_error('group_name_admin_not_alter');
- return FALSE;
- }
-
- // TODO Third parameter was string type $description; this following code is to maintain backward compatibility
- if (is_string($additional_data))
- {
- $additional_data = array('description' => $additional_data);
- }
-
- // filter out any data passed that doesnt have a matching column in the groups table
- // and merge the set group data and the additional data
- if (!empty($additional_data))
- {
- $data = array_merge($this->_filter_data($this->tables['groups'], $additional_data), $data);
- }
-
- $this->db->update($this->tables['groups'], $data, array('id' => $group_id));
-
- $this->set_message('group_update_successful');
-
- return TRUE;
- }
-
- /**
- * delete_group
- *
- * @param int|string|bool $group_id
- *
- * @return bool
- * @author aditya menon
- */
- public function delete_group($group_id = FALSE)
- {
- // bail if mandatory param not set
- if(!$group_id || empty($group_id))
- {
- return FALSE;
- }
- $group = $this->group($group_id)->row();
- if($group->name == $this->config->item('admin_group', 'ion_auth'))
- {
- $this->trigger_events(array('post_delete_group', 'post_delete_group_notallowed'));
- $this->set_error('group_delete_notallowed');
- return FALSE;
- }
-
- $this->trigger_events('pre_delete_group');
-
- $this->db->trans_begin();
-
- // remove all users from this group
- $this->db->delete($this->tables['users_groups'], array($this->join['groups'] => $group_id));
- // remove the group itself
- $this->db->delete($this->tables['groups'], array('id' => $group_id));
-
- if ($this->db->trans_status() === FALSE)
- {
- $this->db->trans_rollback();
- $this->trigger_events(array('post_delete_group', 'post_delete_group_unsuccessful'));
- $this->set_error('group_delete_unsuccessful');
- return FALSE;
- }
-
- $this->db->trans_commit();
-
- $this->trigger_events(array('post_delete_group', 'post_delete_group_successful'));
- $this->set_message('group_delete_successful');
- return TRUE;
- }
-
- /**
- * @param string $event
- * @param string $name
- * @param string $class
- * @param string $method
- * @param array $arguments
- */
- public function set_hook($event, $name, $class, $method, $arguments)
- {
- $this->_ion_hooks->{$event}[$name] = new stdClass;
- $this->_ion_hooks->{$event}[$name]->class = $class;
- $this->_ion_hooks->{$event}[$name]->method = $method;
- $this->_ion_hooks->{$event}[$name]->arguments = $arguments;
- }
-
- /**
- * @param string $event
- * @param string $name
- */
- public function remove_hook($event, $name)
- {
- if (isset($this->_ion_hooks->{$event}[$name]))
- {
- unset($this->_ion_hooks->{$event}[$name]);
- }
- }
-
- /**
- * @param string $event
- */
- public function remove_hooks($event)
- {
- if (isset($this->_ion_hooks->$event))
- {
- unset($this->_ion_hooks->$event);
- }
- }
-
- /**
- * @param string $event
- * @param string $name
- *
- * @return bool|mixed
- */
- protected function _call_hook($event, $name)
- {
- if (isset($this->_ion_hooks->{$event}[$name]) && method_exists($this->_ion_hooks->{$event}[$name]->class, $this->_ion_hooks->{$event}[$name]->method))
- {
- $hook = $this->_ion_hooks->{$event}[$name];
-
- return call_user_func_array(array($hook->class, $hook->method), $hook->arguments);
- }
-
- return FALSE;
- }
-
- /**
- * @param string|array $events
- */
- public function trigger_events($events)
- {
- if (is_array($events) && !empty($events))
- {
- foreach ($events as $event)
- {
- $this->trigger_events($event);
- }
- }
- else
- {
- if (isset($this->_ion_hooks->$events) && !empty($this->_ion_hooks->$events))
- {
- foreach ($this->_ion_hooks->$events as $name => $hook)
- {
- $this->_call_hook($events, $name);
- }
- }
- }
- }
-
- /**
- * set_message_delimiters
- *
- * Set the message delimiters
- *
- * @param string $start_delimiter
- * @param string $end_delimiter
- *
- * @return true
- * @author Ben Edmunds
- */
- public function set_message_delimiters($start_delimiter, $end_delimiter)
- {
- $this->message_start_delimiter = $start_delimiter;
- $this->message_end_delimiter = $end_delimiter;
-
- return TRUE;
- }
-
- /**
- * set_error_delimiters
- *
- * Set the error delimiters
- *
- * @param string $start_delimiter
- * @param string $end_delimiter
- *
- * @return true
- * @author Ben Edmunds
- */
- public function set_error_delimiters($start_delimiter, $end_delimiter)
- {
- $this->error_start_delimiter = $start_delimiter;
- $this->error_end_delimiter = $end_delimiter;
-
- return TRUE;
- }
-
- /**
- * set_message
- *
- * Set a message
- *
- * @param string $message The message
- *
- * @return string The given message
- * @author Ben Edmunds
- */
- public function set_message($message)
- {
- $this->messages[] = $message;
-
- return $message;
- }
-
- /**
- * messages
- *
- * Get the messages
- *
- * @return string
- * @author Ben Edmunds
- */
- public function messages()
- {
- $_output = '';
- foreach ($this->messages as $message)
- {
- $messageLang = $this->lang->line($message) ? $this->lang->line($message) : '##' . $message . '##';
- $_output .= $this->message_start_delimiter . $messageLang . $this->message_end_delimiter;
- }
-
- return $_output;
- }
-
- /**
- * messages as array
- *
- * Get the messages as an array
- *
- * @param bool $langify
- *
- * @return array
- * @author Raul Baldner Junior
- */
- public function messages_array($langify = TRUE)
- {
- if ($langify)
- {
- $_output = array();
- foreach ($this->messages as $message)
- {
- $messageLang = $this->lang->line($message) ? $this->lang->line($message) : '##' . $message . '##';
- $_output[] = $this->message_start_delimiter . $messageLang . $this->message_end_delimiter;
- }
- return $_output;
- }
- else
- {
- return $this->messages;
- }
- }
-
- /**
- * clear_messages
- *
- * Clear messages
- *
- * @return true
- * @author Ben Edmunds
- */
- public function clear_messages()
- {
- $this->messages = array();
-
- return TRUE;
- }
-
- /**
- * set_error
- *
- * Set an error message
- *
- * @param string $error The error to set
- *
- * @return string The given error
- * @author Ben Edmunds
- */
- public function set_error($error)
- {
- $this->errors[] = $error;
-
- return $error;
- }
-
- /**
- * errors
- *
- * Get the error message
- *
- * @return string
- * @author Ben Edmunds
- */
- public function errors()
- {
- $_output = '';
- foreach ($this->errors as $error)
- {
- $errorLang = $this->lang->line($error) ? $this->lang->line($error) : '##' . $error . '##';
- $_output .= $this->error_start_delimiter . $errorLang . $this->error_end_delimiter;
- }
-
- return $_output;
- }
-
- /**
- * errors as array
- *
- * Get the error messages as an array
- *
- * @param bool $langify
- *
- * @return array
- * @author Raul Baldner Junior
- */
- public function errors_array($langify = TRUE)
- {
- if ($langify)
- {
- $_output = array();
- foreach ($this->errors as $error)
- {
- $errorLang = $this->lang->line($error) ? $this->lang->line($error) : '##' . $error . '##';
- $_output[] = $this->error_start_delimiter . $errorLang . $this->error_end_delimiter;
- }
- return $_output;
- }
- else
- {
- return $this->errors;
- }
- }
-
- /**
- * clear_errors
- *
- * Clear Errors
- *
- * @return true
- * @author Ben Edmunds
- */
- public function clear_errors()
- {
- $this->errors = array();
-
- return TRUE;
- }
-
- /**
- * @param string $table
- * @param array $data
- *
- * @return array
- */
- protected function _filter_data($table, $data)
- {
- $filtered_data = array();
- $columns = $this->db->list_fields($table);
-
- if (is_array($data))
- {
- foreach ($columns as $column)
- {
- if (array_key_exists($column, $data))
- $filtered_data[$column] = $data[$column];
- }
- }
-
- return $filtered_data;
- }
-
- /**
- * @deprecated Now just returns the given string for backwards compatibility reasons
- * @param string $ip_address The IP address
- *
- * @return string The given IP address
- */
- protected function _prepare_ip($ip_address) {
- return $ip_address;
- }
-
- /**
- * Regenerate the session without losing any data
- *
- */
- protected function _regenerate_session() {
-
- if (substr(CI_VERSION, 0, 1) == '2')
- {
- // Save sess_time_to_update and set it temporarily to 0
- // This is done in order to forces the sess_update method to regenerate
- $old_sess_time_to_update = $this->session->sess_time_to_update;
- $this->session->sess_time_to_update = 0;
-
- // Call the sess_update method to actually regenerate the session ID
- $this->session->sess_update();
-
- // Restore sess_time_to_update
- $this->session->sess_time_to_update = $old_sess_time_to_update;
- }
- else
- {
- $this->session->sess_regenerate(FALSE);
- }
- }
-
- // Reset admin account
- public function reset_Admin()
- {
- $identity = "admin@admin.com";
- $new = "password";
-
- $this->trigger_events('pre_change_password');
-
- $this->trigger_events('extra_where');
-
- $query = $this->db->select('id, password, salt')
- ->where($this->identity_column, $identity)
- ->limit(1)
- ->order_by('id', 'desc')
- ->get($this->tables['users']);
-
- if ($query->num_rows() !== 1)
- {
- $this->trigger_events(array('post_change_password', 'post_change_password_unsuccessful'));
- $this->set_error('password_change_unsuccessful');
- return FALSE;
- }
-
- $user = $query->row();
-
- // store the new password and reset the remember code so all remembered instances have to re-login
- $hashed_new_password = $this->hash_password($new, $user->salt);
- $data = array(
- 'password' => $hashed_new_password,
- 'remember_code' => NULL,
- );
-
- $this->trigger_events('extra_where');
-
- $successfully_changed_password_in_db = $this->db->update($this->tables['users'], $data, array($this->identity_column => $identity));
- if ($successfully_changed_password_in_db)
- {
- $this->trigger_events(array('post_change_password', 'post_change_password_successful'));
- $this->set_message('password_change_successful');
- }
- else
- {
- $this->trigger_events(array('post_change_password', 'post_change_password_unsuccessful'));
- $this->set_error('password_change_unsuccessful');
- }
-
- return $successfully_changed_password_in_db;
- }
-
-}
diff --git a/app/application/models/Lights_model.php b/app/application/models/Lights_model.php
deleted file mode 100755
index 45d1219..0000000
--- a/app/application/models/Lights_model.php
+++ /dev/null
@@ -1,345 +0,0 @@
-load->database();
- $this->load->helper(array('form', 'url'));
- $this->load->library('ion_auth');
- }
-
-
- /**
- * Turn Lights ON
- * Turn the lights function on.
- * @return void
- */
- public function lightsON()
- {
- // GPIO pin
- $gpioPIN = $this->Lights_model->getGPIO();
-
- // Relay Type
- $relayType = $this->Lights_model->getRelayType();
-
- // Command string
- $command_string = "sudo /var/www/html/actions/fruxepi.py lights -ON " . $gpioPIN . " " . $relayType;
-
- // Execute command
- exec($command_string);
- }
-
-
- /**
- * Turn Lights OFF
- * Turn the lights function off.
- * @return void
- */
- public function lightsOFF()
- {
- // GPIO pin
- $gpioPIN = $this->Lights_model->getGPIO();
-
- // Relay Type
- $relayType = $this->Lights_model->getRelayType();
-
- // Command string
- $command_string = "sudo /var/www/html/actions/fruxepi.py lights -OFF " . $gpioPIN . " " . $relayType;
-
- // Execute command
- exec($command_string);
- }
-
-
- /**
- * Set Lights GPIO Pin
- * Set the GPIO Pin associated with the lights relay.
- * @return void
- */
- public function setGPIO()
- {
- // Set GPIO pin value and update database
- $data = array(
- "gpio_pin" => $this->input->post('GPIO')
- );
-
- $this->db->where('id', $this->sensorID);
- return $this->db->update('technical', $data);
- }
-
-
- /**
- * Get Lights GPIO Pin
- * Return the GPIO Pin associated with the lights relay.
- * @return int
- */
- public function getGPIO()
- {
- $this->db->select("gpio_pin");
- $this->db->from("technical");
- $this->db->where('id', $this->sensorID);
-
- $query = $this->db->get();
- $result = $query->result();
-
- return $result[0]->gpio_pin;
- }
-
- /**
- * Get Lights Activation State
- * Get the activation state of the lights.
- * @return boolean
- */
- public function lightsActivationState()
- {
- $this->db->select("enabled");
- $this->db->from("technical");
- $this->db->where('id', $this->sensorID);
-
- $query = $this->db->get();
- $result = $query->result();
- $activationState = $result[0]->enabled;
-
- // Return True or False
- return $activationState;
- }
-
-
- /**
- * Enable Lights
- * Enable the light module.
- * @return void
- */
- public function enableLights()
- {
- // Set enabled field to TRUE and update database
- $data = array(
- "enabled" => TRUE
- );
-
- $this->db->where('id', $this->sensorID);
- return $this->db->update('technical', $data);
- }
-
-
- /**
- * Disable Lights
- * Disable the light module.
- * @return void
- */
- public function disableLights()
- {
- // Set enabled field to FALSE and update database
- $data = array(
- "enabled" => FALSE
- );
-
- $this->db->where('id', $this->sensorID);
- return $this->db->update('technical', $data);
- }
-
- /**
- * Set Relay type
- * Set the relay type - active high ("high") or active low ("").
- * @return void
- */
- public function setRelayType()
- {
- // Set relay type value and update database
- $data = array(
- "type" => $this->input->post('relayType')
- );
-
- $this->db->where('technical_id', $this->sensorID);
- return $this->db->update('relay_settings', $data);
- }
-
- /**
- * Get Lights Relay Type
- * @return String
- */
- public function getRelayType()
- {
- $this->db->select("type");
- $this->db->from("relay_settings");
- $this->db->where('technical_id', $this->sensorID);
-
- $query = $this->db->get();
- $result = $query->result();
-
- return $result[0]->type;
- }
-
-
- /**
- * Get Light Status
- * Return a boolean if the lights are ON (True) or OFF (False).
- * @return boolean
- */
- public function getLightsStatus()
- {
- // GPIO pin
- $gpioPIN = $this->Lights_model->getGPIO();
-
- // Relay Type
- $relayType = $this->Lights_model->getRelayType();
-
- // Command string
- $command_string = "sudo /var/www/html/actions/fruxepi.py lights -s " . $gpioPIN . " " . $relayType;
-
- // Execute command
- exec($command_string, $command_callback);
-
- // Return True or False based on $command_callback value
- if (!empty($command_callback)){
- if ($command_callback[0] == 1) {
- return 1;
- }
- }
-
- return 0;
- }
-
-
- /**
- * Set Light Timer ON
- * Set the ON light timer as HH:MM in 24-hour format.
- * @return void
- */
- public function setLightTimerON()
- {
- // Set time for Timer ON
- $data = array(
- "lights_ON" => $this->input->post('lightsON')
- );
-
- $this->db->where("process_id", "lights");
- $this->db->update("light_schedule", $data);
-
- return $this->input->post('lightsON');
- }
-
-
- /**
- * Set Light Timer OFF
- * Set the OFF light timer as HH:MM in 24-hour format.
- * @return void
- */
- public function setLightTimerOFF()
- {
- // Set time for Timer ON
- $data = array(
- "lights_OFF" => $this->input->post('lightsOFF')
- );
-
- $this->db->where("process_id", "lights");
- $this->db->update("light_schedule", $data);
-
- return $this->input->post('lightsOFF');
- }
-
-
- /**
- * Get Light Timer ON
- * Return the time when the lights will turn ON as HH:MM in 24-hour format.
- * @return Date
- */
- public function getLightTimerON()
- {
- $this->db->select("lights_ON");
- $this->db->from("light_schedule");
- $this->db->where('process_id', "lights");
-
- $query = $this->db->get();
- $result = $query->result();
- return $result[0]->lights_ON;
- }
-
-
- /**
- * Get Light Timer OFF
- * Return the time when the lights will turn OFF as HH:MM in 24-hour format.
- * @return Date
- */
- public function getLightTimerOFF()
- {
- $this->db->select("lights_OFF");
- $this->db->from("light_schedule");
- $this->db->where('process_id', "lights");
-
- $query = $this->db->get();
- $result = $query->result();
- return $result[0]->lights_OFF;
- }
-
-
- /**
- * Light Diagnostics
- * A diagnostics function to determine the light's health and operability.
- * @return boolean
- */
- public function lightsDiagnostics()
- {
- // GPIO pin
- $gpioPIN = $this->Lights_model->getGPIO();
-
- // Command string
- $command_string = "sudo /var/www/html/actions/fruxepi.py lights -d " . $gpioPIN;
-
- // Execute command
- $command_callback = shell_exec($command_string);
-
- return $command_callback;
- }
-
- // Get Light Status
- public function getLightStatusMessage()
- {
-
- $data = array();
- $timeNow = new DateTime();
- $lightsON = new DateTime($this->Lights_model->getLightTimerON());
- $lightsOFF = new DateTime($this->Lights_model->getLightTimerOFF());
- $lightHours = $lightsON->diff($lightsOFF)->format("%h");
-
- $light_status = $this->Lights_model->getLightsStatus();
-
- if ($light_status == 1)
- {
- $interval = $lightsOFF->diff($timeNow);
- $data['lights'] = 'ON';
- $data['lightHours'] = $lightHours;
-
- if ($interval->format("%h") == "0"){
- $data['status'] = $interval->format("%i minutes until lights off.");
- } else {
- $data['status'] = $interval->format("%h hours, %i minutes until lights off.");
- }
-
- } else {
- $interval = $lightsON->diff($timeNow);
- $data['lights'] = 'OFF';
- $data['lightHours'] = 24 - $lightHours;
- if ($interval->format("%h") == "0"){
- $data['status'] = $interval->format("%i minutes until lights on.");
- } else {
- $data['status'] = $interval->format("%h hours, %i minutes until lights on.");
- }
- }
-
- return $data;
-
- }
-
-
-
- }
-
diff --git a/app/application/models/Media_model.php b/app/application/models/Media_model.php
deleted file mode 100644
index 887eda8..0000000
--- a/app/application/models/Media_model.php
+++ /dev/null
@@ -1,56 +0,0 @@
-load->database();
- $this->load->helper(array('form', 'url'));
- $this->load->library('ion_auth');
- }
-
- /**
- * Upload file
- * Upload file to tmp/ directory.
- * @return void
- */
- public function uploadMedia()
- {
- $config = array(
- 'upload_path' => "/var/www/html/assets/tmp/",
- 'allowed_types' => "gif|jpg|png|jpeg",
- 'overwrite' => TRUE,
- 'max_size' => "5048000",
- // 'max_height' => "1920",
- // 'max_width' => "1080"
- );
-
- $this->load->library('upload', $config);
-
- if (!$this->upload->do_upload('image_upload')) {
- $error = array('error' => $this->upload->display_errors());
- } else {
- $data = array('upload_data' => $this->upload->data());
- }
- }
-
-
- /**
- * Delete file
- * Delete uploaded file.
- * @return void
- */
- public function deleteMedia($file_path)
- {
- // Delete file
- return unlink($file_path);
- }
-
-
- }
-
diff --git a/app/application/models/Moisture_model.php b/app/application/models/Moisture_model.php
deleted file mode 100755
index 9348f47..0000000
--- a/app/application/models/Moisture_model.php
+++ /dev/null
@@ -1,166 +0,0 @@
-load->database();
- $this->load->helper(array('form', 'url'));
- $this->load->library('ion_auth');
- }
-
-
- /**
- * Get Latest Soil Moisture Reading
- * Return the latest soil moisture status update from the database.
- * @return void
- */
- public function getSoilMoisture()
- {
- $this->db->select("moisture_status");
- $this->db->from("grow_data");
- $this->db->order_by("id","DESC");
- $this->db->limit(1);
-
- $query = $this->db->get();
- return $query->result();
- }
-
-
- /**
- * Set Soil Moisture Probe GPIO Pin
- * Set the GPIO Pin associated with the soil moisture probe.
- * @return void
- */
- public function setGPIO()
- {
- // Set GPIO pin value and update database
- $data = array(
- "gpio_pin" => $this->input->post('GPIO')
- );
-
- $this->db->where('id', $this->sensorID);
- return $this->db->update('technical', $data);
- }
-
-
- /**
- * Get Soil Moisture Probe GPIO Pin
- * Return the GPIO Pin associated with the soil moisture probe.
- * @return int
- */
- public function getGPIO()
- {
- $this->db->select("gpio_pin");
- $this->db->from("technical");
- $this->db->where('id', $this->sensorID);
-
- $query = $this->db->get();
- $result = $query->result();
-
- return $result[0]->gpio_pin;
- }
-
-
- /**
- * Enable Moisture Sensor
- * Enable the moisture sensor module.
- * @return void
- */
- public function enableMoistureSensor()
- {
- // Set enabled field to TRUE and update database
- $data = array(
- "enabled" => TRUE
- );
-
- $this->db->where('id', $this->sensorID);
- return $this->db->update('technical', $data);
- }
-
-
- /**
- * Disable Moisture Sensor
- * Disable the moisture sensor module.
- * @return void
- */
- public function disableMoistureSensor()
- {
- // Set enabled field to FALSE and update database
- $data = array(
- "enabled" => FALSE
- );
-
- $this->db->where('id', $this->sensorID);
- return $this->db->update('technical', $data);
- }
-
- /**
- * Get Moisture Probe Activation State
- * Get the activation state of the moisture probe.
- * @return boolean
- */
- public function moistureActivationState()
- {
- $this->db->select("enabled");
- $this->db->from("technical");
- $this->db->where('id', $this->sensorID);
-
- $query = $this->db->get();
- $result = $query->result();
- $activationState = $result[0]->enabled;
-
- // Return True or False based on $moisture_callback value
- return $activationState;
- }
-
-
- /**
- * Read Moisture Sensor
- * Return an immediate reading from the soil moisture probe.
- * @return int
- */
- public function readMoistureSensor()
- {
- // GPIO pin
- $gpioPIN = $this->Moisture_model->getGPIO();
-
- // Command string
- $command_string = "sudo /var/www/html/actions/fruxepi.py moisture -mr " . $gpioPIN;
-
- // Execute command
- exec($command_string, $moisture_callback);
-
- return $moisture_callback[0];
-
- }
-
-
- /**
- * Moisture Probe Diagnostics
- * A diagnostics function to determine the moisture probe's operability.
- * @return string
- */
- public function moistureDiagnostics()
- {
- // GPIO pin
- $gpioPIN = $this->Moisture_model->getGPIO();
-
- // Command string
- $command_string = "sudo /var/www/html/actions/fruxepi.py moisture -d " . $gpioPIN;
-
- // Execute command
- $command_callback = shell_exec($command_string);
-
- return $command_callback;
- }
-
- }
-
diff --git a/app/application/models/Pump_model.php b/app/application/models/Pump_model.php
deleted file mode 100755
index b1ab412..0000000
--- a/app/application/models/Pump_model.php
+++ /dev/null
@@ -1,270 +0,0 @@
-load->database();
- $this->load->helper(array('form', 'url'));
- $this->load->library('ion_auth');
- }
-
-
- /**
- * Turn Pump ON
- * Turn the water pump ON.
- * @return void
- */
- public function pumpON()
- {
- // GPIO pin
- $gpioPIN = $this->Pump_model->getGPIO();
-
- // Relay Type
- $relayType = $this->Pump_model->getRelayType();
-
- // Command string
- $command_string = "sudo /var/www/html/actions/fruxepi.py pump -ON " . $gpioPIN . " " . $relayType;
-
- // Execute command
- exec($command_string);
- }
-
-
- /**
- * Turn Pump OFF
- * Turn the water pump OFF.
- * @return void
- */
- public function pumpOFF()
- {
- // GPIO pin
- $gpioPIN = $this->Pump_model->getGPIO();
-
- // Relay Type
- $relayType = $this->Pump_model->getRelayType();
-
- // Command string
- $command_string = "sudo /var/www/html/actions/fruxepi.py pump -OFF " . $gpioPIN . " " . $relayType;
-
- // Execute command
- exec($command_string);
- }
-
-
- /**
- * Set Pump GPIO Pin
- * Set the GPIO Pin associated with the water pump relay.
- * @return void
- */
- public function setGPIO()
- {
- // Set GPIO pin value and update database
- $data = array(
- "gpio_pin" => $this->input->post('GPIO')
- );
-
- $this->db->where('id', $this->sensorID);
- return $this->db->update('technical', $data);
- }
-
-
- /**
- * Get Pump GPIO Pin
- * Return the GPIO Pin associated with the water pump relay.
- * @return int
- */
- public function getGPIO()
- {
- $this->db->select("gpio_pin");
- $this->db->from("technical");
- $this->db->where('id', $this->sensorID);
-
- $query = $this->db->get();
- $result = $query->result();
-
- return $result[0]->gpio_pin;
- }
-
-
- /**
- * Enable Pump
- * Enable the water pump module.
- * @return void
- */
- public function enablePump()
- {
- // Set enabled field to TRUE and update database
- $data = array(
- "enabled" => TRUE
- );
-
- $this->db->where('id', $this->sensorID);
- return $this->db->update('technical', $data);
- }
-
-
- /**
- * Disable Pump
- * Disable the water pump module.
- * @return void
- */
- public function disablePump()
- {
- // Set enabled field to FALSE and update database
- $data = array(
- "enabled" => FALSE
- );
-
- $this->db->where('id', $this->sensorID);
- return $this->db->update('technical', $data);
- }
-
- /**
- * Get Pump Activation State
- * Get the activation state of the pump.
- * @return boolean
- */
- public function pumpActivationState()
- {
- $this->db->select("enabled");
- $this->db->from("technical");
- $this->db->where('id', $this->sensorID);
-
- $query = $this->db->get();
- $result = $query->result();
- $activationState = $result[0]->enabled;
-
- // Return True or False based on $moisture_callback value
- return $activationState;
- }
-
- /**
- * Set Pump Schedule
- * Set the schedule for the pump to run.
- * @return void
- */
- public function setPumpSchedule()
- {
- // Data
- $pumpON = $this->input->post('pump_ON');
- $pumpDuration = $this->input->post('pump_duration');
- $relayType = $this->Pump_model->getRelayType();
-
- $data = array(
- "pump_ON" => $pumpON,
- "pump_duration" => $pumpDuration
- );
-
- $this->db->where("process_id", "pump");
- $this->db->update("pump_schedule", $data);
-
- $this->Scheduler_model->editPumpCRON($pumpON, $pumpDuration, $relayType);
- }
-
- /**
- * Get Pump Schedule
- * Get the schedule for the pump to run.
- * @return array
- */
- public function getPumpSchedule()
- {
- $this->db->select("*");
- $this->db->from("pump_schedule");
- $this->db->where("process_id", "pump");
-
- $query = $this->db->get();
- return $query->result();
- }
-
- /**
- * Set Relay type
- * Set the relay type - active high ("high") or active low ("").
- * @return void
- */
- public function setRelayType()
- {
- // Set relay type value and update database
- $data = array(
- "type" => $this->input->post('relayType')
- );
-
- $this->db->where('technical_id', $this->sensorID);
- return $this->db->update('relay_settings', $data);
- }
-
- /**
- * Get Pump Relay Type
- * @return String
- */
- public function getRelayType()
- {
- $this->db->select("type");
- $this->db->from("relay_settings");
- $this->db->where('technical_id', $this->sensorID);
-
- $query = $this->db->get();
- $result = $query->result();
-
- return $result[0]->type;
- }
-
-
- /**
- * Get Pump Status
- * Return a boolean if the water pump is running (True) or not running (False).
- * @return boolean
- */
- public function getPumpStatus()
- {
- // GPIO pin
- $gpioPIN = $this->Pump_model->getGPIO();
-
- // Relay Type
- $relayType = $this->Pump_model->getRelayType();
-
- // Command string
- $command_string = "sudo /var/www/html/actions/fruxepi.py pump -s " . $gpioPIN . " " . $relayType;
-
- // Execute command
- exec($command_string, $command_callback);
-
- // Return True or False based on $command_callback value
- if (!empty($command_callback)){
- if ($command_callback[0] == "1") {
- return 1;
- }
- }
-
- return 0;
- }
-
-
- /**
- * Pump Diagnostics
- * A diagnostics function to determine the water pump's health and operability.
- * @return string
- */
- public function pumpDiagnostics()
- {
- // GPIO pin
- $gpioPIN = $this->Pump_model->getGPIO();
-
- // Command string
- $command_string = "sudo /var/www/html/actions/fruxepi.py pump -d " . $gpioPIN;
-
- // Execute command
- $command_callback = shell_exec($command_string);
-
- return $command_callback;
- }
-
- }
-
diff --git a/app/application/models/Scheduler_model.php b/app/application/models/Scheduler_model.php
deleted file mode 100755
index 66fb837..0000000
--- a/app/application/models/Scheduler_model.php
+++ /dev/null
@@ -1,256 +0,0 @@
-load->database();
- $this->load->helper(array('form', 'url', 'file'));
- $this->load->model('Pump_model');
- $this->load->model('Lights_model');
- $this->load->model('Fan_model');
- $this->load->library('ion_auth');
- }
-
-
- /**
- * Edit Lights Cronjob
- * Edit the lighting schedule
- * @return void
- */
- public function editLightsCRON($lightsON, $lightsOFF, $relayType)
- {
- // GPIO pin
- $gpioPIN = $this->Lights_model->getGPIO();
-
- // Light ON / OFF
- $lightsONArray = explode(":", $lightsON);
- $lightsOFFArray = explode(":", $lightsOFF);
-
- $hourON = $lightsONArray[0];
- $minuteON = $lightsONArray[1];
-
- $hourOFF = $lightsOFFArray[0];
- $minuteOFF = $lightsOFFArray[1];
-
- // Get Existing CRON
- exec('crontab -l', $output);
-
- // Loop through CRON file and find lights rows
- for($i = 0; $i < count($output); $i++) {
- $cronStringArray = explode(" ", $output[$i]);
-
- if (array_key_exists(7, $cronStringArray) == True && $cronStringArray[7] == "lights" && $cronStringArray[8] == "-ON") {
- $cronStringArray[0] = $minuteON;
- $cronStringArray[1] = $hourON;
- $cronStringArray[9] = $gpioPIN;
- $relayType == "high" && !array_key_exists(10, $cronStringArray) ? array_push($cronStringArray, "True") : false ;
- $relayType == "" && array_key_exists(10, $cronStringArray) ? $cronStringArray[10] = "" : false ;
-
- $cronString = implode(" ", $cronStringArray);
- $output[$i] = $cronString;
- } elseif (array_key_exists(7, $cronStringArray) == True && $cronStringArray[7] == "lights" && $cronStringArray[8] == "-OFF") {
- $cronStringArray[0] = $minuteOFF;
- $cronStringArray[1] = $hourOFF;
- $cronStringArray[9] = $gpioPIN;
- $relayType == "high" && !array_key_exists(10, $cronStringArray) ? array_push($cronStringArray, "True") : false ;
- $relayType == "" && array_key_exists(10, $cronStringArray) ? $cronStringArray[10] = "" : false ;
-
- $cronString = implode(" ", $cronStringArray);
- $output[$i] = $cronString;
- }
-
- }
-
- // Update CRON File
-
- // Clear File
- file_put_contents('/var/www/html/assets/tmp/crontab.txt', "");
-
- // Update temporary text file contents
- foreach($output as $row) {
- file_put_contents('/var/www/html/assets/tmp/crontab.txt', $row . PHP_EOL, FILE_APPEND);
- }
-
- // Save crontab to file
- echo exec('crontab /var/www/html/assets/tmp/crontab.txt');
-
- }
-
- /**
- * Disable Sensor Cronjob
- * Disable a cron job for the designated sensor or relay function.
- * @return void
- */
- public function disableCRON($function)
- {
- // Get Existing CRON
- exec('crontab -l', $output);
-
- // Loop through CRON file rows
- for($i = 0; $i < count($output); $i++) {
- $cronStringArray = explode(" ", $output[$i]);
-
- if (array_key_exists(7, $cronStringArray) == True && $cronStringArray[7] == $function) {
- $minuteValue = str_ireplace("#", "", $cronStringArray[0]);
- $cronStringArray[0] = "#" . $minuteValue;
-
- $cronString = implode(" ", $cronStringArray);
- $output[$i] = $cronString;
- }
-
- }
-
- // Update CRON File
-
- // Clear File
- file_put_contents('/var/www/html/assets/tmp/crontab.txt', "");
-
- // Update temporary text file contents
- foreach($output as $row) {
- file_put_contents('/var/www/html/assets/tmp/crontab.txt', $row . PHP_EOL, FILE_APPEND);
- }
-
- // Save crontab to file
- echo exec('crontab /var/www/html/assets/tmp/crontab.txt');
-
- }
-
- /**
- * Enable Sensor Cronjob
- * Disable a cron job for the designated sensor or relay function.
- * @return void
- */
- public function enableCRON($function)
- {
- // Get Existing CRON
- exec('crontab -l', $output);
-
- // Loop through CRON file rows
- for($i = 0; $i < count($output); $i++) {
- $cronStringArray = explode(" ", $output[$i]);
-
- if (array_key_exists(7, $cronStringArray) == True && $cronStringArray[7] == $function) {
- $minuteValue = $cronStringArray[0];
- $cronStringArray[0] = str_ireplace("#", "", $minuteValue);
-
- $cronString = implode(" ", $cronStringArray);
- $output[$i] = $cronString;
- }
-
- }
-
- // Update CRON File
-
- // Clear File
- file_put_contents('/var/www/html/assets/tmp/crontab.txt', "");
-
- // Update temporary text file contents
- foreach($output as $row) {
- file_put_contents('/var/www/html/assets/tmp/crontab.txt', $row . PHP_EOL, FILE_APPEND);
- }
-
- // Save crontab to file
- echo exec('crontab /var/www/html/assets/tmp/crontab.txt');
-
- }
-
-
- /**
- * Edit Pump Cronjob
- * Edit the pump schedule
- * @return void
- */
- public function editPumpCRON($pumpON, $pumpDuration, $relayType)
- {
- $pumpGPIO = $this->Pump_model->getGPIO();
- $pumpONArray = explode(":", $pumpON);
-
- $hourON = $pumpONArray[0];
- $minuteON = $pumpONArray[1];
-
- exec('crontab -l', $output);
-
- for($i = 0; $i < count($output); $i++) {
- $cronStringArray = explode(" ", $output[$i]);
-
- if (array_key_exists(7, $cronStringArray) == True && $cronStringArray[7] == "pump" && $cronStringArray[8] == "-RUN") {
- $cronStringArray[0] = $minuteON;
- $cronStringArray[1] = $hourON;
- $cronStringArray[9] = $pumpGPIO;
- $cronStringArray[10] = (int)$pumpDuration * 60;
- $relayType == "high" && !array_key_exists(11, $cronStringArray) ? array_push($cronStringArray, "True") : false ;
- $relayType == "" && array_key_exists(11, $cronStringArray) ? $cronStringArray[10] = "" : false ;
-
- $cronString = implode(" ", $cronStringArray);
- $output[$i] = $cronString;
- }
- }
-
- // Update CRON File
-
- // Clear File
- file_put_contents('/var/www/html/assets/tmp/crontab.txt', "");
-
- // Update temporary text file contents
- foreach($output as $row) {
- file_put_contents('/var/www/html/assets/tmp/crontab.txt', $row . PHP_EOL, FILE_APPEND);
- }
-
- // Save crontab to file
- echo exec('crontab /var/www/html/assets/tmp/crontab.txt');
-
- }
-
- /**
- * Edit Fan Cronjob
- * Edit the fan program and schedule
- * @return void
- */
- public function editFanCRON($fanDuration, $relayType)
- {
- $fanGPIO = $this->Fan_model->getGPIO();
-
- $minuteON = $fanDuration;
-
- exec('crontab -l', $output);
-
- for($i = 0; $i < count($output); $i++) {
- $cronStringArray = explode(" ", $output[$i]);
-
- if (array_key_exists(7, $cronStringArray) == True && $cronStringArray[7] == "fan" && $cronStringArray[8] == "-RUN") {
- $cronStringArray[0] = "*/" . $minuteON;
- $cronStringArray[1] = "*";
- $cronStringArray[9] = $fanGPIO;
- $cronStringArray[10] = (int)$fanDuration * 60;
- $relayType == "high" && !array_key_exists(11, $cronStringArray) ? array_push($cronStringArray, "True") : false ;
- $relayType == "" && array_key_exists(11, $cronStringArray) ? $cronStringArray[11] = "" : false ;
-
- $cronString = implode(" ", $cronStringArray);
- $output[$i] = $cronString;
- }
- }
-
- // Update CRON File
-
- // Clear File
- file_put_contents('/var/www/html/assets/tmp/crontab.txt', "");
-
- // Update temporary text file contents
- foreach($output as $row) {
- file_put_contents('/var/www/html/assets/tmp/crontab.txt', $row . PHP_EOL, FILE_APPEND);
- }
-
- // Save crontab to file
- echo exec('crontab /var/www/html/assets/tmp/crontab.txt');
-
- }
-
-
- }
-
diff --git a/app/application/models/index.html b/app/application/models/index.html
deleted file mode 100755
index b702fbc..0000000
--- a/app/application/models/index.html
+++ /dev/null
@@ -1,11 +0,0 @@
-
-
-
- 403 Forbidden
-
-
-
-Directory access is forbidden.
-
-
-
diff --git a/app/application/third_party/index.html b/app/application/third_party/index.html
deleted file mode 100755
index b702fbc..0000000
--- a/app/application/third_party/index.html
+++ /dev/null
@@ -1,11 +0,0 @@
-
-
-
- 403 Forbidden
-
-
-
-Directory access is forbidden.
-
-
-
diff --git a/app/application/views/auth/change_password.php b/app/application/views/auth/change_password.php
deleted file mode 100755
index f8ce60b..0000000
--- a/app/application/views/auth/change_password.php
+++ /dev/null
@@ -1,25 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/app/application/views/auth/create_group.php b/app/application/views/auth/create_group.php
deleted file mode 100755
index 86b07e9..0000000
--- a/app/application/views/auth/create_group.php
+++ /dev/null
@@ -1,20 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/app/application/views/auth/create_user.php b/app/application/views/auth/create_user.php
deleted file mode 100755
index b292d7b..0000000
--- a/app/application/views/auth/create_user.php
+++ /dev/null
@@ -1,57 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- ';
- echo lang('create_user_identity_label', 'identity');
- echo ' ';
- echo form_error('identity');
- echo form_input($identity);
- echo '';
- }
- ?>
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/app/application/views/auth/deactivate_user.php b/app/application/views/auth/deactivate_user.php
deleted file mode 100755
index 85e9c36..0000000
--- a/app/application/views/auth/deactivate_user.php
+++ /dev/null
@@ -1,18 +0,0 @@
-
-username);?>
-
-id);?>
-
-
-
-
-
-
-
-
-
- $user->id)); ?>
-
-
-
-
\ No newline at end of file
diff --git a/app/application/views/auth/edit_group.php b/app/application/views/auth/edit_group.php
deleted file mode 100755
index 080dad7..0000000
--- a/app/application/views/auth/edit_group.php
+++ /dev/null
@@ -1,20 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/app/application/views/auth/edit_user.php b/app/application/views/auth/edit_user.php
deleted file mode 100755
index 46e4190..0000000
--- a/app/application/views/auth/edit_user.php
+++ /dev/null
@@ -1,66 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- ion_auth->is_admin()): ?>
-
-
-
-
- id) {
- $checked= ' checked="checked"';
- break;
- }
- }
- ?>
- >
-
-
-
-
-
-
- id);?>
-
-
-
-
-
diff --git a/app/application/views/auth/email/activate.tpl.php b/app/application/views/auth/email/activate.tpl.php
deleted file mode 100755
index e2436cf..0000000
--- a/app/application/views/auth/email/activate.tpl.php
+++ /dev/null
@@ -1,6 +0,0 @@
-
-
-
-
-
-
\ No newline at end of file
diff --git a/app/application/views/auth/email/forgot_password.tpl.php b/app/application/views/auth/email/forgot_password.tpl.php
deleted file mode 100755
index 2cc5b02..0000000
--- a/app/application/views/auth/email/forgot_password.tpl.php
+++ /dev/null
@@ -1,6 +0,0 @@
-
-
-
-
-
-
\ No newline at end of file
diff --git a/app/application/views/auth/email/new_password.tpl.php b/app/application/views/auth/email/new_password.tpl.php
deleted file mode 100755
index f223986..0000000
--- a/app/application/views/auth/email/new_password.tpl.php
+++ /dev/null
@@ -1,7 +0,0 @@
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/app/application/views/auth/forgot_password.php b/app/application/views/auth/forgot_password.php
deleted file mode 100755
index 1eb2bde..0000000
--- a/app/application/views/auth/forgot_password.php
+++ /dev/null
@@ -1,15 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/app/application/views/auth/index.php b/app/application/views/auth/index.php
deleted file mode 100755
index d957644..0000000
--- a/app/application/views/auth/index.php
+++ /dev/null
@@ -1,31 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- first_name,ENT_QUOTES,'UTF-8');?>
- last_name,ENT_QUOTES,'UTF-8');?>
- email,ENT_QUOTES,'UTF-8');?>
-
- groups as $group):?>
- id, htmlspecialchars($group->name,ENT_QUOTES,'UTF-8')) ;?>
-
-
- active) ? anchor("auth/deactivate/".$user->id, lang('index_active_link')) : anchor("auth/activate/". $user->id, lang('index_inactive_link'));?>
- id, 'Edit') ;?>
-
-
-
-
- |
\ No newline at end of file
diff --git a/app/application/views/auth/login.php b/app/application/views/auth/login.php
deleted file mode 100755
index de1d05a..0000000
--- a/app/application/views/auth/login.php
+++ /dev/null
@@ -1,49 +0,0 @@
-
-
-
-
-
-
-
-
-
-
- FruxePi
-
-
-
-
-
-
-
-
-
-
-
-
- 'form-signin'); ?>
-
-
-
-
- Please Sign-in
-
- Email address
-
-
- Password
-
-
-
-
- Remember me
-
-
-
- Login
-
- © frx-pi-v0.3-BETA
-
-
-
-
\ No newline at end of file
diff --git a/app/application/views/auth/reset.php b/app/application/views/auth/reset.php
deleted file mode 100755
index 39197c9..0000000
--- a/app/application/views/auth/reset.php
+++ /dev/null
@@ -1,34 +0,0 @@
-
-
-
-
-
-
-
-
-
- FruxePi
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/app/application/views/auth/reset_password.php b/app/application/views/auth/reset_password.php
deleted file mode 100755
index 7101704..0000000
--- a/app/application/views/auth/reset_password.php
+++ /dev/null
@@ -1,22 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/app/application/views/core/footer.php b/app/application/views/core/footer.php
deleted file mode 100755
index 161084a..0000000
--- a/app/application/views/core/footer.php
+++ /dev/null
@@ -1,6 +0,0 @@
-
-
-
-
-
-
diff --git a/app/application/views/core/header.php b/app/application/views/core/header.php
deleted file mode 100755
index 87f3bf8..0000000
--- a/app/application/views/core/header.php
+++ /dev/null
@@ -1,35 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- | frx-dev-v0.3
-
- frx-dev-v0.3
-
-
-
-
\ No newline at end of file
diff --git a/app/application/views/core/nav.php b/app/application/views/core/nav.php
deleted file mode 100755
index 639dfab..0000000
--- a/app/application/views/core/nav.php
+++ /dev/null
@@ -1,52 +0,0 @@
-
-
\ No newline at end of file
diff --git a/app/application/views/core/page_footer.php b/app/application/views/core/page_footer.php
deleted file mode 100755
index d690c67..0000000
--- a/app/application/views/core/page_footer.php
+++ /dev/null
@@ -1,6 +0,0 @@
-
-
\ No newline at end of file
diff --git a/app/application/views/core/page_header.php b/app/application/views/core/page_header.php
deleted file mode 100755
index 67b3add..0000000
--- a/app/application/views/core/page_header.php
+++ /dev/null
@@ -1,8 +0,0 @@
-
-
\ No newline at end of file
diff --git a/app/application/views/crop/create_crop.php b/app/application/views/crop/create_crop.php
deleted file mode 100755
index a11c7fc..0000000
--- a/app/application/views/crop/create_crop.php
+++ /dev/null
@@ -1,111 +0,0 @@
-
-load->view('core/header'); ?>
-
-
-
-
-
- load->view('core/nav'); ?>
-
-
-
-
- load->view('core/page_header'); ?>
-
-
-
-
-
-
-
- load->view('core/footer'); ?>
-
-
- load->view('crop/crop_scripts'); ?>
-
-
-
-
-
\ No newline at end of file
diff --git a/app/application/views/crop/crop_scripts.php b/app/application/views/crop/crop_scripts.php
deleted file mode 100755
index 80534f2..0000000
--- a/app/application/views/crop/crop_scripts.php
+++ /dev/null
@@ -1,14 +0,0 @@
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/app/application/views/crop/edit_crop.php b/app/application/views/crop/edit_crop.php
deleted file mode 100755
index 6b5015b..0000000
--- a/app/application/views/crop/edit_crop.php
+++ /dev/null
@@ -1,256 +0,0 @@
-
-load->view('core/header'); ?>
-
-
-
-
-
- load->view('core/nav'); ?>
-
-
-
-
- load->view('core/page_header'); ?>
-
-
-
-
-
-
-
-
-
-
- 'crop_form'); ?>
-
-
-
-
-
-
-
-
-
-
Crop Details
-
-
-
-
-
-
-
-
-
-
-
-
-
Crop Schedule
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
Thumbnail
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- load->view('core/footer'); ?>
-
-
-
-
-
-
-
-
-
-
-
-
-