phpgroupware-cvs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Phpgroupware-cvs] old/anthill/inc class.boanthill.inc.php, 1.1 class.so


From: skwashd
Subject: [Phpgroupware-cvs] old/anthill/inc class.boanthill.inc.php, 1.1 class.soadmin.inc.php, 1.1 class.boadmin.inc.php, 1.1 class.anthill.inc.php, 1.1 anthill.inc.php, 1.1 class.soanthill.inc.php, 1.1 class.uiadmin.inc.php, 1.1 class.user_anthill.inc.php, 1.1 class.user.inc.php, 1.1 class.uiwidgets.inc.php, 1.1 class.uianthill.inc.php, 1.1 anthill.css, 1.1 config.inc.php, 1.1 hook_admin.inc.php, 1.1 sample-config.inc.php, 1.1 reportengine.php, 1.1 phpgw.inc.php, 1.1 old-functions.inc.php, 1.1 site.inc.php, 1.1
Date: Thu, 5 May 2005 02:34:00 +0200

Update of old/anthill/inc

Added Files:
     Branch: MAIN
            class.boanthill.inc.php 
            class.soadmin.inc.php 
            class.boadmin.inc.php 
            class.anthill.inc.php 
            anthill.inc.php 
            class.soanthill.inc.php 
            class.uiadmin.inc.php 
            class.user_anthill.inc.php 
            class.user.inc.php 
            class.uiwidgets.inc.php 
            class.uianthill.inc.php 
            anthill.css 
            config.inc.php 
            hook_admin.inc.php 
            sample-config.inc.php 
            reportengine.php 
            phpgw.inc.php 
            old-functions.inc.php 
            site.inc.php 

Log Message:
retiring app

====================================================
Index: class.boanthill.inc.php
<?php
  /****************************************************************************
   * Anthill                                                                  *
   * http://anthill.vmlinuz.ca                                                *
   *                                                                          *
   * Written by Vincent Danen address@hidden                              *
   *   and Dave Hall [skwashd AT phpgroupware.org]                            *
   * ------------------------------------------------------------------------ *
   * This program is free software; you can redistribute it 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.                                               *
   * ------------------------------------------------------------------------ *
   ****************************************************************************/
  // $Id: class.boanthill.inc.php,v 1.1 2005/05/05 00:34:03 skwashd Exp $

  /**
  * Common functionality class for Anthill
  */
  class boanthill
  {
    var $so;

    function boanthill()
    {
      $this->so = createObject('anthill.soanthill');
    }

    function do_diff($bid, $new_values)
    {
      $old_values = $this->get_bug($bid);
      $diff = array_diff($old_values, $new_values);
      if($diff['descr'])
      {
      }
    }

    function format_diff($txt, $chr='?')
    {
      $txt = wordwrap($txt);
      $txt = explode("\n", $txt);
      foreach($txt as $num => $line)
      {
        $txt[$num] = "$chr $line";
      }
      return implode("\n", $txt);
    }

    function get_component_info($cid, $field = 'owner')
    {
      return $this->so->get_component_info($cid, $field);
    }

    function get_components($pid, $inc_deleted = False, $order_by = 'name', 
$cid='')
    {
      return $this->so->get_components($pid, $inc_deleted, $order_by, $cid);
    }

    function get_priorities()
    {
      return $this->so->get_priorities();
    }

    function get_register_link()
    {
      return $GLOBALS['phpgw']->link('/anthill/register');
    }

    function get_products($inc_deleted = False, $pid = False)
    {
      return $this->so->get_products($inc_deleted, $pid);
    }

    function get_severities()
    {
      return $this->so->get_severities();
    }

    function get_versions($product_id, $inc_deleted = False, $order_by = 
'name', $vid=0)
    {
      return $this->so->get_versions($product_id, $inc_deleted, $order_by, 
$vid);
    }

    function set_bug($bid, $values)
    {
      $values['modified'] = time();
      if(!$bid)
      {
        $values['creation'] = $values['modified'];
        $autocc = $this->get_component_info($values['component'], 'autocc');
        $values['cc'] = ($autocc ? $autocc . ',' . 
$GLOBALS['anthill']['config']['autocc']
                         : $GLOBALS['anthill']['config']['autocc']);
        $values['reporter'] = $GLOBALS['phpgw_info']['user']['account_id'];
      }
      else
      {
        $this->do_diff($bid, $values);
      }
      return $this->so->set_bug($bid, $values);
    }
  }
?>

====================================================
Index: class.soadmin.inc.php
<?php
  /****************************************************************************
   * Anthill                                                                  *
   * http://anthill.vmlinuz.ca                                                *
   *                                                                          *
   * Written by Vincent Danen address@hidden                              *
   *   and Dave Hall [skwashd AT phpgroupware.org]                            *
   * ------------------------------------------------------------------------ *
   * This program is free software; you can redistribute it 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.                                               *
   * ------------------------------------------------------------------------ *
   ****************************************************************************/
  // $Id: class.soadmin.inc.php,v 1.1 2005/05/05 00:34:03 skwashd Exp $

  include_once(PHPGW_INCLUDE_ROOT . '/anthill/inc/class.soanthill.inc.php');

  class soadmin extends soanthill
  {
    function soadmin()
    {
      $this->soanthill();
    }

    function set_components($cid, $pid, $fields)
    {
      if($cid)// is it existing?
      {
        $sql  = 'UPDATE anthill_components ';
        $sql .= "SET name = '" . $this->db->db_addslashes($fields['name']) . 
"', ";
        $sql .= 'product =' . intval($pid) . ', ';
        $sql .= 'owner = ' . intval($fields['owner']) . ', ';
        $sql .= "description = '" . 
$this->db->db_addslashes($fields['description']) . "', ";
        $sql .= "autocc = '" . $this->db->db_addslashes($fields['autocc']) . 
"', ";
        $sql .= 'deleted = ' . (@$fields['active'] ? '0 ' : '1 ');
        $sql .= 'WHERE pid = ' . intval($pid);
        $this->db->query($sql, __LINE__, __FILE__);
        return $cid;
      }
      else //must be new
      {
        $sql  = 'INSERT INTO anthill_components(name, product, owner, 
description, autocc, deleted) ';
        $sql .= "VALUES ('" . $this->db->db_addslashes($fields['name']) . "', ";
        $sql .= intval($pid) .', ';
        $sql .= intval($fields['owner']) . ', ';
        $sql .= "'" . $this->db->db_addslashes($fields['description']) . "', ";
        $sql .= "'" . $this->db->db_addslashes($fields['autocc']) . "', ";
        $sql .= (@$fields['active'] ? 0 : 1) . ')';
        $this->db->query($sql, __LINE__, __FILE__);
        return $this->db->get_last_insert_id('anthill_components', 'cid');
      }
    }

    function set_priorities($inc_deleted = False)
    {
      $this->db->query("SELECT * FROM anthill_priority_d", __LINE__, __FILE__);
      while ($this->db->next_record())
      {
        $priority[$this->db->f('id')] = $this->db->f('name', True);
      }
      return $priority;
    }

    function set_products($pid, $fields)
    {
      echo '<pre>';
      print_r();
      echo '</pre>';

      if($pid)// is it existing?
      {
        $sql  = 'UPDATE anthill_products ';
        $sql .= "SET name = '" . $this->db->db_addslashes($fields['name']) . 
"', ";
        $sql .= "description = '" . 
$this->db->db_addslashes($fields['description']) . "', ";
        $sql .= 'deleted = ' . (@$fields['active'] ? '0 ' : '1 ');
        $sql .= 'WHERE pid = ' . intval($pid);
        $this->db->query($sql, __LINE__, __FILE__);
        return $pid;
      }
      else //must be new
      {
        $sql  = 'INSERT INTO anthill_products(name, description, deleted) ';
        $sql .= "VALUES ('" . $this->db->db_addslashes($fields['name']) . "', ";
        $sql .= "'" . $this->db->db_addslashes($fields['description']) . "', ";
        $sql .= (@$fields['active'] ? 0 : 1) . ')';
        $this->db->query($sql, __LINE__, __FILE__);
        return $this->db->get_last_insert_id('anthill_products', 'pid');
      }
    }

    function set_severities($inc_deleted = False)
    {
      $this->db->query("SELECT * FROM anthill_severity_d");
      while ($this->db->next_record())
      {
        $severity[$this->db->f('id')] = $this->db->f('name', True);
      }
      return $severity;
    }

    function set_versions($vid, $pid, $fields)
    {
      if($vid)// is it existing?
      {
        $sql  = 'UPDATE anthill_versions ';
        $sql .= "SET name = '" . $this->db->db_addslashes($fields['name']) . 
"', ";
        $sql .= 'deleted = ' . (@$fields['active'] ? '0 ' : '1 ');
        $sql .= 'WHERE vid = ' . intval($vid);
        $this->db->query($sql, __LINE__, __FILE__);
        return $vid;
      }
      else //must be new
      {
        $sql  = 'INSERT INTO anthill_versions(name, product, deleted) ';
        $sql .= "VALUES ('" . $this->db->db_addslashes($fields['name']) . "', ";
        $sql .= intval($pid) . ', ';
        $sql .= (@$fields['active'] ? '0' : '1') . ')';
        $this->db->query($sql, __LINE__, __FILE__);
        return $this->db->get_last_insert_id('anthill_versions', 'vid');
      }
    }
  }
?>

====================================================
Index: class.boadmin.inc.php
<?php
  /****************************************************************************
   * Anthill                                                                  *
   * http://anthill.vmlinuz.ca                                                *
   *                                                                          *
   * Written by Vincent Danen address@hidden                              *
   *   and Dave Hall [skwashd AT phpgroupware.org]                            *
   * ------------------------------------------------------------------------ *
   * This program is free software; you can redistribute it 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.                                               *
   * ------------------------------------------------------------------------ *
   ****************************************************************************/
  // $Id: class.boadmin.inc.php,v 1.1 2005/05/05 00:34:03 skwashd Exp $

  /**
  * Common functionality class for Anthill
  */

  include_once(PHPGW_INCLUDE_ROOT . '/anthill/inc/class.boanthill.inc.php');

  class boadmin extends boanthill
  {
    var $so;

    function boadmin()
    {
      $this->so = createObject('anthill.soadmin');
    }

    function get_admin_menu()
    {
       if (isset($GLOBALS['phpgw_info']['user']['apps']['admin']))
       {
          $menu['manage products'] = $GLOBALS['phpgw']->link('/index.php', 
array('menuaction' => 'anthill.uiadmin.products'));
       }
       return $menu;
    }

    function set_component($cid, $pid, $fields)
    {
      return $this->so->set_components($cid, $pid, $fields);
    }

    function set_products($pid, $fields)
    {
      return $this->so->set_products($pid, $fields);
    }

    function set_versions($vid, $pid, $fields)
    {
      return $this->so->set_versions($vid, $pid, $fields);
    }

    function prod_id2name($pid)
    {
        return $this->so->prod_id2name($pid);
    }

    function ver_id2name($pid)
    {
        return $this->so->prod_id2name($pid);
    }

  }
?>

====================================================
Index: class.anthill.inc.php
<?php
  /****************************************************************************
   * Anthill                                                                  *
   * http://anthill.vmlinuz.ca                                                *
   *                                                                          *
   * Written by Vincent Danen address@hidden                              *
   *   and Dave Hall [skwashd AT phpgroupware.org]                            *
   * ------------------------------------------------------------------------ *
   * This program is free software; you can redistribute it 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.                                               *
   * ------------------------------------------------------------------------ *
   ****************************************************************************/
  // $Id: class.anthill.inc.php,v 1.1 2005/05/05 00:34:03 skwashd Exp $

  class anthill
  {
    var $db;
    var $sessions;
    var $tpl;
    var $user;

    function anthill()
    {
      if ($GLOBALS['anthill_info']['mode'] == 'phpgw')
      {
        $this->db             = $GLOBALS['phpgw']->db;
        $this->user     = createObject('anthill.user');
        $this->sessions = $GLOBALS['phpgw']->sessions;
        $this->tpl      = createObject('phpgwapi.Template');
        
$GLOBALS['anthill']->tpl->set_root($GLOBALS['anthill_info']['path']['tpl_dir']);
      }
    }

    function css()
    {
      return '';
    }

    function link($page, $extravars = '')
    {
      if ($GLOBALS['anthill_info']['mode'] != 'anthill')
      {
        return $GLOBALS['phpgw']->link($page, $extravars);
      }
      else
      {
        return $this->sessions->link($page, $extravars);
      }
    }

    function get_img($img)
    {
      if ($GLOBALS['anthill_info']['mode'] == 'anthill')
      {
        $tpl_dir = $GLOBALS['anthill_info']['path']['tpl_dir'] . '/images/';
        $def_dir = $GLOBALS['anthill_info']['path']['root'] . 
'/templates/default/images/';
        $tpl_url = $GLOBALS['anthill_info']['path']['wtpl_dir'] . '/images/';
        $def_url = $GLOBALS['anthill_info']['path']['webroot'] . 
'/templates/default/images/';

        if ($GLOBALS['anthill_info']['path']['tpl'] != 'default')
        {
          if(is_file("$tpl_dir$img.png"))
          {
            return "$tpl_url$img.png";
          }

          if(is_file("$tpl_dir$img.jpg"))
          {
            return "$tpl_url$img.jpg";
          }

          if(is_file("$tpl_dir$img.gif"))
          {
            return "$tpl_url$img.gif";
          }
        }

        if(is_file("$def_dir$img.png"))
        {
          return "$def_url$img.png";
        }

        if(is_file("$def_dir$img.jpg"))
        {
          return "$def_url$img.jpg";
        }

        if(is_file("$def_dir$img.gif"))
        {
          return "$def_url$img.gif";
        }
        //somthing is wrong
        return '';
      }
    }
  }
?>

====================================================
Index: anthill.inc.php
<?php
  /****************************************************************************
   * Anthill                                                                  *
   * http://anthill.vmlinuz.ca                                                *
   *                                                                          *
   * Written by Vincent Danen address@hidden                              *
   *   and Dave Hall [skwashd AT phpgroupware.org]                            *
   * ------------------------------------------------------------------------ *
   * This program is free software; you can redistribute it 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.                                               *
   * ------------------------------------------------------------------------ *
   ****************************************************************************/
   // $Id: anthill.inc.php,v 1.1 2005/05/05 00:34:03 skwashd Exp $

   // the basic includes we need for Anthill to function
   // formerly in site.inc.php

   // are these constansts really needed?
   define("_VERSION","0.3.0alpha");
   define("_NAME","Anthill");


   // setup the master object
   $GLOBALS['anthill'] = createObject('anthill.anthill');

   // setup the db connection
   $GLOBALS['anthill']->db       = createObject('anthill.db');
   $GLOBALS['anthill']->db->Host     = $GLOBALS['anthill_info']['db']['host'];
   $GLOBALS['anthill']->db->Database = $GLOBALS['anthill_info']['db']['name'];
   $GLOBALS['anthill']->db->User     = $GLOBALS['anthill_info']['db']['user'];
   $GLOBALS['anthill']->db->Password = $GLOBALS['anthill_info']['db']['pw'];
   $GLOBALS['anthill']->db->connect();

   $GLOBALS['anthill']->user     = createObject('anthill.user');
   $GLOBALS['anthill']->sessions = createObject('anthill.sessions');
   $GLOBALS['anthill']->tpl      = createObject('anthill.Template');
   
