rendered paste body# sitedb.v1.0.tcl 2004/04/14 @ GnuMatiC
#
#
# CONTACT:
# This is my first public release of a tcl that I have created. So please
# feel free and contact me with suggestions and comments about this script
# GnuMatiC on #efnet
#
#
# DISCLAIMER:
# - I TAKE NO RESPONSIBILTY IN WHAT THIS SCRIPT MAY OR MAY NOT DO TO YOUR
# - SYSTEM, OR HOW YOU CHOOSE TO USE THIS SCRIPT. USE IT AT YOUR OWN RISK!
#
#
# CHANGELOG:
# v1.0 - initial release
#
#
# DESCRIPTION:
# This is a site database script to be ran with an eggdrop. It allows users of a channel
# to add and remove sites from the database. It also allows users to update various
# information to help keep track of sites. Almost every option allows the scripter to
# fully customize which features they want to use.
# This script ALSO can be used in multiple channels, allowing only one database to be used
# but keeping that information private from the other channels, so each channel that the eggdrop
# is running in with this script, can each have their own private lists of sites.
#
#
# REQUIREMENTS:
# -mysql
# -mysqltcl
# -eggdrop
#
#
# NOTES:
# If theres any problems with this script, first make sure you have tcl and mysql working together first.
# Secondly, make sure none of the global variables or proc names conflict with any other running scripts.
#
#
# INSTRUCTIONS:
# -Define the below variables
# -Run the included .sql file. mysql -u username -p password < sitedb.v1.0.sql
# -Enable this script in eggdrop.conf ie: source scripts/sitedb.v1.0.tcl
# -Rehash/Restart your eggdrop
# -Enable one of the 3 options below, or define it to match your system.
#
# load /usr/local/lib/mysqltcl-2.12/libmysqltcl2.12.so
# package require mysqltcl
load /usr/lib/libmysqltcl2.50.so
#
# VARIABLES:
#
set cmdpre "!site" ;# Trigger you wish to use in channel
set vers "Sitedb.v1.0" ;# Version number to help in debug mode
set outprefix "\037Sitedb:\037" ;# Output prefix in channel to help layout
set db(HOST) "localhost" ;# Hostname for mysql
set db(USER) "user" ;# Username for mysql
set db(PASS) "password" ;# Password for mysql
set db(NAME) "sitesdb" ;# Database name for mysql
set db(TABLE) "sites" ;# Table name for mysql
## set to 0 to Enable and 1 to Disable
set disable(SNAME) 0 ;# Shortname - ie MSN
set disable(LNAME) 0 ;# Longname - ie My Site Name
set disable(LOCATION) 0 ;# Location - Canada
set disable(SPEED) 0 ;# Speed - DSL
set disable(SIZE) 0 ;# Size - 250gb
set disable(STATUS) 0 ;# Status - Up/Down
set disable(BNC) 0 ;# Bnc's - 1.1.1.1:1111 2.2.2.2:2222
set disable(RATING) 0 ;# Rating - 3.0
set disable(GADMIN) 0 ;# Gadmin - billgates
set disable(SLOTS) 0 ;# Slots - 10/4
set disable(AVAILRATIO) 0 ;# Available Ratio Slots - 2
set disable(AVAILLEECH) 0 ;# Available Leech Slots - 0
set disable(SECTIONS) 0 ;# Sections - XXX MOREXXX EVENMOREXXX
set disable(AFFILS) 0 ;# Affils - GROUP1 GROUP2 GROUP3
set disable(NOTES) 0 ;# Extra information - Site is closed on weekdays til 5pm!
set disable(LASTUPDATE) 0 ;# Shows who and when site was lastupdated
set disable(ADD) 0 ;# Allow new additions of sites?
set disable(DEL) 0 ;# Allow deletion of sites?
set disable(SELECT) 0 ;# Allow display of site information?
set disable(SELECTALL) 0 ;# Allow display of all added sites?
set disable(UPDATE) 0 ;# Allow ability to change site information?
set disable(SEARCH) 0 ;# Allow ability to search the information?
set disable(OPTIONS) 0 ;# Allow people to know which options you have enabled?
set disable(VERS) 0 ;# Publically announce version?
set disable(HELP) 0 ;# Allow the help menu system?
set disable(DEBUG) 0 ;# Allow debug info to be logged?
##############################################################################################
# Do not Edit BELOW!
##############################################################################################
## Get an array of enabled options
set option ""
if { $disable(SNAME) == 0 } {
append option "sname "
}
if { $disable(LNAME) == 0 } {
append option "lname "
}
if { $disable(LOCATION) == 0 } {
append option "loc "
}
if { $disable(SPEED) == 0 } {
append option "speed "
}
if { $disable(SIZE) == 0 } {
append option "size "
}
if { $disable(STATUS) == 0 } {
append option "status "
}
if { $disable(BNC) == 0 } {
append option "bnc "
}
if { $disable(RATING) == 0 } {
append option "rating "
}
if { $disable(GADMIN) == 0 } {
append option "gadmin "
}
if { $disable(SLOTS) == 0 } {
append option "slots "
}
if { $disable(AVAILRATIO) == 0 } {
append option "availratio "
}
if { $disable(AVAILLEECH) == 0 } {
append option "availleech "
}
if { $disable(SECTIONS) == 0 } {
append option "sections "
}
if { $disable(AFFILS) == 0 } {
append option "affils "
}
if { $disable(NOTES) == 0 } {
append option "notes"
}
set option [string trimleft $option]
set option [string trimright $option]
## Get an array of enabled abilities
set ability ""
if { $disable(ADD) == 0 } {
append ability "add "
}
if { $disable(DEL) == 0 } {
append ability "del "
}
set ability [string trimleft $ability]
set ability [string trimright $ability]
##############################################################################################
## Begin Main Proc
bind pub -|- [set cmdpre] sitedb
proc sitedb { nick host handle channel arg } {
global db cmdpre vers outprefix disable option ability
## Arguments equal to 0
if { [llength $arg] == 0 } {
putserv "PRIVMSG $channel :Usage: [set cmdpre] <site> <option> <value> :: For more info try [set cmdpre]help"
return 0
}
## Arguments equal to 1
if { [llength $arg] == 1 } {
if { $disable(SELECT) == 0 } {
set site [lindex $arg 0]
set site [string toupper $site]
set db_handle [mysqlconnect -host $db(HOST) -user $db(USER) -password $db(PASS) -db $db(NAME)]
set sql "SELECT * FROM $db(TABLE) WHERE channel='$channel' AND shortname='$site'"
if { $disable(DEBUG) == 0 } {
putlog "$vers: Executing $sql"
}
if { [mysqlsel $db_handle $sql] == 0 } {
putserv "PRIVMSG $channel :$outprefix $site is not a valid Site!"
mysqlclose $db_handle
return 0
}
mysqlmap $db_handle { id time handle host channel sname lname location speed size status bnc rating gadmin slots availratio availleech sections affils notes } {
set time [clock format $time -format "%H:%M on %m-%d-%Y"]
if { $disable(SNAME) == 0 } {
putserv "PRIVMSG $channel :--------------- $sname --------------"
}
if { $disable(LNAME) == 0 } {
putserv "PRIVMSG $channel :------- $lname -------"
}
if { $disable(LOCATION) == 0 } {
putserv "PRIVMSG $channel :--- Location :: $location"
}
if { $disable(SPEED) == 0 } {
putserv "PRIVMSG $channel :--- Speed :: $speed"
}
if { $disable(SIZE) == 0 } {
putserv "PRIVMSG $channel :--- Size :: $size"
}
if { $disable(STATUS) == 0 } {
putserv "PRIVMSG $channel :--- Current Status :: $status"
}
if { $disable(RATING) == 0 } {
putserv "PRIVMSG $channel :--- Rating :: $rating"
}
if { $disable(BNC) == 0 } {
putserv "PRIVMSG $channel :--- Bnc(s) :: $bnc"
}
if { $disable(GADMIN) == 0 } {
putserv "PRIVMSG $channel :--- Gadmin :: $gadmin"
}
if { $disable(SLOTS) == 0 } {
putserv "PRIVMSG $channel :--- Slots :: $slots"
}
if { $disable(AVAILRATIO) == 0 } {
putserv "PRIVMSG $channel :--- Open Ratio :: $availratio"
}
if { $disable(AVAILLEECH) == 0 } {
putserv "PRIVMSG $channel :--- Open Leech :: $availleech"
}
if { $disable(SECTIONS) == 0 } {
putserv "PRIVMSG $channel :--- Sections :: $sections"
}
if { $disable(AFFILS) == 0 } {
putserv "PRIVMSG $channel :--- Affils :: $affils"
}
if { $disable(NOTES) == 0 } {
putserv "PRIVMSG $channel :--- Notes :: $notes"
}
if { $disable(LASTUPDATE) == 0 } {
putserv "PRIVMSG $channel :--- Last Updated: $time by $handle ($host)"
}
}
mysqlclose $db_handle
} else {
putserv "PRIVMSG $channel :$outprefix Usage: [set cmdpre] <site> <option> <value> :: For more info try [set cmdpre]help"
}
}
## Arguments equal to 2
if { [llength $arg] == 2 } {
set site [lindex $arg 0]
set site [string toupper $site]
set myability [lindex $arg 1]
set abilitylength [llength $ability]
set failed 0
##############################################################################################
## Options
if { "$myability" == "options" } {
if { $disable(OPTIONS) == 0 } {
putserv "PRIVMSG $channel :Available options are: $option"
return 0
} else {
putserv "PRIVMSG $channel :Usage: [set cmdpre] <site> <option> <value> :: For more info try [set cmdpre]help"
return 0
}
}
## check to see if ability is enabled, otherwise exit
foreach newability $ability {
if { "$myability" != "$newability" } {
incr failed
}
}
if { "$abilitylength" == "$failed" } {
putserv "PRIVMSG $channel :Usage: [set cmdpre] <site> <option> <value> :: For more info try [set cmdpre]help"
return 0
}
##############################################################################################
## Add
if { "$myability" == "add" } {
set sqlcheck "SELECT * FROM $db(TABLE) WHERE channel='$channel' AND shortname='$site'"
set sql "INSERT INTO $db(TABLE) VALUES"
append sql "(null, '[clock seconds]', '$nick', '$host', '$channel', '$site', "
append sql "'N/A', 'N/A', 'N/A', 'N/A', 'N/A', 'N/A', 'N/A', 'N/A', 'N/A', 'N/A', 'N/A', 'N/A', 'N/A', 'N/A')"
if { $disable(DEBUG) == 0 } {
putlog "$vers: Checking if $site exists ..."
putlog "$vers: Executing $sqlcheck"
}
set db_handle [mysqlconnect -host $db(HOST) -user $db(USER) -password $db(PASS) -db $db(NAME)]
if { [mysqlsel $db_handle $sqlcheck] != 0 } {
putserv "PRIVMSG $channel :$outprefix $site already exists!"
return 0
}
if { $disable(DEBUG) == 0 } {
putlog "$vers: $site does not exist ..."
putlog "$vers: Executing $sql"
}
set result [mysqlexec $db_handle $sql]
if { $result != 1 } {
if { $disable(DEBUG) == 0 } {
putlog "$outprefix An error occurred with the database"
}
putserv "PRIVMSG $channel :$outprefix There is a problem with your database, please inform your admin"
return 0
} else {
putserv "PRIVMSG $channel :$outprefix $nick just added $site"
}
mysqlclose $db_handle
}
##############################################################################################
## Delete
if { "$myability" == "del" } {
set sql "DELETE FROM $db(TABLE) WHERE shortname='$site' AND channel='$channel'"
if { $disable(DEBUG) == 0 } {
putlog "$vers: Executing $sql"
}
set db_handle [mysqlconnect -host $db(HOST) -user $db(USER) -password $db(PASS) -db $db(NAME)]
set result [mysqlexec $db_handle $sql]
if { $result != 1 } {
putserv "PRIVMSG $channel :$outprefix $site is not a valid Site!"
return 0
} else {
putserv "PRIVMSG $channel :$outprefix $nick just deleted $site"
}
mysqlclose $db_handle
}
}
## Arguments greater than 2
if { [llength $arg] > 2 } {
set site [lindex $arg 0]
set site [string toupper $site]
set myoption [lindex $arg 1]
set optionlength [llength $option]
set failed 0
## Check to see if we should even continue
if { $disable(UPDATE) != 0 } {
putserv "PRIVMSG $channel :$outprefix Updating has been disabled"
return 0
}
## Check to see if option is enabled, otherwise exit.
foreach newoption $option {
if { "$myoption" != "$newoption" } {
incr failed
}
}
if { "$optionlength" == "$failed" } {
putserv "PRIVMSG $channel :Usage: [set cmdpre] <site> <option> <value> :: For more info try [set cmdpre]help"
return 0
}
##############################################################################################
## Update - SNAME
if { "$myoption" == "sname" } {
set sname [lindex $arg 2]
set sname [string toupper $sname]
if { [llength $arg] == 3 } {
set sql "UPDATE $db(TABLE) SET shortname='$sname', timestamp='[clock seconds]', nick='$nick', host='$host' WHERE shortname='$site' AND channel='$channel'"
if { $disable(DEBUG) == 0 } {
putlog "$vers: Executing $sql"
}
set db_handle [mysqlconnect -host $db(HOST) -user $db(USER) -password $db(PASS) -db $db(NAME)]
set result [mysqlexec $db_handle $sql]
if { $result != 1 } {
putserv "PRIVMSG $channel :$outprefix $site is not a valid Site!"
return 0
} else {
putserv "PRIVMSG $channel :$outprefix $nick just changed $site to $sname"
}
mysqlclose $db_handle
} else {
putserv "PRIVMSG $channel :Usage: [set cmdpre] <site> sname <value>"
return 0
}
}
##############################################################################################
## Update - LNAME
if { "$myoption" == "lname" } {
set lname [lrange $arg 2 end]
set sql "UPDATE $db(TABLE) SET longname='$lname', timestamp='[clock seconds]', nick='$nick', host='$host' WHERE shortname='$site' AND channel='$channel'"
if { $disable(DEBUG) == 0 } {
putlog "$vers: Executing $sql"
}
set db_handle [mysqlconnect -host $db(HOST) -user $db(USER) -password $db(PASS) -db $db(NAME)]
set result [mysqlexec $db_handle $sql]
if { $result != 1 } {
putserv "PRIVMSG $channel :$outprefix $site is not a valid Site!"
return 0
} else {
putserv "PRIVMSG $channel :$outprefix $nick just updated the longname of $site to $lname"
}
mysqlclose $db_handle
}
##############################################################################################
## Update - LOCATION
if { "$myoption" == "loc" } {
set loc [lrange $arg 2 end]
set sql "UPDATE $db(TABLE) SET location='$loc', timestamp='[clock seconds]', nick='$nick', host='$host' WHERE shortname='$site' AND channel='$channel'"
if { $disable(DEBUG) == 0 } {
putlog "$vers: Executing $sql"
}
set db_handle [mysqlconnect -host $db(HOST) -user $db(USER) -password $db(PASS) -db $db(NAME)]
set result [mysqlexec $db_handle $sql]
if { $result != 1 } {
putserv "PRIVMSG $channel :$outprefix $site is not a valid Site!"
return 0
} else {
putserv "PRIVMSG $channel :$outprefix $nick just updated the location of $site to $loc"
}
mysqlclose $db_handle
}
##############################################################################################
## Update - SPEED
if { "$myoption" == "speed" } {
set speed [lrange $arg 2 end]
set sql "UPDATE $db(TABLE) SET speed='$speed', timestamp='[clock seconds]', nick='$nick', host='$host' WHERE shortname='$site' AND channel='$channel'"
if { $disable(DEBUG) == 0 } {
putlog "$vers: Executing $sql"
}
set db_handle [mysqlconnect -host $db(HOST) -user $db(USER) -password $db(PASS) -db $db(NAME)]
set result [mysqlexec $db_handle $sql]
if { $result != 1 } {
putserv "PRIVMSG $channel :$outprefix $site is not a valid Site!"
return 0
} else {
putserv "PRIVMSG $channel :$outprefix $nick just updated the speed of $site to $speed"
}
mysqlclose $db_handle
}
##############################################################################################
## Update - SIZE
if { "$myoption" == "size" } {
set size [lrange $arg 2 end]
set sql "UPDATE $db(TABLE) SET size='$size', timestamp='[clock seconds]', nick='$nick', host='$host' WHERE shortname='$site' AND channel='$channel'"
if { $disable(DEBUG) == 0 } {
putlog "$vers: Executing $sql"
}
set db_handle [mysqlconnect -host $db(HOST) -user $db(USER) -password $db(PASS) -db $db(NAME)]
set result [mysqlexec $db_handle $sql]
if { $result != 1 } {
putserv "PRIVMSG $channel :$outprefix $site is not a valid Site!"
return 0
} else {
putserv "PRIVMSG $channel :$outprefix $nick just updated the size of $site to $size"
}
mysqlclose $db_handle
}
##############################################################################################
## Update - STATUS
if { "$myoption" == "status" } {
set status [lrange $arg 2 end]
set sql "UPDATE $db(TABLE) SET status='$status', timestamp='[clock seconds]', nick='$nick', host='$host' WHERE shortname='$site' AND channel='$channel'"
if { $disable(DEBUG) == 0 } {
putlog "$vers: Executing $sql"
}
set db_handle [mysqlconnect -host $db(HOST) -user $db(USER) -password $db(PASS) -db $db(NAME)]
set result [mysqlexec $db_handle $sql]
if { $result != 1 } {
putserv "PRIVMSG $channel :$outprefix $site is not a valid Site!"
return 0
} else {
putserv "PRIVMSG $channel :$outprefix $nick just updated the status of $site to $status"
}
mysqlclose $db_handle
}
##############################################################################################
## Update - BNC
if { "$myoption" == "bnc" } {
set bnc [lrange $arg 2 end]
set sql "UPDATE $db(TABLE) SET bnc='$bnc', timestamp='[clock seconds]', nick='$nick', host='$host' WHERE shortname='$site' AND channel='$channel'"
if { $disable(DEBUG) == 0 } {
putlog "$vers: Executing $sql"
}
set db_handle [mysqlconnect -host $db(HOST) -user $db(USER) -password $db(PASS) -db $db(NAME)]
set result [mysqlexec $db_handle $sql]
if { $result != 1 } {
putserv "PRIVMSG $channel :$outprefix $site is not a valid Site!"
return 0
} else {
putserv "PRIVMSG $channel :$outprefix $nick just updated the bnc(s) of $site to $bnc"
}
mysqlclose $db_handle
}
##############################################################################################
## Update - RATING
if { "$myoption" == "rating" } {
set rating [lrange $arg 2 end]
set sql "UPDATE $db(TABLE) SET rating='$rating', timestamp='[clock seconds]', nick='$nick', host='$host' WHERE shortname='$site' AND channel='$channel'"
if { $disable(DEBUG) == 0 } {
putlog "$vers: Executing $sql"
}
set db_handle [mysqlconnect -host $db(HOST) -user $db(USER) -password $db(PASS) -db $db(NAME)]
set result [mysqlexec $db_handle $sql]
if { $result != 1 } {
putserv "PRIVMSG $channel :$outprefix $site is not a valid Site!"
return 0
} else {
putserv "PRIVMSG $channel :$outprefix $nick just updated the rating of $site to $rating"
}
mysqlclose $db_handle
}
##############################################################################################
## Update - GADMIN
if { "$myoption" == "gadmin" } {
set gadmin [lrange $arg 2 end]
set sql "UPDATE $db(TABLE) SET gadmin='$gadmin', timestamp='[clock seconds]', nick='$nick', host='$host' WHERE shortname='$site' AND channel='$channel'"
if { $disable(DEBUG) == 0 } {
putlog "$vers: Executing $sql"
}
set db_handle [mysqlconnect -host $db(HOST) -user $db(USER) -password $db(PASS) -db $db(NAME)]
set result [mysqlexec $db_handle $sql]
if { $result != 1 } {
putserv "PRIVMSG $channel :$outprefix $site is not a valid Site!"
return 0
} else {
putserv "PRIVMSG $channel :$outprefix $nick just updated the gadmin of $site to $gadmin"
}
mysqlclose $db_handle
}
##############################################################################################
## Update - SLOTS
if { "$myoption" == "slots" } {
set slots [lrange $arg 2 end]
set sql "UPDATE $db(TABLE) SET slots='$slots', timestamp='[clock seconds]', nick='$nick', host='$host' WHERE shortname='$site' AND channel='$channel'"
if { $disable(DEBUG) == 0 } {
putlog "$vers: Executing $sql"
}
set db_handle [mysqlconnect -host $db(HOST) -user $db(USER) -password $db(PASS) -db $db(NAME)]
set result [mysqlexec $db_handle $sql]
if { $result != 1 } {
putserv "PRIVMSG $channel :$outprefix $site is not a valid Site!"
return 0
} else {
putserv "PRIVMSG $channel :$outprefix $nick just updated the slots of $site to $slots"
}
mysqlclose $db_handle
}
##############################################################################################
## Update - AVAILRATIO
if { "$myoption" == "availratio" } {
set aratio [lrange $arg 2 end]
set sql "UPDATE $db(TABLE) SET availratio='$aratio', timestamp='[clock seconds]', nick='$nick', host='$host' WHERE shortname='$site' AND channel='$channel'"
if { $disable(DEBUG) == 0 } {
putlog "$vers: Executing $sql"
}
set db_handle [mysqlconnect -host $db(HOST) -user $db(USER) -password $db(PASS) -db $db(NAME)]
set result [mysqlexec $db_handle $sql]
if { $result != 1 } {
putserv "PRIVMSG $channel :$outprefix $site is not a valid Site!"
return 0
} else {
putserv "PRIVMSG $channel :$outprefix $nick just updated the available ratio slots of $site to $aratio"
}
mysqlclose $db_handle
}
##############################################################################################
## Update - AVAILLEECH
if { "$myoption" == "availleech" } {
set aleech [lrange $arg 2 end]
set sql "UPDATE $db(TABLE) SET availleech='$aleech', timestamp='[clock seconds]', nick='$nick', host='$host' WHERE shortname='$site' AND channel='$channel'"
if { $disable(DEBUG) == 0 } {
putlog "$vers: Executing $sql"
}
set db_handle [mysqlconnect -host $db(HOST) -user $db(USER) -password $db(PASS) -db $db(NAME)]
set result [mysqlexec $db_handle $sql]
if { $result != 1 } {
putserv "PRIVMSG $channel :$outprefix $site is not a valid Site!"
return 0
} else {
putserv "PRIVMSG $channel :$outprefix $nick just updated the available leech slots of $site to $aleech"
}
mysqlclose $db_handle
}
##############################################################################################
## Update - SECTIONS
if { "$myoption" == "sections" } {
set section [lrange $arg 2 end]
set sql "UPDATE $db(TABLE) SET sections='$section', timestamp='[clock seconds]', nick='$nick', host='$host' WHERE shortname='$site' AND channel='$channel'"
if { $disable(DEBUG) == 0 } {
putlog "$vers: Executing $sql"
}
set db_handle [mysqlconnect -host $db(HOST) -user $db(USER) -password $db(PASS) -db $db(NAME)]
set result [mysqlexec $db_handle $sql]
if { $result != 1 } {
putserv "PRIVMSG $channel :$outprefix $site is not a valid Site!"
return 0
} else {
putserv "PRIVMSG $channel :$outprefix $nick just updated the sections of $site to $section"
}
mysqlclose $db_handle
}
##############################################################################################
## Update - AFFILS
if { "$myoption" == "affils" } {
set affils [lrange $arg 2 end]
set sql "UPDATE $db(TABLE) SET affils='$affils', timestamp='[clock seconds]', nick='$nick', host='$host' WHERE shortname='$site' AND channel='$channel'"
if { $disable(DEBUG) == 0 } {
putlog "$vers: Executing $sql"
}
set db_handle [mysqlconnect -host $db(HOST) -user $db(USER) -password $db(PASS) -db $db(NAME)]
set result [mysqlexec $db_handle $sql]
if { $result != 1 } {
putserv "PRIVMSG $channel :$outprefix $site is not a valid Site!"
return 0
} else {
putserv "PRIVMSG $channel :$outprefix $nick just updated the affils of $site to $affils"
}
mysqlclose $db_handle
}
##############################################################################################
## Update - NOTES
if { "$myoption" == "notes" } {
set notes [lrange $arg 2 end]
set sql "UPDATE $db(TABLE) SET notes='$notes', timestamp='[clock seconds]', nick='$nick', host='$host' WHERE shortname='$site' AND channel='$channel'"
if { $disable(DEBUG) == 0 } {
putlog "$vers: Executing $sql"
}
set db_handle [mysqlconnect -host $db(HOST) -user $db(USER) -password $db(PASS) -db $db(NAME)]
set result [mysqlexec $db_handle $sql]
if { $result != 1 } {
putserv "PRIVMSG $channel :$outprefix $site is not a valid Site!"
return 0
} else {
putserv "PRIVMSG $channel :$outprefix $nick just updated the notes of $site to $notes"
}
mysqlclose $db_handle
}
}
}
## End Main proc
##############################################################################################
## Display All Sites
if { $disable(SELECTALL) == 0 } {
bind pub -|- [set cmdpre]s sites
proc sites { nick host handle channel arg } {
global db cmdpre vers outprefix disable
if { [llength $arg] == 0 } {
set db_handle [mysqlconnect -host $db(HOST) -user $db(USER) -password $db(PASS) -db $db(NAME)]
set sql "SELECT shortname FROM $db(TABLE) WHERE channel='$channel'"
if { $disable(DEBUG) == 0 } {
putlog "$vers: Executing $sql"
}
set result [mysqlsel $db_handle $sql]
if { $result == 0 } {
putserv "PRIVMSG $channel :$outprefix Available Sites ($result) :: No Sites Found!"
mysqlclose $db_handle
return 0
}
mysqlmap $db_handle {sname} {
append newsname " $sname"
}
putserv "PRIVMSG $channel :$outprefix Available Sites ($result) ::$newsname"
mysqlclose $db_handle
} else {
putserv "PRIVMSG $channel :Usage: [set cmdpre]s"
return 0
}
}
}
##############################################################################################
## Search
if { $disable(SEARCH) == 0 } {
bind pub -|- "[set cmdpre]search" search
proc search { nick host handle channel arg } {
global db cmdpre vers outprefix disable
set search [lrange $arg 0 end]
if { [llength $arg] > 0 } {
set db_handle [mysqlconnect -host $db(HOST) -user $db(USER) -password $db(PASS) -db $db(NAME)]
set sql "SELECT shortname FROM $db(TABLE) WHERE channel='$channel' AND ("
set options "Currently Searching: "
if { $disable(LOCATION) == 0 } {
append sql "location LIKE '%$search%' OR "
append options "Location, "
}
if { $disable(SPEED) == 0 } {
append sql "speed LIKE '%$search%' OR "
append options "Speed, "
}
if { $disable(STATUS) == 0 } {
append sql "status LIKE '%$search%' OR "
append options "Status, "
}
if { $disable(RATING) == 0 } {
append sql "rating LIKE '%$search%' OR "
append options "Rating, "
}
if { $disable(GADMIN) == 0 } {
append sql "gadmin LIKE '%$search%' OR "
append options "Gadmin, "
}
if { $disable(AVAILRATIO) == 0 } {
append sql "availratio LIKE '%$search%' OR "
append options "Open Ratio, "
}
if { $disable(AVAILLEECH) == 0 } {
append sql "availleech LIKE '%$search%' OR "
append options "Open Leech, "
}
if { $disable(SECTIONS) == 0 } {
append sql "sections LIKE '%$search%' OR "
append options "Sections, "
}
if { $disable(AFFILS) == 0 } {
append sql "affils LIKE '%$search%' OR "
append options "Affils, "
}
## this part is messy and needs to be cleaned up
set lenoptions [string length $options]
set lenoptions [expr $lenoptions - 3]
set lensql [string length $sql]
set lensql [expr $lensql - 5]
set options [string range $options 0 $lenoptions]
set sql [string range $sql 0 $lensql]
append sql ")"
if { $disable(DEBUG) == 0 } {
putlog "$vers: Executing $sql"
}
putserv "PRIVMSG $channel :$outprefix $options"
if { [mysqlsel $db_handle $sql] == 0 } {
putserv "PRIVMSG $channel :$outprefix No results found!"
mysqlclose $db_handle
return 0
}
mysqlmap $db_handle {sname} {
append newsname " $sname"
}
putserv "PRIVMSG $channel :$outprefix $newsname contains Search results"
mysqlclose $db_handle
} else {
putserv "PRIVMSG $channel :Usage: [set cmdpre]search <text>"
}
}
}
##############################################################################################
## Version
if { $disable(VERS) == 0 } {
bind pub -|- "[set cmdpre]ver" ver
proc ver { nick host handle channel arg } {
global vers outprefix
putserv "PRIVMSG $channel :$outprefix $vers"
}
}
##############################################################################################
## Help menu
if { $disable(HELP) == 0 } {
bind pub -|- "[set cmdpre]help" help
proc help { nick host handle channel arg } {
global cmdpre vers disable option
puthelp "NOTICE $nick :-------- $vers Help menu --------"
if { $disable(ADD) == 0 } {
puthelp "NOTICE $nick :[set cmdpre] <site> add - Adds site"
}
if { $disable(DEL) == 0 } {
puthelp "NOTICE $nick :[set cmdpre] <site> del - Deletes site"
}
if { $disable(SELECT) == 0 } {
puthelp "NOTICE $nick :[set cmdpre] <site> - Displays all info on site"
}
if { $disable(SELECTALL) == 0 } {
puthelp "NOTICE $nick :[set cmdpre]s - Displays all added sites"
}
if { $disable(UPDATE) == 0 } {
puthelp "NOTICE $nick :[set cmdpre] <site> <option> <value> - Change options"
}
if { $disable(OPTIONS) == 0 } {
puthelp "NOTICE $nick :[set cmdpre] <site> options - Displays available options"
}
if { $disable(SEARCH) == 0 } {
puthelp "NOTICE $nick :[set cmdpre]search <text> - Searches for text"
}
if { $disable(VERS) == 0 } {
puthelp "NOTICE $nick :[set cmdpre]ver - Displays version of this script"
}
if { $disable(HELP) == 0 } {
puthelp "NOTICE $nick :[set cmdpre]help - Displays this menu"
}
if { $disable(OPTIONS) == 0 } {
puthelp "NOTICE $nick :Available options: $option"
}
puthelp "NOTICE $nick :-------- $vers End Help menu --------"
}
}
putlog "Loaded $vers"
## EOF ##