Revision 1277
Added by Luisehahne almost 16 years ago
| class.wb.php | ||
|---|---|---|
| 1 | 1 |
<?php |
| 2 |
/** |
|
| 3 |
* |
|
| 4 |
* @category frontend |
|
| 5 |
* @package framework |
|
| 6 |
* @author WebsiteBaker Project |
|
| 7 |
* @copyright 2004-2009, Ryan Djurovich |
|
| 8 |
* @copyright 2009-2010, Website Baker Org. e.V. |
|
| 9 |
* @link http://www.websitebaker2.org/ |
|
| 10 |
* @license http://www.gnu.org/licenses/gpl.html |
|
| 11 |
* @platform WebsiteBaker 2.8.x |
|
| 12 |
* @requirements PHP 4.3.4 and higher |
|
| 13 |
* @version $Id$ |
|
| 14 |
* @filesource $HeadURL: $ |
|
| 15 |
* @lastmodified $Date: $ |
|
| 16 |
* |
|
| 17 |
*/ |
|
| 2 | 18 |
|
| 3 |
// $Id$ |
|
| 4 |
|
|
| 5 |
/* |
|
| 6 |
|
|
| 7 |
Website Baker Project <http://www.websitebaker.org/> |
|
| 8 |
Copyright (C) 2004-2009, Ryan Djurovich |
|
| 9 |
|
|
| 10 |
Website Baker is free software; you can redistribute it and/or modify |
|
| 11 |
it under the terms of the GNU General Public License as published by |
|
| 12 |
the Free Software Foundation; either version 2 of the License, or |
|
| 13 |
(at your option) any later version. |
|
| 14 |
|
|
| 15 |
Website Baker is distributed in the hope that it will be useful, |
|
| 16 |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
| 17 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
| 18 |
GNU General Public License for more details. |
|
| 19 |
|
|
| 20 |
You should have received a copy of the GNU General Public License |
|
| 21 |
along with Website Baker; if not, write to the Free Software |
|
| 22 |
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
|
| 23 |
|
|
| 24 |
*/ |
|
| 25 |
|
|
| 26 |
/* |
|
| 27 |
|
|
| 28 |
wb class |
|
| 29 |
|
|
| 30 |
This class is the basis for admin and frontend classes. |
|
| 31 |
|
|
| 32 |
*/ |
|
| 33 |
|
|
| 34 | 19 |
// Include PHPLIB template class |
| 35 | 20 |
require_once(WB_PATH."/include/phplib/template.inc"); |
| 36 | 21 |
|
| ... | ... | |
| 45 | 30 |
// performed when frontend or backend is loaded. |
| 46 | 31 |
function wb() {
|
| 47 | 32 |
} |
| 48 |
|
|
| 33 |
|
|
| 49 | 34 |
// Check whether a page is visible or not. |
| 50 | 35 |
// This will check page-visibility and user- and group-rights. |
| 51 | 36 |
/* page_is_visible() returns |
| 52 | 37 |
false: if page-visibility is 'none' or 'deleted', or page-vis. is 'registered' or 'private' and user isn't allowed to see the page. |
| 53 | 38 |
true: if page-visibility is 'public' or 'hidden', or page-vis. is 'registered' or 'private' and user _is_ allowed to see the page. |
| 54 | 39 |
*/ |
| 55 |
function page_is_visible($page) {
|
|
| 40 |
function page_is_visible($page) |
|
| 41 |
{
|
|
| 56 | 42 |
$show_it = false; // shall we show the page? |
| 57 | 43 |
$page_id = $page['page_id']; |
| 58 | 44 |
$visibility = $page['visibility']; |
| 59 | 45 |
$viewing_groups = $page['viewing_groups']; |
| 60 | 46 |
$viewing_users = $page['viewing_users']; |
| 47 |
|
|
| 61 | 48 |
// First check if visibility is 'none', 'deleted' |
| 62 |
if($visibility == 'none') {
|
|
| 49 |
if($visibility == 'none') |
|
| 50 |
{
|
|
| 63 | 51 |
return(false); |
| 64 |
} elseif($visibility == 'deleted') {
|
|
| 52 |
} elseif($visibility == 'deleted') |
|
| 53 |
{
|
|
| 65 | 54 |
return(false); |
| 66 | 55 |
} |
| 56 |
|
|
| 67 | 57 |
// Now check if visibility is 'hidden', 'private' or 'registered' |
| 68 | 58 |
if($visibility == 'hidden') { // hidden: hide the menu-link, but show the page
|
| 69 | 59 |
$show_it = true; |
| 70 |
} elseif($visibility == 'private' || $visibility == 'registered') {
|
|
| 60 |
} elseif($visibility == 'private' || $visibility == 'registered') |
|
| 61 |
{
|
|
| 71 | 62 |
// Check if the user is logged in |
| 72 |
if($this->is_authenticated() == true) {
|
|
| 63 |
if($this->is_authenticated() == true) |
|
| 64 |
{
|
|
| 73 | 65 |
// Now check if the user has perms to view the page |
| 74 | 66 |
$in_group = false; |
| 75 |
foreach($this->get_groups_id() as $cur_gid){
|
|
| 76 |
if(in_array($cur_gid, explode(',', $viewing_groups))) {
|
|
| 67 |
foreach($this->get_groups_id() as $cur_gid) |
|
| 68 |
{
|
|
| 69 |
if(in_array($cur_gid, explode(',', $viewing_groups)))
|
|
| 70 |
{
|
|
| 77 | 71 |
$in_group = true; |
| 78 | 72 |
} |
| 79 | 73 |
} |
| ... | ... | |
| 93 | 87 |
return($show_it); |
| 94 | 88 |
} |
| 95 | 89 |
// Check if there is at least one active section on this page |
| 96 |
function page_is_active($page) {
|
|
| 90 |
function page_is_active($page) |
|
| 91 |
{
|
|
| 97 | 92 |
global $database; |
| 98 | 93 |
$has_active_sections = false; |
| 99 | 94 |
$page_id = $page['page_id']; |
| 100 | 95 |
$now = time(); |
| 101 | 96 |
$query_sections = $database->query("SELECT publ_start,publ_end FROM ".TABLE_PREFIX."sections WHERE page_id = '$page_id'");
|
| 102 |
if($query_sections->numRows() != 0) {
|
|
| 103 |
while($section = $query_sections->fetchRow()) {
|
|
| 104 |
if($now<$section['publ_end'] && ($now>$section['publ_start'] || $section['publ_start']==0) || $now>$section['publ_start'] && $section['publ_end']==0) {
|
|
| 97 |
if($query_sections->numRows() != 0) |
|
| 98 |
{
|
|
| 99 |
while($section = $query_sections->fetchRow()) |
|
| 100 |
{
|
|
| 101 |
if($now<$section['publ_end'] && ($now>$section['publ_start'] || $section['publ_start']==0) || $now>$section['publ_start'] && $section['publ_end']==0) |
|
| 102 |
{
|
|
| 105 | 103 |
$has_active_sections = true; |
| 106 | 104 |
break; |
| 107 | 105 |
} |
| ... | ... | |
| 111 | 109 |
} |
| 112 | 110 |
|
| 113 | 111 |
// Check whether we should show a page or not (for front-end) |
| 114 |
function show_page($page) {
|
|
| 115 |
if($this->page_is_visible($page) && $this->page_is_active($page)) {
|
|
| 112 |
function show_page($page) |
|
| 113 |
{
|
|
| 114 |
if($this->page_is_visible($page) && $this->page_is_active($page)) |
|
| 115 |
{
|
|
| 116 | 116 |
return true; |
| 117 | 117 |
} else {
|
| 118 | 118 |
return false; |
| ... | ... | |
| 121 | 121 |
|
| 122 | 122 |
// Check if the user is already authenticated or not |
| 123 | 123 |
function is_authenticated() {
|
| 124 |
if(isset($_SESSION['USER_ID']) AND $_SESSION['USER_ID'] != "" AND is_numeric($_SESSION['USER_ID'])) {
|
|
| 124 |
if(isset($_SESSION['USER_ID']) AND $_SESSION['USER_ID'] != "" AND is_numeric($_SESSION['USER_ID'])) |
|
| 125 |
{
|
|
| 125 | 126 |
return true; |
| 126 | 127 |
} else {
|
| 127 | 128 |
return false; |
| 128 | 129 |
} |
| 129 | 130 |
} |
| 131 |
|
|
| 130 | 132 |
// Modified addslashes function which takes into account magic_quotes |
| 131 | 133 |
function add_slashes($input) {
|
| 132 | 134 |
if ( get_magic_quotes_gpc() || ( !is_string($input) ) ) {
|
Also available in: Unified diff
update headertext