3 |
3 |
//:Absolute or relative url possible
|
4 |
4 |
//:Remember to enable frontend login in your website settings.
|
5 |
5 |
|
6 |
|
global $wb,$page_id,$TEXT, $MENU, $HEADING;
|
|
6 |
global $page_id,$TEXT, $MENU, $HEADING;
|
7 |
7 |
|
8 |
8 |
$return_value = '<div class="login-box">'."\n";
|
9 |
9 |
$return_admin = ' ';
|
10 |
|
// Return a system permission
|
11 |
|
function get_permission($name, $type = 'system')
|
12 |
|
{
|
13 |
|
global $wb;
|
14 |
|
// Append to permission type
|
15 |
|
$type .= '_permissions';
|
16 |
|
// Check if we have a section to check for
|
17 |
|
if($name == 'start') {
|
18 |
|
return true;
|
19 |
|
} else {
|
20 |
|
// Set system permissions var
|
21 |
|
$system_permissions = $wb->get_session('SYSTEM_PERMISSIONS');
|
22 |
|
// Set module permissions var
|
23 |
|
$module_permissions = $wb->get_session('MODULE_PERMISSIONS');
|
24 |
|
// Set template permissions var
|
25 |
|
$template_permissions = $wb->get_session('TEMPLATE_PERMISSIONS');
|
26 |
|
// Return true if system perm = 1
|
27 |
|
if (isset($$type) && is_array($$type) && is_numeric(array_search($name, $$type))) {
|
28 |
|
if($type == 'system_permissions') {
|
29 |
|
return true;
|
30 |
|
} else {
|
31 |
|
return false;
|
32 |
|
}
|
33 |
|
} else {
|
34 |
|
if($type == 'system_permissions') {
|
35 |
|
return false;
|
36 |
|
} else {
|
37 |
|
return true;
|
38 |
|
}
|
39 |
|
}
|
40 |
|
}
|
41 |
|
}
|
42 |
|
|
43 |
|
function get_page_permission($page, $action='admin') {
|
44 |
|
if ($action!='viewing'){ $action='admin';}
|
45 |
|
$action_groups=$action.'_groups';
|
46 |
|
$action_users=$action.'_users';
|
47 |
|
if (is_array($page)) {
|
48 |
|
$groups=$page[$action_groups];
|
49 |
|
$users=$page[$action_users];
|
50 |
|
} else {
|
51 |
|
global $database,$wb;
|
52 |
|
$results = $database->query("SELECT $action_groups,$action_users FROM ".TABLE_PREFIX."pages WHERE page_id = '$page'");
|
53 |
|
$result = $results->fetchRow();
|
54 |
|
$groups = explode(',', str_replace('_', '', $result[$action_groups]));
|
55 |
|
$users = explode(',', str_replace('_', '', $result[$action_users]));
|
56 |
|
}
|
57 |
|
|
58 |
|
$in_group = FALSE;
|
59 |
|
foreach($wb->get_groups_id() as $cur_gid){
|
60 |
|
if (in_array($cur_gid, $groups)) {
|
61 |
|
$in_group = TRUE;
|
62 |
|
}
|
63 |
|
}
|
64 |
|
if((!$in_group) AND !is_numeric(array_search($wb->get_user_id(), $users))) {
|
65 |
|
return false;
|
66 |
|
}
|
67 |
|
return true;
|
68 |
|
}
|
69 |
|
|
|
10 |
$wb = new admin ('Start', 'start', false, false);
|
70 |
11 |
// Get redirect
|
71 |
12 |
$redirect_url = ((isset($_SESSION['HTTP_REFERER']) && $_SESSION['HTTP_REFERER'] != '') ? $_SESSION['HTTP_REFERER'] : WB_URL );
|
72 |
13 |
$redirect_url = (isset($redirect) && ($redirect!='') ? $redirect : $redirect_url);
|
... | ... | |
76 |
17 |
( $wb->get_session('USER_ID') == '') )
|
77 |
18 |
{
|
78 |
19 |
$return_value .= '<form action="'.LOGIN_URL.'" method="post">'."\n";
|
79 |
|
$return_value .= '<input type="hidden" name="url" value="'.$redirect_url.'" />'."\n";
|
|
20 |
$return_value .= '<input type="hidden" name="redirect" value="'.$redirect_url.'" />'."\n";
|
|
21 |
|
80 |
22 |
$return_value .= '<fieldset>'."\n";
|
81 |
23 |
$return_value .= '<h1>'.$TEXT['LOGIN'].'</h1>'."\n";
|
82 |
24 |
$return_value .= '<label for="username">'.$TEXT['USERNAME'].':</label>'."\n";
|
... | ... | |
95 |
37 |
$return_value .= '</fieldset>'."\n";
|
96 |
38 |
$return_value .= '</form>'."\n";
|
97 |
39 |
|
98 |
|
} elseif( (FRONTEND_LOGIN == 'enabled') &&
|
|
40 |
} elseif( (FRONTEND_LOGIN == true) &&
|
99 |
41 |
(is_numeric($wb->get_session('USER_ID'))) )
|
100 |
42 |
{
|
101 |
|
$return_value .= '<form action="'.LOGOUT_URL.'" method="post" class="login-table">'."\n";
|
102 |
|
$return_value .= '<fieldset>'."\n";
|
103 |
|
$return_value .= '<h1>'.$TEXT["LOGGED_IN"].'</h1>'."\n";
|
104 |
|
$return_value .= '<label>'.$TEXT['WELCOME_BACK'].', '.$wb->get_display_name().'</label>'."\n";
|
105 |
|
$return_value .= '<p><input type="submit" name="submit" value="'.$MENU['LOGOUT'].'" class="dbutton" /></p>'."\n";
|
106 |
|
$return_value .= '<ul class="logout-advance">'."\n";
|
|
43 |
$return_value .= '<form action="'.LOGOUT_URL.'" method="post" class="login-table">'."\n";
|
|
44 |
$return_value .= '<fieldset>'."\n";
|
|
45 |
$return_value .= '<h1>'.$TEXT["LOGGED_IN"].'</h1>'."\n";
|
|
46 |
$return_value .= '<label>'.$TEXT['WELCOME_BACK'].', '.$wb->get_display_name().'</label>'."\n";
|
|
47 |
$return_value .= '<p><input type="submit" name="submit" value="'.$MENU['LOGOUT'].'" class="dbutton" /></p>'."\n";
|
|
48 |
$return_value .= '<ul class="logout-advance">'."\n";
|
|
49 |
if ($wb->ami_group_member('1')||$wb->get_permission('preferences'))
|
|
50 |
{
|
107 |
51 |
$return_value .= '<li class="preference"><a href="'.PREFERENCES_URL.'" title="'.$MENU['PREFERENCES'].'">'.$MENU['PREFERENCES'].'</a></li>'."\n";
|
|
52 |
}
|
108 |
53 |
|
109 |
|
if ($wb->ami_group_member('1')) //change ot the group that should get special links
|
110 |
|
{
|
111 |
|
$return_admin .= '<li class="admin"><a target="_blank" href="'.ADMIN_URL.'/index.php" title="'.$TEXT['ADMINISTRATION'].'" class="blank_target">'.$TEXT["ADMINISTRATION"].'</a></li>'."\n";
|
112 |
|
//you can add more links for your users like userpage, lastchangedpages or something
|
113 |
|
$return_value .= $return_admin;
|
114 |
|
}
|
115 |
|
//change ot the group that should get special links
|
116 |
|
if( get_permission('pages_modify') && get_page_permission( PAGE_ID ) )
|
117 |
|
{
|
118 |
|
$return_value .= '<li class="modify"><a target="_blank" href="'.ADMIN_URL.'/pages/modify.php?page_id='.PAGE_ID.'" title="'.$HEADING['MODIFY_PAGE'].'" class="blank_target">'.$HEADING['MODIFY_PAGE'].'</a></li>'."\n";
|
119 |
|
}
|
120 |
|
$return_value .= '</ul>'."\n";
|
121 |
|
$return_value .= '</fieldset>'."\n";
|
122 |
|
$return_value .= '</form>'."\n";
|
|
54 |
//change ot the group that should get special links
|
|
55 |
if ($wb->ami_group_member('1')||$wb->get_permission('admintools'))
|
|
56 |
{
|
|
57 |
$return_admin .= '<li class="admin"><a target="_blank" href="'.ADMIN_URL.'/index.php" title="'.$TEXT['ADMINISTRATION'].'" class="blank_target">'.$TEXT["ADMINISTRATION"].'</a></li>'."\n";
|
|
58 |
//you can add more links for your users like userpage, lastchangedpages or something
|
|
59 |
$return_value .= $return_admin;
|
|
60 |
}
|
|
61 |
//change ot the group that should get special links
|
|
62 |
if( $wb->get_permission('pages_modify') && $wb->get_page_permission( PAGE_ID ) )
|
|
63 |
{
|
|
64 |
$return_value .= '<li class="modify"><a target="_blank" href="'.ADMIN_URL.'/pages/modify.php?page_id='.PAGE_ID.'" title="'.$HEADING['MODIFY_PAGE'].'" class="blank_target">'.$HEADING['MODIFY_PAGE'].'</a></li>'."\n";
|
|
65 |
}
|
|
66 |
$return_value .= '<li> '.'</li>'."\n";
|
|
67 |
$return_value .= '</ul>'."\n";
|
|
68 |
$return_value .= '</fieldset>'."\n";
|
|
69 |
$return_value .= '</form>'."\n";
|
123 |
70 |
}
|
124 |
71 |
$return_value .= '</div>'."\n";
|
125 |
72 |
return $return_value;
|
! update droplets uninstall, upgrade
! add $database=WbDatabase::getInstance();
! update /examples/