gaim/www

Initial import into CVS
chipx86 start
2002-09-26, Christian Hammond
2b210e25fed4
Parents 88252774b05f
Children
Initial import into CVS
  • +0 -0
    htdocs/images/screenshots/tabbed.gif
  • +0 -0
    htdocs/images/screenshots/tabbed_t.gif
  • +1 -0
    htdocs/images/statusicons/.cvsignore
  • +1 -0
    htdocs/images/statusicons/aim/.cvsignore
  • +0 -0
    htdocs/images/statusicons/aim/activebuddy.gif
  • +0 -0
    htdocs/images/statusicons/aim/admin.gif
  • +0 -0
    htdocs/images/statusicons/aim/aol.gif
  • +0 -0
    htdocs/images/statusicons/aim/away.gif
  • +0 -0
    htdocs/images/statusicons/aim/confirmed.gif
  • +0 -0
    htdocs/images/statusicons/aim/offline.gif
  • +0 -0
    htdocs/images/statusicons/aim/unconfirmed.gif
  • +0 -0
    htdocs/images/statusicons/aim/wireless.gif
  • +1 -0
    htdocs/images/statusicons/gg/.cvsignore
  • +0 -0
    htdocs/images/statusicons/gg/away.gif
  • +0 -0
    htdocs/images/statusicons/gg/busy.gif
  • +0 -0
    htdocs/images/statusicons/gg/invisible.gif
  • +0 -0
    htdocs/images/statusicons/gg/online.gif
  • +1 -0
    htdocs/images/statusicons/icq/.cvsignore
  • +0 -0
    htdocs/images/statusicons/icq/away.gif
  • +0 -0
    htdocs/images/statusicons/icq/dnd.gif
  • +0 -0
    htdocs/images/statusicons/icq/ffc.gif
  • +0 -0
    htdocs/images/statusicons/icq/na.gif
  • +0 -0
    htdocs/images/statusicons/icq/occ.gif
  • +0 -0
    htdocs/images/statusicons/icq/offline.gif
  • +0 -0
    htdocs/images/statusicons/icq/online.gif
  • +1 -0
    htdocs/images/statusicons/irc/.cvsignore
  • +0 -0
    htdocs/images/statusicons/irc/offline.gif
  • +0 -0
    htdocs/images/statusicons/irc/online.gif
  • +1 -0
    htdocs/images/statusicons/jabber/.cvsignore
  • +0 -0
    htdocs/images/statusicons/jabber/available.gif
  • +0 -0
    htdocs/images/statusicons/jabber/away.gif
  • +0 -0
    htdocs/images/statusicons/jabber/chat.gif
  • +0 -0
    htdocs/images/statusicons/jabber/dnd.gif
  • +0 -0
    htdocs/images/statusicons/jabber/error.gif
  • +0 -0
    htdocs/images/statusicons/jabber/offline.gif
  • +0 -0
    htdocs/images/statusicons/jabber/xa.gif
  • +1 -0
    htdocs/images/statusicons/msn/.cvsignore
  • +0 -0
    htdocs/images/statusicons/msn/away.gif
  • +0 -0
    htdocs/images/statusicons/msn/occupied.gif
  • +0 -0
    htdocs/images/statusicons/msn/offline.gif
  • +0 -0
    htdocs/images/statusicons/msn/online.gif
  • +1 -0
    htdocs/images/statusicons/napster/.cvsignore
  • +0 -0
    htdocs/images/statusicons/napster/online.gif
  • +1 -0
    htdocs/images/statusicons/yahoo/.cvsignore
  • +0 -0
    htdocs/images/statusicons/yahoo/away.gif
  • +0 -0
    htdocs/images/statusicons/yahoo/game.gif
  • +0 -0
    htdocs/images/statusicons/yahoo/idle.gif
  • +0 -0
    htdocs/images/statusicons/yahoo/offline.gif
  • +0 -0
    htdocs/images/statusicons/yahoo/online.gif
  • +121 -0
    htdocs/oldplugins/misc/grumpy.c
  • +253 -0
    inc/database.inc.php
  • +214 -0
    inc/plugins.inc.php
  • +180 -0
    inc/sessions.inc.php
  • +182 -0
    inc/users.inc.php
  • +113 -0
    inc/utils.inc.php
  • +41 -0
    sql/plugins.sql
  • Binary file htdocs/images/screenshots/tabbed.gif has changed
    Binary file htdocs/images/screenshots/tabbed_t.gif has changed
    --- /dev/null Thu Jan 01 00:00:00 1970 +0000
    +++ b/htdocs/images/statusicons/.cvsignore Thu Sep 26 06:23:23 2002 -0400
    @@ -0,0 +1,1 @@
    +.xvpics
    --- /dev/null Thu Jan 01 00:00:00 1970 +0000
    +++ b/htdocs/images/statusicons/aim/.cvsignore Thu Sep 26 06:23:23 2002 -0400
    @@ -0,0 +1,1 @@
    +.xvpics
    Binary file htdocs/images/statusicons/aim/activebuddy.gif has changed
    Binary file htdocs/images/statusicons/aim/admin.gif has changed
    Binary file htdocs/images/statusicons/aim/aol.gif has changed
    Binary file htdocs/images/statusicons/aim/away.gif has changed
    Binary file htdocs/images/statusicons/aim/confirmed.gif has changed
    Binary file htdocs/images/statusicons/aim/offline.gif has changed
    Binary file htdocs/images/statusicons/aim/unconfirmed.gif has changed
    Binary file htdocs/images/statusicons/aim/wireless.gif has changed
    --- /dev/null Thu Jan 01 00:00:00 1970 +0000
    +++ b/htdocs/images/statusicons/gg/.cvsignore Thu Sep 26 06:23:23 2002 -0400
    @@ -0,0 +1,1 @@
    +.xvpics
    Binary file htdocs/images/statusicons/gg/away.gif has changed
    Binary file htdocs/images/statusicons/gg/busy.gif has changed
    Binary file htdocs/images/statusicons/gg/invisible.gif has changed
    Binary file htdocs/images/statusicons/gg/online.gif has changed
    --- /dev/null Thu Jan 01 00:00:00 1970 +0000
    +++ b/htdocs/images/statusicons/icq/.cvsignore Thu Sep 26 06:23:23 2002 -0400
    @@ -0,0 +1,1 @@
    +.xvpics
    Binary file htdocs/images/statusicons/icq/away.gif has changed
    Binary file htdocs/images/statusicons/icq/dnd.gif has changed
    Binary file htdocs/images/statusicons/icq/ffc.gif has changed
    Binary file htdocs/images/statusicons/icq/na.gif has changed
    Binary file htdocs/images/statusicons/icq/occ.gif has changed
    Binary file htdocs/images/statusicons/icq/offline.gif has changed
    Binary file htdocs/images/statusicons/icq/online.gif has changed
    --- /dev/null Thu Jan 01 00:00:00 1970 +0000
    +++ b/htdocs/images/statusicons/irc/.cvsignore Thu Sep 26 06:23:23 2002 -0400
    @@ -0,0 +1,1 @@
    +.xvpics
    Binary file htdocs/images/statusicons/irc/offline.gif has changed
    Binary file htdocs/images/statusicons/irc/online.gif has changed
    --- /dev/null Thu Jan 01 00:00:00 1970 +0000
    +++ b/htdocs/images/statusicons/jabber/.cvsignore Thu Sep 26 06:23:23 2002 -0400
    @@ -0,0 +1,1 @@
    +.xvpics
    Binary file htdocs/images/statusicons/jabber/available.gif has changed
    Binary file htdocs/images/statusicons/jabber/away.gif has changed
    Binary file htdocs/images/statusicons/jabber/chat.gif has changed
    Binary file htdocs/images/statusicons/jabber/dnd.gif has changed
    Binary file htdocs/images/statusicons/jabber/error.gif has changed
    Binary file htdocs/images/statusicons/jabber/offline.gif has changed
    Binary file htdocs/images/statusicons/jabber/xa.gif has changed
    --- /dev/null Thu Jan 01 00:00:00 1970 +0000
    +++ b/htdocs/images/statusicons/msn/.cvsignore Thu Sep 26 06:23:23 2002 -0400
    @@ -0,0 +1,1 @@
    +.xvpics
    Binary file htdocs/images/statusicons/msn/away.gif has changed
    Binary file htdocs/images/statusicons/msn/occupied.gif has changed
    Binary file htdocs/images/statusicons/msn/offline.gif has changed
    Binary file htdocs/images/statusicons/msn/online.gif has changed
    --- /dev/null Thu Jan 01 00:00:00 1970 +0000
    +++ b/htdocs/images/statusicons/napster/.cvsignore Thu Sep 26 06:23:23 2002 -0400
    @@ -0,0 +1,1 @@
    +.xvpics
    Binary file htdocs/images/statusicons/napster/online.gif has changed
    --- /dev/null Thu Jan 01 00:00:00 1970 +0000
    +++ b/htdocs/images/statusicons/yahoo/.cvsignore Thu Sep 26 06:23:23 2002 -0400
    @@ -0,0 +1,1 @@
    +.xvpics
    Binary file htdocs/images/statusicons/yahoo/away.gif has changed
    Binary file htdocs/images/statusicons/yahoo/game.gif has changed
    Binary file htdocs/images/statusicons/yahoo/idle.gif has changed
    Binary file htdocs/images/statusicons/yahoo/offline.gif has changed
    Binary file htdocs/images/statusicons/yahoo/online.gif has changed
    --- /dev/null Thu Jan 01 00:00:00 1970 +0000
    +++ b/htdocs/oldplugins/misc/grumpy.c Thu Sep 26 06:23:23 2002 -0400
    @@ -0,0 +1,121 @@
    +#define GAIM_PLUGINS
    +
    +// grumpy.c -- inspired by the spell-check plugin, but i thought it
    +// would be too messy to tack this onto its split-on-punctuation
    +// logic.
    +//
    +// Copyright 2000 Decklin Foster, <decklin@red-bean.com>, GPLed (see
    +// the top-level gaim source dir for your copy).
    +
    +#include "gaim.h"
    +#include <string.h>
    +#include <stdlib.h>
    +
    +// isn't this next line just disgusting?
    +
    +const char *munge = "<b></b>";
    +
    +// and we put that after the first char in any of these. "O:-)" has
    +// it's own graphic, but will be caught looking for ":-)". Entries on
    +// the same line have the same graphic.
    +
    +const char *smileys[] = {
    + ":-D",
    + ":-!",
    + ":-X",
    + ":'(",
    + ":-[",
    + ":-*",
    + ":-$",
    + ":-(", ":(",
    + "=-O",
    + ":-)", ":)",
    + "8-)",
    + ":-/",
    + ":-P", ":P", ":-p", ":p",
    + ";-)", ";)",
    + ">:o",
    + NULL
    +};
    +
    +// this is bad -- free should barf if dest is auto. either g_free
    +// checks this or i'm very lucky. need a better way to prevent
    +// memleaks here. (when i doubt, blame the plugin interface for
    +// forcing me to munge strings like this ;-)
    +
    +static void insert_str(char **dest, size_t pos, const char *src)
    +{
    + char *new = g_malloc(strlen(*dest) + strlen(src) + 1);
    +
    + //printf(" inserting '%s' into '%s' @ %d\n", src, *dest, pos);
    + if (!new) {
    + fprintf(stderr, "yipes! can't g_malloc.\n");
    + return;
    + }
    +
    + strcpy(new, *dest);
    + strcpy(new+pos, src);
    + strcpy(new+pos+strlen(src), *dest+pos);
    + //printf(" result: '%s'\n", new);
    +
    + g_free(*dest);
    + *dest = new;
    +}
    +
    +// There are probably more efficent ways to do this, given that half
    +// our keys start with ':'. Do I care? ha!
    +
    +static void munge_smileys(struct gaim_connection *gc, char *buddy,
    + char **im, void *cb_data)
    +{
    + const char **s;
    + char *p;
    +
    + if (!im) return;
    + //printf("im: '%s'\n", *im);
    +
    + for (s = smileys; *s; s++) {
    + //printf("looking for: '%s'\n", *s);
    + p = *im;
    + while (p = strstr(p, *s)) {
    + //printf(" got substr: '%s'\n", p);
    + insert_str(im, p - *im + 1, munge);
    + //printf(" advancing %d chars\n", strlen(*s));
    + p += strlen(*s);
    + //printf(" p is now: '%s'\n", p);
    + }
    + }
    +}
    +
    +// what's my name? say my name, bitch!
    +
    +char *name()
    +{
    + return "Grumpifier";
    +}
    +
    +char *description()
    +{
    + return "Munges smiley faces so that your buddy's AIM software won't "
    + "display them as pictures. Fight the evil forces of cuteness!";
    +}
    +
    +// these GAIM weirdos really need to use capital letters for their
    +// constants or something. 'handle'? wuzzat? (hi Rob ;-)
    +
    +char *gaim_plugin_init(GModule *handle)
    +{
    + gaim_signal_connect(handle, event_im_send, munge_smileys, NULL);
    + gaim_signal_connect(handle, event_chat_send, munge_smileys, NULL);
    + return NULL;
    +}
    +
    +void gaim_plugin_remove()
    +{
    + // dave's not here, man...
    +}
    +
    +void gaim_plugin_config()
    +{
    + // FIXME: make a dialog box for stupid people
    +}
    --- /dev/null Thu Jan 01 00:00:00 1970 +0000
    +++ b/inc/database.inc.php Thu Sep 26 06:23:23 2002 -0400
    @@ -0,0 +1,253 @@
    +<?php
    +/*
    + * $Id$
    + *
    + * Portal In A Bottle
    + * Database routines
    + * Copyright (C) 1999 Portal Web Design. All rights reserved.
    + *
    + * A class implementing database routines with support for
    + * many types of databases.
    + * For use with the Portal In A Bottle toolkit.
    + *
    + * Part of the Portal In A Bottle base utilities.
    + */
    +
    + class Database {
    + var $dbclass;
    +
    + var $host;
    + var $username;
    + var $password;
    + var $database;
    +
    + var $result;
    +
    + /********************************************************************
    + * function Database($db_server_type, $host, $username, $password,
    + * $database)
    + * $db_server_type - Database type, defaults to "mysql"
    + * $host - Host where the database server resides
    + * $username - Username for the database
    + * $password - Password for the database
    + * $database - Database name
    + *
    + * Constructor
    + ********************************************************************/
    + function Database($dbserver_type = "mysql", $host = "localhost", $username = "", $password = "", $database = "") {
    + $dbserver_type = strtolower($dbserver_type);
    +// if (empty($host)) { fatal_error("Host required"); }
    +
    + if (empty($username)) {
    + fatal_error("Username required");
    + }
    +
    + if ($dbserver_type == "mysql") {
    + $this->dbclass = new Database_MySQL();
    + }
    + else {
    + fatal_error("This database format is not supported!");
    + }
    +
    + $this->dbclass->host = $host;
    + $this->dbclass->username = $username;
    + $this->dbclass->password = $password;
    + $this->dbclass->database = $database;
    + }
    +
    + /********************************************************************
    + * function connect()
    + *
    + * Connects to the database
    + ********************************************************************/
    + function connect() {
    + $this->dbclass->connect();
    + }
    +
    + /********************************************************************
    + * function disconnect()
    + *
    + * Closes the connection to the database
    + ********************************************************************/
    + function disconnect() {
    + $this->dbclass->disconnect();
    + }
    +
    + /********************************************************************
    + * function set_database($db)
    + * $db - Database name
    + *
    + * Sets which database to use
    + ********************************************************************/
    + function set_database($db) {
    + $this->dbclass->database = $db;
    + }
    +
    + /********************************************************************
    + * function get_database()
    + *
    + * Returns the name of the current database.
    + ********************************************************************/
    + function get_database() {
    + return($this->dbclass->database);
    + }
    +
    + /********************************************************************
    + * function query($query)
    + * $query - the SQL query
    + *
    + * Queries the database
    + ********************************************************************/
    + function query($query) {
    + $this->free_result();
    +// print "SQL Call = {$query}<br />\n";
    + $this->dbclass->query($query);
    + }
    +
    + /********************************************************************
    + * function row_exists($rowname)
    + * $rowname - The name of the row
    + *
    + * Returns TRUE if the specified row exists. FALSE otherwise.
    + ********************************************************************/
    + function row_exists($rowname) {
    + $this->free_result();
    + return $this->row_exists($rowname);
    + }
    +
    + /********************************************************************
    + * function result_array()
    + *
    + * Returns the result in array form
    + ********************************************************************/
    + function result_array() {
    + return($this->dbclass->result_array());
    + }
    +
    + /********************************************************************
    + * function valid_result()
    + *
    + * Returns TRUE if the result is not NULL, FALSE otherwise.
    + ********************************************************************/
    + function valid_result() {
    + if (empty($this->dbclass->result)) {
    + return FALSE;
    + }
    +
    + return TRUE;
    + }
    +
    + /********************************************************************
    + * function num_rows()
    + *
    + * Returns the number of rows in the previous query.
    + ********************************************************************/
    + function num_rows() {
    + return($this->dbclass->num_rows());
    + }
    +
    + /********************************************************************
    + * function free_result()
    + *
    + * Frees the $result.
    + ********************************************************************/
    + function free_result() {
    + $this->dbclass->free_result();
    + }
    +
    + function get_insert_id() {
    + return $this->dbclass->get_insert_id();
    + }
    + }
    +
    +
    +/*********************************************************************/
    +
    +
    + /********************************************************************
    + * class Database_MySQL extends Database
    + *
    + * MySQL database implementation
    + ********************************************************************/
    + class Database_MySQL extends Database {
    +
    + function Database_MySQL() {}
    +
    + /********************************************************************
    + * function connect()
    + *
    + * Connects to the database
    + ********************************************************************/
    + function connect() {
    + mysql_pconnect($this->host, $this->username, $this->password)
    + or fatal_error(mysql_error());
    + }
    +
    + /********************************************************************
    + * function disconnect()
    + *
    + * Closes the connection to the database
    + ********************************************************************/
    + function disconnect() {
    + /*
    + * We want a persistant connection. This would defeat the purpose.
    + */
    +// mysql_close();
    + }
    +
    + /********************************************************************
    + * function query($query)
    + * $query - SQL query
    + *
    + * Queries the database
    + ********************************************************************/
    + function query($query) {
    + $this->result = mysql_db_query($this->database, $query)
    + or fatal_error(mysql_error());
    + }
    +
    + /********************************************************************
    + * function row_exists($rowname)
    + * $rowname - The name of the row
    + * $key - The key to use in the COUNT() (optional)
    + * $misc - Misc. stuff
    + *
    + * Returns TRUE if the specified row exists. FALSE otherwise.
    + ********************************************************************/
    + function row_exists($rowname, $key = "*", $misc = "") {
    + $this->query("SELECT COUNT($key) FROM $this->database");
    + }
    +
    + /********************************************************************
    + * function result_array()
    + *
    + * Returns the result in an array form
    + ********************************************************************/
    + function result_array() {
    + return(mysql_fetch_array($this->result));
    + }
    +
    + /********************************************************************
    + * function num_rows()
    + *
    + * Returns the number of rows in the previous query.
    + ********************************************************************/
    + function num_rows() {
    + return(mysql_num_rows($this->result));
    + }
    +
    + /********************************************************************
    + * function free_result()
    + *
    + * Frees the $result.
    + ********************************************************************/
    + function free_result() {
    + //mysql_free_result($this->result);
    + unset($this->result);
    + }
    +
    + function get_insert_id() {
    + return mysql_insert_id();
    + }
    + }
    +?>
    --- /dev/null Thu Jan 01 00:00:00 1970 +0000
    +++ b/inc/plugins.inc.php Thu Sep 26 06:23:23 2002 -0400
    @@ -0,0 +1,214 @@
    +<?php
    + class Plugins
    + {
    + function Plugins()
    + {
    + }
    +
    + function do_plugin_query($sql)
    + {
    + global $db;
    +
    + $db->query($sql);
    +
    + if ($db->num_rows() > 0)
    + {
    + while ($info = $db->result_array())
    + {
    + $plugins[$info["PLUGIN_ID"]] = $info;
    + }
    +
    + return $plugins;
    + }
    +
    + return NULL;
    + }
    +
    + function get_plugin_count()
    + {
    + global $db;
    +
    + $db->query("SELECT COUNT(*) FROM Plugins");
    +
    + $result = $db->result_array();
    +
    + return $result[0]["COUNT(*)"];
    + }
    +
    + function get_all_plugins($start = 0, $limit = 25)
    + {
    + return $this->do_plugin_query(
    + "SELECT Plugins.*, Users.USER_ID, Users.USERNAME," .
    + " Users.FIRSTNAME, Users.LASTNAME FROM Plugins, Users" .
    + " WHERE Plugins.USER_ID=Users.USER_ID LIMIT $start,$limit"
    + );
    + }
    +
    + function get_popular_plugins($limit = 10)
    + {
    + return $this->do_plugin_query(
    + "SELECT Plugins.*, Users.USER_ID, Users.USERNAME," .
    + " Users.FIRSTNAME, Users.LASTNAME FROM Plugins, Users" .
    + " WHERE Plugins.USER_ID=Users.USER_ID AND" .
    + " Plugins.DOWNLOAD_COUNT > 1" .
    + " ORDER BY DOWNLOAD_COUNT DESC LIMIT $limit"
    + );
    + }
    +
    + function get_users_plugins($user_id)
    + {
    + return $this->do_plugin_query(
    + "SELECT * FROM Plugins WHERE USER_ID=" . $user_id
    + );
    + }
    +
    + function get_plugin_author($plugin_id)
    + {
    + global $db;
    +
    + $db->query(
    + "SELECT Users.* FROM Users, Plugins" .
    + " WHERE Plugins.PLUGIN_ID=" . $plugin_id .
    + " AND Users.USER_ID=Plugins.PLUGIN_ID"
    + );
    +
    + if ($db->num_rows() > 0)
    + return $db->result_array();
    +
    + return NULL;
    + }
    +
    + function get_plugin($plugin_id)
    + {
    + global $db;
    +
    + $db->query(
    + "SELECT Plugins.*, Users.USER_ID, Users.USERNAME," .
    + " Users.FIRSTNAME, Users.LASTNAME FROM Plugins, Users" .
    + " WHERE Plugins.PLUGIN_ID=" . $plugin_id . " AND " .
    + " Plugins.USER_ID=Users.USER_ID"
    + );
    +
    + if ($db->num_rows() > 0)
    + return $db->result_array();
    +
    + return NULL;
    + }
    +
    + function add_plugin($userid, $name, $version, $url, $homepage,
    + $filesize, $brief, $description)
    + {
    + global $db;
    +
    + $name = addslashes($name);
    + $version = addslashes($version);
    + $url = addslashes($url);
    + $homepage = addslashes($homepage);
    + $brief = addslashes($brief);
    + $description = addslashes($description);
    +
    + $db->query(
    + "INSERT INTO Plugins VALUES(0, $userid, \"$name\","
    + . " \"$version\", \"$url\", \"$homepage\", $filesize,"
    + . " \"$brief\", \"$description\", NOW(), NOW(), 0, 0)"
    + );
    + }
    +
    + function update_plugin($plugin_id, $name, $version, $url, $homepage,
    + $filesize, $brief, $description)
    + {
    + global $db;
    +
    + $name = addslashes($name);
    + $version = addslashes($version);
    + $url = addslashes($url);
    + $homepage = addslashes($homepage);
    + $brief = addslashes($brief);
    + $description = addslashes($description);
    +
    + $db->query(
    + "UPDATE Plugins SET NAME=\"$name\", VERSION=\"$version\"," .
    + " URL=\"$url\", HOMEPAGE=\"$homepage\", FILESIZE=$filesize," .
    + " BRIEF=\"$brief\", DESCRIPTION=\"$description\", " .
    + " UPDATED=NOW() WHERE PLUGIN_ID=" . $plugin_id
    + );
    + }
    +
    + function delete_plugin($plugin_id)
    + {
    + global $db;
    +
    + $db->query(
    + "DELETE FROM Plugins WHERE PLUGIN_ID=" . $plugin_id
    + );
    + }
    +
    + function update_download_count($plugin_id)
    + {
    + global $db;
    +
    + $db->query(
    + "UPDATE Plugins SET DOWNLOAD_COUNT=DOWNLOAD_COUNT+1" .
    + " WHERE PLUGIN_ID=" . $plugin_id
    + );
    + }
    +
    + function update_view_count($plugin_id)
    + {
    + global $db;
    +
    + $db->query(
    + "UPDATE Plugins SET VIEW_COUNT=VIEW_COUNT+1" .
    + " WHERE PLUGIN_ID=" . $plugin_id
    + );
    + }
    +
    + function get_search_count($keywords, $type)
    + {
    + global $db;
    +
    + $keywords = strtolower(str_replace(" ", "|", $keywords));
    +
    + $querystr = "SELECT COUNT(*) FROM Plugins WHERE LOWER(";
    +
    + if ($type == "name")
    + $querystr .= "NAME";
    + else
    + $querystr .= "DESCRIPTION";
    +
    + $querystr .= ") REGEXP \"(" . $keywords . ")\"";
    +
    + if ($type != "name")
    + $querystr .= " OR LOWER(BRIEF) REGEXP \"(" . $keywords . ")\"";
    +
    + $db->query($querystr);
    +
    + $result = $db->result_array();
    +
    + return $result[0]["COUNT(*)"];
    + }
    +
    + function search_plugins($keywords, $type, $start, $limit)
    + {
    + global $db;
    +
    + $keywords = strtolower(str_replace(" ", "|", $keywords));
    +
    + $querystr = "SELECT * FROM Plugins WHERE LOWER(";
    +
    + if ($type == "name")
    + $querystr .= "NAME";
    + else
    + $querystr .= "DESCRIPTION";
    +
    + $querystr .= ") REGEXP \"(" . $keywords . ")\"";
    +
    + if ($type != "name")
    + $querystr .= " OR LOWER(BRIEF) REGEXP \"(" . $keywords . ")\"";
    +
    + $querystr .= " LIMIT $start,$limit";
    +
    + return $this->do_plugin_query($querystr);
    + }
    + }
    +?>
    --- /dev/null Thu Jan 01 00:00:00 1970 +0000
    +++ b/inc/sessions.inc.php Thu Sep 26 06:23:23 2002 -0400
    @@ -0,0 +1,180 @@
    +<?php
    + class Session {
    + var $sid = ""; /* Session ID */
    +
    + /********************************************************************
    + * function Session()
    + *
    + * The Session() constructor
    + ********************************************************************/
    + function Session() {
    + }
    +
    + function startSession() {
    + global $sid, $username, $db;
    + global $HTTP_COOKIE_VARS, $HTTP_GET_VARS, $HTTP_POST_VARS;
    + global $PHP_SELF;
    +
    + if ((!isset($sid)) || (empty($sid))) { return; }
    +
    + $this->sid = $sid = urldecode($sid);
    +
    + $db->query(
    + "SELECT * FROM Users WHERE SESSION_ID='" . $sid . "'"
    + );
    +
    + if ($db->num_rows() == 0) {
    + /*
    + * Oops, a cookie is set but there is no session info.
    + * You know what we have to do... KILL THE COOKIE!
    + */
    + setcookie("sid", "", 0);
    + unset($GLOBALS["sid"]);
    + unset($HTTP_COOKIE_VARS["sid"]);
    + unset($this->sid);
    + }
    + }
    +
    + function login($username, $password) {
    + global $db, $users;
    + global $HTTP_USER_AGENT, $PHP_SELF, $HTTP_COOKIE_VARS;
    +
    + $missinginfo = false;
    +
    + $GLOBALS["username_missing"] = false;
    + $GLOBALS["password_missing"] = false;
    +
    + if ($username != "") {
    + if (!$users->user_exists($username)) {
    + $GLOBALS["username_missing"] = -1;
    + $GLOBALS["password_missing"] = -1;
    + $missinginfo = true;
    + }
    + }
    + else {
    + if ($username == "") {
    + $GLOBALS["username_missing"] = -1;
    + $missinginfo = true;
    + }
    + if ($password == "") {
    + $GLOBALS["password_missing"] = -1;
    + $missinginfo = true;
    + }
    + }
    +
    + if ($missinginfo) { return false; }
    +
    + if ($users->logged_in()) {
    + return true;
    + }
    +
    + $db->query(
    + "SELECT * FROM Users WHERE USERNAME='".$username."'"
    + );
    +
    + if ($db->num_rows() > 0) {
    + $info = $db->result_array();
    + $salt = substr($info["PASSWORD"], 0, 2);
    + $newpass = crypt($password, $salt);
    +
    + if ($newpass != $info["PASSWORD"]) {
    + return false;
    + }
    +
    + $this->sid = $this->generate_get_sid();
    +
    + $db->query(
    + "UPDATE Users SET SESSION_ID='" . $this->sid . "'"
    + . " WHERE USER_ID=" . $info["USER_ID"]
    + );
    +
    + $HTTP_COOKIE_VARS["sid"] = $this->sid;
    +
    + $expdate = time() + 63072000;
    + setcookie("sid", $this->sid, $expdate);
    +
    + header("Location: " . $this->localUrl($PHP_SELF) . "\n");
    + exit;
    + }
    +
    + return false;
    +
    + }
    +
    + /********************************************************************
    + * function generate_get_sid()
    + *
    + * Generates a Session ID based on the date/time and IP address.
    + ********************************************************************/
    + function generate_get_sid() {
    + return "s" . md5(uniqid(rand()));
    + }
    +
    + /********************************************************************
    + * function get_sid()
    + *
    + * Returns the session ID in a pib_sessionid=... way.
    + ********************************************************************/
    + function get_sid() {
    + return "sid=" . urlencode($this->sid);
    + }
    +
    + /********************************************************************
    + * function sid_value()
    + *
    + * Returns the session ID.
    + ********************************************************************/
    + function sid_value() {
    + return urlencode($this->sid);
    + }
    +
    + function localUrl($url) {
    + return $url;
    +
    +/*
    + if (empty($this->sid)) {
    + return $url . "?";
    + } else {
    + return $url . "?" . $this->get_sid();
    + }
    +*/
    + }
    +
    + function hidden_sid() {
    + return "";
    +
    +/*
    + if (empty($this->sid)) {
    + return "";
    + } else {
    + return "<input type=\"hidden\" name=\"sid\""
    + . " value=\"" . $this->get_sid() . "\" />";
    + }
    +*/
    + }
    +
    + /********************************************************************
    + * function destroy()
    + *
    + * Destroys the Session and removes all data and variables
    + * associated with it.
    + ********************************************************************/
    + function destroy() {
    + global $db;
    + global $PHP_SELF;
    +
    + $db->query(
    + "UPDATE Users SET SESSION_ID='' WHERE SESSION_ID='" .
    + $this->sid . "'"
    + );
    +
    + /* We don't care if this is a valid result or not. */
    + /* If it doesn't exist already, it's already deleted :) */
    +
    + unset($this->sid);
    +
    +// header("Location: $PHP_SELF");
    +// exit;
    + }
    + }
    +?>
    --- /dev/null Thu Jan 01 00:00:00 1970 +0000
    +++ b/inc/users.inc.php Thu Sep 26 06:23:23 2002 -0400
    @@ -0,0 +1,182 @@
    +<?php
    + class Users {
    +
    + var $user_info = array();
    + var $is_logged_in = false;
    +
    + function Users() {
    + global $sid, $db;
    +
    + if (empty($sid)) {
    + $this->is_logged_in = false;
    + return;
    + }
    +
    + $db->query(
    + "SELECT * FROM Users WHERE SESSION_ID='" . $sid . "'"
    + );
    +
    + if ($db->num_rows() > 0) {
    + $this->user_info = $db->result_array();
    +
    + $this->is_logged_in = true;
    + }
    + }
    +
    + function logged_in() {
    + global $sid;
    +
    + return $this->is_logged_in;
    + }
    +
    + function login($username, $password) {
    + global $session;
    +
    + if ($session->login($username, $password)) {
    + $this->is_logged_in = true;
    + return true;
    + } else {
    + return false;
    + }
    + }
    +
    + function logout() {
    + global $session;
    +
    + $session->destroy();
    +
    + $this->is_logged_in = false;
    + }
    +
    + function user_exists($username) {
    + global $db;
    +
    + $db->query("SELECT * FROM Users WHERE USERNAME='$username'");
    +
    + if ($db->num_rows() > 0) {
    + $info = $db->result_array();
    + if (!empty($info["USERNAME"])) {
    + return true;
    + }
    + }
    +
    + return false;
    + }
    +
    + function get_user_info_from_id($userid) {
    + global $db;
    +
    + if ($userid == -1) { return NULL; }
    +
    + if ($userid == $this->user_info["USER_ID"]) {
    + return $this->user_info;
    + }
    +
    + $db->query(
    + "SELECT * FROM Users WHERE USER_ID=" . $userid
    + );
    +
    + if ($db->num_rows() > 0) {
    + return $db->result_array();
    + }
    +
    + return NULL;
    + }
    +
    + function get_user_info_from_username($username) {
    + global $db;
    +
    + if ($username == "") { return NULL; }
    +
    + if ($username == $this->user_info["USERNAME"]) {
    + return $this->user_info;
    + }
    +
    + $db->query(
    + "SELECT * FROM Users WHERE USERNAME='" . $username . "'"
    + );
    +
    + if ($db->num_rows() > 0) {
    + return $db->result_array();
    + }
    +
    + return NULL;
    + }
    +
    + function get_active_user_username() {
    + return $this->user_info["USERNAME"];
    + }
    +
    + function get_active_user_id() {
    + return $this->user_info["USER_ID"];
    + }
    +
    + function is_active_user_admin() {
    + return ($this->user_info["ADMIN"] == "Y");
    + }
    +
    + function get_active_user_info() {
    + return $this->user_info;
    + }
    +
    + function change_password($username, $newpassword) {
    + global $db;
    +
    + $seed = genseed();
    + $newpass = crypt($newpassword, $seed);
    +
    + $db->query(
    + "UPDATE Users SET PASSWORD='$newpass'"
    + . " WHERE USERNAME='$username'"
    + );
    + }
    +
    + function register() {
    + global $db, $session;
    +
    + $bakusername = $GLOBALS["username"];
    +
    + $requiredinfo = array("username", "password", "password2");
    +
    + $missinginfo = false;
    +
    + for ($i = 0; $i < count($requiredinfo); $i++) {
    + if (empty($GLOBALS[$requiredinfo[$i]])) {
    + $GLOBALS[$requiredinfo[$i]] = -1;
    + $missinginfo = true;
    + }
    + }
    +
    + if ($bakusername != "") {
    + if ($this->user_exists($bakusername)) {
    + $GLOBALS["username"] = -2;
    + $missinginfo = true;
    + }
    + }
    +
    + if ($GLOBALS["password"] != $GLOBALS["password2"]) {
    + $GLOBALS["password"] = -1;
    + $GLOBALS["password2"] = -1;
    + }
    +
    + if ($missinginfo) { return false; }
    +
    + $seed = genseed();
    + $newpass = crypt($GLOBALS["password"], $seed);
    +
    + $db->query(
    + "INSERT INTO Users VALUES(0, '$GLOBALS[username]', "
    + . "'$newpass', '$GLOBALS[firstname]', '$GLOBALS[lastname]', "
    + . "'$GLOBALS[email]', '$GLOBALS[icquin]', '$GLOBALS[aimname]', "
    + . "'$GLOBALS[yahooname]', '$GLOBALS[jabbername]', "
    + . "'$GLOBALS[msnname]', '$GLOBALS[ggname]', '', 'N')"
    + );
    +
    + if (!$db->valid_result()) {
    + return false;
    + }
    +
    + return true;
    + }
    + }
    +?>
    --- /dev/null Thu Jan 01 00:00:00 1970 +0000
    +++ b/inc/utils.inc.php Thu Sep 26 06:23:23 2002 -0400
    @@ -0,0 +1,113 @@
    +<?php
    + function setup_site($title = "") {
    + global $db, $session, $users;
    + global $sql_type, $sql_server, $sql_username, $sql_password;
    + global $sql_database;
    + global $setup_ran;
    +
    + if ($setup_ran == false) {
    + $setup_ran = true;
    +
    + /* Connect to the database. */
    + $db = new Database($sql_type, $sql_server, $sql_username,
    + $sql_password, $sql_database);
    + $db->connect();
    +
    + /* Session management. */
    + $session = new Session();
    + $session->startSession();
    +
    + $users = new Users();
    + }
    +
    + if ($title != -1) {
    + start_html($title);
    + }
    + }
    +
    + function fatal_error($error) {
    + echo "<b>Fatal error:</b> " . $error . "<br />\n";
    + site_shutdown();
    + exit;
    + }
    +
    + function site_shutdown() {
    + end_html();
    + exit;
    + }
    +
    + function genseed() {
    + function rannum() {
    + mt_srand((double)microtime()*1000000);
    + $num = mt_rand(46,122);
    + return($num);
    + }
    + function genchr() {
    + do {
    + $num = rannum();
    + } while (($num > 57 && $num < 65) || ($num > 90 && $num < 97));
    +
    + $char = chr($num);
    + return($char);
    + }
    + $a = genchr();
    + $b = genchr();
    + $salt = "$a$b";
    + return($salt);
    + }
    +
    + function form_item($desc, $name, $value = "", $required = false,
    + $size = "", $maxlength = "") {
    + global $missinginfo;
    +
    + print " <tr>\n";
    + print " <td align=\"right\" nowrap=\"nowrap\">";
    +
    + if ($required) {
    + print "<font color=\"#FF0000\">*</font> ";
    + }
    +
    + start_font();
    +
    + print "<b>";
    +
    + if ($missinginfo
    + && (($value == -1 || $value == -2)
    + || ($name == "password" || $name == "password2"))) {
    + print "<font color=\"#FF0000\">" . $desc . ":</font>";
    + }
    + else {
    + print $desc . ":";
    + }
    +
    + end_font();
    +
    + print "</b>&nbsp;</td>\n";
    +
    + print " <td width=\"60%\">";
    +
    + start_font();
    +
    + print "<input type=\"";
    +
    + if ($name == "password" || $name == "password2") {
    + print "password";
    + } else {
    + print "text";
    + }
    +
    + print "\" name=\"" . $name . "\"";
    +
    + if ($value != -1 && $value != -2 && $value != "") {
    + print " value=\"" . $value . "\"";
    + }
    +
    + if ($size != "") { print " size=\"" . $size . "\""; }
    + if ($maxlength != "") { print " maxlength=\"" . $maxlength . "\""; }
    +
    + print " />";
    + end_font();
    + print "</td>\n";
    + print " </tr>\n";
    + }
    +?>
    --- /dev/null Thu Jan 01 00:00:00 1970 +0000
    +++ b/sql/plugins.sql Thu Sep 26 06:23:23 2002 -0400
    @@ -0,0 +1,41 @@
    +CREATE TABLE IF NOT EXISTS Users (
    + USER_ID INT NOT NULL AUTO_INCREMENT,
    + USERNAME VARCHAR(15) NOT NULL,
    + PASSWORD VARCHAR(15) NOT NULL,
    + FIRSTNAME VARCHAR(20),
    + LASTNAME VARCHAR(20),
    +
    + EMAIL VARCHAR(85) NOT NULL,
    + ICQUIN VARCHAR(20),
    + AIMNAME VARCHAR(40),
    + YAHOONAME VARCHAR(40),
    + JABBERNAME VARCHAR(40),
    + MSNNAME VARCHAR(40),
    + GGNAME VARCHAR(20),
    +
    + SESSION_ID VARCHAR(255) NOT NULL,
    +
    + ADMIN CHAR(1) NOT NULL DEFAULT 'N',
    +
    + PRIMARY KEY (USER_ID),
    + UNIQUE (USERNAME)
    +);
    +
    +CREATE TABLE IF NOT EXISTS Plugins (
    + PLUGIN_ID INT NOT NULL AUTO_INCREMENT,
    + USER_ID INT NOT NULL,
    + NAME VARCHAR(128) NOT NULL,
    + VERSION VARCHAR(16) NOT NULL,
    + URL VARCHAR(255) NOT NULL,
    + HOMEPAGE VARCHAR(255),
    + FILESIZE INT NOT NULL,
    + BRIEF VARCHAR(255) NOT NULL
    + DESCRIPTION BLOB NOT NULL,
    + CREATED DATETIME NOT NULL,
    + UPDATED DATETIME NOT NULL,
    +
    + VIEW_COUNT INT,
    + DOWNLOAD_COUNT INT,
    +
    + PRIMARY KEY (PLUGIN_ID)
    +);