-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.php
87 lines (71 loc) · 2.15 KB
/
index.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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
<?php
require 'Slim/Slim.php';
require 'src/Rating.php';
require 'src/Misc.php';
\Slim\Slim::registerAutoloader();
use RateMyLandlord\Rating;
$app = new \Slim\Slim(array(
'debug' => true
));
$app->hook('slim.before', function () use ($app) {
$posIndex = strpos( $_SERVER['PHP_SELF'], '/index.php');
$baseUrl = substr( $_SERVER['PHP_SELF'], 0, $posIndex);
$app->view()->appendData(array('baseUrl' => $baseUrl . '/' ));
});
$app->get('/', function () use($app) {
$app->render('index.php');
});
$app->get('/about-us', function () use($app) {
$app->render('about-us.php');
});
$app->get('/essential-info', function () use($app) {
$app->render('essential-info.php');
});
$app->get('/rate-my-landlord', function () use($app) {
$app->render('rate-my-landlord.php');
});
$app->get('/contact-us', function () use($app) {
$app->render('contact-us.php');
});
$app->get('/view-ratings', function () use($app) {
$ratings = Rating::getRatings();
$app->view()->setData(array('ratings' => $ratings));
$app->render('view-ratings.php');
});
$app->get('/rating/:id', function ($id) use ($app) {
$ratings = Rating::getRatingByID($id);
if (empty($ratings)) {
$res = new \Slim\Http\Response();
$res->setStatus(400);
$res->write('You made a bad request');
$res->headers->set('Content-Type', 'text/plain');
/**
* Finalize
* @return [
* 200,
* ['Content-type' => 'text/plain'],
* 'You made a bad request'
* ]
*/
$res->isNotFound();
exit;
} else {
$app->view()->setData(array('ratings' => $ratings));
$app->render('rating.php');
}
});
$app->get('/search/:postcode', function ($postcode) use ($app) {
$results = Rating::getSearchResults($postcode);
$app->view()->setData(array('ratings' => $results));
$app->render('search-results.php');
});
//old urls still on social media
$app->get('/civichack/view-ratings', function () use($app) {
$ratings = Rating::getRatings();
$app->view()->setData(array('ratings' => $ratings));
$app->render('view-ratings.php');
});
$app->get('/civichack/rate-my-landlord', function () use($app) {
$app->render('rate-my-landlord.php');
});
$app->run();