plugins/PunBB.php
changeset 3 c0c445d4a13e
parent 2 a8a21e1c7afa
child 4 eb9ed4c366d0
equal deleted inserted replaced
2:a8a21e1c7afa 3:c0c445d4a13e
    48 define('PUN', '');
    48 define('PUN', '');
    49 define('PUN_DISABLE_BUFFERING', '');
    49 define('PUN_DISABLE_BUFFERING', '');
    50 
    50 
    51 function page_Special_Forum()
    51 function page_Special_Forum()
    52 {
    52 {
       
    53   global $db, $session, $paths, $template, $plugins; // Common objects
    53   if ( getConfig('punbb_installed') != 'yes' )
    54   if ( getConfig('punbb_installed') != 'yes' )
    54   {
    55   {
    55     punano_installer();
    56     punano_installer();
    56   }
    57   }
    57   else if ( getConfig('punbb_version') != PUNANO_VERSION )
    58   else if ( getConfig('punbb_version') != PUNANO_VERSION )
    58   {
    59   {
    59     punano_upgrade();
    60     punano_upgrade();
       
    61   }
       
    62   else if ( preg_match('/^admin_/i', $paths->getParam(0)) )
       
    63   {
       
    64     punano_admin_console();
    60   }
    65   }
    61   else
    66   else
    62   {
    67   {
    63     punano_main();
    68     punano_main();
    64   }
    69   }
   224   // Don't worry. This is sanitized.
   229   // Don't worry. This is sanitized.
   225   require PUN_ROOT . $file . '.php';
   230   require PUN_ROOT . $file . '.php';
   226   
   231   
   227 }
   232 }
   228 
   233 
       
   234 function punano_admin_console()
       
   235 {
       
   236   global $db, $session, $paths, $template, $plugins; // Common objects
       
   237   
       
   238   $valid = array('categories', 'censoring', 'forums', 'groups', 'index', 'loader', 'maintenance', 'options', 'permissions', 'prune', 'ranks', 'reports', 'users');
       
   239   $mod = array('bans', 'censoring', 'index', 'loader', 'reports', 'users');
       
   240 
       
   241   $file = 'index';
       
   242   
       
   243   if ( $x = $paths->getParam(0) )
       
   244   {
       
   245     $x = preg_replace('/\.php$/', '', $x);
       
   246     $x = preg_replace('/^admin_/i', '', $x);
       
   247     if ( in_array(strtolower($x), $valid) )
       
   248     {
       
   249       $file = strtolower($x);
       
   250     }
       
   251   }
       
   252   
       
   253   if ( in_array($file, $mod) )
       
   254   {
       
   255     $need_level = USER_LEVEL_MOD;
       
   256   }
       
   257   else
       
   258   {
       
   259     $need_level = USER_LEVEL_ADMIN;
       
   260   }
       
   261 
       
   262   if ( $session->auth_level < $need_level )
       
   263   {
       
   264     redirect( makeUrlNS('Special', 'Login/' . $paths->fullpage, 'level=' . $need_level, false), 'Permission denied', 'You need to have permission level ' . $session->userlevel_to_string($need_level) . ' to use the PunBB administration console.', 2);
       
   265   }
       
   266   
       
   267   // Don't worry. This is sanitized.
       
   268   require PUN_ROOT . 'admin_' . $file . '.php';
       
   269   
       
   270 }
       
   271 
   229 ?>
   272 ?>