-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.php
More file actions
225 lines (194 loc) · 8.2 KB
/
index.php
File metadata and controls
225 lines (194 loc) · 8.2 KB
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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
<?php
/********************************************************
Dumpz v1.5
Release date: Aug 2014
Copyright (C) nullfix.com
*********************************************************/
session_start();
// basic config start
include('config.php');
// Default meta Tags for any other page exept dump page
$meta_desc = "Post Snippets and code and help others complete projects faster. Long-term memory for coders. Share and store code snippets.";
$meta_title = $_CONFIG['site_name']." | Post your code bits and snippets and get infamous!";
$meta_keywords = "snipets, snippets, snipt, code, highlight, text, functions, class, help, developers, coders";
//var_dump(getenv('HTTP_MOD_REWRITE')); //we can check if apatche mod_rewrite is on!
// php main code in head.
$page_to_load = filter_input(INPUT_GET, 'v', FILTER_SANITIZE_STRING);
switch($page_to_load) {
case 'about':
//Logic to view or HTML for view
$page_final = "views/about.php";
break;
case 'account':
//Logic to add or HTML for add
$page_final = ($_SESSION['user_logged'] === 1) ? "views/account.php" : "views/login.php";
break;
case 'users':
//Logic to add or HTML for add
$page_final = "views/users.php";
break;
case 'login':
//Logic to add or HTML for add
$page_final = "views/login.php";
break;
case 'signup':
//Logic to add or HTML for add
$page_final = "views/register.php";
break;
case 'forgotpw':
//Logic to add or HTML for add
$page_final = "views/lostpw.php";
break;
case 'logout':
//Logic to add or HTML for add
unset($_SESSION['username']);
unset($_SESSION['user_logged']);
header('Location: '.$_CONFIG['site_url'].'/index.php');
break;
default:
$page_final = "views/home.php";
}
// if user is logged in, we dont want to show login page again so we redirect them to index page.!
if ($_SESSION['user_logged'] === 1 && ($page_final == "views/login.php" || $page_final == "views/register.php")) {
header('Location: '.$_CONFIG['site_url'].'/index.php');
}
// check if we need to open the view page instead!
if(!empty($_GET['i']) && isset($_GET['i'])) {
$_GET['i'] = filter_input(INPUT_GET, 'i', FILTER_SANITIZE_STRING);
$alldump = mycustomdb()->prepare("SELECT * FROM dump WHERE key = ? LIMIT 1");
$alldump->execute(array($_GET['i']));
$alldump = $alldump->fetch();
$page_final = "views/view.php";
// find out user who's dump is this! for meta tags and seo.
if ($alldump['user_id'] == 0) {
$seo_user = 'Anonymous';
} else {
$seo_user = mycustomdb()->prepare("SELECT nick FROM users WHERE id = ? LIMIT 1");
$seo_user->execute(array($alldump['user_id']));
$seo_user = $seo_user->fetch();
$seo_user = $seo_user['nick'];
}
// seo meta tag optimizations
$meta_desc = "Source Code in ".ucfirst($alldump['syntax'])." syntax from ".$seo_user.". ".$alldump['title'];
$meta_title = ($alldump['title'] != '') ? $alldump['title']." | ".$_CONFIG['site_name'] : $_CONFIG['site_name'];
$meta_keywords = extract_keywords($alldump['code']); // todo extract keywords from code function.
if($alldump === false){
$sreply = "This Dump is not here anymore or deleted!";
}
}
?>
<!DOCTYPE html>
<html>
<head>
<!-- Meta tags -->
<title><?=$meta_title?></title>
<meta name="description" content="<?=$meta_desc?>" />
<meta name="keywords" content="<?=$meta_keywords?>" />
<meta charset="utf-8" />
<link rel="shortcut icon" href="<?=$_CONFIG['site_url']?>/favicon.ico" />
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="robots" content="index,follow,archive">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<!-- SEO -->
<!-- Global site tag (gtag.js) - Google Analytics -->
<script async src="//www.googletagmanager.com/gtag/js?id=UA-4771730-16"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'UA-4771730-16');
</script>
<!-- CSS -->
<!-- DO NOT LOAD bootstrap via CDN - it breaks IE respond.js library -->
<!--<link href="static/bootstrap3/css/bootstrap.min.css?1" rel="stylesheet">-->
<link href="<?=$_CONFIG['site_url']?>/static/css/cosmo/bootstrap.min.css" rel="stylesheet">
<link rel="stylesheet" type="text/css" href="<?=$_CONFIG['site_url']?>/static/css/custom.css?1">
<!-- HTML5 Shim and Respond.js IE8 support of HTML5 elements and media queries -->
<!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
<!--[if lt IE 9]>
<script src="//oss.maxcdn.com/libs/html5shiv/3.7.0/html5shiv.js"></script>
<script src="//oss.maxcdn.com/libs/respond.js/1.4.2/respond.min.js"></script>
<![endif]-->
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
<!-- Extra head stuff -->
</head>
<body>
<nav class="navbar navbar-default navbar-fixed-top" role="navigation">
<div class="container">
<div class="navbar-header">
<div class="text-center">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#foo">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" href="<?=$_CONFIG['site_url']?>/index.php"><?=$_CONFIG['site_name']?></a>
<ul class="nav navbar-nav pull-left">
<li><a class="arrow" href="<?=$_CONFIG['site_url']?>/index.php" style="color: #3fb618;">Upload</a></li>
</ul>
</div>
</div>
<div class="collapse navbar-collapse" id="foo">
<ul class="nav navbar-nav pull-left">
<li><a class="arrow" href="<?=$_CONFIG['site_url']?>/?v=users">Users</a></li>
<li><a class="arrow" href="<?=$_CONFIG['site_url']?>/?v=about">About</a></li>
</ul>
<ul class="nav navbar-nav pull-right">
<?php if($_SESSION[user_logged] === 1) { ?>
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown">
<?=$_SESSION['username']?>
<b class="caret"></b>
</a>
<ul class="dropdown-menu">
<li><a href="<?=$_CONFIG['site_url']?>/?v=logout">Log Out</a></li>
<li><a class="mydumps arrow" href="<?=$_CONFIG['site_url']?>/?v=users&user=<?=$_SESSION['username']?>">My Snippets</a></li>
</ul>
</li>
<?php } else { ?>
<li><a href="<?=$_CONFIG['site_url']?>/?v=login">Log in</a></li>
<li><a href="<?=$_CONFIG['site_url']?>/?v=signup">Sign Up</a></li>
<?php } ?>
</ul>
</div>
</div><!-- /.container-fluid -->
</nav>
<div class="container">
<?php
if (file_exists($page_final)) {
// Pages and Views Setup
require($page_final);
} else {
require('views/home.php');
}
?>
</div> <!-- /container -->
<hr style="margin-top: 40px;"/>
<div class="container" style="margin-bottom: 20px;">
<div class="row">
<div class="col-md-3">
<div style="font-size: 12px" class="text-muted">
Contact: <a class="text-muted" style="text-decoration: underline" href="mailto:<?=$_CONFIG['admin_mail']?>"><?=$_CONFIG['admin_mail']?></a>
</div>
</div>
<div class="col-md-6">
</div>
<div class="col-md-3">
<div style="font-size: 12px" class="pull-right text-muted">
<?=$_CONFIG['script_copyrights']?> ¤ V <?=$_CONFIG['script_version']?>
<br/>
</div>
<div style="height: 1px; widht: 1px; overflow: hidden">
</div>
</div>
</div>
</div>
<script src="//netdna.bootstrapcdn.com/bootstrap/3.1.1/js/bootstrap.min.js"></script>
<script type="text/javascript" src="<?=$_CONFIG['site_url']?>/static/js/util.js?c=1"></script>
<?php // debug line.
//var_dump($alldump);
//var_dump($_GET);
?>
</body>
</html>