Subversion Repositories travelsized

Rev

Rev 475 | Blame | Compare with Previous | Last modification | View Log | RSS feed

<?PHP
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
 * This file is part of Travelsized CMS
 *              A content management system with modules, based on wiki syntax
 *
 * Author: Dan Jensen <admin@leinir.dk>
 * Copyright 2003/2004
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * The GNU General Public License is available at: http://www.gnu.org/copyleft/
 * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */

include("documentation.php");
/**************************************************************************
* SETUP INFORMATION - THIS IS CHANGABLE DURING INITIAL SETUP OF THE SITE!
***************************************************************************/


// Basic information about the owner of the system (used in many places) {
$owner_name = "Dan Jensen";
$owner_email = "admin@NOSPAMleinir.dk";
// Basic information about the owner of the system (used in many places) }

// This is where the setup files are to be put {
$setup_folder = "setup";
// This is where the setup files are to be put }

// If this is set to true, all users can delete themselves as user {
$let_users_delete_self = false;
// If this is set to true, all users can delete themselves as user }

// Set the default language
// Values are standard ISO two-letter language definitions
//
// For example:
// en = English
// dk = Danish
// de = German
// es = Spanish
$default_language = "en";

/**************************************************************************
* SETUP INFORMATION ENDS HERE - NO USER SETUP BELLOW THIS POINT!
***************************************************************************/


// Script execution timer start {
$mtime = microtime();
$mtime = explode(" ",$mtime);
$mtime = $mtime[1] + $mtime[0];
$starttime = $mtime;
// Script execution timer start }

// Bad form, but it's needed for the thumbnailer to work with largeish pictures
ini_set( "memory_limit","64M" );
ini_set( "date.timezone", "UTC" );

// // Please somebody tell me why this is necessary?!
// if( get_magic_quotes_gpc() )
// {
//      function stripslashes_deep($value)
//      {
//              $value = is_array($value) ?
//              array_map('stripslashes_deep', $value) :
//              stripslashes($value);
//             
//              return $value;
//      }
//
//      $_POST = array_map('stripslashes_deep', $_POST);
//      $_GET = array_map('stripslashes_deep', $_GET);
//      $_COOKIE = array_map('stripslashes_deep', $_COOKIE);
//      $_REQUEST = array_map('stripslashes_deep', $_REQUEST);
// }

// Set the language
$language = $default_language;
if( array_key_exists( "language", $_REQUEST ) )
        $language = $_REQUEST['language'];


// Define variables determining where stuff goes... {
$password_file = "$setup_folder/password.txt";
$recent_file = "$setup_folder/recent_pages.txt";
$page_folder = "$setup_folder/pages";
$menu_folder = "$setup_folder/menus";
$module_folder = "$setup_folder/modules";
$files_folder = "$setup_folder/files";
$userinfo_folder = "$setup_folder/userinfo";
// Define variables determining where stuff goes... }

//Setup folders must exist
/* This does not, for some reason, work on some servers... (Security issues I suppose...)
if (!file_exists($setup_folder)) mkdir($setup_folder,0777);
if (!file_exists($page_folder)) mkdir($page_folder,0777);
if (!file_exists($menu_folder)) mkdir($menu_folder,0777);
if (!file_exists($files_folder)) mkdir($files_folder,0777);
touch($recent_file);
*/


// Update scripts {
include("update.php");
updateTo020();
updateTo030();
// Update scripts }

//The person who made the system
$creator_name = "Dan Jensen";
$creator_email = "admin@NOSPAMleinir.dk";

//$usergroups_global_default = "";

// Set the variables used around the site...
$meta_headers = "";
$globalError = "";

// Set the system options defaults, then include them system options
$systemOptions = array(
        "locked" => 0,
        "timeformat" => "M j Y G:i",
        "rewrite" => 0,
        "humanurls" => 0,
        "permissionmessages" => 1
        );

if( file_exists( "$setup_folder/systemOptions.php" ) )
        include( "$setup_folder/systemOptions.php" );

if( ! array_key_exists( "permissionmessages", $systemOptions ) )
        $systemOptions["permissionmessages"] = 1;

// A bunch of shared functions, also loads profile options
include("shared.php");

// Internationalisation stuff
include("i18n-functions.php");
include("i18n.php");

include("page.class.php"); // Page functions
$pagectl = new Page; // Create a page control to work with

// Get list of recently changed pages
include("recentchanges.php");

// Get list over theme names and folders
include("theme_list.php");

// Authentication subsystem
include("auth.php");
if( array_key_exists( "logout", $_REQUEST ) && $_REQUEST["logout"] == "true" )
        unauth();

$usermanager = new Userman;
if( array_key_exists( "username", $_REQUEST ) && array_key_exists( "password", $_REQUEST )  && !array_key_exists( "new_user", $_REQUEST ) && $_REQUEST["logout"] != "true" )
        auth($_REQUEST['username'], $_REQUEST['password']);
