Skip to content

Commit 7243a4c

Browse files
authored
Reverted index.php
Accidentally commited an older index.php which triggered errors
1 parent bda6858 commit 7243a4c

File tree

1 file changed

+127
-126
lines changed

1 file changed

+127
-126
lines changed

index.php

Lines changed: 127 additions & 126 deletions
Original file line numberDiff line numberDiff line change
@@ -1,185 +1,186 @@
1-
<?php error_reporting(0); /* E_ALL - for Debugging*/
1+
<?php error_reporting(E_ALL);
22
// Degugging?
33
$sttime = microtime(true);
44
// Security
5-
if( !defined( 'in_phpvibe' ) )
6-
define( 'in_phpvibe', true);
5+
if (!defined('in_phpvibe'))
6+
define('in_phpvibe', true);
77
// Root
8-
if( !defined( 'ABSPATH' ) )
9-
define( 'ABSPATH', str_replace( '\\', '/', dirname( __FILE__ ) ) );
8+
if (!defined('ABSPATH'))
9+
define('ABSPATH', str_replace('\\', '/', dirname(__FILE__)));
1010
//Check if installed
11-
if(!is_readable('vibe_config.php') || is_readable('hold')){
12-
echo '<div style="padding:10% 20%; display:block; color:#fff; background:#ff604f"><h1>Hold on!</h1>';
13-
echo '<h3> The configuration file needs editing OR/AND the "hold" file exists on your server! </h3><br />';
14-
echo '<a href="setup/index.php"><h2>RUN PHPVibe\'s SETUP</h2></a></strong>';
15-
echo '</div>';
16-
die();
11+
if (!is_readable('vibe_config.php') || is_readable('hold')) {
12+
echo '<div style="padding:10% 20%; display:block; color:#fff; background:#ff604f"><h1>Hold on!</h1>';
13+
echo '<h3> The configuration file needs editing OR/AND the "hold" file exists on your server! </h3><br />';
14+
echo '<a href="setup/index.php"><h2>RUN PHPVibe\'s SETUP</h2></a></strong>';
15+
echo '</div>';
16+
die();
1717
}
1818
//Include configuration
19-
require_once( ABSPATH.'/vibe_config.php' );
19+
require_once(ABSPATH . '/vibe_config.php');
2020
//Check session start
21-
if (!isset($_SESSION)) { session_start(); }
21+
if (!isset($_SESSION)) {
22+
session_start();
23+
}
2224
/*** Start static serving from cache ***/
2325
/* Kill static cache for users */
24-
if(isset($_SESSION['user_id']) || isset($_COOKIE[md5(SITE_URL)]) || isset($_GET['action'])) {
25-
$killcache = true;
26-
}
26+
if (isset($_SESSION['user_id']) || isset($_COOKIE[md5(SITE_URL)]) || isset($_GET['action'])) {
27+
$killcache = true;
28+
}
2729
/* Serve static pages for visitors */
28-
if (isset($killcache) && !$killcache) {
29-
$a = strip_tags($_SERVER['REQUEST_URI']);
30-
if(($a === '/') || ($a === '/index.php')) { $a = '/index.php'; }
31-
/* Exclude specific pages */
32-
if((strpos($a,'register') == false) && (strpos($a,'dashboard') == false) && (strpos($a,'login') == false) && (strpos($a,'moderator') == false) && (strpos($a,'setup') == false) && !isset($_GET['clang'])) {
33-
require_once( ABSPATH.'/lib/fullcache.php' );
34-
/* Create cache token for this page */
35-
$token = (isset($_SESSION['phpvibe-language'])) ? $a.$_SESSION['phpvibe-language'] : $a;
36-
/* Run static caching and serving */
37-
FullCache::Encode($token);
38-
FullCache::Live();
39-
}
40-
}
30+
if (isset($killcache) && !$killcache) {
31+
$a = strip_tags($_SERVER['REQUEST_URI']);
32+
if (($a === '/') || ($a === '/index.php')) {
33+
$a = '/index.php';
34+
}
35+
/* Exclude specific pages */
36+
if ((strpos($a, 'register') == false) && (strpos($a, 'dashboard') == false) && (strpos($a, 'login') == false) && (strpos($a, 'moderator') == false) && (strpos($a, 'setup') == false) && !isset($_GET['clang'])) {
37+
require_once(ABSPATH . '/lib/fullcache.php');
38+
/* Create cache token for this page */
39+
$token = (isset($_SESSION['phpvibe-language'])) ? $a . $_SESSION['phpvibe-language'] : $a;
40+
/* Run static caching and serving */
41+
FullCache::Encode($token);
42+
FullCache::Live();
43+
}
44+
}
4145
/** End static serving from cache **/
4246
//Vital file include
4347
require_once("load.php");
4448
ob_start();
4549
// Login, maybe?
46-
if (!is_user()) {
50+
if (!is_user()) {
4751
//action = login, logout ; type = facebook, google
48-
if (!empty($_GET['action']) && $_GET['action'] == "login") {
49-
switch ($_GET['type']) {
50-
case 'facebook':
51-
if(get_option('allowfb') == 1 ) {
52-
require_once( TRDS.'/facebook/autoload.php' );
53-
$fb = new Facebook\Facebook([
54-
'app_id' => Fb_Key,
55-
'app_secret' => Fb_Secret,
56-
'default_graph_version' => 'v2.8',
57-
]);
58-
$helper = $fb->getRedirectLoginHelper();
59-
$permissions = explode (",", $conf_facebook['permissions']); // Optional permissions
60-
$facebookLoginUrl = $helper->getLoginUrl($conf_facebook['redirect_uri'], $permissions);
61-
//Send user to login
62-
redirect($facebookLoginUrl);
63-
}
64-
break;
65-
case 'google':
66-
if(get_option('allowg') == 1 ) {
67-
//Initialize google login
52+
if (!empty($_GET['action']) && $_GET['action'] == "login") {
53+
switch ($_GET['type']) {
54+
case 'facebook':
55+
if (get_option('allowfb') == 1) {
56+
require_once(TRDS . '/facebook/autoload.php');
57+
$fb = new Facebook\Facebook([
58+
'app_id' => Fb_Key,
59+
'app_secret' => Fb_Secret,
60+
'default_graph_version' => 'v2.8',
61+
]);
62+
$helper = $fb->getRedirectLoginHelper();
63+
$permissions = explode(",", $conf_facebook['permissions']); // Optional permissions
64+
$facebookLoginUrl = $helper->getLoginUrl($conf_facebook['redirect_uri'], $permissions);
65+
//Send user to login
66+
redirect($facebookLoginUrl);
67+
}
68+
break;
69+
case 'google':
70+
if (get_option('allowg') == 1) {
71+
//Initialize google login
6872

69-
require_once(TRDS.'/google/Google/Client.php');
73+
require_once(TRDS . '/google/Google/Client.php');
7074

71-
$client = new Google_Client();
72-
$client->setClientId(trim(get_option('GClientID')));
73-
$client->setClientSecret(trim(get_option('GClientSecret')));
74-
$client->setRedirectUri($conf_google['return_url']);
75-
$client->setScopes(array('https://www.googleapis.com/auth/userinfo.email','https://www.googleapis.com/auth/userinfo.profile'));
76-
$authUrl = $client->createAuthUrl();
75+
$client = new Google_Client();
76+
$client->setClientId(trim(get_option('GClientID')));
77+
$client->setClientSecret(trim(get_option('GClientSecret')));
78+
$client->setRedirectUri($conf_google['return_url']);
79+
$client->setScopes(array('https://www.googleapis.com/auth/userinfo.email', 'https://www.googleapis.com/auth/userinfo.profile'));
80+
$authUrl = $client->createAuthUrl();
7781

78-
if (!empty($authUrl)) {
79-
redirect($authUrl);
80-
}
81-
}
82-
break;
82+
if (!empty($authUrl)) {
83+
redirect($authUrl);
84+
}
85+
}
86+
break;
8387

84-
default:
85-
//If any login system found, warn user
86-
echo _lang('Invalid Login system');
87-
}
88-
}
89-
} else {
90-
if (!empty($_GET['action']) && $_GET['action'] == "logout") {
91-
//If action is logout, kill sessions
92-
user::clearSessionData();
93-
//var_dump($_COOKIE);exit;
94-
redirect(site_url()."index.php");
95-
}
96-
}
88+
default:
89+
//If any login system found, warn user
90+
echo _lang('Invalid Login system');
91+
}
92+
}
93+
} else {
94+
if (!empty($_GET['action']) && $_GET['action'] == "logout") {
95+
//If action is logout, kill sessions
96+
user::clearSessionData();
97+
//var_dump($_COOKIE);exit;
98+
redirect(site_url() . "index.php");
99+
}
100+
}
97101

98102
// Let's start the site
99103
//$page = com();
100-
$id_pos = null;
101-
$router = new Router();
104+
$id_pos = null;
105+
$router = new Router();
102106
/* Uncomment and edit bellow if installed in a folder */
103107
// $router->setBasePath('/video-folder'));
104108
/* End folder check */
105109
do_action('VibePermalinks');
106110
$router->map('/', 'home', array('methods' => 'GET', 'filters' => array('id' => '(\d+)')));
107111
$router->map('/payment/:section', 'payment', array('methods' => 'GET,PUT,POST', 'filters' => array('section' => '(.*)')));
108-
$router->map(get_option('profile-seo-url','/profile/:name/:id/'), 'profile', array('methods' => 'GET,PUT,POST', _makeUrlArgs(get_option('profile-seo-url','/profile/:name/:id/'))));
109-
$router->map('/'.premiumhub.'/:section', 'premiumhub', array('methods' => 'GET', 'filters' => array('section' => '(.*)')));
110-
$router->map('/'.videos.'/:section', 'videolist', array('methods' => 'GET', 'filters' => array('section' => '(.*)')));
112+
$router->map(get_option('profile-seo-url', '/profile/:name/:id/'), 'profile', array('methods' => 'GET,PUT,POST', _makeUrlArgs(get_option('profile-seo-url', '/profile/:name/:id/'))));
113+
$router->map('/' . premiumhub . '/:section', 'premiumhub', array('methods' => 'GET', 'filters' => array('section' => '(.*)')));
114+
$router->map('/' . videos . '/:section', 'videolist', array('methods' => 'GET', 'filters' => array('section' => '(.*)')));
111115
$router->map('/images/:section', 'imageslist', array('methods' => 'GET', 'filters' => array('section' => '(.*)')));
112116
$router->map('/music/:section', 'musiclist', array('methods' => 'GET', 'filters' => array('section' => '(.*)')));
113117
$router->map('/music/:section', 'musiclist', array('methods' => 'GET', 'filters' => array('section' => '(.*)')));
114-
$router->map(get_option('channel-seo-url','/category/:name/:id/'), 'category', array('methods' => 'GET', 'filters' => _makeUrlArgs(get_option('channel-seo-url','/category/:name/:id/'))));
115-
$router->map(get_option('music-channel-seo-url','/musicfilter/:name/:id/'), 'categorymusic', array('methods' => 'GET', 'filters' => _makeUrlArgs(get_option('channel-seo-url','/category/:name/:id/'))));
116-
$router->map(get_option('image-channel-seo-url','/imagefilter/:name/:id/'), 'categoryimage', array('methods' => 'GET', 'filters' => _makeUrlArgs(get_option('channel-seo-url','/category/:name/:id/'))));
117-
$router->map('/playlist/:name/:id/:section', 'playlist', array('methods' => 'GET,POST', 'filters' => array('id' => '(\d+)','section' => '(.*)')));
118-
$router->map(get_option('page-seo-url','/read/:name/:id'), 'page', array('methods' => 'GET', 'filters' => _makeUrlArgs(get_option('page-seo-url','/read/:name/:id'))));
119-
$router->map('/'.me.':section', 'manager', array('methods' => 'GET,PUT,POST', 'filters' => array('section' => '(.*)')));
120-
$router->map('/'.blog, 'blog', array('methods' => 'GET'));
121-
$router->map('/'.members.'/:section', 'channels', array('methods' => 'GET', 'filters' => array('section' => '(.*)')));
122-
$router->map('/'.playlists.'/:section', 'playlists', array('methods' => 'GET', 'filters' => array('section' => '(.*)')));
123-
$router->map('/'.albums.'/:section', 'albums', array('methods' => 'GET', 'filters' => array('section' => '(.*)')));
124-
$router->map('/'.album.'/:section', 'album', array('methods' => 'GET', 'filters' => array('section' => '(.*)')));
125-
$router->map('/'.blogcat.'/:name/:id/:section', 'blogcat', array('methods' => 'GET', 'filters' => array('section' => '(.*)')));
126-
$router->map(get_option('article-seo-url','/read/:name/:id'), 'post', array('methods' => 'GET', 'filters' => _makeUrlArgs(get_option('article-seo-url','/read/:name/:id'))));
127-
$router->map('/forward/:section', 'forward', array('methods' => 'GET', 'filters' => array('section' => '(.*)')));
128-
$router->map('/msg/:section', 'msg', array('methods' => 'GET', 'filters' => array('section' => '(.*)')));
129-
$router->map('/conversation/:id', 'conversation', array('methods' => 'GET', 'filters' => array('id' => '(\d+)')));
130-
$router->map('/login/:section', 'login', array('methods' => 'GET,PUT,POST', 'filters' => array('section' => '(.*)')));
118+
$router->map(get_option('channel-seo-url', '/category/:name/:id/'), 'category', array('methods' => 'GET', 'filters' => _makeUrlArgs(get_option('channel-seo-url', '/category/:name/:id/'))));
119+
$router->map(get_option('music-channel-seo-url', '/musicfilter/:name/:id/'), 'categorymusic', array('methods' => 'GET', 'filters' => _makeUrlArgs(get_option('channel-seo-url', '/category/:name/:id/'))));
120+
$router->map(get_option('image-channel-seo-url', '/imagefilter/:name/:id/'), 'categoryimage', array('methods' => 'GET', 'filters' => _makeUrlArgs(get_option('channel-seo-url', '/category/:name/:id/'))));
121+
$router->map('/playlist/:name/:id/:section', 'playlist', array('methods' => 'GET,POST', 'filters' => array('id' => '(\d+)', 'section' => '(.*)')));
122+
$router->map(get_option('page-seo-url', '/read/:name/:id'), 'page', array('methods' => 'GET', 'filters' => _makeUrlArgs(get_option('page-seo-url', '/read/:name/:id'))));
123+
$router->map('/' . me . ':section', 'manager', array('methods' => 'GET,PUT,POST', 'filters' => array('section' => '(.*)')));
124+
$router->map('/' . blog, 'blog', array('methods' => 'GET'));
125+
$router->map('/' . members . '/:section', 'channels', array('methods' => 'GET', 'filters' => array('section' => '(.*)')));
126+
$router->map('/' . playlists . '/:section', 'playlists', array('methods' => 'GET', 'filters' => array('section' => '(.*)')));
127+
$router->map('/' . albums . '/:section', 'albums', array('methods' => 'GET', 'filters' => array('section' => '(.*)')));
128+
$router->map('/' . album . '/:section', 'album', array('methods' => 'GET', 'filters' => array('section' => '(.*)')));
129+
$router->map('/' . blogcat . '/:name/:id/:section', 'blogcat', array('methods' => 'GET', 'filters' => array('section' => '(.*)')));
130+
$router->map(get_option('article-seo-url', '/read/:name/:id'), 'post', array('methods' => 'GET', 'filters' => _makeUrlArgs(get_option('article-seo-url', '/read/:name/:id'))));
131+
$router->map('/forward/:section', 'forward', array('methods' => 'GET', 'filters' => array('section' => '(.*)')));
132+
$router->map('/msg/:section', 'msg', array('methods' => 'GET', 'filters' => array('section' => '(.*)')));
133+
$router->map('/conversation/:id', 'conversation', array('methods' => 'GET', 'filters' => array('id' => '(\d+)')));
134+
$router->map('/login/:section', 'login', array('methods' => 'GET,PUT,POST', 'filters' => array('section' => '(.*)')));
131135
$router->map('/register/:section', 'register', array('methods' => 'GET,PUT,POST', 'filters' => array('section' => '(.*)')));
132-
$router->map('/'.buzz.'/:section', 'buzz', array('methods' => 'GET', 'filters' => array('section' => '(.*)')));
133-
$router->map('/'.buzz.'/:section', 'buzz', array('methods' => 'GET', 'filters' => array('section' => '(.*)')));
134-
$router->map('/'.thetags.'/:section', 'tag', array('methods' => 'GET', 'filters' => array('section' => '(.*)')));
135-
$router->map('/'.show.'/:section', 'search', array('methods' => 'GET', 'filters' => array('section' => '(.*)')));
136-
$router->map('/'.imgsearch.'/:section', 'searchimages', array('methods' => 'GET', 'filters' => array('section' => '(.*)')));
137-
$router->map('/'.pplsearch.'/:section', 'searchppl', array('methods' => 'GET', 'filters' => array('section' => '(.*)')));
138-
$router->map('/'.playlistsearch.'/:section', 'searchpaylist', array('methods' => 'GET', 'filters' => array('section' => '(.*)')));
136+
$router->map('/' . buzz . '/:section', 'buzz', array('methods' => 'GET', 'filters' => array('section' => '(.*)')));
137+
$router->map('/' . buzz . '/:section', 'buzz', array('methods' => 'GET', 'filters' => array('section' => '(.*)')));
138+
$router->map('/' . thetags . '/:section', 'tag', array('methods' => 'GET', 'filters' => array('section' => '(.*)')));
139+
$router->map('/' . show . '/:section', 'search', array('methods' => 'GET', 'filters' => array('section' => '(.*)')));
140+
$router->map('/' . imgsearch . '/:section', 'searchimages', array('methods' => 'GET', 'filters' => array('section' => '(.*)')));
141+
$router->map('/' . pplsearch . '/:section', 'searchppl', array('methods' => 'GET', 'filters' => array('section' => '(.*)')));
142+
$router->map('/' . playlistsearch . '/:section', 'searchpaylist', array('methods' => 'GET', 'filters' => array('section' => '(.*)')));
139143
$router->map('/api/:section', 'api', array('methods' => 'GET,PUT,POST', 'filters' => array('section' => '(.*)')));
140144
$router->map('/embed/:section', 'embed', array('methods' => 'GET', 'filters' => array('section' => '(.*)')));
141145
$router->map('/feed/:section', 'feed', array('methods' => 'GET', 'filters' => array('section' => '(.*)')));
142146
$router->map('/share/:section', 'share', array('methods' => 'GET,PUT,POST', 'filters' => array('section' => '(.*)')));
143-
$router->map('/'.upimage.'/:section', 'addimage', array('methods' => 'GET,PUT,POST', 'filters' => array('section' => '(.*)')));
144-
$router->map('/'.upmusic.'/:section', 'addmusic', array('methods' => 'GET,PUT,POST', 'filters' => array('section' => '(.*)')));
145-
$router->map('/'.add.'/:section', 'addvideo', array('methods' => 'GET,PUT,POST', 'filters' => array('section' => '(.*)')));
147+
$router->map('/' . upimage . '/:section', 'addimage', array('methods' => 'GET,PUT,POST', 'filters' => array('section' => '(.*)')));
148+
$router->map('/' . upmusic . '/:section', 'addmusic', array('methods' => 'GET,PUT,POST', 'filters' => array('section' => '(.*)')));
149+
$router->map('/' . add . '/:section', 'addvideo', array('methods' => 'GET,PUT,POST', 'filters' => array('section' => '(.*)')));
146150
$router->map('/dashboard/:section', 'dashboard', array('methods' => 'GET,PUT,POST', 'filters' => array('section' => '(.*)')));
147151
/* Single video or song */
148-
$router->map(get_option('video-seo-url','/video/:id/:name'), 'video', array('methods' => 'GET', 'filters' => _makeUrlArgs(get_option('video-seo-url','/video/:id/:name'))));
152+
$router->map(get_option('video-seo-url', '/video/:id/:name'), 'video', array('methods' => 'GET', 'filters' => _makeUrlArgs(get_option('video-seo-url', '/video/:id/:name'))));
149153
/* Single image */
150-
$router->map(get_option('image-seo-url','/image/:id/:name'), 'image', array('methods' => 'GET', 'filters' => _makeUrlArgs(get_option('image-seo-url','/image/:id/:name'))));
154+
$router->map(get_option('image-seo-url', '/image/:id/:name'), 'image', array('methods' => 'GET', 'filters' => _makeUrlArgs(get_option('image-seo-url', '/image/:id/:name'))));
151155
//Match
152156
$route = $router->matchCurrentRequest();
153157
//end routing
154158
/* include the theme functions / filters */
155159
//Global tpl
156-
if($route) {
157-
/* Assign page from route */
158-
$page = $route->getTarget();
160+
if ($route) {
161+
/* Assign page from route */
162+
$page = $route->getTarget();
159163
}
160164

161-
include_once(TPL.'/tpl.globals.php');
165+
include_once(TPL . '/tpl.globals.php');
162166
//If offline
163-
if(!is_admin() && (get_option('site-offline', 0) == 1 )) {
164-
layout('offline');
165-
exit();
167+
if (!is_admin() && (get_option('site-offline', 0) == 1)) {
168+
layout('offline');
169+
exit();
166170
}
167171
/* Include public resolver */
168-
if($route) {
169-
include_once(ABSPATH."/views/_".$route->getTarget().".php");
170-
} else {
171-
include_once(ABSPATH."/views/_404.php");
172-
}
172+
if ($route) {
173+
include_once(ABSPATH . "/views/" . $route->getTarget() . ".route.php");
174+
} else {
175+
include_once(ABSPATH . "/views/404.route.php");
176+
}
173177

174178
//end sitewide
175179
ob_end_flush();
176180
//Debugging
177181
/*
178-
if(is_admin()) { */
179-
//echo "<pre class=\"footerdebug\" style='text-align:center'>Time Elapsed: ".(microtime(true) - $sttime)."s</pre>";
180-
/*
181-
}
182-
*/
182+
echo "<pre class=\"footerdebug\" style='text-align:center'>Time Elapsed: " . (microtime(true) - $sttime) . "s</pre>";
183183
184+
*/
184185
//That's all folks!
185186
?>

0 commit comments

Comments
 (0)