Platon Technologies
neprihlásený Prihlásiť Registrácia
SlovakEnglish
open source software development oslavujeme 10 rokov vývoja otvoreného softvéru! Štvrtok, 28. marec 2024

Súbor: [Platon] / Metafox / admin / _core.php (stiahnutie)

Revízia 1.10, Tue Jan 20 15:20:17 2015 UTC (9 years, 2 months ago) by igor


Zmeny od 1.9: +44 -3 [lines]

implement admin API for custom applications,
added cleaning cache in debug level 10,
added function array_insert into library Platon

<?php

/*
 * Metafox - flexible content management system
 *
 * admin/_core.php - admin core file
 * ____________________________________________________________
 *
 * Developed by Ondrej Jombik <nepto@platon.sk>
 * Copyright (c) 2001-2008 Platon Group, http://platon.sk/
 * All rights reserved.
 *
 * See README file for more information about this software.
 * See COPYING file for license information.
 *
 * Download the latest version from
 * http://platon.sk/projects/Metafox/
 */

/* $Platon: Metafox/admin/_core.php,v 1.9 2012-09-28 18:49:48 nepto Exp $ */

/* MAINTAINANCE: This file is maintained in Metafox project and distributed
   across the particular projects accordingly. */

header('Pragma: no-cache');                                    // HTTP/1.0
header('Cache-Control: no-cache, must-revalidate');              // HTTP/1.1
header('Expires: Mon, 01 Jun 1981 05:00:00 GMT');              // Date in the past
header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT'); // always modified

chdir('inc/');
require_once 'init.inc.php';
chdir('../');

require_once 'inc/functions.inc.php';
require_once 'Platon.php';
require_once 'Auth/AuthDB.php';
$ezin_auth === false && $ezin_auth = new AuthDB($ezin_auth_options);
isset($ezin_admin_action) || $ezin_admin_action = '';

ezin_reset_session_records();

/* If admin's authentifaction function was defined, use it. */
if (strlen($ezin_cfg['admin_auth_function']) > 0) {
    $ezin_auth->setLoggedFunction($ezin_cfg['admin_auth_function']);
}

if ($ezin_admin_action == 'logout') {
    if ($ezin_auth->getAuth()) {
        $ezin_auth->logout();
        if (strlen($ezin_cfg['admin_auth_function']) > 0 /* <-- consider if this is neccessary */
                && strlen($ezin_cfg['admin_auth_logout_redirect']) > 0) {
            header('Location: '.ezin_adjust_link($ezin_cfg['admin_auth_logout_redirect']));
            exit;
        }
    } else {
        header('Location: http://'.$_SERVER['HTTP_HOST'].$ezin_cfg['url'].$ezin_sys['dir']['admin']);
        exit;
    }
}

if (strlen($ezin_cfg['admin_auth_function']) > 0
        && function_exists($ezin_cfg['admin_auth_function'])
        && (string) @$ezin_cfg['admin_auth_function']() == '') {
    if ($ezin_auth->getAuth()) {
        $ezin_auth->logout();
    } else {
        if (strlen($ezin_cfg['admin_auth_login_redirect']) > 0) {
            header('Location: '.ezin_adjust_link($ezin_cfg['admin_auth_login_redirect']));
            exit;
        }
    }
}