else
        auth();

// Comments handling functionality
include("comment_handler.php");

// Messaging and subscription subsystem
include "messages.php";
$subscriptions = new subscriptionsManager;

// Get the current page_id and get the data that goes with it {
// Anything but globalID is for backwards compatability
$page_id = 0;
$page_content = "";
if( array_key_exists( "globalID", $_REQUEST ) ) // If we have a global ID
{
        $globalID = $_REQUEST["globalID"];
        $page_id = handleGlobalID();
}
else if( array_key_exists( "page", $_REQUEST ) ) //if $page is present
        $page_id = getpage_id($setup_folder, $_REQUEST["page"]); //get $page_id by backtracing the $page
else if( array_key_exists( "page_id", $_REQUEST ) )
        $page_id = $_REQUEST["page_id"];
else
        $page_id = 0;
// Get the current page_id and get the data that goes with it }

// Are we adding a new user, or is this a user profile? {
if( array_key_exists( "user_id", $_REQUEST ) )
        $page_id = 13;
if( array_key_exists( "new_user", $_REQUEST ) )
        header("Location: " . globalIDtoURL("user/" . i18n("username") . "/new") );
// Are we adding a new user, or is this a user profile? }

// Language links
// Needs to be here (we need the page_id, and we don't have that before now)
include("languagelinks.php");

// Formatting toolbar used for editing page data.
include("formattingtoolbar.php");


/******************************************************************************
 * Figure out which page we are showing and present the user with the result! *
 ******************************************************************************/


