-
Notifications
You must be signed in to change notification settings - Fork 0
/
makePublic.php
46 lines (41 loc) · 1.29 KB
/
makePublic.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_once 'core/init.php';
$user = new User();
if($user->hasPermission('banned')){
exit("you are banned");
}
$data = $user->data();
if(!$user->isLoggedIn()){
Redirect::to('index.php');
exit("you are not logged in");
}
if(!$option = Input::get('option')){
$option = 0;
}
if(!$postId = Input::get('post')){
Session::flash('userMessage', 'noting to change!');
Redirect::to('index.php');
exit("Nothing to change!");
}elseif (Token::check(Input::get('token'))) {
$posts = DB::getInstance()->get('posts', array('id', '=', $postId));
$results = $posts->results();
foreach ($results as $post) {
if($data->id !== $post->userID){
Session::flash('userMessage', 'You cannot change that post!');
Redirect::to('index.php');
exit("Sorry you have no permission to delete that file");
}
}
if(!DB::getInstance()->update('posts',$postId,array('public' => $option))){
Session::flash('userMessage', 'Sorry we could not change that');
Redirect::to('index.php');
exit("Sorry we could not change that post!");
}
}else{
Session::flash('userMessage', 'Sorry token invaild');
Redirect::to('index.php');
exit("Sorry token invaild!");
}
Session::flash('userMessage', $data->username.' we where able to change that post!');
Redirect::to('index.php');
exit("we where able to change that post!");