-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.php
149 lines (145 loc) · 6.02 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
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
<?php
define('path' , '');
$page = "home";
require path.'inc/init.php';
$user = new User();
$blog = new Blog();
?>
<html>
<head>
<?php include path.'assets/php/css.php';?>
</head>
<body>
<?php include path.'assets/php/nav.php';?>
<div class="container">
<?php
if(Session::exists('complete')){
echo '<div class="alert alert-success">';
echo Session::flash('complete');
echo '</div>';
}
if(Session::exists('error')){
echo '<div class="alert alert-danger">';
echo Session::flash('error');
echo '</div>';
}
if(!$user->exist()){
echo '<div class="alert alert-dismissible alert-info" role="alert"><button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">×</span></button><strong>This site uses cookies!</strong><br>These cookies will enhance your experience on this site.</div>';
echo '<div class="alert alert-dismissible alert-info" role="alert"><button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">×</span></button><strong>Welcome</strong> Guest! Please <a href="pages/login/index.php" class="alert-link">sign in</a> or <a class="alert-link" href="pages/register/index.php">register</a> to use full functions of this site!</div>';
}
?>
<div class="jumbotron">
<h1>Hello!</h1>
<?php if(!$user->isLoggedIn()){echo'<h3>Please come and stay for an while</h3>';}else{echo 'Welcome back '.$user->data()->name;}?>
</div>
<div class="col-md-9">
<?php
$i=0;
foreach ($blog->getPost() as $cat){
if($i<=4){
echo '<div class="panel panel-primary">';
echo '<div class="panel-heading">';
echo '<h3 class="panel-title">'.$cat->title.' ~ '.$cat->name.' @ '.$cat->date.' By: '.$cat->author.'</h3>';
echo '</div>';
echo '<div class="panel-body">';
echo $cat->content;
echo '</div>';
echo '</div>';
}
$i++;
}
?>
</div>
<div class="col-md-3">
<?php
if($user->isLoggedIn() && $user->hasPermission('Admin')){?>
<div class="panel panel-primary">
<div class="panel-heading">
<h3 class="panel-title">AdminCP Quick Panel</h3>
</div>
<div class="panel-body">
<button type="button" class="btn btn-primary btn-sm" data-toggle="modal" data-target="#addPost">
Add Post
</button>
<button type="button" class="btn btn-primary btn-sm" data-toggle="modal" data-target="#addCat">
Add Cat
</button>
<div class="modal fade" id="addPost" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button>
<h4 class="modal-title" id="myModalLabel">Add Post</h4>
</div>
<div class="modal-body">
<form method="post" action="pages/user/admin/addPost.php">
<div class="form-group">
<textarea class="form-control" name="title" rows="1" cols="255" placeholder="title"></textarea>
</div>
<div class="form-group">
<textarea class="form-control" name="content" rows="12" cols="255" placeholder="Content"></textarea>
</div>
<div class="form-group">
<select class="form-control" name="cat" id="cat">
<option value="<?php echo null;?>" id='cat'>Category</option>
<?php
foreach ($blog->getCat() as $cat){
echo "<option name='cat' id='cat' value='{$cat->id}'>{$cat->name}</option>";
}
?>
</select>
</div>
<input type="hidden" name="token" value="<?php echo Token::generate()?>">
<div class="form-group">
<button type="reset" class="btn btn-default">Reset</button>
<button type="button" class="btn btn-danger" data-dismiss="modal">Close</button>
<button type="submit" class="btn btn-primary">Save changes</button>
</div>
</form>
</div>
</div>
</div>
</div>
<div class="modal fade" id="addCat" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button>
<h4 class="modal-title" id="myModalLabel">Add Cat</h4>
</div>
<div class="modal-body">
<form method="post" action="pages/user/admin/addCat.php">
<div class="form-group">
<input name="name" placeholder="Cat Name" class="form-control" type="text">
</div>
<input type="hidden" name="token" value="<?php echo Token::generate()?>">
<div class="form-group">
<button type="reset" class="btn btn-default">Reset</button>
<button type="button" class="btn btn-danger" data-dismiss="modal">Close</button>
<button type="submit" class="btn btn-primary">Save changes</button>
</div>
</form>
</div>
</div>
</div>
</div>
</div>
</div>
<?php
}else if(!$user->isLoggedIn()){
?>
<div class="panel panel-primary">
<div class="panel-heading">
<h3 class="panel-title">Quick Login Panel</h3>
</div>
<div class="panel-body">
<a href="pages/login/index.php" class="btn btn-primary">Login</a>
<a href="pages/register/index.php" class="btn btn-primary">Register</a>
</div>
</div>
<?php }?>
</div>
</div>
<?php include path.'assets/php/js.php';?>
</body>
</html>