-
Notifications
You must be signed in to change notification settings - Fork 0
/
unit.php
46 lines (34 loc) · 1.31 KB
/
unit.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
<?php
require 'header.php';
if(!$user->isLoggedIn()) {
Redirect::to('index.php');
}
if(Input::exists('get')) {
$unitID = Input::get('id');
$short = Input::get('slug');
$unit = new Unit($short, $unitID, $user);
if(!empty($_GET['unlock'])) {
if($_GET['unlock'] == true) {
$unitsTable = "" . $short . "_units";
$unitInfo = $unit->getDB()->get($unitsTable, array('id', '=', $unitID));
$unitPrice = $unitInfo->first()->price;
if($user->getCoins() >= $unitPrice) {
$unit->unlock();
Session::flash('module', 'Unit '. $unit->getUnitTitle() .' unlocked!');
Redirect::to('module.php?slug='. $short);
} else {
Session::flash('module', 'Not enough coins!');
Redirect::to('module.php?slug='. $short);
}
} else {
Session::flash('module', 'No such a quest!');
Redirect::to('module.php?slug='. $short);
}
} else {
if(Session::exists('unit')) {
echo Session::flash('unit');
}
$unit->render();
}
}
include 'footer.php';