if (! $ezin_auth->getAuth()) { // not logged in case
    
    switch ($ezin_auth->getStatus()) {
        case AUTH_DB_NOT_LOGGED: require 'inc-html/login.html';   break;
        case AUTH_DB_LOGGED_OUT: require 'inc-html/logout.html';  break;
        case AUTH_DB_FAILED:     require 'inc-html/logfail.html'; break;
        case AUTH_DB_TIMEOUT:    require 'inc-html/timeout.html'; break;
        case AUTH_DB_EXPIRED:    require 'inc-html/expired.html'; break;
        default:
             echo '<center>';
             echo '<p><big><b>Unknown status ('; // )
             echo $ezin_auth->getStatus().')</b></big>';
             echo '</center>';
             break;
    }

} else { // logged in case

    $ezin_user = $ezin_auth->getUserInfo();

    if (empty($ezin_user['role_login'])) {
        echo 'You\'re not allowed to log in.<br>';
        $ezin_auth->logout();
    } else {

        echo '<table class="ezin-admin-main">' . "\n";
        echo '<tr><td class="ezin-admin-main" align="left" valign="top">';
        echo '<!-- Metafox::ADMIN::MENU -->';
        require_once 'inc-html/bar-title.html';
        require_once 'inc/menu.inc.php';

        foreach ($ezin_ADMIN_MENU as $ar) {
            $ok = 0;
            if (0) { /* change if's 0 to 1 to get all menu links */
                $ok = 1;
            } elseif (! isset($ar['column'])) {
                $ok = 1;
            } elseif (is_array($ar['column'])) {
                foreach ($ar['column'] as $col) {
                    if (ezin_admin_check_list_privileges($ezin_user[$col])) {
                        $ok = 1;
                        break;
                    }
                }
            } elseif (ezin_admin_check_list_privileges($ezin_user[$ar['column']])) {
                $ok = 1;
            }
            if ($ok) {
                echo '<strong><big>&middot;</big></strong>&nbsp;';
                echo '<a href="'.$ezin_cfg['url'].$ezin_sys['dir']['admin'].'/'.$ar['link'].'">'.$ar['caption'].'</a><br>'."\n";
            }
        }

        require_once 'inc-html/bar-info.html';
        echo '<!-- /Metafox::ADMIN::MENU --></td>',"\n";
        echo '<td width="100%" align="left" valign="top" class="ezin-admin-main">';
        echo '<!-- Metafox::ADMIN::CONTENT -->',"\n";

        switch ($ezin_admin_action) {
            /*
             * Empty action
             */
            case '': 
                require 'inc-html/welcome.html';
                $results = ezin_admin_db_check_run(); // Check after login
                foreach($results as $result) {
                    switch($result['result']) {
                        case 1:
                            // TEST OK
                            break;
                        case 2:
                            echo "Info: DB fix successful, Application: <b>$result[app]</b>, Check title: <b>$result[title]</b><br>";
                            break;
                        default:
                            echo "Error: DB fix failed, Application: <b>$result[app]</b>, Check title: <b>$result[title]</b>, Error code: <b>$result[result]</b><br>";
                            break;
                    }
                }
                break;

                /*
                 * File management action
                 */
            case 'file_management':
                if (ezin_admin_check_list_privileges($ezin_user['role_file_management'])) {
                    $ezin_admin_orig_dir = getcwd();
                    Platon::chdir_back($ezin_sys['dir']['admin']);
                    if (@file_exists($ezin_sys['dir']['upload'])) {
                        chdir('lib/phpWebFileManager/');
                        require_once 'index.php';
                        chdir($ezin_admin_orig_dir);
                    } else {
                        chdir($ezin_admin_orig_dir);
                        require 'inc-html/nofilemngdir.html';
                    }
                } else {
                    require 'inc-html/permdenied.html';
                }
                break;

                /*
                 * Custom applications
                 */
            case 'application':
                $parts = explode('/', $_GET['link']);
                if (count($parts) < 4) {
                    require 'inc-html/app-noaction.html';
                    break;
                }
                $info = ezin_admin_menu_info($parts[2], $parts[3]);
                if ($info === false) {
                    require 'inc-html/app-noinfo.html';
                    break;
                }
                $app_file_inc = $ezin_sys['dir']['root'].$ezin_sys['dir']['apps'].'/'
                    .$info['app_dir'].'/'.$info['inc_file'];
                if (!file_exists($app_file_inc)
                    || !is_readable($app_file_inc))
                {
                    require 'inc-html/app-notexistsfile.html';
                    break;
                }
                global $ezin_admin_app_action;
                $ezin_admin_app_action = $parts[3];
                require $app_file_inc;
                break;

                /*
                 * Database manipulation action
                 */
            default:
                foreach ($ezin_ADMIN_MENU as $ar) {
                    if (isset($ar['action']) && ! strcmp($ar['action'], $ezin_admin_action)) {
                        $inc_filename = 'inc-db/'.$ar['inc_file'];
                        if (@file_exists($inc_filename) && @is_file($inc_filename) && @is_readable($inc_filename)) {
                            require_once $inc_filename;
                        } else {
                            require 'inc-html/failure.html';
                        }
                        break;
                    }
                }
                break;
        };

        echo '<!-- /Metafox::ADMIN::CONTENT --></td></tr>';
        if (@file_exists('inc-html/signature.html')) {
            echo '<tr><td class="ezin-admin-main" colspan="2">';
            echo '<!-- Metafox::ADMIN::SIGNATURE -->',"\n";
            require 'inc-html/signature.html';
            echo '<!-- /Metafox::ADMIN::SIGNATURE --></td></tr>';
        }
        echo '</table>'."\n";
    }
}


chdir('inc/');
require_once 'destroy.inc.php';
chdir('../');

?>

Platon Group <platon@platon.sk> http://platon.sk/
Copyright © 2002-2006 Platon Group
Stránka používa redakčný systém Metafox
Na začiatok