$setupSection = false;
if ($page_id > 99)
{ // Specific pages created by the user
        $page_temp = $pagectl->fetchPageData($page_id, $language, $page_folder);
        $page_author = $page_temp["author"];
        $page_author_email = $page_temp["email"];
        $page_menu = $page_temp["menu"];
        $page_date = $page_temp["date"];
        $page_title = $page_temp["title"];
        if ((array_key_exists( "username", $_REQUEST ) && array_key_exists( "password", $_REQUEST ) ) && !auth($_REQUEST['username'], $_REQUEST['password']))
        {
                $page_content = "<p>" . i18n("You have reached a restricted area of the website. If you are allowed to view this part of the site, please log in below.") . "</p>" . loginform($language, globalIDtoURL("content/$language/" . $page_temp["title"]));
        }
        else if ( isAllowed( "menu_" . $page_menu . "_view" ) || ( $pagectl->numberOfMenus() < 1 && isAllowed("global_menus_view") ) )
        {
                $page_content = $page_temp["content"];
                //only parse the page content if it isn't already html
                if (!strpos($page_content, "<") === true)
                        $page_content = parse_page_data($page_content);
        }
        else
                $page_content = "<p>" . i18n("You have reached a restricted area of the website. If you are allowed to view this part of the site, please log in below.") . "</p>" . loginform($language, globalIDtoURL("content/$language/" . $page_temp["title"]));
} else if (is_array($page_id)) {//this means that the search for pages returned more than one $page_id, and that it is now an array.
        $page_author = $owner_name;
        $page_author_email = $owner_email;
        $page_menu = 0;
        $page_date = formatTime( time() );
        $page_title = i18n("Found pages");
        $page_content = "<p>" . i18n("The following pages were found with a title which includes &quot;##0##&quot;. Click on any of them to see the entire contents.", array($_REQUEST['page'])) . "</p>\n<ul>";
        $page_newtitle = htmlspecialchars($_REQUEST["page"]);
        //cycle through the list of found pages and write the $page_title and a short bit of the $page_content
        foreach ($page_id as $key => $value) {
                foreach($value["title"] as $key2 => $value2) {
                        $page_content .= "
                        <li><div><a href=\""
. globalIDtoURL("content/{$page_id[$key]['language'][$key2]}/{$page_id[$key]['id']}") ."\">{$page_id[$key]['title'][$key2]} ({$page_id[$key]['language'][$key2]})</a></div>";
                }
        }
        $page_content .= "</ul>\n               <hr size=\"1\">";
       
        if( isauth() )
                $page_content .= "\n            <p><a href=\"" . globalIDtoURL("setup/editpage/$language/$page_newtitle") . "\">" . i18n("Click here to make a new page with this title") . "</a>.</p>";
}
else
{
        /*List of $page_ids
        0 = Front page
        1 = About the system, and who has made it
        2 = Tag wall
        3 = Site setup (links to editing pages, menu menus, users, themes)
        4 = User setup (make, delete users, change password)
        5 = Manage pages (delete, update $page-to-$page_id backwards lookup index (setup/page_backwards.txt))
        6 = Edit page (include $edit_id (or an $edit_title for creating a new). Update recentchanges.php on exit (rotate_recent($new_id) function in recentchanges.php)
        7 = Manage the menu menus
        8 = Edit $menu_menu (include $menu_id)
        9 = Theme management
        10 = List of all pages
        11 = File management (downloads...)
        12 = Module setup
        13 = Profile
        14 = Help
        15 = Request password
        16 = System options
        17 = Updates
        18 = Login page
        */

        switch( $page_id )
        {
        case 0:
                include ("frontpage.php");
                if ((array_key_exists( "username", $_REQUEST) && array_key_exists( "password", $_REQUEST ) ) && !auth($_REQUEST['username'], $_REQUEST['password']))
                {
                        $setupSection = true;
                        $page_content = "<p>" . i18n("Access to this website is restricted. If you are allowed to view this site, please log in below.") . "</p>" . loginform($language, globalIDtoURL("content/$language/0") );
                }
                else if (isAllowed("global_frontpage_view"))
                {
                        if( file_exists( $page_folder . "/0.$language.php" ) || file_exists( $page_folder . "/0.$default_language.php" ) )
                        {
                                $page_temp = $pagectl->fetchPageData( 0, $language );
                                $page_author = $page_temp["author"];
                                $page_author_email = $page_temp["email"];
                                $page_menu = $page_temp["menu"];
                                $page_date = $page_temp["date"];
                                $page_title = $page_temp["title"];
                                $page_content = parse_page_data($page_temp["content"]);
                        }
                        else
                        {
                                //only parse the page content if it isn't already html
                                if (!strpos($page_content, "<") === true)
                                        $page_content = parse_page_data($page_content);
                        }
                }
                else
                        $page_content = "<p>" . i18n("Access to this website is restricted. If you are allowed to view this site, please log in below.") . "</p>" . loginform($language, globalIDtoURL("content/$language/0") );
               
                break;
        case 1:
                include ("about.php");
                break;
        case 2:
                include ("tagwall.php");
                break;
        case 3:
                $setupSection = true;
                include ("setup.php");
                break;
        case 4:
                $setupSection = true;
                include ("usersetup.php");
                break;
        case 5:
                $setupSection = true;
                include ("pagesetup.php");
                break;
        case 6:
                $setupSection = true;
                include ("pageedit.php");
                break;
        case 7:
                $setupSection = true;
                include ("menusetup.php");
                break;
        case 8:
                $setupSection = true;
                include ("menuedit.php");
                break;
        case 9:
                $setupSection = true;
                include ("themesetup.php");
                break;
        case 10:
                include ("allpages.php");
                break;
        case 11:
                $setupSection = true;
                include ("filesetup.php");
                break;
        case 12:
                $setupSection = true;
                include ("modulesetup.php");
                break;
        case 13:
                include ("profiles.php");
                break;
        case 14:
                $_REQUEST["theme"] = "empty";
                $page_title = i18n("Page Layout Help");
                $page_content = "<html><head><title>" . i18n("Page Layout Help") . "</title><style>.page_help_term, .page_help_description { border-top: 1px dotted gray; }</style></head><body><h1>" . i18n("Page Layout Help") . "</h1>" . generate_pagehelp() . "</body></html>";
                break;
        case 15:
                include ("requestpassword.php");
                break;
        case 16:
                $setupSection = true;
                include ("systemoptions.php");
                break;
        case 17:
                include ("subscriptionupdates.php");
                break;
        case 18:
                include ("login.php");
                break;
        case -1:
                $page_author = $owner_name;
                $page_author_email = $owner_email;
                $page_title = htmlspecialchars($_REQUEST["page"]);
                $page_menu = 0;
               
                if( !isauth() )
                        $page_content = parse_page_data(i18n("The page (##0##) was not found on the system. Please return to the ((Front page)) and try again.", array($page_title)));
                else
                        $page_content = parse_page_data(i18n("The page (##0##) was not found on the system. Please return to the ((Front page)) and try again.", array($page_title)) . "<hr /><a href=\"" . globalIDtoURL("setup/editpage/$language/$page_title") . "\">" . i18n("Click here to make a new page with this title") . "</a>");
               
                $page_date = formatTime( time() );
                break;
        default:
                //Something is broken, this should NEVER happen!
                $page_title = "THIS SHOULD NOT HAPPEN!!";
        }
}

//Theming is the last thing to be done
include("theming.php");

// Script execution timer end {
$mtime = microtime();
$mtime = explode(" ",$mtime);
$mtime = $mtime[1] + $mtime[0];
$endtime = $mtime;
$totaltime = ($endtime - $starttime);
// echo "<div style=\"text-align : center; font-size: 6px; color : #c0c0c0;\">This page was created in ".$totaltime." seconds</div>";
// Script execution timer end }
?>