Visualizzazione dei risultati da 1 a 5 su 5
  1. #1
    Utente bannato
    Registrato dal
    Feb 2011
    Messaggi
    165

    [PHP] Bloccare alcune pagine

    Salve, come faccio ad bloccare alcune pagine che entra solo amministratore e collaboratore?

    Io faccio cosi:
    Codice PHP:
    <?php
    session_start
    ();
    require_once(
    dirname(__FILE__) . '/../inc.php');
    require_once(
    dirname(__FILE__) . '/../check_member.php');
    if(!isset(
    $_COOKIE["autolog"]) == "loggato" || isset($_SESSION["login"]) == true)
    {
     
    $error ="Non consentito"// Qui non e loggato.
    }else
    {
    if(
    isadmin ($userid) || isadmin ($_SESSION["user_id"]))  // Qui controllo se admin/collab.
    // e da qui visualizzo tutto se e l'admin e collaboratore.
    if(isset($error)){ echo $error;}
    if(isset(
    $msg)){ echo $msg;} else {?>
    <?php 
    ?>
        


    Cookie</p>
     [b]<?php echo $userid;?>[/b]

     [b]<?php echo get_username($userid);?>[/b]
     

    Sessioni</p>
    <?php

    echo $_SESSION["user_id"];
    ?>

    [b]<?php echo get_username($_SESSION["user_id"]);?>[/b]
    <?php 
    }
    }
    ?>

    C'è un modo più veloce?

    Ed in più senza usare la funzione exit(); che non me piace tanto.


    Una soluzione più bella si può trovare?

    grazie mille.

  2. #2
    Utente bannato
    Registrato dal
    Feb 2011
    Messaggi
    165
    si può usare true e false,

    ma non so come fare?

    mi date una mano?

    grazie

  3. #3
    devi usare dei permessi. Metti un campo su DB con 1 per admin e 2 per collaboratore, ad esempio ... e poi ogni pagina controlla se è 1 o 2...

  4. #4
    Utente bannato
    Registrato dal
    Feb 2011
    Messaggi
    165
    si quello lo fatto,
    solo che volevo sapere come posso includere un codice in una decina di script ..php,
    senza usare if else ogni pagina.

    mi basta un piccolissimo include che dice che entra admin/collaboratore;

    La funzione isadmin è questa:
    Lo presa da altri esempi di aree riservate:
    Codice PHP:
    function isadmin $id )
        {
            
    $query mysql_query("SELECT `Level_access` FROM `users` WHERE `md5_id` = '" mysql_real_escape_string $id ) . "'");
            
            if ( 
    mysql_num_rows $query ) == )
            {
                
    $row mysql_fetch_array $query );
                
                if ( 
    $row['Level_access'] == )
                {
                    return 
    TRUE;
                }
                else {
                    return 
    FALSE;
                }
            }
            else {
                return 
    FALSE;
            }
        } 
    solo che vorrei bloccare l'accesso alle pagine della cartella admin/ con un solo include?

    si può fare?

    grazie mille
    e buona giornata.

  5. #5
    Utente bannato
    Registrato dal
    Feb 2011
    Messaggi
    165
    scusate, sapete mica cosa è questo pezzo di codice di wordpress
    che sta nello script admin.php

    if ( ! defined('WP_ADMIN') )
    define('WP_ADMIN', TRUE);

    ???

    if ( ! defined( 'WP_ADMIN' ) )
    require_once( './admin.php' );

    ???

    e lo chiama ad esempio questa pagina:
    che sta nella wp-admin/index.php

    è c'è questo codice:
    Codice PHP:
    <?php
    /**
     * Dashboard Administration Panel
     *
     * @package WordPress
     * @subpackage Administration
     */

    /** Load WordPress Bootstrap */
    require_once('./admin.php');

    /** Load WordPress dashboard API */
    require_once(ABSPATH 'wp-admin/includes/dashboard.php');

    wp_dashboard_setup();

    wp_enqueue_script'dashboard' );
    wp_enqueue_script'plugin-install' );
    wp_enqueue_script'media-upload' );
    wp_admin_css'dashboard' );
    wp_admin_css'plugin-install' );
    add_thickbox();

    $title __('Dashboard');
    $parent_file 'index.php';

    if ( 
    is_user_admin() )
        
    add_screen_option('layout_columns', array('max' => 4'default' => 1) );
    else
        
    add_screen_option('layout_columns', array('max' => 4'default' => 2) );

    add_contextual_help($current_screen,

        
    '

    __'Welcome to your WordPress Dashboard! You will find helpful tips in the Help tab of each screen to assist you as you get to know the application.' ) . '</p>' .
        
    '

    __'The Admin Bar at the top, new in 3.1, provides quick access to common tasks when you are viewing your site.' ) . '</p>' .
        
    '

    __'The left-hand navigation menu provides links to the administration screens in your WordPress application. You can expand or collapse navigation sections by clicking on the arrow that appears on the right side of each navigation item when you hover over it. You can also minimize the navigation menu to a narrow icon strip by clicking on the faint separator lines between the Dashboard and Posts sections, or between Comments and Appearance; when minimized, the submenu items will be displayed on hover.' ) . '</p>' .
        
    '

    __'You can configure your dashboard by choosing which boxes, or modules, to display in the work area, how many columns to display them in, and where each box should be placed. You can hide/show boxes and select the number of columns in the Screen Options tab. To rearrange the boxes, drag and drop by clicking on the title bar of the selected box and releasing when you see a gray dotted-line rectangle appear in the location you want to place the box. You can also expand or collapse each box by clicking once on the title bar of the box. In addition, some boxes are configurable, and will show a “Configure” link in the title bar when you hover over it.' ) . '</p>' .
        
    '

    __'The boxes on your Dashboard screen are:' ) . '</p>' .
        
    '

    __'[b]Right Now[/b] - Displays a summary of the content on your site and identifies which theme and version of WordPress you are using.' ) . '</p>' .
        
    '

    __'[b]Recent Comments[/b] - Shows the most recent comments on your posts (configurable, up to 30) and allows you to moderate them.' ) . '</p>' .
        
    '

    __'[b]Incoming Links[/b] - Shows links to your site found by Google Blog Search.' ) . '</p>' .
        
    '

    __'[b]QuickPress[/b] - Allows you to create a new post and either publish it or save it as a draft.' ) . '</p>' .
        
    '

    __'[b]Recent Drafts[/b] - Displays links to the 5 most recent draft posts you’ve started.' ) . '</p>' .
        
    '

    __'[b]WordPress Development Blog[/b] - Come here for the latest scoop.' ) . '</p>' .
        
    '

    __'[b]Other WordPress News[/b] - Shows the feed from [url="http://planet.wordpress.org"]WordPress Planet[/url]. You can configure it to show a different feed of your choosing.' ) . '</p>' .
        
    '

    __'[b]Plugins[/b] - Features the most popular, newest, and recently updated plugins from the WordPress.org Plugin Directory.' ) . '</p>' .
        
    '

    [b]' 
    __'For more information:' ) . '[/b]</p>' .
        
    '

    __'[url="http://codex.wordpress.org/Dashboard_SubPanel"]Documentation on Dashboard[/url]' ) . '</p>' .
        
    '

    __'[url="http://wordpress.org/support/"]Support Forums[/url]' ) . '</p>'
    );

    include (
    ABSPATH 'wp-admin/admin-header.php');

    $today current_time('mysql'1);
    ?>

    <div class="wrap">
    <?php screen_icon(); ?>
    <h2><?php echo esc_html$title ); ?></h2>

    <div id="dashboard-widgets-wrap">

    <?php wp_dashboard(); ?>

    <div class="clear"></div>
    </div>

    </div>

    <?php require(ABSPATH 'wp-admin/admin-footer.php'); ?>
    Come posso fare anche io la stessa cosa?

    come si può fare con i define??.

    grazie mille.

Permessi di invio

  • Non puoi inserire discussioni
  • Non puoi inserire repliche
  • Non puoi inserire allegati
  • Non puoi modificare i tuoi messaggi
  •  
Powered by vBulletin® Version 4.2.1
Copyright © 2025 vBulletin Solutions, Inc. All rights reserved.