plugins/ajim.php
changeset 1 7785b3e99977
parent 0 2f9b67edc9b1
--- a/plugins/ajim.php	Wed Jun 13 22:33:00 2007 -0400
+++ b/plugins/ajim.php	Sat Dec 08 13:25:13 2007 -0500
@@ -17,9 +17,9 @@
   if(defined('scriptPath'))
     define('ajimClientPath', scriptPath.'/ajim');
   
-  if(!defined('ENANO_ROOT'))
-    define('ENANO_ROOT', dirname(dirname(__FILE__)));
-  define('ajimServerPath', ENANO_ROOT.'/ajim');
+  // if(!defined('ENANO_ROOT'))
+  //   define('ENANO_ROOT', dirname(dirname(__FILE__)));
+  
   global $db, $session, $paths, $template, $plugins; // Common objects
   $__ajim_config = Array(
     'sb_color_background'=>'#FFF',
@@ -27,56 +27,63 @@
     );
   if(defined('ENANO_INSTALLED') || defined('MIDGET_INSTALLED'))
   {
-    if(!isset($_GET['admin']))
+    define('ajimServerPath', ENANO_ROOT.'/ajim');
+    
+    $plugins->attachHook('compile_template', 'AjIM_SideBar();');
+    $plugins->attachHook('acl_rule_init', 'global $session; $session->register_acl_type(\'ajim_post\', AUTH_ALLOW, \'Submit AjIM posts\');');
+    require_once(ajimServerPath . '/ajim.php');
+    
+    function AjIM_SideBar()
     {
-      $plugins->attachHook('compile_template', 'AjIM_SideBar();');
-      $plugins->attachHook('acl_rule_init', 'global $session; $session->register_acl_type(\'ajim_post\', AUTH_ALLOW, \'Submit AjIM posts\');');
-      include(ajimServerPath . '/ajim.php');
-      
-      function AjIM_SideBar()
+      global $db, $session, $paths, $template, $plugins; // Common objects
+      global $__ajim_config;
+      $paths->addAdminNode('Plugin configuration', 'AjIM configuration', 'AjIM_Config');
+      $dir = getcwd();
+      chdir(ENANO_ROOT);
+      include('config.php');
+      chdir($dir);
+      unset($dir);
+      if($session->user_level >= USER_LEVEL_ADMIN)
       {
-        global $db, $session, $paths, $template, $plugins; // Common objects
-        global $__ajim_config;
-        $paths->addAdminNode('Plugin configuration', 'AjIM configuration', 'AjIM_Config');
-        $dir = getcwd();
-        chdir(ENANO_ROOT);
-        include('config.php');
-        chdir($dir);
-        unset($dir);
-        if($session->user_level >= USER_LEVEL_ADMIN)
-        {
-          $r = $db->sql_query('SELECT password FROM '.table_prefix.'users WHERE username=\''.$session->username.'\'');
-          $p = $db->fetchrow_num($r);
-          $admin = $p[0];
-        }
-        else 
-        {
-          $admin = false;
-        }
-        $__ajim_config['db_connection_handle'] = $db->_conn;
-        if(!$session->user_logged_in)
-        {
-          $__ajim_config['cant_post_notice'] = 'The administrator requires that you <a href="'.makeUrlNS('Special', 'Login/'.$paths->page, null, true).'">log in</a> to post messages.';
-        }
-        else
-        {
-          $__ajim_config['cant_post_notice'] = 'The administrator has disallowed message posting for your user account.';
-        }
-        $canpost = ( $session->get_permissions('ajim_post') ) ? true : false;
-        $ajim = new ajim($__ajim_config, table_prefix, scriptPath.'/plugins/ajim.php', $admin, false, $canpost, array('RenderMan', 'render'));
-        $template->sidebar_widget('Shoutbox', $ajim->html(ajimClientPath));
-        $template->additional_headers .= '<link rel="stylesheet" type="text/css" href="'.ajimClientPath.'/ajim.php?css&amp;id='.$ajim->id.'&amp;pfx='.table_prefix.'&amp;path='.scriptPath.'/plugins/ajim.php" />';
+        $r = $db->sql_query('SELECT password FROM '.table_prefix.'users WHERE username=\''.$session->username.'\'');
+        $p = $db->fetchrow_num($r);
+        $admin = $p[0];
+      }
+      else 
+      {
+        $admin = false;
+      }
+      $__ajim_config['db_connection_handle'] = $db->_conn;
+      if(!$session->user_logged_in)
+      {
+        $__ajim_config['cant_post_notice'] = 'The administrator requires that you <a href="'.makeUrlNS('Special', 'Login/'.$paths->page, null, true).'">log in</a> to post messages.';
       }
+      else
+      {
+        $__ajim_config['cant_post_notice'] = 'The administrator has disallowed message posting for your user account.';
+      }
+      $canpost = ( $session->get_permissions('ajim_post') ) ? true : false;
+      $ajim = new ajim($__ajim_config, table_prefix, scriptPath.'/plugins/ajim.php', $admin, false, $canpost, array('RenderMan', 'render'));
+      $template->sidebar_widget('Shoutbox', $ajim->html(ajimClientPath));
+      $template->additional_headers .= '<link rel="stylesheet" type="text/css" href="'.ajimClientPath.'/ajim.php?css&amp;id='.$ajim->id.'&amp;pfx='.table_prefix.'&amp;path='.scriptPath.'/plugins/ajim.php" />';
     }
-  } elseif(isset($_GET['ajimmode'])) {
+  }
+  elseif ( isset($_GET['ajimmode']) )
+  {
     global $db, $session, $paths, $template, $plugins, $dbhost, $dbname, $dbuser, $dbpasswd;
     require_once('../includes/common.php');
+    define('ajimServerPath', ENANO_ROOT.'/ajim');
     require_once(ajimServerPath . '/ajim.php');
     header('HTTP/1.1 200 OK');
     define('ajimClientPath', scriptPath.'/ajim');
-    if($session->user_level >= USER_LEVEL_ADMIN) {
+    if ( $session->user_level >= USER_LEVEL_ADMIN )
+    {
       $admin = $session->grab_password_hash(); 
-    } else $admin = false;
+    }
+    else
+    {
+      $admin = false;
+    }
     require('../config.php');
     $canpost = (getConfig('ajim_require_login') != '1' || $session->user_logged_in) ? true : false;
     $__ajim_config['db_connection_handle'] = $db->_conn;