-
Notifications
You must be signed in to change notification settings - Fork 3
/
user.php
140 lines (125 loc) · 5.21 KB
/
user.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
<?php
session_start();
//include required functions & config, set meta data (title, stylesheet)
require 'functions/apicalls.php';
$config = require('config.php');
$title = "My profile | SocialDomayn";
$stylesheet = "jodel.css";
include 'functions/header.php';
//checks if user wants to logout
if(isset($_GET['logout'])) {
session_destroy();
//log out the user ^ and redirect to login \/
header('Location: ' . $config->baseUrl . 'login.php');
}
$userid = $_SESSION['userid'];
?>
<!-- main menu-->
<a class="forker" target="_blank" href="https://github.com/jhuesser/bzu-jodel-clone"><img class="forker" style="position: absolute; top: 0; right: 0; border: 0;" src="https://camo.githubusercontent.com/652c5b9acfaddf3a9c326fa6bde407b87f7be0f4/68747470733a2f2f73332e616d617a6f6e6177732e636f6d2f6769746875622f726962626f6e732f666f726b6d655f72696768745f6f72616e67655f6666373630302e706e67" alt="Fork me on GitHub" data-canonical-src="https://s3.amazonaws.com/github/ribbons/forkme_right_orange_ff7600.png"></a>
<div id="top"></div>
<ul class="nav justify-content-center">
<li class="nav-item">
<a class="nav-link" href="jodels.php"><i class="fa fa-chevron-left" aria-hidden="true"></i></a>
</li>
<li class="nav-item">
<a class="nav-link" href="javascript:window.location.reload();"><i class="fa fa-refresh" aria-hidden="true"></i></a>
</li>
<li class="nav-item">
<a class="nav-link" href="user.php"><i class="fa fa-user" aria-hidden="true"></i><?php echo $_SESSION['karma'];?></a>
</li>
<li class="nav-item">
<a class="nav-link" href="?logout=1"><i class="fa fa-sign-out" aria-hidden="true"></i></a>
</li>
</ul>
<div class="test"></div>
<!-- end main menu -->
<?php
if(isset($_SESSION['errorMsg'])) {
?>
<!-- error messages -->
<div class="alert alert-danger" role="alert">
<strong>Holy guacamole!</strong> <?php echo $_SESSION['errorMsg'];?>
</div>
<!-- end error messages -->
<?php
}
?>
<!-- user functions -->
<div class="container">
<h1>
<?php echo "Hello " . $_SESSION['username'];?>
</h1>
<div class="list-group">
<a href="<?php echo $config->baseUrl;?>jodels.php?sort=my" class="list-group-item list-group-item-action">My <?php echo $config->app_vocabulary['posts'];?></a>
<a href="<?php echo $config->baseUrl;?>jodels.php?sort=mycomms" class="list-group-item list-group-item-action">My <?php echo $config->app_vocabulary['comments'];?></a>
<a href="<?php echo $config->baseUrl;?>jodels.php?sort=myvotes" class="list-group-item list-group-item-action">My votes</a>
</div>
<!-- end user functions -->
<?php
//get the account type of the user and set the name of the user role. also get user caps.
switch($_SESSION['acctype']){
case 0:
$accdesc = $config->app_vocabulary['baned'];
break;
case 1:
$accdesc = $config->app_vocabulary['jodler'];
$caps = $config->user_caps->user;
break;
case 2:
$accdesc = $config->app_vocabulary['mod'];
$caps = $config->user_caps->mod;
break;
case 3:
$accdesc = $config->app_vocabulary['admin'];
$caps = $config->user_caps->admin;
break;
case 4:
$accdesc = $config->app_vocabulary['superadmin'];
$caps = $config->user_caps->superadmin;
break;
default:
$accdesc = "Well you are a funny type of user.";
}
$_SESSION['my_caps'] = $caps;
//show user tools
echo "<h2>You are " . $accdesc . ". Here are your tools:</h2>";
?>
<div class="list-group">
<?php
if($caps['mod_posts'] == true){
//is mod
echo '<a href="user/mod.php" class="list-group-item list-group-item-action">Moderation</a>';
$hascaps = true;
}
if($caps['reset_paswd'] == true){
//can change passwords
echo '<a href="user/resetpasswd.php" class="list-group-item list-group-item-action">Reset user password</a>';
$_SESSION['caps_reset_paswd'] = true;
$hascaps = true;
}
if($caps['promote_to_mod'] == true || $caps['promote_to_admin'] == true || $caps['promote_to_superadmin'] == true || $caps['promote_to_user'] == true || $caps['ban'] == true || $caps['delete_users'] == true || $caps['change_karma'] == true ) {
//can manage users
echo '<a href="user/usermgmt.php" class="list-group-item list-group-item-action">Usermanagement</a>';
$hascaps = true;
}
if($caps['delete_posts'] == true || $caps['change_post_score'] == true || $caps['change_votes'] == true || $caps['edit_posts'] == true){
//can manage posts
echo '<a href="user/postmgmt.php" class="list-group-item list-group-item-action">Postmanagement</a>';
$hascaps = true;
}
if($caps['add_color'] == true){
//can manage colors
echo '<a href="user/colormgmt.php" class="list-group-item list-group-item-action">Add a color</a>';
$hascaps = true;
}
if($caps['create_admin_notice'] == true){
//can manage admin notices
echo '<a href="user/adminote.php" class="list-group-item list-group-item-action">Create admin notice</a>';
$hascaps = true;
}
if(!isset($hascaps)){
//user has no caps
echo '<div class="alert alert-warning" role="alert"><strong>Oh snap!</strong> You don\'t have any tools, go create good vibes and incerase your ' . $config->app_vocabulary['karma'] . ' to recive some.</div>';
}
?>
</div>