$GLOBALS['anthill']->tpl->set_root($GLOBALS['anthill_info']['path']['tpl_dir']);

   load_config();


  // run a series of configuration tests
  // test to make sure that things are configured on the system properly
  // original work by Vincent Danen
  function configtest()
  {
    $error = False;
    if (!is_dir($GLOBALS['anthill_info']['path']['shadow']) || 
!is_writable($GLOBALS['anthill_info']['path']['shadow']))
    {
      echo '<p><b><font color="red">' . gettext("shadow is not writable; please 
notify the administrator.") . '</font></b></p>';
      $error = True;
    }

    if (!is_dir($GLOBALS['anthill_info']['path']['tmp']) || 
!is_writable($GLOBALS['anthill_info']['path']['tmp']))
    {
      echo '<p><b><font color="red">' . gettext("temporary directory is not 
writable; please notify the administrator.") . '</font></b></p>';
      $error = True;
    }

    $localgpgdir = $GLOBALS['anthill_info']['path']['root'] . 
$GLOBALS['anthill_info']['path']['gpgdir'];
    if (!is_dir($localgpgdir) || !is_writable($localgpgdir))
    {
      echo '<p><b><font color="red">' . gettext("gnupg storage directory is not 
writable; please notify the administrator.") . '</font></b></p>';
      $error = True;
    }

    $localattdir = $GLOBALS['anthill_info']['path']['root'] . 
$GLOBALS['anthill_info']['path']['attachdir'];
    if (!is_dir($localattdir) || !is_writable($localattdir))
    {
      echo '<p><b><font color="red">' . gettext("attachments directory is not 
writable; please notify the administrator.") . '</font></b></p>';
      $error = True;
    }

    if (ini_get('safe_mode') == 1) // are in safe_mode
    {
      if (ini_get('safe_mode_exec_dir') == "")
      {
        echo '<p><b><font color=red>' . gettext("safe_mode enabled, but no 
safe_mode_exec_dir defined - diff will be unable to run; please notify the 
administrator.") . '</font></b></p>';
        $error = True;
      } else // let's make sure that our difftool is in the exec_dir
      {
        if 
(!ereg(ini_get('safe_mode_exec_dir'),$GLOBALS['anthill_info']['difftool']))
        {
          echo '<p><b><font color=red>' . gettext("diff is not in 
safe_mode_exec_dir and will not be able to run; please notify the 
administrator.") . '</font></b></p>';
          $error = True;
        }
      }
    }
    if ($error)
    {
      exit; //misconfigured
    }
  }

   // CreateObject
   // Originally taken from DoubleChocoLatte - http://dcl.sf.net
   // Tweaked by Dave Hall
   // This function is licensed under the GPL
   function CreateObject($class)
   {
     $class = substr($class, 8); //strip the anthill. which is required by phpgw
     if (file_exists($GLOBALS['anthill_info']['path']['inc'] . '/class.' . 
$class . '.inc.php'))
     {
       include_once($GLOBALS['anthill_info']['path']['inc'] . '/class.' . 
$class . '.inc.php');
     }
     else
     {
       echo '<p><b><font color="red">ERROR: class. ' . $class . '.inc.php does 
not exist!!</font></b></p>';
       exit;
     }
     $obj = new $class;
     return $obj;
   }

   // lang
   // phpGroupWare compatiable translation call
   // Written by Dave Hall
   // This function is licensed under the GPL
   function lang($phrase, $var1='', $var2='', $var3='')
   {
     $phrase = ereg_replace('%[0-9]','%s', $phrase);
     $phrase = gettext("$phrase"); //enforce the double quotes
     return sprintf($phrase, $var1, $var2, $var3);
   }

   // load the config info
   function load_config()
   {
     configtest();
     $GLOBALS['anthill']->db->query('SELECT * FROM anthill_config');
     while ($GLOBALS['anthill']->db->next_record())
     {
       $GLOBALS['anthill_info']['config'][$GLOBALS['anthill']->db->f('name', 
true)] = $GLOBALS['anthill']->db->f('value', true);
     }
   }

   // get_var
   // Adapted from phpGroupWare
   // Written by Dave Hall
   // This function is licensed under the GPL
   function get_var($varname, $method = 'any', $default='')
   {
     //echo 'get_var(' . $varname . ',' . $method .') called<br>';
     if ($method == 'any')
     {
       $method = Array('GLOBAL','GET','POST','COOKIE','SERVER','DEFAULT');
     }
     elseif (!is_array($method))
     {
       $method = Array($method);
     }

     foreach ($method as $var_type)
     {
       //echo 'checking ' . $var_type . ' for ' . $varname .'<br>';
       switch(strtoupper($var_type))
       {
         case 'DEFAULT':
           if ($default)
           {
             $value = $default;
             break 2;
           }
           break;

         case 'GLOBAL':
           if (@isset($GLOBALS[$varname]))
           {
             $value = $GLOBALS[$varname];
             break 2;
           }
           break;

         case 'GET':
           if (@isset($_GET[$varname]))
           {
             $value = $_GET[$varname];
             break 2;
           }
           break;
         case 'POST':
           if (@isset($_POST[$varname]))
           {
             $value = $_POST[$varname];
             break 2;
           }
           break;
         case 'COOKIE':
           if (@isset($_COOKIE[$varname]))
           {
             $value = $_COOKIE[$varname];
             break 2;
           }
           break;
         case 'SERVER':
           if (@isset($_SERVER[$varname]))
           {
             $value = $_SERVER[$varname];
             break 2;
           }
           break;
         default:
           if (@isset($GLOBALS[$var_type][$varname]))
           {
             $value = $GLOBALS[$var_type][$varname];
             break 2;
           }
         break;
      } // switch
    }

    if (@!isset($value))
    {
      $value = $default_value;
    }
    return $value;
  }
?>

====================================================
Index: class.soanthill.inc.php
<?php
  /****************************************************************************
   * Anthill                                                                  *
   * http://anthill.vmlinuz.ca                                                *
   *                                                                          *
   * Written by Vincent Danen address@hidden                              *
   *   and Dave Hall [skwashd AT phpgroupware.org]                            *
   * ------------------------------------------------------------------------ *
   * This program is free software; you can redistribute it 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.                                               *
   * ------------------------------------------------------------------------ *
   ****************************************************************************/
  // $Id: class.soanthill.inc.php,v 1.1 2005/05/05 00:34:03 skwashd Exp $

  class soanthill
  {
    var $db;

    function soanthill()
    {
      $this->db = $GLOBALS['phpgw']->db;
    }

    function get_component_info($cid, $field = 'owner')
    {
      $sql  = 'SELECT ' . $this->db->db_addslashes($field) . ' FROM 
anthill_components ';
      $sql .= 'WHERE cid = ' . intval($cid);
      $this->db->query($sql, __LINE__, __FILE__);
      if ($this->db->next_record())
      {
        return $this->db->f('owner');
      }
      else
      {
        return False;
      }
    }

    function get_components($product_id, $inc_deleted = False, $order_by = 
'name', $cid = '')
    {
      $sql  = 'SELECT * FROM anthill_components ';
      if(!$cid)
      {
        $sql .= 'WHERE product = ' . intval($product_id) .' ';
        $sql .= ($inc_deleted ? '' : 'AND deleted = 0 ');
        $sql .= 'ORDER BY ' . $this->db->db_addslashes($order_by);
        $this->db->query($sql, __LINE__, __FILE__);
        while ($this->db->next_record())
        {
          $components[$this->db->f('cid')] = $this->db->f('name', True);
        }
      }
      else
      {
        $sql .= 'WHERE cid=' . intval($cid);
        $this->db->query($sql, __LINE__, __FILE__);
        while($this->db->next_record())
        {
          $components[$this->db->f('cid')] = array('name'        => 
$this->db->f('name'),
                                                   'pid'         => 
$this->db->f('product'),
                                                   'owner'       => 
$this->db->f('owner'),
                                                   'description' => 
$this->db->f('description',True),
                                                   'autocc'      => 
$this->db->f('autocc', True),
                                                   'active'      => (bool) 
!$this->db->f('deleted')
                                                   );
        }
      }
      return $components;
    }

    function get_priorities($inc_deleted = False)
    {
      $this->db->query("SELECT * FROM anthill_priority_d");
      while ($this->db->next_record())
      {
        $priority[$this->db->f('id')] = $this->db->f('name', True);
      }
      return $priority;
    }

    function get_products($inc_deleted = False, $pid = False)
    {
      $sql  = 'SELECT * FROM anthill_products ';
      if(!$pid)
      {
        $sql .= ($inc_deleted ? '' : 'WHERE deleted = 0 ');
      }
      else
      {
        $sql .= 'WHERE pid = ' . intval($pid);
      }

      $this->db->query($sql, __LINE__, __FILE__);
      while ($this->db->next_record())
      {
        $products[$this->db->f('pid')] = array('name'        => 
$this->db->f('name', True),
                                              'deleted'     => (bool) 
!$this->db->f('deleted'),
                                              'description' => 
$this->db->f('description', True),
                                              );
      }
      return $products;
    }

    function get_severities($inc_deleted = False)
    {
      $this->db->query("SELECT * FROM anthill_severity_d");
      while ($this->db->next_record())
      {
        $severity[$this->db->f('id')] = $this->db->f('name', True);
      }
      return $severity;
    }

    function get_versions($product_id, $inc_deleted = False, $order_by = 
'name', $vid=0)
    {
      $sql  = 'SELECT * FROM anthill_versions ';
      if(!$vid)
      {
        $sql .= 'WHERE product = ' . intval($product_id) .' ';
        $sql .= ($inc_deleted ? '' : 'AND deleted = 0 ');
        $sql .= 'ORDER BY ' . $this->db->db_addslashes($order_by);
        $this->db->query($sql, __LINE__, __FILE__);
        while ($this->db->next_record())
        {
          $versions[$this->db->f('vid')] = $this->db->f('name', True);
        }
      }
      else
      {
        $sql .= 'WHERE vid = ' . intval($vid) .' ';
               $this->db->query($sql, __LINE__, __FILE__);
        while ($this->db->next_record())
        {
          $versions[$this->db->f('vid')] = array('name'    => 
$this->db->f('name', True),
                                                 'active'  => (bool) 
!$this->db->f('deleted')
                                                 );
        }
      }
      return $versions;
    }

    function prod_id2name($pid)
    {
        $sql  = 'SELECT name FROM anthill_products WHERE pid=' . intval($pid);
      $this->db->query($sql);
      if($this->db->next_record())
      {
        return $this->db->f('name',True);
      }
      else
      {
        return '';
      }
    }

    function ver_id2name($vid)
    {
        $sql  = 'SELECT name FROM anthill_versions WHERE pid=' . intval($vid);
      $this->db->query($sql);
      if($this->db->next_record())
      {
        return $this->db->f('name',True);
      }
      else
      {
        return '';
      }
    }

    function set_bug($bid, $values)
    {
      if($bid)
      {
         //edit code to go here!
      }
      else
      {
        $sql  = 'INSERT INTO anthill_bugs (assigned, severity, status, 
creation, ';
        $sql .= 'modified, shortdesc, priority, product, reporter, version, ';
        $sql .= 'component, cc, private, url) VALUES';
        $sql .= "('" . $this->db->db_addslashes($values['assigned']) . "',";
        $sql .= intval($values['severity']) . ',' . intval($values['status']) 
.',';
        $sql .= intval($values['creation']) .',' . intval($values['modified']) 
. ',';
        $sql .= "'" . $this->db->db_addslashes($shortdesc) . "',";
        $sql .= intval($values['priority']) . ',' . intval($values['product']) 
. ',';
        $sql .= intval($values['reporter']) . ',' . intval($value['version']) . 
',';
        $sql .= intval($values['component']) . ",'" . 
$this->db->db_addslashes($values['cc']) ."',";
        $sql .= "0,'" . $this->db->db_addslashes($values['url']) . "')";
        //      ^^^ must change just got lazy

        $this->db->query($sql, __LINE__, __FILE__);
        return $this->db->get_last_insert_id('anthill_bugs', 'bid');
      }
    }
  }
?>

====================================================
Index: class.uiadmin.inc.php
<?php
  /****************************************************************************
   * Anthill                                                                  *
   * http://anthill.vmlinuz.ca                                                *
   *                                                                          *
   * Written by Vincent Danen address@hidden                              *
   *   and Dave Hall [skwashd AT phpgroupware.org]                            *
   * ------------------------------------------------------------------------ *
   * This program is free software; you can redistribute it 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.                                               *
   * ------------------------------------------------------------------------ *
   ****************************************************************************/
   // $Id: class.uiadmin.inc.php,v 1.1 2005/05/05 00:34:03 skwashd Exp $

   class uiadmin
   {
     var $bo;
     var $t;
     var $widgets;
     var $public_functions = array(
       'components' => True,
       'editcomp'   => True,
       'editprod'   => True,
       'editver'    => True,
       'index'      => True,
       'products'   => True,
       'versions'   => True,
     );

     function uiadmin()
     {
       if (!isset($GLOBALS['phpgw_info']['user']['apps']['admin']))
       {
         $GLOBALS['phpgw']->redirect_link('/index.php', array('menuaction' => 
'anthill.uianthill.denied'));
         exit;
       }
       $this->bo = CreateObject('anthill.boadmin');
       $this->t = &$GLOBALS['phpgw']->template;
       $this->t->set_root($GLOBALS['phpgw']->common->get_tpl_dir('anthill'));
       $this->t->set_unknowns('remove');
       $this->widgets = createObject('anthill.uiwidgets');
     }

     function editprod()
     {
       $pid = get_var('pid', array('GET', 'POST'), False);

       echo '<pre>';
       print_r($_POST);
       echo '</pre>';

       if($_POST['submitit'])
       {
         $fields = $_POST['fields'];
         $pid = $this->bo->set_products($pid, $fields);
       }

       if($pid)
       {
         list($pid, $pinfo) = @each($this->bo->get_products(False, $pid));
       }

       $GLOBALS['phpgw']->common->phpgw_header();
       echo parse_navbar();
       $this->widgets->render_header('admin: edit product');

       $this->t->set_file('editprod', 'editprod.tpl');
       $this->t->set_var('action', $GLOBALS['phpgw']->link('/index.php',
         array('menuaction' => 'anthill.uiadmin.editprod')));

       if(!empty($pinfo) && is_array($pinfo))
       {
         foreach($pinfo as $key => $val)
         {
           $this->t->set_var("value_$key", htmlspecialchars($val));
         }
         $this->t->set_var('value_active', ($pinfo['active'] ? 'CHECKED' : ''));
       }

       $this->t->set_var(array('lang_edit_product' => lang('edit product'),
                               'lang_product'      => lang('product'),
                               'lang_description'  => lang('description'),
                               'lang_active'                     => 
lang('active'),
                               'lang_save'         => lang('save'),
                               'lang_undo'         => lang('undo'),
                               'lang_done'         => lang('done'),
         ));

       $this->t->set_var('cancel_url', $GLOBALS['phpgw']->link('/index.php',
         array('menuaction' => 'anthill.uiadmin.products')));

       $this->t->pfp('out', 'editprod');
       $this->widgets->render_footer();
     }

     function editcomp()
     {
       $pid = $_GET['pid'];
       $cid = get_var('cid', array('GET', 'POST'), False);
       $sbox = createObject('phpgwapi.sbox2');

       if($_POST['submitit'])
       {
         $fields = $_POST['fields'];
         $cid = $this->bo->set_component($cid, $pid, $fields);
       }

       if($cid)
       {
         list($cid, $cinfo) = @each($this->bo->get_components($pid, False, '', 
$cid));
       }

       $GLOBALS['phpgw']->common->phpgw_header();
       echo parse_navbar();
       $this->widgets->render_header('admin: edit components');

       $this->t->set_file('editcomp', 'editcomp.tpl');
       $this->t->set_var('action', $GLOBALS['phpgw']->link('/index.php',
         array('menuaction' => 'anthill.uiadmin.editcomp', 'pid' => $pid)));

       if(!empty($cinfo) && is_array($cinfo))
       {
         foreach($cinfo as $key => $val)
         {
           $this->t->set_var("value_$key", htmlspecialchars($val));
         }
         $this->t->set_var('value_active', ($cinfo['active'] ? 'CHECKED' : ''));
       }
       $this->t->set_var('value_owner', 
$sbox->getAccount('fields[owner]',$cinfo['owner'],1));

       $this->t->set_var(array('lang_edit_component' => lang('edit component'),
                               'lang_component'      => lang('component'),
                               'lang_description'    => lang('description'),
                               'lang_owner'          => lang('owner'),
                               'lang_autocc'         => lang('autocc'),
                               'lang_active'         => lang('active'),
                               'lang_save'           => lang('save'),
                               'lang_undo'           => lang('undo'),
                               'lang_done'           => lang('done'),
         ));

       $this->t->set_var('cancel_url', $GLOBALS['phpgw']->link('/index.php',
         array('menuaction' => 'anthill.uiadmin.components', 'pid' => $pid)));

       $this->t->pfp('out', 'editcomp');
       $this->widgets->render_footer();
     }

     function editver()
     {
       $pid = $_GET['pid'];
       $vid = get_var('vid', array('GET', 'POST'), False);

       if($_POST['submitit'])
       {
         $fields = $_POST['fields'];
         $vid = $this->bo->set_versions($vid, $pid, $fields);
       }

       if($vid)
       {
         list($vid, $vinfo) = @each($this->bo->get_versions($pid, False, '', 
$vid));
       }

       $GLOBALS['phpgw']->common->phpgw_header();
       echo parse_navbar();
       $this->widgets->render_header('admin: edit versions');

       $this->t->set_file('editver', 'editver.tpl');
       $this->t->set_var('action', $GLOBALS['phpgw']->link('/index.php',
         array('menuaction' => 'anthill.uiadmin.editver', 'pid' => $pid)));

       if(!empty($vinfo) && is_array($vinfo))
       {
         foreach($vinfo as $key => $val)
         {
           $this->t->set_var("value_$key", htmlspecialchars($val));
         }
         $this->t->set_var('value_active', ($vinfo['active'] ? 'CHECKED' : ''));
       }

       $this->t->set_var(array('lang_edit_version' => lang('edit version'),
                               'lang_version'      => lang('version'),
                               'lang_active'                     => 
lang('active'),
                               'lang_save'         => lang('save'),
                               'lang_undo'         => lang('undo'),
                               'lang_done'         => lang('done'),
         ));

       $this->t->set_var('cancel_url', $GLOBALS['phpgw']->link('/index.php',
         array('menuaction' => 'anthill.uiadmin.versions', 'pid' => $pid)));

       $this->t->pfp('out', 'editver');
       $this->widgets->render_footer();
     }

     function index()
     {
       $GLOBALS['phpgw']->common->phpgw_header();
       echo parse_navbar();
       $this->widgets->render_header('administration');
       echo 'Admin Menu<br>';

       foreach($this->bo->get_admin_menu() as $text => $link)
       {
         echo "<a href=\"$link\">" . lang($text) . "</a><br>\n";
       }

       $this->widgets->render_footer();
     }

     function components()
     {
       $pid = $_GET['pid'];
       $prodname = $this->bo->prod_id2name($pid);

       $GLOBALS['phpgw']->common->phpgw_header();
       echo parse_navbar();
       $this->widgets->render_header('admin: edit components');

       if(!$prodname) //invlaid product - stop'em dead!
       {
         echo '<a href="' . $GLOBALS['phpgw']->link('/index.php',
                        array('menuaction' => 'anthill.uiadmin.products')) . 
'">'
           . lang('invalid product - return to products') . '</a>';

         $this->widgets->render_footer();
         exit;
       }

       $url = $GLOBALS['phpgw']->link('/index.php',
               array('menuaction' => 'anthill.uiadmin.editcomp', 'pid' => 
$pid));

       $components = $this->bo->get_components($pid, True);
       $this->t->set_file('compselect', 'compselect.tpl');
       $this->t->set_block('compselect', 'component', 'components');
       $this->t->set_var('lang_comp_4_product', lang('edit components for: %1', 
$prodname));

       if(!empty($components) && is_array($components))// do we have versions?
       {
         foreach($components as $cid => $cinfo)
         {
           $this->t->set_var('url', $url);
           $this->t->set_var('cid', $cid);
           $this->t->set_var('name', lang('edit: %1', $cinfo));
           $this->t->parse('components', 'component', True);
         }
       }

       $this->t->set_var('lang_add_new_component', lang('add new component'));
       $this->t->set_var('url_add_new_component', $url .'&cid=0');

       $this->t->pfp('out', 'compselect');
       $this->widgets->render_footer();
     }

     function products()
     {
       $GLOBALS['phpgw']->common->phpgw_header();
       echo parse_navbar();
       $this->widgets->render_header('admin: select product');

       $url = $GLOBALS['phpgw']->link('/index.php',
               array('menuaction' => 'anthill.uiadmin.editprod'));

       $this->t->set_file('prodselect', 'prodselect.tpl');
       $this->t->set_block('prodselect', 'product', 'products');

       $products = $this->bo->get_products();

       if(!empty($products) && is_array($products))// do we have products?
       {
         foreach($products as $pid => $pinfo)
         {
           $this->t->set_var('url', $url);
           $this->t->set_var('pid', $pid);
           $this->t->set_var($pinfo);
           $this->t->set_var('extra', '<a href="' . 
$GLOBALS['phpgw']->link('/index.php',
                        array('menuaction' => 'anthill.uiadmin.versions', 'pid' 
=> $pid)) . '">'
             .lang('edit versions') . '</a> - <a href="' . 
$GLOBALS['phpgw']->link('/index.php',
                        array('menuaction' => 'anthill.uiadmin.components', 
'pid' => $pid)) . '">'
             .lang('edit components') . '</a>');
           $this->t->parse('products', 'product', True);
         }
       }

       $this->t->set_var('url_add', $url .'&pid=0');
       $this->t->set_var('lang_add', lang('add product'));

       $this->t->pfp('out', 'prodselect');
       $this->widgets->render_footer();
     }

     function versions()
     {
       $GLOBALS['phpgw']->common->phpgw_header();
       echo parse_navbar();
       $this->widgets->render_header('admin: select version');

       $pid = $_GET['pid'];
       $prodname = $this->bo->prod_id2name($pid);

       if(!$prodname) //invlaid product - stop'em dead!
       {
         echo '<a href="' . $GLOBALS['phpgw']->link('/index.php',
                        array('menuaction' => 'anthill.uiadmin.products')) . 
'">'
           . lang('invalid product - return to products') . '</a>';

         $this->widgets->render_footer();
         exit;
       }

       $url = $GLOBALS['phpgw']->link('/index.php',
               array('menuaction' => 'anthill.uiadmin.editver', 'pid' => $pid));

       $versions = $this->bo->get_versions($pid, True);
       $this->t->set_file('verselect', 'verselect.tpl');
       $this->t->set_block('verselect', 'version', 'versions');
       $this->t->set_var('lang_vers_4_product', lang('edit versions for: %1', 
$prodname));

       if(!empty($versions) && is_array($versions))// do we have versions?
       {
         foreach($versions as $vid => $vinfo)
         {
           $this->t->set_var('url', $url);
           $this->t->set_var('vid', $vid);
           $this->t->set_var('name', lang('edit: %1', $vinfo));
           $this->t->parse('versions', 'version', True);
         }
       }

       $this->t->set_var('lang_add_new_version', lang('add new version'));
       $this->t->set_var('url_add_new_version', $url .'&vid=0');

       $this->t->pfp('out', 'verselect');
       $this->widgets->render_footer();
     }
   }
?>

====================================================
Index: class.user_anthill.inc.php
<?php
    
/***************************************************************************\
    * Anthill                                                                   
*
    * http://anthill.vmlinuz.ca                                                 
*
    * Written by Vincent Danen address@hidden                               *
    *   and Dave Hall [skwashd AT phpgroupware.org]                             
*
    * ------------------------------------------------------------------------  
*
    *  This program is free software; you can redistribute it 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.                                               
*
    *  ------------------------------------------------------------------------ 
*
    
\***************************************************************************/
    /* $Id: class.user_anthill.inc.php,v 1.1 2005/05/05 00:34:03 skwashd Exp $ 
*/

    class user extends user_
    {
      var $db;

      function user()
      {
        $this->db = $GLOBALS['anthill']->db; //clone to prevent accidential 
free call
      }

      function auth($uname,$passwd)
      {
        $sql  = 'SELECT * ';
        $sql .= 'FROM anthill_users ';
        $sql .= "WHERE uname = '" . $this->db->db_addslashes($uname) . "' ";
        $sql .= 'AND deleted = 0 ';
        $sql .= "AND passwd = '" . md5($passwd) . "'";
        $this->db->query($sql, __LINE__, __FILE__);
        if (!$this->db->next_record())
        {
          return False;
        }

        $GLOBALS['anthill_info']['user'] = array(
          'account_id'    => $this->db->f('uid'),
          'name'          => $this->db->f('name', True),
          'lid'           => $this->db->f('uname'),
          'email'         => $this->db->f('email', True),
          'access'        => intval($this->db->f('access', True)),
          'laston'        => $this->db->f('thison'),
          'gpg'           => $this->db->f('gpg', True),
          'email_updates' => (bool) $this->db->f('email_updates')
        );

        $sql  = 'UPDATE anthill_users ';
        $sql .= 'SET laston = ' . 
intval(@$GLOBALS['anthill_info']['user']['laston']) . ', ';
        $sql .= 'thison = ' . time() . ' ';
        $sql .= 'WHERE uid = ' . 
@$GLOBALS['anthill_info']['user']['account_id'];
        $this->db->query($sql, __LINE__, __FILE__);

        return True;
      }

      function get_rights($uid=False)
      {
        //echo "checking for $uid:";
        if ($uid === False)
        {
          //echo ' using current uid';
          if (isset($GLOBALS['anthill_info']['user']['access']))
          {
            //echo ' db call not required<br>';
            $rights = $GLOBALS['anthill_info']['user']['access'];
          }
          else
          {
            //echo ' db call required for uid: ' . 
$GLOBALS['anthil_info']['user']['account_id'] .'<br>';
            $rights = 
$this->read_rights($GLOBALS['anthil_info']['user']['account_id']);
          }
        }
        elseif(uid === 0)
        {
          $rights = 0;
        }
        else
        {
          $rights = $this->read_rights($uid);
        }
        return $rights;
      }

      function read_rights($uid)
      {
        //echo "checking for $uid: ";
        $sql  = 'SELECT access ';
        $sql .= 'FROM anthill_users ';
        $sql .= 'WHERE uid = ' . intval($uid);

        $this->db->query($sql, __LINE__, __FILE__);
        if ($this->db->next_record())
        {
          //echo 'FOUND<br>';
          $rights = intval($this->db->f('access'));
        }
        else
        {
          //echo 'NOT FOUND<br>';
          $rights = 0;//for anon user or user not found
        }
        return $rights;
      }


      function get_user_list($rights, $inc_deleted=False)
      {
        $sql  = 'SELECT * FROM anthill_users ';
        $sql .= 'WHERE access >= ' . intval($rights) . ' ';
        $sql .= ($inc_deleted ? '' : 'AND deleted = 0 ');
        $sql .= 'ORDER BY uname';
        $this->db->query($sql, __LINE__, __FILE__);

        while($this->db->next_record())
        {
          $users[$this->db->f('uid')] = array('uname'   => 
$this->db->f('uname', True),
                                              'name'    => $this->db->f('name', 
True),
                                              'email'   => 
$this->db->f('email', True),
                                              'access'  => 
intval($this->db->f('access')),
                                              'updates' => (bool) 
$this->db->f('email_updates'),
                                              'deleted' => (bool) 
$this->db->f('deleted'),
                                             );
        }
        return $users;
      }

      function id2name($uid)
      {
        $sql  = 'SELECT uname ';
        $sql .= 'FROM anthill_users ';
        $sql .= "WHERE uname ='" . intval($uid) . "'";
        $this->db->query($sql, __LINE__, __FILE__);
        if ($this->db->next_record())
        {
          return $this->db->f('uname', True);
        }
        else
        {
          return False;
        }
      }

      function is_admin($uid=0)
      {
        if ($GLOBALS['anthill_info']['user']['access'] >= 
$GLOBALS['anthill_info']['config']['adminac'])
        {
          return True;
        }
        else
        {
          return False;
        }
      }

      function name2id($uname)
      {
        $sql  = 'SELECT uid ';
        $sql .= 'FROM anthill_users ';
        $sql .= "WHERE uname ='" . $this->db->db_addslashes($uname) . "'";
        $this->db->query($sql, __LINE__, __FILE__);

        if ($this->db->next_record())
        {
          return $this->db->f('uid');
        }
        else
        {
          return false;
        }
      }

      // generate new random password
      // based on code from PHP-Nuke
      // enhanced for readability and improved "randomness" by skwashd
      function random_password($uname)
      {
        $syllables = 
'er,in,tia,wol,fe,pre,vet,jo,nes,al,len,son,cha,ir,ler,bo,ok,tio,nar,sim,ple,bla,ten,toe,cho,co,lat,spe,ak,er,po,co,lor,pen,cil,li,ght,wh,at,the,he,ck,is,mam,bo,no,fi,ve,any,way,pol,iti,cs,ra,dio,sou,rce,sea,rch,pa,per,com,bo,sp,eak,st,fi,rst,gr,oup,boy,ea,gle,tr,ail,bi,ble,brb,pri,dee,kay,en,be,se';
        $syllable_array = explode(",", $syllables);

        mt_srand(microtime()*1000000);

        $pass='';
        for ($count=1; $count<=4; $count++)
        {
          if (mt_rand()%10 == 1)
          {
            $pass .= (mt_rand()%50) +1;
          }
          else
          {
            $pass .= $syllable_array[mt_rand(0, count($syllable_array) -1)];
          }
        }
        return $pass;
      }

      function get_user_data($uid)
      {
        $sql  = 'SELECT * ';
        $sql .= 'FROM anthill_users ';
        $sql .= 'WHERE uid = ' . intval($uid);
        $this->db->query($sql, __LINE__, __FILE__);
        if (!$this->db->next_record())
        {
          return False;
        }

        return array(
          'account_id'    => $this->db->f('uid'),
          'name'          => $this->db->f('name', True),
          'lid'           => $this->db->f('uname'),
          'email'         => $this->db->f('email', True),
          'access'        => intval($this->db->f('access', True)),
          'laston'        => $this->db->f('thison'),
          'gpg'           => $this->db->f('gpg', True),
          'email_updates' => (bool) $this->db->f('email_updates')
        );
       }


      // checks to see if user already exists in the db
      // written by skwashd
      function user_exists($uname, $email, $uid=0)
      {
        //stop the use of system usernames
        if (@$GLOBALS['anthill_info']['global_denied_users'][$uname])
        {
          return array('ERROR: Username is reserved.');
        }

        $sql  = 'SELECT * FROM anthill_users ';
        $sql .= 'WHERE deleted = 0 ';
        $sql .= "AND (uname='" . $this->db->db_addslashes($uname) ."' ";
        $sql .= "OR email='" . $this->db->db_addslashes($email) ."') ";

        if ($uid)
        {
          $sql .= 'AND uid <> ' . intval($uid);
        }

        $this->db->query($sql, __LINE__, __FILE__);
        if ($this->db->next_record())
        {
          if ($this->db->f('uname',True) == $uname)
          {
            $errors[] = 'ERROR: Username is already taken.';
          }

          if ($this->db->f('email',True) == $email)
          {
            $errors[] = 'ERROR: Email address is already taken.';
          }
        }
        //no errors then username is ok - so return false
        return (count($errors) ? $errors : false);
      }

      function update_userdata($uname, $email, $uid)
      {
        $errors = $this->user_exists($uname, $email, $uid);
        if ($errors)
        {
          return $errors;
        }
        else
        {
          unset($errors);
        }

        if ((!$email) || ($email=="") || (strrpos($uname,' ') > 0)
          || (!eregi("^[_\.0-9a-z-]+@([0-9a-z][0-9a-z-]+\.)+[a-z]{2,4}$", 
$email)))
        {
          $errors[] = 'ERROR: Invalid email address.';
        }

        if ((!$uname) || ($uname=="") || (ereg("[^a-zA-Z0-9_-]",$uname)))
        {
          $errors[] = 'ERROR: Invalid username.';
        }

        if (strlen($uname) > 25)
        {
          $errors[] = 'ERROR: Username is too long.  It must be less than 25 
characters';
        }

        return (isset($errors) ? $errors : true);
      }

      // not sure what to do about this
      function do_checkaccess($newusers, $uid, $uname)
      {
        if ($newusers == 0 && !isset($uid))
        {
          d_DrawNav($uname);
          d_DrawHeader(gettext("Access Denied"));
          echo gettext("You must be logged in to obtain a report.");
          d_DrawFooter();
          return 1;
        }
      }
    }
?>

====================================================
Index: class.user.inc.php
<?php
  /****************************************************************************
   * Anthill                                                                  *
   * http://anthill.vmlinuz.ca                                                *
   *                                                                          *
   * Written by Vincent Danen address@hidden                              *
   *   and Dave Hall [skwashd at phpgroupware.org]                            *
   * ------------------------------------------------------------------------ *
   * This program is free software; you can redistribute it 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.                                               *
   * ------------------------------------------------------------------------ *
   ****************************************************************************/
  // $Id: class.user.inc.php,v 1.1 2005/05/05 00:34:03 skwashd Exp $

  include($GLOBALS['anthill_info']['path']['inc'] . '/class.user_' . 
$GLOBALS['anthill_info']['mode'] . '.inc.php');


  class user_
  {
    // there may be some user stuff added here later - but it is unlikely :)
  }
?>

====================================================
Index: class.uiwidgets.inc.php
<?php
  /****************************************************************************
   * Anthill                                                                  *
   * http://anthill.vmlinuz.ca                                                *
   *                                                                          *
   * Written by Vincent Danen address@hidden                              *
   *   and Dave Hall [skwashd AT phpgroupware.org]                            *
   * ------------------------------------------------------------------------ *
   * This program is free software; you can redistribute it 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.                                               *
   * ------------------------------------------------------------------------ *
   ****************************************************************************/
   // $Id: class.uiwidgets.inc.php,v 1.1 2005/05/05 00:34:03 skwashd Exp $

   class uiwidgets
   {
     function array_select($array, $name, $selected, $size = 1, $js='', 
$val_key = 'name')
     {
       $select  = '<select name="'.$name.'" size="' . intval($size) . '" ' . 
$js . ">\n";
       if(is_array($array))
       {
         foreach ($array as $key => $vals)
         {
           if ($key == $selected)
           {
             $select .= '<option value="' . $key . '" SELECTED>';
           }
           else
           {
             $select .= '<option value="' . $key . '">';
           }

           if (is_array($vals))
           {
             $select .= htmlentities($vals[$val_key]) . "</option>\n";
           }
           else
           {
             $select .= htmlentities($vals) . "</option>\n";
           }
         }
       }
       $select .= "</select>\n";
       return $select;
     }

     function get_nav_links()
     {
        $links[] = array('lang_nav' => lang('submit a bug'),
          'url_nav' => $GLOBALS['phpgw']->link('/index.php',
            array('menuaction' => 'anthill.uianthill.submit')
          )
        );

        $links[] = array('lang_nav' => lang('my bugs'),
          'url_nav' => $GLOBALS['phpgw']->link('/index.php',
            array('menuaction' => 'anthill.uianthill.query', 'status' => 'new', 
'type' => 'mine')
          )
        );

        if (@isset($GLOBALS['phpgw_info']['user']['apps']['admin']))
        {
          $links[] = array('lang_nav' => lang('administration'),
            'url_nav' => $GLOBALS['phpgw']->link('/index.php',
              array('menuaction' => 'anthill.uiadmin.index')
            )
          );

        }
        return $links;
     }

     function render_footer()
     {
       $GLOBALS['phpgw']->template->set_file('footer', 'footer.tpl');
       $GLOBALS['phpgw']->template->set_var('url_img', 
$GLOBALS['phpgw']->common->find_image('anthill','Anthillbutton'));
       $GLOBALS['phpgw']->template->set_var('lang_powered_by',  lang('powered 
by anthill'));
       $GLOBALS['phpgw']->template->set_var('url_anthill', 
'http://anthill.vmlinuz.ca/');
       $GLOBALS['phpgw']->template->set_var('lang_copyright', lang('&copy 
2001-2003 Danen Consulting Services; &copy 2003 Free Software Founation.'));
       $GLOBALS['phpgw']->template->pfp('out', 'footer');
     }

     function render_header($section)
     {
       $GLOBALS['phpgw']->template->set_file('nav', 'nav.tpl');

       $GLOBALS['phpgw']->template->set_var('url_home', 
$GLOBALS['phpgw']->link('index.php',
         array('menuaction' => 'anthill.uianthill.index')));
       $GLOBALS['phpgw']->template->set_var('lang_home', lang('home'));

       $GLOBALS['phpgw']->template->set_block('nav', 'nav_link', 'nav_links');
       $links = $this->get_nav_links();
       foreach ($links as $link)
       {
         $GLOBALS['phpgw']->template->set_var($link);
         $GLOBALS['phpgw']->template->parse('nav_links', 'nav_link', true);
       }
       $GLOBALS['phpgw']->template->set_var('cur_user', lang('current user: 
%1', $GLOBALS['phpgw_info']['user']['fullname']));

       $GLOBALS['phpgw']->template->set_var('section',($section ? 
lang($section): '&nbsp;'));

       $GLOBALS['phpgw']->template->pfp('out', 'nav');
     }
   }
?>

====================================================
Index: class.uianthill.inc.php
<?php
  /****************************************************************************
   * Anthill                                                                  *
   * http://anthill.vmlinuz.ca                                                *
   *                                                                          *
   * Written by Vincent Danen address@hidden                              *
   *   and Dave Hall [skwashd AT phpgroupware.org]                            *
   * ------------------------------------------------------------------------ *
   * This program is free software; you can redistribute it 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.                                               *
   * ------------------------------------------------------------------------ *
   ****************************************************************************/
   // $Id: class.uianthill.inc.php,v 1.1 2005/05/05 00:34:03 skwashd Exp $

   class uianthill
   {
     var $bo;
     var $t;
     var $widgets;
     var $public_functions = array(
       'denied'   => True,
       'index'    => True,
       'post_bug' => True,
       'submit'   => True,
     );

     function uianthill()
     {
       $this->bo = CreateObject('anthill.boanthill');
       $this->t = &$GLOBALS['phpgw']->template;
       $this->t->set_root($GLOBALS['phpgw']->common->get_tpl_dir('anthill'));
       $this->widgets = createObject('anthill.uiwidgets');
     }

     function index()
     {
       $GLOBALS['phpgw']->common->phpgw_header();
       echo parse_navbar();
       $this->widgets->render_header('welcome to anthill');

       $this->t->set_file('home', 'home.tpl');
       $this->t->set_var('lang_welcome', lang('welcome to anthill'));
       $this->t->set_var('site_blurb', 
$GLOBALS['phpgw_info']['anthill']['config']['siteblurb']);
       $this->t->set_var('lang_accounting', lang('accounting'));

       $this->t->set_block('home', 'l_link', 'l_links');
       $this->t->set_var('url_l', $GLOBALS['phpgw']->link('/index.php',
          array('menuaction' => 'anthill.uianthill.help', 'section' => 'home')
          )
       );
       $this->t->set_var('lang_l', lang('help'));
       $this->t->parse('l_links', 'l_link', True);

       $this->t->set_block('home', 'r_link', 'r_links');
       $this->t->set_var('lang_problem_reporting', lang('problem reporting'));

       $this->t->set_var('url_r', $GLOBALS['phpgw']->link('/index.php',
          array('menuaction' => 'anthill.uianthill.submit')
          )
       );
       $this->t->set_var('lang_r', lang('enter a bug'));
       $this->t->parse('r_links', 'r_link', True);

       $this->t->set_var('url_r', $GLOBALS['phpgw']->link('/index.php',
          array('menuaction' => 'anthill.uianthill.buglist', 'mode' => 
'reporternew')
          )
       );
       $this->t->set_var('lang_r', lang('new bugs you reported'));
       $this->t->parse('r_links', 'r_link', True);

       $this->t->set_var('url_r', $GLOBALS['phpgw']->link('/index.php',
          array('menuaction' => 'anthill.uianthill.buglist', 'mode' => 'mine', 
'class' => 'new')
          )
       );
       $this->t->set_var('lang_r', lang('my open bugs'));
       $this->t->parse('r_links', 'r_link', True);

       $this->t->set_var('url_r', $GLOBALS['phpgw']->link('/index.php',
          array('menuaction' => 'anthill.uianthill.buglist', 'mode' => 
'uresolved')
          )
       );
       $this->t->set_var('lang_r', lang('uresolved bugs'));
       $this->t->parse('r_links', 'r_link', True);

       $this->t->set_var('url_r', $GLOBALS['phpgw']->link('/index.php',
          array('menuaction' => 'anthill.uianthill.buglist', 'mode' => 
'unvalidated')
          )
       );
       $this->t->set_var('lang_r', lang('bugs requiring validation'));
       $this->t->parse('r_links', 'r_link', True);

       $this->t->set_var('url_r', $GLOBALS['phpgw']->link('/index.php',
          array('menuaction' => 'anthill.uianthill.reports')
          )
       );
       $this->t->set_var('lang_r', lang('reports'));
       $this->t->parse('r_links', 'r_link', True);

       $this->t->pfp('out', 'home');
       $this->widgets->render_footer();
     }

     function denied()
     {
       echo 'access denied to ' . $_SERVER['HTTP_REFERER'] . '<br>Args to 
script:';
       echo '<pre>';
       print_r($_GET);
       echo '</pre>';
     }

     function select_product($products)
     {
       $GLOBALS['phpgw']->common->phpgw_header();
       echo parse_navbar();
       $this->widgets->render_header('select product');

       if (empty($products) && !is_array($products))
       {
         $products = $this->bo->get_products();
       }
       if(empty($products) && !is_array($products))//not setup yet
       {
         echo lang('No products in the database, please contact sysadmin - 
exiting!');
       }
       else
       {
         $this->t->set_file('prodselect', 'prodselect.tpl');
         $this->t->set_block('prodselect', 'product', 'products');

         $url = $GLOBALS['phpgw']->link('/index.php',
                 array('menuaction' => 'anthill.uianthill.submit'));

         foreach($products as $product => $pinfo)
         {
           $this->t->set_var('url', $url);
           $this->t->set_var('pid', $product);
           $this->t->set_var($pinfo);
           $this->t->parse('products', 'product', True);
         }
         $this->t->set_var('lang_add', '');
         $this->t->set_var('extra', '');
         $this->t->pparse('out','prodselect');
       }
       $this->widgets->render_footer();
     }

     function post_bug()
     {
       if ($_POST['assigned'] == 0) // chosen to assign to component owner
       {
         $_POST['assigned'] = 
$this->bo->get_component_info($_POST['component'], 'owner');
         // a little naughty - but hey it works :)
       }

       /*
       if ($GLOBALS['anthill']->user->read_rights($_POST['assigned'])
           < $GLOBALS['anthill_info']['config']['devac']) // assigned user's 
access is lower than developer access
       {
         $errors[] = 'ERROR: You have assigned the bug to someone unauthorized 
to own bugs';
       }
       */

       if (!$_POST['shortdesc']) // no short description entered
       {
         $errors[] = 'ERROR: You need to include a summary of the bug';
       }

       if (!$_POST['longdesc']) // no long description entered
       {
         $errors[] = 'ERROR: You need to include a description of the bug';
       }

       if (!$_POST['version']) // no version chosen
       {
         $errors[] = 'ERROR: You need to select a version for this bug';
       }

       if (!$_POST['component']) // no component chosen
       {
         $errors[] = 'ERROR: You need to select a component for this bug';
       }

       if($errors) // something is not as it should be
       {
         $_GET['pid'] = $_POST['product'];
         $this->submit($errors);
         exit;
       }

       //must be ok - so lets move on
       $bid = $this->bo->set_bug(False, $_POST);
       echo "Bug $bid logged ok - fix msg!!!<br>";
     }

     function submit($errors=False)
     {
       $msg = '';
       if ($errors)//must have failed posting
       {
         foreach ($_POST as $key => $val)
         {
           $default['def_' . $key] = $val;
         }

         $msg = '<span class="text">';
         foreach ($errors as $error)
         {
           $msg .= lang($error) . "<br>\n";
         }
         $msg .= '</span>';
       }

       $products = $this->bo->get_products();

       if(isset($_GET['pid']))
       {
         $pid = @$_GET['pid'];
       }
       else
       {
         if (count($products) == 1)
         {
           reset($products);
           $pid = key($products);
         }
       }

       if(! ($pid && (@$products[$pid]) ) )
       {
         $this->select_product($products);
         exit;
       }

       //if we get to here then all must be ok
       $lang['lang_explain'] = lang('This page lets you enter a new bug into 
Anthill');
       $lang['lang_reporter'] = lang('Reporter');
       $lang['lang_product'] = lang('product');
       $lang['lang_version'] = lang('version');
       $lang['lang_component'] = lang('component');
       $lang['lang_priority'] = lang('resolution priority');
       $lang['lang_severity'] = lang('severity');
       $lang['lang_assigned_to'] = lang('assigned to');
       $lang['lang_explain_assign'] = lang('leave at default to assign to 
component owner');
       $lang['lang_summary'] = lang('summary');
       $lang['lang_inc_prefix'] = lang('include prefix');
       $lang['lang_description'] = lang('description');
       $lang['lang_save'] = lang('save');
       $lang['lang_clear'] = lang('clear');

       $GLOBALS['phpgw']->common->phpgw_header();
       echo parse_navbar();
       $this->widgets->render_header('submit a bug');

       $this->t->set_file('submit', 'submit.tpl');
       $this->t->set_var($GLOBALS['anthill_info']['user']);
       $this->t->set_var($lang);
       $this->t->set_var($deafults);
       $this->t->set_var('reporter', 
$GLOBALS['phpgw_info']['user']['fullname']);

       $this->t->set_var('errors',$msg);

       $this->t->set_var('form_action', $GLOBALS['phpgw']->link('/index.php',
         array('menuaction' => 'anthill.uianthill.post_bug'))
       );

       $this->t->set_var('product_name', $products[$pid]['name']);
       $this->t->set_var('pid', $pid);
       $this->t->set_var('select_version',
       $this->widgets->array_select($this->bo->get_versions($pid), 'version', 
@$defaults['def_version'], 5));

       $this->t->set_var('select_component',
         $this->widgets->array_select($this->bo->get_components($pid), 
'component', @$defaults['def_component'], 5));

       $this->t->set_var('select_priority',
         $this->widgets->array_select($this->bo->get_priorities(), 'priority', 
$GLOBALS['anthill_info']['config']['def_priority'], 1));

       $this->t->set_var('select_severity',
         $this->widgets->array_select($this->bo->get_severities(), 'severity', 
$GLOBALS['anthill_info']['config']['def_severity'], 1));


       $sbox = createObject('phpgwapi.sbox2');
       
$this->t->set_var('select_assign',$sbox->getAccount('fields[owner]',$cinfo['owner'],1));

       $this->t->set_var('product_name', $products[$pid]['name']);
       $this->t->set_var('pid', $pid);
       $this->t->set_var('select_version',
         $this->widgets->array_select($this->bo->get_versions($pid), 'version', 
@$defaults['def_version'], 5));

       $this->t->set_var('select_component',
         $this->widgets->array_select($this->bo->get_components($pid), 
'component', @$defaults['def_component'], 5));

       $this->t->set_var('select_priority',
         $this->widgets->array_select($this->bo->get_priorities(), 'priority', 
$GLOBALS['anthill_info']['config']['def_priority'], 1));

       $this->t->set_var('select_severity',
         $this->widgets->array_select($this->bo->get_severities(), 'severity', 
$GLOBALS['anthill_info']['config']['def_severity'], 1));

       $this->t->set_var('select_assign', 
$sbox->getAccount('fields[owner]',$cinfo['owner'],1));
       $this->t->pfp('out', 'submit');

       $this->widgets->render_footer();
     }
   }
?>

====================================================
Index: anthill.css
body            { font-family: Helvetica, Arial; font-size: 12px;
                  color: #000000; background-color: #ffffff }

a               { text-decoration: none }
a:link          { color: darkcyan }
a:visited       { color: darkcyan }
a:hover         { color: red; text-decoration: underline }

p               { font-family: Helvetica, Arial;
                  color: #000000; font-size: 12px; margin-right: 10px }

h1              { font-family: Helvetica, Arial; font-size: 22px;
                  color: darkblue; text-align: center }

h2              { font-family: Helvetica, Arial; font-size: 18px;
                  color: darkred }

h3              { font-family: Helvetica, Arial; font-size: 14px;
                  color: darkcyan; text-decoration: underline }

td              { font-family: Helvetica, Arial; font-size: 12px }
ol              { font-family: Helvetica, Arial; font-size: 12px }
ul              { font-family: Helvetica, Arial; font-size: 12px }
input           { font-family: Helvetica, Arial; font-size: 10px }
textarea        { font-family: Helvetica, Arial; font-size: 10px;
                  width: 500px }

.header         { font-family: Helvetica, Arial; font-weight: bold;
                  color: #ffffff; font-size: 12px }

.subhead        { font-family: Helvetica, Arial; font-weight: bold;
                  color: #000000; font-size: 14px; text-decoration: underline }

.text           { font-family: Helvetica, Arial; color: #000000;
                  font-size: 12px }

.foot           { font-family: Helvetica, Arial; color: #000000;
                  font-size: 10px }

.tiny           { font-family: Helvetica, Arial; color: #000000;
                  font-size: 8px }

.rcs            { font-family: Helvetica, Arial; color: #000000;
                  font-size: 8px; text-align: right }

.code           { font-family: Helvetica; color: #000000;
                  font-size: 10px; }

====================================================
Index: config.inc.php
<?php
  /****************************************************************************
   * Anthill                                                                  *
   * http://anthill.vmlinuz.ca                                                *
   *                                                                          *
   * Written by Vincent Danen address@hidden                              *
   *   and Dave Hall [skwashd AT phpgroupware.org]                            *
   * ------------------------------------------------------------------------ *
   * This program is free software; you can redistribute it 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.                                               *
   * ------------------------------------------------------------------------ *
   ****************************************************************************/
   /* $Id: config.inc.php,v 1.1 2005/05/05 00:34:03 skwashd Exp $ */

   // Please use the setup.php script to edit this file - you may break
   // something by manually editting it.

  ###########################################################################
  # Config password: used for accessing the setup.php script
  ###########################################################################
  $GLOBALS['anthill_setup']['pass'] = '67e92c8765a9bc7fb2d335c459de9eb5';

  ###########################################################################
  # Directory locations:
  #
  # root:      base Anthill directory
  # webroot:   home url
  # offroot:   directory which is out of the document root
  #            (should be rw to user running the web server; ie. apache, 
nobody, www-data)
  # tpl:       template set to be used - generally leave as default
  # langdir:   directory where locale/language files/dirs are kept
  # difftool:  /path/to/diff
  ###########################################################################

  $GLOBALS['anthill_info']['path']['root']      = 
'/var/www/anthill/anthill-0.3/';
  $GLOBALS['anthill_info']['path']['webroot']   = 
'http://shitbox/anthill/anthill-0.3/';
  $GLOBALS['anthill_info']['path']['offroot']   = '/usr/local/anthill';
  $GLOBALS['anthill_info']['path']['tpl']       = 'default';
  $GLOBALS['anthill_info']['path']['lang']      = 
'/var/www/anthill/anthill-0.3/backend/lang/';
  $GLOBALS['anthill_info']['path']['difftool']  = '/usr/bin/diff';

  ###########################################################################
  # Time/date details:
  #
  # datefmt:    date format to use (see PHP manual for proper syntax)
  # timefmt:    time format to use (see PHP manual for proper syntax)
  ###########################################################################

  $GLOBALS['anthill_info']['format']['date']     = 'd-M-Y';
  $GLOBALS['anthill_info']['format']['time']     = 'g:i a';

  ###########################################################################
  # Session details:
  #
  # cookies:    enable cookies for sessions? True = COOKIE else False = GET
  # perm_days:     default seconds for cookie expiry for permanent cookies
  #                (can be overriden by users in their prefs)
  # timeout:    default seconds for session cookie persistence (only
  #                 useful if you don't want persistent cookies)
  # path:       cookie path (usually just '/')
  # domain:     the domain in which the cookie should be sent to server
  #                 for (default is $SERVER_NAME, which is the name of the
  #                 running server, but you can change this if you need to)
  # secure:     0=HTTP, 1=HTTPS (does site run over SSL?)
  # verify_ip:  verify the client ip address - False needed for some users who
  #                 connect through a transparent proxy - such as AOL
  ###########################################################################

  $GLOBALS['anthill_info']['sessions']['cookies']     = True;
  $GLOBALS['anthill_info']['sessions']['perm_days']   = 1;
  $GLOBALS['anthill_info']['sessions']['timeout']     = 7220;
  $GLOBALS['anthill_info']['sessions']['path']        = '/';
  $GLOBALS['anthill_info']['sessions']['domain']      = 'shitbox';
  $GLOBALS['anthill_info']['sessions']['secure']      = True;
  $GLOBALS['anthill_info']['sessions']['verify_ip']   = True;

  ###########################################################################
  # Language details:
  #
  # meta_lang:  charset to send to browser (meta tag)
  ###########################################################################

  $GLOBALS['anthill_info']['charset']['meta_lang'] = 'utf-8';

  ###########################################################################
  # SQL connection info:
  #
  # user:  SQL username
  # pw:    SQL user's password
  # host:  SQL server hostname
  # name:  SQL database name
  # type:  SQL database type ("mysql" or "pgsql");
  ###########################################################################

  $GLOBALS['anthill_info']['db']['user']    = 'anthill';
  $GLOBALS['anthill_info']['db']['pw']      = 'changeme';
  $GLOBALS['anthill_info']['db']['host']    = 'localhost';
  $GLOBALS['anthill_info']['db']['name']    = 'anthill';
  $GLOBALS['anthill_info']['db']['type']    = 'mysql';

  #### DO NOT TOUCH ANYTHING BELOW THIS LINE ################################

  if(! @$GLOBALS['inc_from_setup'])
  {
    if(file_exists($GLOBALS['anthill_info']['path']['root'] . 
'/inc/functions.inc.php'))
    {
      include_once($GLOBALS['anthill_info']['path']['root'] . 
'/inc/functions.inc.php');
    }
    else
    {
      echo '<p><b><font color="red">Configuration file does not 
exist!!</font></b></p>';
      exit;
    }
  }
?>

====================================================
Index: hook_admin.inc.php
<?php
  /****************************************************************************
   * Anthill                                                                  *
   * http://anthill.vmlinuz.ca                                                *
   *                                                                          *
   * This file written Dave Hall [skwashd AT phpgroupware.org]                *
   * ------------------------------------------------------------------------ *
   * This program is free software; you can redistribute it 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.                                               *
   * ------------------------------------------------------------------------ *
   ****************************************************************************/
   // $Id: hook_admin.inc.php,v 1.1 2005/05/05 00:34:03 skwashd Exp $
{
   $file = array(
      'Site configuration' => $GLOBALS['phpgw']->link('/index.php',array(
         'menuaction' => 'admin.uiconfig.admin',
         'appname'    => $appname
      )),

      array(
      'Configure Products' => $GLOBALS['phpgw']->link('/index.php',array(
         'menuaction' => 'anthill.uiadmin.products',
         'appname'    => $appname
      )))

   );
   //Do not modify below this line

   display_section($appname,$file);
}

====================================================
Index: sample-config.inc.php
<?php
   // Anthill configuration file
   // during upgrades you probably shouldn't replace this file
   // $Id: sample-config.inc.php,v 1.1 2005/05/05 00:34:03 skwashd Exp $

   // DONT NOT EDIT THE NEXT LINE
   unset($GLOBALS['anthill_info']);//register_globals=on protection

  ###########################################################################
  # Directory locations:
  #
  # root:      base Anthill directory
  # incdir:    include directory
  # webroot:   home url
  # imgdir:    images directory
  # tpl:       template set to be used - generally leave as default
  # langdir:   directory where locale/language files/dirs are kept
  # shadodir:  shadow directory (stores text copy of bugs for diffs)
  # tmp:       temporary directory (should be rw to user running the
  #              web server; ie. apache or nobody)
  # gpg:       directory to store GPG keys (should be rw only to web
  #             server user; located off of the root directory)
  # attach:    directory to store attachments (should be rw only to web
  #             server user; located off of the root directory)
  # difftool:  /path/to/diff
  ###########################################################################

  $GLOBALS['anthill_info']['path']['root']      = '/var/www/html/anthill/';
  $GLOBALS['anthill_info']['path']['incdir']    = '/inc';
  $GLOBALS['anthill_info']['path']['webroot']   = 'http://server.com/anthill/';
  $GLOBALS['anthill_info']['path']['tpl']       = 'default';
  $GLOBALS['anthill_info']['path']['langdir']   = '/backend/language';
  $GLOBALS['anthill_info']['path']['shadow']    = 
$GLOBALS['anthill_info']['root'] . "shadow";
  $GLOBALS['anthill_info']['path']['tmp']       = 
$GLOBALS['anthill_info']['root'] . "tmp";
  $GLOBALS['anthill_info']['path']['gpg']       = "/gpg";
  $GLOBALS['anthill_info']['path']['attachdir'] = "/attachments";
  $GLOBALS['anthill_info']['path']['difftool']  = "/usr/bin/diff";

  ###########################################################################
  # Time/date details:
  #
  # datefmt:    date format to use (see PHP manual for proper syntax)
  # timefmt:    time format to use (see PHP manual for proper syntax)
  ###########################################################################

  $GLOBALS['anthill_info']['format']['date']     = "Y-m-d";
  $GLOBALS['anthill_info']['format']['time']     = "g:i A";

  ###########################################################################
  # Session details:
  #
  # cookies:    enable cookies for sessions? True = COOKIE else False = GET
  # perm_days:     default seconds for cookie expiry for permanent cookies
  #                 (can be overriden by users in their prefs)
  # timeout:    default seconds for session cookie persistence (only
  #                 useful if you don't want persistent cookies)
  # path:        cookie path (usually just '/')
  # domain:      the domain in which the cookie should be sent to server
  #                 for (default is $SERVER_NAME, which is the name of the
  #                 running server, but you can change this if you need to)
  # secure:      0=HTTP, 1=HTTPS (does site run over SSL?)
  # verify_ip:   verify the client ip address - False needed for some users who
  #              connect through a transparent proxy - such as AOL
  ###########################################################################

  $GLOBALS['anthill_info']['sessions']['cookies']     = True;
  $GLOBALS['anthill_info']['sessions']['perm_days']   = 1;
  $GLOBALS['anthill_info']['sessions']['timeout']     = 7200;
  $GLOBALS['anthill_info']['sessions']['path']        = "/";
  $GLOBALS['anthill_info']['sessions']['domain']      = $_SERVER['SERVER_NAME'];
  $GLOBALS['anthill_info']['sessions']['secure']      = 0;
  $GLOBALS['anthill_info']['sessions']['verify_ip']   = True;

  ###########################################################################
  # Language details:
  #
  # meta_lang:  charset to send to browser (meta tag)
  ###########################################################################

  $GLOBALS['anthill_info']['charset']['meta_lang'] = "utf-8";

  ###########################################################################
  # SQL connection info:
  #
  # user:  SQL username
  # pw:  SQL user's password
  # host:  SQL server hostname
  # name:  SQL database name
  # type:    SQL database type ("mysql" or "pgsql");
  ###########################################################################

  $GLOBALS['anthill_info']['db']['user']    = "anthill";
  $GLOBALS['anthill_info']['db']['pw']      = "pass";
  $GLOBALS['anthill_info']['db']['host']    = "localhost";
  $GLOBALS['anthill_info']['db']['name']    = "anthill";
  $GLOBALS['anthill_info']['db']['type']    = "mysql";

  #### DO NOT TOUCH ANYTHING BELOW THIS LINE ################################

  if(file_exists($GLOBALS['anthill_info']['path']['root']
    . $GLOBALS['anthill_info']['path']['incdir'] . '/functions.inc.php'))
  {
    include_once($GLOBALS['anthill_info']['path']['root']
      . $GLOBALS['anthill_info']['path']['incdir'] . '/functions.inc.php');
  }
  else
  {
    echo '<p><b><font color="red">Configuration file does not 
exist!!</font></b></p>';
    exit;
  }

?>

====================================================
Index: reportengine.php
<?
   // Report Engine Functions
   // $Id: reportengine.php,v 1.1 2005/05/05 00:34:03 skwashd Exp $
   //
   // (C) 2002 by John Gatewood Ham
   //
   // This program is free software; you can redistribute it 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.
   //
   // This program is distributed in the hope that it will be useful,
   // but WITHOUT ANY WARRANTY; without even the implied warranty of
   // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   // GNU General Public License for more details.
   //
   // You should have received a copy of the GNU General Public License
   // along with this program; if not, write to the Free Software
   // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
   //

   //
   // This will convert a date from MYSQL into a date suitable
   // for printing.  This version has hard-coded format so that
   // changes in the site.inc.php file won't break report layouts.
   // Also, all times are forced to be displayed in GMT so you
   // can compare reports across time zones easily.
   //
   function d_getTimeGMT($date) {
      $year  = substr($date,0,4);
      $mon   = substr($date,4,2);
      $day   = substr($date,6,2);
      $hour  = substr($date,8,2);
      $min   = substr($date,10,2);
      $sec   = substr($date,12,2);
      $gdate = gmdate("Y-m-d H:i T",mktime($hour,$min,$sec,$mon,$day,$year));
      return($gdate);
   }

   //
   // This initializes the report engine.  There are 7 parameters, and
   // all have default values.  The parameters are:
   // rows     Total number of rows on the output
   // columns  Total number of columns on the output
   // ff       1 means add a ctl-L after each page, 0 means do not do this
   // isdos    1 means newlines are ms-dos style, 0 means Unix style
   // ht       This is the report title to put into the header of the report
   // lm       This is a left margin to indent.  0 means do not indent.
   // rm       This is a right margin to indent.  0 means do not indent.
   //          (lm and rm units are columns)
   //
   // examples:
   //    report_init();
   //       accepts all default values
   //    report_init(10, 80, 1, 1, "Testing 3", 0, 0);
   //       10 lines, 80 columns, use form feeds, create ms-dos newlines,
   //       the report title is "Testing 3", do not indent left or right
   //       margins.
   //    report_init(58, 132, 1, 0, "Testing 2", 5, 5);
   //       58 lines, 132 columns, use forfeeds, Unix newlines,
   //       report title is "Testing 2", indent 5 columns left and right.
   //
   function report_init($rows = 58, $columns = 80, $ff = 1, $isdos = 0,$ht = 
"", $lm = 0, $rm = 0) {
     $pageoftext['magic'] = "magic";
     $GLOBALS['report_headertext'] = $ht;
     $GLOBALS['report_pageoftext'] = $pageoftext; // lines in buffered page
     $GLOBALS['report_rows'] = $rows - 4; // reserve 4 lines for header/footer
     $GLOBALS['report_columns'] = $columns;
     $GLOBALS['report_linecount'] = 0; // number of lines in buffered page
     $GLOBALS['report_pageno'] = 0; // current page number
     // following 3 items are for poisitioning items in the header/footer
     $GLOBALS['report_left'] = (int)floor($GLOBALS['report_columns'] / 3.0);
     $GLOBALS['report_right'] = $GLOBALS['report_left'];
     $GLOBALS['report_center'] = $GLOBALS['report_columns'] - 
$GLOBALS['report_left'] - $GLOBALS['report_right'];
     $GLOBALS['report_do_ctl_l'] = $ff;
     $GLOBALS['report_leftmargin'] = $lm;
     $GLOBALS['report_rightmargin'] = $rm;
     $GLOBALS['report_linewidth'] = $columns - $lm - $rm; // columns remaining 
after margins
     $GLOBALS['report_keep'] = "off";    // are we in a keep block?
     $GLOBALS['report_keep_lines'] = 0;  // number of lines in keep
     $keeparea['magic'] = "magic";
     $GLOBALS['report_keep_area'] = $keeparea; // lines in keep

     // isdos 1 is do chr(13)chr(10), 0 is just chr(10)
     if ($isdos == 1) {
        $GLOBALS['report_newline'] = chr(13) . chr(10);
     } else {
        $GLOBALS['report_newline'] = chr(10);
     }
     return;
   }

   //
   // Begin a keep group.  A keep group is a group of lines
   // that we want to keep together on the same page.  If the
   // entire keep won't fit on the current page, a page eject
   // is done and the keep is started at the top of the next page.
   // returns 1 if we can start the keep, 0 otherwise
   //
   function report_start_keep() {
     if ($GLOBALS['report_keep'] == "off") {
        $GLOBALS['report_keep'] = "on";
        $GLOBALS['report_keep_lines'] = 0;
        return 1;
     }
     return 0;
   }

   //
   // End a keep group.  This transfers the lines in the keep
   // area to the buffered page, doing a page eject first if
   // necessary.
   //
   function report_end_keep() {
     if ($GLOBALS['report_keep'] == "on") {
        $ll = $GLOBALS['report_rows'] - $GLOBALS['report_linecount'];
        if ($GLOBALS['report_keep_lines'] > $ll) {
           report_page_eject();
        }
        $GLOBALS['report_keep'] = "off";
        for ($i=0;$i< $GLOBALS['report_keep_lines']; $i += 1) {
          report_que_line($GLOBALS['report_keep_area'][$i]);
        }
        $GLOBALS['report_keep_lines'] = 0;
     }
     return 0;
   }

   //
   // End a report.  This ends any open keep area, then
   // flushes any buffered lines with a page eject if necessary.
   //
   function report_finish() {
     if ($GLOBALS['report_keep'] == "on") {
        report_end_keep();
     }
     if ($GLOBALS['report_linecount'] > 0) {
        report_page_eject();
     }
     return;
   }

   //
   // This is an internal function to format one line of a header
   // or footer.
   //
   function report_do_header_line($l,$c,$r) {
     return (str_pad($l,$GLOBALS['report_left']," ", STR_PAD_RIGHT) .
             str_pad($c,$GLOBALS['report_center']," ", STR_PAD_BOTH) .
             str_pad($r,$GLOBALS['report_right']," ", STR_PAD_LEFT));
   }

   //
   // This is an internal function to print the header.
   //
   function report_do_header() {
     printf("%s%s%s",report_do_header_line(gmdate("D, d M 
Y"),$GLOBALS['report_headertext'],gmdate("H:i:s")),
        $GLOBALS['report_newline'],$GLOBALS['report_newline']);
     return;
   }

   //
   // This is an internal function to print the footer.
   //
   function report_do_footer() {
     $GLOBALS['report_pageno'] += 1;
     printf("%s%s%s",$GLOBALS['report_newline'],
            report_do_header_line("","Page " . $GLOBALS['report_pageno'], ""),
            $GLOBALS['report_newline']);
     if ($GLOBALS['report_do_ctl_l'] == 1) {
        print(chr(12));
     }
     return;
   }

   //
   // This function will perform a page eject, flushing any
   // buffered lines onto the current page before starting
   // a new page.
   //
   function report_page_eject() {
     report_do_header();

     for($i = 0; $i < $GLOBALS['report_linecount']; $i += 1) {
        printf("%s%s%s%s",str_pad("",$GLOBALS['report_leftmargin']," 
",STR_PAD_RIGHT),
               $GLOBALS['report_pageoftext'][$i],
               str_pad("",$GLOBALS['report_rightmargin']," ",STR_PAD_RIGHT),
               $GLOBALS['report_newline']);
        $GLOBALS['report_pageoftext'][$i] = "XXX ($i)";
     }
     for(;$i < $GLOBALS['report_rows']; $i += 1) {
        printf("%s",$GLOBALS['report_newline']);
        $GLOBALS['report_pageoftext'][$i] = "YYY ($i)";
     }
     report_do_footer();
     $GLOBALS['report_linecount'] = 0;
     return;
   }

   //
   // This function will add the linedata to the current page buffer.
   // If it will not fit, a page eject is done and linedata is added
   // to the next page.  This routine also does primitive line wrapping
   // by breaking the input into report_linewidth sized chunks.  Use
   // report_flowtext for breaking at word boundaries.
   //
   function report_que_line($linedata) {
     $tstring = $linedata;
     $x = strlen($tstring);
     do {
       if ($GLOBALS['report_linecount']+1 > $GLOBALS['report_rows']) {
          report_page_eject();
       }
       if ($GLOBALS['report_keep'] == "on") {
            $GLOBALS['report_keep_lines'] += 1;
       } else {
            $GLOBALS['report_linecount'] += 1;
       }
       if ($x > $GLOBALS['report_linewidth']) {
         $ostring = substr($tstring,0,$GLOBALS['report_linewidth']);
         $tstring = substr($tstring,$GLOBALS['report_linewidth']);
         $x = strlen($tstring);
       } else {
         $ostring = $tstring;
         $tstring = "";
         $x = 0;
       }
       if ($GLOBALS['report_keep'] == "on") {
         $GLOBALS['report_keep_area'][$GLOBALS['report_keep_lines']-1] = 
$ostring;
       } else {
         $GLOBALS['report_pageoftext'][$GLOBALS['report_linecount']-1] = 
$ostring;
       }
     } while ($x > 0);
     return;
   }

   //
   // Internal function used by report_flowtext to compute where
   // word breaks can occur.
   // returns 0 to say no split required
   // returns place to split if a space is found to split on
   // if no space found to split on, split on report_linewidth value
   //
   function report_where2split($linedata,$lm = 0) {
     $tstring = $linedata;
     $x = strlen($tstring);
     if ($x > $GLOBALS['report_linewidth']-$lm) {
        $ostring = substr($tstring,0,$GLOBALS['report_linewidth']-$lm);
        $y = strrpos($ostring," ");
        if ($y > 0) {
           return($y);
        } else {
           return($GLOBALS['report_linewidth']-$lm);
        }
     }
     return(0);
   }

  //
  // This is like report_que_line(), but it does better line breaking
  // for long lines by breaking on spaces if possible. For example,
  // On a 10 column output, report_flowtext would do this:
  //
  // 0123456789
  // This was
  // only a
  // test.
  //
  // but report_que_line() would do this:
  // 0123456789
  // This was o
  // nly a test
  // .
  //
  // Breaks are done on spaces (" ").
  //
  function report_flowtext($data,$lm = 0) {
     $outstring = $data;
     if ($lm > 0) {
        $tpad = str_pad("", $lm, " ", STR_PAD_LEFT);
     } else {
        $tpad = "";
     }
     do {
       $z = report_where2split($outstring,$lm);
       if ($z > 0) {
          report_que_line($tpad . substr($outstring,0,$z));
          $outstring = substr($outstring,$z+1);
          $z = report_where2split($outstring,$lm);
       }
     } while ($z > 0);
     if (strlen($outstring) > 0) {
        report_que_line($tpad . $outstring);
     }
     return;
  }

 ?>

====================================================
Index: phpgw.inc.php
<?php
  /****************************************************************************
   * Anthill                                                                  *
   * http://anthill.vmlinuz.ca                                                *
   *                                                                          *
   * Written by Vincent Danen address@hidden                              *
   *   and Dave Hall [skwashd AT phpgroupware.org]                            *
   * ------------------------------------------------------------------------ *
   * This program is free software; you can redistribute it 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.                                               *
   * ------------------------------------------------------------------------ *
   ****************************************************************************/
  // $Id: phpgw.inc.php,v 1.1 2005/05/05 00:34:03 skwashd Exp $

  // the basic includes we need for Anthill to function
  // formely in site.inc.php
  define("_VERSION","0.3.0alpha");
  define("_NAME","Anthill");

  if (file_exists($GLOBALS['_CONF']['path']['inc'] . '/functions.inc.php'))
  {
    include_once($GLOBALS['_CONF']['path']['inc'] . '/functions.inc.php');
  }

  function load_config()
  {
    $GLOBALS['phpgw']->config = createObject('phpgwapi.config');
    $GLOBALS['phpgw']->config->read_repository();
    $GLOBALS['_CONF']['config'] = $GLOBALS['phpgw']->config->config_data;
  }
?>

====================================================
Index: old-functions.inc.php
<?php
    
/***************************************************************************\
    * Anthill                                                                   
*
    * http://anthill.vmlinuz.ca                                                 
*
    *                                                                           
*
    * Written by Vincent Danen address@hidden                             *
    *   and Dave Hall [skwashd AT phpgroupware.org]                             
*
    * ------------------------------------------------------------------------  
*
    *  This program is free software; you can redistribute it 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.                                               
*
    
\***************************************************************************/
    // $Id: old-functions.inc.php,v 1.1 2005/05/05 00:34:03 skwashd Exp $

    /*!
    @abstract Global functions for Anthill - used in both modes
    */


    // check if php version is less than 4.1.0
    if (!function_exists('version_compare'))
    {
      echo '<p><b><font color="red">' . gettext('minimum PHP version required 
is 4.1.0 and you have PHP version ' . phpversion() . ' installed!') . 
'</font></b></p>';
      exit;
    }

    $GLOBALS['anthill_info']['path']['inc']  = 
$GLOBALS['anthill_info']['path']['root'] . 
$GLOBALS['anthill_info']['path']['incdir'];
    $GLOBALS['anthill_info']['path']['tpl_dir']  = 
$GLOBALS['anthill_info']['path']['root'] . '/templates/'. 
$GLOBALS['anthill_info']['path']['tpl'];
    $GLOBALS['anthill_info']['path']['wtpl_dir'] = 
$GLOBALS['anthill_info']['path']['webroot'] . '/templates/' . 
$GLOBALS['anthill_info']['path']['tpl'];


    //are we running within phpgroupware?
    if (@is_dir($GLOBALS['anthill_info']['path']['root'] . '/../phpgwapi/')
      && @is_file($GLOBALS['anthill_info']['path']['root'] . 
'/../header.inc.php'))
    {
      $GLOBALS['anthill_info']['mode'] = 'phpgw';
      if(file_exists($GLOBALS['anthill_info']['path']['inc'] . 
'/phpgw.inc.php'))
      {
        include_once($GLOBALS['anthill_info']['path']['inc'] . 
'/phpgw.inc.php');
      }
      else
      {
        echo '<p><b><font color="red">Configuration file does not 
exist!!</font></b></p>';
        exit;
      }
    }
    else
    {
      $GLOBALS['anthill_info']['mode'] = 'anthill';
      if (file_exists($GLOBALS['anthill_info']['path']['inc'] . 
'/anthill.inc.php'))
      {
        include_once($GLOBALS['anthill_info']['path']['inc'] . 
'/anthill.inc.php');
      }
      else
      {
        echo '<p><b><font color="red">Configuration file does not 
exist!!</font></b></p>';
        exit;
      }
    }

        //reserved usernames
    $GLOBALS['anthill_info']['global_denied_users'] = array(
                'root'     => True, 'bin'      => True, 'daemon'   => True,
                'adm'      => True, 'lp'       => True, 'sync'     => True,
                'shutdown' => True, 'halt'     => True, 'ldap'     => True,
                'mail'     => True, 'news'     => True, 'uucp'     => True,
                'operator' => True, 'games'    => True, 'gopher'   => True,
                'nobody'   => True, 'xfs'      => True, 'pgsql'    => True,
                'mysql'    => True, 'postgres' => True, 'oracle'   => True,
                'ftp'      => True, 'gdm'      => True, 'named'    => True,
                'alias'    => True, 'web'      => True, 'sweep'    => True,
                'cvs'      => True, 'qmaild'   => True, 'qmaill'   => True,
                'qmaillog' => True, 'qmailp'   => True, 'qmailq'   => True,
                'qmailr'   => True, 'qmails'   => True, 'rpc'      => True,
                'rpcuser'  => True, 'amanda'   => True, 'apache'   => True,
                'pvm'      => True, 'squid'    => True, 'ident'    => True,
                'nscd'     => True, 'mailnull' => True, 'cyrus'    => True,
                'backup'   => True, 'www-data' => True, 'postfix'  => True,
      'none'     => True,
        );

    function get_nav_links()
    {
      $rights = $GLOBALS['anthill']->user->get_rights();
      if ($rights)
      {
        $links[] = array('lang_nav' => lang('preferences'),
          'url_nav' => $GLOBALS['anthill']->link('/index.php',
            array('menuaction' => 'anthill.ui.prefs')
          )
        );

        $links[] = array('lang_nav' => lang('submit a bug'),
          'url_nav' => $GLOBALS['anthill']->link('/index.php',
            array('menuaction' => 'anthill.ui.submit')
          )
        );

        $links[] = array('lang_nav' => lang('my bugs'),
          'url_nav' => $GLOBALS['anthill']->link('/index.php',
            array('menuaction' => 'anthill.ui.query', 'status' => 'new', 'type' 
=> 'mine')
          )
        );

        if ($GLOBALS['anthill_info']['mode'] != 'phpgw')
        {
          $links[] = array('lang_nav' => lang('logout'),
            'url_nav' => $GLOBALS['anthill']->link('/logout.php')
          );
        }
      }
      else
      {
        if ($GLOBALS['anthill_info']['mode'] == 'anthill')
        {
          $links[] = array('lang_nav' => lang('login'),
            'url_nav' => $GLOBALS['anthill']->link('/login.php')
          );
        }

        $links[] = array('lang_nav' => lang('register'),
          'url_nav' => $GLOBALS['anthill']->link('/index.php',
            array('menuaction' => 'anthill.ui.register')
          )
        );
      }

      if ($GLOBALS['anthill']->user->is_admin())
      {
        $links[] = array('lang_nav' => lang('administration'),
          'url_nav' => $GLOBALS['anthill']->link('/index.php',
            array('menuaction' => 'anthill.uiadmin.index')
          )
        );

      }
      return $links;
    }

   function page_footer()
   {
     $GLOBALS['anthill']->tpl->set_file('footer', 'footer.tpl');
     $GLOBALS['anthill']->tpl->set_var('url_img', 
$GLOBALS['anthill']->get_img('Anthillbutton'));
     $GLOBALS['anthill']->tpl->set_var('lang_powered_by',  lang('Powered by 
Anthill!'));
     $GLOBALS['anthill']->tpl->set_var('url_anthill', 
'http://anthill.vmlinuz.ca/');
     $GLOBALS['anthill']->tpl->set_var('lang_copyright', lang('&copy 2001-2003 
Danen Consulting Services; all rights reserved.'));
     $GLOBALS['anthill']->tpl->pfp('out', 'footer');
   }

   function page_header($page_title = False)
   {
     if($GLOBALS['anthill_info']['mode'] == 'anthill')
     {
       $page_title = ($page_title ? ' - ' . $page_title : '');
       $GLOBALS['anthill']->tpl->set_file('head', 'header.tpl');

       $GLOBALS['anthill']->tpl->set_var($GLOBALS['anthill_info']['config']);
       $GLOBALS['anthill']->tpl->set_var('charset', 
$GLOBALS['anthill_info']['charset']['meta_lang']);
       $GLOBALS['anthill']->tpl->set_var('page_title', $page_title);
       $GLOBALS['anthill']->tpl->set_var('css', $GLOBALS['anthill']->css());

       $GLOBALS['anthill']->tpl->pfp('out', 'head');
       navbar();
     }
     else
     {
       //phpgw stuff to go here
     }
   }

   function navbar()
   {
     $GLOBALS['anthill']->tpl->set_file('nav', 'nav.tpl');

     $GLOBALS['anthill']->tpl->set_var('url_home', 
$GLOBALS['anthill']->link('index.php',
       array('menuaction' => 'anthill.ui.index')));
     $GLOBALS['anthill']->tpl->set_var('lang_home', lang('home'));

     $GLOBALS['anthill']->tpl->set_block('nav', 'nav_link', 'nav_links');
     $links = get_nav_links();
     foreach ($links as $link)
     {
       $GLOBALS['anthill']->tpl->set_var($link);
       $GLOBALS['anthill']->tpl->parse('nav_links', 'nav_link', true);
     }

     $GLOBALS['anthill']->tpl->set_var('cur_user', lang('current user: %1', 
$GLOBALS['anthill_info']['user']['name']));

     $GLOBALS['anthill']->tpl->pfp('out', 'nav');
   }


/******************************************************************************\
* ALL OF THIS CODE WILL EVENTUALLY MOVED - DO NOT RELY ON IT BEING HERE 2MORO  *
\******************************************************************************/

  function d_getTime($date)
  {
    $year  = substr($date,0,4);
    $mon   = substr($date,4,2);
    $day   = substr($date,6,2);
    $hour  = substr($date,8,2);
    $min   = substr($date,10,2);
    $sec   = substr($date,12,2);
    return date($GLOBALS['anthill_info']['format']['date'] . ' '
      . 
$GLOBALS['anthill_info']['format']['time'],mktime($hour,$min,$sec,$mon,$day,$year));
  }

  function d_StartPage($ptitle)
  {
    //move to ui layer
    echo 'depreciated call';
  }

  function d_DrawIndex()
  {
    $sitename     = $GLOBALS['anthill_info']['config']['sitename'];
    $content      = $GLOBALS['anthill_info']['config']['siteblurb'];
    t_index($sitename, $content);
  }

  function d_DrawHeader($option)
  {
    t_header($option);
  }

  function d_DrawNav($ulogin)
  {
    //move to ui layer
    echo 'depreciated call';
  }

  function d_DrawFooter()
  {
    $name         = _NAME;
    $version      = _VERSION;
    $copyright    = gettext("Copyright &copy; 2001-2003 <a 
href=\"http://www.danen.ca/\";>Danen Consulting Services</a>; all rights 
reserved.");
    $weburl       = $GLOBALS['anthill_info']['path']['webroot'];
    t_footer($name, $version, $copyright, $weburl);
  }

  function d_DrawNewUser()
  {
    global $config;
    $sitename     = $config['sitename'];
    $content      = stripslashes($config['newublurb']);
    $name         = _NAME;
    $form         = "newuser.php";
    t_newuser($sitename, $content, $name, $form);
  }

  function d_DrawQueryForm($uid)
  {
    global $config;
    $sitename = $config['sitename'];
    // get status
    $statopts = NULL; $useropts = NULL; $user2opts = NULL; $prodopts = NULL;
    $count    = 0;
    $GLOBALS['anthill']->db->query("SELECT * FROM status_d");
    while ($db->next_record())
    {
      $status[$count] = array("id" => $db->record['id'], "name" => 
$db->record['name']);
      $count++;
    }
    while (list($key, $val) = each($status))
    {
      $statopts .= sprintf("<option value=\"%s\">%s</option>", 
$val['id'],$val['name']);
    }
    // get products
    $count    = 0;
    $db->query("SELECT * FROM products WHERE deleted = '0'");
    while ($db->next_record())
    {
      $prod[$count] = array("id" => $db->record['pid'], "name" => 
$db->record['name']);
      $count++;
    }
    while (list($key, $val) = each($prod))
    {
      $prodopts .= sprintf("<option value=\"%s\">%s</option>", 
$val['id'],$val['name']);
    }
    // get users
    $count    = 0;
    $db->query("SELECT * FROM users");
    while ($db->next_record())
    {
      $user[$count] = array("uid" => $db->record['uid'], "email" => 
$db->record['email']);
      $count++;
    }
    while (list($key, $val) = each($user))
    {
      $useropts .= sprintf("<option value=\"%s\">%s</option>", 
$val['uid'],$val['email']);
    }
    // get users without current user
    $count    = 0;
    $db->query("SELECT * FROM users WHERE uid != '$uid'");
    while ($db->next_record())
    {
      $user2[$count] = array("uid" => $db->record['uid'], "email" => 
$db->record['email']);
      $count++;
    }
    if (is_array($user2))
    {
      while (list($key, $val) = each($user2))
      {
        $user2opts .= sprintf("<option value=\"%s\">%s</option>", 
$val['uid'],$val['email']);
      }
    }
    else
    {
      $user2opts = "";
    }
    t_queryform($sitename, $statopts, $useropts, $user2opts, $prodopts);
  }

  function d_DrawPref($uid)
  {
    global $config, $db;

    $db->query("SELECT * FROM users WHERE uid = '$uid'");
    $db->next_record();
    $user  = $db->record;

    $sitename     = $config['sitename'];
    $content      = stripslashes($config['prefblurb']);
    $form         = "pref.php";
    $uname        = $user['uname'];
    $rname        = $user['name'];
    $email        = $user['email'];
    $cookieval    = $user['cookietimeout'];
    $laston       = $user['laston'];
    $epref        = $user['epref'];
    if ($laston == "")
    {
      $laston     = gettext("This is your first login");
    }
    // get gpg info
    if (isset($user['gpg']))
    {
      $fp        = fopen($GLOBALS['anthill_info']['root'] . $user['gpg'], "r");
      $gpg       = fread($fp, filesize($GLOBALS['anthill_info']['root'] . 
$user['gpg']));
      fclose($fp);
      $dkeyform  = "<form method=\"post\" action=\"" . $form . "\">\n";
      $dkeyform .= "<input type=\"hidden\" name=\"go\" value=\"deletekey\">\n";
      $dkeyform .= "<input type=\"submit\" value=\"" . gettext("Delete Key") . 
"\"></form>\n";
    }
    else
    {
      $gpg      = "";
      $dkeyform = "";
    }

    t_pref($sitename, $content, $form, $uname, $rname, $email, $laston, $uid, 
$gpg, $dkeyform, $cookieval, $epref);
    $db->free();
  }

  function d_DrawLogin()
  {
    $form = "login.php";
    t_login($form);
  }

  function d_DrawEditProd($what, $pid)
  {
    global $db;

    // we can have two possible values of $what: insert or change
    if ($what == "insert")
    {
      $button = gettext("Add");
    }
    elseif ($what == "change")
    {
      $button = gettext("Change");
    }
    else
    {
      print("invalid call to d_DrawEditProd()");
      exit;
    }
    $db->query("SELECT * FROM products WHERE pid = '$pid'");
    $db->next_record();
    $product  = $db->record;
?>
    <form method="post" action="editproducts.php">
    <table border="0" cellpadding="0" cellspacing="0" width="100%">
      <tr>
        <td width="50%" align="right">
          <? print(gettext("Product")); ?>:
        </td>
        <td width="50%">
          <input type="text" name="name" size="50" maxlength="64" value="<? 
print($product['name']); ?>">
        </td>
      </tr>
      <tr>
        <td width="50%" align="right">
          <? print(gettext("Description")); ?>:
        </td>
        <td width="50%">
          <textarea name="description" cols="50" rows="2" wrap="Virtual"><? 
print($product['description']); ?></textarea>
        </td>
      </tr>
      <tr>
        <td width="50%" align="right">
          <input type="submit" value="<? print($button); ?>">
          <input type="hidden" name="action" value="<? print($what); ?>">
          <input type="hidden" name="pid" value="<? print($pid); ?>">
        </td>
        <td width="50%">
          &nbsp;
        </td>
      </tr>
    </table>
    </form>
<?
  $db->free();
  }

  function d_DrawEditVer($what, $vid, $pid)
  {
    global $db;

    // we can have two possible values of $what: insert or change
    if ($what == "insert") {
      $button = gettext("Add");
    } elseif ($what == "change") {
      $button = gettext("Change");
    } else {
      print("invalid call to d_DrawEditVer()");
      exit;
    }
    $db->query("SELECT * FROM versions WHERE vid = '$vid'");
    $db->next_record();
    $version = $db->record;
?>
    <form method="post" action="editversions.php">
    <table border="0" cellpadding="0" cellspacing="0" width="100%">
      <tr>
        <td width="50%" align="right">
          <? print(gettext("Version")); ?>:
        </td>
        <td width="50%">
          <input type="text" name="name" size="50" maxlength="64" value="<? 
print($version['name']); ?>">
        </td>
      </tr>
      <tr>
        <td width="50%" align="right">
          <input type="submit" value="<? print($button); ?>">
          <input type="hidden" name="action" value="<? print($what); ?>">
          <input type="hidden" name="vid" value="<? print($vid); ?>">
          <input type="hidden" name="pid" value="<? print($pid); ?>">
        </td>
        <td width="50%">
          &nbsp;
        </td>
      </tr>
    </table>
    </form>
<?
  $db->free();
  }

  function d_DrawEditComp($what, $cid, $pid)
  {
    global $db, $config;

    // we can have two possible values of $what: insert or change
    if ($what == "insert")
    {
      $button = gettext("Add");
    }
    elseif ($what == "change")
    {
      $button = gettext("Change");
    }
    else
    {
      print("invalid call to d_DrawEditComp()");
      exit;
    }
    $db->query("SELECT * FROM components WHERE cid = '$cid'");
    $db->next_record();
    $component = $db->record;
    $owner     = $component['owner'];
    $db->free();
    $db->query("SELECT * FROM users WHERE uid = '$owner'");
    $db->next_record();
    $uid       = $db->record;
?>
    <form method="post" action="editcomponents.php">
    <table border="0" cellpadding="0" cellspacing="0" width="100%">
      <tr>
        <td width="50%" align="right">
          <? print(gettext("Component")); ?>:
        </td>
        <td width="50%">
          <input type="text" name="name" size="50" maxlength="64" value="<? 
print($component['name']); ?>">
        </td>
      </tr>
      <tr>
        <td width="50%" align="right">
          <? print(gettext("Description")); ?>:
        </td>
        <td width="50%">
          <textarea name="description" cols="50" rows="2" wrap="Virtual"><? 
print($component['description']); ?></textarea>
        </td>
      </tr>
      <tr>
        <td width="50%" align="right">
          <? print(gettext("Initial Owner")); ?>:
        </td>
        <td width="50%">
          <select name="owner" value="<? print($uid['uid']); ?>">
          <? $db->free();
             $db->query("SELECT * FROM users WHERE (access >= '" . 
$config['devac'] . "') AND (deleted = '0')");
             while ($db->next_record()) {
               $user = $db->record;
               $sel  = "";
               if ($uid['uid'] == $user['uid']) {
                 $sel = "selected";
               }
               print(sprintf("<option value=\"%s\" 
%s>%s</option>\n",$user['uid'],$sel,$user['email']));
             }
          ?>
          </select>
        </td>
      </tr>
      <tr>
        <td width="50%" align="right">
          <? print(gettext("Auto CC (separate by commas)")); ?>:
        </td>
        <td width="50%">
          <input type="text" name="autocc" size="50" maxlength="100" value="<? 
print($component['autocc']); ?>">
        </td>
      </tr>
      <tr>
        <td width="50%" align="right">
          <input type="submit" value="<? print($button); ?>">
          <input type="hidden" name="action" value="<? print($what); ?>">
          <input type="hidden" name="cid" value="<? print($cid); ?>">
          <input type="hidden" name="pid" value="<? print($pid); ?>">
        </td>
        <td width="50%">
          &nbsp;
        </td>
      </tr>
    </table>
    </form>
    <p><? print(gettext("Auto CC is used to automatically add email addresses 
to new bugs assigned to this component.  This is a comma delimited list (ie. 
'address@hidden,address@hidden')")); ?></p>
<?
  $db->free();
  }

  function d_DrawEditUser($moduserid) {
    global $config, $db;

    $db->query("SELECT * FROM users WHERE uid = '$moduserid'");
    $db->next_record();
    $utmp  = $db->record;
?>
    <form method="post" action="editusers.php">
    <table border="0" cellpadding="0" cellspacing="0" width="100%">
      <tr>
        <td width="50%" align="right">
          <? print(gettext("User Name")); ?>:
        </td>
        <td width="50%">
          <input type="text" name="uname" size="50" maxlength="64" value="<? 
print($utmp['uname']); ?>">
        </td>
      </tr>
      <tr>
        <td width="50%" align="right">
          <? print(gettext("Real Name")); ?>:
        </td>
        <td width="50%">
          <input type="text" name="name" size="50" maxlength="64" value="<? 
print($utmp['name']); ?>">
        </td>
      </tr>
      <tr>
        <td width="50%" align="right">
          <? print(gettext("Email Address")); ?>:
        </td>
        <td width="50%">
          <input type="text" name="email" size="50" maxlength="64" value="<? 
print($utmp['email']); ?>">
        </td>
      </tr>
      <tr>
        <td width="50%" align="right">
          <? print(gettext("Access Level")); ?>:
        </td>
        <td width="50%">
          <select name ="access">
            <option value="<? print($config['defaultac']); ?>" <? if 
($utmp['access'] == $config['defaultac']) { print("SELECTED"); } ?>><? 
print(gettext("Basic User")); ?></option>
            <option value="<? print($config['devac']); ?>" <? if 
($utmp['access'] == $config['devac']) { print("SELECTED"); } ?>><? 
print(gettext("Developer")); ?></option>
            <option value="<? print($config['adminac']); ?>" <? if 
($utmp['access'] == $config['adminac']) { print("SELECTED"); } ?>><? 
print(gettext("Administrator")); ?></option>
          </select>
        </td>
      </tr>
      <tr>
        <td width="50%" align="right">
          <? print(gettext("New Password")); ?>:
        </td>
        <td width="50%">
          <input type="password" name="pass1" size="50" maxlength="64" value="">
        </td>
      </tr>
      <tr>
        <td width="50%" align="right">
          <? print(gettext("New Password (re-enter)")); ?>:
        </td>
        <td width="50%">
          <input type="password" name="pass2" size="50" maxlength="64" value="">
        </td>
      </tr>
      <tr>
        <td width="50%" align="right">
          <input type="submit" value="<? print(gettext("Change")); ?>">
          <input type="hidden" name="action" value="change">
          <input type="hidden" name="moduserid" value="<? print($moduserid); 
?>">
        </td>
        <td width="50%">
          &nbsp;
        </td>
      </tr>
    </table>
    </form>
<?
  $db->free();
  }

  function d_DrawCAttach($bug)
  {
    global $config;

    t_cattach($bug, $config['maxfsize']);
  }

  function d_DoDiff($bugnum)
  {
    global $config, $db, $_USER;

    $db2         = new db_Sql();
    $db2->host   = $GLOBALS['anthill_info']['db_host'];
    $db2->dbase  = $GLOBALS['anthill_info']['db_name'];
    $db2->user   = $GLOBALS['anthill_info']['db_user'];
    $db2->passwd = $GLOBALS['anthill_info']['db_pw'];
    $db2->connect();

    $db->query("SELECT * FROM bugs WHERE bid = '$bugnum'");
    $db->next_record();
    $bug      = $db->record;
    $db->free();
    $db->query("SELECT * FROM users WHERE uid = '" . $bug['assigned'] . "'");
    $db->next_record();
    $assigned = $db->record['email'];
    $db->free();
    $db->query("SELECT * FROM users WHERE uid = '" . $_USER['uid'] . "'");
    $db->next_record();
    $callinguser = NULL;
    if ($db->record['epref'] == 0) // user doesn't want to receive their changes
    {
      $callinguser = $db->record['email'];
    }
    $db->query("SELECT * FROM users WHERE uid = '" . $bug['reporter'] . "'");
    $db->next_record();
    $reported = $db->record['email'];
    $db->free();
    $db->query("SELECT * FROM status_d WHERE id = '" . $bug['status'] . "'");
    $db->next_record();
    $statx    = $db->record['name'];
    $db->free();
    if ($bug['resolution'] != "")
    {
      $db->query("SELECT * FROM resolve_d WHERE id = '" . $bug['resolution'] . 
"'");
      $db->next_record();
      $resolve = $db->record['name'];
      $db->free();
      if ($bug['fixedver'] != "") {
        $fixver = $bug['fixedver'];
      }
      else
      {
        $fixver = NULL;
      }
    }
    else
    {
      $resolve = NULL;
    }
    $db->query("SELECT * FROM priority_d WHERE id = '" . $bug['priority'] . 
"'");
    $db->next_record();
    $priority = $db->record['name'];
    $db->free();
    $db->query("SELECT * FROM components WHERE cid = '" . $bug['component'] . 
"'");
    $db->next_record();
    $compt    = $db->record['name'];
    $db->free();
    $db->query("SELECT * FROM products WHERE pid = '" . $bug['product'] . "'");
    $db->next_record();
    $product  = $db->record['name'];
    $db->free();
    $db->query("SELECT * FROM versions WHERE vid = '" . $bug['version'] . "'");
    $db->next_record();
    $version  = $db->record['name'];
    $db->free();

    if ($bug['private'] == 0)
    {
      $priv   = gettext("PUBLIC");
    }
    else
    {
      $priv   = gettext("PRIVATE");
    }

      // get the maximum string length to format the email nicely
      // we do not use gettext here; all diffs are abitrarily in english
      // (this prevents multi-language erroneous diffs if users use
      // different languages)
      $msg[0]   = "Bug#";
      $msg[1]   = "Product";
      $msg[2]   = "Version";
      $msg[3]   = "Status";
      $msg[4]   = "Priority";
      $msg[5]   = "Component";
      $msg[6]   = "URL";
      $msg[7]   = "Assigned To";
      $msg[8]   = "Reported By";
      $msg[9]   = "Type";
      $msg[10]  = "Summary";
      $msg[11]  = "Resolution";
      $msg[12]  = "Fixed Ver";
      $limit    = count($msg);
      $size     = 0;
      for ($i=0; $i < $limit; $i++)
      {
        if (strlen($msg[$i]) > $size) {
          $size = strlen($msg[$i]);
        }
      }
      for ($i=0; $i < $limit; $i++)
      {
        $buff = $size - strlen($msg[$i]);
        if ($buff > 0)
        {
          $msg[$i] = $msg[$i] . str_repeat(" ", $buff);
        }
      }

    // need to find way to format a little nicer dependant on length of
    // defined strings
    $tmpdesc    = $msg[0]  . ": " . stripslashes($bugnum) . "\n";
    $tmpdesc   .= $msg[1]  . ": " . stripslashes($product) . "\n";
    $tmpdesc   .= $msg[2]  . ": " . stripslashes($version) . "\n";
    $tmpdesc   .= $msg[3]  . ": " . $statx . "\n";
    if (isset($resolve))
    {
      $tmpdesc .= $msg[11] . ": " . $resolve . "\n";
      $tmpdesc .= $msg[12] . ": " . $fixver . "\n";
    }
    $tmpdesc   .= $msg[4]  . ": " . $priority . "\n";
    $tmpdesc   .= $msg[5]  . ": " . stripslashes($compt) . "\n";
    $tmpdesc   .= $msg[6]  . ": " . stripslashes($bug['url']) . "\n";
    $tmpdesc   .= $msg[7]  . ": " . $assigned . "\n";
    $tmpdesc   .= $msg[8]  . ": " . $reported . "\n";
    $tmpdesc   .= $msg[9]  . ": " . $priv . "\n\n";
    $tmpdesc   .= $msg[10] . ": " . stripslashes($bug['shortdesc']) . "\n\n";

    $db->query("SELECT * FROM bugdesc WHERE bid = '" . $bug['bid'] . "'");
    while ($db->next_record())
    {
      $ldesc    = $db->record;
      $db2->query("SELECT * FROM users WHERE uid = '" . $ldesc['user'] . "'");
      $db2->next_record();
      $rep      = $db2->record;
      $tmpdesc .= sprintf("Comment posted: %s by %s", 
d_getTime($ldesc['date']), $rep['email']) . "\n\n";
      $tmpdesc .= stripslashes($ldesc['description']) . "\n\n";
      $db2->free();
    }
    $db->free();

    $oldfile = $GLOBALS['anthill_info']['shadowdir'] . "/" . $bugnum;
    $tmpfile = tempnam($GLOBALS['anthill_info']['shadowdir'],$bugnum . ".tmp.");
    if (file_exists($tmpfile))
    {
      $fp = fopen($tmpfile, "w");
      fwrite($fp, $tmpdesc);
      fclose($fp);
    }
    else
    {
      echo '<p><font color="red">' . gettext("Error: Cannot open temporary 
file.") . '</font></p>';
    }

    // create oldfile if it doesn't exist otherwise diff will not create the
    // initial diff file
    if (!file_exists($oldfile))
    {
      $fp = fopen($oldfile, "w");
      fwrite($fp, "");
      fclose($fp);
    }

    // create the diff
    $stmpfile = ereg_replace($GLOBALS['anthill_info']['shadowdir'] . 
"/","",$tmpfile);
    $antdiff  = tempnam($GLOBALS['anthill_info']['tmpdir'],"ant-diff.");
    $cmd      = sprintf("%s -ruN %s/$bugnum 
%s/$stmpfile",$GLOBALS['anthill_info']['difftool'],$GLOBALS['anthill_info']['shadowdir'],$GLOBALS['anthill_info']['shadowdir']);
    $output   = exec($cmd,$diffarray,$return);
    if ($return == 1) // there are differences
    {
      $x = implode($diffarray,"\n");
      $x = ereg_replace($GLOBALS['anthill_info']['shadowdir']."/","",$x);
    }
    else
    {
      $x = "";
    }
    if (file_exists($antdiff)) {
      $fp = fopen($antdiff, "w");
      fwrite($fp, $x);
      fclose($fp);
    }
    else
    {
      echo '<p><font color="red>' . gettext("Error: Cannot open diff file.") . 
'</font></p>';
    }

    // move new bug desc file to old
    unlink($oldfile)
      or die ("Cannot delete $oldfile");
    rename($tmpfile, $oldfile)
      or die ("Cannot rename $tmpfile to $oldfile");

    // send email to assigned user and all cc's
    $message = $GLOBALS['anthill_info']['webroot'] . "/query.php?bug=" . 
$bugnum . "\n\n";
    $db->query("SELECT * FROM bugs WHERE bid = '$bugnum'");
    $db->next_record();
    $bugx    = $db->record;
    $db->free();

    $diffmsg  = file($antdiff);
    $q        = $GLOBALS['anthill_info']['webroot'] . "/query.php";
    $diffmsg  = str_replace("query.php", $q, $diffmsg);
    $s        = $GLOBALS['anthill_info']['webroot'] . "/showattachment.php";
    $diffmsg  = str_replace("showattachment.php", $s, $diffmsg);

    // delete diff file after use
    unlink($antdiff)
      or die ("Cannot delete $antdiff");

    $diffnum  = count($diffmsg);
    if ($diffnum == 0)
    {
      echo '<span class="text"><font color="red">' . gettext("There was an 
error or you entered no information when saving changes; diff is empty!") . 
'</font></span>';
    }
    $message .= implode($diffmsg, "");

    $db->query("SELECT * FROM users WHERE uid = '" . $bugx['assigned'] . "'");
    $db->next_record();
    $userx  = $db->record;
    $db->free();

    // make our cc list, try and remove all duplicate addresses
    $cclist = $userx['email'] . ", " . $reported;
    if ($bugx['cc'] != "") // make sure we don't add an extra ", " to the list 
this way
    {
      $cclist = $cclist . ", " . $bugx['cc'];
    }
    $cclist = explode(", ",$cclist);
    $tempcc = array_unique($cclist);
    $cc     = array();
    foreach ($tempcc as $element)
    {
      if($element != $callinguser) // user doesn't want mail
      {
          array_push($cc, $element);
      }
    }

/*
    $tempcc = "";
    for ($i=0; $i < count($cclist); $i++) {
      $pattern = ereg_replace("@","\@",$cclist[$i]);
      if (is_array($cc)) $tempcc = implode($cc, ", ");
      if ($cclist[$i] != $userx['email'] || !ereg($pattern, $tempcc)) {
        if (is_array($cc)) $tempcc = implode($cc, ", ");
#          if (!ereg($pattern, $tempcc)) {
            if ($cclist[$i] != $userx['email']) {
              $cc[$i] = $cclist[$i];
#            }
          }
      }
    }
*/
    // reconstruct the list
    if (count($cc) > 1) // more than one recipient
    {
      $emailto = $cc[0];
      unset($cc[0]);
      $cc = implode($cc, ", ");
    }
    else
    {
      $emailto = $cc[0];
      $cc = "";
    }
    if ($config['mdaemonreplyto'] != "") {
      $replyto = "Reply-To: " . $config['mdaemonreplyto'] . "\n";
    } else {
      $replyto = "";
    }
    if ($emailto != "") {
      $retval = @mail($emailto,
              "[Bug #" . $bugnum . "] [" . stripslashes($compt) . "] " . 
stripslashes($bug['shortdesc']), $message,
              "From: " . $config['mdaemon'] . " <" . $config['memail'] . 
">\nCc: " . $cc . "\n" . $replyto . "Return-Path: <" . $config['memail'] . 
">\r\nX-Mailer: " . _NAME . " " . _VERSION);
    }
  }

  function d_DoSearchList($search) {
    global $user, $db;

    // query retrieves only the bugid (bid)
    $count  = 0;
    $query  = "SELECT * FROM bugs WHERE (shortdesc like '%$search%'";
    $query .= "OR shortdesc like '$search%'";
    $query .= "OR shortdesc like '%$search')";
    $db->query($query);
    while ($db->next_record()) {
      $btmp[$count] = $db->record['bid'];
      $count++;
    }
    $db->free();
    $query  = "SELECT * FROM bugdesc WHERE (description like '%$search%'";
    $query .= "OR description like '$search%'";
    $query .= "OR description like '%$search')";
    $db->query($query);
    while ($db->next_record()) {
      $btmp[$count] = $db->record['bid'];
      $count++;
    }
    $db->free();

    // sort and remove duplicates
    if ($btmp) { // test if there is anything in btmp first otherwise we get 
errors
      sort($btmp);
    }
    $lastbid = 0;
    $x       = 0;
    for ($i=0; $i<count($btmp); $i++) {
      if ($btmp[$i] != $lastbid) {
        $db->query("SELECT * FROM bugs WHERE bid = '" . $btmp[$i] . "'");
        $db->next_record();
        $bugs = $db->record;
        if ($bugs['private'] == 1 && !isset($user['uid'])) {
          continue;
        }
        $db->free();
        $x++;
?>
    <tr>
      <td valign="top">
        <a href="query.php?bug=<? print($bugs['bid']); ?>"><? 
print($bugs['bid']); ?></a>&nbsp;
      </td>
      <td valign="top">
        <? $db->query("SELECT * FROM products WHERE pid = '" . $bugs['product'] 
. "'");
           $db->next_record();
           print($db->record['name']);
           $db->free();
        ?>&nbsp;
      </td>
      <td valign="top">
        <? $db->query("SELECT * FROM components WHERE cid = '" . 
$bugs['component'] . "'");
           $db->next_record();
           print($db->record['name']);
           $db->free();
        ?>&nbsp;
      </td>
      <td valign="top">
        <? $db->query("SELECT * FROM priority_d WHERE id = '" . 
$bugs['priority'] . "'");
           $db->next_record();
           print($db->record['name']);
           $db->free();
        ?>&nbsp;
      </td>
      <td valign="top">
        <? $db->query("SELECT * FROM users WHERE uid = '" . $bugs['assigned'] . 
"'");
           $db->next_record();
           print($db->record['email']);
           $db->free();
        ?>&nbsp;
      </td>
      <td valign="top">
        <? $db->query("SELECT * FROM status_d WHERE id = '" . $bugs['status'] . 
"'");
           $db->next_record();
           print($db->record['name']);
           $db->free();
        ?>&nbsp;
      </td>
      <td valign="top">
        <? if ($bugs['resolution'] != "") {
             $db->query("SELECT * FROM resolve_d WHERE id = '" . 
$bugs['resolution'] . "'");
             $db->next_record();
             print($db->record['name']);
             $db->free();
           }
        ?>&nbsp;
      </td>
      <td valign="top">
        <? print(stripslashes($bugs['shortdesc'])); ?>
      </td>
    </tr>
<?
      }
      $lastbid = $btmp[$i];
    }
  return($x);
  }

  function d_DoBugList($query) {
    global $user, $db;

    $db2         = new db_Sql();
    $db2->host   = $GLOBALS['anthill_info']['db_host'];
    $db2->dbase  = $GLOBALS['anthill_info']['db_name'];
    $db2->user   = $GLOBALS['anthill_info']['db_user'];
    $db2->passwd = $GLOBALS['anthill_info']['db_pw'];
    $db2->connect();

    $db->query($query);
    $count   = 0;
    while ($db->next_record())
    {
      $bugs = $db->record;
      if ($bugs['private'] == 1 && !isset($user['uid']))
      {
        continue;
      }
      $count++;
?>
    <tr>
      <td valign="top">
        <a href="query.php?bug=<? print($bugs['bid']); ?>"><? 
print($bugs['bid']); ?></a>&nbsp;
      </td>
      <td valign="top">
        <? $db2->query("SELECT * FROM products WHERE pid = '" . 
$bugs['product'] . "'");
           $db2->next_record();
           print($db2->record['name']);
           $db2->free();
        ?>&nbsp;
      </td>
      <td valign="top">
        <? $db2->query("SELECT * FROM components WHERE cid = '" . 
$bugs['component'] . "'");
           $db2->next_record();
           print($db2->record['name']);
           $db2->free();
        ?>&nbsp;
      </td>
      <td valign="top">
        <? $db2->query("SELECT * FROM priority_d WHERE id = '" . 
$bugs['priority'] . "'");
           $db2->next_record();
           print($db2->record['name']);
           $db2->free();
        ?>&nbsp;
      </td>
      <td valign="top">
        <? $db2->query("SELECT * FROM users WHERE uid = '" . $bugs['assigned'] 
. "'");
           $db2->next_record();
           print($db2->record['email']);
           $db2->free();
        ?>&nbsp;
      </td>
      <td valign="top">
        <? $db2->query("SELECT * FROM status_d WHERE id = '" . $bugs['status'] 
. "'");
           $db2->next_record();
           print($db2->record['name']);
           $db2->free();
        ?>&nbsp;
      </td>
      <td valign="top">
        <? if ($bugs['resolution'] != "") {
             $db2->query("SELECT * FROM resolve_d WHERE id = '" . 
$bugs['resolution'] . "'");
             $db2->next_record();
             print($db2->record['name']);
             $db2->free();
           }
        ?>&nbsp;
      </td>
      <td valign="top">
        <? print(stripslashes($bugs['shortdesc'])); ?>
      </td>
    </tr>
<?
    }
  return($count);
  }

  function d_mailUser($subject)
  {
    global $config, $db;

    $bugurl = $GLOBALS['anthill_info']['webroot'] . "/query.php?bug=BUG";

    switch($subject)
    {
      case "NEW":
        $msg   = sprintf(gettext("There are new bugs assigned to you.  Please 
accept them or assign them to\nsomeone else by going to %s\n\n"), $bugurl);
        $query = "SELECT assigned, shortdesc, bid FROM bugs WHERE status = '1'";
        break;
      case "UNRESOLVED":
        $msg   = sprintf(gettext("There are unresolved bugs assigned to you. 
This is a reminder that you\nhave open bugs in the bug system.\n\n%s\n\n"), 
$bugurl);
        $query = "SELECT assigned, shortdesc, bid FROM bugs WHERE (status = '2' 
OR status = '3' OR status = '5')";
        break;
    }

    $db->query($query);
    if ($db->num_rows() > 0)
    {
      $db2         = new db_Sql();
      $db2->host   = $GLOBALS['anthill_info']['db_host'];
      $db2->dbase  = $GLOBALS['anthill_info']['db_name'];
      $db2->user   = $GLOBALS['anthill_info']['db_user'];
      $db2->passwd = $GLOBALS['anthill_info']['db_pw'];
      $db2->connect();
      while($db->next_record())
      {
        $bid       = $db->record['bid'];
        $shortdesc = stripslashes($db->record['shortdesc']);
        $assigned  = $db->record['assigned'];
        $db2->query("SELECT email FROM users WHERE uid = '$assigned'");
        $db2->next_record();
        $email     = $db2->record['email'];
        $db2->free();
        $db2->query("SELECT user, description FROM bugdesc WHERE bid = '$bid' 
ORDER BY date LIMIT 1");
        $db2->next_record();
        $rid       = $db2->record['user'];
        $ldesc     = $db2->record['description'];
        $db2->free();
        $db2->query("SELECT email FROM users WHERE uid = '$rid'");
        $db2->next_record();
        $reporter  = $db2->record['email'];
        $db2->free();

        $message  = str_replace("BUG","$bid",$msg);
        $message .= "\n\nReported by: $reporter";
        $message .= "\n\nShort Description:\n$shortdesc";
        $message .= "\n\nLong Description:\n" . stripslashes($ldesc);
        $message .= "\n\n--\n" . $GLOBALS['anthill_info']['webroot'];

        $retval = @mail($email, "[$subject BUG #$bid] $shortdesc", $message,
                        "From: " . $config['mdaemon'] . " <" . 
$config['memail'] . ">\r\nReturn-Path: <" . $config['memail'] . ">\r\nX-Mailer: 
" . _NAME . " " . _VERSION);
      }
    }
    $db->free();
  }

  function d_TransURL($url, $blank)
  {
    // if this is an escaped url (ie. someone entered it using <a 
href="">bla</a> do not htmlize it as
    // a) it would be bad form and b) it looks horrible.
    if (ereg(".*lt;a\ href.*quot;.*gt;.*",$url) || ereg(".*quot;.*gt;.*",$url)) 
return($url);

    if ($blank==1)
    {
      $trans = preg_replace("/((http(s?):\/\/)|(www\.))([\S\.]+)\b/i",
        "<a href=\"http$3://$4$5\" target=\"_blank\">$2$4$5</a>", $url);
    }
    else
    {
      $trans = preg_replace("/((http(s?):\/\/)|(www\.))([\S\.]+)\b/i",
        "<a href=\"http$3://$4$5\">$2$4$5</a>", $url);
    }
    return($trans);
  }

  function z_MakeDropDown($formField, $lookupTable, $lookupField, 
$lookupDisplay, $nodeleted)
  {
    // code for this function under GPL and contributed/copyright
    // by Ali Ziad
    global $db;
    if ($nodeleted == 1) {
      $query = "SELECT $lookupField,$lookupDisplay FROM $lookupTable WHERE 
deleted = '0'";
    }
    else
    {
      $query = "SELECT $lookupField,$lookupDisplay FROM $lookupTable";
    }
    $db->query($query);
    $result  = "<select size=1 name=\"$formField\">";
    $result .= "<option value=-1> * All " . ucfirst($lookupTable) . "</option>";
    while ($db->next_record())
    {
      $result .= "<option value=\"" . $db->record[$lookupField] . "\"> " . 
$db->record[$lookupDisplay] . "</option> ";
    }
    $db->free();
    $result .= "</select>";
    return($result);
  }

  function z_MakeDateRangeDropDown($formField)
  {
    // code for this function under GPL and contributed/copyright
    // by Ali Ziad
    $today = getdate();
    $month = $today['month'];
    $mday  = $today['mday'];
    $year  = $today['year'];

    $months = array("1"=>"January","2"=>"Febuary","3"=>"March","4"=>"April",
        "5"=>"May","6"=>"June","7"=>"July","8"=>"August",
        "9"=>"September","10"=>"October","11"=>"November","12"=>"December");

    $result = "<select name=\"$formField" . "_day\">";
    for ($i=1; $i<32; $i++)
    {
      $result .= "<option value=\"$i\"> $i </option>";
    }
    $result .= "</select> ";

    $result .= "<select name=\"$formField" ."_month\">";
    while (list($month, $month_name) = each($months))
    {
      $result .= "<option value=\"$month\"> $month_name </option> ";
    }
    $result .= "</select> ";

    $result .= "<select name=\"$formField" . "_year\">";
    for ($i=2001; $i<($year+1); $i++)
    {
      $result .= "<option value=\"$i\"> $i </option>";
    }
    $result .= "</select> ";
    return($result);
  }


  function z_MakeFieldCheckBoxes($TableName)
  {
    // code for this function under GPL and contributed/copyright
    // by Ali Ziad
    global $db;
    $db->query("SELECT * FROM $TableName LIMIT 1");
    for ($i=0; $i<$db->num_rows(); $i++) {
      $db->next_record();
      $meta = $db->record();
      if ($meta) {
        $result .= "<INPUT TYPE=\"checkbox\" NAME=\"show_" . $meta['name'] . 
"\" CHECKED>" . $meta['name'];
      }
    }
    return($result);
  }

  function z_MakeSelectFieldsList($TableName)
  {
    // code for this function under GPL and contributed/copyright
    // by Ali Ziad
    global $db;
    $db->query("SELECT * FROM $TableName LIMIT 1");
    $db->next_record();
    $num_fields = $db->num_fields();
    $c=4;
    $t=0;
    $result="\n<table border=0 width=\"100%\" cellspacing=2>\n\t<tr>\n";
    for ($nSort=0; $nSort<$num_fields; $nSort++)
    {
      if ($t == $c)
      {
        $result.="\t</tr>\n\t<tr>\n";
        $t=0;
      }
      $result .= "\t\t<td align=right width=15 valign=middle bgcolor=#bac2ca>". 
(string)($nSort+1) .".</td>\n";
      $result .= "\t\t<td align=center bgcolor=#bac2ca>\n\t\t\t<SELECT 
NAME=\"show_$nSort\" SIZE=1>\n";
      $options = '';
      for ($i=0; $i<$num_fields; $i++)
      {
        $meta = $db->fetch_fieldname($i);
        if ($meta)
        {
          // print "\n nSort = $nSort , i = $i  ";
          if ($i == $nSort) {
            $IS_SELECTED = 'SELECTED';
          }
          else
          {
            $IS_SELECTED= '';
          }
          $options .= "\t\t\t\t<OPTION VALUE=\"" . $meta . "\" $IS_SELECTED> " 
. $meta . "\n";
        }
     }
     $result .= $options;
     $result .= "\t\t\t\t<OPTION VALUE=\"\" SIZE=1> -------- \n";
     $result .= "\t\t\t</SELECT> \n\t\t</td>\n";
     $t++;
   }
   if ($t == $c)
   {
     $result.="\t</tr>\n</table>\n";
   }
   else
   {
     $r=($c - $t)*2;
     $result.="\t\t<td colspan=$r bgcolor=#bac2ca><hr 
width=75%></td>\n\t</tr>\n</table>\n";
   }
   return($result);
  }

  function z_MakeSortFieldsList($TableName)
  {
    // code for this function under GPL and contributed/copyright
    // by Ali Ziad
    global $db;
    $result = ''; $options = '';
    $db->query("SELECT * FROM $TableName LIMIT 1");
    $c=4;
    $t=0;
    $result="<table border=0 cellspacing=2 width=\"100%\">\n\t<tr>\n";
    for ($i=0 ; $i<$db->num_fields(); $i++) {
      $meta = $db->fetch_fieldname($i);
      if ($meta) {
        $options .= "\t\t\t\t<OPTION VALUE=\"" . $meta . "\"> " . $meta . "\n";
      }
    }

    for ($nSort=1; $nSort<13 ; $nSort++)
    {
      if ($t == $c)
      {
        $result.="\t</tr>\n\t<tr>\n";
        $t=0;
      }
      $result .= "\t\t<td align=right width=15 valign=middle 
bgcolor=#bac2ca>$nSort.</td>\n";
      $result .= "\t\t<td align=center bgcolor=#bac2ca>\n\t\t\t<SELECT 
NAME=\"sort_$nSort\" SIZE=1>\n";
      $result .= "\t\t\t\t<OPTION VALUE=\"\" SIZE=1 SELECTED> -------- \n";
      $result .= $options;
      $result .= "\t\t\t</SELECT> \n";
      $t++;
    }
   if ($t == $c)
   {
     $result.="\t</tr>\n</table>\n";
   }
   else
   {
     $r=($c - $t)*2;
     $result.="\t\t<td colspan=$r><hr width=75%></td>\n\t</tr>\n</table>\n";
   }
    return($result);
  }

  function z_CheckBoxesArray($handle, $SourceArray)
  {
    // code for this function under GPL and contributed/copyright
    // by Ali Ziad
    $l      = strlen($handle);
    $result = array();
    while (list($k,$v)= each($SourceArray))
    {
      if (!strncmp($k,$handle,$l))
      {
        $checked = substr($k, $l);
        // print "<br> |$k|$v|$handle| ($checked)";
        array_push($result, $checked);
      }
    }
    return($result);
  }

  function z_OrderedListArray($handle, $SourceArray)
  {
    // code for this function under GPL and contributed/copyright
    // by Ali Ziad
    $l      = strlen($handle);
    $result = array();
    while (list($k,$v)= each($SourceArray))
    {
      if (!strncmp($k,$handle,$l))
      {
        $checked = substr($k, $l);
        // print "<br> |$k|$v|$handle| ($checked)";
        $result[$checked] = $v;
      }
    }
    return($result);
  }

  function z_FormatFormDate($formatString, $datename, $SourceArray)
  {
    // code for this function under GPL and contributed/copyright
    // by Ali Ziad
    $day   = $SourceArray[$datename.'_day'];
    $month = $SourceArray[$datename.'_month'];
    $year  = $SourceArray[$datename.'_year'];
    return(date($formatString, mktime(0,0,0,$month,$day,$year)));
  }

  function z_MysqlDateRange($fieldName,$SourceArray)
  {
    // code for this function under GPL and contributed/copyright
    // by Ali Ziad
    $fromDate = z_FormatFormDate("Ymd000000",$fieldName .'_from',$SourceArray);
    $toDate   = z_FormatFormDate("Ymd000000",$fieldName .'_to',$SourceArray);
    $result   = " ( (bugs.$fieldName >= $fromDate)&&(bugs.$fieldName<=$toDate) 
) ";
    return($result);
  }

  function z_ParseQueryArguments($SourceArray)
  {
    // code for this function under GPL and contributed/copyright
    // by Ali Ziad
    $ScalarVars = array("product","component","priority","severity","status",
            "resolution","reporter","assigned");
    $Parameters = array();
    while (list($k,$v) = each ($ScalarVars) )
    {
      if (isset($SourceArray[$v]))
      {
        if ($SourceArray[$v] > -1)
        {
          array_push($Parameters," (bugs.$v = ".$SourceArray[$v].") ");
        }
        // if ($SourceArray[$v] > -1) print ("\n<br> (bugs.$v = 
".$SourceArray[$v].") ");
      }
    }
    if (isset($SourceArray['mrange']))
    {
      if ($SourceArray['mrange'])
      {
        array_push($Parameters,z_MysqlDateRange('modified',$SourceArray) );
      }
    }
    if (isset($SourceArray['crange']))
    {
      if ($SourceArray['crange'])
      {
        array_push($Parameters,z_MysqlDateRange('creation',$SourceArray) );
      }
    }
    return($Parameters);
  }


  function z_ComposeQuery($Parameters,$SortList)
  {
    // code for this function under GPL and contributed/copyright
    // by Ali Ziad
    // substitute for what's defined.
    $user_options = NULL;
    while (list($k,$v) = each ($Parameters))
    {
      $user_options .= $v . " and ";
    }
    $user_options .= " (1=1) ";

    $InOrder       = 0;
    $ORDER_BY_LIST = ' order by ';
    while (list($k,$v) = each ($SortList))
    {
      if (strlen($v)>0)
      {
        $InOrder = 1;
        $ORDER_BY_LIST .= $v . ',';
      }
    }
    if ($InOrder)
    {
      $p = strrpos($ORDER_BY_LIST,',');
      if ($p)
      {
        $ORDER_BY_LIST = substr($ORDER_BY_LIST,0,$p);
      }
    }
    else
    {
      $ORDER_BY_LIST = '';
    }

    $query = "\nselect bid, cc, private, url, products.name product, 
components.name component, versions.name version, shortdesc, severity_d.name 
severity,  "
           . "\n priority_d.name priority, status_d.name status, resolve_d.name 
resolution, u1.name assigned, u2.name reporter ,  "
           . "\n DATE_FORMAT(creation,\"%b. %e,%Y\") creation, 
DATE_FORMAT(modified,\"%b. %e,%Y\") modified "
           . "\n from 
bugs,products,components,versions,status_d,priority_d,severity_d, users u1, 
users u2 "
           . "\n left join resolve_d on resolve_d.id = resolution "
           . "\n where status_d.id = status and bugs.severity = severity_d.id 
and priority = priority_d.id "
           . "\n and bugs.product = products.pid and component = components.cid 
and version = versions.vid "
           . "\n and u1.uid = bugs.assigned and u2.uid = bugs.reporter "
           . "\n and ($user_options) "
           . "\n $ORDER_BY_LIST ";
    return($query);
  }

  function z_PrintResultSet($Columns, $Query)
  {
    // code for this function under GPL and contributed/copyright
    // by Ali Ziad
    global $db, $config;

    $db->query($Query);

    print("<table>");
    print("<tr bgcolor=" . $config['barcol1'] . ">");
    reset($Columns);
    $innercol = $Columns;

    while (list($k, $v) = each($Columns)) {
      if (strlen($v) > 0) {
        print("<td><font size=-1><b>$v</b></font></td>");
      }
    }
    print("</tr>");

    while ($db->next_record())
    {
      reset($innercol);
      print("<tr>");
      while (list($k, $v) = each($innercol))
      {
        if (strlen($v)>0)
        {
          if (strcmp($v,'bid'))
          {
            $record = stripcslashes($db->record[$v]);
            if ($v == "private")
            {
              if ($db->record[$v] == 0)
              {
                $record = "NO";
              }
              else
              {
                $record = "YES";
              }
            }
            print("<td bgcolor=#f2f2f2> <font size=-1>$record</font> </td>");
          }
          else
          {
            print("<td bgcolor=#f2f2f2> <font size=-1><a href=\"query.php?bug=" 
. $db->record['bid'] . "\">" . $db->record['bid'] . "</font></td>");
          }
        }
      }
      print("</tr>");
    }
    print("</table>");
  }

  function z_ShowSelectionGrid()
  {
    // code for this function under GPL and contributed/copyright
    // by Ali Ziad
    global $config;

    print "<center><form action=query.php method=post>";
    print "<table bgcolor=#dae2ea cellpadding=0 border=1 width=640>";
    print "<tr><td align=center valign=middle><br>";
    print "<table bgcolor=#dae2ea cellpadding=3 border=1 width=600>";
    print "<tr><td>Product   </td><td>" . 
z_MakeDropDown("product","products","pid","name",1) . "</td>";
    print "<td>Component </td><td>" . 
z_MakeDropDown("component","components","cid","name",1) . "</td></tr>";
    print "<tr><td>Priority </td><td>" . 
z_MakeDropDown("priority","priority_d","id","name",0) ."</td>";
    print "    <td>Severity </td><td>" . 
z_MakeDropDown("severity","severity_d","id","name",0) ."</td></tr>";
    print "<tr><td>Status   </td><td>" . 
z_MakeDropDown("status","status_d","id","name",0) . "</td>";
    print "<td> Resolution </td><td>" . 
z_MakeDropDown("resolution","resolve_d","id","name",0) . "</td></tr>";
    print "</table>";

    print "<table bgcolor=#dae2ea cellpadding=3 border=0 width=600>";
    print "<tr><td colspan=4> <input type=radio name=crange value=0 checked> 
Submited anytime !</td></tr>";
    print "<tr><td> <input type=radio name=crange value=1> Between </td> "
         ."<td>" . z_MakeDateRangeDropDown("creation_from") . "</td>";
    print "<td> And </td><td>" . z_MakeDateRangeDropDown("creation_to") . 
"</td></tr>";
    print "</table>";

    print "<table bgcolor=#dae2ea cellpadding=3 border=0 width=600>";
    print "<tr><td colspan=4> <input type=radio name=mrange value=0 checked> 
Modified anytime !</td></tr>";
    print "<tr><td> <input type=radio name=mrange value=1> Between </td> "
         ."<td>" . z_MakeDateRangeDropDown("modified_from") . "</td>";
    print "<td> And </td><td>" . z_MakeDateRangeDropDown("modified_to") . 
"</td></tr>";
    print "</table>";

    print "<table bgcolor=#dae2ea cellpadding=3 border=1 width=600>";
    print "<tr><td> Reported By   </td><td>" . 
z_MakeDropDown("reporter","users","uid","name",1) . "</td>";
    print "<td> Assigned To </td><td>" . 
z_MakeDropDown("assigned","users","uid","name",1) . "</td></tr>";
    print "</table>";

    print "<table bgcolor=#dae2ea cellpadding=3 border=0 width=600>";
    print "<tr><td> Fields to Display: <b><br><font size=-2> ";
    print z_MakeSelectFieldsList("bugs") . "</font></td></tr>";
    print "</table>";

    print "<table bgcolor=#dae2ea cellpadding=3 border=0 width=600>";
    print "<tr><td> Sort Fields<br> <b><font size=1>";
    print  z_MakeSortFieldsList("bugs") . "</font></td></tr>";
    print "</table>";

    print "<table bgcolor=#dae2ea cellpadding=3 border=0 width=600>";
    print "\n<tr><td colspan=2>&nbsp;</td></tr>";
    print "<tr><td align=center><input type=submit name=btnQuery value=\"Run 
Query\"></td></tr>";
    print "</table>";
    print "</td></tr></table>";
    print "</form></center>";
    print "<br>";
  }

  function d_doQuery($uid)
  {
    print("<p>" . gettext("For simple bug searching and reporting, use any of 
the following simple forms.") . "</p>");
    d_DrawQueryForm($uid);
    print("<br /><br /><p>" . gettext("For advanced bug searching and reporting 
capabilities, you can use the following form instead.") . "</p>");
    z_ShowSelectionGrid();
  }

  function d_DumpVdiff($product, $data)
  {
    print(sprintf("<tr><td><a 
href=\"query.php?bug=%s\">%s</a></td>",$data['bid'],$data['bid']));
    print("<td>$product</td>");
    print("<td>" . $data['fixedver'] . "</td>");
    print("<td>" . $data['shortdesc'] . "</td></tr>");
  }

  function d_AskVersion($product)
  {
    global $db;

    $db->query("SELECT * FROM products WHERE pid = '$product'");
    $db->next_record();
    $pname = $db->record['name'];
    $db->free();

    print("<p>" . sprintf(gettext("Requested difference between versions  for 
%s..."), $pname) . "</p>");
?>
    <form method="post" action="buglist.php">
    <input type="hidden" name="product" value=<? print($product); ?>">
    <table cellpadding="0" cellspacing="0" border="0" width="100%">
      <tr>
        <td valign="center">
          <? print(gettext("Check differences between version ")); ?>
          <input type="text" name="sversion" size="8" maxsize="8">
          <? print(" " . gettext("and version") . " "); ?>
          <input type="text" name="eversion" size="8" maxsize="8">
        </td>
        <tr>
        <tr>
          <td>
            <br /><input type="submit" value="<? print(gettext("Check")); ?>">
          </td>
        </tr>
      </table>
      </form>
<?php
  }
?>

====================================================
Index: site.inc.php
<?php
  // Anthill site include
  // $Id: site.inc.php,v 1.1 2005/05/05 00:34:03 skwashd Exp $

  ###########################################################################
  #
  # DO NOT TOUCH ANYTHING BELOW!!  DOING SO CAN RENDER YOUR SYSTEM UNUSABLE!!
  #
  ###########################################################################

  define("_VERSION","0.3.0alpha");
  define("_NAME","Anthill");

        include_once($GLOBALS['anthill_info']['path']['inc'] . 
'/class.anthill.inc.php');
        $GLOBALS['antill'] = new anthill();

  // set language; retrieve from user settings (no longer site dependant)
  $BROWSER_LANGUAGE = "";
  if ($_SERVER['HTTP_ACCEPT_LANGUAGE']) {
    $tmp = strtok($_SERVER['HTTP_ACCEPT_LANGUAGE'], ",");
    while ($tmp) {
      while ($tmp[0] == " ") $tmp = substr($tmp, 1);
      $BROWSER_LANGUAGE = $BROWSER_LANGUAGE . ereg_replace("-","_",$tmp) . ":";
      $tmp = strtok(",");
    }
  }
  $BROWSER_LANGUAGE = $BROWSER_LANGUAGE . "en"; // always have default to en
  // check if english is primary, if it is, do not bind textdomain in case
  // of present secondary languages
  if (substr($BROWSER_LANGUAGE, 0, 2) != "en") {
    putenv(sprintf("LANGUAGE=%s",$BROWSER_LANGUAGE));
    putenv("LC_ALL=UTF-8");
    setlocale(LC_ALL, "");
    bindtextdomain("Anthill", $_CONF['root'] . $_CONF['langdir']);
    textdomain("Anthill");
  }

  // BUG: if browser is closed and user comes back, they have to go to the
  // home page twice in order for it to recognize them as logged in
  // ie. login, close browser, open browser, homepage shows "none", go to
  // login, still shows "none", go to home and then all of a sudden you're
  // recognized

  // session checking; is user logged in?

  $_USER = do_sessioncheck();
  $user  = $_USER; // compatability

  // handle persistent cookies
  if (!isset($_COOKIE[$_CONF['cookie_name']]) || !isset($_COOKIE['password'])) {
    // either their cookie expired or they are new
    $cookietime = do_getusercookietimeout();
    if (!empty($cookietime)) {
      // persistent cookie
      setcookie($_CONF['cookie_name'],$_USER['uid'],time() + 
$cookietime,$_CONF['cookie_path'],$_CONF['webroot'],$_CONF['cookie_secure']);
      setcookie('password',$_USER['passwd'],time() + 
$cookietime,$_CONF['cookie_path'],$_CONF['webroot'],$_CONF['cookie_secure']);
    }
  } else {
    $userid = $_COOKIE[$_CONF['cookie_name']];
    if ($userid) {
      $user_logged_in = 1;
      // create new session
      $userdata       = do_getuserdatafromid($userid);
      $_USER          = $userdata;
    }
  }

  if(file_exists(sprintf("%s/%s/theme.php", $rtmpldir, $config['theme']))) {
    include_once(sprintf("%s/%s/theme.php", $rtmpldir, $config['theme']));
  }

?>






reply via email to

[Prev in Thread] Current Thread [Next in Thread]