plugins/PunBB.php
changeset 6 5e1f1e916419
parent 5 e3d7322305bf
child 8 8baccbad4a55
--- a/plugins/PunBB.php	Sun Sep 02 11:00:57 2007 -0400
+++ b/plugins/PunBB.php	Sat Apr 05 23:56:45 2008 -0400
@@ -4,15 +4,15 @@
 Plugin URI: http://enanocms.org/PunBB_plugin
 Description: Provides a complete forum solution in PunBB, a separately maintained and very lightweight GPL forum.
 Author: Dan Fuhry
-Version: 0.1.12.15
+Version: 1.3-beta
 Author URI: http://enanocms.org/
 */
 
 /*
  * PunBB Plugin for Enano CMS
- * Version 0.1.12.15
- * Copyright (C) 2006-2007 Dan Fuhry
- * Copyright (C) 2002-2007 Rickard Andersson
+ * Version 1.3-beta
+ * Copyright (C) 2006-2008 Dan Fuhry
+ * Copyright (C) 2002-2008 Rickard Andersson
  *
  * This program is Free Software; you can redistribute 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.
@@ -36,17 +36,19 @@
 $plugins->attachHook('session_started', '
     $pid = RenderMan::strToPageId($paths->get_pageid_from_url());
 
-    if ( getConfig("punbb_installed") == "yes" && getConfig("punbb_version") == PUNANO_VERSION && $pid[0] == "Forum" && $pid[1] == "Special" )
+    $is_style_or_script = ( strpos($_SERVER["REQUEST_URI"], "/style/") || strpos($_SERVER["REQUEST_URI"], "/include/js/") );
+    if ( getConfig("punbb_installed") == "yes" && getConfig("punbb_version") == PUNANO_VERSION && $pid[0] == "Forum" && $pid[1] == "Special" && !$is_style_or_script )
     {
       require( "punbb/include/common.php" );
     }
     ');
 
-define('PUNANO_VERSION', '0.1.12.15');
-define('PUNBB_VERSION',  '1.2.15');
+define('PUNANO_VERSION', '0.1.3-beta');
+define('PUNBB_VERSION',  '1.3-beta');
 define('PUN_ROOT', ENANO_ROOT . '/punbb/');
 define('PUN', '');
 define('PUN_DISABLE_BUFFERING', '');
+// define('PUN_SHOW_QUERIES', '');
 
 function page_Special_Forum()
 {
@@ -59,10 +61,22 @@
   {
     punano_upgrade();
   }
-  else if ( preg_match('/^admin_/i', $paths->getParam(0)) )
+  else if ( $paths->getParam(0) == 'admin' )
   {
     punano_admin_console();
   }
+  else if ( $paths->getParam(0) == 'style' )
+  {
+    $path = $paths->getAllParams();
+    header('Location: ' . scriptPath . '/punbb/' . $path);
+    exit();
+  }
+  else if ( $paths->getParam(0) == 'include' && $paths->getParam(1) == 'js' )
+  {
+    $path = $paths->getAllParams();
+    header('Location: ' . scriptPath . '/punbb/' . $path);
+    exit();
+  }
   else
   {
     punano_main();
@@ -80,7 +94,7 @@
   else if ( $session->auth_level < USER_LEVEL_ADMIN )
   {
     $url = makeUrlNS('Special', 'Login/' . $paths->page, 'level=' . USER_LEVEL_ADMIN, true);
-    redirect($url, 'Permission denied', 'You need to have an active high-privilege session to set up Punano.', 4);
+    pun_redirect($url, 'Permission denied', 'You need to have an active high-privilege session to set up Punano.', 4);
   }
   
   $template->header();
@@ -115,11 +129,13 @@
 function _punano_perform_install()
 {
   global $db, $session, $paths, $template, $plugins; // Common objects
+  global $dbdriver;
+  
   $db_prefix = table_prefix . 'pun_';
   $admin_email = getConfig('contact_email');
   $pun_version = PUNBB_VERSION;
   
-  $schema = file_get_contents( ENANO_ROOT . '/punbb/schema.sql' );
+  $schema = file_get_contents( ENANO_ROOT . "/punbb/install-$dbdriver.sql" );
   if ( empty($schema) )
   {
     echo 'ERROR: cannot load schema file!';
@@ -129,7 +145,8 @@
   $replace = array(
       '{{TABLE_PREFIX}}' => $db_prefix,
       '{{ENANO_ADMIN_EMAIL}}' => $admin_email,
-      '{{PUN_VERSION}}' => $pun_version
+      '{{PUN_VERSION}}' => $pun_version,
+      '{{NOW}}' => strval(time())
     );
   
   $schema = strtr($schema, $replace);
@@ -214,6 +231,7 @@
   // At this point, the PunBB API is already loaded
   // So we'll include one of the Pun frontend files
   
+  /*
   $valid = array('delete', 'edit', 'extern', 'help', 'index', 'misc', 'moderate', 'post', 'profile', 'search', 'userlist', 'viewforum', 'viewtopic');
   
   $file = 'index';
@@ -225,26 +243,28 @@
       $file = strtolower($x);
     }
   }
+  */
+  $file = 'rewrite';
   
   // Don't worry. This is sanitized.
-  require PUN_ROOT . $file . '.php';
-  
+  $file = PUN_ROOT . $file . '.php';
+  require $file;
 }
 
 function punano_admin_console()
 {
   global $db, $session, $paths, $template, $plugins; // Common objects
   
-  $valid = array('categories', 'censoring', 'forums', 'groups', 'index', 'loader', 'maintenance', 'options', 'permissions', 'prune', 'ranks', 'reports', 'users');
-  $mod = array('bans', 'censoring', 'index', 'loader', 'reports', 'users');
+  $valid = array('bans', 'categories', 'censoring', 'extensions', 'forums', 'groups', 'index', 'options', 'prune', 'ranks', 'reindex', 'reports', 'users');
+  $mod   = array();
 
   $file = 'index';
   
-  if ( $x = $paths->getParam(0) )
+  if ( $x = $paths->getParam(1) )
   {
     $x = preg_replace('/\.php$/', '', $x);
     $x = preg_replace('/^admin_/i', '', $x);
-    if ( in_array(strtolower($x), $valid) )
+    if ( in_array(strtolower($x), $valid) || in_array(strtolower($x), $mod) )
     {
       $file = strtolower($x);
     }
@@ -265,7 +285,7 @@
   }
   
   // Don't worry. This is sanitized.
-  require PUN_ROOT . 'admin_' . $file . '.php';
+  require PUN_ROOT . 'admin/' . $file . '.php';
   
 }